@@ -143,6 +143,18 @@ fn get_arg_flag_value(name: &str) -> Option<String> {
143
143
ArgFlagValueIter :: new ( name) . next ( )
144
144
}
145
145
146
+ fn forward_patched_extern_arg ( args : & mut impl Iterator < Item = String > , cmd : & mut Command ) {
147
+ cmd. arg ( "--extern" ) ; // always forward flag, but adjust filename:
148
+ let path = args. next ( ) . expect ( "`--extern` should be followed by a filename" ) ;
149
+ if let Some ( lib) = path. strip_suffix ( ".rlib" ) {
150
+ // If this is an rlib, make it an rmeta.
151
+ cmd. arg ( format ! ( "{}.rmeta" , lib) ) ;
152
+ } else {
153
+ // Some other extern file (e.g. a `.so`). Forward unchanged.
154
+ cmd. arg ( path) ;
155
+ }
156
+ }
157
+
146
158
/// Returns the path to the `miri` binary
147
159
fn find_miri ( ) -> PathBuf {
148
160
if let Some ( path) = env:: var_os ( "MIRI" ) {
@@ -734,21 +746,11 @@ fn phase_cargo_runner(binary: &Path, binary_args: env::Args) {
734
746
// but when we run here, cargo does not interpret the JSON any more. `--json`
735
747
// then also nees to be dropped.
736
748
let mut args = info. args . into_iter ( ) ;
737
- let extern_flag = "--extern" ;
738
749
let error_format_flag = "--error-format" ;
739
750
let json_flag = "--json" ;
740
751
while let Some ( arg) = args. next ( ) {
741
- if arg == extern_flag {
742
- cmd. arg ( extern_flag) ; // always forward flag, but adjust filename
743
- // `--extern` is always passed as a separate argument by cargo.
744
- let next_arg = args. next ( ) . expect ( "`--extern` should be followed by a filename" ) ;
745
- if let Some ( next_lib) = next_arg. strip_suffix ( ".rlib" ) {
746
- // If this is an rlib, make it an rmeta.
747
- cmd. arg ( format ! ( "{}.rmeta" , next_lib) ) ;
748
- } else {
749
- // Some other extern file (e.g., a `.so`). Forward unchanged.
750
- cmd. arg ( next_arg) ;
751
- }
752
+ if arg == "--extern" {
753
+ forward_patched_extern_arg ( & mut args, & mut cmd) ;
752
754
} else if arg. starts_with ( error_format_flag) {
753
755
let suffix = & arg[ error_format_flag. len ( ) ..] ;
754
756
assert ! ( suffix. starts_with( '=' ) ) ;
0 commit comments