@@ -761,17 +761,19 @@ fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
761
761
"WARNING: Ignoring `RUSTC` environment variable; set `MIRI` if you want to control the binary used as the driver."
762
762
) ;
763
763
}
764
- // Build scripts (and also cargo: https://github.com/rust-lang/cargo/issues/10885) will invoke `rustc` even when `RUSTC_WRAPPER` is set.
765
- // To make sure everything is coherent, we want that to be the Miri driver, but acting as rustc, on the target level.
766
- // (Target, rather than host, is needed for cross-interpretation situations.) This is not a
767
- // perfect emulation of real rustc (it might be unable to produce binaries since the sysroot is
768
- // check-only), but it's as close as we can get, and it's good enough for autocfg.
764
+ // Build scripts (and also cargo: https://github.com/rust-lang/cargo/issues/10885) will invoke
765
+ // `rustc` even when `RUSTC_WRAPPER` is set. To make sure everything is coherent, we want that
766
+ // to be the Miri driver, but acting as rustc, on the target level. (Target, rather than host,
767
+ // is needed for cross-interpretation situations.) This is not a perfect emulation of real rustc
768
+ // (it might be unable to produce binaries since the sysroot is check-only), but it's as close
769
+ // as we can get, and it's good enough for autocfg.
769
770
//
770
771
// In `main`, we need the value of `RUSTC` to distinguish RUSTC_WRAPPER invocations from rustdoc
771
772
// or TARGET_RUNNER invocations, so we canonicalize it here to make it exceedingly unlikely that
772
- // there would be a collision with other invocations of cargo-miri (as rustdoc or as runner).
773
- // We explicitly do this even if RUSTC_STAGE is set, since for these builds we do *not* want the
774
- // bootstrap `rustc` thing in our way! Instead, we have MIRI_HOST_SYSROOT to use for host builds.
773
+ // there would be a collision with other invocations of cargo-miri (as rustdoc or as runner). We
774
+ // explicitly do this even if RUSTC_STAGE is set, since for these builds we do *not* want the
775
+ // bootstrap `rustc` thing in our way! Instead, we have MIRI_HOST_SYSROOT to use for host
776
+ // builds.
775
777
cmd. env ( "RUSTC" , & fs:: canonicalize ( find_miri ( ) ) . unwrap ( ) ) ;
776
778
cmd. env ( "MIRI_BE_RUSTC" , "target" ) ; // we better remember to *unset* this in the other phases!
777
779
@@ -850,7 +852,8 @@ fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
850
852
let verbose = std:: env:: var ( "MIRI_VERBOSE" )
851
853
. map_or ( 0 , |verbose| verbose. parse ( ) . expect ( "verbosity flag must be an integer" ) ) ;
852
854
let target_crate = is_target_crate ( ) ;
853
- let print = get_arg_flag_value ( "--print" ) . is_some ( ) || has_arg_flag ( "-vV" ) ; // whether this is cargo/xargo invoking rustc to get some infos
855
+ // Determine whether this is cargo/xargo invoking rustc to get some infos.
856
+ let info_query = get_arg_flag_value ( "--print" ) . is_some ( ) || has_arg_flag ( "-vV" ) ;
854
857
855
858
let store_json = |info : CrateRunInfo | {
856
859
// Create a stub .d file to stop Cargo from "rebuilding" the crate:
@@ -872,7 +875,7 @@ fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
872
875
info. store ( & out_filename ( "" , ".exe" ) ) ;
873
876
} ;
874
877
875
- let runnable_crate = !print && is_runnable_crate ( ) ;
878
+ let runnable_crate = !info_query && is_runnable_crate ( ) ;
876
879
877
880
if runnable_crate && target_crate {
878
881
assert ! (
@@ -934,7 +937,7 @@ fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
934
937
let mut emit_link_hack = false ;
935
938
// Arguments are treated very differently depending on whether this crate is
936
939
// for interpretation by Miri, or for use by a build script / proc macro.
937
- if !print && target_crate {
940
+ if !info_query && target_crate {
938
941
// Forward arguments, but remove "link" from "--emit" to make this a check-only build.
939
942
let emit_flag = "--emit" ;
940
943
while let Some ( arg) = args. next ( ) {
@@ -968,8 +971,9 @@ fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
968
971
cmd. arg ( "-C" ) . arg ( "panic=abort" ) ;
969
972
}
970
973
} else {
971
- // For host crates (but not when we are printing), we might still have to set the sysroot.
972
- if !print {
974
+ // For host crates (but not when we are just printing some info),
975
+ // we might still have to set the sysroot.
976
+ if !info_query {
973
977
// When we're running `cargo-miri` from `x.py` we need to pass the sysroot explicitly
974
978
// due to bootstrap complications.
975
979
if let Some ( sysroot) = std:: env:: var_os ( "MIRI_HOST_SYSROOT" ) {
@@ -990,7 +994,7 @@ fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
990
994
// Run it.
991
995
if verbose > 0 {
992
996
eprintln ! (
993
- "[cargo-miri rustc] target_crate={target_crate} runnable_crate={runnable_crate} print={print }"
997
+ "[cargo-miri rustc] target_crate={target_crate} runnable_crate={runnable_crate} info_query={info_query }"
994
998
) ;
995
999
}
996
1000
debug_cmd ( "[cargo-miri rustc]" , verbose, & cmd) ;
@@ -1030,7 +1034,9 @@ fn phase_runner(mut binary_args: impl Iterator<Item = String>, phase: RunnerPhas
1030
1034
1031
1035
let binary = binary_args. next ( ) . unwrap ( ) ;
1032
1036
let file = File :: open ( & binary)
1033
- . unwrap_or_else ( |_| show_error ( format ! ( "file {:?} not found or `cargo-miri` invoked incorrectly; please only invoke this binary through `cargo miri`" , binary) ) ) ;
1037
+ . unwrap_or_else ( |_| show_error ( format ! (
1038
+ "file {:?} not found or `cargo-miri` invoked incorrectly; please only invoke this binary through `cargo miri`" , binary
1039
+ ) ) ) ;
1034
1040
let file = BufReader :: new ( file) ;
1035
1041
1036
1042
let info = serde_json:: from_reader ( file) . unwrap_or_else ( |_| {
0 commit comments