diff --git a/openmp/libomptarget/plugins/CMakeLists.txt b/openmp/libomptarget/plugins/CMakeLists.txt --- a/openmp/libomptarget/plugins/CMakeLists.txt +++ b/openmp/libomptarget/plugins/CMakeLists.txt @@ -30,26 +30,38 @@ # Define macro with the ELF ID for this target. add_definitions("-DTARGET_ELF_ID=${elf_machine_id}") - add_library("omptarget.rtl.${tmachine_libname}" SHARED - ${CMAKE_CURRENT_SOURCE_DIR}/../generic-elf-64bit/src/rtl.cpp) + add_llvm_library("omptarget.rtl.${tmachine_libname}" + SHARED - # Install plugin under the lib destination folder. - install(TARGETS "omptarget.rtl.${tmachine_libname}" - LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}") + ${CMAKE_CURRENT_SOURCE_DIR}/../generic-elf-64bit/src/rtl.cpp - target_include_directories( "omptarget.rtl.${tmachine_libname}" PRIVATE + ADDITIONAL_HEADER_DIRS ${LIBOMPTARGET_INCLUDE_DIR} ${LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR} - ${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR}) + ${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR} - target_link_libraries( - "omptarget.rtl.${tmachine_libname}" + LINK_LIBS + PRIVATE elf_common ${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES} ${LIBOMPTARGET_DEP_LIBELF_LIBRARIES} dl ${OPENMP_PTHREAD_LIB} - "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports") + "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports" + + NO_INSTALL_RPATH + ) + + # Install plugin under the lib destination folder. + install(TARGETS "omptarget.rtl.${tmachine_libname}" + LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}") + set_target_properties("omptarget.rtl.${tmachine_libname}" PROPERTIES + INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/..") + + target_include_directories( "omptarget.rtl.${tmachine_libname}" PRIVATE + ${LIBOMPTARGET_INCLUDE_DIR} + ${LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR} + ${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR}) list(APPEND LIBOMPTARGET_TESTED_PLUGINS "omptarget.rtl.${tmachine_libname}") diff --git a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt --- a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt +++ b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt @@ -57,23 +57,6 @@ set(LIBOMPTARGET_DEP_LIBRARIES) endif() -add_library(omptarget.rtl.amdgpu SHARED - impl/impl.cpp - impl/interop_hsa.cpp - impl/data.cpp - impl/get_elf_mach_gfx_name.cpp - impl/system.cpp - impl/msgpack.cpp - src/rtl.cpp - ${LIBOMPTARGET_EXTRA_SOURCE} - ) -add_dependencies(omptarget.rtl.amdgpu omptarget.devicertl.amdgpu) - -# Install plugin under the lib destination folder. -# When we build for debug, OPENMP_LIBDIR_SUFFIX get set to -debug -install(TARGETS omptarget.rtl.amdgpu LIBRARY DESTINATION "lib${OPENMP_LIBDIR_SUFFIX}") -set_property(TARGET omptarget.rtl.amdgpu PROPERTY INSTALL_RPATH_USE_LINK_PATH ON) - if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") # On FreeBSD, the 'environ' symbol is undefined at link time, but resolved by # the dynamic linker at runtime. Therefore, allow the symbol to be undefined @@ -83,15 +66,21 @@ set(LDFLAGS_UNDEFINED "-Wl,-z,defs") endif() -target_include_directories( - omptarget.rtl.amdgpu - PRIVATE +add_llvm_library(omptarget.rtl.amdgpu SHARED + impl/impl.cpp + impl/interop_hsa.cpp + impl/data.cpp + impl/get_elf_mach_gfx_name.cpp + impl/system.cpp + impl/msgpack.cpp + src/rtl.cpp + ${LIBOMPTARGET_EXTRA_SOURCE} + + ADDITIONAL_HEADER_DIRS ${LIBOMPTARGET_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/impl -) -target_link_libraries( - omptarget.rtl.amdgpu + LINK_LIBS PRIVATE elf_common ${LIBOMPTARGET_DEP_LIBRARIES} @@ -100,7 +89,23 @@ ${OPENMP_PTHREAD_LIB} "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports" ${LDFLAGS_UNDEFINED} - ) + + NO_INSTALL_RPATH +) +add_dependencies(omptarget.rtl.amdgpu omptarget.devicertl.amdgpu) + +target_include_directories( + omptarget.rtl.amdgpu + PRIVATE + ${LIBOMPTARGET_INCLUDE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/impl +) + + +# Install plugin under the lib destination folder. +install(TARGETS omptarget.rtl.amdgpu LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}") +set_target_properties(omptarget.rtl.amdgpu PROPERTIES + INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/..") # in case of amdgcn, skip running tests if amdgpu-arch was not built or fails if (NOT TARGET amdgpu-arch) diff --git a/openmp/libomptarget/plugins/cuda/CMakeLists.txt b/openmp/libomptarget/plugins/cuda/CMakeLists.txt --- a/openmp/libomptarget/plugins/cuda/CMakeLists.txt +++ b/openmp/libomptarget/plugins/cuda/CMakeLists.txt @@ -40,33 +40,64 @@ if (LIBOMPTARGET_CAN_LINK_LIBCUDA AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA) libomptarget_say("Building CUDA plugin linked against libcuda") include_directories(${LIBOMPTARGET_DEP_CUDA_INCLUDE_DIRS}) - add_library(omptarget.rtl.cuda SHARED src/rtl.cpp) - set (LIBOMPTARGET_DEP_LIBRARIES ${LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES}) + add_llvm_library(omptarget.rtl.cuda SHARED + + src/rtl.cpp + + ADDITIONAL_HEADER_DIRS + ${LIBOMPTARGET_INCLUDE_DIR} + ${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS} + + LINK_LIBS + PRIVATE + elf_common + MemoryManager + ${LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES} + ${LIBOMPTARGET_DEP_LIBELF_LIBRARIES} + ${OPENMP_PTHREAD_LIB} + "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports" + "-Wl,-z,defs" + + NO_INSTALL_RPATH + ) else() libomptarget_say("Building CUDA plugin for dlopened libcuda") include_directories(dynamic_cuda) - add_library(omptarget.rtl.cuda SHARED src/rtl.cpp dynamic_cuda/cuda.cpp) - set (LIBOMPTARGET_DEP_LIBRARIES ${CMAKE_DL_LIBS}) + add_llvm_library(omptarget.rtl.cuda + SHARED + + src/rtl.cpp + dynamic_cuda/cuda.cpp + + ADDITIONAL_HEADER_DIRS + ${LIBOMPTARGET_INCLUDE_DIR} + ${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS} + + LINK_LIBS + PRIVATE + elf_common + MemoryManager + ${CMAKE_DL_LIBS} + ${LIBOMPTARGET_DEP_LIBELF_LIBRARIES} + ${OPENMP_PTHREAD_LIB} + "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports" + "-Wl,-z,defs" + + NO_INSTALL_RPATH + ) endif() add_dependencies(omptarget.rtl.cuda omptarget.devicertl.nvptx) # Install plugin under the lib destination folder. install(TARGETS omptarget.rtl.cuda LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}") +set_target_properties(omptarget.rtl.cuda PROPERTIES + INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/..") target_include_directories(omptarget.rtl.cuda PRIVATE ${LIBOMPTARGET_INCLUDE_DIR} ${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS} ) -target_link_libraries(omptarget.rtl.cuda - elf_common - MemoryManager - ${LIBOMPTARGET_DEP_LIBRARIES} - ${LIBOMPTARGET_DEP_LIBELF_LIBRARIES} - ${OPENMP_PTHREAD_LIB} - "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports" - "-Wl,-z,defs") - # Report to the parent scope that we are building a plugin for CUDA. # This controls whether tests are run for the nvptx offloading target # Run them if libcuda is available, or if the user explicitly asked for dlopen diff --git a/openmp/libomptarget/plugins/ve/CMakeLists.txt b/openmp/libomptarget/plugins/ve/CMakeLists.txt --- a/openmp/libomptarget/plugins/ve/CMakeLists.txt +++ b/openmp/libomptarget/plugins/ve/CMakeLists.txt @@ -23,12 +23,30 @@ # Define macro with the ELF ID for this target. add_definitions("-DTARGET_ELF_ID=${elf_machine_id}") - add_library("omptarget.rtl.${tmachine_libname}" SHARED - ${CMAKE_CURRENT_SOURCE_DIR}/src/rtl.cpp) + add_llvm_library("omptarget.rtl.${tmachine_libname}" + SHARED + ${CMAKE_CURRENT_SOURCE_DIR}/src/rtl.cpp + + ADDITIONAL_HEADER_DIRS + ${LIBOMPTARGET_INCLUDE_DIR} + ${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR} + ${LIBOMPTARGET_DEP_VEO_INCLUDE_DIR} + + LINK_LIBS + PRIVATE + elf_common + ${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES} + ${LIBOMPTARGET_DEP_LIBELF_LIBRARIES} + ${additional_libs} + "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports -Wl,-z,defs" + + NO_INSTALL_RPATH + ) # Install plugin under the lib destination folder. - install(TARGETS "omptarget.rtl.${tmachine_libname}" - LIBRARY DESTINATION lib${OPENMP_LIBDIR_SUFFIX}) + install(TARGETS "omptarget.rtl.${tmachine_libname}" LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}") + set_target_properties("omptarget.rtl.${tmachine_libname}" PROPERTIES + INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/..") target_include_directories("omptarget.rtl.${tmachine_libname}" PRIVATE ${LIBOMPTARGET_INCLUDE_DIR} diff --git a/openmp/libomptarget/src/CMakeLists.txt b/openmp/libomptarget/src/CMakeLists.txt --- a/openmp/libomptarget/src/CMakeLists.txt +++ b/openmp/libomptarget/src/CMakeLists.txt @@ -30,7 +30,8 @@ Support Object - LINK_LIBS + LINK_LIBS + PRIVATE ${CMAKE_DL_LIBS} "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports" NO_INSTALL_RPATH