@@ -52,7 +52,7 @@ use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
52
52
StableVec } ;
53
53
use arena:: { TypedArena , SyncDroplessArena } ;
54
54
use 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 } ;
56
56
use std:: any:: Any ;
57
57
use std:: borrow:: Borrow ;
58
58
use std:: cmp:: Ordering ;
@@ -1029,6 +1029,9 @@ pub struct GlobalCtxt<'tcx> {
1029
1029
1030
1030
pub sess_rc : Lrc < Session > ,
1031
1031
1032
+ // This stores a `Arc<dyn CodegenBackend + Send + Sync>`.
1033
+ pub codegen_backend : Box < dyn Any + Send + Sync > ,
1034
+
1032
1035
lowered_hir : AtomicOnce < & ' tcx hir:: LoweredHir > ,
1033
1036
hir_map : AtomicOnce < & ' tcx hir_map:: Map < ' tcx > > ,
1034
1037
@@ -1071,6 +1074,7 @@ pub struct GlobalCtxt<'tcx> {
1071
1074
/// when satisfying the query for a particular codegen unit. Internally in
1072
1075
/// the query it'll send data along this channel to get processed later.
1073
1076
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 > > > > ,
1074
1078
}
1075
1079
1076
1080
impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
@@ -1224,7 +1228,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1224
1228
extern_providers : ty:: query:: Providers < ' tcx > ,
1225
1229
arenas : & ' tcx AllArenas < ' tcx > ,
1226
1230
crate_name : Option < String > ,
1227
- tx : mpsc :: Sender < Box < dyn Any + Send > > ,
1231
+ codegen_backend : Box < dyn Any + Send + Sync > ,
1228
1232
io : InputsAndOutputs ,
1229
1233
) -> GlobalCtxt < ' tcx > {
1230
1234
let data_layout = TargetDataLayout :: parse ( & s. target . target ) . unwrap_or_else ( |err| {
@@ -1235,12 +1239,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1235
1239
let max_cnum = cstore. crates_untracked ( ) . iter ( ) . map ( |c| c. as_usize ( ) ) . max ( ) . unwrap_or ( 0 ) ;
1236
1240
let mut providers = IndexVec :: from_elem_n ( extern_providers, max_cnum + 1 ) ;
1237
1241
providers[ LOCAL_CRATE ] = local_providers;
1242
+ let ( tx, rx) = mpsc:: channel ( ) ;
1238
1243
1239
1244
GlobalCtxt {
1240
1245
sess : & * * s,
1241
1246
cstore,
1242
1247
cstore_rc,
1243
1248
sess_rc : s. clone ( ) ,
1249
+ codegen_backend,
1244
1250
global_arenas : & arenas. global ,
1245
1251
global_interners : interners,
1246
1252
dep_graph : AtomicOnce :: new ( ) ,
@@ -1264,6 +1270,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1264
1270
allocation_interner : Default :: default ( ) ,
1265
1271
alloc_map : Lock :: new ( interpret:: AllocMap :: new ( ) ) ,
1266
1272
tx_to_llvm_workers : Lock :: new ( tx) ,
1273
+ rx_to_llvm_workers : Steal :: new ( OneThread :: new ( rx) ) ,
1267
1274
io,
1268
1275
}
1269
1276
}
0 commit comments