Skip to content
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

std_detect: Always avoid dlsym on *-linux-{musl,ohos}* targets #1746

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Mar 18, 2025

Similar to #1375 (for *-linux-gnu*) and #1406 (for *-android*), but for -linux-{musl,ohos}*:

On musl with static linking, there is a known problem that getauxval is not always available, independent of version requirements: rust-lang/rust#89626
However, this seems to be due to the fact that compiler-builtins is built before libc (which is a dependency of std) links musl. So IIUC the std and its dependent can use getauxval without this problem (std_detect is a part of std). Actually std uses it since Rust 1.78: rust-lang/rust@9da004e


After this PR, remaining linux/android targets that use dlsym are:

@rustbot
Copy link
Collaborator

rustbot commented Mar 18, 2025

r? @Amanieu

rustbot has assigned @Amanieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

not(all(
target_os = "linux",
any(target_env = "gnu", target_env = "musl", target_env = "ohos"),
)),
// TODO: libc crate currently doesn't provide getauxval on 32-bit Android.
not(all(target_os = "android", target_pointer_width = "64")),
))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of duplication in this function which makes it hard to review. I think this is a good opportunity to move the choice of whether to use libc::getauxval or look it up dynamically into the local getauxval function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants