File tree 2 files changed +12
-3
lines changed
test/run-make/codegen-options-parsing
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> {
320
320
}
321
321
322
322
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
+ }
324
333
}
325
334
326
335
fn link_dylib ( & mut self , lib : & str ) {
Original file line number Diff line number Diff line change 25
25
26
26
# Should not link dead code...
27
27
$(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'
29
29
# ... unless you specifically ask to keep it
30
30
$(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