Skip to content

Commit 1e3f638

Browse files
committed
Make LLVM worker channel thread-safe
1 parent 3773f4d commit 1e3f638

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/librustc/ty/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ pub struct GlobalCtxt<'tcx> {
909909
/// This is intended to only get used during the trans phase of the compiler
910910
/// when satisfying the query for a particular codegen unit. Internally in
911911
/// the query it'll send data along this channel to get processed later.
912-
pub tx_to_llvm_workers: mpsc::Sender<Box<dyn Any + Send>>,
912+
pub tx_to_llvm_workers: Lock<mpsc::Sender<Box<dyn Any + Send>>>,
913913

914914
output_filenames: Arc<OutputFilenames>,
915915
}
@@ -1283,7 +1283,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12831283
stability_interner: Lock::new(FxHashSet()),
12841284
interpret_interner: Default::default(),
12851285
all_traits: RefCell::new(None),
1286-
tx_to_llvm_workers: tx,
1286+
tx_to_llvm_workers: Lock::new(tx),
12871287
output_filenames: Arc::new(output_filenames.clone()),
12881288
}, f)
12891289
}

src/librustc_trans/back/write.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ pub fn start_async_translation(tcx: TyCtxt,
10351035
crate_info,
10361036

10371037
time_graph,
1038-
coordinator_send: tcx.tx_to_llvm_workers.clone(),
1038+
coordinator_send: tcx.tx_to_llvm_workers.lock().clone(),
10391039
trans_worker_receive,
10401040
shared_emitter_main,
10411041
future: coordinator_thread,
@@ -1428,7 +1428,7 @@ fn start_executing_work(tcx: TyCtxt,
14281428
metadata_config: Arc<ModuleConfig>,
14291429
allocator_config: Arc<ModuleConfig>)
14301430
-> thread::JoinHandle<Result<CompiledModules, ()>> {
1431-
let coordinator_send = tcx.tx_to_llvm_workers.clone();
1431+
let coordinator_send = tcx.tx_to_llvm_workers.lock().clone();
14321432
let sess = tcx.sess;
14331433

14341434
// Compute the set of symbols we need to retain when doing LTO (if we need to)
@@ -2340,7 +2340,7 @@ pub(crate) fn submit_translated_module_to_llvm(tcx: TyCtxt,
23402340
mtrans: ModuleTranslation,
23412341
cost: u64) {
23422342
let llvm_work_item = WorkItem::Optimize(mtrans);
2343-
drop(tcx.tx_to_llvm_workers.send(Box::new(Message::TranslationDone {
2343+
drop(tcx.tx_to_llvm_workers.lock().send(Box::new(Message::TranslationDone {
23442344
llvm_work_item,
23452345
cost,
23462346
})));

0 commit comments

Comments
 (0)