diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-05-09 20:37:06 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-06-05 11:35:15 +0000 |
| commit | f8e9778eb12573eabac183f5d617e1a7404505c7 (patch) | |
| tree | 232141a227612b9c17496cad84c30fb31c6935d7 /compiler/rustc_codegen_ssa/src/back/link.rs | |
| parent | 95a2212587f1b8500af1ac630322b0cb2e030c61 (diff) | |
| download | rust-f8e9778eb12573eabac183f5d617e1a7404505c7.tar.gz rust-f8e9778eb12573eabac183f5d617e1a7404505c7.zip | |
Make #[used(linker)] the default on ELF too
#[used] currently is an alias for #[used(linker)] on all platforms except ELF based ones where it is an alias for #[used(compiler)]. The latter has surprising behavior and the LLVM LangRef explicitly states that it "should only be used in rare circumstances, and should not be exposed to source languages." The reason #[used] still was an alias to #[used(compiler)] on ELF is because the gold linker has issues with it. Luckily gold has been deprecated with GCC 15 and seems to be unable to bootstrap rustc anyway. As such we shouldn't really care about supporting gold.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/back/link.rs')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/link.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index c5792da2678..30128c4bea2 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1986,7 +1986,7 @@ fn add_post_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor /// This method creates a synthetic object file, which contains undefined references to all symbols /// that are necessary for the linking. They are only present in symbol table but not actually /// used in any sections, so the linker will therefore pick relevant rlibs for linking, but -/// unused `#[no_mangle]` or `#[used]` can still be discard by GC sections. +/// unused `#[no_mangle]` or `#[used(compiler)]` can still be discard by GC sections. /// /// There's a few internal crates in the standard library (aka libcore and /// libstd) which actually have a circular dependence upon one another. This @@ -2020,7 +2020,8 @@ fn add_linked_symbol_object( 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. + // Without this flag, unused `#[no_mangle]` or `#[used(compiler)]` cannot be + // discard on MachO targets. file.set_subsections_via_symbols(); } |
