@@ -532,8 +532,7 @@ fn phase_cargo_rustc(args: env::Args) {
532
532
fn is_runnable_crate ( ) -> bool {
533
533
let is_bin = get_arg_flag_value ( "--crate-type" ) . as_deref ( ) . unwrap_or ( "bin" ) == "bin" ;
534
534
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
537
536
}
538
537
539
538
fn out_filename ( prefix : & str , suffix : & str ) -> PathBuf {
@@ -552,8 +551,21 @@ fn phase_cargo_rustc(args: env::Args) {
552
551
553
552
let verbose = std:: env:: var_os ( "MIRI_VERBOSE" ) . is_some ( ) ;
554
553
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
+ }
555
567
556
- if target_crate && is_runnable_crate ( ) {
568
+ if !print && target_crate && is_runnable_crate ( ) {
557
569
// This is the binary or test crate that we want to interpret under Miri.
558
570
// But we cannot run it here, as cargo invoked us as a compiler -- our stdin and stdout are not
559
571
// like we want them.
@@ -577,7 +589,7 @@ fn phase_cargo_rustc(args: env::Args) {
577
589
let mut emit_link_hack = false ;
578
590
// Arguments are treated very differently depending on whether this crate is
579
591
// for interpretation by Miri, or for use by a build script / proc macro.
580
- if target_crate {
592
+ if !print && target_crate {
581
593
// Forward arguments, but remove "link" from "--emit" to make this a check-only build.
582
594
let emit_flag = "--emit" ;
583
595
for arg in args {
@@ -607,7 +619,7 @@ fn phase_cargo_rustc(args: env::Args) {
607
619
cmd. arg ( "--sysroot" ) ;
608
620
cmd. arg ( sysroot) ;
609
621
} else {
610
- // For host crates, just forward everything.
622
+ // For host crates or when we are printing , just forward everything.
611
623
cmd. args ( args) ;
612
624
}
613
625
0 commit comments