Skip to content

Commit c0eb13b

Browse files
author
hyd-dev
committed
Patch --extern arguments in phase_cargo_rustc as well
1 parent 56250cc commit c0eb13b

File tree

6 files changed

+32
-2
lines changed

6 files changed

+32
-2
lines changed

cargo-miri/bin.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ fn phase_cargo_miri(mut args: env::Args) {
565565
exec(cmd)
566566
}
567567

568-
fn phase_cargo_rustc(args: env::Args) {
568+
fn phase_cargo_rustc(mut args: env::Args) {
569569
/// Determines if we are being invoked (as rustc) to build a crate for
570570
/// the "target" architecture, in contrast to the "host" architecture.
571571
/// Host crates are for build scripts and proc macros and still need to
@@ -655,7 +655,7 @@ fn phase_cargo_rustc(args: env::Args) {
655655
if !print && target_crate {
656656
// Forward arguments, but remove "link" from "--emit" to make this a check-only build.
657657
let emit_flag = "--emit";
658-
for arg in args {
658+
while let Some(arg) = args.next() {
659659
if arg.starts_with(emit_flag) {
660660
// Patch this argument. First, extract its value.
661661
let val = &arg[emit_flag.len()..];
@@ -671,6 +671,10 @@ fn phase_cargo_rustc(args: env::Args) {
671671
}
672672
}
673673
cmd.arg(format!("{}={}", emit_flag, val.join(",")));
674+
} else if arg == "--extern" {
675+
// Patch `--extern` filenames, since Cargo sometimes passes stub `.rlib` files:
676+
// https://github.com/rust-lang/miri/issues/1705
677+
forward_patched_extern_arg(&mut args, &mut cmd);
674678
} else {
675679
cmd.arg(arg);
676680
}

test-cargo-miri/Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-cargo-miri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ edition = "2018"
1111
byteorder = "1.0"
1212
issue_1567 = { path = "issue-1567" }
1313
issue_1691 = { path = "issue-1691" }
14+
issue_1705 = { path = "issue-1705" }
1415

1516
[dev-dependencies]
1617
rand = { version = "0.7", features = ["small_rng"] }

test-cargo-miri/issue-1705/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "issue_1705"
3+
version = "0.1.0"
4+
authors = ["Miri Team"]
5+
edition = "2018"
6+
7+
[lib]
8+
crate-type = ["lib", "staticlib", "cdylib"]
9+
10+
[dependencies]
11+
byteorder = "1.0"

test-cargo-miri/issue-1705/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
use byteorder::{LittleEndian, ByteOrder};
2+
3+
pub fn use_the_dependency() {
4+
let _n = <LittleEndian as ByteOrder>::read_u32(&[1,2,3,4]);
5+
}

test-cargo-miri/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
/// assert!(cargo_miri_test::make_true());
44
/// ```
55
pub fn make_true() -> bool {
6+
issue_1705::use_the_dependency();
67
issue_1691::use_me()
78
}

0 commit comments

Comments
 (0)