@@ -376,9 +376,9 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
376376 backend : B ,
377377 tcx : TyCtxt < ' _ > ,
378378 metadata : EncodedMetadata ,
379- coordinator_receive : Receiver < Box < dyn Any + Send > > ,
380379 total_cgus : usize ,
381380) -> OngoingCodegen < B > {
381+ let ( coordinator_send, coordinator_receive) = channel ( ) ;
382382 let sess = tcx. sess ;
383383 let crate_name = tcx. crate_name ( LOCAL_CRATE ) ;
384384 let crate_hash = tcx. crate_hash ( LOCAL_CRATE ) ;
@@ -500,7 +500,8 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
500500 sess. jobserver . clone ( ) ,
501501 Arc :: new ( modules_config) ,
502502 Arc :: new ( metadata_config) ,
503- Arc :: new ( allocator_config) ) ;
503+ Arc :: new ( allocator_config) ,
504+ coordinator_send. clone ( ) ) ;
504505
505506 OngoingCodegen {
506507 backend,
@@ -511,7 +512,7 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
511512 linker_info,
512513 crate_info,
513514
514- coordinator_send : tcx . tx_to_llvm_workers . lock ( ) . clone ( ) ,
515+ coordinator_send,
515516 codegen_worker_receive,
516517 shared_emitter_main,
517518 future : coordinator_thread,
@@ -1005,8 +1006,9 @@ fn start_executing_work<B: ExtraBackendMethods>(
10051006 modules_config : Arc < ModuleConfig > ,
10061007 metadata_config : Arc < ModuleConfig > ,
10071008 allocator_config : Arc < ModuleConfig > ,
1009+ tx_to_llvm_workers : Sender < Box < dyn Any + Send > > ,
10081010) -> thread:: JoinHandle < Result < CompiledModules , ( ) > > {
1009- let coordinator_send = tcx . tx_to_llvm_workers . lock ( ) . clone ( ) ;
1011+ let coordinator_send = tx_to_llvm_workers;
10101012 let sess = tcx. sess ;
10111013
10121014 // Compute the set of symbols we need to retain when doing LTO (if we need to)
@@ -1857,7 +1859,7 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
18571859
18581860 // These are generally cheap and won't throw off scheduling.
18591861 let cost = 0 ;
1860- submit_codegened_module_to_llvm ( & self . backend , tcx , module, cost) ;
1862+ submit_codegened_module_to_llvm ( & self . backend , & self . coordinator_send , module, cost) ;
18611863 }
18621864
18631865 pub fn codegen_finished ( & self , tcx : TyCtxt < ' _ > ) {
@@ -1899,24 +1901,24 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
18991901
19001902pub fn submit_codegened_module_to_llvm < B : ExtraBackendMethods > (
19011903 _backend : & B ,
1902- tcx : TyCtxt < ' _ > ,
1904+ tx_to_llvm_workers : & Sender < Box < dyn Any + Send > > ,
19031905 module : ModuleCodegen < B :: Module > ,
19041906 cost : u64 ,
19051907) {
19061908 let llvm_work_item = WorkItem :: Optimize ( module) ;
1907- drop ( tcx . tx_to_llvm_workers . lock ( ) . send ( Box :: new ( Message :: CodegenDone :: < B > {
1909+ drop ( tx_to_llvm_workers. send ( Box :: new ( Message :: CodegenDone :: < B > {
19081910 llvm_work_item,
19091911 cost,
19101912 } ) ) ) ;
19111913}
19121914
19131915pub fn submit_post_lto_module_to_llvm < B : ExtraBackendMethods > (
19141916 _backend : & B ,
1915- tcx : TyCtxt < ' _ > ,
1917+ tx_to_llvm_workers : & Sender < Box < dyn Any + Send > > ,
19161918 module : CachedModuleCodegen ,
19171919) {
19181920 let llvm_work_item = WorkItem :: CopyPostLtoArtifacts ( module) ;
1919- drop ( tcx . tx_to_llvm_workers . lock ( ) . send ( Box :: new ( Message :: CodegenDone :: < B > {
1921+ drop ( tx_to_llvm_workers. send ( Box :: new ( Message :: CodegenDone :: < B > {
19201922 llvm_work_item,
19211923 cost : 0 ,
19221924 } ) ) ) ;
@@ -1925,6 +1927,7 @@ pub fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
19251927pub fn submit_pre_lto_module_to_llvm < B : ExtraBackendMethods > (
19261928 _backend : & B ,
19271929 tcx : TyCtxt < ' _ > ,
1930+ tx_to_llvm_workers : & Sender < Box < dyn Any + Send > > ,
19281931 module : CachedModuleCodegen ,
19291932) {
19301933 let filename = pre_lto_bitcode_filename ( & module. name ) ;
@@ -1939,7 +1942,7 @@ pub fn submit_pre_lto_module_to_llvm<B: ExtraBackendMethods>(
19391942 } )
19401943 } ;
19411944 // Schedule the module to be loaded
1942- drop ( tcx . tx_to_llvm_workers . lock ( ) . send ( Box :: new ( Message :: AddImportOnlyModule :: < B > {
1945+ drop ( tx_to_llvm_workers. send ( Box :: new ( Message :: AddImportOnlyModule :: < B > {
19431946 module_data : SerializedModule :: FromUncompressedFile ( mmap) ,
19441947 work_product : module. source ,
19451948 } ) ) ) ;
0 commit comments