@@ -2689,16 +2689,27 @@ impl Step for Crate {
26892689
26902690 match mode {
26912691 Mode :: Std => {
2692- compile:: std_cargo ( builder, target, compiler. stage , & mut cargo) ;
2693- // `std_cargo` actually does the wrong thing: it passes `--sysroot build/host/stage2`,
2694- // but we want to use the force-recompile std we just built in `build/host/stage2-test-sysroot`.
2695- // Override it.
2696- if builder. download_rustc ( ) && compiler. stage > 0 {
2697- let sysroot = builder
2698- . out
2699- . join ( compiler. host . triple )
2700- . join ( format ! ( "stage{}-test-sysroot" , compiler. stage) ) ;
2701- cargo. env ( "RUSTC_SYSROOT" , sysroot) ;
2692+ if builder. kind == Kind :: Miri {
2693+ // We can't use `std_cargo` as that uses `optimized-compiler-builtins` which
2694+ // needs host tools for the given target. This is similar to what `compile::Std`
2695+ // does when `is_for_mir_opt_tests` is true. There's probably a chance for
2696+ // de-duplication here... `std_cargo` should support a mode that avoids needing
2697+ // host tools.
2698+ cargo
2699+ . arg ( "--manifest-path" )
2700+ . arg ( builder. src . join ( "library/sysroot/Cargo.toml" ) ) ;
2701+ } else {
2702+ compile:: std_cargo ( builder, target, compiler. stage , & mut cargo) ;
2703+ // `std_cargo` actually does the wrong thing: it passes `--sysroot build/host/stage2`,
2704+ // but we want to use the force-recompile std we just built in `build/host/stage2-test-sysroot`.
2705+ // Override it.
2706+ if builder. download_rustc ( ) && compiler. stage > 0 {
2707+ let sysroot = builder
2708+ . out
2709+ . join ( compiler. host . triple )
2710+ . join ( format ! ( "stage{}-test-sysroot" , compiler. stage) ) ;
2711+ cargo. env ( "RUSTC_SYSROOT" , sysroot) ;
2712+ }
27022713 }
27032714 }
27042715 Mode :: Rustc => {
0 commit comments