Skip to content

Commit f002f8a

Browse files
committed
Merge bitcoin/bitcoin#25599: build: Check for std::atomic::exchange rather than std::atomic_exchange
4de4221 build: Check for std::atomic::exchange rather than std::atomic_exchange (Andrew Chow) Pull request description: Our usage of std::atomic is with it's own exchange function, not std::atomic_exchange. So we should be looking specifically for that function. This removes the need for -latomic for riscv builds, which resolves a guix cross architecture reproducibility issue. ACKs for top commit: hebasto: ACK 4de4221 fanquake: ACK 4de4221 Tree-SHA512: dd8225fc9c6a335601f611700003d0249b9ef941efa502db39306129677929d013048e9221be1d6d7f0ea2d90313d4b87de239f441be21b25bea40a6c19a031e
2 parents 821f5c8 + 4de4221 commit f002f8a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

build-aux/m4/l_atomic.m4

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ m4_define([_CHECK_ATOMIC_testbody], [[
1818
1919
int main() {
2020
std::atomic<bool> lock{true};
21-
std::atomic_exchange(&lock, false);
21+
lock.exchange(false);
2222
2323
std::atomic<std::chrono::seconds> t{0s};
2424
t.store(2s);
@@ -34,6 +34,8 @@ m4_define([_CHECK_ATOMIC_testbody], [[
3434
AC_DEFUN([CHECK_ATOMIC], [
3535
3636
AC_LANG_PUSH(C++)
37+
TEMP_CXXFLAGS="$CXXFLAGS"
38+
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
3739
3840
AC_MSG_CHECKING([whether std::atomic can be used without link library])
3941
@@ -51,5 +53,6 @@ AC_DEFUN([CHECK_ATOMIC], [
5153
])
5254
])
5355
56+
CXXFLAGS="$TEMP_CXXFLAGS"
5457
AC_LANG_POP
5558
])

configure.ac

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ else
8787
AX_CXX_COMPILE_STDCXX([20], [noext], [mandatory])
8888
fi
8989

90-
dnl Check if -latomic is required for <std::atomic>
91-
CHECK_ATOMIC
92-
9390
dnl check if additional link flags are required for std::filesystem
9491
CHECK_FILESYSTEM
9592

@@ -887,6 +884,9 @@ AC_C_BIGENDIAN
887884
dnl Check for pthread compile/link requirements
888885
AX_PTHREAD
889886

887+
dnl Check if -latomic is required for <std::atomic>
888+
CHECK_ATOMIC
889+
890890
dnl The following macro will add the necessary defines to bitcoin-config.h, but
891891
dnl they also need to be passed down to any subprojects. Pull the results out of
892892
dnl the cache and add them to CPPFLAGS.

0 commit comments

Comments
 (0)