Skip to content

Commit 8418235

Browse files
committed
detect: Remove last use of is_aarch64_feature_detected
1 parent a4d656b commit 8418235

13 files changed

Lines changed: 212 additions & 72 deletions

File tree

.cirrus.yml

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,18 @@ env:
1212
RUSTFLAGS: -D warnings
1313
RUSTUP_MAX_RETRIES: '10'
1414

15-
aarch64_linux_test_task:
15+
aarch64_linux_gnu_test_task:
16+
env:
17+
TARGET: aarch64-unknown-linux-gnu
1618
matrix:
1719
- name: test ($TARGET)
18-
env:
19-
TARGET: aarch64-unknown-linux-gnu
2020
arm_container:
2121
image: rust:latest
2222
setup_script:
2323
- set -ex
2424
- lscpu
2525
- rustup toolchain add nightly --no-self-update --component rust-src && rustup default nightly
2626
- name: test ($TARGET, glibc 2.17)
27-
env:
28-
TARGET: aarch64-unknown-linux-gnu
2927
arm_container:
3028
# glibc 2.17 is the minimum glibc version that aarch64 support is available: https://sourceware.org/legacy-ml/libc-announce/2012/msg00001.html
3129
image: centos:7
@@ -34,16 +32,6 @@ aarch64_linux_test_task:
3432
- lscpu
3533
- yum install -y gcc git
3634
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain nightly --component rust-src
37-
- name: test ($TARGET)
38-
env:
39-
TARGET: aarch64-unknown-linux-musl
40-
arm_container:
41-
image: rust:alpine
42-
setup_script:
43-
- set -ex
44-
- apk --no-cache add bash git musl-dev util-linux
45-
- lscpu
46-
- rustup toolchain add nightly --no-self-update --component rust-src && rustup default nightly
4735
test_script:
4836
- |
4937
[ ! -f $HOME/.cargo/env ] || . $HOME/.cargo/env
@@ -54,6 +42,27 @@ aarch64_linux_test_task:
5442
# FEAT_LSE2 is tested on aarch64 macOS VM.
5543
- RUSTFLAGS="$RUSTFLAGS -C target-feature=+lse" RUSTDOCFLAGS="$RUSTDOCFLAGS -C target-feature=+lse" ./tools/test.sh -vv
5644

45+
aarch64_linux_musl_test_task:
46+
name: test ($TARGET)
47+
env:
48+
TARGET: aarch64-unknown-linux-musl
49+
arm_container:
50+
image: rust:alpine
51+
setup_script:
52+
- set -ex
53+
- apk --no-cache add bash git musl-dev util-linux
54+
- lscpu
55+
- rustup toolchain add nightly --no-self-update --component rust-src && rustup default nightly
56+
test_script:
57+
- set -ex
58+
- ./tools/test.sh -vv
59+
# -crt-static
60+
- RUSTFLAGS="$RUSTFLAGS -C target-feature=-crt-static" RUSTDOCFLAGS="$RUSTDOCFLAGS -C target-feature=-crt-static" ./tools/test.sh -vv
61+
# +lse
62+
# Graviton2 (Neoverse N1) is ARMv8.2-a and doesn't support FEAT_LSE2.
63+
# FEAT_LSE2 is tested on aarch64 macOS VM.
64+
- RUSTFLAGS="$RUSTFLAGS -C target-feature=+lse" RUSTDOCFLAGS="$RUSTDOCFLAGS -C target-feature=+lse" ./tools/test.sh -vv
65+
5766
armel_linux_test_task:
5867
name: test ($TARGET)
5968
env:

.github/.cspell/organization-dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ musleabi
6161
musleabihf
6262
newlibeabihf
6363
nvptx
64+
ohos
6465
openwrt
6566
riscv
6667
softfloat

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ jobs:
166166
if: startsWith(matrix.rust, 'nightly') && !startsWith(matrix.os, 'windows')
167167

