diff --git a/bases/cmake-native/macos-arm/clang/lib/predefined_macros.txt b/bases/cmake-native/macos-arm/clang/lib/predefined_macros.txt index 142d5612e8..f7f01571e4 100644 --- a/bases/cmake-native/macos-arm/clang/lib/predefined_macros.txt +++ b/bases/cmake-native/macos-arm/clang/lib/predefined_macros.txt @@ -186,6 +186,8 @@ clang no __GCC_ATOMIC_POINTER_LOCK_FREE 2 clang no __GCC_ATOMIC_SHORT_LOCK_FREE 2 clang no __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 clang no __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 +clang no __GCC_CONSTRUCTIVE_SIZE 64 +clang no __GCC_DESTRUCTIVE_SIZE 256 clang no __GCC_HAVE_DWARF2_CFI_ASM 1 clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 diff --git a/bases/cmake-native/macos-arm/clang/lib_macos_arm64/predefined_macros.txt b/bases/cmake-native/macos-arm/clang/lib_macos_arm64/predefined_macros.txt index 142d5612e8..f7f01571e4 100644 --- a/bases/cmake-native/macos-arm/clang/lib_macos_arm64/predefined_macros.txt +++ b/bases/cmake-native/macos-arm/clang/lib_macos_arm64/predefined_macros.txt @@ -186,6 +186,8 @@ clang no __GCC_ATOMIC_POINTER_LOCK_FREE 2 clang no __GCC_ATOMIC_SHORT_LOCK_FREE 2 clang no __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 clang no __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 +clang no __GCC_CONSTRUCTIVE_SIZE 64 +clang no __GCC_DESTRUCTIVE_SIZE 256 clang no __GCC_HAVE_DWARF2_CFI_ASM 1 clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 diff --git a/bases/cmake-native/macos-x86_64/clang/lib/predefined_macros.txt b/bases/cmake-native/macos-x86_64/clang/lib/predefined_macros.txt index bbdb1e76a2..4fafa38dd4 100644 --- a/bases/cmake-native/macos-x86_64/clang/lib/predefined_macros.txt +++ b/bases/cmake-native/macos-x86_64/clang/lib/predefined_macros.txt @@ -137,6 +137,8 @@ clang no __GCC_ATOMIC_POINTER_LOCK_FREE 2 clang no __GCC_ATOMIC_SHORT_LOCK_FREE 2 clang no __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 clang no __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 +clang no __GCC_CONSTRUCTIVE_SIZE 64 +clang no __GCC_DESTRUCTIVE_SIZE 64 clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1 clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 diff --git a/bases/cmake-native/macos-x86_64/clang/lib_macos_x86_64/predefined_macros.txt b/bases/cmake-native/macos-x86_64/clang/lib_macos_x86_64/predefined_macros.txt index bbdb1e76a2..4fafa38dd4 100644 --- a/bases/cmake-native/macos-x86_64/clang/lib_macos_x86_64/predefined_macros.txt +++ b/bases/cmake-native/macos-x86_64/clang/lib_macos_x86_64/predefined_macros.txt @@ -137,6 +137,8 @@ clang no __GCC_ATOMIC_POINTER_LOCK_FREE 2 clang no __GCC_ATOMIC_SHORT_LOCK_FREE 2 clang no __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 clang no __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 +clang no __GCC_CONSTRUCTIVE_SIZE 64 +clang no __GCC_DESTRUCTIVE_SIZE 64 clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1 clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 diff --git a/tests/tests/changes/.GH319.rto/default.1.1.txt b/tests/tests/changes/.GH319.rto/default.1.1.txt new file mode 100644 index 0000000000..1f9def3e3a --- /dev/null +++ b/tests/tests/changes/.GH319.rto/default.1.1.txt @@ -0,0 +1 @@ +fe_only -DTEST_NUMBER=1 --clang --c++17 Test_name.c diff --git a/tests/tests/changes/GH319.sft.cpp b/tests/tests/changes/GH319.sft.cpp new file mode 100644 index 0000000000..ea53ca357b --- /dev/null +++ b/tests/tests/changes/GH319.sft.cpp @@ -0,0 +1,49 @@ +//type:fp +//options_all:--clang --c++17 +//remark:[GH #319] The macOS clang bases define __GCC_CONSTRUCTIVE_SIZE and __GCC_DESTRUCTIVE_SIZE +// 10/15/26 [GH #319] +// +// Clang 19 and later predefine __GCC_CONSTRUCTIVE_SIZE and +// __GCC_DESTRUCTIVE_SIZE, and libc++ (<__new/interference_size.h>, reached by +// , , , , ...) uses them unconditionally from +// C++17 on to define std::hardware_constructive_interference_size and +// std::hardware_destructive_interference_size. +// +// The values depend on the target (Apple clang 21 gives 64 and 256 for arm64, +// 64 and 64 for x86_64), so the test checks that the macros are defined and +// usable the way libc++ uses them, not their values. + +#if defined(__APPLE__) && defined(__clang__) + +#ifndef __GCC_DESTRUCTIVE_SIZE +#error "__GCC_DESTRUCTIVE_SIZE is not defined" +#endif +#ifndef __GCC_CONSTRUCTIVE_SIZE +#error "__GCC_CONSTRUCTIVE_SIZE is not defined" +#endif + +typedef decltype(sizeof(0)) size_t; + +// As in libc++'s <__new/interference_size.h>. +inline constexpr size_t hardware_destructive_interference_size = + __GCC_DESTRUCTIVE_SIZE; +inline constexpr size_t hardware_constructive_interference_size = + __GCC_CONSTRUCTIVE_SIZE; + +// Both are positive powers of two, and the destructive size (the one that +// avoids false sharing) is not smaller than the constructive one. +static_assert(hardware_constructive_interference_size > 0 && + (hardware_constructive_interference_size & + (hardware_constructive_interference_size - 1)) == 0, + "constructive size is a power of two"); +static_assert(hardware_destructive_interference_size > 0 && + (hardware_destructive_interference_size & + (hardware_destructive_interference_size - 1)) == 0, + "destructive size is a power of two"); +static_assert(hardware_destructive_interference_size >= + hardware_constructive_interference_size, + "destructive size is not smaller than constructive size"); + +#endif + +int main() { return 0; }