@@ -521,23 +521,24 @@ impl Step for Miri {
521521
522522 // This compiler runs on the host, we'll just use it for the target.
523523 let target_compiler = builder. compiler ( stage, host) ;
524- // Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
525- // we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage
526- // compilers, which isn't what we want. Rustdoc should be linked in the same way as the
527- // rustc compiler it's paired with, so it must be built with the previous stage compiler.
528- let host_compiler = builder. compiler ( stage - 1 , host) ;
529524
530525 // Build our tools.
531- let miri = builder. ensure ( tool:: Miri { compiler : host_compiler , target : host } ) ;
526+ let miri = builder. ensure ( tool:: Miri { compiler : target_compiler , target : host } ) ;
532527 // the ui tests also assume cargo-miri has been built
533- builder. ensure ( tool:: CargoMiri { compiler : host_compiler , target : host } ) ;
528+ builder. ensure ( tool:: CargoMiri { compiler : target_compiler , target : host } ) ;
534529
535530 // We also need sysroots, for Miri and for the host (the latter for build scripts).
536531 // This is for the tests so everything is done with the target compiler.
537532 let miri_sysroot = Miri :: build_miri_sysroot ( builder, target_compiler, target) ;
538533 builder. ensure ( compile:: Std :: new ( target_compiler, host) ) ;
539534 let host_sysroot = builder. sysroot ( target_compiler) ;
540535
536+ // Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
537+ // we'd have stageN/bin/rustc and stageN/bin/miri be effectively different stage
538+ // compilers, which isn't what we want. Rustdoc should be linked in the same way as the
539+ // rustc compiler it's paired with, so it must be built with the previous stage compiler.
540+ let host_compiler = builder. compiler ( stage - 1 , host) ;
541+
541542 // Miri has its own "target dir" for ui test dependencies. Make sure it gets cleared when
542543 // the sysroot gets rebuilt, to avoid "found possibly newer version of crate `std`" errors.
543544 if !builder. config . dry_run ( ) {
@@ -1734,17 +1735,6 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17341735 // If we're using `--stage 0`, we should provide the bootstrap cargo.
17351736 builder. initial_cargo . clone ( )
17361737 } else {
1737- // We need to properly build cargo using the suitable stage compiler.
1738-
1739- let compiler = builder. download_rustc ( ) . then_some ( compiler) . unwrap_or_else ( ||
1740- // HACK: currently tool stages are off-by-one compared to compiler stages, i.e. if
1741- // you give `tool::Cargo` a stage 1 rustc, it will cause stage 2 rustc to be built
1742- // and produce a cargo built with stage 2 rustc. To fix this, we need to chop off
1743- // the compiler stage by 1 to align with expected `./x test run-make --stage N`
1744- // behavior, i.e. we need to pass `N - 1` compiler stage to cargo. See also Miri
1745- // which does a similar hack.
1746- builder. compiler ( builder. top_stage - 1 , compiler. host ) ) ;
1747-
17481738 builder. ensure ( tool:: Cargo { compiler, target : compiler. host } )
17491739 } ;
17501740
0 commit comments