-
Notifications
You must be signed in to change notification settings - Fork 304
std_detect: Always avoid dlsym on *-linux-{musl,ohos}* targets #1746
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
Conversation
| )), | ||
| // TODO: libc crate currently doesn't provide getauxval on 32-bit Android. | ||
| not(all(target_os = "android", target_pointer_width = "64")), | ||
| ))] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 2960b07.
I actually found a difference between the two blocks...
stdarch/crates/std_detect/src/detect/os/linux/auxvec.rs
Lines 83 to 89 in 5ba56c7
| // Targets with only AT_HWCAP: | |
| #[cfg(any( | |
| target_arch = "riscv32", | |
| target_arch = "riscv64", | |
| target_arch = "mips", | |
| target_arch = "mips64" | |
| ))] |
stdarch/crates/std_detect/src/detect/os/linux/auxvec.rs
Lines 130 to 137 in 5ba56c7
| // Targets with only AT_HWCAP: | |
| #[cfg(any( | |
| target_arch = "riscv32", | |
| target_arch = "riscv64", | |
| target_arch = "mips", | |
| target_arch = "mips64", | |
| target_arch = "loongarch64", | |
| ))] |
148859f to
d0173d3
Compare
d0173d3 to
2960b07
Compare
See rust-lang/stdarch#1746. libc 0.2.172 added getauxval for 32-bit ARM Android.
See rust-lang/stdarch#1746. libc 0.2.172 added getauxval for 32-bit ARM Android.
See rust-lang/stdarch#1746. libc 0.2.172 added getauxval for 32-bit ARM Android.
See rust-lang/stdarch#1746. libc 0.2.172 added getauxval for 32-bit ARM Android.
Similar to #1375 (for
*-linux-gnu*) and #1406 (for*-android*), but for-linux-{musl,ohos}*:*-linux-musl*targets (at least since Rust 1.15) use musl newer than musl 1.1.0 that addedgetauxval*-linux-ohos*targets use a fork of musl 1.2On musl with static linking, there is a known problem that
getauxvalis not always available, independent of version requirements: rust-lang/rust#89626However, this seems to be due to the fact that
compiler-builtinsis built beforelibc(which is a dependency ofstd) links musl. So IIUC thestdand its dependent can usegetauxvalwithout this problem (std_detectis a part ofstd). Actuallystduses it since Rust 1.78: rust-lang/rust@9da004eAfter this PR, remaining linux/android targets that use dlsym are:
*-android*: This is actually a issue inlibccrate std_detect: Do not use libc::getauxval on 32-bit Android #1421*-linux-uclibc*: uclibc-ng supportsgetauxvalsince 1.0.43stdcannot be compiled with these toolchains without a patch because the commit mentioned above that started usinggetauxvalis included. (Either thestdor the platform support documentation should be fixed.)*-linux-none: This target does not use any libc APIs.stdin the first place and only for x86_64 which doesn't usegetauxval.getauxval.