@@ -412,8 +412,11 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
412
412
// Arguments are treated very differently depending on whether this crate is
413
413
// for interpretation by Miri, or for use by a build script / proc macro.
414
414
if target_crate {
415
- // Set the sysroot.
416
- cmd. arg ( "--sysroot" ) . arg ( env:: var_os ( "MIRI_SYSROOT" ) . unwrap ( ) ) ;
415
+ if phase != RustcPhase :: Setup {
416
+ // Set the sysroot -- except during setup, where we don't have an existing sysroot yet
417
+ // and where the bootstrap wrapper adds its own `--sysroot` flag so we can't set ours.
418
+ cmd. arg ( "--sysroot" ) . arg ( env:: var_os ( "MIRI_SYSROOT" ) . unwrap ( ) ) ;
419
+ }
417
420
418
421
// Forward arguments, but patched.
419
422
let emit_flag = "--emit" ;
@@ -578,9 +581,9 @@ pub fn phase_runner(mut binary_args: impl Iterator<Item = String>, phase: Runner
578
581
}
579
582
580
583
if phase != RunnerPhase :: Rustdoc {
581
- // Set the sysroot. Not necessary in rustdoc, where we already set the sysroot when invoking
582
- // rustdoc itself, which will forward that flag when invoking rustc (i.e., us), so the flag
583
- // is present in `info.args`.
584
+ // Set the sysroot. Not necessary in rustdoc, where we already set the sysroot in
585
+ // `phase_rustdoc`. rustdoc will forward that flag when invoking rustc (i.e., us), so the
586
+ // flag is present in `info.args`.
584
587
cmd. arg ( "--sysroot" ) . arg ( env:: var_os ( "MIRI_SYSROOT" ) . unwrap ( ) ) ;
585
588
}
586
589
// Forward rustc arguments.
0 commit comments