about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/back/write.rs
diff options
context:
space:
mode:
authorThe Miri Cronjob Bot <miri@cron.bot>2025-09-04 05:00:34 +0000
committerThe Miri Cronjob Bot <miri@cron.bot>2025-09-04 05:00:34 +0000
commit94e40cd9c4aac126cd4c58ad9d1e8fbfc12724de (patch)
treee8acabf18ebf722dd56a65ddc69c47befc889c3c /compiler/rustc_codegen_ssa/src/back/write.rs
parentd9619ed1c54f7c20b74913982cf0715002380e10 (diff)
parentd8ca776f6de1d484afc9f847f558bd32b94ceced (diff)
downloadrust-94e40cd9c4aac126cd4c58ad9d1e8fbfc12724de.tar.gz
rust-94e40cd9c4aac126cd4c58ad9d1e8fbfc12724de.zip
Merge ref '9385c64c95d9' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: 9385c64c95d971329e62917adc4349c8ccdbafe0
Filtered ref: 80818ce34771a13f1a67a706e7e283ba58bdc460

This merge was created using https://github.com/rust-lang/josh-sync.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/back/write.rs')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/write.rs13
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)