1
- use super :: TestCx ;
1
+ use std:: path:: PathBuf ;
2
+
3
+ use super :: { AllowUnused , Emit , LinkToAux , ProcRes , TargetLocation , TestCx } ;
2
4
3
5
impl TestCx < ' _ > {
4
6
pub ( super ) fn run_assembly_test ( & self ) {
@@ -16,4 +18,32 @@ impl TestCx<'_> {
16
18
self . fatal_proc_rec ( "verification with 'FileCheck' failed" , & proc_res) ;
17
19
}
18
20
}
21
+
22
+ fn compile_test_and_save_assembly ( & self ) -> ( ProcRes , PathBuf ) {
23
+ // This works with both `--emit asm` (as default output name for the assembly)
24
+ // and `ptx-linker` because the latter can write output at requested location.
25
+ let output_path = self . output_base_name ( ) . with_extension ( "s" ) ;
26
+ let input_file = & self . testpaths . file ;
27
+
28
+ // Use the `//@ assembly-output:` directive to determine how to emit assembly.
29
+ let emit = match self . props . assembly_output . as_deref ( ) {
30
+ Some ( "emit-asm" ) => Emit :: Asm ,
31
+ Some ( "bpf-linker" ) => Emit :: LinkArgsAsm ,
32
+ Some ( "ptx-linker" ) => Emit :: None , // No extra flags needed.
33
+ Some ( other) => self . fatal ( & format ! ( "unknown 'assembly-output' directive: {other}" ) ) ,
34
+ None => self . fatal ( "missing 'assembly-output' directive" ) ,
35
+ } ;
36
+
37
+ let rustc = self . make_compile_args (
38
+ input_file,
39
+ TargetLocation :: ThisFile ( output_path. clone ( ) ) ,
40
+ emit,
41
+ AllowUnused :: No ,
42
+ LinkToAux :: Yes ,
43
+ Vec :: new ( ) ,
44
+ ) ;
45
+
46
+ let proc_res = self . compose_and_run_compiler ( rustc, None , self . testpaths ) ;
47
+ ( proc_res, output_path)
48
+ }
19
49
}
0 commit comments