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-gnu* targets #1375

Merged
merged 2 commits into from
Feb 3, 2023

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Jan 29, 2023

Currently, we use dlsym on non-x861 Linux/Android when the std_detect_dlsym_getauxval feature (enabled by default) is enabled because getauxval may not be available.

However, since Rust 1.64, all *-linux-gnu* targets have glibc requirements higher than glibc 2.16 that getauxval added, and we can safely assume getauxval is linked to the binary.

Related #655 (fyi @briansmith)


IIUC, at this time, we can do this on only *-linux-gnu* targets, because:

Footnotes

  1. On x86, we use cpuid instead of auxv.

@rustbot
Copy link
Collaborator

rustbot commented Jan 29, 2023

r? @Amanieu

(rustbot has picked a reviewer for you, use r? to override)

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 <[email protected]>
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 <[email protected]>
crates/std_detect/README.md Outdated Show resolved Hide resolved
crates/std_detect/src/detect/os/linux/auxvec.rs Outdated Show resolved Hide resolved
Co-authored-by: Amanieu d'Antras <[email protected]>
@Amanieu Amanieu merged commit 75aa6f6 into rust-lang:master Feb 3, 2023
@taiki-e taiki-e deleted the std-detect-getauxval branch February 3, 2023 23:29
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.

4 participants