@@ -141,6 +141,9 @@ pub fn run_compiler(
141
141
callbacks : & mut ( dyn Callbacks + Send ) ,
142
142
file_loader : Option < Box < dyn FileLoader + Send + Sync > > ,
143
143
emitter : Option < Box < dyn Write + Send > > ,
144
+ make_codegen_backend : Option <
145
+ Box < dyn FnOnce ( & config:: Options ) -> Box < dyn CodegenBackend > + Send > ,
146
+ > ,
144
147
) -> interface:: Result < ( ) > {
145
148
let mut args = Vec :: new ( ) ;
146
149
for arg in at_args {
@@ -162,6 +165,11 @@ pub fn run_compiler(
162
165
let sopts = config:: build_session_options ( & matches) ;
163
166
let cfg = interface:: parse_cfgspecs ( matches. opt_strs ( "cfg" ) ) ;
164
167
168
+ // We wrap `make_codegen_backend` in another `Option` such that `dummy_config` can take
169
+ // ownership of it when necessary, while also allowing the non-dummy config to take ownership
170
+ // when `dummy_config` is not used.
171
+ let mut make_codegen_backend = Some ( make_codegen_backend) ;
172
+
165
173
let mut dummy_config = |sopts, cfg, diagnostic_output| {
166
174
let mut config = interface:: Config {
167
175
opts : sopts,
@@ -177,6 +185,7 @@ pub fn run_compiler(
177
185
lint_caps : Default :: default ( ) ,
178
186
register_lints : None ,
179
187
override_queries : None ,
188
+ make_codegen_backend : make_codegen_backend. take ( ) . unwrap ( ) ,
180
189
registry : diagnostics_registry ( ) ,
181
190
} ;
182
191
callbacks. config ( & mut config) ;
@@ -253,6 +262,7 @@ pub fn run_compiler(
253
262
lint_caps : Default :: default ( ) ,
254
263
register_lints : None ,
255
264
override_queries : None ,
265
+ make_codegen_backend : make_codegen_backend. unwrap ( ) ,
256
266
registry : diagnostics_registry ( ) ,
257
267
} ;
258
268
@@ -1265,7 +1275,7 @@ pub fn main() -> ! {
1265
1275
} )
1266
1276
} )
1267
1277
. collect :: < Vec < _ > > ( ) ;
1268
- run_compiler ( & args, & mut callbacks, None , None )
1278
+ run_compiler ( & args, & mut callbacks, None , None , None )
1269
1279
} ) ;
1270
1280
// The extra `\t` is necessary to align this label with the others.
1271
1281
print_time_passes_entry ( callbacks. time_passes , "\t total" , start. elapsed ( ) ) ;
0 commit comments