-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Emit a warning when gold is used as the linker #141748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Oh, looks like
that's really funny. |
Warn when gold was used as the linker gold has been deprecated recently and is known to behave incorrectly around Rust programs, including miscompiling `#[used(linker)]`. Tell people to switch to a different linker instead. closes #141748 opening mostly for perf for now, but feel free to review r? bjorn3
People really want link args to remain opaque to rustc, and it’s becoming quite hard to handle these combinations of flags, driver versions, etc without understanding the link args or knowing which linker is going to be used. We can’t even really say "let’s not default to lld if there are any link args". We may need to retry linking without it if it causes issues instead. Very disheartening. |
Warn when gold was used as the linker gold has been deprecated recently and is known to behave incorrectly around Rust programs, including miscompiling `#[used(linker)]`. Tell people to switch to a different linker instead. closes #141748 opening mostly for perf for now, but feel free to review r? bjorn3
Warn when gold was used as the linker gold has been deprecated recently and is known to behave incorrectly around Rust programs, including miscompiling `#[used(linker)]`. Tell people to switch to a different linker instead. closes rust-lang/rust#141748 r? bjorn3
Warn when gold was used as the linker gold has been deprecated recently and is known to behave incorrectly around Rust programs, including miscompiling `#[used(linker)]`. Tell people to switch to a different linker instead. closes rust-lang/rust#141748 r? bjorn3
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 miscompilesSHF_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
, whichcc
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.The text was updated successfully, but these errors were encountered: