aboutsummaryrefslogtreecommitdiff
path: root/build-aux/m4
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2022-07-11 20:26:25 -0400
committerAndrew Chow <achow101-github@achow101.com>2022-07-18 10:47:19 -0400
commit4de4221ab4b645ff77503c777c9b195a962e9fa1 (patch)
tree405973ab3a4f30807ea877e4e1c4420ca778163f /build-aux/m4
parentc92eb6cda0f402b83263c9a9ee129d5d0763fd3f (diff)
downloadbitcoin-4de4221ab4b645ff77503c777c9b195a962e9fa1.tar.xz
build: Check for std::atomic::exchange rather than std::atomic_exchange
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. Additionally, -pthread and -lpthread have an effect on whether -latomic will be needed, so the atomics check needs to use these flags as well. This will make the flags in use better match what is actually used when linking. This removes the need for -latomic for riscv builds, which resolves a guix cross architecture reproducibility issue.
Diffstat (limited to 'build-aux/m4')
-rw-r--r--build-aux/m4/l_atomic.m45
1 files changed, 4 insertions, 1 deletions
diff --git a/build-aux/m4/l_atomic.m4 b/build-aux/m4/l_atomic.m4
index 40639dfe61..602b57fe43 100644
--- a/build-aux/m4/l_atomic.m4
+++ b/build-aux/m4/l_atomic.m4
@@ -18,7 +18,7 @@ m4_define([_CHECK_ATOMIC_testbody], [[
int main() {
std::atomic<bool> lock{true};
- std::atomic_exchange(&lock, false);
+ lock.exchange(false);
std::atomic<std::chrono::seconds> t{0s};
t.store(2s);
@@ -34,6 +34,8 @@ m4_define([_CHECK_ATOMIC_testbody], [[
AC_DEFUN([CHECK_ATOMIC], [
AC_LANG_PUSH(C++)
+ TEMP_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
AC_MSG_CHECKING([whether std::atomic can be used without link library])
@@ -51,5 +53,6 @@ AC_DEFUN([CHECK_ATOMIC], [
])
])
+ CXXFLAGS="$TEMP_CXXFLAGS"
AC_LANG_POP
])