44use std:: fs:: File ;
55use std:: io:: BufWriter ;
66use std:: path:: PathBuf ;
7- use std:: sync:: Arc ;
87use std:: thread:: JoinHandle ;
98
109use cranelift_object:: { ObjectBuilder , ObjectModule } ;
@@ -344,7 +343,6 @@ fn codegen_cgu_content(
344343
345344fn module_codegen (
346345 tcx : TyCtxt < ' _ > ,
347- global_asm_config : Arc < GlobalAsmConfig > ,
348346 cgu_name : rustc_span:: Symbol ,
349347 token : ConcurrencyLimiterToken ,
350348) -> OngoingModuleCodegen {
@@ -360,6 +358,7 @@ fn module_codegen(
360358 let profiler = tcx. prof . clone ( ) ;
361359 let output_filenames = tcx. output_filenames ( ( ) ) . clone ( ) ;
362360 let should_write_ir = crate :: pretty_clif:: should_write_ir ( tcx. sess ) ;
361+ let global_asm_config = GlobalAsmConfig :: new ( tcx. sess ) ;
363362
364363 OngoingModuleCodegen :: Async ( std:: thread:: spawn ( move || {
365364 profiler. clone ( ) . generic_activity_with_arg ( "compile functions" , & * cgu_name) . run ( || {
@@ -461,8 +460,6 @@ pub(crate) fn run_aot(tcx: TyCtxt<'_>) -> Box<OngoingCodegen> {
461460 }
462461 } ) ;
463462
464- let global_asm_config = Arc :: new ( crate :: global_asm:: GlobalAsmConfig :: new ( tcx. sess ) ) ;
465-
466463 let ( todo_cgus, done_cgus) =
467464 cgus. iter ( ) . enumerate ( ) . partition :: < Vec < _ > , _ > ( |& ( i, _) | match cgu_reuse[ i] {
468465 _ if tcx. sess . opts . unstable_opts . disable_incr_comp_backend_caching => true ,
@@ -479,14 +476,7 @@ pub(crate) fn run_aot(tcx: TyCtxt<'_>) -> Box<OngoingCodegen> {
479476 let ( module, _) = tcx. dep_graph . with_task (
480477 dep_node,
481478 tcx,
482- || {
483- module_codegen (
484- tcx,
485- global_asm_config. clone ( ) ,
486- cgu. name ( ) ,
487- concurrency_limiter. acquire ( tcx. dcx ( ) ) ,
488- )
489- } ,
479+ || module_codegen ( tcx, cgu. name ( ) , concurrency_limiter. acquire ( tcx. dcx ( ) ) ) ,
490480 Some ( rustc_middle:: dep_graph:: hash_result) ,
491481 ) ;
492482 IntoDynSyncSend ( module)
0 commit comments