Merge bitcoin/bitcoin#25599: build: Check for std::atomic::exchange rather than std::atomic_exchange

4de4221ab4b645ff77503c777c9b195a962e9fa1 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 4de4221ab4b645ff77503c777c9b195a962e9fa1
  fanquake:
    ACK 4de4221ab4b645ff77503c777c9b195a962e9fa1

Tree-SHA512: dd8225fc9c6a335601f611700003d0249b9ef941efa502db39306129677929d013048e9221be1d6d7f0ea2d90313d4b87de239f441be21b25bea40a6c19a031e
This commit is contained in:
fanquake 2022-07-18 16:31:44 +01:00 committed by pasta
parent 1204dc0f83
commit b66eebe64d
No known key found for this signature in database
GPG Key ID: E2F3D7916E722D38
2 changed files with 7 additions and 4 deletions

View File

@ -18,7 +18,7 @@ m4_define([_CHECK_ATOMIC_testbody], [[
int main() { int main() {
std::atomic<bool> lock{true}; std::atomic<bool> lock{true};
std::atomic_exchange(&lock, false); lock.exchange(false);
std::atomic<std::chrono::seconds> t{0s}; std::atomic<std::chrono::seconds> t{0s};
t.store(2s); t.store(2s);
@ -34,6 +34,8 @@ m4_define([_CHECK_ATOMIC_testbody], [[
AC_DEFUN([CHECK_ATOMIC], [ AC_DEFUN([CHECK_ATOMIC], [
AC_LANG_PUSH(C++) AC_LANG_PUSH(C++)
TEMP_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
AC_MSG_CHECKING([whether std::atomic can be used without link library]) 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 AC_LANG_POP
]) ])

View File

@ -79,9 +79,6 @@ else
AX_CXX_COMPILE_STDCXX([20], [noext], [mandatory]) AX_CXX_COMPILE_STDCXX([20], [noext], [mandatory])
fi fi
dnl Check if -latomic is required for <std::atomic>
CHECK_ATOMIC
dnl check if additional link flags are required for std::filesystem dnl check if additional link flags are required for std::filesystem
CHECK_FILESYSTEM CHECK_FILESYSTEM
@ -896,6 +893,9 @@ AC_C_BIGENDIAN
dnl Check for pthread compile/link requirements dnl Check for pthread compile/link requirements
AX_PTHREAD AX_PTHREAD
dnl Check if -latomic is required for <std::atomic>
CHECK_ATOMIC
dnl The following macro will add the necessary defines to bitcoin-config.h, but dnl The following macro will add the necessary defines to bitcoin-config.h, but
dnl they also need to be passed down to any subprojects. Pull the results out of dnl they also need to be passed down to any subprojects. Pull the results out of
dnl the cache and add them to CPPFLAGS. dnl the cache and add them to CPPFLAGS.