From: Alberto Garcia Date: Wed, 21 Mar 2018 12:31:13 +0000 (+0000) Subject: Detect __sync_add_and_fetch_8() and __atomic_fetch_add_8() X-Git-Tag: archive/raspbian/2.20.0-2+rpi1^2~7 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e68c74d8cdf9eb3b3d6f3ffb718499bb06a1aff5;p=webkit2gtk.git Detect __sync_add_and_fetch_8() and __atomic_fetch_add_8() =================================================================== Gbp-Pq: Name fix-atomics-build.patch --- diff --git a/Source/JavaScriptCore/CMakeLists.txt b/Source/JavaScriptCore/CMakeLists.txt index 94036df921..d3d8c841c1 100644 --- a/Source/JavaScriptCore/CMakeLists.txt +++ b/Source/JavaScriptCore/CMakeLists.txt @@ -116,15 +116,15 @@ set(JavaScriptCore_LIBRARIES ${LLVM_LIBRARIES} ) -# Since r228149, on MIPS we need to link with -latomic, because -# __atomic_fetch_add_8 is not available as a compiler intrinsic. It is -# available on other platforms (including 32-bit Arm), so the link with -# libatomic is only neede on MIPS. -if (WTF_CPU_MIPS) - list(APPEND JavaScriptCore_LIBRARIES - -latomic - ) +file(WRITE ${CMAKE_BINARY_DIR}/test_atomics.cpp + "int main(void)\n" + "{ long long x = 1; return (int) __atomic_fetch_add_8(&x, 1, 1); }\n") +try_compile(ATOMICS_BUILD_SUCCEEDED ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/test_atomics.cpp) +message(STATUS "Found __atomic_fetch_add_8(): ${ATOMICS_BUILD_SUCCEEDED}") +if (NOT ATOMICS_BUILD_SUCCEEDED) + list(APPEND JavaScriptCore_LIBRARIES -latomic) endif () +file(REMOVE ${CMAKE_BINARY_DIR}/test_atomics.cpp) set(JavaScriptCore_SCRIPTS_SOURCES_DIR "${JAVASCRIPTCORE_DIR}/Scripts") diff --git a/Source/WTF/wtf/CMakeLists.txt b/Source/WTF/wtf/CMakeLists.txt index 220bafd348..bc34609fdb 100644 --- a/Source/WTF/wtf/CMakeLists.txt +++ b/Source/WTF/wtf/CMakeLists.txt @@ -315,7 +315,6 @@ set(WTF_HEADERS set(WTF_SOURCES Assertions.cpp - Atomics.cpp AutomaticThread.cpp BitVector.cpp CPUTime.cpp @@ -458,6 +457,16 @@ if (NOT USE_SYSTEM_MALLOC) list(APPEND WTF_LIBRARIES bmalloc) endif () +file(WRITE ${CMAKE_BINARY_DIR}/test_atomics.cpp + "int main(void)\n" + "{ long long x = 1; return (int) __sync_add_and_fetch_8(&x, 1); }\n") +try_compile(ATOMICS_BUILD_SUCCEEDED ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/test_atomics.cpp) +message(STATUS "Found __sync_add_and_fetch_8(): ${ATOMICS_BUILD_SUCCEEDED}") +if (NOT ATOMICS_BUILD_SUCCEEDED) + list(APPEND WTF_SOURCES Atomics.cpp) +endif () +file(REMOVE ${CMAKE_BINARY_DIR}/test_atomics.cpp) + list(APPEND WTF_SOURCES unicode/CollatorDefault.cpp