diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f02be470..1002810f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -170,26 +170,33 @@ jobs: - run: tools/test.sh -vv $TARGET $DOCTEST_XCOMPILE $BUILD_STD $REPORT_TIME - run: tools/test.sh -vv $TARGET $DOCTEST_XCOMPILE $BUILD_STD $REPORT_TIME env: - # Note: This cfg is intended to make it easy for portable-atomic developers - # to test has_cmpxchg16b == false, has_vmovdqa_atomic = false, has_lse == false, or __kuser_helper_version < 5 cases, - # and is not a public API. + # Note: detect_false cfg is intended to make it easy for portable-atomic developers to + # test cases such as has_cmpxchg16b == false, has_lse == false, + # __kuser_helper_version < 5, etc., and is not a public API. RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} --cfg portable_atomic_test_outline_atomics_detect_false RUSTFLAGS: ${{ env.RUSTFLAGS }} --cfg portable_atomic_test_outline_atomics_detect_false # outline-atomics is disabled by default on aarch64 musl with static linking if: (matrix.target == '' || startsWith(matrix.target, 'x86_64')) || startsWith(matrix.target, 'aarch64') && !contains(matrix.target, '-musl') || startsWith(matrix.target, 'armv5te') || matrix.target == 'arm-linux-androideabi' - # -crt-static - - run: tools/test.sh -vv $TARGET $DOCTEST_XCOMPILE $BUILD_STD $REPORT_TIME - env: - RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} -C target-feature=-crt-static - RUSTFLAGS: ${{ env.RUSTFLAGS }} -C target-feature=-crt-static - if: contains(matrix.target, '-musl') - # +crt-static + outline-atomics # outline-atomics is disabled by default on aarch64 musl with static linking - run: tools/test.sh -vv $TARGET $DOCTEST_XCOMPILE $BUILD_STD $REPORT_TIME env: RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} --cfg portable_atomic_outline_atomics RUSTFLAGS: ${{ env.RUSTFLAGS }} --cfg portable_atomic_outline_atomics if: startsWith(matrix.target, 'aarch64') && contains(matrix.target, '-musl') + - run: tools/test.sh -vv $TARGET $DOCTEST_XCOMPILE $BUILD_STD $REPORT_TIME + env: + # Note: detect_false cfg is intended to make it easy for portable-atomic developers to + # test cases such as has_cmpxchg16b == false, has_lse == false, + # __kuser_helper_version < 5, etc., and is not a public API. + RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} --cfg portable_atomic_outline_atomics --cfg portable_atomic_test_outline_atomics_detect_false + RUSTFLAGS: ${{ env.RUSTFLAGS }} --cfg portable_atomic_outline_atomics --cfg portable_atomic_test_outline_atomics_detect_false + if: startsWith(matrix.target, 'aarch64') && contains(matrix.target, '-musl') + # -crt-static + - run: tools/test.sh -vv $TARGET $DOCTEST_XCOMPILE $BUILD_STD $REPORT_TIME + env: + RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} -C target-feature=-crt-static + RUSTFLAGS: ${{ env.RUSTFLAGS }} -C target-feature=-crt-static + if: contains(matrix.target, '-musl') # +cmpxchg16b - run: tools/test.sh -vv $TARGET $DOCTEST_XCOMPILE $BUILD_STD $REPORT_TIME env: diff --git a/src/imp/arm_linux.rs b/src/imp/arm_linux.rs index dd149963..e3fcebca 100644 --- a/src/imp/arm_linux.rs +++ b/src/imp/arm_linux.rs @@ -56,8 +56,9 @@ fn __kuser_helper_version() -> i32 { } #[inline] fn has_kuser_cmpxchg64() -> bool { - // Note: This cfg is intended to make it easy for portable-atomic developers - // to test __kuser_helper_version < 5 cases, and is not a public API. + // Note: detect_false cfg is intended to make it easy for portable-atomic developers to + // test cases such as has_cmpxchg16b == false, has_lse == false, + // __kuser_helper_version < 5, etc., and is not a public API. if cfg!(portable_atomic_test_outline_atomics_detect_false) { return false; } diff --git a/src/imp/atomic128/detect/common.rs b/src/imp/atomic128/detect/common.rs index 42103f9c..8ae10d58 100644 --- a/src/imp/atomic128/detect/common.rs +++ b/src/imp/atomic128/detect/common.rs @@ -33,9 +33,9 @@ pub(crate) fn detect() -> CpuInfo { return info; } info.set(CpuInfo::INIT); - // Note: This cfg is intended to make it easy for portable-atomic developers - // to test has_cmpxchg16b == false or has_lse == false cases, - // and is not a public API. + // Note: detect_false cfg is intended to make it easy for portable-atomic developers to + // test cases such as has_cmpxchg16b == false, has_lse == false, + // __kuser_helper_version < 5, etc., and is not a public API. if !cfg!(portable_atomic_test_outline_atomics_detect_false) { _detect(&mut info); } @@ -229,20 +229,40 @@ mod tests_common { use std::{fmt::Write as _, io::Write, string::String}; let mut features = String::new(); + macro_rules! print_feature { + ($name:expr, $enabled:expr $(,)?) => {{ + let _ = writeln!(features, " {}: {}", $name, $enabled); + }}; + } #[cfg(target_arch = "aarch64")] { - let _ = writeln!(features, "lse: {}", detect().test(CpuInfo::HAS_LSE)); - let _ = writeln!(features, "lse2: {}", detect().test(CpuInfo::HAS_LSE2)); - let _ = writeln!(features, "lse128: {}", detect().test(CpuInfo::HAS_LSE128)); - let _ = writeln!(features, "rcpc3: {}", detect().test(CpuInfo::HAS_RCPC3)); + features.push_str("run-time:\n"); + print_feature!("lse", detect().test(CpuInfo::HAS_LSE)); + print_feature!("lse2", detect().test(CpuInfo::HAS_LSE2)); + print_feature!("lse128", detect().test(CpuInfo::HAS_LSE128)); + print_feature!("rcpc3", detect().test(CpuInfo::HAS_RCPC3)); + features.push_str("compile-time:\n"); + print_feature!( + "lse", + cfg!(any(target_feature = "lse", portable_atomic_target_feature = "lse")), + ); + print_feature!( + "lse2", + cfg!(any(target_feature = "lse2", portable_atomic_target_feature = "lse2")), + ); } #[cfg(target_arch = "x86_64")] { - let _ = writeln!(features, "cmpxchg16b: {}", detect().test(CpuInfo::HAS_CMPXCHG16B)); - let _ = writeln!( - features, - "vmovdqa-atomic: {}", - detect().test(CpuInfo::HAS_VMOVDQA_ATOMIC) + features.push_str("run-time:\n"); + print_feature!("cmpxchg16b", detect().test(CpuInfo::HAS_CMPXCHG16B)); + print_feature!("vmovdqa-atomic", detect().test(CpuInfo::HAS_VMOVDQA_ATOMIC)); + features.push_str("compile-time:\n"); + print_feature!( + "cmpxchg16b", + cfg!(any( + target_feature = "cmpxchg16b", + portable_atomic_target_feature = "cmpxchg16b", + )), ); } let stdout = std::io::stderr(); diff --git a/src/utils.rs b/src/utils.rs index 4be50b22..6b670484 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -70,7 +70,11 @@ macro_rules! ifunc { #[allow(unused_macros)] #[cfg(not(portable_atomic_no_outline_atomics))] -#[cfg(any(target_arch = "aarch64", target_arch = "arm", target_arch = "x86_64"))] +#[cfg(any( + target_arch = "aarch64", + target_arch = "arm", + all(target_arch = "x86_64", not(target_env = "sgx")), +))] macro_rules! fn_alias { ( $(#[$($fn_attr:tt)*])*