168168
- run: tools/test.sh -vv $TARGET $DOCTEST_XCOMPILE $BUILD_STD
169+
# -crt-static
170+
- run: tools/test.sh -vv $TARGET $DOCTEST_XCOMPILE $BUILD_STD
171+
env:
172+
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} -C target-feature=-crt-static
173+
RUSTFLAGS: ${{ env.RUSTFLAGS }} -C target-feature=-crt-static
174+
if: contains(matrix.target, '-musl')
169175
# +cmpxchg16b
170176
# macOS is skipped because it is +cmpxchg16b by default
171177
- run: tools/test.sh -vv $TARGET $DOCTEST_XCOMPILE $BUILD_STD

src/imp/atomic128/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ Here is the table of targets that support run-time feature detection and the ins
2626
| target_arch | target_os/target_env | instruction/API |
2727
| ----------- | -------------------- | --------------- |
2828
| x86_64 | all (except for sgx) | cpuid |
29-
| aarch64 | linux-gnu/android | getauxval |
30-
| aarch64 | other linux | dlsym(getauxval) (via is_aarch64_feature_detected) |
29+
| aarch64 | linux/android | getauxval |
3130
| aarch64 | freebsd | elf_aux_info |
3231
| aarch64 | macos/openbsd | sysctl |
3332
| aarch64 | windows | IsProcessorFeaturePresent |
3433
| aarch64 | fuchsia | zx_system_get_features |
3534

3635
For targets not included in the above table, run-time detections are disabled and work the same as when `--cfg portable_atomic_no_outline_atomics` is set.
36+
37+
See [detect/aarch64_auxv.rs](detect/aarch64_auxv.rs) module-level comments for more details on Linux/Android/FreeBSD.

src/imp/atomic128/aarch64.rs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,17 @@
5252

5353
include!("macros.rs");
5454

55+
// On musl with static linking, it seems that getauxval is not always available.
56+
// See detect/aarch64_auxv.rs for more.
5557
#[cfg(not(portable_atomic_no_outline_atomics))]
5658
#[cfg(any(
57-
all(target_os = "linux", target_env = "gnu"),
59+
all(
60+
target_os = "linux",
61+
any(
62+
target_env = "gnu",
63+
all(any(target_env = "musl", target_env = "ohos"), not(target_feature = "crt-static")),
64+
),
65+
),
5866
target_os = "android",
5967
target_os = "freebsd",
6068
))]
@@ -72,10 +80,6 @@ mod detect;
7280
#[cfg(target_os = "windows")]
7381
#[path = "detect/aarch64_windows.rs"]
7482
mod detect;
75-
#[cfg(not(portable_atomic_no_outline_atomics))]
76-
#[cfg(all(target_os = "linux", not(target_env = "gnu")))]
77-
#[path = "detect/aarch64_std.rs"]
78-
mod detect;
7983

