File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -658,7 +658,12 @@ impl Step for Rustc {
658
658
659
659
// With LLD, we can use ICF (identical code folding) to reduce the executable size
660
660
// of librustc_driver/rustc and to improve i-cache utilization.
661
- if builder. config . use_lld {
661
+ //
662
+ // -Wl,[link options] doesn't work on MSVC. However, /OPT:ICF (technically /OPT:REF,ICF)
663
+ // is already on by default in MSVC optimized builds, which is interpreted as --icf=all:
664
+ // https://github.com/llvm/llvm-project/blob/3329cec2f79185bafd678f310fafadba2a8c76d2/lld/COFF/Driver.cpp#L1746
665
+ // https://github.com/rust-lang/rust/blob/f22819bcce4abaff7d1246a56eec493418f9f4ee/compiler/rustc_codegen_ssa/src/back/linker.rs#L827
666
+ if builder. config . use_lld && !compiler. host . contains ( "msvc" ) {
662
667
cargo. rustflag ( "-Clink-args=-Wl,--icf=all" ) ;
663
668
}
664
669
You can’t perform that action at this time.
0 commit comments