File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
test/run-make/codegen-options-parsing Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -320,7 +320,16 @@ impl<'a> Linker for MsvcLinker<'a> {
320320 }
321321
322322 fn gc_sections ( & mut self , _keep_metadata : bool ) {
323- self . cmd . arg ( "/OPT:REF,ICF" ) ;
323+ // MSVC's ICF (Identical COMDAT Folding) link optimization is
324+ // slow for Rust and thus we disable it by default when not in
325+ // optimization build.
326+ if self . sess . opts . optimize != config:: OptLevel :: No {
327+ self . cmd . arg ( "/OPT:REF,ICF" ) ;
328+ } else {
329+ // It is necessary to specify NOICF here, because /OPT:REF
330+ // implies ICF by default.
331+ self . cmd . arg ( "/OPT:REF,NOICF" ) ;
332+ }
324333 }
325334
326335 fn link_dylib ( & mut self , lib : & str ) {
Original file line number Diff line number Diff line change 2525
2626 # Should not link dead code...
2727 $(RUSTC) -Z print-link-args dummy.rs 2>&1 | \
28- grep -e '--gc-sections' -e '-dead_strip' -e '/OPT:REF,ICF '
28+ grep -e '--gc-sections' -e '-dead_strip' -e '/OPT:REF'
2929 # ... unless you specifically ask to keep it
3030 $(RUSTC) -Z print-link-args -C link-dead-code dummy.rs 2>&1 | \
31- (! grep -e '--gc-sections' -e '-dead_strip' -e '/OPT:REF,ICF ')
31+ (! grep -e '--gc-sections' -e '-dead_strip' -e '/OPT:REF')
You can’t perform that action at this time.
0 commit comments