diff options
| author | khyperia <953151+khyperia@users.noreply.github.com> | 2022-08-12 23:30:24 +0200 |
|---|---|---|
| committer | khyperia <953151+khyperia@users.noreply.github.com> | 2022-08-12 23:59:02 +0200 |
| commit | dcead65e48bb4957f9f20bdb037806dfa6c2db66 (patch) | |
| tree | 9cbecba3d4e783fbe72e467e0c8772b5414ea9c8 | |
| parent | 569788e47ee3595c9c6f0e332844d982b3e991c2 (diff) | |
| download | rust-dcead65e48bb4957f9f20bdb037806dfa6c2db66.tar.gz rust-dcead65e48bb4957f9f20bdb037806dfa6c2db66.zip | |
Make `[rust] use-lld=true` work on windows
Before, it would fail with "error: ignoring unknown argument '-Wl,--icf=all'"
| -rw-r--r-- | src/bootstrap/compile.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index dd2b9d59366..c3aabb16a9b 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -658,7 +658,12 @@ impl Step for Rustc { // 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"); } |
