Skip to content

Commit 02a33d4

Browse files
committed
Auto merge of #1557 - RalfJung:cargo-miri, r=RalfJung
support non-rlib extern files This came up in hsivonen/encoding_rs#57.
2 parents cbc7560 + 4dda2ad commit 02a33d4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cargo-miri/bin.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,11 +663,16 @@ fn phase_cargo_runner(binary: &Path, binary_args: env::Args) {
663663
let json_flag = "--json";
664664
while let Some(arg) = args.next() {
665665
if arg == extern_flag {
666+
cmd.arg(extern_flag); // always forward flag, but adjust filename
666667
// `--extern` is always passed as a separate argument by cargo.
667668
let next_arg = args.next().expect("`--extern` should be followed by a filename");
668-
let next_arg = next_arg.strip_suffix(".rlib").expect("all extern filenames should end in `.rlib`");
669-
cmd.arg(extern_flag);
670-
cmd.arg(format!("{}.rmeta", next_arg));
669+
if let Some(next_lib) = next_arg.strip_suffix(".rlib") {
670+
// If this is an rlib, make it an rmeta.
671+
cmd.arg(format!("{}.rmeta", next_lib));
672+
} else {
673+
// Some other extern file (e.g., a `.so`). Forward unchanged.
674+
cmd.arg(next_arg);
675+
}
671676
} else if arg.starts_with(error_format_flag) {
672677
let suffix = &arg[error_format_flag.len()..];
673678
assert!(suffix.starts_with('='));

0 commit comments

Comments
 (0)