diff options
| author | bors <bors@rust-lang.org> | 2025-09-03 19:07:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-09-03 19:07:55 +0000 |
| commit | a1208bf765ba783ee4ebdc4c29ab0a0c215806ef (patch) | |
| tree | 4f9ad1f420dbfe8b572336a336a98c9e00c26928 /compiler/rustc_codegen_ssa | |
| parent | fd75a9c32d643f39c8c61df770d2cff60b3fefd5 (diff) | |
| parent | 916b55e08217ca14dabec0169067ed8d6523bf6e (diff) | |
| download | rust-a1208bf765ba783ee4ebdc4c29ab0a0c215806ef.tar.gz rust-a1208bf765ba783ee4ebdc4c29ab0a0c215806ef.zip | |
Auto merge of #146133 - rcvalle:rust-cfi-fix-145981, r=bjorn3
Revert "Make `lto` and `linker-plugin-lto` work the same for `compiler_builtins` This reverts commit cf8753e4f9c3597f04cd5d3aa261e4561d5378a6 (PR https://github.com/rust-lang/rust/pull/145368) and fix the regressions reported at rust-lang/rust#145981, rust-lang/rust#146109, and rust-lang/rust#146145.
Diffstat (limited to 'compiler/rustc_codegen_ssa')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/write.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 92582dcc399..8586615f7c7 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -138,12 +138,23 @@ impl ModuleConfig { let emit_obj = if !should_emit_obj { EmitObj::None - } else if sess.target.obj_is_bitcode || sess.opts.cg.linker_plugin_lto.enabled() { + } else if sess.target.obj_is_bitcode + || (sess.opts.cg.linker_plugin_lto.enabled() && !no_builtins) + { // This case is selected if the target uses objects as bitcode, or // if linker plugin LTO is enabled. In the linker plugin LTO case // the assumption is that the final link-step will read the bitcode // and convert it to object code. This may be done by either the // native linker or rustc itself. + // + // Note, however, that the linker-plugin-lto requested here is + // explicitly ignored for `#![no_builtins]` crates. These crates are + // specifically ignored by rustc's LTO passes and wouldn't work if + // loaded into the linker. These crates define symbols that LLVM + // lowers intrinsics to, and these symbol dependencies aren't known + // until after codegen. As a result any crate marked + // `#![no_builtins]` is assumed to not participate in LTO and + // instead goes on to generate object code. EmitObj::Bitcode } else if need_bitcode_in_object(tcx) { EmitObj::ObjectCode(BitcodeSection::Full) |
