X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_metadata%2Fcstore_impl.rs;h=11121ee875ddab9cf0f3c065fe58b5c11640f339;hb=34067ee9613bdc87557d4803e77d2856fa167b0a;hp=d6450f00c8b6a47ca66265365d2d425010d6830b;hpb=59cc53e6e708e9b9e86822c1b4d69f28f6c45eae;p=rust.git diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index d6450f00c8b..11121ee875d 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -10,6 +10,7 @@ EncodedMetadata, NativeLibraryKind}; use rustc::middle::exported_symbols::ExportedSymbol; use rustc::middle::stability::DeprecationEntry; +use rustc::middle::dependency_format::Linkage; use rustc::hir::def; use rustc::hir; use rustc::session::{CrateDisambiguator, Session}; @@ -133,6 +134,7 @@ fn into_args(self) -> (DefId, DefId) { (self.0.as_def_id(), self.1) } fn_sig => { cdata.fn_sig(def_id.index, tcx) } inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) } is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) } + asyncness => { cdata.asyncness(def_id.index) } is_foreign_item => { cdata.is_foreign_item(def_id.index) } static_mutability => { cdata.static_mutability(def_id.index) } def_kind => { cdata.def_kind(def_id.index) } @@ -239,7 +241,30 @@ fn into_args(self) -> (DefId, DefId) { (self.0.as_def_id(), self.1) } used_crate_source => { Lrc::new(cdata.source.clone()) } - exported_symbols => { Arc::new(cdata.exported_symbols(tcx)) } + exported_symbols => { + let mut syms = cdata.exported_symbols(tcx); + + // When linked into a dylib crates don't export their generic symbols, + // so if that's happening then we can't load upstream monomorphizations + // from this crate. + let formats = tcx.dependency_formats(LOCAL_CRATE); + let remove_generics = formats.iter().any(|(_ty, list)| { + match list.get(def_id.krate.as_usize() - 1) { + Some(Linkage::IncludedFromDylib) | Some(Linkage::Dynamic) => true, + _ => false, + } + }); + if remove_generics { + syms.retain(|(sym, _threshold)| { + match sym { + ExportedSymbol::Generic(..) => false, + _ => return true, + } + }); + } + + Arc::new(syms) + } } pub fn provide(providers: &mut Providers<'_>) { @@ -370,6 +395,11 @@ pub fn provide(providers: &mut Providers<'_>) { tcx.arena.alloc(visible_parent_map) }, + dependency_formats: |tcx, cnum| { + assert_eq!(cnum, LOCAL_CRATE); + Lrc::new(crate::dependency_format::calculate(tcx)) + }, + ..*providers }; } @@ -444,7 +474,8 @@ pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro { .insert(local_span, (name.to_string(), data.get_span(id.index, sess))); LoadedMacro::MacroDef(ast::Item { - ident: ast::Ident::from_str(&name.as_str()), + // FIXME: cross-crate hygiene + ident: ast::Ident::with_dummy_span(name.as_symbol()), id: ast::DUMMY_NODE_ID, span: local_span, attrs: attrs.iter().cloned().collect(),