[CMake] Do not use LLVM static libraries for FTL JIT
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Jan 2016 07:34:09 +0000 (07:34 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Jan 2016 07:34:09 +0000 (07:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=151559

Reviewed by Michael Catanzaro.

.:

Also export LLVM_LIBRARIES variable that can be used to prefer
linking to the llvm dynamic libraries.

* Source/cmake/FindLLVM.cmake:

Source/JavaScriptCore:

Allow ports decide whether to prefer linking to llvm static or
dynamic libraries. This patch only changes the behavior of the GTK
port, other ports can change the default behavior by setting
llvmForJSC_LIBRARIES in their platform specific cmake files.

* CMakeLists.txt: Move llvmForJSC library definition after the
WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS, to allow platform specific
files to set their own llvmForJSC_LIBRARIES. When not set, it
defaults to LLVM_STATIC_LIBRARIES. The command to create
WebKitLLVMLibraryToken.h no longer depends on the static
libraries, since we are going to make the build fail anyway when
not found in case of linking to the static libraries. If platform
specific file defined llvmForJSC_INSTALL_DIR llvmForJSC is also
installed to the given destination.
* PlatformGTK.cmake: Set llvmForJSC_LIBRARIES and
llvmForJSC_INSTALL_DIR.

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

ChangeLog
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/PlatformGTK.cmake
Source/cmake/FindLLVM.cmake

index d4e838f..f34121c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2016-01-13  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [CMake] Do not use LLVM static libraries for FTL JIT
+        https://bugs.webkit.org/show_bug.cgi?id=151559
+
+        Reviewed by Michael Catanzaro.
+
+        Also export LLVM_LIBRARIES variable that can be used to prefer
+        linking to the llvm dynamic libraries.
+
+        * Source/cmake/FindLLVM.cmake:
+
 2016-01-13  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [GTK] Add comments above options declarations in OptionsGTK.cmake
index 14d9acd..6d46ff7 100644 (file)
@@ -972,10 +972,6 @@ list(APPEND JavaScriptCore_SOURCES
 
 
 if (ENABLE_FTL_JIT)
-    if (NOT LLVM_STATIC_LIBRARIES)
-        message(FATAL_ERROR "No LLVM libs found, but FTL is enabled. Stopping build.")
-    endif ()
-
     # Configure llvmForJSC.so
     set(llvmForJSC_SOURCES
         llvm/library/LLVMAnchor.cpp
@@ -989,17 +985,9 @@ if (ENABLE_FTL_JIT)
 
     add_custom_command(
         OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/WebKitLLVMLibraryToken.h
-        DEPENDS ${LLVM_STATIC_LIBRARIES}
         COMMAND ${CMAKE_COMMAND} -E touch ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/WebKitLLVMLibraryToken.h
         VERBATIM)
 
-    WEBKIT_WRAP_SOURCELIST(${llvmForJSC_SOURCES})
-    add_library(llvmForJSC SHARED ${llvmForJSC_SOURCES} ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/WebKitLLVMLibraryToken.h)
-    target_link_libraries(llvmForJSC ${LLVM_STATIC_LIBRARIES} ${LLVM_SYSTEM_LIBRARIES})
-    if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
-        ADD_TARGET_PROPERTIES(llvmForJSC LINK_FLAGS "-Wl,--version-script=${JAVASCRIPTCORE_DIR}/llvm/library/libllvmForJSC.version")
-    endif ()
-
     # Added extra items for JavaScriptCore
     list(APPEND JavaScriptCore_SYSTEM_INCLUDE_DIRECTORIES
         ${LLVM_INCLUDE_DIRS}
@@ -1346,6 +1334,25 @@ endif ()
 
 WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
 
+if (ENABLE_FTL_JIT)
+    if (NOT llvmForJSC_LIBRARIES)
+        set(llvmForJSC_LIBRARIES ${LLVM_STATIC_LIBRARIES})
+    endif ()
+    if (NOT llvmForJSC_LIBRARIES)
+        message(FATAL_ERROR "No LLVM libs found, but FTL is enabled. Stopping build.")
+    endif ()
+
+    WEBKIT_WRAP_SOURCELIST(${llvmForJSC_SOURCES})
+    add_library(llvmForJSC SHARED ${llvmForJSC_SOURCES} ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/WebKitLLVMLibraryToken.h)
+    target_link_libraries(llvmForJSC ${llvmForJSC_LIBRARIES} ${LLVM_SYSTEM_LIBRARIES})
+    if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
+        ADD_TARGET_PROPERTIES(llvmForJSC LINK_FLAGS "-Wl,--version-script=${JAVASCRIPTCORE_DIR}/llvm/library/libllvmForJSC.version")
+    endif ()
+    if (llvmForJSC_INSTALL_DIR)
+        install(TARGETS llvmForJSC DESTINATION "${llvmForJSC_INSTALL_DIR}")
+    endif ()
+endif ()
+
 WEBKIT_CREATE_FORWARDING_HEADERS(JavaScriptCore DIRECTORIES ${JavaScriptCore_FORWARDING_HEADERS_DIRECTORIES} FILES ${JavaScriptCore_FORWARDING_HEADERS_FILES})
 
 
index 07e23ca..cd5d37a 100644 (file)
@@ -1,3 +1,27 @@
+2016-01-13  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [CMake] Do not use LLVM static libraries for FTL JIT
+        https://bugs.webkit.org/show_bug.cgi?id=151559
+
+        Reviewed by Michael Catanzaro.
+
+        Allow ports decide whether to prefer linking to llvm static or
+        dynamic libraries. This patch only changes the behavior of the GTK
+        port, other ports can change the default behavior by setting
+        llvmForJSC_LIBRARIES in their platform specific cmake files.
+
+        * CMakeLists.txt: Move llvmForJSC library definition after the
+        WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS, to allow platform specific
+        files to set their own llvmForJSC_LIBRARIES. When not set, it
+        defaults to LLVM_STATIC_LIBRARIES. The command to create
+        WebKitLLVMLibraryToken.h no longer depends on the static
+        libraries, since we are going to make the build fail anyway when
+        not found in case of linking to the static libraries. If platform
+        specific file defined llvmForJSC_INSTALL_DIR llvmForJSC is also
+        installed to the given destination.
+        * PlatformGTK.cmake: Set llvmForJSC_LIBRARIES and
+        llvmForJSC_INSTALL_DIR.
+
 2016-01-13  Saam barati  <sbarati@apple.com>
 
         NativeExecutable should have a name field
index cb22151..2fb7893 100644 (file)
@@ -39,9 +39,8 @@ if (ENABLE_INTROSPECTION)
 endif ()
 
 if (ENABLE_FTL_JIT)
-    install(TARGETS llvmForJSC
-            DESTINATION "${LIB_INSTALL_DIR}/javascriptcoregtk-${WEBKITGTK_API_VERSION}"
-    )
+    set(llvmForJSC_LIBRARIES ${LLVM_LIBRARIES})
+    set(llvmForJSC_INSTALL_DIR "${LIB_INSTALL_DIR}/javascriptcoregtk-${WEBKITGTK_API_VERSION}")
 endif ()
 
 add_definitions(-DSTATICALLY_LINKED_WITH_WTF)
index 31e2055..8a1ac20 100644 (file)
@@ -23,13 +23,27 @@ endforeach ()
 execute_process(COMMAND ${LLVM_CONFIG_EXE} --includedir OUTPUT_VARIABLE LLVM_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE)
 execute_process(COMMAND ${LLVM_CONFIG_EXE} --libfiles OUTPUT_VARIABLE LLVM_STATIC_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE)
 execute_process(COMMAND ${LLVM_CONFIG_EXE} --system-libs OUTPUT_VARIABLE LLVM_SYSTEM_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND ${LLVM_CONFIG_EXE} --libdir OUTPUT_VARIABLE LLVM_LIBS_DIRECTORY OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND ${LLVM_CONFIG_EXE} --libs OUTPUT_VARIABLE LLVM_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND ${LLVM_CONFIG_EXE} --ldflags OUTPUT_VARIABLE LLVM_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+# Depending on how llvm was built, we could have either a global .so file when built using autotools,
+# or multiple .so files for each static library when built using CMake. So, we set the LLVM_LIBS_DIRECTORY
+# variable here accordingly for each case.
+# We need to build the soname manually in any case, since there's currently no way to get it from llvm-config.
+set(LLVM_SONAME "LLVM-${LLVM_VERSION}")
+if (EXISTS "${LLVM_LIBS_DIRECTORY}/lib${LLVM_SONAME}.so")
+    set(LLVM_LIBRARIES "${LLVM_LDFLAGS} -l${LLVM_SONAME}")
+else ()
+    set(LLVM_LIBRARIES "${LLVM_LDFLAGS} ${LLVM_LIBS}")
+endif ()
 
 # convert the list of paths into a cmake list
 separate_arguments(LLVM_STATIC_LIBRARIES)
 
 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(LLVM
-                                  REQUIRED_VARS LLVM_VERSION LLVM_INCLUDE_DIRS LLVM_STATIC_LIBRARIES
+                                  REQUIRED_VARS LLVM_VERSION LLVM_INCLUDE_DIRS LLVM_LIBRARIES LLVM_STATIC_LIBRARIES
                                   VERSION_VAR LLVM_VERSION)
 
-mark_as_advanced(LLVM_VERSION LLVM_INCLUDE_DIRS LLVM_STATIC_LIBRARIES)
+mark_as_advanced(LLVM_VERSION LLVM_INCLUDE_DIRS LLVM_LIBRARIES LLVM_STATIC_LIBRARIES)