-
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-{musl,ohos}* targets #1746
Conversation
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")), | ||
))] |
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
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
getauxval
is not always available, independent of version requirements: rust-lang/rust#89626However, this seems to be due to the fact that
compiler-builtins
is built beforelibc
(which is a dependency ofstd
) links musl. So IIUC thestd
and its dependent can usegetauxval
without this problem (std_detect
is a part ofstd
). Actuallystd
uses 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 inlibc
crate std_detect: Do not use libc::getauxval on 32-bit Android #1421*-linux-uclibc*
: uclibc-ng supportsgetauxval
since 1.0.43std
cannot be compiled with these toolchains without a patch because the commit mentioned above that started usinggetauxval
is included. (Either thestd
or the platform support documentation should be fixed.)*-linux-none
: This target does not use any libc APIs.std
in the first place and only for x86_64 which doesn't usegetauxval
.getauxval
.