diff options
| author | Jakub Beránek <berykubik@gmail.com> | 2025-07-05 10:55:12 +0200 |
|---|---|---|
| committer | Jakub Beránek <berykubik@gmail.com> | 2025-07-06 17:25:19 +0200 |
| commit | 20719767bc04ab72ae1c1d0751caff960b984ac9 (patch) | |
| tree | 9da082bea340b716338fd6495314fad2af55986d | |
| parent | 97da04c9222b1b1b362309555c5825793c3f7f03 (diff) | |
| download | rust-20719767bc04ab72ae1c1d0751caff960b984ac9.tar.gz rust-20719767bc04ab72ae1c1d0751caff960b984ac9.zip | |
Use stage auto-bump when cross-checking on stage 1
| -rw-r--r-- | src/bootstrap/src/core/build_steps/check.rs | 22 | ||||
| -rw-r--r-- | src/bootstrap/src/core/builder/tests.rs | 9 |
2 files changed, 14 insertions, 17 deletions
diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index 555a02ac587..40632f35bd7 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -1,7 +1,5 @@ //! Implementation of compiling the compiler and standard library, in "check"-based modes. -use build_helper::exit; - use crate::core::build_steps::compile::{ add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo, std_crates_for_run_make, }; @@ -264,19 +262,23 @@ fn prepare_compiler_for_check( build_compiler } Mode::ToolRustc | Mode::Codegen => { + // FIXME: this is a hack, see description of Mode::Rustc below + let stage = if host == target { builder.top_stage - 1 } else { builder.top_stage }; // When checking tool stage N, we check it with compiler stage N-1 - let build_compiler = builder.compiler(builder.top_stage - 1, host); + let build_compiler = builder.compiler(stage, host); builder.ensure(Rustc::new(builder, build_compiler, target)); build_compiler } Mode::Rustc => { - if builder.top_stage < 2 && host != target { - eprintln!("Cannot do a cross-compilation check of rustc on stage 1, use stage 2"); - exit!(1); - } - - // When checking the stage N compiler, we want to do it with the stage N-1 compiler - builder.compiler(builder.top_stage - 1, host) + // This is a horrible hack, because we actually change the compiler stage numbering + // here. If you do `x check --stage 1 --host FOO`, we build stage 1 host rustc, + // and use that to check stage 1 FOO rustc (which actually makes that stage 2 FOO + // rustc). + // + // FIXME: remove this and either fix cross-compilation check on stage 2 (which has a + // myriad of other problems) or disable cross-checking on stage 1. + let stage = if host == target { builder.top_stage - 1 } else { builder.top_stage }; + builder.compiler(stage, host) } Mode::Std => { // When checking std stage N, we want to do it with the stage N compiler diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index f0dba1a85f3..a6bd531fd14 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -1299,7 +1299,6 @@ mod snapshot { let ctx = TestCtx::new(); insta::assert_snapshot!( ctx.config("check") - .stage(2) .targets(&[TEST_TRIPLE_1]) .hosts(&[TEST_TRIPLE_1]) .render_steps(), @r" @@ -1307,7 +1306,6 @@ mod snapshot { [build] rustc 0 <host> -> rustc 1 <host> [build] rustc 1 <host> -> std 1 <host> [build] rustc 1 <host> -> std 1 <target1> - [build] llvm <target1> [check] rustc 1 <host> -> rustc 2 <target1> [check] rustc 1 <host> -> Rustdoc 2 <target1> [check] rustc 1 <host> -> cranelift 2 <target1> @@ -1318,12 +1316,9 @@ mod snapshot { [check] rustc 0 <host> -> MiroptTestTools 1 <target1> [check] rustc 1 <host> -> Rustfmt 2 <target1> [check] rustc 1 <host> -> rust-analyzer 2 <target1> - [build] rustc 1 <host> -> rustc 2 <host> - [build] rustc 2 <host> -> std 2 <host> - [build] rustc 2 <host> -> std 2 <target1> - [check] rustc 2 <host> -> TestFloatParse 3 <target1> + [check] rustc 1 <host> -> TestFloatParse 2 <target1> [check] rustc 0 <host> -> FeaturesStatusDump 1 <target1> - [check] rustc 2 <host> -> std 2 <target1> + [check] rustc 1 <host> -> std 1 <target1> "); } |
