Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use RUSTC_WRAPPER for the cargo hook #573

Merged
merged 6 commits into from
Dec 12, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/bin/cargo-miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ fn main() {
_ => {}
}
}
} else {
// This arm is executed when cargo-miri runs `cargo rustc` with the `RUSTC` env var set to itself:
} else if let Some("rustc") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) {
// This arm is executed when cargo-miri runs `cargo rustc` with the `RUSTC_WRAPPER` env var set to itself:
// Dependencies get dispatched to rustc, the final test/binary to miri.

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

// this conditional check for the --sysroot flag is there so users can call `cargo-miri` directly
// without having to pass --sysroot or anything
let rustc_args = std::env::args().skip(2);
let mut args: Vec<String> = if std::env::args().any(|s| s == "--sysroot") {
std::env::args().skip(1).collect()
rustc_args.collect()
} else {
std::env::args()
.skip(1)
rustc_args
.chain(Some("--sysroot".to_owned()))
.chain(Some(sys_root))
.collect()
Expand Down Expand Up @@ -365,6 +365,8 @@ fn main() {
Err(ref e) if miri_enabled => panic!("error during miri run: {:?}", e),
Err(ref e) => panic!("error during rustc call: {:?}", e),
}
} else {
show_error!("Must be called with either `miri` or `rustc` as first argument.")
}
}

Expand All @@ -389,7 +391,7 @@ where
let path = std::env::current_exe().expect("current executable path invalid");
let exit_status = Command::new("cargo")
.args(&args)
.env("RUSTC", path)
.env("RUSTC_WRAPPER", path)
.spawn()
.expect("could not run cargo")
.wait()
Expand Down