diff options
| author | Oliver Schneider <oli-obk@users.noreply.github.com> | 2017-06-29 20:44:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-29 20:44:48 +0200 |
| commit | 4fa71ad3ebe3e8cd07e255c1a997dda3147dae2e (patch) | |
| tree | 1cfd1d7c0648c3637acab0b329cd19458c666fd2 /src | |
| parent | 8722ce8d4b66c0d7939d54c2d59502116a662a60 (diff) | |
| parent | 7a755ce8f948ebacb0157a1213d9dc4039f87807 (diff) | |
| download | rust-4fa71ad3ebe3e8cd07e255c1a997dda3147dae2e.tar.gz rust-4fa71ad3ebe3e8cd07e255c1a997dda3147dae2e.zip | |
Merge pull request #230 from dwrensha/cargo-miri
get cargo-miri to work
Diffstat (limited to 'src')
| -rw-r--r-- | src/bin/cargo-miri.rs | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index f67bbd39a74..6eff6650fa9 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -44,8 +44,6 @@ fn main() { return; } - let dep_path = std::env::current_dir().expect("current dir is not readable").join("target").join("debug").join("deps"); - if let Some("miri") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) { // this arm is when `cargo miri` is called @@ -84,13 +82,11 @@ fn main() { let args = std::env::args().skip(skip); let kind = target.kind.get(0).expect("badly formatted cargo metadata: target::kind is an empty array"); if test && kind == "test" { - if let Err(code) = process(vec!["--test".to_string(), target.name].into_iter().chain(args), - &dep_path) { + if let Err(code) = process(vec!["--test".to_string(), target.name].into_iter().chain(args)) { std::process::exit(code); } } else if !test && kind == "bin" { - if let Err(code) = process(vec!["--bin".to_string(), target.name].into_iter().chain(args), - &dep_path) { + if let Err(code) = process(vec!["--bin".to_string(), target.name].into_iter().chain(args)) { std::process::exit(code); } } @@ -117,7 +113,7 @@ fn main() { .expect("need to specify RUST_SYSROOT env var during miri compilation, or use rustup or multirust") }; - // this conditional check for the --sysroot flag is there so users can call `cargo-clippy` directly + // this conditional check for the --sysroot flag is there so users can call `cargo-miri` directly // without having to pass --sysroot or anything let mut args: Vec<String> = if std::env::args().any(|s| s == "--sysroot") { std::env::args().skip(1).collect() @@ -129,25 +125,29 @@ fn main() { // interpreted but not built let miri_enabled = std::env::args().any(|s| s == "-Zno-trans"); - if miri_enabled { - args.extend_from_slice(&["--cfg".to_owned(), r#"feature="cargo-miri""#.to_owned()]); - } + let mut command = if miri_enabled { + let mut path = std::env::current_exe().expect("current executable path invalid"); + path.set_file_name("miri"); + Command::new(path) + } else { + Command::new("rustc") + }; - let mut path = std::env::current_exe().expect("current executable path invalid"); - path.set_file_name("miri"); + args.extend_from_slice(&["-Z".to_owned(), "always-encode-mir".to_owned()]); + args.extend_from_slice(&["--cfg".to_owned(), r#"feature="cargo-miri""#.to_owned()]); - match Command::new(path).args(&args).status() { + match command.args(&args).status() { Ok(exit) => if !exit.success() { std::process::exit(exit.code().unwrap_or(42)); }, - Err(e) => panic!("error during miri run: {:?}", e), + Err(ref e) if miri_enabled => panic!("error during miri run: {:?}", e), + Err(ref e) => panic!("error during rustc call: {:?}", e), } } } -fn process<P, I>(old_args: I, dep_path: P) -> Result<(), i32> - where P: AsRef<Path>, - I: Iterator<Item = String> +fn process<I>(old_args: I) -> Result<(), i32> + where I: Iterator<Item = String> { let mut args = vec!["rustc".to_owned()]; @@ -159,8 +159,6 @@ fn process<P, I>(old_args: I, dep_path: P) -> Result<(), i32> if !found_dashes { args.push("--".to_owned()); } - args.push("-L".to_owned()); - args.push(dep_path.as_ref().to_string_lossy().into_owned()); args.push("-Zno-trans".to_owned()); args.push("--cfg".to_owned()); args.push(r#"feature="cargo-miri""#.to_owned()); |
