Skip to content

std_detect: Do not use libc::getauxval on 32-bit Android #1421

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

Merged
merged 2 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,13 @@ jobs:
if: "matrix.os == 'ubuntu-latest' && !startsWith(matrix.target, 'thumb')"
env:
TARGET: ${{ matrix.target }}

build-std-detect:
needs: [style]
name: Build std_detect
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update nightly && rustup default nightly
- run: ./ci/build-std-detect.sh
40 changes: 40 additions & 0 deletions ci/build-std-detect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

# Build std_detect on non-Linux & non-x86 targets.
#
# In std_detect, non-x86 targets have OS-specific implementations,
# but we can test only Linux in CI. This script builds targets supported
# by std_detect but cannot be tested in CI.

set -ex
cd "$(dirname "$0")"/..

targets=(
# Android
aarch64-linux-android
arm-linux-androideabi

# FreeBSD
aarch64-unknown-freebsd
armv6-unknown-freebsd
powerpc-unknown-freebsd
powerpc64-unknown-freebsd

# OpenBSD
aarch64-unknown-openbsd

# Windows
aarch64-pc-windows-msvc
)

rustup component add rust-src # for -Z build-std

cd crates/std_detect
for target in "${targets[@]}"; do
if rustup target add "${target}" &>/dev/null; then
cargo build --target "${target}"
else
# tier 3 targets requires -Z build-std.
cargo build -Z build-std="core,alloc" --target "${target}"
fi
done
6 changes: 4 additions & 2 deletions crates/std_detect/src/detect/os/linux/auxvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ pub(crate) fn auxv() -> Result<AuxVec, ()> {
#[cfg(all(
feature = "std_detect_dlsym_getauxval",
not(all(target_os = "linux", target_env = "gnu")),
not(target_os = "android"),
// TODO: libc crate currently doesn't provide getauxval on 32-bit Android.
not(all(target_os = "android", target_pointer_width = "64")),
))]
{
// Try to call a dynamically-linked getauxval function.
Expand Down Expand Up @@ -118,7 +119,8 @@ pub(crate) fn auxv() -> Result<AuxVec, ()> {
#[cfg(any(
not(feature = "std_detect_dlsym_getauxval"),
all(target_os = "linux", target_env = "gnu"),
target_os = "android",
// TODO: libc crate currently doesn't provide getauxval on 32-bit Android.
all(target_os = "android", target_pointer_width = "64"),
))]
{
// Targets with only AT_HWCAP:
Expand Down