Skip to content

Commit e38a28d

Browse files
committed
Use stage auto-bump when cross-checking on stage 1
1 parent 05e94e8 commit e38a28d

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/bootstrap/src/core/build_steps/check.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Implementation of compiling the compiler and standard library, in "check"-based modes.
22
3-
use build_helper::exit;
4-
53
use crate::core::build_steps::compile::{
64
add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo, std_crates_for_run_make,
75
};
@@ -264,19 +262,23 @@ fn prepare_compiler_for_check(
264262
build_compiler
265263
}
266264
Mode::ToolRustc | Mode::Codegen => {
265+
// FIXME: this is a hack, see description of Mode::Rustc below
266+
let stage = if host == target { builder.top_stage - 1 } else { builder.top_stage };
267267
// When checking tool stage N, we check it with compiler stage N-1
268-
let build_compiler = builder.compiler(builder.top_stage - 1, host);
268+
let build_compiler = builder.compiler(stage, host);
269269
builder.ensure(Rustc::new(builder, build_compiler, target));
270270
build_compiler
271271
}
272272
Mode::Rustc => {
273-
if builder.top_stage < 2 && host != target {
274-
eprintln!("Cannot do a cross-compilation check of rustc on stage 1, use stage 2");
275-
exit!(1);
276-
}
277-
278-
// When checking the stage N compiler, we want to do it with the stage N-1 compiler
279-
builder.compiler(builder.top_stage - 1, host)
273+
// This is a horrible hack, because we actually change the compiler stage numbering
274+
// here. If you do `x check --stage 1 --host FOO`, we build stage 1 host rustc,
275+
// and use that to check stage 1 FOO rustc (which actually makes that stage 2 FOO
276+
// rustc).
277+
//
278+
// FIXME: remove this and either fix cross-compilation check on stage 2 (which has a
279+
// myriad of other problems) or disable cross-checking on stage 1.
280+
let stage = if host == target { builder.top_stage - 1 } else { builder.top_stage };
281+
builder.compiler(stage, host)
280282
}
281283
Mode::Std => {
282284
// When checking std stage N, we want to do it with the stage N compiler

src/bootstrap/src/core/builder/tests.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,15 +1299,13 @@ mod snapshot {
12991299
let ctx = TestCtx::new();
13001300
insta::assert_snapshot!(
13011301
ctx.config("check")
1302-
.stage(2)
13031302
.targets(&[TEST_TRIPLE_1])
13041303
.hosts(&[TEST_TRIPLE_1])
13051304
.render_steps(), @r"
13061305
[build] llvm <host>
13071306
[build] rustc 0 <host> -> rustc 1 <host>
13081307
[build] rustc 1 <host> -> std 1 <host>
13091308
[build] rustc 1 <host> -> std 1 <target1>
1310-
[build] llvm <target1>
13111309
[check] rustc 1 <host> -> rustc 2 <target1>
13121310
[check] rustc 1 <host> -> Rustdoc 2 <target1>
13131311
[check] rustc 1 <host> -> cranelift 2 <target1>
@@ -1318,12 +1316,9 @@ mod snapshot {
13181316
[check] rustc 0 <host> -> MiroptTestTools 1 <target1>
13191317
[check] rustc 1 <host> -> Rustfmt 2 <target1>
13201318
[check] rustc 1 <host> -> rust-analyzer 2 <target1>
1321-
[build] rustc 1 <host> -> rustc 2 <host>
1322-
[build] rustc 2 <host> -> std 2 <host>
1323-
[build] rustc 2 <host> -> std 2 <target1>
1324-
[check] rustc 2 <host> -> TestFloatParse 3 <target1>
1319+
[check] rustc 1 <host> -> TestFloatParse 2 <target1>
13251320
[check] rustc 0 <host> -> FeaturesStatusDump 1 <target1>
1326-
[check] rustc 2 <host> -> std 2 <target1>
1321+
[check] rustc 1 <host> -> std 1 <target1>
13271322
");
13281323
}
13291324

0 commit comments

Comments
 (0)