Hi! On 2025-04-29T21:09:17+0100, Jonathan Wakely <jwak...@redhat.com> wrote: > The GLIBCXX_ENABLE_BACKTRACE macro currently uses the > glibcxx_ac_atomic_int macro defined by the checks that this commit > removes from GLIBCXX_ENABLE_ATOMIC_BUILTINS. That wasn't a good check > anyway, because libbacktrace actually depends on atomic loads+stores for > pointers as well as int, and for atomic stores for size_t. This commit > replaces the glibcxx_ac_atomic_int check with a proper test for all the > required atomic operations on all three of int, void* and size_t. This > ensures that the libbacktrace code used for std::stacktrace will either > use native atomics, or implement those loads and stores only in terms of > __sync_bool_compare_and_swap (possibly requiring that to come from > libatomic or elsewhere).
> Tested x86_64-linux, no changes to the c++config.h results. > I need to do more testing on other targets. Hmm... ;-P Pushed to trunk branch commit 4589ccbed5cad42296d4d1810b61e8dec0dadf79 "libstdc++: Rewrite atomic builtin checks: Fix up 'GLIBCXX_ENABLE_BACKTRACE' check with 'size_t' [PR119667]", see attached. Grüße Thomas
>From 4589ccbed5cad42296d4d1810b61e8dec0dadf79 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tschwi...@baylibre.com> Date: Mon, 12 May 2025 10:35:11 +0200 Subject: [PATCH] libstdc++: Rewrite atomic builtin checks: Fix up 'GLIBCXX_ENABLE_BACKTRACE' check with 'size_t' [PR119667] Fix-up for commit 86627faec10da53d7532805019e5296fcf15ac09 "libstdc++: Rewrite atomic builtin checks [PR70560]", which, for example, for x86_64-pc-linux-gnu lost '-DHAVE_ATOMIC_FUNCTIONS=1' from 'BACKTRACE_CPPFLAGS' due to: configure:53554: checking for atomic builtins for libbacktrace configure:53587: [...]/./gcc/xgcc -shared-libgcc -B[...]/./gcc -nostdinc++ -L[...]/x86_64-pc-linux-gnu/libstdc++-v3/src -L[...]/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L[...]/x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -B/x86_64-pc-linux-gnu/bin/ -B/x86_64-pc-linux-gnu/lib/ -isystem /x86_64-pc-linux-gnu/include -isystem /x86_64-pc-linux-gnu/sys-include -o conftest -O0 conftest.cpp >&5 conftest.cpp: In function 'int main()': conftest.cpp:265:13: error: 'size_t' was not declared in this scope 265 | size_t s = 0; | ^~~~~~ conftest.cpp:1:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 1 | /* confdefs.h */ conftest.cpp:273:31: error: 's' was not declared in this scope 273 | __atomic_store_n(&s, s, __ATOMIC_RELEASE); | ^ configure:53587: $? = 1 configure: failed program was: | /* confdefs.h */ [...] | int | main () | { |[...] | size_t s = 0; |[...] | // backtrace_atomic_store_size_t | __atomic_store_n(&s, s, __ATOMIC_RELEASE); |[...] | } configure:53595: result: no PR libstdc++/70560 PR libstdc++/119667 libstdc++-v3/ * acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): Use '__SIZE_TYPE__' instead of 'size_t'. * configure: Regenerate. --- libstdc++-v3/acinclude.m4 | 4 ++-- libstdc++-v3/configure | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 204bed5b27b..d1ecb1ad956 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -5304,7 +5304,7 @@ AC_DEFUN([GLIBCXX_ENABLE_BACKTRACE], [ [AC_TRY_LINK([], [ int i = 0; int* p = &i; - size_t s = 0; + __SIZE_TYPE__ s = 0; // backtrace_atomic_load_pointer void* vp = __atomic_load_n(&p, __ATOMIC_ACQUIRE); // backtrace_atomic_load_int @@ -5331,7 +5331,7 @@ int main() { int i = 0; int* p = &i; - size_t s = 0; + __SIZE_TYPE__ s = 0; // backtrace_atomic_load_pointer void* vp = __atomic_load_n(&p, __ATOMIC_ACQUIRE); // backtrace_atomic_load_int diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 0529ff5708f..d6891e544cf 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -53568,7 +53568,7 @@ main () int i = 0; int* p = &i; - size_t s = 0; + __SIZE_TYPE__ s = 0; // backtrace_atomic_load_pointer void* vp = __atomic_load_n(&p, __ATOMIC_ACQUIRE); // backtrace_atomic_load_int @@ -53607,7 +53607,7 @@ int main() { int i = 0; int* p = &i; - size_t s = 0; + __SIZE_TYPE__ s = 0; // backtrace_atomic_load_pointer void* vp = __atomic_load_n(&p, __ATOMIC_ACQUIRE); // backtrace_atomic_load_int -- 2.34.1