@@ -70,7 +70,7 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
70
70
71
71
let ( chunk_size, chunk_count) = chunk_info ( self . intrinsics . len ( ) ) ;
72
72
73
- let cpp_compiler = compile:: build_cpp_compilation ( & self . cli_options ) . unwrap ( ) ;
73
+ let cpp_compiler_wrapped = compile:: build_cpp_compilation ( & self . cli_options ) ;
74
74
75
75
let notice = & build_notices ( "// " ) ;
76
76
fs:: create_dir_all ( "c_programs" ) . unwrap ( ) ;
@@ -82,10 +82,15 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
82
82
let mut file = File :: create ( & c_filename) . unwrap ( ) ;
83
83
write_mod_cpp ( & mut file, notice, c_target, platform_headers, chunk) . unwrap ( ) ;
84
84
85
- // compile this cpp file into a .o file
86
- let output = cpp_compiler
87
- . compile_object_file ( & format ! ( "mod_{i}.cpp" ) , & format ! ( "mod_{i}.o" ) ) ?;
88
- assert ! ( output. status. success( ) , "{output:?}" ) ;
85
+ // compile this cpp file into a .o file.
86
+ //
87
+ // This is done because `cpp_compiler_wrapped` is None when
88
+ // the --generate-only flag is passed
89
+ if let Some ( cpp_compiler) = cpp_compiler_wrapped. as_ref ( ) {
90
+ let output = cpp_compiler
91
+ . compile_object_file ( & format ! ( "mod_{i}.cpp" ) , & format ! ( "mod_{i}.o" ) ) ?;
92
+ assert ! ( output. status. success( ) , "{output:?}" ) ;
93
+ }
89
94
90
95
Ok ( ( ) )
91
96
} )
@@ -101,21 +106,25 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
101
106
)
102
107
. unwrap ( ) ;
103
108
104
- // compile this cpp file into a .o file
105
- info ! ( "compiling main.cpp" ) ;
106
- let output = cpp_compiler
107
- . compile_object_file ( "main.cpp" , "intrinsic-test-programs.o" )
108
- . unwrap ( ) ;
109
- assert ! ( output. status. success( ) , "{output:?}" ) ;
110
-
111
- let object_files = ( 0 ..chunk_count)
112
- . map ( |i| format ! ( "mod_{i}.o" ) )
113
- . chain ( [ "intrinsic-test-programs.o" . to_owned ( ) ] ) ;
114
-
115
- let output = cpp_compiler
116
- . link_executable ( object_files, "intrinsic-test-programs" )
117
- . unwrap ( ) ;
118
- assert ! ( output. status. success( ) , "{output:?}" ) ;
109
+ // This is done because `cpp_compiler_wrapped` is None when
110
+ // the --generate-only flag is passed
111
+ if let Some ( cpp_compiler) = cpp_compiler_wrapped. as_ref ( ) {
112
+ // compile this cpp file into a .o file
113
+ info ! ( "compiling main.cpp" ) ;
114
+ let output = cpp_compiler
115
+ . compile_object_file ( "main.cpp" , "intrinsic-test-programs.o" )
116
+ . unwrap ( ) ;
117
+ assert ! ( output. status. success( ) , "{output:?}" ) ;
118
+
119
+ let object_files = ( 0 ..chunk_count)
120
+ . map ( |i| format ! ( "mod_{i}.o" ) )
121
+ . chain ( [ "intrinsic-test-programs.o" . to_owned ( ) ] ) ;
122
+
123
+ let output = cpp_compiler
124
+ . link_executable ( object_files, "intrinsic-test-programs" )
125
+ . unwrap ( ) ;
126
+ assert ! ( output. status. success( ) , "{output:?}" ) ;
127
+ }
119
128
120
129
true
121
130
}
0 commit comments