Skip to content

Commit cf7d88f

Browse files
committed
unset RUSTC_WRAPPER for xargo invocation
1 parent 2c0ab51 commit cf7d88f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/bin/cargo-miri.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ path = "lib.rs"
335335
command.current_dir(&dir);
336336
command.env("XARGO_HOME", &dir);
337337
command.env("XARGO_RUST_SRC", &rust_src);
338-
command.env_remove("RUSTFLAGS"); // Make sure external `RUSTFLAGS` do not influence the build.
339338
// Use Miri as rustc to build a libstd compatible with us (and use the right flags).
340339
// However, when we are running in bootstrap, we cannot just overwrite `RUSTC`,
341340
// because we still need bootstrap to distinguish between host and target crates.
@@ -347,6 +346,12 @@ path = "lib.rs"
347346
command.env("RUSTC", find_miri());
348347
}
349348
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");
350355
// Finally run it!
351356
if command.status().expect("failed to run xargo").success().not() {
352357
show_error(format!("Failed to run xargo"));
@@ -446,6 +451,9 @@ fn in_cargo_miri() {
446451
// Set `RUSTC_WRAPPER` to ourselves. Cargo will prepend that binary to its usual invocation,
447452
// i.e., the first argument is `rustc` -- which is what we use in `main` to distinguish
448453
// 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+
}
449457
let path = std::env::current_exe().expect("current executable path invalid");
450458
cmd.env("RUSTC_WRAPPER", path);
451459
if verbose {

0 commit comments

Comments
 (0)