[Openmp-commits] [openmp] 08c4081 - [OpenMP] Use `add_llvm_library` to build the target `PluginInterface` in `plugins-nextgen`
Shilei Tian via Openmp-commits
openmp-commits at lists.llvm.org
Mon Dec 5 16:46:17 PST 2022
Author: Shilei Tian
Date: 2022-12-05T19:46:12-05:00
New Revision: 08c4081bd3605e1b01a7ccd6accc9052c8966250
URL: https://github.com/llvm/llvm-project/commit/08c4081bd3605e1b01a7ccd6accc9052c8966250
DIFF: https://github.com/llvm/llvm-project/commit/08c4081bd3605e1b01a7ccd6accc9052c8966250.diff
LOG: [OpenMP] Use `add_llvm_library` to build the target `PluginInterface` in `plugins-nextgen`
This patch uses `add_llvm_library` to build the target `PluginInterface` since it can handle LLVM dependences much better. One temporary drawback of using this is that currently LLVM CMake macro doesn't support object libraries very well (there was a try a couple years ago but it was reverted later https://github.com/llvm/llvm-project/commit/29e57229497711a3a294f437b59afa6ddc36a3d8). After switching to that, `CXX_VISIBILITY_PRESET` can not be set correctly, which can cause runtime error that a function call from one plugin could go to another. As a consequence, `PluginInterface` is built as a static library for now. I have asked the question in CMake community (https://discourse.cmake.org/t/set-target-properties-doesnt-work-properly/7016). Once that issue is solved, I'll switch it back to object library. It is not necessarily too bad to use static library, especially `BUILDTREE_ONLY` is already set such that `PluginInterface.a` will not be installed.
Reviewed By: jhuber6
Differential Revision: https://reviews.llvm.org/D139371
Added:
Modified:
openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt
Removed:
################################################################################
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt
index 60aeff8796fc7..3c2230858d6c1 100644
--- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt
+++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt
@@ -11,24 +11,28 @@
##===----------------------------------------------------------------------===##
# Plugin Interface library.
-add_library(PluginInterface OBJECT PluginInterface.cpp GlobalHandler.cpp)
+add_llvm_library(PluginInterface PluginInterface.cpp GlobalHandler.cpp
+ BUILDTREE_ONLY
-# Define the TARGET_NAME.
-add_definitions("-DTARGET_NAME=PluginInterface")
+ LINK_COMPONENTS
+ Support
-# Define the DEBUG_PREFIX.
-add_definitions(-DDEBUG_PREFIX="PluginInterface")
+ LINK_LIBS PRIVATE
+ elf_common
+ MemoryManager
+)
+
+# Define the TARGET_NAME and DEBUG_PREFIX.
+target_compile_definitions(PluginInterface PRIVATE
+ TARGET_NAME="PluginInterface"
+ DEBUG_PREFIX="PluginInterface"
+)
+
+target_include_directories(PluginInterface
+ INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${LIBOMPTARGET_INCLUDE_DIR}
+)
set_target_properties(PluginInterface PROPERTIES
POSITION_INDEPENDENT_CODE ON
CXX_VISIBILITY_PRESET protected)
-llvm_update_compile_flags(PluginInterface)
-set(LINK_LLVM_LIBS LLVMSupport)
-if (LLVM_LINK_LLVM_DYLIB)
- set(LINK_LLVM_LIBS LLVM)
-endif()
-target_link_libraries(PluginInterface INTERFACE ${LINK_LLVM_LIBS} PRIVATE elf_common MemoryManager)
-add_dependencies(PluginInterface ${LINK_LLVM_LIBS})
-
-target_include_directories(PluginInterface INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
-target_include_directories(PluginInterface PRIVATE ${LIBOMPTARGET_INCLUDE_DIR})
More information about the Openmp-commits
mailing list