@@ -52,18 +52,6 @@ fn show_version() {
5252 println ! ( ) ;
5353}
5454
55- fn forward_patched_extern_arg ( args : & mut impl Iterator < Item = String > , cmd : & mut Command ) {
56- cmd. arg ( "--extern" ) ; // always forward flag, but adjust filename:
57- let path = args. next ( ) . expect ( "`--extern` should be followed by a filename" ) ;
58- if let Some ( lib) = path. strip_suffix ( ".rlib" ) {
59- // If this is an rlib, make it an rmeta.
60- cmd. arg ( format ! ( "{lib}.rmeta" ) ) ;
61- } else {
62- // Some other extern file (e.g. a `.so`). Forward unchanged.
63- cmd. arg ( path) ;
64- }
65- }
66-
6755pub fn phase_cargo_miri ( mut args : impl Iterator < Item = String > ) {
6856 // Require a subcommand before any flags.
6957 // We cannot know which of those flags take arguments and which do not,
@@ -444,7 +432,6 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
444432 }
445433
446434 let mut cmd = miri ( ) ;
447- let mut emit_link_hack = false ;
448435 // Arguments are treated very differently depending on whether this crate is
449436 // for interpretation by Miri, or for use by a build script / proc macro.
450437 if target_crate {
@@ -455,7 +442,7 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
455442 }
456443
457444 // Forward arguments, but patched.
458- let emit_flag = "--emit" ;
445+
459446 // This hack helps bootstrap run standard library tests in Miri. The issue is as follows:
460447 // when running `cargo miri test` on libcore, cargo builds a local copy of core and makes it
461448 // a dependency of the integration test crate. This copy duplicates all the lang items, so
@@ -472,29 +459,6 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
472459 && !runnable_crate
473460 && phase == RustcPhase :: Build ;
474461 while let Some ( arg) = args. next ( ) {
475- // Patch `--emit`: remove "link" from "--emit" to make this a check-only build.
476- if let Some ( val) = arg. strip_prefix ( emit_flag) {
477- // Patch this argument. First, extract its value.
478- let val =
479- val. strip_prefix ( '=' ) . expect ( "`cargo` should pass `--emit=X` as one argument" ) ;
480- let mut val: Vec < _ > = val. split ( ',' ) . collect ( ) ;
481- // Now make sure "link" is not in there, but "metadata" is.
482- if let Some ( i) = val. iter ( ) . position ( |& s| s == "link" ) {
483- emit_link_hack = true ;
484- val. remove ( i) ;
485- if !val. contains ( & "metadata" ) {
486- val. push ( "metadata" ) ;
487- }
488- }
489- cmd. arg ( format ! ( "{emit_flag}={}" , val. join( "," ) ) ) ;
490- continue ;
491- }
492- // Patch `--extern` filenames, since Cargo sometimes passes stub `.rlib` files:
493- // https://github.com/rust-lang/miri/issues/1705
494- if arg == "--extern" {
495- forward_patched_extern_arg ( & mut args, & mut cmd) ;
496- continue ;
497- }
498462 // If the REPLACE_LIBRS hack is enabled and we are building a `lib.rs` file, and a
499463 // `lib.miri.rs` file exists, then build that instead.
500464 if replace_librs {
@@ -543,17 +507,6 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
543507 eprintln ! ( "[cargo-miri rustc] target_crate={target_crate} runnable_crate={runnable_crate}" ) ;
544508 }
545509
546- // Create a stub .rlib file if "link" was requested by cargo.
547- // This is necessary to prevent cargo from doing rebuilds all the time.
548- if emit_link_hack {
549- for filename in out_filenames ( ) {
550- if verbose > 0 {
551- eprintln ! ( "[cargo-miri rustc] creating fake lib file at `{}`" , filename. display( ) ) ;
552- }
553- File :: create ( filename) . expect ( "failed to create fake lib file" ) ;
554- }
555- }
556-
557510 debug_cmd ( "[cargo-miri rustc]" , verbose, & cmd) ;
558511 exec ( cmd) ;
559512}
@@ -624,17 +577,12 @@ pub fn phase_runner(mut binary_args: impl Iterator<Item = String>, phase: Runner
624577 cmd. arg ( "--sysroot" ) . arg ( env:: var_os ( "MIRI_SYSROOT" ) . unwrap ( ) ) ;
625578 }
626579 // Forward rustc arguments.
627- // We need to patch "--extern" filenames because we forced a check-only
628- // build without cargo knowing about that: replace `.rlib` suffix by
629- // `.rmeta`.
630- // We also need to remove `--error-format` as cargo specifies that to be JSON,
580+ // We need to remove `--error-format` as cargo specifies that to be JSON,
631581 // but when we run here, cargo does not interpret the JSON any more. `--json`
632582 // then also needs to be dropped.
633583 let mut args = info. args . iter ( ) ;
634584 while let Some ( arg) = args. next ( ) {
635- if arg == "--extern" {
636- forward_patched_extern_arg ( & mut ( & mut args) . cloned ( ) , & mut cmd) ;
637- } else if let Some ( suffix) = arg. strip_prefix ( "--error-format" ) {
585+ if let Some ( suffix) = arg. strip_prefix ( "--error-format" ) {
638586 assert ! ( suffix. starts_with( '=' ) ) ;
639587 // Drop this argument.
640588 } else if let Some ( suffix) = arg. strip_prefix ( "--json" ) {
@@ -668,23 +616,15 @@ pub fn phase_runner(mut binary_args: impl Iterator<Item = String>, phase: Runner
668616 }
669617}
670618
671- pub fn phase_rustdoc ( mut args : impl Iterator < Item = String > ) {
619+ pub fn phase_rustdoc ( args : impl Iterator < Item = String > ) {
672620 let verbose = env:: var ( "MIRI_VERBOSE" )
673621 . map_or ( 0 , |verbose| verbose. parse ( ) . expect ( "verbosity flag must be an integer" ) ) ;
674622
675623 // phase_cargo_miri sets the RUSTDOC env var to ourselves, and puts a backup
676624 // of the old value into MIRI_ORIG_RUSTDOC. So that's what we have to invoke now.
677625 let rustdoc = env:: var ( "MIRI_ORIG_RUSTDOC" ) . unwrap_or ( "rustdoc" . to_string ( ) ) ;
678626 let mut cmd = Command :: new ( rustdoc) ;
679-
680- while let Some ( arg) = args. next ( ) {
681- if arg == "--extern" {
682- // Patch --extern arguments to use *.rmeta files, since phase_cargo_rustc only creates stub *.rlib files.
683- forward_patched_extern_arg ( & mut args, & mut cmd) ;
684- } else {
685- cmd. arg ( arg) ;
686- }
687- }
627+ cmd. args ( args) ;
688628
689629 // Doctests of `proc-macro` crates (and their dependencies) are always built for the host,
690630 // so we are not able to run them in Miri.
0 commit comments