From beb020b11a8cd4ef1b3d5ed9af9cc018ce02e868 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 6 Jun 2025 04:53:07 +0000 Subject: [PATCH 1/2] Add `compiler-builtins` to bootstrap --- src/bootstrap/src/core/build_steps/test.rs | 62 ++++++++++++++++++++++ src/bootstrap/src/core/builder/mod.rs | 1 + 2 files changed, 63 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index ebb926d81cef4..0c429024874e4 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2731,6 +2731,68 @@ impl Step for Crate { } } +/// Test compiler-builtins via its testcrate. +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct CompilerBuiltins { + compiler: Compiler, + target: TargetSelection, + mode: Mode, +} + +impl Step for CompilerBuiltins { + type Output = (); + const DEFAULT: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.paths(&["library/compiler-builtins", "library/compiler-builtins/compiler-builtins"]) + } + + fn make_run(run: RunConfig<'_>) { + let builder = run.builder; + let host = run.build_triple(); + let compiler = builder.compiler_for(builder.top_stage, host, host); + + builder.ensure(CompilerBuiltins { compiler, target: run.target, mode: Mode::Std }); + } + + fn run(self, builder: &Builder<'_>) -> Self::Output { + let compiler = self.compiler; + let target = self.target; + let mode = self.mode; + + builder.ensure(compile::Std::new(compiler, compiler.host).force_recompile(true)); + let compiler = builder.compiler_for(compiler.stage, compiler.host, target); + + // Also prepare a sysroot for the target. + if !builder.config.is_host_target(target) { + builder.ensure(compile::Std::new(compiler, target).force_recompile(true)); + builder.ensure(RemoteCopyLibs { compiler, target }); + } + + let make_cargo = |f: fn(&mut builder::Cargo) -> &mut builder::Cargo| { + let mut c = builder::Cargo::new( + builder, + compiler, + mode, + SourceType::InTree, + target, + Kind::Test, + ); + f(&mut c); + c + }; + + // Most tests are in the builtins-test crate. + let crates = ["compiler-builtins".to_string(), "builtins-test".to_string()]; + let cargo = make_cargo(|c| c); + run_cargo_test(cargo, &[], &crates, "compiler-buitlins", target, builder); + let cargo = make_cargo(|c| c.arg("--release")); + run_cargo_test(cargo, &[], &crates, "compiler-buitlins --release", target, builder); + let cargo = make_cargo(|c| c.arg("--features=c")); + run_cargo_test(cargo, &[], &crates, "compiler-buitlins --features c", target, builder); + } +} + /// Rustdoc is special in various ways, which is why this step is different from `Crate`. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CrateRustdoc { diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 887db683f7899..81c0069ef35e7 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -1027,6 +1027,7 @@ impl<'a> Builder<'a> { test::HtmlCheck, test::RustInstaller, test::TestFloatParse, + test::CompilerBuiltins, test::CollectLicenseMetadata, // Run bootstrap close to the end as it's unlikely to fail test::Bootstrap, From b08b4033998c4a95dd28746036c298b65ca8c03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Mon, 16 Jun 2025 11:05:02 +0200 Subject: [PATCH 2/2] Simplify bootstrap step --- src/bootstrap/src/core/build_steps/test.rs | 28 +++++++--------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 0c429024874e4..161fecd229074 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2736,7 +2736,6 @@ impl Step for Crate { pub struct CompilerBuiltins { compiler: Compiler, target: TargetSelection, - mode: Mode, } impl Step for CompilerBuiltins { @@ -2744,52 +2743,43 @@ impl Step for CompilerBuiltins { const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.paths(&["library/compiler-builtins", "library/compiler-builtins/compiler-builtins"]) + run.path("library/compiler-builtins") } fn make_run(run: RunConfig<'_>) { let builder = run.builder; let host = run.build_triple(); - let compiler = builder.compiler_for(builder.top_stage, host, host); + let compiler = builder.compiler(builder.top_stage, host); - builder.ensure(CompilerBuiltins { compiler, target: run.target, mode: Mode::Std }); + builder.ensure(CompilerBuiltins { compiler, target: run.target }); } fn run(self, builder: &Builder<'_>) -> Self::Output { let compiler = self.compiler; let target = self.target; - let mode = self.mode; - builder.ensure(compile::Std::new(compiler, compiler.host).force_recompile(true)); - let compiler = builder.compiler_for(compiler.stage, compiler.host, target); - - // Also prepare a sysroot for the target. - if !builder.config.is_host_target(target) { - builder.ensure(compile::Std::new(compiler, target).force_recompile(true)); - builder.ensure(RemoteCopyLibs { compiler, target }); - } + builder.ensure(compile::Std::new(compiler, target)); let make_cargo = |f: fn(&mut builder::Cargo) -> &mut builder::Cargo| { let mut c = builder::Cargo::new( builder, compiler, - mode, + Mode::ToolStd, SourceType::InTree, target, Kind::Test, ); + c.current_dir(&builder.src.join("library").join("compiler-builtins")); f(&mut c); c }; // Most tests are in the builtins-test crate. - let crates = ["compiler-builtins".to_string(), "builtins-test".to_string()]; + let crates = ["compiler_builtins".to_string(), "builtins-test".to_string()]; let cargo = make_cargo(|c| c); - run_cargo_test(cargo, &[], &crates, "compiler-buitlins", target, builder); - let cargo = make_cargo(|c| c.arg("--release")); - run_cargo_test(cargo, &[], &crates, "compiler-buitlins --release", target, builder); + run_cargo_test(cargo, &[], &crates, "compiler-builtins", target, builder); let cargo = make_cargo(|c| c.arg("--features=c")); - run_cargo_test(cargo, &[], &crates, "compiler-buitlins --features c", target, builder); + run_cargo_test(cargo, &[], &crates, "compiler-builtins --features c", target, builder); } }