@@ -196,11 +196,13 @@ impl Step for Rustc {
196
196
// Build host std for compiling build scripts
197
197
builder. std ( build_compiler, build_compiler. host ) ;
198
198
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
+ }
204
206
205
207
let mut cargo = builder:: Cargo :: new (
206
208
builder,
@@ -270,13 +272,19 @@ fn prepare_compiler_for_check(
270
272
build_compiler
271
273
}
272
274
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)
276
287
}
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)
280
288
}
281
289
Mode :: Std => {
282
290
// When checking std stage N, we want to do it with the stage N compiler
0 commit comments