Skip to content

Commit

Permalink
Make LLVM worker channel thread-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Mar 27, 2018
1 parent 3773f4d commit 1e3f638
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ pub struct GlobalCtxt<'tcx> {
/// This is intended to only get used during the trans phase of the compiler
/// when satisfying the query for a particular codegen unit. Internally in
/// the query it'll send data along this channel to get processed later.
pub tx_to_llvm_workers: mpsc::Sender<Box<dyn Any + Send>>,
pub tx_to_llvm_workers: Lock<mpsc::Sender<Box<dyn Any + Send>>>,

output_filenames: Arc<OutputFilenames>,
}
Expand Down Expand Up @@ -1283,7 +1283,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
stability_interner: Lock::new(FxHashSet()),
interpret_interner: Default::default(),
all_traits: RefCell::new(None),
tx_to_llvm_workers: tx,
tx_to_llvm_workers: Lock::new(tx),
output_filenames: Arc::new(output_filenames.clone()),
}, f)
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ pub fn start_async_translation(tcx: TyCtxt,
crate_info,

time_graph,
coordinator_send: tcx.tx_to_llvm_workers.clone(),
coordinator_send: tcx.tx_to_llvm_workers.lock().clone(),
trans_worker_receive,
shared_emitter_main,
future: coordinator_thread,
Expand Down Expand Up @@ -1428,7 +1428,7 @@ fn start_executing_work(tcx: TyCtxt,
metadata_config: Arc<ModuleConfig>,
allocator_config: Arc<ModuleConfig>)
-> thread::JoinHandle<Result<CompiledModules, ()>> {
let coordinator_send = tcx.tx_to_llvm_workers.clone();
let coordinator_send = tcx.tx_to_llvm_workers.lock().clone();
let sess = tcx.sess;

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

0 comments on commit 1e3f638

Please sign in to comment.