From fbb9c925ef15051a57cd016b7271f75078d2443b Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 6 Jun 2025 04:53:07 +0000 Subject: [PATCH 1/3] Add `CompilerBuiltins` bootstrap test step --- src/bootstrap/src/core/build_steps/test.rs | 95 +++++++++++++++++++ .../builder/cli_paths/snapshots/x_test.snap | 3 + .../snapshots/x_test_skip_coverage.snap | 3 + .../snapshots/x_test_skip_coverage_map.snap | 3 + .../snapshots/x_test_skip_coverage_run.snap | 3 + .../snapshots/x_test_skip_tests.snap | 3 + .../snapshots/x_test_skip_tests_coverage.snap | 3 + .../snapshots/x_test_skip_tests_etc.snap | 3 + src/bootstrap/src/core/builder/mod.rs | 1 + 9 files changed, 117 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 70a97c8b87826..e8907757a2dca 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -3746,6 +3746,101 @@ impl CommandLineStep for Crate { } } +/// Test compiler-builtins via its testcrate. +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct CompilerBuiltins { + compiler: Compiler, + target: TargetSelection, +} + +impl CommandLineStep for CompilerBuiltins { + type Output = (); + + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.alias("compiler-builtins") + } + + fn make_run(run: RunConfig<'_>) { + let builder = run.builder; + let host = run.build_triple(); + let compiler = builder.compiler(builder.top_stage, host); + + builder.ensure(CompilerBuiltins { compiler, target: run.target }); + } + + fn run(self, builder: &Builder<'_>) -> Self::Output { + let compiler = self.compiler; + let target = self.target; + let record_failed_tests = builder.ensure(SetupFailedTestsFile); + + builder.ensure(compile::Std::new(compiler, target)); + + const COMPILER_BUILTINS_ALLOW_FEATURES: &[&str] = &[ + // tidy-alphabetical-start + "abi_custom", + "asm_experimental_arch", + "cfg_target_has_atomic", + "compiler_builtins", + "compiler_builtins_lib", + "complex_numbers", + "core_intrinsics", + "decl_macro", + "f16", + "f128", + "lang_items", + "linkage", + "macro_metavar_expr_concat", + "repr_simd", + "rustc_attrs", + "rustc_private", + "wasm_numeric_instr", + // tidy-alphabetical-end + ]; + + let make_cargo = |f: fn(&mut builder::Cargo) -> &mut builder::Cargo| { + let mut cargo = builder::Cargo::new( + builder, + compiler, + Mode::ToolStd, + SourceType::InTree, + target, + Kind::Test, + ); + cargo.current_dir(&builder.src.join("library").join("compiler-builtins")); + cargo.allow_features(&COMPILER_BUILTINS_ALLOW_FEATURES.join(",")); + f(&mut cargo); + cargo + }; + + // 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-builtins", + target, + builder, + record_failed_tests.clone(), + ); + let cargo = make_cargo(|c| c.arg("--features=c")); + run_cargo_test( + cargo, + &[], + &crates, + "compiler-builtins --features c", + target, + builder, + record_failed_tests, + ); + } +} + /// Run cargo tests for the rustdoc crate. /// Rustdoc is special in various ways, which is why this step is different from `Crate`. #[derive(Debug, Clone, PartialEq, Eq, Hash)] diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap index 0967b604412e6..1fe97ca766c81 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap @@ -217,6 +217,9 @@ expression: test [Test] test::TestFloatParse targets: [aarch64-unknown-linux-gnu] - Set({src/tools/test-float-parse}) +[Test] test::CompilerBuiltins + targets: [aarch64-unknown-linux-gnu] + - Set({compiler-builtins}) [Test] test::RunMake targets: [aarch64-unknown-linux-gnu] - Suite(tests/run-make) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap index cd835904b00d1..f112cdafa81b3 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap @@ -214,6 +214,9 @@ expression: test --skip=coverage [Test] test::TestFloatParse targets: [aarch64-unknown-linux-gnu] - Set({src/tools/test-float-parse}) +[Test] test::CompilerBuiltins + targets: [aarch64-unknown-linux-gnu] + - Set({compiler-builtins}) [Test] test::RunMake targets: [aarch64-unknown-linux-gnu] - Suite(tests/run-make) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap index 0801bdf09328f..401cdc8432d2f 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap @@ -217,6 +217,9 @@ expression: test --skip=coverage-map [Test] test::TestFloatParse targets: [aarch64-unknown-linux-gnu] - Set({src/tools/test-float-parse}) +[Test] test::CompilerBuiltins + targets: [aarch64-unknown-linux-gnu] + - Set({compiler-builtins}) [Test] test::RunMake targets: [aarch64-unknown-linux-gnu] - Suite(tests/run-make) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap index d7ec4e55cc710..01d5b362e928f 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap @@ -217,6 +217,9 @@ expression: test --skip=coverage-run [Test] test::TestFloatParse targets: [aarch64-unknown-linux-gnu] - Set({src/tools/test-float-parse}) +[Test] test::CompilerBuiltins + targets: [aarch64-unknown-linux-gnu] + - Set({compiler-builtins}) [Test] test::RunMake targets: [aarch64-unknown-linux-gnu] - Suite(tests/run-make) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap index bee21f9fd3b91..b936eeefe8805 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap @@ -163,6 +163,9 @@ expression: test --skip=tests [Test] test::TestFloatParse targets: [aarch64-unknown-linux-gnu] - Set({src/tools/test-float-parse}) +[Test] test::CompilerBuiltins + targets: [aarch64-unknown-linux-gnu] + - Set({compiler-builtins}) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - Set({intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap index afa6039d5cba2..c7ea1c663a030 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap @@ -214,6 +214,9 @@ expression: test --skip=tests/coverage [Test] test::TestFloatParse targets: [aarch64-unknown-linux-gnu] - Set({src/tools/test-float-parse}) +[Test] test::CompilerBuiltins + targets: [aarch64-unknown-linux-gnu] + - Set({compiler-builtins}) [Test] test::RunMake targets: [aarch64-unknown-linux-gnu] - Suite(tests/run-make) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap index 20c8ec8b25a9a..98b39e619fad8 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap @@ -143,6 +143,9 @@ expression: test --skip=tests --skip=library --skip=tidyselftest [Test] test::TestFloatParse targets: [aarch64-unknown-linux-gnu] - Set({src/tools/test-float-parse}) +[Test] test::CompilerBuiltins + targets: [aarch64-unknown-linux-gnu] + - Set({compiler-builtins}) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - Set({intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 1359733089eee..44445fe74d3b0 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -938,6 +938,7 @@ impl<'a> Builder<'a> { test::HtmlCheck, test::RustInstaller, test::TestFloatParse, + test::CompilerBuiltins, test::CollectLicenseMetadata, test::RunMake, test::RunMakeCargo, From 80fbc1dac573085fdd5e8285a8ae7a5c95e4428f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 20 Oct 2026 10:09:37 +0200 Subject: [PATCH 2/3] Vendor `compiler-builtins` dependencies --- src/bootstrap/src/core/build_steps/test.rs | 8 +++++++- src/bootstrap/src/core/build_steps/vendor.rs | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index e8907757a2dca..a2888fc48f146 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -3810,7 +3810,13 @@ impl CommandLineStep for CompilerBuiltins { target, Kind::Test, ); - cargo.current_dir(&builder.src.join("library").join("compiler-builtins")); + // We have to run from the root directory to make offline builds work. + // We have to use the combined vendored dependencies + // from the `default_paths_to_vendor` function, rather than only the vendored + // dependencies of the standard library, which do not contain compiler-builtins + // dependencies. + cargo.arg("--manifest-path"); + cargo.arg(builder.src.join("library").join("compiler-builtins").join("Cargo.toml")); cargo.allow_features(&COMPILER_BUILTINS_ALLOW_FEATURES.join(",")); f(&mut cargo); cargo diff --git a/src/bootstrap/src/core/build_steps/vendor.rs b/src/bootstrap/src/core/build_steps/vendor.rs index 0d8ccc0d5b5c7..a91a729c6ef8c 100644 --- a/src/bootstrap/src/core/build_steps/vendor.rs +++ b/src/bootstrap/src/core/build_steps/vendor.rs @@ -25,6 +25,7 @@ pub fn default_paths_to_vendor(builder: &Builder<'_>) -> Vec<(PathBuf, Vec<&'sta ("compiler/rustc_codegen_gcc/Cargo.toml", vec![]), ("library/Cargo.toml", vec![]), ("library/stdarch/Cargo.toml", vec![]), + ("library/compiler-builtins/Cargo.toml", vec![]), ("src/bootstrap/Cargo.toml", vec![]), ("src/tools/rustbook/Cargo.toml", SUBMODULES_FOR_RUSTBOOK.into()), ("src/tools/rustc-perf/Cargo.toml", vec!["src/tools/rustc-perf"]), From a3721d48388f0cfd13990768e7fbff1062a1296b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 27 Oct 2026 17:11:00 +0100 Subject: [PATCH 3/3] Build std also for the compiler's host target --- src/bootstrap/src/core/build_steps/test.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index a2888fc48f146..dea408a4cfddb 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -3777,6 +3777,7 @@ impl CommandLineStep for CompilerBuiltins { let target = self.target; let record_failed_tests = builder.ensure(SetupFailedTestsFile); + builder.ensure(compile::Std::new(compiler, compiler.host)); builder.ensure(compile::Std::new(compiler, target)); const COMPILER_BUILTINS_ALLOW_FEATURES: &[&str] = &[