Skip to content

Commit

Permalink
lookup exported symbols only when needed.
Browse files Browse the repository at this point in the history
reduces the time to emit dep-info and metadata.
  • Loading branch information
andjo403 committed Feb 16, 2018
1 parent 3ec5a99 commit 7041ef3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
9 changes: 6 additions & 3 deletions src/librustc_trans/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ pub(crate) fn run(cgcx: &CodegenContext,
None
}
};

let mut symbol_white_list = cgcx.exported_symbols[&LOCAL_CRATE]
let exported_symbols = cgcx.exported_symbols
.as_ref().expect("needs exported symbols for LTO");
let mut symbol_white_list = exported_symbols[&LOCAL_CRATE]
.iter()
.filter_map(symbol_filter)
.collect::<Vec<CString>>();
Expand Down Expand Up @@ -156,8 +157,10 @@ pub(crate) fn run(cgcx: &CodegenContext,
}

for &(cnum, ref path) in cgcx.each_linked_rlib_for_lto.iter() {
let exported_symbols = cgcx.exported_symbols
.as_ref().expect("needs exported symbols for LTO");
symbol_white_list.extend(
cgcx.exported_symbols[&cnum]
exported_symbols[&cnum]
.iter()
.filter_map(symbol_filter));

Expand Down
25 changes: 18 additions & 7 deletions src/librustc_trans/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ pub struct CodegenContext {
pub no_landing_pads: bool,
pub save_temps: bool,
pub fewer_names: bool,
pub exported_symbols: Arc<ExportedSymbols>,
pub exported_symbols: Option<Arc<ExportedSymbols>>,
pub opts: Arc<config::Options>,
pub crate_types: Vec<config::CrateType>,
pub each_linked_rlib_for_lto: Vec<(CrateNum, PathBuf)>,
Expand Down Expand Up @@ -1394,14 +1394,25 @@ fn start_executing_work(tcx: TyCtxt,
allocator_config: Arc<ModuleConfig>)
-> thread::JoinHandle<Result<CompiledModules, ()>> {
let coordinator_send = tcx.tx_to_llvm_workers.clone();
let mut exported_symbols = FxHashMap();
exported_symbols.insert(LOCAL_CRATE, tcx.exported_symbols(LOCAL_CRATE));
for &cnum in tcx.crates().iter() {
exported_symbols.insert(cnum, tcx.exported_symbols(cnum));
}
let exported_symbols = Arc::new(exported_symbols);
let sess = tcx.sess;

let exported_symbols = match sess.lto() {
Lto::No => None,
Lto::ThinLocal => {
let mut exported_symbols = FxHashMap();
exported_symbols.insert(LOCAL_CRATE, tcx.exported_symbols(LOCAL_CRATE));
Some(Arc::new(exported_symbols))
}
Lto::Yes | Lto::Fat | Lto::Thin => {
let mut exported_symbols = FxHashMap();
exported_symbols.insert(LOCAL_CRATE, tcx.exported_symbols(LOCAL_CRATE));
for &cnum in tcx.crates().iter() {
exported_symbols.insert(cnum, tcx.exported_symbols(cnum));
}
Some(Arc::new(exported_symbols))
}
};

// First up, convert our jobserver into a helper thread so we can use normal
// mpsc channels to manage our messages and such.
// After we've requested tokens then we'll, when we can,
Expand Down

0 comments on commit 7041ef3

Please sign in to comment.