diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2025-07-31 13:12:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-31 13:12:45 +0200 |
| commit | d8c09c10e5e86559cd49e1081482d2b700ba5ccf (patch) | |
| tree | d42f502c7e5c9b4f7cac82f1017e774ca0cc1824 /compiler/rustc_codegen_ssa/src | |
| parent | cc0a5b73053c62a3df5f84b3ee85079c9b65fa87 (diff) | |
| parent | 7a127fba657ed627cc4877f2871abaf7d9819caa (diff) | |
| download | rust-d8c09c10e5e86559cd49e1081482d2b700ba5ccf.tar.gz rust-d8c09c10e5e86559cd49e1081482d2b700ba5ccf.zip | |
Rollup merge of #136840 - Flakebi:linker-plugin-lto-fat, r=dianqk
Fix linker-plugin-lto only doing thin lto When rust provides LLVM bitcode files to lld and the bitcode contains function summaries as used for thin lto, lld defaults to using thin lto. This prevents some optimizations that are only applied for fat lto. We solve this by not creating function summaries when fat lto is enabled. The bitcode for the module is just directly written out. An alternative solution would be to set the `ThinLTO=0` module flag to signal lld to do fat lto. The code in clang that sets this flag is here: https://github.com/llvm/llvm-project/blob/560149b5e3c891c64899e9912e29467a69dc3a4c/clang/lib/CodeGen/BackendUtil.cpp#L1150 The code in LLVM that queries the flag and defaults to thin lto if not set is here: https://github.com/llvm/llvm-project/blob/e258bca9505f35e0a22cb213a305eea9b76d11ea/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp#L4441-L4446 try-job: x86_64-gnu-debug try-job: aarch64-gnu-debug
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/write.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 6773d3e24e9..aa29afb7f5b 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -214,7 +214,9 @@ impl ModuleConfig { false ), emit_obj, - emit_thin_lto: sess.opts.unstable_opts.emit_thin_lto, + // thin lto summaries prevent fat lto, so do not emit them if fat + // lto is requested. See PR #136840 for background information. + emit_thin_lto: sess.opts.unstable_opts.emit_thin_lto && sess.lto() != Lto::Fat, emit_thin_lto_summary: if_regular!( sess.opts.output_types.contains_key(&OutputType::ThinLinkBitcode), false |
