Description
ld.gold is officially deprecated and doesn't seem entirely work properly for Rust: #139425
Once rustc starts emitting SHF_GNU_RETAIN
sections for #[used]
(#140872), it will get even worse, as gold miscompiles SHF_GNU_RETAIN
(it doesn't just ignore it, it breaks the program in other ways).
It may be possible for rustc to detect usage of gold an emit an appropriate warning, telling the user to switch to a different linker like BFD or LLD instead.
@bjorn3 suggested looking at .comment
after linking in #139425 (comment). From local testing, it looks like gold only adds this if you pass --enable-linker-version
, which cc
doesn't seem to pass by default.
But it looks like gold always emits a note, .note.gnu.gold-version
/NT_GNU_GOLD_VERSION
, which seems like a reliable way to detect gold.