From 7160e76d54e7bfbad3f2c5e55cb72e51fa7015b8 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 16 Oct 2026 15:43:11 -0400 Subject: [PATCH 1/2] Define __GCC_CONSTRUCTIVE/DESTRUCTIVE_SIZE on macOS [GH #319] --- .../macos-arm/clang/lib/predefined_macros.txt | 2 + .../lib_macos_arm64/predefined_macros.txt | 2 + .../clang/lib/predefined_macros.txt | 2 + .../lib_macos_x86_64/predefined_macros.txt | 2 + .../tests/changes/.GH319.rto/default.1.1.txt | 1 + tests/tests/changes/GH319.sft.cpp | 49 +++++++++++++++++++ 6 files changed, 58 insertions(+) create mode 100644 tests/tests/changes/.GH319.rto/default.1.1.txt create mode 100644 tests/tests/changes/GH319.sft.cpp 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..bf08e56b9e --- /dev/null +++ b/tests/tests/changes/GH319.sft.cpp @@ -0,0 +1,49 @@ +//type:fp +//options_all:--clang --c++17 +//remark:[GH #?] The macOS clang bases define __GCC_CONSTRUCTIVE_SIZE and __GCC_DESTRUCTIVE_SIZE +// 10/15/26 [GH #?] +// +// 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; } From a4e8327c9f1fc796cc3efb4dec30d7008f690a60 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 16 Oct 2026 22:51:47 -0400 Subject: [PATCH 2/2] Fix issue number [] --- tests/tests/changes/GH319.sft.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/tests/changes/GH319.sft.cpp b/tests/tests/changes/GH319.sft.cpp index bf08e56b9e..ea53ca357b 100644 --- a/tests/tests/changes/GH319.sft.cpp +++ b/tests/tests/changes/GH319.sft.cpp @@ -1,7 +1,7 @@ //type:fp //options_all:--clang --c++17 -//remark:[GH #?] The macOS clang bases define __GCC_CONSTRUCTIVE_SIZE and __GCC_DESTRUCTIVE_SIZE -// 10/15/26 [GH #?] +//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