Skip to content
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
11 changes: 10 additions & 1 deletion .github/.cspell/project-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ atxmega
Auxinfo
auxv
auxvec
balign
bitops
BOOKE
braich
Expand All @@ -29,6 +30,7 @@ ccmp
cdsg
cgrjh
cgrjl
chericap
clgr
clgrjh
clgrjhe
Expand Down Expand Up @@ -60,15 +62,16 @@ cxchgweak
devkitc
devkitm
devtmpfs
dlfcn
dlsym
ecall
Espressif
espup
exynos
fdpic
fild
fistp
FPSR
FUNCDESC
getauxval
getisax
getpid
Expand Down Expand Up @@ -157,12 +160,16 @@ osxsave
outputdir
phdr
picolibc
popsection
poweroff
prctl
prefetcher
PRIMASK
progbits
PSRAM
pstq
purecap
pushsection
quadword
rcpc
rdinit
Expand Down Expand Up @@ -229,9 +236,11 @@ wfxt
wokwi
xadd
xchg
XCOFF
xgetbv
xmegau
xmmword
XPLINK
xsave
xsub
zaamo
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,13 @@ jobs:

# {,no-}outline-atomics
# portable_atomic_no_outline_atomics only affects x86_64, AArch64, Arm, powerpc64, and RISC-V Linux.
# outline-atomics is disabled by default on AArch64/powerpc64 musl with static linking, and AIX.
# outline-atomics is disabled by default on AIX.
# powerpc64le- (little-endian) is skipped because it is pwr8 by default
- run: tools/test.sh -vv --tests ${TARGET:-} ${BUILD_STD:-}
env:
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} --cfg portable_atomic_no_outline_atomics
RUSTFLAGS: ${{ env.RUSTFLAGS }} --cfg portable_atomic_no_outline_atomics
if: startsWith(matrix.target, 'x86_64') || ((startsWith(matrix.target, 'aarch64') || startsWith(matrix.target, 'arm64')) || startsWith(matrix.target, 'powerpc64-')) && !(contains(matrix.target, '-musl') && matrix.flags == '') || startsWith(matrix.target, 'armv4t') || startsWith(matrix.target, 'armv5te') || matrix.target == 'arm-linux-androideabi' || startsWith(matrix.target, 'riscv')
if: startsWith(matrix.target, 'x86_64') || ((startsWith(matrix.target, 'aarch64') || startsWith(matrix.target, 'arm64')) || startsWith(matrix.target, 'powerpc64-')) || startsWith(matrix.target, 'armv4t') || startsWith(matrix.target, 'armv5te') || matrix.target == 'arm-linux-androideabi' || startsWith(matrix.target, 'riscv')
# powerpc64 and RISC-V are skipped because tested below.
- run: tools/test.sh -vv --tests ${TARGET:-} ${BUILD_STD:-}
env:
Expand Down Expand Up @@ -508,6 +508,9 @@ jobs:
- target: aarch64-unknown-openbsd
os: openbsd
version: '7.9'
- target: aarch64-unknown-openbsd
os: openbsd
version: '7.5' # no elf_aux_info
- target: aarch64-unknown-illumos
os: omnios
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -558,9 +561,10 @@ jobs:
if: matrix.toolchain != ''
- uses: taiki-e/cross-platform-actions-action@63e3c031895caac4783f1f778f3e2e0e409353b3 # dev # zizmor: ignore[stale-action-refs]
env:
OS_VERSION: ${{ matrix.version }}
TOOLCHAIN: ${{ matrix.toolchain }}
with:
environment_variables: CARGO_INCREMENTAL CARGO_NET_RETRY CARGO_TERM_COLOR RUST_BACKTRACE RUST_TEST_THREADS RUSTDOCFLAGS RUSTFLAGS RUSTUP_MAX_RETRIES PORTABLE_ATOMIC_DENY_WARNINGS TEST_FEATURES TOOLCHAIN
environment_variables: CARGO_INCREMENTAL CARGO_NET_RETRY CARGO_TERM_COLOR RUST_BACKTRACE RUST_TEST_THREADS RUSTDOCFLAGS RUSTFLAGS RUSTUP_MAX_RETRIES PORTABLE_ATOMIC_DENY_WARNINGS TEST_FEATURES OS_VERSION TOOLCHAIN
operating_system: ${{ matrix.os }}
architecture: ${{ matrix.os == 'omnios' && 'x86_64' || 'aarch64' }}
version: ${{ matrix.os == 'omnios' && 'r151058' || matrix.version }}
Expand Down
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(target_arch,values("loongarch32"))', # 1.89+ https://github.com/rust-lang/rust/pull/142053
'cfg(target_os,values("trusty"))', # 1.82+ https://github.com/rust-lang/rust/pull/129490
'cfg(target_os,values("psx"))', # 1.84+ https://github.com/rust-lang/rust/pull/131168
'cfg(target_os,values("cygwin"))', # 1.86+ https://github.com/rust-lang/rust/pull/134999
'cfg(target_os,values("zos"))', # https://github.com/rust-lang/compiler-team/issues/992
'cfg(target_env,values("psx"))', # pre-1.84 https://github.com/rust-lang/rust/pull/131168
'cfg(target_abi,values("pauthtest"))', # 1.98+ https://github.com/rust-lang/rust/pull/155722
'cfg(target_abi,values("purecap"))', # https://github.com/kent-weak-memory/rust
'cfg(target_abi,values("fdpic"))', # https://github.com/llvm/llvm-project/issues/146959
'cfg(target_feature,values("lse2","lse128","rcpc3"))', # 1.82+ https://github.com/rust-lang/rust/pull/128192
'cfg(target_feature,values("quadword-atomics"))', # 1.83+ https://github.com/rust-lang/rust/pull/130873
'cfg(target_feature,values("zaamo","zabha"))', # 1.83+ https://github.com/rust-lang/rust/pull/130877
Expand All @@ -112,7 +116,7 @@ unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(target_pointer_width,values("128"))',
# Known custom cfgs, excluding those that may be set by build script.
# Public APIs, considered unstable unless documented as stable in readme.
'cfg(portable_atomic_no_outline_atomics,portable_atomic_outline_atomics,portable_atomic_unstable_f16,portable_atomic_unstable_f128)',
'cfg(portable_atomic_outline_atomics,portable_atomic_unstable_f16,portable_atomic_unstable_f128)',
# Not public API.
'cfg(portable_atomic_test_detect_false,portable_atomic_test_no_std_static_assert_ffi,qemu,valgrind,valgrind_cross)',
] }
Expand Down
63 changes: 60 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn main() {
// Custom cfgs set by build script. Not public API.
// grep -F 'cargo:rustc-cfg=' build.rs | grep -Ev '^ *//' | sed -E 's/^.*cargo:rustc-cfg=//; s/(=\\)?".*$//' | LC_ALL=C sort -u | tr '\n' ',' | sed -E 's/,$/\n/'
println!(
"cargo:rustc-check-cfg=cfg(portable_atomic_atomic_intrinsics,portable_atomic_disable_fiq,portable_atomic_force_amo,portable_atomic_ll_sc_rmw,portable_atomic_llvm_16_or_later,portable_atomic_llvm_17_or_later,portable_atomic_no_asm,portable_atomic_no_asm_maybe_uninit,portable_atomic_no_asm_syscall,portable_atomic_no_atomic_64,portable_atomic_no_atomic_cas,portable_atomic_no_atomic_load_store,portable_atomic_no_atomic_min_max,portable_atomic_no_cfg_target_has_atomic,portable_atomic_no_cmpxchg16b_intrinsic,portable_atomic_no_cmpxchg16b_target_feature,portable_atomic_no_const_mut_refs,portable_atomic_no_const_raw_ptr_deref,portable_atomic_no_const_transmute,portable_atomic_no_core_unwind_safe,portable_atomic_no_diagnostic_namespace,portable_atomic_no_strict_provenance,portable_atomic_no_strict_provenance_atomic_ptr,portable_atomic_no_stronger_failure_ordering,portable_atomic_no_track_caller,portable_atomic_no_unsafe_op_in_unsafe_fn,portable_atomic_old_miri,portable_atomic_pre_llvm_16,portable_atomic_pre_llvm_18,portable_atomic_pre_llvm_20,portable_atomic_s_mode,portable_atomic_sanitize_thread,portable_atomic_target_cpu,portable_atomic_target_feature,portable_atomic_unsafe_assume_privileged,portable_atomic_unsafe_assume_single_core,portable_atomic_unstable_asm,portable_atomic_unstable_asm_experimental_arch,portable_atomic_unstable_cfg_target_has_atomic,portable_atomic_unstable_isa_attribute)"
"cargo:rustc-check-cfg=cfg(portable_atomic_atomic_intrinsics,portable_atomic_disable_fiq,portable_atomic_force_amo,portable_atomic_ll_sc_rmw,portable_atomic_llvm_16_or_later,portable_atomic_llvm_17_or_later,portable_atomic_no_asm,portable_atomic_no_asm_maybe_uninit,portable_atomic_no_asm_syscall,portable_atomic_no_atomic_64,portable_atomic_no_atomic_cas,portable_atomic_no_atomic_load_store,portable_atomic_no_atomic_min_max,portable_atomic_no_cfg_target_has_atomic,portable_atomic_no_cmpxchg16b_intrinsic,portable_atomic_no_cmpxchg16b_target_feature,portable_atomic_no_const_mut_refs,portable_atomic_no_const_raw_ptr_deref,portable_atomic_no_const_transmute,portable_atomic_no_core_unwind_safe,portable_atomic_no_diagnostic_namespace,portable_atomic_no_outline_atomics,portable_atomic_no_strict_provenance,portable_atomic_no_strict_provenance_atomic_ptr,portable_atomic_no_stronger_failure_ordering,portable_atomic_no_target_abi,portable_atomic_no_track_caller,portable_atomic_no_unsafe_op_in_unsafe_fn,portable_atomic_old_miri,portable_atomic_pre_llvm_16,portable_atomic_pre_llvm_18,portable_atomic_pre_llvm_20,portable_atomic_purecap,portable_atomic_s_mode,portable_atomic_sanitize_thread,portable_atomic_target_cpu,portable_atomic_target_feature,portable_atomic_unsafe_assume_privileged,portable_atomic_unsafe_assume_single_core,portable_atomic_unstable_asm,portable_atomic_unstable_asm_experimental_arch,portable_atomic_unstable_cfg_target_has_atomic,portable_atomic_unstable_isa_attribute)"
);
// TODO: handle multi-line emit_target_feature_fallback
// grep -F 'emit_target_feature_fallback("' build.rs | grep -Ev '^ *//' | sed -E 's/^.*emit_target_feature_fallback\(//; s/",.*$/"/' | LC_ALL=C sort -u | tr '\n' ',' | sed -E 's/,$/\n/'
Expand Down Expand Up @@ -127,6 +127,19 @@ fn main() {
if !version.probe(74, 2023, 8, 23) {
println!("cargo:rustc-cfg=portable_atomic_no_asm_maybe_uninit");
}
// #[cfg(target_abi)] stabilized in Rust 1.78 (nightly-2024-02-26): https://github.com/rust-lang/rust/pull/119590
if !version.probe(78, 2024, 2, 25) {
println!("cargo:rustc-cfg=portable_atomic_no_target_abi");
if target_arch == "aarch64"
&& (env::var("CARGO_CFG_TARGET_ABI")
.unwrap_or_default()
.split(',')
.any(|abi| abi == "purecap")
|| target.ends_with("-purecap"))
{
println!("cargo:rustc-cfg=portable_atomic_purecap");
}
}
// #[diagnostic] stabilized in Rust 1.78 (nightly-2024-03-09): https://github.com/rust-lang/rust/pull/119888
if !version.probe(78, 2024, 3, 8) {
println!("cargo:rustc-cfg=portable_atomic_no_diagnostic_namespace");
Expand Down Expand Up @@ -175,6 +188,13 @@ fn main() {
// The part of this feature we use has not been changed since nightly-2020-06-21
// until it was stabilized, so it can safely be enabled in nightly for that period.
println!("cargo:rustc-cfg=portable_atomic_unstable_asm");
if (target_arch == "aarch64"/* test-only: || target_arch == "arm" */)
&& (!rustflags.is_allowed_feature("global_asm") || !version.probe(54, 2021, 5, 19))
{
// weakref macro needs global_asm! and extended_key_value_attributes
// (stabilized in 1.54 (nightly-2021-05-20): https://github.com/rust-lang/rust/pull/83366).
println!("cargo:rustc-cfg=portable_atomic_no_outline_atomics");
}
if (target_arch == "riscv32" || target_arch == "riscv64")
&& !version.probe(56, 2021, 8, 15)
{
Expand Down Expand Up @@ -226,7 +246,7 @@ fn main() {
}
}

// feature(cfg_target_has_atomic) stabilized in Rust 1.60 (nightly-2022-02-11): https://github.com/rust-lang/rust/pull/93824
// cfg(target_has_atomic) stabilized in Rust 1.60 (nightly-2022-02-11): https://github.com/rust-lang/rust/pull/93824
if !version.probe(60, 2022, 2, 10) {
if version.nightly
&& version.probe(40, 2019, 10, 13)
Expand Down Expand Up @@ -404,6 +424,32 @@ fn main() {
if is_apple || rustflags.target_cpu.map_or(false, |cpu| cpu.starts_with("apple-")) {
println!("cargo:rustc-cfg=portable_atomic_ll_sc_rmw");
}

if target_os == "linux"
&& env::var("CARGO_CFG_TARGET_ABI")
.unwrap_or_default()
.split(',')
.any(|abi| abi == "pauthtest")
{
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default();
// The compiler normally rejects crt-static for pauthtest ABI, but check just in case.
// https://github.com/rust-lang/rust/blob/0844f35a32c98882d77e39da8c2a872ec74615cd/compiler/rustc_session/src/session.rs#L1510
// crt-static is not shown in CARGO_CFG_TARGET_FEATURE when enabled by default, but fine in this case.
if !cfg!(feature = "std")
&& target_env == "musl"
&& env::var("CARGO_CFG_TARGET_FEATURE")
.unwrap_or_default()
.split(',')
.any(|f| f == "crt-static")
|| target_env == "uclibc"
{
// Do not use weakref on pauthtest ABI due to:
// - LLD bug: https://github.com/llvm/llvm-project/issues/173296
// - There is no good way to recognize `-Z pointer-authentication=-calls`
// Note: There is no builtin targets can reach this.
println!("cargo:rustc-cfg=portable_atomic_no_outline_atomics");
}
}
}
"arm" => {
// For non-Linux/Android pre-v6 Arm (tier 3) with unsafe_assume_single_core enabled.
Expand Down Expand Up @@ -633,11 +679,22 @@ fn main() {
{
// Cell Broadband Engine SPU syscalls support a subset of powerpc64 syscalls with the exact semantics: https://github.com/torvalds/linux/blob/v7.1/arch/powerpc/platforms/cell/spu_callbacks.c#L17
// but have a different syscall sequence: https://github.com/mirror/newlib-cygwin/blob/newlib-4.4.0/libgloss/spu/linux_syscalls.c#L37
// GCC 10 (https://gcc.gnu.org/gcc-9/changes.html) and LLVM 3.3.0 (https://releases.llvm.org/3.3/docs/ReleaseNotes.html#non-comprehensive-list-of-changes-in-this-release)
// Note: There is no builtin SPU targets. And GCC 10 (https://gcc.gnu.org/gcc-9/changes.html)
// and LLVM 3.3.0 (https://releases.llvm.org/3.3/docs/ReleaseNotes.html#non-comprehensive-list-of-changes-in-this-release)
// removed support for SPU, so this is unlikely to be supported in rust-lang/rust: https://github.com/rust-lang/compiler-team/issues/614
// Note: code referring this cfg is currently used only for testing.
println!("cargo:rustc-cfg=portable_atomic_no_asm_syscall");
}
if env::var("CARGO_CFG_TARGET_POINTER_WIDTH")
.expect("CARGO_CFG_TARGET_POINTER_WIDTH not set")
== "32"
{
// Do not use weakref on PowerPC64 ILP32 due to LLVM bug:
// - https://github.com/llvm/llvm-project/issues/52826
// - https://github.com/llvm/llvm-project/issues/169283
// Note: There is no builtin PowerPC64 ILP32 targets.
println!("cargo:rustc-cfg=portable_atomic_no_outline_atomics");
}
}
"s390x" => {
let mut arch9_features = false; // z196+
Expand Down
Loading