]> git.lizzy.rs Git - rust.git/blobdiff - src/bootstrap/compile.rs
Rollup merge of #99915 - WaffleLapkin:recover_keyword_bounds, r=compiler-errors
[rust.git] / src / bootstrap / compile.rs
index dd2b9d59366eab0b5bfc38dfe20a116a8381afca..c3aabb16a9b9af131c70095d4ecc6e667efe5a07 100644 (file)
@@ -658,7 +658,12 @@ fn run(self, builder: &Builder<'_>) {
 
         // 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 {
+        //
+        // -Wl,[link options] doesn't work on MSVC. However, /OPT:ICF (technically /OPT:REF,ICF)
+        // is already on by default in MSVC optimized builds, which is interpreted as --icf=all:
+        // https://github.com/llvm/llvm-project/blob/3329cec2f79185bafd678f310fafadba2a8c76d2/lld/COFF/Driver.cpp#L1746
+        // https://github.com/rust-lang/rust/blob/f22819bcce4abaff7d1246a56eec493418f9f4ee/compiler/rustc_codegen_ssa/src/back/linker.rs#L827
+        if builder.config.use_lld && !compiler.host.contains("msvc") {
             cargo.rustflag("-Clink-args=-Wl,--icf=all");
         }