From 3501ed1fdfc7f34f4c809a7212974078dc217bf3 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Sat, 11 Nov 2017 15:29:42 +0200 Subject: [PATCH] Do not require libatomic on FreeBSD f3e09f36 hooked a dependency on libatomic on 32 bit machines if Clang is used because compilation failed with: `std::__atomic_base::load(std::memory_order) const': /usr/bin/../lib/gcc/i686-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/bits/atomic_base.h:396: undefined reference to `__atomic_load_8' But that does not happen on FreeBSD. The problem is likely that on Linux Clang tries to use GCC-provided C++11 library. Further, __atomic_load_8() (for 8-byte integers) is not readily available on 32 bit machines. From https://gcc.gnu.org/wiki/Atomic/GCCMM: "When lock free instructions are not available (either through hardware or OS support) atomic operations are left as function calls to be resolved by a library." --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 637e9c4e6..75d6a1ecd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -698,7 +698,7 @@ endif() if(ANDROID) set(ATOMIC libatomic.a) endif() -if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND ARCH_WIDTH EQUAL "32" AND NOT IOS) +if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND ARCH_WIDTH EQUAL "32" AND NOT IOS AND NOT FREEBSD) find_library(ATOMIC atomic) list(APPEND EXTRA_LIBRARIES ${ATOMIC}) endif()