@@ -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 ( ) {
@@ -1715,17 +1716,6 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17151716 // If we're using `--stage 0`, we should provide the bootstrap cargo.
17161717 builder. initial_cargo . clone ( )
17171718 } else {
1718- // We need to properly build cargo using the suitable stage compiler.
1719-
1720- let compiler = builder. download_rustc ( ) . then_some ( compiler) . unwrap_or_else ( ||
1721- // HACK: currently tool stages are off-by-one compared to compiler stages, i.e. if
1722- // you give `tool::Cargo` a stage 1 rustc, it will cause stage 2 rustc to be built
1723- // and produce a cargo built with stage 2 rustc. To fix this, we need to chop off
1724- // the compiler stage by 1 to align with expected `./x test run-make --stage N`
1725- // behavior, i.e. we need to pass `N - 1` compiler stage to cargo. See also Miri
1726- // which does a similar hack.
1727- builder. compiler ( builder. top_stage - 1 , compiler. host ) ) ;
1728-
17291719 builder. ensure ( tool:: Cargo { compiler, target : compiler. host } )
17301720 } ;
17311721
0 commit comments