@@ -52,7 +52,7 @@ use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
5252 StableVec } ;
5353use arena:: { TypedArena , SyncDroplessArena } ;
5454use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
55- use rustc_data_structures:: sync:: { self , Lrc , Lock , WorkerLocal , AtomicOnce , Once } ;
55+ use rustc_data_structures:: sync:: { self , Lrc , Lock , WorkerLocal , AtomicOnce , Once , OneThread } ;
5656use std:: any:: Any ;
5757use std:: borrow:: Borrow ;
5858use std:: cmp:: Ordering ;
@@ -1029,6 +1029,9 @@ pub struct GlobalCtxt<'tcx> {
10291029
10301030 pub sess_rc : Lrc < Session > ,
10311031
1032+ // This stores a `Arc<dyn CodegenBackend + Send + Sync>`.
1033+ pub codegen_backend : Box < dyn Any + Send + Sync > ,
1034+
10321035 lowered_hir : AtomicOnce < & ' tcx hir:: LoweredHir > ,
10331036 hir_map : AtomicOnce < & ' tcx hir_map:: Map < ' tcx > > ,
10341037
@@ -1071,6 +1074,7 @@ pub struct GlobalCtxt<'tcx> {
10711074 /// when satisfying the query for a particular codegen unit. Internally in
10721075 /// the query it'll send data along this channel to get processed later.
10731076 pub tx_to_llvm_workers : Lock < mpsc:: Sender < Box < dyn Any + Send > > > ,
1077+ pub rx_to_llvm_workers : Steal < OneThread < mpsc:: Receiver < Box < dyn Any + Send > > > > ,
10741078}
10751079
10761080impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
@@ -1224,7 +1228,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12241228 extern_providers : ty:: query:: Providers < ' tcx > ,
12251229 arenas : & ' tcx AllArenas < ' tcx > ,
12261230 crate_name : Option < String > ,
1227- tx : mpsc :: Sender < Box < dyn Any + Send > > ,
1231+ codegen_backend : Box < dyn Any + Send + Sync > ,
12281232 io : InputsAndOutputs ,
12291233 ) -> GlobalCtxt < ' tcx > {
12301234 let data_layout = TargetDataLayout :: parse ( & s. target . target ) . unwrap_or_else ( |err| {
@@ -1235,12 +1239,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12351239 let max_cnum = cstore. crates_untracked ( ) . iter ( ) . map ( |c| c. as_usize ( ) ) . max ( ) . unwrap_or ( 0 ) ;
12361240 let mut providers = IndexVec :: from_elem_n ( extern_providers, max_cnum + 1 ) ;
12371241 providers[ LOCAL_CRATE ] = local_providers;
1242+ let ( tx, rx) = mpsc:: channel ( ) ;
12381243
12391244 GlobalCtxt {
12401245 sess : & * * s,
12411246 cstore,
12421247 cstore_rc,
12431248 sess_rc : s. clone ( ) ,
1249+ codegen_backend,
12441250 global_arenas : & arenas. global ,
12451251 global_interners : interners,
12461252 dep_graph : AtomicOnce :: new ( ) ,
@@ -1264,6 +1270,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12641270 allocation_interner : Default :: default ( ) ,
12651271 alloc_map : Lock :: new ( interpret:: AllocMap :: new ( ) ) ,
12661272 tx_to_llvm_workers : Lock :: new ( tx) ,
1273+ rx_to_llvm_workers : Steal :: new ( OneThread :: new ( rx) ) ,
12671274 io,
12681275 }
12691276 }
0 commit comments