Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
dff0c07
rustc: Move a few more cstore methods to queries
alexcrichton Aug 28, 2017
ed6f868
rustc: Move `impl_defaultness` to a query
alexcrichton Aug 28, 2017
98b74c5
rustc: Migrate `CStore::expored_symbols` to a query
alexcrichton Aug 29, 2017
205bc9a
rustc: Migrate `CStore::native_libraries` to a query
alexcrichton Aug 29, 2017
2d4445f
rustc: Move {plugin,derive}_registrar_fn to queries
alexcrichton Aug 29, 2017
ebc1fd3
rustc: Move crate_disambiguator to queries
alexcrichton Aug 29, 2017
d6c88f4
rustc: Move crate_hash to a query
alexcrichton Aug 29, 2017
52b67f9
rustc: Move original_crate_name to a query
alexcrichton Aug 29, 2017
4af1284
Ignore failing incremental tests
alexcrichton Aug 29, 2017
4dec2a8
rustc: Fix a borrow mut error with debug assertions
alexcrichton Aug 30, 2017
1c7294e
rustc: Move implementations_of_trait to a query
alexcrichton Aug 30, 2017
87ea0a1
Ignore failing tests harder
alexcrichton Aug 30, 2017
64a7034
rustc: Remove a number of mutable fields in cstore
alexcrichton Aug 30, 2017
fd61fa5
rustc: Hide the `named_region_map` behind queries
alexcrichton Aug 30, 2017
43ae380
rustc: Flag some CrateStore methods as "untracked"
alexcrichton Aug 31, 2017
a2e2aba
rustc: Migrate lang items to a query
alexcrichton Aug 31, 2017
953490d
rustc: Remove lang item methods from CrateStore
alexcrichton Aug 31, 2017
84ae4b7
rustc: Migrate `CrateStore::item_body` to a query
alexcrichton Aug 31, 2017
88399a9
rustc: Migrate `visible_parent_map` to a query
alexcrichton Aug 31, 2017
0b7e0aa
rustc: Classify two more CrateStore methods untracked
alexcrichton Aug 31, 2017
490f34a
rustc: Remove `CrateStore::used_crate*`
alexcrichton Aug 31, 2017
bf5550b
rustc: Convert `freevars` to a query
alexcrichton Aug 31, 2017
7d9c98e
rustc: Hide `maybe_unused_*` fields in queries
alexcrichton Aug 31, 2017
0182c8b
rustc: Rename item_body query to extern_const_body
alexcrichton Aug 31, 2017
9a23196
rustc: Move stability functionality into queries
alexcrichton Aug 31, 2017
0cdc58a
rustc: Store InternedString in `DefPathData`
alexcrichton Sep 1, 2017
c6445ba
Clarify failure condition on tests
alexcrichton Sep 5, 2017
2ee7493
Add some more with_ignore to get tests passing
alexcrichton Sep 7, 2017
fd0aa64
rustc: Remove `CrateStore::crates` as a method
alexcrichton Sep 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rustc: Migrate CStore::native_libraries to a query
  • Loading branch information
alexcrichton committed Sep 5, 2017
commit 205bc9a80ab214244d44ac4c8c8f155520d00989
1 change: 1 addition & 0 deletions src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ define_dep_nodes!( <'tcx>
[] IsNoBuiltins(CrateNum),
[] ImplDefaultness(DefId),
[] ExportedSymbols(CrateNum),
[] NativeLibraries(CrateNum),
);

trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {
Expand Down
3 changes: 0 additions & 3 deletions src/librustc/middle/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ pub trait CrateStore {
fn crate_disambiguator(&self, cnum: CrateNum) -> Symbol;
fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>;
fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>;
fn native_libraries(&self, cnum: CrateNum) -> Vec<NativeLibrary>;

// resolve
fn def_key(&self, def: DefId) -> DefKey;
Expand Down Expand Up @@ -364,8 +363,6 @@ impl CrateStore for DummyCrateStore {
{ bug!("plugin_registrar_fn") }
fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
{ bug!("derive_registrar_fn") }
fn native_libraries(&self, cnum: CrateNum) -> Vec<NativeLibrary>
{ bug!("native_libraries") }

// resolve
fn def_key(&self, def: DefId) -> DefKey { bug!("def_key") }
Expand Down
9 changes: 8 additions & 1 deletion src/librustc/ty/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use hir::def::{Def, Export};
use hir::{self, TraitCandidate, HirId};
use lint;
use middle::const_val;
use middle::cstore::{ExternCrate, LinkagePreference};
use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary};
use middle::privacy::AccessLevels;
use middle::region;
use mir;
Expand Down Expand Up @@ -593,6 +593,12 @@ impl<'tcx> QueryDescription for queries::exported_symbols<'tcx> {
}
}

impl<'tcx> QueryDescription for queries::native_libraries<'tcx> {
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
format!("looking up the native libraries of a linked crate")
}
}

