Skip to content

Commit 5a4d090

Browse files
committed
remove -znostart-stop-gc workaround
Now that `#[used(linker)]` is the default on ELF, we don't need to use the `-znostart-stop-gc` link-arg workaround to match bfd's behavior when using lld.
1 parent b7d46b0 commit 5a4d090

File tree

1 file changed

+0
-29
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+0
-29
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3326,35 +3326,6 @@ fn add_lld_args(
33263326
// this, `wasm-component-ld`, which is overridden if this option is passed.
33273327
if !sess.target.is_like_wasm {
33283328
cmd.cc_arg("-fuse-ld=lld");
3329-
3330-
// On ELF platforms like at least x64 linux, GNU ld and LLD have opposite defaults on some
3331-
// section garbage-collection features. For example, the somewhat popular `linkme` crate and
3332-
// its dependents rely in practice on this difference: when using lld, they need `-z
3333-
// nostart-stop-gc` to prevent encapsulation symbols and sections from being
3334-
// garbage-collected.
3335-
//
3336-
// More information about all this can be found in:
3337-
// - https://maskray.me/blog/2021-01-31-metadata-sections-comdat-and-shf-link-order
3338-
// - https://lld.llvm.org/ELF/start-stop-gc
3339-
//
3340-
// So when using lld, we restore, for now, the traditional behavior to help migration, but
3341-
// will remove it in the future.
3342-
// Since this only disables an optimization, it shouldn't create issues, but is in theory
3343-
// slightly suboptimal. However, it:
3344-
// - doesn't have any visible impact on our benchmarks
3345-
// - reduces the need to disable lld for the crates that depend on this
3346-
//
3347-
// Note that lld can detect some cases where this difference is relied on, and emits a
3348-
// dedicated error to add this link arg. We could make use of this error to emit an FCW. As
3349-
// of writing this, we don't do it, because lld is already enabled by default on nightly
3350-
// without this mitigation: no working project would see the FCW, so we do this to help
3351-
// stabilization.
3352-
//
3353-
// FIXME: emit an FCW if linking fails due its absence, and then remove this link-arg in the
3354-
// future.
3355-
if sess.target.llvm_target == "x86_64-unknown-linux-gnu" {
3356-
cmd.link_arg("-znostart-stop-gc");
3357-
}
33583329
}
33593330

33603331
if !flavor.is_gnu() {

0 commit comments

Comments
 (0)