Skip to content

Undefined symbols when bootstrapping with ld.gold in DragonFly BSD #139425

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

Closed
tuxillo opened this issue Apr 5, 2025 · 4 comments
Closed

Undefined symbols when bootstrapping with ld.gold in DragonFly BSD #139425

tuxillo opened this issue Apr 5, 2025 · 4 comments
Labels
A-linkers Area: linkers... you gotta love linkers C-external-bug Category: issue that is caused by bugs in software beyond our control T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@tuxillo
Copy link
Contributor

tuxillo commented Apr 5, 2025

Summary

TL;DR: When building rust 1.82 onwards and trying to link the rustc_driver with ld.gold, it will fail with the following error:

 = note: /usr/libexec/binutils234/elf/ld.gold: error: version script assignment of  to symbol __rust_alloc failed: symbol not defined
/usr/libexec/binutils234/elf/ld.gold: error: version script assignment of  to symbol __rust_alloc_error_handler failed: symbol not defined
/usr/libexec/binutils234/elf/ld.gold: error: version script assignment of  to symbol __rust_alloc_error_handler_should_panic failed: symbol not defined
/usr/libexec/binutils234/elf/ld.gold: error: version script assignment of  to symbol __rust_alloc_zeroed failed: symbol not defined
/usr/libexec/binutils234/elf/ld.gold: error: version script assignment of  to symbol __rust_dealloc failed: symbol not defined
/usr/libexec/binutils234/elf/ld.gold: error: version script assignment of  to symbol __rust_no_alloc_shim_is_unstable failed: symbol not defined
/usr/libexec/binutils234/elf/ld.gold: error: version script assignment of  to symbol __rust_realloc failed: symbol not defined
collect2: error: ld returned 1 exit status
error: could not compile `rustc_driver` (lib) due to 1 previous error

Full story on Zulip: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/__rust_alloc_error_handler_should_panic.20not.20defined/with/510418013

Command used

Rust +1.82 bootstrapped with a custom script.

Expected behaviour

The build to succeed.

Actual behaviour

Fails to build, see summary.

Bootstrap configuration (bootstrap.toml)

<config>

Operating system

DragonFly BSD 6.4 and above (including bleeding edge).

HEAD

Any Rust version from 1.82 and above.

Additional context

Build Log

<log>

@tuxillo tuxillo added C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 5, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 5, 2025
@onur-ozkan onur-ozkan added O-dragonfly Operating system: DragonFly BSD A-linkers Area: linkers... you gotta love linkers and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 6, 2025
@bjorn3 bjorn3 added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. and removed O-dragonfly Operating system: DragonFly BSD labels Apr 6, 2025
@jieyouxu jieyouxu added C-external-bug Category: issue that is caused by bugs in software beyond our control and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. C-bug Category: This is a bug. labels Apr 7, 2025
@jieyouxu
Copy link
Member

For more context (see the zulip thread)

ld.gold is deprecated in GCC 15

@Noratrieb
Copy link
Member

Closing this, as it is a gold issue. To resolve this, use a different maintained linker like GNU ld (BFD), or lld.

@Noratrieb Noratrieb closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2025
@bjorn3
Copy link
Member

bjorn3 commented May 29, 2025

Maybe we could do a check that gold isn't used as linker. We might want to do the same for the ld-classic on macOS given recently discovered bugs. The fastest and most reliable method I can think of is to check the .comment section for ELF binaries to see that it doesn't contain gold as used tool. This avoids an extra linker invocation for detecting which linker is used.

@Noratrieb
Copy link
Member

That would be cool, especially when we start emitting SHF_GNU_RETAIN. I'll open an issue.

bors added a commit that referenced this issue Jun 5, 2025
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." [^2]

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 [^1] and seems to be unable to bootstrap rustc anyway [^3]. As such we shouldn't really care about supporting gold.

This would also allow re-enabling start-stop-gc with lld.

cc #93798
Likely fixes #85045

[^1]: https://lists.gnu.org/archive/html/info-gnu/2025-02/msg00001.html
[^2]: https://llvm.org/docs/LangRef.html#the-llvm-compiler-used-global-variable
[^3]: #139425
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Jun 6, 2025
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." [^2]

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 [^1] and seems to be unable to bootstrap rustc anyway [^3]. As such we shouldn't really care about supporting gold.

This would also allow re-enabling start-stop-gc with lld.

cc rust-lang/rust#93798
Likely fixes rust-lang/rust#85045

[^1]: https://lists.gnu.org/archive/html/info-gnu/2025-02/msg00001.html
[^2]: https://llvm.org/docs/LangRef.html#the-llvm-compiler-used-global-variable
[^3]: rust-lang/rust#139425
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkers Area: linkers... you gotta love linkers C-external-bug Category: issue that is caused by bugs in software beyond our control T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

6 participants