[Openmp-commits] [openmp] e87e4cf - [OpenMP] Make `libomptarget` link against `libomp`
Shilei Tian via Openmp-commits
openmp-commits at lists.llvm.org
Sat May 6 20:26:56 PDT 2023
Author: Shilei Tian
Date: 2023-05-06T23:26:51-04:00
New Revision: e87e4cfc12884479ff402e0689f374f155a41abf
URL: https://github.com/llvm/llvm-project/commit/e87e4cfc12884479ff402e0689f374f155a41abf
DIFF: https://github.com/llvm/llvm-project/commit/e87e4cfc12884479ff402e0689f374f155a41abf.diff
LOG: [OpenMP] Make `libomptarget` link against `libomp`
In `libomptarget` we use a couple of functions from `libomp`, but we didn't link
`libomptarget` against `libomp`. That will not work on some platforms such
as macOS. A linker error will be encountered because those symbols are not resolved
at link time when building `libomptarget`. This patch simply makes `libomptarget`
link agains `libomp`, makes it a "user" of `libomp`. I think this will not break
the policies between `libomp` and `libomptarget`.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D149617
Added:
Modified:
openmp/libomptarget/src/CMakeLists.txt
openmp/runtime/src/CMakeLists.txt
Removed:
################################################################################
diff --git a/openmp/libomptarget/src/CMakeLists.txt b/openmp/libomptarget/src/CMakeLists.txt
index 425121c9ef109..bf6c23bd5eb5f 100644
--- a/openmp/libomptarget/src/CMakeLists.txt
+++ b/openmp/libomptarget/src/CMakeLists.txt
@@ -31,6 +31,10 @@ add_llvm_library(omptarget
Support
Object
+ LINK_LIBS
+ PUBLIC
+ omp
+
NO_INSTALL_RPATH
)
target_include_directories(omptarget PRIVATE ${LIBOMPTARGET_INCLUDE_DIR})
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index 73ba1525c3d5e..13aa1fa8d5151 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -354,11 +354,18 @@ if(${MIC})
endif()
add_dependencies(libomp-micro-tests libomp-test-deps)
+# `omp` needs to be exported if in-tree build.
+set(export_to_llvmexports)
+if (NOT OPENMP_STANDALONE_BUILD)
+ get_target_export_arg(omp LLVM export_to_llvmexports)
+ set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS omp)
+endif()
+
# Install rules
# We want to install libomp in ${DESTDIR}/${CMAKE_INSTALL_FULL_LIBDIR}
# We want to install headers in ${DESTDIR}/${CMAKE_INSTALL_FULL_INCLUDEDIR}
if(WIN32)
- install(TARGETS omp RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ install(TARGETS omp ${export_to_llvmexports} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(TARGETS ${LIBOMP_IMP_LIB_TARGET} ARCHIVE DESTINATION "${OPENMP_INSTALL_LIBDIR}")
# Create aliases (regular copies) of the library for backwards compatibility
set(LIBOMP_ALIASES "libiomp5md")
@@ -371,7 +378,7 @@ if(WIN32)
endforeach()
else()
- install(TARGETS omp ${LIBOMP_INSTALL_KIND} DESTINATION "${OPENMP_INSTALL_LIBDIR}")
+ install(TARGETS omp ${export_to_llvmexports} ${LIBOMP_INSTALL_KIND} DESTINATION "${OPENMP_INSTALL_LIBDIR}")
if(${LIBOMP_INSTALL_ALIASES})
# Create aliases (symlinks) of the library for backwards compatibility
More information about the Openmp-commits
mailing list