@@ -522,23 +522,24 @@ impl Step for Miri {
522522
523523 // This compiler runs on the host, we'll just use it for the target.
524524 let target_compiler = builder. compiler ( stage, host) ;
525- // Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
526- // we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage
527- // compilers, which isn't what we want. Rustdoc should be linked in the same way as the
528- // rustc compiler it's paired with, so it must be built with the previous stage compiler.
529- let host_compiler = builder. compiler ( stage - 1 , host) ;
530525
531526 // Build our tools.
532- let miri = builder. ensure ( tool:: Miri { compiler : host_compiler , target : host } ) ;
527+ let miri = builder. ensure ( tool:: Miri { compiler : target_compiler , target : host } ) ;
533528 // the ui tests also assume cargo-miri has been built
534- builder. ensure ( tool:: CargoMiri { compiler : host_compiler , target : host } ) ;
529+ builder. ensure ( tool:: CargoMiri { compiler : target_compiler , target : host } ) ;
535530
536531 // We also need sysroots, for Miri and for the host (the latter for build scripts).
537532 // This is for the tests so everything is done with the target compiler.
538533 let miri_sysroot = Miri :: build_miri_sysroot ( builder, target_compiler, target) ;
539534 builder. ensure ( compile:: Std :: new ( target_compiler, host) ) ;
540535 let host_sysroot = builder. sysroot ( target_compiler) ;
541536
537+ // Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
538+ // we'd have stageN/bin/rustc and stageN/bin/miri be effectively different stage
539+ // compilers, which isn't what we want. Rustdoc should be linked in the same way as the
540+ // rustc compiler it's paired with, so it must be built with the previous stage compiler.
541+ let host_compiler = builder. compiler ( stage - 1 , host) ;
542+
542543 // Miri has its own "target dir" for ui test dependencies. Make sure it gets cleared when
543544 // the sysroot gets rebuilt, to avoid "found possibly newer version of crate `std`" errors.
544545 if !builder. config . dry_run ( ) {
@@ -1720,17 +1721,6 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17201721 // If we're using `--stage 0`, we should provide the bootstrap cargo.
17211722 builder. initial_cargo . clone ( )
17221723 } else {
1723- // We need to properly build cargo using the suitable stage compiler.
1724-
1725- let compiler = builder. download_rustc ( ) . then_some ( compiler) . unwrap_or_else ( ||
1726- // HACK: currently tool stages are off-by-one compared to compiler stages, i.e. if
1727- // you give `tool::Cargo` a stage 1 rustc, it will cause stage 2 rustc to be built
1728- // and produce a cargo built with stage 2 rustc. To fix this, we need to chop off
1729- // the compiler stage by 1 to align with expected `./x test run-make --stage N`
1730- // behavior, i.e. we need to pass `N - 1` compiler stage to cargo. See also Miri
1731- // which does a similar hack.
1732- builder. compiler ( builder. top_stage - 1 , compiler. host ) ) ;
1733-
17341724 builder. ensure ( tool:: Cargo { compiler, target : compiler. host } )
17351725 } ;
17361726
0 commit comments