Changeset 231843 in webkit


Ignore:
Timestamp:
May 16, 2018 6:33:50 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

Reviewed by Michael Catanzaro.

.:

  • Source/cmake/OptionsGTK.cmake:
  • Source/cmake/OptionsJSCOnly.cmake:
  • Source/cmake/OptionsWPE.cmake:

Enable THREADS_PREFER_PTHREAD_FLAG. This uses -pthread instead of
-lpthread, fixing the 64-bit RISC-V build of the GTK+ port due to
missing atomic primitives.

  • 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:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r231753 r231843  
     12018-05-16  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
     6        Reviewed by Michael Catanzaro.
     7
     8        * Source/cmake/OptionsGTK.cmake:
     9        * Source/cmake/OptionsJSCOnly.cmake:
     10        * Source/cmake/OptionsWPE.cmake:
     11        Enable THREADS_PREFER_PTHREAD_FLAG. This uses -pthread instead of
     12        -lpthread, fixing the 64-bit RISC-V build of the GTK+ port due to
     13        missing atomic primitives.
     14
     15        * Source/cmake/WebKitCompilerFlags.cmake:
     16        Move the test to detect whether we need to link against libatomic
     17        to a common CMake file so it can be used from both JavaScriptCore
     18        and WebKit.
     19
    1202018-05-14  Zan Dobersek  <zdobersek@igalia.com>
    221
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r231719 r231843  
    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

    r231839 r231843  
     12018-05-16  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
     6        Reviewed by Michael Catanzaro.
     7
     8        We were linking JavaScriptCore against libatomic in MIPS because
     9        in that architecture __atomic_fetch_add_8() is not a compiler
     10        intrinsic and is provided by that library instead. However other
     11        architectures (e.g armel) are in the same situation, so we need a
     12        generic test.
     13
     14        That test already exists in WebKit/CMakeLists.txt, so we just have
     15        to move it to a common file (WebKitCompilerFlags.cmake) and use
     16        its result (ATOMIC_INT64_REQUIRES_LIBATOMIC) here.
     17
     18        * CMakeLists.txt:
     19
    1202018-05-15  Yusuke Suzuki  <utatane.tea@gmail.com>
    221
  • trunk/Source/WebKit/CMakeLists.txt

    r231282 r231843  
    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

    r231839 r231843  
     12018-05-16  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
     6        Reviewed by Michael Catanzaro.
     7
     8        Move the test to determine whether we need to link against
     9        libatomic to the common file WebKitCompilerFlags.cmake so it can
     10        also be used for JavaScriptCore.
     11
     12        * CMakeLists.txt:
     13
    1142018-05-15  Yusuke Suzuki  <utatane.tea@gmail.com>
    215
  • trunk/Source/cmake/OptionsGTK.cmake

    r231553 r231843  
    1717set(INTROSPECTION_INSTALL_GIRDIR "${CMAKE_INSTALL_FULL_DATADIR}/gir-1.0")
    1818set(INTROSPECTION_INSTALL_TYPELIBDIR "${LIB_INSTALL_DIR}/girepository-1.0")
     19
     20set(THREADS_PREFER_PTHREAD_FLAG ON)
    1921
    2022find_package(Cairo 1.10.2 REQUIRED)
  • trunk/Source/cmake/OptionsJSCOnly.cmake

    r231553 r231843  
     1set(THREADS_PREFER_PTHREAD_FLAG ON)
    12find_package(Threads REQUIRED)
    23
  • trunk/Source/cmake/OptionsWPE.cmake

    r231568 r231843  
    1212set(EXEC_INSTALL_DIR "${CMAKE_INSTALL_FULL_BINDIR}" CACHE PATH "Absolute path to executable installation directory")
    1313set(LIBEXEC_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}/wpe-webkit-${WPE_API_VERSION}" CACHE PATH "Absolute path to install executables executed by the library")
     14
     15set(THREADS_PREFER_PTHREAD_FLAG ON)
    1416
    1517WEBKIT_OPTION_BEGIN()
  • trunk/Source/cmake/WebKitCompilerFlags.cmake

    r231753 r231843  
    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.