From b98c6823c72aeb40e8fe3d61bd061234f341db3d Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 8 Jul 2021 17:06:49 +0000 Subject: [PATCH] Fix build on RISC-V (#856) Compiling on RISC-V (without an explicit -latomic) fails with /usr/riscv64-linux-gnu/include/c++/10/ostream:611: undefined reference to __atomic_compare_exchange_1 Use std::atomic::exchange() to detect whether -latomic implements 1-byte compare-and-exchange API used by Squid. Signed-off-by: Heinrich Schuchardt --- configure.ac | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 85018e65a8..3ce45e1f36 100644 --- a/configure.ac +++ b/configure.ac @@ -450,8 +450,11 @@ AC_DEFUN([LIBATOMIC_CHECKER],[ #include #include int - main(int, char **) { - return std::atomic{}.is_lock_free() ? 0 : 1; + main(int argc, char **) { + return ( + std::atomic(uint8_t(argc)).exchange(0) && + std::atomic{}.is_lock_free() + ) ? 0 : 1; } ]])],[ AC_MSG_RESULT(yes) -- 2.47.2