-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Android: -ldl must appear after -lgcc when linking #91381
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
In this case perhaps libdl shouldn't be passed at all to save some work for the linker. |
It's getting included by the The link flags are a bit weird: some are defined in the |
The rule of thumb is that if |
I think a proper cleanup of the link attributes in std/libc can be done in another PR. In the meantime, CI on stdarch is blocked on this PR because android builds are failing. |
@bors r+ |
📌 Commit 41e2a53 has been approved by |
Android: -ldl must appear after -lgcc when linking rust-lang#90846 accidentally broke Android builds because it causes the standard library to no longer use `dlsym` on Android. This results in `libdl` being ignored by the linker since no symbols are needed from it. However, we later import `libgcc` for unwinding which *does* depend on `libdl` for `dl_iterate_phdr`. Since linkers don't revisit previous libraries when resolving symbols, this causes a linker error due to an undefined reference to `dl_iterate_phdr`. This is resolved by adding a second `-ldl` after `-lgcc` in the linker command-line.
Android: -ldl must appear after -lgcc when linking rust-lang#90846 accidentally broke Android builds because it causes the standard library to no longer use `dlsym` on Android. This results in `libdl` being ignored by the linker since no symbols are needed from it. However, we later import `libgcc` for unwinding which *does* depend on `libdl` for `dl_iterate_phdr`. Since linkers don't revisit previous libraries when resolving symbols, this causes a linker error due to an undefined reference to `dl_iterate_phdr`. This is resolved by adding a second `-ldl` after `-lgcc` in the linker command-line.
…askrgr Rollup of 10 pull requests Successful merges: - rust-lang#88906 (Implement write() method for Box<MaybeUninit<T>>) - rust-lang#90269 (Make `Option::expect` unstably const) - rust-lang#90854 (Type can be unsized and uninhabited) - rust-lang#91170 (rustdoc: preload fonts) - rust-lang#91273 (Fix ICE rust-lang#91268 by checking that the snippet ends with a `)`) - rust-lang#91381 (Android: -ldl must appear after -lgcc when linking) - rust-lang#91453 (Document Windows TLS drop behaviour) - rust-lang#91462 (Use try_normalize_erasing_regions in needs_drop) - rust-lang#91474 (suppress warning about set_errno being unused on DragonFly) - rust-lang#91483 (Sync rustfmt subtree) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
☔ The latest upstream changes (presumably #91486) made this pull request unmergeable. Please resolve the merge conflicts. |
This has been merged into master by bors (in #91486), but GitHub didn't detect it for whatever reason. Closing. |
#90846 accidentally broke Android builds because it causes the standard library to no longer use
dlsym
on Android. This results inlibdl
being ignored by the linker since no symbols are needed from it. However, we later importlibgcc
for unwinding which does depend onlibdl
fordl_iterate_phdr
. Since linkers don't revisit previous libraries when resolving symbols, this causes a linker error due to an undefined reference todl_iterate_phdr
.This is resolved by adding a second
-ldl
after-lgcc
in the linker command-line.