@@ -335,7 +335,6 @@ path = "lib.rs"
335
335
command. current_dir ( & dir) ;
336
336
command. env ( "XARGO_HOME" , & dir) ;
337
337
command. env ( "XARGO_RUST_SRC" , & rust_src) ;
338
- command. env_remove ( "RUSTFLAGS" ) ; // Make sure external `RUSTFLAGS` do not influence the build.
339
338
// Use Miri as rustc to build a libstd compatible with us (and use the right flags).
340
339
// However, when we are running in bootstrap, we cannot just overwrite `RUSTC`,
341
340
// because we still need bootstrap to distinguish between host and target crates.
@@ -347,6 +346,12 @@ path = "lib.rs"
347
346
command. env ( "RUSTC" , find_miri ( ) ) ;
348
347
}
349
348
command. env ( "MIRI_BE_RUSTC" , "1" ) ;
349
+ // Make sure there are no other wrappers or flags getting in our way
350
+ // (Cc https://github.com/rust-lang/miri/issues/1421).
351
+ // This is consistent with normal `cargo build` that does not apply `RUSTFLAGS`
352
+ // to the sysroot either.
353
+ command. env_remove ( "RUSTC_WRAPPER" ) ;
354
+ command. env_remove ( "RUSTFLAGS" ) ;
350
355
// Finally run it!
351
356
if command. status ( ) . expect ( "failed to run xargo" ) . success ( ) . not ( ) {
352
357
show_error ( format ! ( "Failed to run xargo" ) ) ;
@@ -446,6 +451,9 @@ fn in_cargo_miri() {
446
451
// Set `RUSTC_WRAPPER` to ourselves. Cargo will prepend that binary to its usual invocation,
447
452
// i.e., the first argument is `rustc` -- which is what we use in `main` to distinguish
448
453
// the two codepaths. (That extra argument is why we prefer this over setting `RUSTC`.)
454
+ if env:: var_os ( "RUSTC_WRAPPER" ) . is_some ( ) {
455
+ println ! ( "WARNING: Ignoring existing `RUSTC_WRAPPER` environment variable, Miri does not support wrapping." ) ;
456
+ }
449
457
let path = std:: env:: current_exe ( ) . expect ( "current executable path invalid" ) ;
450
458
cmd. env ( "RUSTC_WRAPPER" , path) ;
451
459
if verbose {
0 commit comments