Consider only libs that aren't excluded by #[link(cfg=...)]
This commit is contained in:
parent
b700dd35e7
commit
7d05d1e7f0
|
@ -113,6 +113,13 @@ fn register_native_lib(sess: &Session,
|
|||
cstore.add_used_library(lib);
|
||||
}
|
||||
|
||||
fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {
|
||||
match lib.cfg {
|
||||
Some(ref cfg) => attr::cfg_matches(cfg, &sess.parse_sess, None),
|
||||
None => true,
|
||||
}
|
||||
}
|
||||
|
||||
// Extra info about a crate loaded for plugins or exported macros.
|
||||
struct ExtensionCrate {
|
||||
metadata: PMDSource,
|
||||
|
@ -290,7 +297,7 @@ impl<'a> CrateLoader<'a> {
|
|||
|
||||
let cnum_map = self.resolve_crate_deps(root, &crate_root, &metadata, cnum, span, dep_kind);
|
||||
|
||||
let cmeta = Rc::new(cstore::CrateMetadata {
|
||||
let mut cmeta = cstore::CrateMetadata {
|
||||
name: name,
|
||||
extern_crate: Cell::new(None),
|
||||
key_map: metadata.load_key_map(crate_root.index),
|
||||
|
@ -308,9 +315,18 @@ impl<'a> CrateLoader<'a> {
|
|||
rlib: rlib,
|
||||
rmeta: rmeta,
|
||||
},
|
||||
dllimport_foreign_items: RefCell::new(None),
|
||||
});
|
||||
dllimport_foreign_items: FxHashSet(),
|
||||
};
|
||||
|
||||
let dllimports: Vec<_> = cmeta.get_native_libraries().iter()
|
||||
.filter(|lib| relevant_lib(self.sess, lib) &&
|
||||
lib.kind == cstore::NativeLibraryKind::NativeUnknown)
|
||||
.flat_map(|lib| &lib.foreign_items)
|
||||
.map(|id| *id)
|
||||
.collect();
|
||||
cmeta.dllimport_foreign_items.extend(dllimports);
|
||||
|
||||
let cmeta = Rc::new(cmeta);
|
||||
self.cstore.set_crate_data(cnum, cmeta.clone());
|
||||
(cnum, cmeta)
|
||||
}
|
||||
|
@ -643,7 +659,7 @@ impl<'a> CrateLoader<'a> {
|
|||
let mut items = vec![];
|
||||
let libs = self.cstore.get_used_libraries();
|
||||
for lib in libs.borrow().iter() {
|
||||
if lib.kind == kind {
|
||||
if relevant_lib(self.sess, lib) && lib.kind == kind {
|
||||
items.extend(&lib.foreign_items);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ pub struct CrateMetadata {
|
|||
|
||||
pub proc_macros: Option<Vec<(ast::Name, Rc<SyntaxExtension>)>>,
|
||||
// Foreign items imported from a dylib (Windows only)
|
||||
pub dllimport_foreign_items: RefCell<Option<FxHashSet<DefIndex>>>,
|
||||
pub dllimport_foreign_items: FxHashSet<DefIndex>,
|
||||
}
|
||||
|
||||
pub struct CachedInlinedItem {
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
// Decoding metadata from a single crate's metadata
|
||||
|
||||
use astencode::decode_inlined_item;
|
||||
use cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary, NativeLibraryKind};
|
||||
use cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary};
|
||||
use index::Index;
|
||||
use schema::*;
|
||||
|
||||
use rustc::hir::map as hir_map;
|
||||
use rustc::hir::map::{DefKey, DefPathData};
|
||||
use rustc::util::nodemap::{FxHashMap, FxHashSet};
|
||||
use rustc::util::nodemap::FxHashMap;
|
||||
use rustc::hir;
|
||||
use rustc::hir::intravisit::IdRange;
|
||||
|
||||
|
@ -36,7 +36,6 @@ use rustc::mir::Mir;
|
|||
use std::borrow::Cow;
|
||||
use std::cell::Ref;
|
||||
use std::io;
|
||||
use std::iter::FromIterator;
|
||||
use std::mem;
|
||||
use std::str;
|
||||
use std::u32;
|
||||
|
@ -1089,15 +1088,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
|
||||
pub fn is_dllimport_foreign_item(&self, id: DefIndex) -> bool {
|
||||
if self.dllimport_foreign_items.borrow().is_none() {
|
||||
*self.dllimport_foreign_items.borrow_mut() = Some(FxHashSet::from_iter(
|
||||
self.get_native_libraries().iter()
|
||||
.filter(|lib| lib.kind == NativeLibraryKind::NativeUnknown)
|
||||
.flat_map(|lib| &lib.foreign_items)
|
||||
.map(|id| *id)
|
||||
));
|
||||
}
|
||||
self.dllimport_foreign_items.borrow().as_ref().unwrap().contains(&id)
|
||||
self.dllimport_foreign_items.contains(&id)
|
||||
}
|
||||
|
||||
pub fn is_defaulted_trait(&self, trait_id: DefIndex) -> bool {
|
||||
|
|
Loading…
Reference in New Issue