@@ -141,6 +141,9 @@ pub fn run_compiler(
141141 callbacks : & mut ( dyn Callbacks + Send ) ,
142142 file_loader : Option < Box < dyn FileLoader + Send + Sync > > ,
143143 emitter : Option < Box < dyn Write + Send > > ,
144+ make_codegen_backend : Option <
145+ Box < dyn FnOnce ( & config:: Options ) -> Box < dyn CodegenBackend > + Send > ,
146+ > ,
144147) -> interface:: Result < ( ) > {
145148 let mut args = Vec :: new ( ) ;
146149 for arg in at_args {
@@ -162,6 +165,11 @@ pub fn run_compiler(
162165 let sopts = config:: build_session_options ( & matches) ;
163166 let cfg = interface:: parse_cfgspecs ( matches. opt_strs ( "cfg" ) ) ;
164167
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+
165173 let mut dummy_config = |sopts, cfg, diagnostic_output| {
166174 let mut config = interface:: Config {
167175 opts : sopts,
@@ -177,6 +185,7 @@ pub fn run_compiler(
177185 lint_caps : Default :: default ( ) ,
178186 register_lints : None ,
179187 override_queries : None ,
188+ make_codegen_backend : make_codegen_backend. take ( ) . unwrap ( ) ,
180189 registry : diagnostics_registry ( ) ,
181190 } ;
182191 callbacks. config ( & mut config) ;
@@ -253,6 +262,7 @@ pub fn run_compiler(
253262 lint_caps : Default :: default ( ) ,
254263 register_lints : None ,
255264 override_queries : None ,
265+ make_codegen_backend : make_codegen_backend. unwrap ( ) ,
256266 registry : diagnostics_registry ( ) ,
257267 } ;
258268
@@ -1265,7 +1275,7 @@ pub fn main() -> ! {
12651275 } )
12661276 } )
12671277 . collect :: < Vec < _ > > ( ) ;
1268- run_compiler ( & args, & mut callbacks, None , None )
1278+ run_compiler ( & args, & mut callbacks, None , None , None )
12691279 } ) ;
12701280 // The extra `\t` is necessary to align this label with the others.
12711281 print_time_passes_entry ( callbacks. time_passes , "\t total" , start. elapsed ( ) ) ;
0 commit comments