Make Session.injected_panic_runtime thread-safe
This commit is contained in:
parent
dacf9ba00f
commit
006f9b2f56
@ -223,7 +223,7 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
//
|
||||
// Things like allocators and panic runtimes may not have been activated
|
||||
// quite yet, so do so here.
|
||||
activate_injected_dep(sess.injected_panic_runtime.get(), &mut ret,
|
||||
activate_injected_dep(*sess.injected_panic_runtime.get(), &mut ret,
|
||||
&|cnum| tcx.is_panic_runtime(cnum));
|
||||
activate_injected_allocator(sess, &mut ret);
|
||||
|
||||
@ -302,7 +302,7 @@ fn attempt_static<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<DependencyLis
|
||||
// Our allocator/panic runtime may not have been linked above if it wasn't
|
||||
// explicitly linked, which is the case for any injected dependency. Handle
|
||||
// that here and activate them.
|
||||
activate_injected_dep(sess.injected_panic_runtime.get(), &mut ret,
|
||||
activate_injected_dep(*sess.injected_panic_runtime.get(), &mut ret,
|
||||
&|cnum| tcx.is_panic_runtime(cnum));
|
||||
activate_injected_allocator(sess, &mut ret);
|
||||
|
||||
|
@ -120,7 +120,7 @@ pub struct Session {
|
||||
/// injected.
|
||||
pub injected_allocator: Once<Option<CrateNum>>,
|
||||
pub allocator_kind: Once<Option<AllocatorKind>>,
|
||||
pub injected_panic_runtime: Cell<Option<CrateNum>>,
|
||||
pub injected_panic_runtime: Once<Option<CrateNum>>,
|
||||
|
||||
/// Map from imported macro spans (which consist of
|
||||
/// the localized span for the macro body) to the
|
||||
@ -1107,7 +1107,7 @@ pub fn build_session_(
|
||||
next_node_id: OneThread::new(Cell::new(NodeId::new(1))),
|
||||
injected_allocator: Once::new(),
|
||||
allocator_kind: Once::new(),
|
||||
injected_panic_runtime: Cell::new(None),
|
||||
injected_panic_runtime: Once::new(),
|
||||
imported_macro_spans: OneThread::new(RefCell::new(HashMap::new())),
|
||||
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
|
||||
ignored_attr_names: ich::compute_ignored_attr_names(),
|
||||
|
@ -614,6 +614,7 @@ impl<'a> CrateLoader<'a> {
|
||||
});
|
||||
if !any_non_rlib {
|
||||
info!("panic runtime injection skipped, only generating rlib");
|
||||
self.sess.injected_panic_runtime.set(None);
|
||||
return
|
||||
}
|
||||
|
||||
@ -646,6 +647,7 @@ impl<'a> CrateLoader<'a> {
|
||||
// we just don't need one at all, then we're done here and there's
|
||||
// nothing else to do.
|
||||
if !needs_panic_runtime || runtime_found {
|
||||
self.sess.injected_panic_runtime.set(None);
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user