Skip to content

Commit ed83cc2

Browse files
committed
use RUSTC_WRAPPER for the cargo hook
1 parent ff140da commit ed83cc2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/bin/cargo-miri.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ fn main() {
305305
_ => {}
306306
}
307307
}
308-
} else {
309-
// This arm is executed when cargo-miri runs `cargo rustc` with the `RUSTC` env var set to itself:
308+
} else if let Some("rustc") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) {
309+
// This arm is executed when cargo-miri runs `cargo rustc` with the `RUSTC_WRAPPER` env var set to itself:
310310
// Dependencies get dispatched to rustc, the final test/binary to miri.
311311

312312
let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME"));
@@ -332,11 +332,11 @@ fn main() {
332332

333333
// this conditional check for the --sysroot flag is there so users can call `cargo-miri` directly
334334
// without having to pass --sysroot or anything
335+
let rustc_args = std::env::args().skip(2);
335336
let mut args: Vec<String> = if std::env::args().any(|s| s == "--sysroot") {
336-
std::env::args().skip(1).collect()
337+
rustc_args.collect()
337338
} else {
338-
std::env::args()
339-
.skip(1)
339+
rustc_args
340340
.chain(Some("--sysroot".to_owned()))
341341
.chain(Some(sys_root))
342342
.collect()
@@ -365,6 +365,8 @@ fn main() {
365365
Err(ref e) if miri_enabled => panic!("error during miri run: {:?}", e),
366366
Err(ref e) => panic!("error during rustc call: {:?}", e),
367367
}
368+
} else {
369+
eprintln!("Unexpected call: Must be called with either `miri` or `rustc` as first argument.")
368370
}
369371
}
370372

@@ -389,7 +391,7 @@ where
389391
let path = std::env::current_exe().expect("current executable path invalid");
390392
let exit_status = Command::new("cargo")
391393
.args(&args)
392-
.env("RUSTC", path)
394+
.env("RUSTC_WRAPPER", path)
393395
.spawn()
394396
.expect("could not run cargo")
395397
.wait()

0 commit comments

Comments
 (0)