about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorandjo403 <andjo403@users.noreply.github.com>2018-02-14 21:08:21 +0100
committerandjo403 <andjo403@users.noreply.github.com>2018-02-16 07:44:32 +0100
commit7041ef3cf437acd39262eed4cec0d4aa3c1ff1f9 (patch)
tree73d2b1a05080ae393f8040bb2fa91533bb220ed8 /src
parent3ec5a99aaa0084d97a9e845b34fdf03d1462c475 (diff)
downloadrust-7041ef3cf437acd39262eed4cec0d4aa3c1ff1f9.tar.gz
rust-7041ef3cf437acd39262eed4cec0d4aa3c1ff1f9.zip
lookup exported symbols only when needed.
reduces the time to emit dep-info and metadata.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_trans/back/lto.rs9
-rw-r--r--src/librustc_trans/back/write.rs25
2 files changed, 24 insertions, 10 deletions
diff --git a/src/librustc_trans/back/lto.rs b/src/librustc_trans/back/lto.rs
index 9ff5bcf7a33..c440393a25f 100644
--- a/src/librustc_trans/back/lto.rs
+++ b/src/librustc_trans/back/lto.rs
@@ -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>>();
@@ -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));
 
diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs
index ded9a296817..af5178eb565 100644
--- a/src/librustc_trans/back/write.rs
+++ b/src/librustc_trans/back/write.rs
@@ -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)>,
@@ -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,