@@ -168,8 +168,6 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
168
168
// Forward all further arguments (not consumed by `ArgSplitFlagValue`) to cargo.
169
169
cmd. args ( args) ;
170
170
171
- // Let it know where the Miri sysroot lives.
172
- cmd. env ( "MIRI_SYSROOT" , miri_sysroot) ;
173
171
// Set `RUSTC_WRAPPER` to ourselves. Cargo will prepend that binary to its usual invocation,
174
172
// i.e., the first argument is `rustc` -- which is what we use in `main` to distinguish
175
173
// the two codepaths. (That extra argument is why we prefer this over setting `RUSTC`.)
@@ -196,10 +194,7 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
196
194
// always applied. However, buggy build scripts (https://github.com/eyre-rs/eyre/issues/84) and
197
195
// also cargo (https://github.com/rust-lang/cargo/issues/10885) will invoke `rustc` even when
198
196
// `RUSTC_WRAPPER` is set, bypassing the wrapper. To make sure everything is coherent, we want
199
- // that to be the Miri driver, but acting as rustc, on the target level. (Target, rather than
200
- // host, is needed for cross-interpretation situations.) This is not a perfect emulation of real
201
- // rustc (it might be unable to produce binaries since the sysroot is check-only), but it's as
202
- // close as we can get, and it's good enough for autocfg.
197
+ // that to be the Miri driver, but acting as rustc, on the target level.
203
198
//
204
199
// In `main`, we need the value of `RUSTC` to distinguish RUSTC_WRAPPER invocations from rustdoc
205
200
// or TARGET_RUNNER invocations, so we canonicalize it here to make it exceedingly unlikely that
@@ -208,11 +203,18 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
208
203
// bootstrap `rustc` thing in our way! Instead, we have MIRI_HOST_SYSROOT to use for host
209
204
// builds.
210
205
cmd. env ( "RUSTC" , fs:: canonicalize ( find_miri ( ) ) . unwrap ( ) ) ;
206
+ // In case we get invoked as RUSTC without the wrapper, let's be a target rustc. (Target,
207
+ // rather than host, is needed for cross-interpretation situations.) This is not a perfect
208
+ // emulation of real rustc (it might be unable to produce binaries since the sysroot is
209
+ // check-only), but it's as close as we can get, and it's good enough for eyre.
210
+ // (But we won't actually have the Miri sysroot so this will not necessarily work great.)
211
211
cmd. env ( "MIRI_BE_RUSTC" , "target" ) ; // we better remember to *unset* this in the other phases!
212
212
213
213
// Set rustdoc to us as well, so we can run doctests.
214
214
cmd. env ( "RUSTDOC" , & cargo_miri_path) ;
215
215
216
+ // Forward some crucial information to our own re-invocations.
217
+ cmd. env ( "MIRI_SYSROOT" , miri_sysroot) ;
216
218
cmd. env ( "MIRI_LOCAL_CRATES" , local_crates ( & metadata) ) ;
217
219
if verbose > 0 {
218
220
cmd. env ( "MIRI_VERBOSE" , verbose. to_string ( ) ) ; // This makes the other phases verbose.
@@ -410,6 +412,8 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
410
412
// Arguments are treated very differently depending on whether this crate is
411
413
// for interpretation by Miri, or for use by a build script / proc macro.
412
414
if target_crate {
415
+ // Set the sysroot.
416
+ cmd. arg ( "--sysroot" ) . arg ( env:: var_os ( "MIRI_SYSROOT" ) . unwrap ( ) ) ;
413
417
// Forward arguments, but remove "link" from "--emit" to make this a check-only build.
414
418
let emit_flag = "--emit" ;
415
419
while let Some ( arg) = args. next ( ) {
@@ -543,6 +547,12 @@ pub fn phase_runner(mut binary_args: impl Iterator<Item = String>, phase: Runner
543
547
cmd. env ( name, val) ;
544
548
}
545
549
550
+ if phase != RunnerPhase :: Rustdoc {
551
+ // Set the sysroot. Not necessary in rustdoc, where we already set the sysroot when invoking
552
+ // rustdoc itself, which will forward that flag when invoking rustc (i.e., us), so the flag
553
+ // is present in `info.args`.
554
+ cmd. arg ( "--sysroot" ) . arg ( env:: var_os ( "MIRI_SYSROOT" ) . unwrap ( ) ) ;
555
+ }
546
556
// Forward rustc arguments.
547
557
// We need to patch "--extern" filenames because we forced a check-only
548
558
// build without cargo knowing about that: replace `.rlib` suffix by
0 commit comments