[PATCH] D95727: llvm-shlib: Create object libraries for each component and link against them
Tom Stellard via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 20 11:11:42 PDT 2021
tstellar updated this revision to Diff 381032.
tstellar added a comment.
Fix build failure with polly enabled.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95727/new/
https://reviews.llvm.org/D95727
Files:
llvm/cmake/modules/AddLLVM.cmake
llvm/lib/ExecutionEngine/Interpreter/CMakeLists.txt
llvm/tools/llvm-shlib/CMakeLists.txt
Index: llvm/tools/llvm-shlib/CMakeLists.txt
===================================================================
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -33,6 +33,10 @@
add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
list(REMOVE_DUPLICATES LIB_NAMES)
+
+ # Link against the object libraries instead of static libraries.
+ list(TRANSFORM LIB_NAMES PREPEND "obj.")
+
if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU)
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU")
Index: llvm/lib/ExecutionEngine/Interpreter/CMakeLists.txt
===================================================================
--- llvm/lib/ExecutionEngine/Interpreter/CMakeLists.txt
+++ llvm/lib/ExecutionEngine/Interpreter/CMakeLists.txt
@@ -6,6 +6,10 @@
include_directories( ${FFI_INCLUDE_PATH} )
endif()
+if( LLVM_ENABLE_FFI )
+ set(link_libs ${FFI_LIBRARY_PATH})
+endif()
+
add_llvm_component_library(LLVMInterpreter
Execution.cpp
ExternalFunctions.cpp
@@ -14,13 +18,10 @@
DEPENDS
intrinsics_gen
+ LINK_LIBS PRIVATE ${link_libs}
LINK_COMPONENTS
CodeGen
Core
ExecutionEngine
Support
)
-
-if( LLVM_ENABLE_FFI )
- target_link_libraries( LLVMInterpreter PRIVATE ${FFI_LIBRARY_PATH} )
-endif()
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -515,7 +515,13 @@
add_dependencies(${obj_name} ${link_lib})
endif()
endforeach()
+ target_link_libraries(${obj_name} ${ARG_LINK_LIBS})
endif()
+
+ # Add target include directories from the main target. This makes it
+ # possible to call target_include_directories() with ${name} after
+ # calling llvm_add_library() and still have it apply to the object library.
+ set_target_properties(${obj_name} PROPERTIES INCLUDE_DIRECTORIES "$<TARGET_PROPERTY:${name},INCLUDE_DIRECTORIES>")
endif()
if(ARG_SHARED AND ARG_STATIC)
@@ -779,7 +785,7 @@
"COMPONENT_NAME;ADD_TO_COMPONENT"
""
${ARGN})
- add_llvm_library(${name} COMPONENT_LIB ${ARG_UNPARSED_ARGUMENTS})
+ add_llvm_library(${name} COMPONENT_LIB OBJECT ${ARG_UNPARSED_ARGUMENTS})
string(REGEX REPLACE "^LLVM" "" component_name ${name})
set_property(TARGET ${name} PROPERTY LLVM_COMPONENT_NAME ${component_name})
@@ -1034,8 +1040,11 @@
# Add static plugins to the Extension component
foreach(llvm_extension ${LLVM_STATIC_EXTENSIONS})
- set_property(TARGET LLVMExtensions APPEND PROPERTY LINK_LIBRARIES ${llvm_extension})
- set_property(TARGET LLVMExtensions APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${llvm_extension})
+ # Update the properties for the normal library and the object library.
+ foreach (lib "LLVMExtensions;obj.LLVMExtensions")
+ set_property(TARGET ${lib} APPEND PROPERTY LINK_LIBRARIES ${llvm_extension})
+ set_property(TARGET ${lib} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${llvm_extension})
+ endforeach()
endforeach()
# Eventually generate the extension headers, and store config to a cmake file
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95727.381032.patch
Type: text/x-patch
Size: 3269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211020/c01e8875/attachment.bin>
More information about the llvm-commits
mailing list