Skip to content

Commit 8ed7fac

Browse files
committed
Auto merge of #1577 - RalfJung:rlib, r=RalfJung
fix for rlib/cdylib crates in dependency tree Fixes #1567 Unfortunately, I found no nice way to test for this.
2 parents 7448e79 + 5058ec1 commit 8ed7fac

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

cargo-miri/bin.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,7 @@ fn phase_cargo_rustc(args: env::Args) {
532532
fn is_runnable_crate() -> bool {
533533
let is_bin = get_arg_flag_value("--crate-type").as_deref().unwrap_or("bin") == "bin";
534534
let is_test = has_arg_flag("--test");
535-
let print = get_arg_flag_value("--print").is_some();
536-
(is_bin || is_test) && !print
535+
is_bin || is_test
537536
}
538537

539538
fn out_filename(prefix: &str, suffix: &str) -> PathBuf {
@@ -552,8 +551,21 @@ fn phase_cargo_rustc(args: env::Args) {
552551

553552
let verbose = std::env::var_os("MIRI_VERBOSE").is_some();
554553
let target_crate = is_target_crate();
554+
let print = get_arg_flag_value("--print").is_some(); // whether this is cargo passing `--print` to get some infos
555+
556+
// rlib and cdylib are just skipped, we cannot interpret them and do not need them
557+
// for the rest of the build either.
558+
match get_arg_flag_value("--crate-type").as_deref() {
559+
Some("rlib") | Some("cdylib") => {
560+
if verbose {
561+
eprint!("[cargo-miri rustc] (rlib/cdylib skipped)");
562+
}
563+
return;
564+
}
565+
_ => {},
566+
}
555567

556-
if target_crate && is_runnable_crate() {
568+
if !print && target_crate && is_runnable_crate() {
557569
// This is the binary or test crate that we want to interpret under Miri.
558570
// But we cannot run it here, as cargo invoked us as a compiler -- our stdin and stdout are not
559571
// like we want them.
@@ -577,7 +589,7 @@ fn phase_cargo_rustc(args: env::Args) {
577589
let mut emit_link_hack = false;
578590
// Arguments are treated very differently depending on whether this crate is
579591
// for interpretation by Miri, or for use by a build script / proc macro.
580-
if target_crate {
592+
if !print && target_crate {
581593
// Forward arguments, but remove "link" from "--emit" to make this a check-only build.
582594
let emit_flag = "--emit";
583595
for arg in args {
@@ -607,7 +619,7 @@ fn phase_cargo_rustc(args: env::Args) {
607619
cmd.arg("--sysroot");
608620
cmd.arg(sysroot);
609621
} else {
610-
// For host crates, just forward everything.
622+
// For host crates or when we are printing, just forward everything.
611623
cmd.args(args);
612624
}
613625

0 commit comments

Comments
 (0)