From 51bc8bdcd6e819c811a3dfb3e95ff2e84d83237b Mon Sep 17 00:00:00 2001 From: merge-script Date: Wed, 17 Apr 2024 14:00:40 +0100 Subject: [PATCH] Merge bitcoin/bitcoin#29859: build: Fix false positive `CHECK_ATOMIC` test dd3e0fa12534c9e782dc9c24d2e30b70a0d73176 build: Fix false positive `CHECK_ATOMIC` test for clang-15 (Hennadii Stepanov) Pull request description: On the master branch @ 0de63b8b46eff5cda85b4950062703324ba65a80, a building `bitcoind` with clang-15 for `i686-pc-linux-gnu` fails to link: ``` CXXLD bitcoind /usr/bin/ld: libbitcoin_wallet.a(libbitcoin_wallet_a-wallet.o): in function `std::remove_volatile::type std::__atomic_impl::load(double const*, std::memory_order)': /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/atomic_base.h:948: undefined reference to `__atomic_load' /usr/bin/ld: libbitcoin_wallet.a(libbitcoin_wallet_a-wallet.o): in function `void std::__atomic_impl::store(double*, std::remove_volatile::type, std::memory_order)': /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/atomic_base.h:940: undefined reference to `__atomic_store' /usr/bin/ld: libbitcoin_wallet.a(libbitcoin_wallet_a-wallet.o): in function `void std::__atomic_impl::store(double*, std::remove_volatile::type, std::memory_order)': /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/atomic_base.h:940: undefined reference to `__atomic_store' /usr/bin/ld: /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/atomic_base.h:940: undefined reference to `__atomic_store' /usr/bin/ld: libbitcoin_wallet.a(libbitcoin_wallet_a-wallet.o): in function `std::remove_volatile::type std::__atomic_impl::load(double const*, std::memory_order)': /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/atomic_base.h:948: undefined reference to `__atomic_load' /usr/bin/ld: libbitcoin_wallet.a(libbitcoin_wallet_a-wallet.o): in function `void std::__atomic_impl::store(double*, std::remove_volatile::type, std::memory_order)': /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/atomic_base.h:940: undefined reference to `__atomic_store' /usr/bin/ld: libbitcoin_wallet.a(libbitcoin_wallet_a-backup.o): in function `void std::__atomic_impl::store(double*, std::remove_volatile::type, std::memory_order)': /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/atomic_base.h:940: undefined reference to `__atomic_store' /usr/bin/ld: /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/atomic_base.h:940: undefined reference to `__atomic_store' /usr/bin/ld: /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/atomic_base.h:940: undefined reference to `__atomic_store' /usr/bin/ld: /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/atomic_base.h:940: undefined reference to `__atomic_store' /usr/bin/ld: libbitcoin_wallet.a(libbitcoin_wallet_a-backup.o):/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/atomic_base.h:940: more undefined references to `__atomic_store' follow clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` due to false positive `CHECK_ATOMIC` test in the `configure` script. This PR fixes this test. ACKs for top commit: maflcko: review ACK dd3e0fa12534c9e782dc9c24d2e30b70a0d73176 fanquake: ACK dd3e0fa12534c9e782dc9c24d2e30b70a0d73176 Tree-SHA512: b60acf8d83fc84cc3280d95028395d341ed9ed2fcf38ae0a101d50aa19cc35540e9763aa36668c4dc1e1bc7e1f33dbda0e662df39c9e414a284ef91d7fc55fba --- build-aux/m4/l_atomic.m4 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build-aux/m4/l_atomic.m4 b/build-aux/m4/l_atomic.m4 index aa00168fce..859ddaabbb 100644 --- a/build-aux/m4/l_atomic.m4 +++ b/build-aux/m4/l_atomic.m4 @@ -7,7 +7,7 @@ dnl warranty. # Clang, when building for 32-bit, # and linking against libstdc++, requires linking with # -latomic if using the C++ atomic library. -# Can be tested with: clang++ test.cpp -m32 +# Can be tested with: clang++ -std=c++20 test.cpp -m32 # # Sourced from http://bugs.debian.org/797228 @@ -27,8 +27,11 @@ m4_define([_CHECK_ATOMIC_testbody], [[ auto t1 = t.load(); t.compare_exchange_strong(t1, 3s); - std::atomic a{}; + std::atomic d{}; + d.store(3.14); + auto d1 = d.load(); + std::atomic a{}; int64_t v = 5; int64_t r = a.fetch_add(v); return static_cast(r);