Changeset 232067 in webkit


Ignore:
Timestamp:
May 22, 2018 8:54:48 AM (6 years ago)
Author:
berto@igalia.com
Message:

[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.

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:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r232062 r232067  
     12018-05-22  Alberto Garcia  <berto@igalia.com>
     2
     3        [CMake] Properly detect compiler flags, needed libs, and fallbacks for usage of 64-bit atomic operations
     4        https://bugs.webkit.org/show_bug.cgi?id=182622
     5        <rdar://problem/40292317>
     6
     7        Reviewed by Michael Catanzaro.
     8
     9        * Source/cmake/WebKitCompilerFlags.cmake:
     10        Move the test to detect whether we need to link against libatomic
     11        to a common CMake file so it can be used from both JavaScriptCore
     12        and WebKit.
     13
    1142018-05-22  Michael Catanzaro  <mcatanzaro@igalia.com>
    215
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r232062 r232067  
    125125endif ()
    126126
    127 # Since r228149, on MIPS we need to link with -latomic, because
    128 # __atomic_fetch_add_8 is not available as a compiler intrinsic. It is
    129 # available on other platforms (including 32-bit Arm), so the link with
    130 # libatomic is only neede on MIPS.
    131 if (WTF_CPU_MIPS)
    132     list(APPEND JavaScriptCore_LIBRARIES
    133         -latomic
    134     )
     127if (ATOMIC_INT64_REQUIRES_LIBATOMIC)
     128    list(APPEND JavaScriptCore_LIBRARIES atomic)
    135129endif ()
    136130
  • trunk/Source/JavaScriptCore/ChangeLog

    r232062 r232067  
     12018-05-22  Alberto Garcia  <berto@igalia.com>
     2
     3        [CMake] Properly detect compiler flags, needed libs, and fallbacks for usage of 64-bit atomic operations
     4        https://bugs.webkit.org/show_bug.cgi?id=182622
     5        <rdar://problem/40292317>
     6
     7        Reviewed by Michael Catanzaro.
     8
     9        We were linking JavaScriptCore against libatomic in MIPS because
     10        in that architecture __atomic_fetch_add_8() is not a compiler
     11        intrinsic and is provided by that library instead. However other
     12        architectures (e.g armel) are in the same situation, so we need a
     13        generic test.
     14
     15        That test already exists in WebKit/CMakeLists.txt, so we just have
     16        to move it to a common file (WebKitCompilerFlags.cmake) and use
     17        its result (ATOMIC_INT64_REQUIRES_LIBATOMIC) here.
     18
     19        * CMakeLists.txt:
     20
    1212018-05-22  Michael Catanzaro  <mcatanzaro@igalia.com>
    222
  • trunk/Source/WebKit/CMakeLists.txt

    r232062 r232067  
    811811endif ()
    812812
    813 if (COMPILER_IS_GCC_OR_CLANG)
    814     set(ATOMIC_TEST_SOURCE
    815     "
    816         #include <atomic>
    817         int main() { std::atomic<int64_t> i(0); i++; return 0; }
    818     "
    819     )
    820     check_cxx_source_compiles("${ATOMIC_TEST_SOURCE}" ATOMIC_INT64_IS_BUILTIN)
    821     if (NOT ATOMIC_INT64_IS_BUILTIN)
    822         set(CMAKE_REQUIRED_LIBRARIES atomic)
    823         check_cxx_source_compiles("${ATOMIC_TEST_SOURCE}" ATOMIC_INT64_REQUIRES_LIBATOMIC)
    824         if (ATOMIC_INT64_REQUIRES_LIBATOMIC)
    825             list(APPEND WebKit_LIBRARIES PRIVATE atomic)
    826         endif ()
    827         unset(CMAKE_REQUIRED_LIBRARIES)
    828     endif ()
     813if (ATOMIC_INT64_REQUIRES_LIBATOMIC)
     814    list(APPEND WebKit_LIBRARIES PRIVATE atomic)
    829815endif ()
    830816
  • trunk/Source/WebKit/ChangeLog

    r232062 r232067  
     12018-05-22  Alberto Garcia  <berto@igalia.com>
     2
     3        [CMake] Properly detect compiler flags, needed libs, and fallbacks for usage of 64-bit atomic operations
     4        https://bugs.webkit.org/show_bug.cgi?id=182622
     5        <rdar://problem/40292317>
     6
     7        Reviewed by Michael Catanzaro.
     8
     9        Move the test to determine whether we need to link against
     10        libatomic to the common file WebKitCompilerFlags.cmake so it can
     11        also be used for JavaScriptCore.
     12
     13        * CMakeLists.txt:
     14
    1152018-05-22  Michael Catanzaro  <mcatanzaro@igalia.com>
    216
  • trunk/Source/cmake/WebKitCompilerFlags.cmake

    r232062 r232067  
    231231   set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} ${SYSTEM_INCLUDE_DIRS})
    232232endif ()
     233
     234if (COMPILER_IS_GCC_OR_CLANG)
     235    set(ATOMIC_TEST_SOURCE "
     236        #include <atomic>
     237        int main() { std::atomic<int64_t> i(0); i++; return 0; }
     238    ")
     239    check_cxx_source_compiles("${ATOMIC_TEST_SOURCE}" ATOMIC_INT64_IS_BUILTIN)
     240    if (NOT ATOMIC_INT64_IS_BUILTIN)
     241        set(CMAKE_REQUIRED_LIBRARIES atomic)
     242        check_cxx_source_compiles("${ATOMIC_TEST_SOURCE}" ATOMIC_INT64_REQUIRES_LIBATOMIC)
     243        unset(CMAKE_REQUIRED_LIBRARIES)
     244    endif ()
     245endif ()
Note: See TracChangeset for help on using the changeset viewer.