about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-05-03 03:52:37 +0000
committerbors <bors@rust-lang.org>2025-05-03 03:52:37 +0000
commit973ec11f61ba77123aafbb2799dd24f291250a2b (patch)
tree92c4f6ba0fce794421e07b35089c2161ed401bec /compiler/rustc_codegen_ssa/src
parent9d6fe3d1b2e24fad0574ef47915df47c72ba2ee3 (diff)
parent260fcc67f395d6961b8c1776c6c5cf64e8839517 (diff)
downloadrust-973ec11f61ba77123aafbb2799dd24f291250a2b.tar.gz
rust-973ec11f61ba77123aafbb2799dd24f291250a2b.zip
Auto merge of #140592 - cuviper:beta-next, r=cuviper
[beta] backports

- Don't allow flattened format_args in const. #139624
- set subsections_via_symbols for ld64 helper sections #139752
- Fix detection of `main` function if there are expressions around it #140220
- rustdoc: Fix doctest heuristic for main fn wrapping #140420
- extend the list of registered dylibs on `test::prepare_cargo_test` #140563

r? cuviper
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index b59d73a9aae..5f170be354d 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -2011,6 +2011,12 @@ fn add_linked_symbol_object(
         file.set_mangling(object::write::Mangling::None);
     }
 
+    if file.format() == object::BinaryFormat::MachO {
+        // Divide up the sections into sub-sections via symbols for dead code stripping.
+        // Without this flag, unused `#[no_mangle]` or `#[used]` cannot be discard on MachO targets.
+        file.set_subsections_via_symbols();
+    }
+
     // ld64 requires a relocation to load undefined symbols, see below.
     // Not strictly needed if linking with lld, but might as well do it there too.
     let ld64_section_helper = if file.format() == object::BinaryFormat::MachO {