[CMake] Properly detect compiler flags, needed libs, and fallbacks for usage of 64...
authorberto@igalia.com <berto@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2018 15:54:48 +0000 (15:54 +0000)
committerberto@igalia.com <berto@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2018 15:54:48 +0000 (15:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182622
<rdar://problem/40292317>

Reviewed by Michael Catanzaro.

.:

* Source/cmake/WebKitCompilerFlags.cmake:
Move the test to detect whether we need to link against libatomic
to a common CMake file so it can be used from both JavaScriptCore
and WebKit.

Source/JavaScriptCore:

We were linking JavaScriptCore against libatomic in MIPS because
in that architecture __atomic_fetch_add_8() is not a compiler
intrinsic and is provided by that library instead. However other
architectures (e.g armel) are in the same situation, so we need a
generic test.

That test already exists in WebKit/CMakeLists.txt, so we just have
to move it to a common file (WebKitCompilerFlags.cmake) and use
its result (ATOMIC_INT64_REQUIRES_LIBATOMIC) here.

* CMakeLists.txt:

Source/WebKit:

Move the test to determine whether we need to link against
libatomic to the common file WebKitCompilerFlags.cmake so it can
also be used for JavaScriptCore.

* CMakeLists.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232067 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/WebKit/CMakeLists.txt
Source/WebKit/ChangeLog
Source/cmake/WebKitCompilerFlags.cmake

index 665712e..96dbeb3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2018-05-22  Alberto Garcia  <berto@igalia.com>
+
+        [CMake] Properly detect compiler flags, needed libs, and fallbacks for usage of 64-bit atomic operations
+        https://bugs.webkit.org/show_bug.cgi?id=182622
+        <rdar://problem/40292317>
+
+        Reviewed by Michael Catanzaro.
+
+        * Source/cmake/WebKitCompilerFlags.cmake:
+        Move the test to detect whether we need to link against libatomic
+        to a common CMake file so it can be used from both JavaScriptCore
+        and WebKit.
+
 2018-05-22  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Unreviewed, rolling out r231843.
index dd9a6f8..5e56d50 100644 (file)
@@ -124,14 +124,8 @@ if (USE_CAPSTONE)
     list(APPEND JavaScriptCore_LIBRARIES capstone)
 endif ()
 
-# 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
-    )
+if (ATOMIC_INT64_REQUIRES_LIBATOMIC)
+    list(APPEND JavaScriptCore_LIBRARIES atomic)
 endif ()
 
 set(JavaScriptCore_SCRIPTS_SOURCES_DIR "${JAVASCRIPTCORE_DIR}/Scripts")
index b10e565..aca1333 100644 (file)
@@ -1,3 +1,23 @@
+2018-05-22  Alberto Garcia  <berto@igalia.com>
+
+        [CMake] Properly detect compiler flags, needed libs, and fallbacks for usage of 64-bit atomic operations
+        https://bugs.webkit.org/show_bug.cgi?id=182622
+        <rdar://problem/40292317>
+
+        Reviewed by Michael Catanzaro.
+
+        We were linking JavaScriptCore against libatomic in MIPS because
+        in that architecture __atomic_fetch_add_8() is not a compiler
+        intrinsic and is provided by that library instead. However other
+        architectures (e.g armel) are in the same situation, so we need a
+        generic test.
+
+        That test already exists in WebKit/CMakeLists.txt, so we just have
+        to move it to a common file (WebKitCompilerFlags.cmake) and use
+        its result (ATOMIC_INT64_REQUIRES_LIBATOMIC) here.
+
+        * CMakeLists.txt:
+
 2018-05-22  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Unreviewed, rolling out r231843.
index f1d03e4..bd9de34 100644 (file)
@@ -810,22 +810,8 @@ else ()
     set(JavaScriptCore_SCRIPTS_DIR "${FORWARDING_HEADERS_DIR}/JavaScriptCore/Scripts")
 endif ()
 
-if (COMPILER_IS_GCC_OR_CLANG)
-    set(ATOMIC_TEST_SOURCE
-    "
-        #include <atomic>
-        int main() { std::atomic<int64_t> i(0); i++; return 0; }
-    "
-    )
-    check_cxx_source_compiles("${ATOMIC_TEST_SOURCE}" ATOMIC_INT64_IS_BUILTIN)
-    if (NOT ATOMIC_INT64_IS_BUILTIN)
-        set(CMAKE_REQUIRED_LIBRARIES atomic)
-        check_cxx_source_compiles("${ATOMIC_TEST_SOURCE}" ATOMIC_INT64_REQUIRES_LIBATOMIC)
-        if (ATOMIC_INT64_REQUIRES_LIBATOMIC)
-            list(APPEND WebKit_LIBRARIES PRIVATE atomic)
-        endif ()
-        unset(CMAKE_REQUIRED_LIBRARIES)
-    endif ()
+if (ATOMIC_INT64_REQUIRES_LIBATOMIC)
+    list(APPEND WebKit_LIBRARIES PRIVATE atomic)
 endif ()
 
 if (UNIX)
index 0d1c94d..6df8ba4 100644 (file)
@@ -1,3 +1,17 @@
+2018-05-22  Alberto Garcia  <berto@igalia.com>
+
+        [CMake] Properly detect compiler flags, needed libs, and fallbacks for usage of 64-bit atomic operations
+        https://bugs.webkit.org/show_bug.cgi?id=182622
+        <rdar://problem/40292317>
+
+        Reviewed by Michael Catanzaro.
+
+        Move the test to determine whether we need to link against
+        libatomic to the common file WebKitCompilerFlags.cmake so it can
+        also be used for JavaScriptCore.
+
+        * CMakeLists.txt:
+
 2018-05-22  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Unreviewed, rolling out r231843.
index 12b7bc8..5512aa7 100644 (file)
@@ -230,3 +230,16 @@ if (COMPILER_IS_GCC_OR_CLANG)
    DETERMINE_GCC_SYSTEM_INCLUDE_DIRS("c++" "${CMAKE_CXX_COMPILER}" "${CMAKE_CXX_FLAGS}" SYSTEM_INCLUDE_DIRS)
    set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} ${SYSTEM_INCLUDE_DIRS})
 endif ()
+
+if (COMPILER_IS_GCC_OR_CLANG)
+    set(ATOMIC_TEST_SOURCE "
+        #include <atomic>
+        int main() { std::atomic<int64_t> i(0); i++; return 0; }
+    ")
+    check_cxx_source_compiles("${ATOMIC_TEST_SOURCE}" ATOMIC_INT64_IS_BUILTIN)
+    if (NOT ATOMIC_INT64_IS_BUILTIN)
+        set(CMAKE_REQUIRED_LIBRARIES atomic)
+        check_cxx_source_compiles("${ATOMIC_TEST_SOURCE}" ATOMIC_INT64_REQUIRES_LIBATOMIC)
+        unset(CMAKE_REQUIRED_LIBRARIES)
+    endif ()
+endif ()