on-demand dylib dependency formats
This commit is contained in:
parent
532a08b947
commit
328c6c81bf
5 changed files with 23 additions and 18 deletions
|
|
@ -247,8 +247,6 @@ pub trait CrateStore {
|
|||
fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool;
|
||||
|
||||
// crate metadata
|
||||
fn dylib_dependency_formats(&self, cnum: CrateNum)
|
||||
-> Vec<(CrateNum, LinkagePreference)>;
|
||||
fn dep_kind(&self, cnum: CrateNum) -> DepKind;
|
||||
fn export_macros(&self, cnum: CrateNum);
|
||||
fn lang_items(&self, cnum: CrateNum) -> Vec<(DefIndex, usize)>;
|
||||
|
|
@ -367,9 +365,6 @@ impl CrateStore for DummyCrateStore {
|
|||
fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool { false }
|
||||
|
||||
// crate metadata
|
||||
fn dylib_dependency_formats(&self, cnum: CrateNum)
|
||||
-> Vec<(CrateNum, LinkagePreference)>
|
||||
{ bug!("dylib_dependency_formats") }
|
||||
fn lang_items(&self, cnum: CrateNum) -> Vec<(DefIndex, usize)>
|
||||
{ bug!("lang_items") }
|
||||
fn missing_lang_items(&self, cnum: CrateNum) -> Vec<lang_items::LangItem>
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ use hir::def_id::CrateNum;
|
|||
|
||||
use session;
|
||||
use session::config;
|
||||
use ty::TyCtxt;
|
||||
use middle::cstore::DepKind;
|
||||
use middle::cstore::LinkagePreference::{self, RequireStatic, RequireDynamic};
|
||||
use util::nodemap::FxHashMap;
|
||||
|
|
@ -91,18 +92,22 @@ pub enum Linkage {
|
|||
Dynamic,
|
||||
}
|
||||
|
||||
pub fn calculate(sess: &session::Session) {
|
||||
pub fn calculate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
let sess = &tcx.sess;
|
||||
let mut fmts = sess.dependency_formats.borrow_mut();
|
||||
for &ty in sess.crate_types.borrow().iter() {
|
||||
let linkage = calculate_type(sess, ty);
|
||||
let linkage = calculate_type(tcx, ty);
|
||||
verify_ok(sess, &linkage);
|
||||
fmts.insert(ty, linkage);
|
||||
}
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
|
||||
fn calculate_type(sess: &session::Session,
|
||||
ty: config::CrateType) -> DependencyList {
|
||||
fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
ty: config::CrateType) -> DependencyList {
|
||||
|
||||
let sess = &tcx.sess;
|
||||
|
||||
if !sess.opts.output_types.should_trans() {
|
||||
return Vec::new();
|
||||
}
|
||||
|
|
@ -167,8 +172,8 @@ fn calculate_type(sess: &session::Session,
|
|||
if src.dylib.is_some() {
|
||||
info!("adding dylib: {}", name);
|
||||
add_library(sess, cnum, RequireDynamic, &mut formats);
|
||||
let deps = sess.cstore.dylib_dependency_formats(cnum);
|
||||
for &(depnum, style) in &deps {
|
||||
let deps = tcx.dylib_dependency_formats(cnum);
|
||||
for &(depnum, style) in deps.iter() {
|
||||
info!("adding {:?}: {}", style,
|
||||
sess.cstore.crate_name(depnum));
|
||||
add_library(sess, depnum, style, &mut formats);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE};
|
|||
use hir::def::Def;
|
||||
use hir;
|
||||
use middle::const_val;
|
||||
use middle::cstore::LinkagePreference;
|
||||
use middle::privacy::AccessLevels;
|
||||
use middle::region::RegionMaps;
|
||||
use mir;
|
||||
|
|
@ -482,6 +483,12 @@ impl<'tcx> QueryDescription for queries::is_const_fn<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> QueryDescription for queries::dylib_dependency_formats<'tcx> {
|
||||
fn describe(_: TyCtxt, _: CrateNum) -> String {
|
||||
"dylib dependency formats of crate".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! define_maps {
|
||||
(<$tcx:tt>
|
||||
$($(#[$attr:meta])*
|
||||
|
|
@ -938,6 +945,9 @@ define_maps! { <'tcx>
|
|||
[] needs_drop_raw: needs_drop_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
|
||||
[] layout_raw: layout_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
|
||||
-> Result<&'tcx Layout, LayoutError<'tcx>>,
|
||||
|
||||
[] dylib_dependency_formats: MetaDataByCrateNum(CrateNum)
|
||||
-> Rc<Vec<(CrateNum, LinkagePreference)>>,
|
||||
}
|
||||
|
||||
fn type_param_predicates((item_id, param_id): (DefId, DefId)) -> DepConstructor {
|
||||
|
|
|
|||
|
|
@ -1049,7 +1049,7 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
|
||||
time(time_passes,
|
||||
"resolving dependency formats",
|
||||
|| dependency_format::calculate(&tcx.sess));
|
||||
|| dependency_format::calculate(tcx));
|
||||
|
||||
let translation =
|
||||
time(time_passes,
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ provide! { <'tcx> tcx, def_id, cdata, cnum,
|
|||
}
|
||||
|
||||
ByCrateNum {
|
||||
dylib_dependency_formats => { Rc::new(cdata.get_dylib_dependency_formats(&tcx.dep_graph)) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -229,12 +230,6 @@ impl CrateStore for cstore::CStore {
|
|||
}
|
||||
}
|
||||
|
||||
fn dylib_dependency_formats(&self, cnum: CrateNum)
|
||||
-> Vec<(CrateNum, LinkagePreference)>
|
||||
{
|
||||
self.get_crate_data(cnum).get_dylib_dependency_formats(&self.dep_graph)
|
||||
}
|
||||
|
||||
fn dep_kind(&self, cnum: CrateNum) -> DepKind
|
||||
{
|
||||
let data = self.get_crate_data(cnum);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue