@@ -523,16 +523,11 @@ impl Step for Miri {
523523
524524 // This compiler runs on the host, we'll just use it for the target.
525525 let target_compiler = builder. compiler ( stage, host) ;
526- // Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
527- // we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage
528- // compilers, which isn't what we want. Rustdoc should be linked in the same way as the
529- // rustc compiler it's paired with, so it must be built with the previous stage compiler.
530- let host_compiler = builder. compiler ( stage - 1 , host) ;
531526
532527 // Build our tools.
533- let miri = builder. ensure ( tool:: Miri { compiler : host_compiler , target : host } ) ;
528+ let miri = builder. ensure ( tool:: Miri { compiler : target_compiler , target : host } ) ;
534529 // the ui tests also assume cargo-miri has been built
535- builder. ensure ( tool:: CargoMiri { compiler : host_compiler , target : host } ) ;
530+ builder. ensure ( tool:: CargoMiri { compiler : target_compiler , target : host } ) ;
536531
537532 // We also need sysroots, for Miri and for the host (the latter for build scripts).
538533 // This is for the tests so everything is done with the target compiler.
@@ -543,7 +538,8 @@ impl Step for Miri {
543538 // Miri has its own "target dir" for ui test dependencies. Make sure it gets cleared when
544539 // the sysroot gets rebuilt, to avoid "found possibly newer version of crate `std`" errors.
545540 if !builder. config . dry_run ( ) {
546- let ui_test_dep_dir = builder. stage_out ( host_compiler, Mode :: ToolStd ) . join ( "miri_ui" ) ;
541+ let ui_test_dep_dir =
542+ builder. stage_out ( miri. build_compiler , Mode :: ToolStd ) . join ( "miri_ui" ) ;
547543 // The mtime of `miri_sysroot` changes when the sysroot gets rebuilt (also see
548544 // <https://github.com/RalfJung/rustc-build-sysroot/commit/10ebcf60b80fe2c3dc765af0ff19fdc0da4b7466>).
549545 // We can hence use that directly as a signal to clear the ui test dir.
@@ -554,7 +550,7 @@ impl Step for Miri {
554550 // This is with the Miri crate, so it uses the host compiler.
555551 let mut cargo = tool:: prepare_tool_cargo (
556552 builder,
557- host_compiler ,
553+ miri . build_compiler ,
558554 Mode :: ToolRustc ,
559555 host,
560556 Kind :: Test ,
@@ -1722,17 +1718,6 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17221718 // If we're using `--stage 0`, we should provide the bootstrap cargo.
17231719 builder. initial_cargo . clone ( )
17241720 } else {
1725- // We need to properly build cargo using the suitable stage compiler.
1726-
1727- let compiler = builder. download_rustc ( ) . then_some ( compiler) . unwrap_or_else ( ||
1728- // HACK: currently tool stages are off-by-one compared to compiler stages, i.e. if
1729- // you give `tool::Cargo` a stage 1 rustc, it will cause stage 2 rustc to be built
1730- // and produce a cargo built with stage 2 rustc. To fix this, we need to chop off
1731- // the compiler stage by 1 to align with expected `./x test run-make --stage N`
1732- // behavior, i.e. we need to pass `N - 1` compiler stage to cargo. See also Miri
1733- // which does a similar hack.
1734- builder. compiler ( builder. top_stage - 1 , compiler. host ) ) ;
1735-
17361721 builder. ensure ( tool:: Cargo { compiler, target : compiler. host } )
17371722 } ;
17381723
0 commit comments