Skip to content

Commit 951c61c

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

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,13 @@ impl Step for Rustc {
196196
// Build host std for compiling build scripts
197197
builder.std(build_compiler, build_compiler.host);
198198

199-
// Build target std so that the checked rustc can link to it during the check
200-
// FIXME: maybe we can a way to only do a check of std here?
201-
// But for that we would have to copy the stdlib rmetas to the sysroot of the build
202-
// compiler, which conflicts with std rlibs, if we also build std.
203-
builder.std(build_compiler, target);
199+
if build_compiler.host != target {
200+
// Build target std so that the checked rustc can link to it during the check
201+
// FIXME: maybe we can a way to only do a check of std here?
202+
// But for that we would have to copy the stdlib rmetas to the sysroot of the build
203+
// compiler, which conflicts with std rlibs, if we also build std.
204+
builder.ensure(Std::new(build_compiler, target));
205+
}
204206

205207
let mut cargo = builder::Cargo::new(
206208
builder,
@@ -270,13 +272,19 @@ fn prepare_compiler_for_check(
270272
build_compiler
271273
}
272274
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);
275+
// This is a horrible hack, because we actually change the compiler stage numbering
276+
// here. If you do `x check --stage 1 --host FOO`, we build stage 1 host rustc,
277+
// and use that to check stage 1 FOO rustc (which actually makes that stage 2 FOO
278+
// rustc).
279+
//
280+
// FIXME: remove this and either fix cross-compilation check on stage 2 (which has a
281+
// myriad of other problems) or disable cross-checking on stage 1.
282+
if host != target {
283+
builder.compiler(builder.top_stage, host)
284+
} else {
285+
// When checking the stage N compiler, we want to do it with the stage N-1 compiler
286+
builder.compiler(builder.top_stage - 1, host)
276287
}
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)
280288
}
281289
Mode::Std => {
282290
// When checking std stage N, we want to do it with the stage N compiler

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,31 +1299,29 @@ 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>
1309-
[build] rustc 1 <host> -> std 1 <target1>
1310-
[build] llvm <target1>
1308+
[check] rustc 1 <host> -> std 1 <target1>
13111309
[check] rustc 1 <host> -> rustc 2 <target1>
1312-
[check] rustc 1 <host> -> Rustdoc 2 <target1>
1313-
[check] rustc 1 <host> -> cranelift 2 <target1>
1314-
[check] rustc 1 <host> -> gcc 2 <target1>
1315-
[check] rustc 1 <host> -> Clippy 2 <target1>
1316-
[check] rustc 1 <host> -> Miri 2 <target1>
1317-
[check] rustc 1 <host> -> CargoMiri 2 <target1>
1310+
[check] rustc 0 <host> -> std 0 <target1>
1311+
[build] llvm <target1>
1312+
[check] rustc 0 <host> -> rustc 1 <target1>
1313+
[check] rustc 0 <host> -> Rustdoc 1 <target1>
1314+
[check] rustc 0 <host> -> cranelift 1 <target1>
1315+
[check] rustc 0 <host> -> gcc 1 <target1>
1316+
[check] rustc 0 <host> -> Clippy 1 <target1>
1317+
[check] rustc 0 <host> -> Miri 1 <target1>
1318+
[check] rustc 0 <host> -> CargoMiri 1 <target1>
13181319
[check] rustc 0 <host> -> MiroptTestTools 1 <target1>
1319-
[check] rustc 1 <host> -> Rustfmt 2 <target1>
1320-
[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>
1320+
[check] rustc 0 <host> -> Rustfmt 1 <target1>
1321+
[check] rustc 0 <host> -> rust-analyzer 1 <target1>
1322+
[build] rustc 1 <host> -> std 1 <target1>
1323+
[check] rustc 1 <host> -> TestFloatParse 2 <target1>
13251324
[check] rustc 0 <host> -> FeaturesStatusDump 1 <target1>
1326-
[check] rustc 2 <host> -> std 2 <target1>
13271325
");
13281326
}
13291327

0 commit comments

Comments
 (0)