@@ -376,9 +376,9 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
376
376
backend : B ,
377
377
tcx : TyCtxt < ' _ > ,
378
378
metadata : EncodedMetadata ,
379
- coordinator_receive : Receiver < Box < dyn Any + Send > > ,
380
379
total_cgus : usize ,
381
380
) -> OngoingCodegen < B > {
381
+ let ( coordinator_send, coordinator_receive) = channel ( ) ;
382
382
let sess = tcx. sess ;
383
383
let crate_name = tcx. crate_name ( LOCAL_CRATE ) ;
384
384
let crate_hash = tcx. crate_hash ( LOCAL_CRATE ) ;
@@ -500,7 +500,8 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
500
500
sess. jobserver . clone ( ) ,
501
501
Arc :: new ( modules_config) ,
502
502
Arc :: new ( metadata_config) ,
503
- Arc :: new ( allocator_config) ) ;
503
+ Arc :: new ( allocator_config) ,
504
+ coordinator_send. clone ( ) ) ;
504
505
505
506
OngoingCodegen {
506
507
backend,
@@ -511,7 +512,7 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
511
512
linker_info,
512
513
crate_info,
513
514
514
- coordinator_send : tcx . tx_to_llvm_workers . lock ( ) . clone ( ) ,
515
+ coordinator_send,
515
516
codegen_worker_receive,
516
517
shared_emitter_main,
517
518
future : coordinator_thread,
@@ -1005,8 +1006,9 @@ fn start_executing_work<B: ExtraBackendMethods>(
1005
1006
modules_config : Arc < ModuleConfig > ,
1006
1007
metadata_config : Arc < ModuleConfig > ,
1007
1008
allocator_config : Arc < ModuleConfig > ,
1009
+ tx_to_llvm_workers : Sender < Box < dyn Any + Send > > ,
1008
1010
) -> thread:: JoinHandle < Result < CompiledModules , ( ) > > {
1009
- let coordinator_send = tcx . tx_to_llvm_workers . lock ( ) . clone ( ) ;
1011
+ let coordinator_send = tx_to_llvm_workers;
1010
1012
let sess = tcx. sess ;
1011
1013
1012
1014
// 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> {
1857
1859
1858
1860
// These are generally cheap and won't throw off scheduling.
1859
1861
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) ;
1861
1863
}
1862
1864
1863
1865
pub fn codegen_finished ( & self , tcx : TyCtxt < ' _ > ) {
@@ -1899,24 +1901,24 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
1899
1901
1900
1902
pub fn submit_codegened_module_to_llvm < B : ExtraBackendMethods > (
1901
1903
_backend : & B ,
1902
- tcx : TyCtxt < ' _ > ,
1904
+ tx_to_llvm_workers : & Sender < Box < dyn Any + Send > > ,
1903
1905
module : ModuleCodegen < B :: Module > ,
1904
1906
cost : u64 ,
1905
1907
) {
1906
1908
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 > {
1908
1910
llvm_work_item,
1909
1911
cost,
1910
1912
} ) ) ) ;
1911
1913
}
1912
1914
1913
1915
pub fn submit_post_lto_module_to_llvm < B : ExtraBackendMethods > (
1914
1916
_backend : & B ,
1915
- tcx : TyCtxt < ' _ > ,
1917
+ tx_to_llvm_workers : & Sender < Box < dyn Any + Send > > ,
1916
1918
module : CachedModuleCodegen ,
1917
1919
) {
1918
1920
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 > {
1920
1922
llvm_work_item,
1921
1923
cost : 0 ,
1922
1924
} ) ) ) ;
@@ -1925,6 +1927,7 @@ pub fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
1925
1927
pub fn submit_pre_lto_module_to_llvm < B : ExtraBackendMethods > (
1926
1928
_backend : & B ,
1927
1929
tcx : TyCtxt < ' _ > ,
1930
+ tx_to_llvm_workers : & Sender < Box < dyn Any + Send > > ,
1928
1931
module : CachedModuleCodegen ,
1929
1932
) {
1930
1933
let filename = pre_lto_bitcode_filename ( & module. name ) ;
@@ -1939,7 +1942,7 @@ pub fn submit_pre_lto_module_to_llvm<B: ExtraBackendMethods>(
1939
1942
} )
1940
1943
} ;
1941
1944
// 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 > {
1943
1946
module_data : SerializedModule :: FromUncompressedFile ( mmap) ,
1944
1947
work_product : module. source ,
1945
1948
} ) ) ) ;
0 commit comments