You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let verbose = std::env::var_os("MIRI_VERBOSE").is_some();
510
534
511
535
let file = File::open(binary)
512
-
.unwrap_or_else(|_| show_error(format!("File {:?} not found, or cargo-miri invoked incorrectly", binary)));
536
+
.unwrap_or_else(|_| show_error(format!("File {:?} not found or `cargo-miri` invoked incorrectly; please only invoke this binary through `cargo miri`", binary)));
513
537
let file = BufReader::new(file);
514
538
let info:CrateRunInfo = serde_json::from_reader(file)
515
539
.unwrap_or_else(|_| show_error(format!("File {:?} does not contain valid JSON", binary)));
516
-
// FIXME: remove the file.
540
+
fs::remove_file(binary)
541
+
.unwrap_or_else(|_| show_error(format!("Unable to remove file {:?}", binary)));
517
542
518
543
letmut cmd = miri();
519
-
// Forward rustc arguments,with our sysroot.
520
-
cmd.args(info.args);
544
+
// Forward rustc arguments, with our sysroot. We need to patch "--extern" filenames because
545
+
// we forced a check-only build without cargo knowing about that: replace `.rlib` suffix by `.rmeta`.
546
+
letmut args = info.args.into_iter();
547
+
let extern_flag = "--extern";
548
+
whileletSome(arg) = args.next(){
549
+
if arg.to_str() == Some(extern_flag){
550
+
let next_arg = args.next().expect("`--extern` shoulw be followed by a filename");
551
+
let next_arg = next_arg.to_str().expect("Cannot work with non-UTF-8 extern filenames");
552
+
let next_arg = next_arg.strip_suffix(".rlib").expect("all extern filenames should end in `.rlib`");
553
+
cmd.arg(extern_flag);
554
+
cmd.arg(format!("{}.rmeta", next_arg));
555
+
}else{
556
+
cmd.arg(arg);
557
+
}
558
+
}
521
559
let sysroot =
522
560
env::var_os("MIRI_SYSROOT").expect("The wrapper should have set MIRI_SYSROOT");
523
561
cmd.arg("--sysroot");
524
562
cmd.arg(sysroot);
525
563
526
564
// Then pass binary arguments.
527
565
cmd.arg("--");
528
-
cmd.args(args);
566
+
cmd.args(binary_args);
529
567
530
568
// Run it.
531
569
if verbose {
532
-
eprintln!("+ {:?}", cmd);
570
+
eprintln!("[cargo-miri runner] {:?}", cmd);
533
571
}
534
572
exec(cmd)
535
573
}
@@ -556,10 +594,10 @@ fn main() {
556
594
// binary crates for later interpretation.
557
595
// - When we are executed due to CARGO_TARGET_RUNNER, we start interpretation based on the
0 commit comments