@@ -1100,25 +1100,23 @@ actual:\n\
11001100 }
11011101
11021102 fn compile_test ( & self ) -> ProcRes {
1103- let aux_dir = self . aux_output_dir_name ( ) ;
1104- // FIXME (#9639): This needs to handle non-utf8 paths
1105- let mut extra_args = vec ! [ "-L" . to_owned( ) ,
1106- aux_dir. to_str( ) . unwrap( ) . to_owned( ) ] ;
1103+ let mut rustc = self . make_compile_args (
1104+ & self . testpaths . file , TargetLocation :: ThisFile ( self . make_exe_name ( ) ) ) ;
1105+
1106+ rustc. arg ( "-L" ) . arg ( & self . aux_output_dir_name ( ) ) ;
1107+
11071108 match self . config . mode {
11081109 CompileFail | Ui => {
11091110 // compile-fail and ui tests tend to have tons of unused code as
11101111 // it's just testing various pieces of the compile, but we don't
11111112 // want to actually assert warnings about all this code. Instead
11121113 // let's just ignore unused code warnings by defaults and tests
11131114 // can turn it back on if needed.
1114- extra_args. push ( "-A" . to_owned ( ) ) ;
1115- extra_args. push ( "unused" . to_owned ( ) ) ;
1115+ rustc. args ( & [ "-A" , "unused" ] ) ;
11161116 }
11171117 _ => { }
11181118 }
11191119
1120- let rustc = self . make_compile_args (
1121- extra_args, & self . testpaths . file , TargetLocation :: ThisFile ( self . make_exe_name ( ) ) ) ;
11221120 self . compose_and_run_compiler ( rustc, None )
11231121 }
11241122
@@ -1241,17 +1239,27 @@ actual:\n\
12411239 }
12421240
12431241 let aux_dir = self . aux_output_dir_name ( ) ;
1244- // FIXME (#9639): This needs to handle non-utf8 paths
1245- let extra_link_args = vec ! [ "-L" . to_owned( ) ,
1246- aux_dir. to_str( ) . unwrap( ) . to_owned( ) ] ;
12471242
12481243 for rel_ab in & self . props . aux_builds {
12491244 let aux_testpaths = self . compute_aux_test_paths ( rel_ab) ;
12501245 let aux_props = self . props . from_aux_file ( & aux_testpaths. file ,
12511246 self . revision ,
12521247 self . config ) ;
1253- let mut crate_type = if aux_props. no_prefer_dynamic {
1254- Vec :: new ( )
1248+ let aux_output = {
1249+ let f = self . make_lib_name ( & self . testpaths . file ) ;
1250+ let parent = f. parent ( ) . unwrap ( ) ;
1251+ TargetLocation :: ThisDirectory ( parent. to_path_buf ( ) )
1252+ } ;
1253+ let aux_cx = TestCx {
1254+ config : self . config ,
1255+ props : & aux_props,
1256+ testpaths : & aux_testpaths,
1257+ revision : self . revision
1258+ } ;
1259+ let mut aux_rustc = aux_cx. make_compile_args ( & aux_testpaths. file , aux_output) ;
1260+
1261+ let crate_type = if aux_props. no_prefer_dynamic {
1262+ None
12551263 } else if ( self . config . target . contains ( "musl" ) && !aux_props. force_host ) ||
12561264 self . config . target . contains ( "emscripten" ) {
12571265 // We primarily compile all auxiliary libraries as dynamic libraries
@@ -1263,24 +1271,17 @@ actual:\n\
12631271 // dynamic libraries so we just go back to building a normal library. Note,
12641272 // however, that for MUSL if the library is built with `force_host` then
12651273 // it's ok to be a dylib as the host should always support dylibs.
1266- vec ! [ "--crate-type= lib". to_owned ( ) ]
1274+ Some ( " lib")
12671275 } else {
1268- vec ! [ "--crate-type=dylib" . to_owned( ) ]
1269- } ;
1270- crate_type. extend ( extra_link_args. clone ( ) ) ;
1271- let aux_output = {
1272- let f = self . make_lib_name ( & self . testpaths . file ) ;
1273- let parent = f. parent ( ) . unwrap ( ) ;
1274- TargetLocation :: ThisDirectory ( parent. to_path_buf ( ) )
1275- } ;
1276- let aux_cx = TestCx {
1277- config : self . config ,
1278- props : & aux_props,
1279- testpaths : & aux_testpaths,
1280- revision : self . revision
1276+ Some ( "dylib" )
12811277 } ;
1282- let aux_rustc =
1283- aux_cx. make_compile_args ( crate_type, & aux_testpaths. file , aux_output) ;
1278+
1279+ if let Some ( crate_type) = crate_type {
1280+ aux_rustc. args ( & [ "--crate-type" , crate_type] ) ;
1281+ }
1282+
1283+ aux_rustc. arg ( "-L" ) . arg ( & aux_dir) ;
1284+
12841285 let auxres = aux_cx. compose_and_run ( aux_rustc,
12851286 aux_cx. config . compile_lib_path . to_str ( ) . unwrap ( ) ,
12861287 Some ( aux_dir. to_str ( ) . unwrap ( ) ) ,
@@ -1337,12 +1338,7 @@ actual:\n\
13371338 result
13381339 }
13391340
1340- fn make_compile_args ( & self ,
1341- extra_args : Vec < String > ,
1342- input_file : & Path ,
1343- output_file : TargetLocation )
1344- -> Command
1345- {
1341+ fn make_compile_args ( & self , input_file : & Path , output_file : TargetLocation ) -> Command {
13461342 let mut rustc = Command :: new ( & self . config . rustc_path ) ;
13471343 rustc. arg ( input_file)
13481344 . arg ( "-L" ) . arg ( & self . config . build_base ) ;
@@ -1410,8 +1406,6 @@ actual:\n\
14101406 }
14111407 }
14121408
1413- rustc. args ( & extra_args) ;
1414-
14151409 if !self . props . no_prefer_dynamic {
14161410 rustc. args ( & [ "-C" , "prefer-dynamic" ] ) ;
14171411 }
@@ -1635,17 +1629,13 @@ actual:\n\
16351629
16361630 fn compile_test_and_save_ir ( & self ) -> ProcRes {
16371631 let aux_dir = self . aux_output_dir_name ( ) ;
1638- // FIXME (#9639): This needs to handle non-utf8 paths
1639- let mut link_args = vec ! [ "-L" . to_owned( ) ,
1640- aux_dir. to_str( ) . unwrap( ) . to_owned( ) ] ;
1641- let llvm_args = vec ! [ "--emit=llvm-ir" . to_owned( ) , ] ;
1642- link_args. extend ( llvm_args) ;
1643- let rustc = self . make_compile_args ( link_args,
1644- & self . testpaths . file ,
1645- TargetLocation :: ThisDirectory (
1646- self . output_base_name ( ) . parent ( )
1647- . unwrap ( )
1648- . to_path_buf ( ) ) ) ;
1632+
1633+ let output_file = TargetLocation :: ThisDirectory (
1634+ self . output_base_name ( ) . parent ( ) . unwrap ( ) . to_path_buf ( ) ) ;
1635+ let mut rustc = self . make_compile_args ( & self . testpaths . file , output_file) ;
1636+ rustc. arg ( "-L" ) . arg ( aux_dir)
1637+ . arg ( "--emit=llvm-ir" ) ;
1638+
16491639 self . compose_and_run_compiler ( rustc, None )
16501640 }
16511641
0 commit comments