about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2022-07-17 17:37:10 +0200
committerJakub Beránek <berykubik@gmail.com>2022-07-17 17:37:10 +0200
commit97f6f958796bccf765a2e3038a40ecf5a8bb355a (patch)
tree27a40a58068fdb8a373098cb28328d1bb5ece0f0 /src/bootstrap
parent967a9c94b34bb8f394db03b1d205831eddf6f589 (diff)
Use LLD linker for compiling rustc on Linux x64 and use ICF for binary size optimization
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/compile.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index 3d678b2290d..aa7cda46bda 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -651,6 +651,12 @@ impl Step for Rustc {
             panic!("Cannot use and generate PGO profiles at the same time");
         }
 
+        // With LLD, we can use ICF (identical code folding) to reduce the executable size
+        // of librustc_driver/rustc and to improve i-cache utilization.
+        if builder.config.use_lld {
+            cargo.rustflag("-Clink-args=-Wl,--icf=all");
+        }
+
         let is_collecting = if let Some(path) = &builder.config.rust_profile_generate {
             if compiler.stage == 1 {
                 cargo.rustflag(&format!("-Cprofile-generate={}", path));