// utility functions
fn encode_metadata(&self, tcx: TyCtxt<'_>) -> EncodedMetadata;
fn metadata_encoding_version(&self) -> &[u8];
+ fn injected_panic_runtime(&self) -> Option<CrateNum>;
}
pub type CrateStoreDyn = dyn CrateStore + sync::Sync;
use self::code_stats::CodeStats;
use crate::dep_graph::cgu_reuse_tracker::CguReuseTracker;
-use crate::hir::def_id::CrateNum;
use rustc_data_structures::fingerprint::Fingerprint;
use crate::lint;
/// dependency if it didn't already find one, and this tracks what was
/// injected.
pub allocator_kind: Once<Option<AllocatorKind>>,
- pub injected_panic_runtime: Once<Option<CrateNum>>,
/// Map from imported macro spans (which consist of
/// the localized span for the macro body) to the
type_length_limit: Once::new(),
const_eval_stack_frame_limit: 100,
allocator_kind: Once::new(),
- injected_panic_runtime: Once::new(),
imported_macro_spans: OneThread::new(RefCell::new(FxHashMap::default())),
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
cgu_reuse_tracker,
self.all_crate_nums(LOCAL_CRATE)
}
+ pub fn injected_panic_runtime(self) -> Option<CrateNum> {
+ self.cstore.injected_panic_runtime()
+ }
+
pub fn features(self) -> &'tcx feature_gate::Features {
self.features_query(LOCAL_CRATE)
}
});
if !any_non_rlib {
info!("panic runtime injection skipped, only generating rlib");
- self.sess.injected_panic_runtime.set(None);
+ self.cstore.injected_panic_runtime = None;
return
}
// 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);
+ self.cstore.injected_panic_runtime = None;
return
}
name, desired_strategy.desc()));
}
- self.sess.injected_panic_runtime.set(Some(cnum));
+ self.cstore.injected_panic_runtime = Some(cnum);
self.inject_dependency_if(cnum, "a panic runtime",
&|data| data.root.needs_panic_runtime);
}
#[derive(Clone)]
pub struct CStore {
metas: IndexVec<CrateNum, Option<Lrc<CrateMetadata>>>,
+ pub(crate) injected_panic_runtime: Option<CrateNum>,
}
pub enum LoadedMacro {
// corresponding `CrateNum`. This first entry will always remain
// `None`.
metas: IndexVec::from_elem_n(None, 1),
+ injected_panic_runtime: None,
}
}
}
//
// 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(tcx.injected_panic_runtime(), &mut ret,
&|cnum| tcx.is_panic_runtime(cnum));
// When dylib B links to dylib A, then when using B we must also link to A.
}
fn attempt_static(tcx: TyCtxt<'_>) -> Option<DependencyList> {
- let sess = &tcx.sess;
let crates = cstore::used_crates(tcx, RequireStatic);
if !crates.iter().by_ref().all(|&(_, ref p)| p.is_some()) {
return None
// 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(tcx.injected_panic_runtime(), &mut ret,
&|cnum| tcx.is_panic_runtime(cnum));
Some(ret)
{
rmeta::METADATA_HEADER
}
+
+ fn injected_panic_runtime(&self) -> Option<CrateNum> {
+ self.injected_panic_runtime
+ }
}