8084
// test only
8185
#[cfg(test)]
@@ -310,7 +314,16 @@ unsafe fn atomic_compare_exchange(
310314
not(portable_atomic_no_aarch64_target_feature),
311315
not(portable_atomic_no_outline_atomics),
312316
any(
313-
target_os = "linux",
317+
all(
318+
target_os = "linux",
319+
any(
320+
target_env = "gnu",
321+
all(
322+
any(target_env = "musl", target_env = "ohos"),
323+
not(target_feature = "crt-static"),
324+
),
325+
),
326+
),
314327
target_os = "android",
315328
target_os = "freebsd",
316329
target_os = "openbsd",
@@ -325,7 +338,16 @@ unsafe fn atomic_compare_exchange(
325338
not(portable_atomic_no_aarch64_target_feature),
326339
not(portable_atomic_no_outline_atomics),
327340
any(
328-
target_os = "linux",
341+
all(
342+
target_os = "linux",
343+
any(
344+
target_env = "gnu",
345+
all(
346+
any(target_env = "musl", target_env = "ohos"),
347+
not(target_feature = "crt-static"),
348+
),
349+
),
350+
),
329351
target_os = "android",
330352
target_os = "freebsd",
331353
target_os = "openbsd",

src/imp/atomic128/detect/aarch64_auxv.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,23 @@
88
//
99
// - On glibc (*-linux-gnu*), [aarch64 support is available on glibc 2.17+](https://sourceware.org/legacy-ml/libc-announce/2012/msg00001.html)
1010
// and is newer than [glibc 2.16 that added getauxval](https://sourceware.org/legacy-ml/libc-announce/2012/msg00000.html).
11+
// - On musl (*-linux-musl*, *-linux-ohos*), [aarch64 support is available on musl 1.1.7+](https://git.musl-libc.org/cgit/musl/tree/WHATSNEW?h=v1.1.7#n1422)
12+
// and is newer than [musl 1.1.0 that added getauxval](https://git.musl-libc.org/cgit/musl/tree/WHATSNEW?h=v1.1.0#n1197).
13+
// https://github.com/rust-lang/rust/commit/9a04ae4997493e9260352064163285cddc43de3c
1114
// - On bionic (*-android*), [64-bit architecture support is available on Android 5.0+ (API level 21+)](https://android-developers.googleblog.com/2014/10/whats-new-in-android-50-lollipop.html)
1215
// and is newer than [Android 4.3 (API level 18) that added getauxval](https://github.com/aosp-mirror/platform_bionic/blob/d3ebc2f7c49a9893b114124d4a6b315f3a328764/libc/include/sys/auxv.h#L49).
1316
//
14-
// On other Linux targets, we cannot assume that getauxval is always available,
15-
// so we use is_aarch64_feature_detected which uses dlsym (+io fallback) instead
16-
// of this module.
17+
// However, on musl with static linking, it seems that getauxval is not always available, independent of version requirements: https://github.com/rust-lang/rust/issues/89626
18+
// (That problem may have been fixed in https://github.com/rust-lang/rust/commit/9a04ae4997493e9260352064163285cddc43de3c,
19+
// but even in the version containing that patch, [there is report](https://github.com/rust-lang/rust/issues/89626#issuecomment-1242636038)
20+
// of the same error.)
1721
//
18-
// - On musl (*-linux-musl*), [aarch64 support is available on musl 1.1.7+](https://git.musl-libc.org/cgit/musl/tree/WHATSNEW?h=v1.1.7#n1422)
19-
// and is newer than [musl 1.1.0 that added getauxval](https://git.musl-libc.org/cgit/musl/tree/WHATSNEW?h=v1.1.0#n1197).
20-
// However, it seems that getauxval is not always available, independent of version requirements: https://github.com/rust-lang/rust/issues/89626
21-
// (That problem may have been fixed in https://github.com/rust-lang/rust/commit/9a04ae4997493e9260352064163285cddc43de3c,
22-
// but even in the version containing that patch, [there is report](https://github.com/rust-lang/rust/issues/89626#issuecomment-1242636038)
23-
// of the same error.)
24-
// - On uClibc-ng (*-linux-uclibc*), they [recently added getauxval](https://repo.or.cz/uclibc-ng.git/commitdiff/d869bb1600942c01a77539128f9ba5b5b55ad647)
22+
// On other Linux targets, we cannot assume that getauxval is always available, so we don't support
23+
// outline-atomics for now.
24+
//
25+
// - On musl with static linking. See the above for more.
26+
// Also, in this case, dlsym(getauxval) always returns null.
27+
// - On uClibc-ng (*-linux-uclibc*, *-l4re-uclibc*), they [recently added getauxval](https://repo.or.cz/uclibc-ng.git/commitdiff/d869bb1600942c01a77539128f9ba5b5b55ad647)
2528
// but have not released it yet (as of 2023-02-09).
2629
// - On Picolibc, [Picolibc 1.4.6 added getauxval stub](https://github.com/picolibc/picolibc#picolibc-version-146).
2730
//

src/imp/atomic128/detect/aarch64_std.rs

Lines changed: 0 additions & 38 deletions
This file was deleted.

tests/helper/src/gen/sys/aarch64_linux_musl/arch_arm64_include_uapi_asm_hwcap.rs

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/helper/src/gen/sys/aarch64_linux_musl/include_uapi_linux_auxvec.rs

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/helper/src/gen/sys/aarch64_linux_musl/mod.rs

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)