-
Notifications
You must be signed in to change notification settings - Fork 286
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-gnu* targets #1375
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Since Rust 1.64, all `*-linux-gnu*` targets have glibc requirements higher than glibc 2.16 that `getauxval` added. Refs: - https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-requirements.html - https://sourceware.org/legacy-ml/libc-announce/2012/msg00000.html
r? @Amanieu (rustbot has picked a reviewer for you, use r? to override) |
lu-zero
approved these changes
Jan 29, 2023
bors bot
added a commit
to taiki-e/portable-atomic
that referenced
this pull request
Jan 30, 2023
67: detect: Avoid dlsym on aarch64 linux-gnu r=taiki-e a=taiki-e As of nightly-2023-01-23, is_aarch64_feature_detected always uses dlsym by default on aarch64 linux, but on linux-gnu [aarch64 support is available on glibc 2.17+](https://sourceware.org/legacy-ml/libc-announce/2012/msg00001.html) and is newer than [glibc 2.16 that getauxval was added](https://sourceware.org/legacy-ml/libc-announce/2012/msg00000.html), so we can safely assume getauxval is linked to the binary. A patch on stdarch side: rust-lang/stdarch#1375 On other linux targets, we cannot assume that getauxval is always available yet (see stdarch PR linked above for details), so we continue to use is_aarch64_feature_detected which uses dlsym (+io fallback) instead of this module. Co-authored-by: Taiki Endo <te316e89@gmail.com>
bors bot
added a commit
to taiki-e/portable-atomic
that referenced
this pull request
Jan 30, 2023
67: detect: Avoid dlsym on aarch64 linux-gnu r=taiki-e a=taiki-e As of nightly-2023-01-23, is_aarch64_feature_detected always uses dlsym by default on aarch64 linux, but on linux-gnu [aarch64 support is available on glibc 2.17+](https://sourceware.org/legacy-ml/libc-announce/2012/msg00001.html) and is newer than [glibc 2.16 that getauxval was added](https://sourceware.org/legacy-ml/libc-announce/2012/msg00000.html), so we can safely assume getauxval is linked to the binary. A patch on stdarch side: rust-lang/stdarch#1375 On other linux targets, we cannot assume that getauxval is always available yet (see stdarch PR linked above for details), so we continue to use is_aarch64_feature_detected which uses dlsym (+io fallback) instead of this module. Co-authored-by: Taiki Endo <te316e89@gmail.com>
Amanieu
reviewed
Jan 31, 2023
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, we use
dlsym
on non-x861 Linux/Android when thestd_detect_dlsym_getauxval
feature (enabled by default) is enabled becausegetauxval
may not be available.However, since Rust 1.64, all
*-linux-gnu*
targets have glibc requirements higher than glibc 2.16 thatgetauxval
added, and we can safely assumegetauxval
is linked to the binary.Related #655 (fyi @briansmith)
IIUC, at this time, we can do this on only
*-linux-gnu*
targets, because:*-linux-musl*
, it seems thatgetauxval
is not always available, independent of version requirements: Undefined reference togetauxval
in functioninit_have_lse_atomics
when compiling to nightlyaarch64-unknown-linux-musl
rust#89626getauxval
is used on the C/C++ side).*-android*
, according to auxv crate,getauxval
is available for android 4.3 or later, but the Android API requirement for Rust is still 4.0 (Ice Cream Sandwich).getauxval
is always available.*-linux-*
targets (e.g.*-linux-uclibc*
), according to auxv crate,getauxval
is not available.Footnotes
On x86, we use cpuid instead of auxv. ↩