@@ -208,11 +208,13 @@ enum WillExecute {
208
208
Disabled ,
209
209
}
210
210
211
- /// Should `--emit metadata` be used ?
211
+ /// What value should be passed to `--emit` ?
212
212
#[ derive( Copy , Clone ) ]
213
- enum EmitMetadata {
214
- Yes ,
215
- No ,
213
+ enum Emit {
214
+ None ,
215
+ Metadata ,
216
+ LlvmIr ,
217
+ Asm ,
216
218
}
217
219
218
220
impl < ' test > TestCx < ' test > {
@@ -412,7 +414,7 @@ impl<'test> TestCx<'test> {
412
414
}
413
415
414
416
let should_run = self . run_if_enabled ( ) ;
415
- let mut proc_res = self . compile_test ( should_run, EmitMetadata :: No ) ;
417
+ let mut proc_res = self . compile_test ( should_run, Emit :: None ) ;
416
418
417
419
if !proc_res. status . success ( ) {
418
420
self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
@@ -658,7 +660,7 @@ impl<'test> TestCx<'test> {
658
660
659
661
// compile test file (it should have 'compile-flags:-g' in the header)
660
662
let should_run = self . run_if_enabled ( ) ;
661
- let compile_result = self . compile_test ( should_run, EmitMetadata :: No ) ;
663
+ let compile_result = self . compile_test ( should_run, Emit :: None ) ;
662
664
if !compile_result. status . success ( ) {
663
665
self . fatal_proc_rec ( "compilation failed!" , & compile_result) ;
664
666
}
@@ -778,7 +780,7 @@ impl<'test> TestCx<'test> {
778
780
779
781
// compile test file (it should have 'compile-flags:-g' in the header)
780
782
let should_run = self . run_if_enabled ( ) ;
781
- let compiler_run_result = self . compile_test ( should_run, EmitMetadata :: No ) ;
783
+ let compiler_run_result = self . compile_test ( should_run, Emit :: None ) ;
782
784
if !compiler_run_result. status . success ( ) {
783
785
self . fatal_proc_rec ( "compilation failed!" , & compiler_run_result) ;
784
786
}
@@ -1010,7 +1012,7 @@ impl<'test> TestCx<'test> {
1010
1012
fn run_debuginfo_lldb_test_no_opt ( & self ) {
1011
1013
// compile test file (it should have 'compile-flags:-g' in the header)
1012
1014
let should_run = self . run_if_enabled ( ) ;
1013
- let compile_result = self . compile_test ( should_run, EmitMetadata :: No ) ;
1015
+ let compile_result = self . compile_test ( should_run, Emit :: None ) ;
1014
1016
if !compile_result. status . success ( ) {
1015
1017
self . fatal_proc_rec ( "compilation failed!" , & compile_result) ;
1016
1018
}
@@ -1426,21 +1428,21 @@ impl<'test> TestCx<'test> {
1426
1428
}
1427
1429
}
1428
1430
1429
- fn should_emit_metadata ( & self , pm : Option < PassMode > ) -> EmitMetadata {
1431
+ fn should_emit_metadata ( & self , pm : Option < PassMode > ) -> Emit {
1430
1432
match ( pm, self . props . fail_mode , self . config . mode ) {
1431
- ( Some ( PassMode :: Check ) , ..) | ( _, Some ( FailMode :: Check ) , Ui ) => EmitMetadata :: Yes ,
1432
- _ => EmitMetadata :: No ,
1433
+ ( Some ( PassMode :: Check ) , ..) | ( _, Some ( FailMode :: Check ) , Ui ) => Emit :: Metadata ,
1434
+ _ => Emit :: None ,
1433
1435
}
1434
1436
}
1435
1437
1436
- fn compile_test ( & self , will_execute : WillExecute , emit_metadata : EmitMetadata ) -> ProcRes {
1437
- self . compile_test_general ( will_execute, emit_metadata , self . props . local_pass_mode ( ) )
1438
+ fn compile_test ( & self , will_execute : WillExecute , emit : Emit ) -> ProcRes {
1439
+ self . compile_test_general ( will_execute, emit , self . props . local_pass_mode ( ) )
1438
1440
}
1439
1441
1440
1442
fn compile_test_general (
1441
1443
& self ,
1442
1444
will_execute : WillExecute ,
1443
- emit_metadata : EmitMetadata ,
1445
+ emit : Emit ,
1444
1446
local_pm : Option < PassMode > ,
1445
1447
) -> ProcRes {
1446
1448
// Only use `make_exe_name` when the test ends up being executed.
@@ -1472,10 +1474,13 @@ impl<'test> TestCx<'test> {
1472
1474
_ => AllowUnused :: No ,
1473
1475
} ;
1474
1476
1475
- let mut rustc =
1476
- self . make_compile_args ( & self . testpaths . file , output_file, emit_metadata, allow_unused) ;
1477
-
1478
- rustc. arg ( "-L" ) . arg ( & self . aux_output_dir_name ( ) ) ;
1477
+ let rustc = self . make_compile_args (
1478
+ & self . testpaths . file ,
1479
+ output_file,
1480
+ emit,
1481
+ allow_unused,
1482
+ LinkToAux :: Yes ,
1483
+ ) ;
1479
1484
1480
1485
self . compose_and_run_compiler ( rustc, None )
1481
1486
}
@@ -1702,8 +1707,13 @@ impl<'test> TestCx<'test> {
1702
1707
// Create the directory for the stdout/stderr files.
1703
1708
create_dir_all ( aux_cx. output_base_dir ( ) ) . unwrap ( ) ;
1704
1709
let input_file = & aux_testpaths. file ;
1705
- let mut aux_rustc =
1706
- aux_cx. make_compile_args ( input_file, aux_output, EmitMetadata :: No , AllowUnused :: No ) ;
1710
+ let mut aux_rustc = aux_cx. make_compile_args (
1711
+ input_file,
1712
+ aux_output,
1713
+ Emit :: None ,
1714
+ AllowUnused :: No ,
1715
+ LinkToAux :: No ,
1716
+ ) ;
1707
1717
1708
1718
for key in & aux_props. unset_rustc_env {
1709
1719
aux_rustc. env_remove ( key) ;
@@ -1831,8 +1841,9 @@ impl<'test> TestCx<'test> {
1831
1841
& self ,
1832
1842
input_file : & Path ,
1833
1843
output_file : TargetLocation ,
1834
- emit_metadata : EmitMetadata ,
1844
+ emit : Emit ,
1835
1845
allow_unused : AllowUnused ,
1846
+ link_to_aux : LinkToAux ,
1836
1847
) -> Command {
1837
1848
let is_aux = input_file. components ( ) . map ( |c| c. as_os_str ( ) ) . any ( |c| c == "auxiliary" ) ;
1838
1849
let is_rustdoc = self . is_rustdoc ( ) && !is_aux;
@@ -1947,8 +1958,18 @@ impl<'test> TestCx<'test> {
1947
1958
}
1948
1959
}
1949
1960
1950
- if let ( false , EmitMetadata :: Yes ) = ( is_rustdoc, emit_metadata) {
1951
- rustc. args ( & [ "--emit" , "metadata" ] ) ;
1961
+ match emit {
1962
+ Emit :: None => { }
1963
+ Emit :: Metadata if is_rustdoc => { }
1964
+ Emit :: Metadata => {
1965
+ rustc. args ( & [ "--emit" , "metadata" ] ) ;
1966
+ }
1967
+ Emit :: LlvmIr => {
1968
+ rustc. args ( & [ "--emit" , "llvm-ir" ] ) ;
1969
+ }
1970
+ Emit :: Asm => {
1971
+ rustc. args ( & [ "--emit" , "asm" ] ) ;
1972
+ }
1952
1973
}
1953
1974
1954
1975
if !is_rustdoc {
@@ -2014,6 +2035,10 @@ impl<'test> TestCx<'test> {
2014
2035
rustc. arg ( "-Ctarget-feature=-crt-static" ) ;
2015
2036
}
2016
2037
2038
+ if let LinkToAux :: Yes = link_to_aux {
2039
+ rustc. arg ( "-L" ) . arg ( self . aux_output_dir_name ( ) ) ;
2040
+ }
2041
+
2017
2042
rustc. args ( & self . props . compile_flags ) ;
2018
2043
2019
2044
rustc
@@ -2205,13 +2230,15 @@ impl<'test> TestCx<'test> {
2205
2230
// codegen tests (using FileCheck)
2206
2231
2207
2232
fn compile_test_and_save_ir ( & self ) -> ProcRes {
2208
- let aux_dir = self . aux_output_dir_name ( ) ;
2209
-
2210
2233
let output_file = TargetLocation :: ThisDirectory ( self . output_base_dir ( ) ) ;
2211
2234
let input_file = & self . testpaths . file ;
2212
- let mut rustc =
2213
- self . make_compile_args ( input_file, output_file, EmitMetadata :: No , AllowUnused :: No ) ;
2214
- rustc. arg ( "-L" ) . arg ( aux_dir) . arg ( "--emit=llvm-ir" ) ;
2235
+ let rustc = self . make_compile_args (
2236
+ input_file,
2237
+ output_file,
2238
+ Emit :: LlvmIr ,
2239
+ AllowUnused :: No ,
2240
+ LinkToAux :: Yes ,
2241
+ ) ;
2215
2242
2216
2243
self . compose_and_run_compiler ( rustc, None )
2217
2244
}
@@ -2223,14 +2250,11 @@ impl<'test> TestCx<'test> {
2223
2250
2224
2251
let output_file = TargetLocation :: ThisFile ( output_path. clone ( ) ) ;
2225
2252
let input_file = & self . testpaths . file ;
2226
- let mut rustc =
2227
- self . make_compile_args ( input_file, output_file, EmitMetadata :: No , AllowUnused :: No ) ;
2228
-
2229
- rustc. arg ( "-L" ) . arg ( self . aux_output_dir_name ( ) ) ;
2230
2253
2254
+ let mut emit = Emit :: None ;
2231
2255
match self . props . assembly_output . as_ref ( ) . map ( AsRef :: as_ref) {
2232
2256
Some ( "emit-asm" ) => {
2233
- rustc . arg ( "-- emit=asm" ) ;
2257
+ emit = Emit :: Asm ;
2234
2258
}
2235
2259
2236
2260
Some ( "ptx-linker" ) => {
@@ -2241,6 +2265,9 @@ impl<'test> TestCx<'test> {
2241
2265
None => self . fatal ( "missing 'assembly-output' header" ) ,
2242
2266
}
2243
2267
2268
+ let rustc =
2269
+ self . make_compile_args ( input_file, output_file, emit, AllowUnused :: No , LinkToAux :: Yes ) ;
2270
+
2244
2271
( self . compose_and_run_compiler ( rustc, None ) , output_path)
2245
2272
}
2246
2273
@@ -2365,10 +2392,10 @@ impl<'test> TestCx<'test> {
2365
2392
let mut rustc = new_rustdoc. make_compile_args (
2366
2393
& new_rustdoc. testpaths . file ,
2367
2394
output_file,
2368
- EmitMetadata :: No ,
2395
+ Emit :: None ,
2369
2396
AllowUnused :: Yes ,
2397
+ LinkToAux :: Yes ,
2370
2398
) ;
2371
- rustc. arg ( "-L" ) . arg ( & new_rustdoc. aux_output_dir_name ( ) ) ;
2372
2399
new_rustdoc. build_all_auxiliary ( & mut rustc) ;
2373
2400
2374
2401
let proc_res = new_rustdoc. document ( & compare_dir) ;
@@ -2641,7 +2668,7 @@ impl<'test> TestCx<'test> {
2641
2668
fn run_codegen_units_test ( & self ) {
2642
2669
assert ! ( self . revision. is_none( ) , "revisions not relevant here" ) ;
2643
2670
2644
- let proc_res = self . compile_test ( WillExecute :: No , EmitMetadata :: No ) ;
2671
+ let proc_res = self . compile_test ( WillExecute :: No , Emit :: None ) ;
2645
2672
2646
2673
if !proc_res. status . success ( ) {
2647
2674
self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
@@ -3154,7 +3181,7 @@ impl<'test> TestCx<'test> {
3154
3181
if let Some ( FailMode :: Build ) = self . props . fail_mode {
3155
3182
// Make sure a build-fail test cannot fail due to failing analysis (e.g. typeck).
3156
3183
let pm = Some ( PassMode :: Check ) ;
3157
- let proc_res = self . compile_test_general ( WillExecute :: No , EmitMetadata :: Yes , pm) ;
3184
+ let proc_res = self . compile_test_general ( WillExecute :: No , Emit :: Metadata , pm) ;
3158
3185
self . check_if_test_should_compile ( & proc_res, pm) ;
3159
3186
}
3160
3187
@@ -3312,13 +3339,13 @@ impl<'test> TestCx<'test> {
3312
3339
if self . props . run_rustfix && self . config . compare_mode . is_none ( ) {
3313
3340
// And finally, compile the fixed code and make sure it both
3314
3341
// succeeds and has no diagnostics.
3315
- let mut rustc = self . make_compile_args (
3342
+ let rustc = self . make_compile_args (
3316
3343
& self . testpaths . file . with_extension ( UI_FIXED ) ,
3317
3344
TargetLocation :: ThisFile ( self . make_exe_name ( ) ) ,
3318
3345
emit_metadata,
3319
3346
AllowUnused :: No ,
3347
+ LinkToAux :: Yes ,
3320
3348
) ;
3321
- rustc. arg ( "-L" ) . arg ( & self . aux_output_dir_name ( ) ) ;
3322
3349
let res = self . compose_and_run_compiler ( rustc, None ) ;
3323
3350
if !res. status . success ( ) {
3324
3351
self . fatal_proc_rec ( "failed to compile fixed code" , & res) ;
@@ -3852,3 +3879,8 @@ enum AllowUnused {
3852
3879
Yes ,
3853
3880
No ,
3854
3881
}
3882
+
3883
+ enum LinkToAux {
3884
+ Yes ,
3885
+ No ,
3886
+ }
0 commit comments