// If enabled, send a message to the profile-queries thread
macro_rules! profq_msg {
($tcx:expr, $msg:expr) => {
Expand Down Expand Up @@ -1170,6 +1176,7 @@ define_maps! { <'tcx>

[] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
[] fn exported_symbols: ExportedSymbols(CrateNum) -> Rc<Vec<DefId>>,
[] fn native_libraries: NativeLibraries(CrateNum) -> Rc<Vec<NativeLibrary>>,
}

fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {
Expand Down
6 changes: 1 addition & 5 deletions src/librustc_metadata/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ provide! { <'tcx> tcx, def_id, cdata,
is_no_builtins => { cdata.is_no_builtins(&tcx.dep_graph) }
impl_defaultness => { cdata.get_impl_defaultness(def_id.index) }
exported_symbols => { Rc::new(cdata.get_exported_symbols(&tcx.dep_graph)) }
native_libraries => { Rc::new(cdata.get_native_libraries(&tcx.dep_graph)) }
}

pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) {
Expand Down Expand Up @@ -298,11 +299,6 @@ impl CrateStore for cstore::CStore {
})
}

fn native_libraries(&self, cnum: CrateNum) -> Vec<NativeLibrary>
{
self.get_crate_data(cnum).get_native_libraries(&self.dep_graph)
}

/// Returns the `DefKey` for a given `DefId`. This indicates the
/// parent `DefId` as well as some idea of what kind of data the
/// `DefId` refers to.
Expand Down
15 changes: 9 additions & 6 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ fn link_staticlib(sess: &Session,

let res = each_linked_rlib(sess, &mut |cnum, path| {
let name = sess.cstore.crate_name(cnum);
let native_libs = sess.cstore.native_libraries(cnum);
let native_libs = &trans.crate_info.native_libraries[&cnum];

// Here when we include the rlib into our staticlib we need to make a
// decision whether to include the extra object files along the way.
Expand All @@ -637,7 +637,7 @@ fn link_staticlib(sess: &Session,
sess.lto() && !ignored_for_lto(&trans.crate_info, cnum),
skip_object_files).unwrap();

all_native_libs.extend(sess.cstore.native_libraries(cnum));
all_native_libs.extend(trans.crate_info.native_libraries[&cnum].iter().cloned());
});
if let Err(e) = res {
sess.fatal(&e);
Expand Down Expand Up @@ -1002,7 +1002,7 @@ fn link_args(cmd: &mut Linker,
// on other dylibs (e.g. other native deps).
add_local_native_libraries(cmd, sess);
add_upstream_rust_crates(cmd, sess, trans, crate_type, tmpdir);
add_upstream_native_libraries(cmd, sess, crate_type);
add_upstream_native_libraries(cmd, sess, trans, crate_type);

// Tell the linker what we're doing.
if crate_type != config::CrateTypeExecutable {
Expand Down Expand Up @@ -1239,7 +1239,7 @@ fn add_upstream_rust_crates(cmd: &mut Linker,
// See the comment above in `link_staticlib` and `link_rlib` for why if
// there's a static library that's not relevant we skip all object
// files.
let native_libs = sess.cstore.native_libraries(cnum);
let native_libs = &trans.crate_info.native_libraries[&cnum];
let skip_native = native_libs.iter().any(|lib| {
lib.kind == NativeLibraryKind::NativeStatic && !relevant_lib(sess, lib)
});
Expand Down Expand Up @@ -1352,7 +1352,10 @@ fn add_upstream_rust_crates(cmd: &mut Linker,
// generic function calls a native function, then the generic function must
// be instantiated in the target crate, meaning that the native symbol must
// also be resolved in the target crate.
fn add_upstream_native_libraries(cmd: &mut Linker, sess: &Session, crate_type: config::CrateType) {
fn add_upstream_native_libraries(cmd: &mut Linker,
sess: &Session,
trans: &CrateTranslation,
crate_type: config::CrateType) {
// Be sure to use a topological sorting of crates because there may be
// interdependencies between native libraries. When passing -nodefaultlibs,
// for example, almost all native libraries depend on libc, so we have to
Expand All @@ -1367,7 +1370,7 @@ fn add_upstream_native_libraries(cmd: &mut Linker, sess: &Session, crate_type: c

let crates = sess.cstore.used_crates(LinkagePreference::RequireStatic);
for (cnum, _) in crates {
for lib in sess.cstore.native_libraries(cnum) {
for lib in trans.crate_info.native_libraries[&cnum].iter() {
if !relevant_lib(sess, &lib) {
continue
}
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1515,9 +1515,11 @@ impl CrateInfo {
profiler_runtime: None,
sanitizer_runtime: None,
is_no_builtins: FxHashSet(),
native_libraries: FxHashMap(),
};

for cnum in tcx.sess.cstore.crates() {
info.native_libraries.insert(cnum, tcx.native_libraries(cnum));
if tcx.is_panic_runtime(cnum) {
info.panic_runtime = Some(cnum);
}
Expand Down
7 changes: 6 additions & 1 deletion src/librustc_trans/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ pub use back::symbol_names::provide;

pub use metadata::LlvmMetadataLoader;
pub use llvm_util::{init, target_features, print_version, print_passes, print, enable_llvm_debug};

use std::rc::Rc;

use rustc::hir::def_id::CrateNum;
use rustc::util::nodemap::FxHashSet;
use rustc::util::nodemap::{FxHashSet, FxHashMap};
use rustc::middle::cstore::NativeLibrary;

pub mod back {
mod archive;
Expand Down Expand Up @@ -229,6 +233,7 @@ pub struct CrateInfo {
profiler_runtime: Option<CrateNum>,
sanitizer_runtime: Option<CrateNum>,
is_no_builtins: FxHashSet<CrateNum>,
native_libraries: FxHashMap<CrateNum, Rc<Vec<NativeLibrary>>>,
}

__build_diagnostic_array! { librustc_trans, DIAGNOSTICS }