From aa6ea6009fc50b02dbf3788ee9fe605081b154f6 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Tue, 6 Dec 2022 20:47:20 +0300 Subject: [PATCH] Revert "[OpenMP] Use `add_llvm_library` to build the target `PluginInterface` in `plugins-nextgen`" This is still not working for me: ``` -- Configuring done CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.amdgpu" which requires target "elf_common" that is not in any export set. CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.cuda" which requires target "elf_common" that is not in any export set. CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.x86_64" which requires target "elf_common" that is not in any export set. CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.cuda.nextgen" which requires target "elf_common" that is not in any export set. CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.cuda.nextgen" which requires target "PluginInterface" that is not in any export set. CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.x86_64.nextgen" which requires target "elf_common" that is not in any export set. CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.x86_64.nextgen" which requires target "PluginInterface" that is not in any export set. -- Generating done ``` This reverts commit e682a76c3bf61c52628d79d6ec4db221430768c0. --- .../common/PluginInterface/CMakeLists.txt | 45 +++++++------------ .../plugins/common/elf_common/CMakeLists.txt | 28 ++++++------ 2 files changed, 28 insertions(+), 45 deletions(-) diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt index 64ebda2da478..60aeff8796fc 100644 --- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt +++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt @@ -11,39 +11,24 @@ ##===----------------------------------------------------------------------===## # Plugin Interface library. -add_llvm_library(PluginInterface PluginInterface.cpp GlobalHandler.cpp - BUILDTREE_ONLY +add_library(PluginInterface OBJECT PluginInterface.cpp GlobalHandler.cpp) - LINK_COMPONENTS - Support +# Define the TARGET_NAME. +add_definitions("-DTARGET_NAME=PluginInterface") - LINK_LIBS - elf_common -) - -# NOTE: Please don't move `MemoryManager` to `LINK_LIBS` above, even though it -# is an interface "library". Don't expect it to be treated as a "library" such -# that we just need to link it via CMake and its include path will be updated -# automatically. It is because `PluginInterface` is a static library here, and -# per CMake design (which makes sense), privately linked libraries have to be -# exported. However, there is no a typical way in CMake to export an interface -# library without install rules. We apparently don't need `MemoryManager`'s -# header out of the build tree. -target_include_directories(PluginInterface PRIVATE - $ -) - -# 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} -) +# Define the DEBUG_PREFIX. +add_definitions(-DDEBUG_PREFIX="PluginInterface") 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}) diff --git a/openmp/libomptarget/plugins/common/elf_common/CMakeLists.txt b/openmp/libomptarget/plugins/common/elf_common/CMakeLists.txt index 60affae40eae..f6aa809b4616 100644 --- a/openmp/libomptarget/plugins/common/elf_common/CMakeLists.txt +++ b/openmp/libomptarget/plugins/common/elf_common/CMakeLists.txt @@ -10,23 +10,21 @@ # ##===----------------------------------------------------------------------===## -add_llvm_library(elf_common elf_common.cpp ELFSymbols.cpp - BUILDTREE_ONLY - - LINK_COMPONENTS - BinaryFormat - Object - Support - - LINK_LIBS - ${OPENMP_PTHREAD_LIB} -) +add_library(elf_common OBJECT elf_common.cpp ELFSymbols.cpp) # Build elf_common with PIC to be able to link it with plugin shared libraries. set_property(TARGET elf_common PROPERTY POSITION_INDEPENDENT_CODE ON) +llvm_update_compile_flags(elf_common) +set(LINK_LLVM_LIBS LLVMBinaryFormat LLVMObject LLVMSupport) +if (LLVM_LINK_LLVM_DYLIB) + set(LINK_LLVM_LIBS LLVM) +endif() +target_link_libraries(elf_common INTERFACE ${LINK_LLVM_LIBS}) +add_dependencies(elf_common ${LINK_LLVM_LIBS}) + +# The code uses Debug.h, which requires threads support. +target_link_libraries(elf_common INTERFACE ${OPENMP_PTHREAD_LIB}) # Expose elf_common.h directory to the users of this library. -target_include_directories(elf_common - INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${LIBOMPTARGET_INCLUDE_DIR} -) +target_include_directories(elf_common INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(elf_common PRIVATE ${LIBOMPTARGET_INCLUDE_DIR})