[Openmp-commits] [PATCH] D136365: [Libomptarget] Build plugins with protected visibility by default
Joseph Huber via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Thu Oct 20 08:57:40 PDT 2022
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, JonChesterfield, ye-luo, ronlieb, gregrodgers.
Herald added subscribers: kosarev, kerbowa, pengfei, jvesely.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added a project: OpenMP.
Herald added a subscriber: openmp-commits.
The plugins all define the same interface symbols. This is generally not
a problem when calling the plugin directly from the dynamic library's
handle. However, when calling from within the plugin itself it is
possible for another plugin's symbols to preempt the symbols. This was
observed with the `__tgt_rtl_is_valid_binary` call in the
`__tgt_rtl_is_valid_binary_info` function being mapped to the x86_64
plugin.
This patch changes the default visibility to `protected` intead. This
visibility ensures that these symbols are all externally visible from
the plugin, but ensures their definitions are fixed within the shared
library. Having protected visiiblity makes such symbol preemption
impossible.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D136365
Files:
openmp/libomptarget/plugins/CMakeLists.txt
openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
openmp/libomptarget/plugins/cuda/CMakeLists.txt
openmp/libomptarget/plugins/ve/CMakeLists.txt
Index: openmp/libomptarget/plugins/ve/CMakeLists.txt
===================================================================
--- openmp/libomptarget/plugins/ve/CMakeLists.txt
+++ openmp/libomptarget/plugins/ve/CMakeLists.txt
@@ -44,7 +44,8 @@
# 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}/..")
+ INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/.."
+ CXX_VISIBILITY_PRESET protected)
target_include_directories("omptarget.rtl.${tmachine_libname}" PRIVATE
${LIBOMPTARGET_INCLUDE_DIR}
Index: openmp/libomptarget/plugins/cuda/CMakeLists.txt
===================================================================
--- openmp/libomptarget/plugins/cuda/CMakeLists.txt
+++ openmp/libomptarget/plugins/cuda/CMakeLists.txt
@@ -87,7 +87,8 @@
# 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}/..")
+ INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/.."
+ CXX_VISIBILITY_PRESET protected)
target_include_directories(omptarget.rtl.cuda PRIVATE
${LIBOMPTARGET_INCLUDE_DIR}
Index: openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
===================================================================
--- openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
+++ openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
@@ -102,7 +102,8 @@
# 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}/..")
+ INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/.."
+ CXX_VISIBILITY_PRESET protected)
# Report to the parent scope that we are building a plugin for hsa.
# This controls whether tests are run for the nvptx offloading target
Index: openmp/libomptarget/plugins/CMakeLists.txt
===================================================================
--- openmp/libomptarget/plugins/CMakeLists.txt
+++ openmp/libomptarget/plugins/CMakeLists.txt
@@ -52,7 +52,8 @@
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}/..")
+ INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/.."
+ CXX_VISIBILITY_PRESET protected)
target_include_directories( "omptarget.rtl.${tmachine_libname}" PRIVATE
${LIBOMPTARGET_INCLUDE_DIR}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136365.469250.patch
Type: text/x-patch
Size: 3027 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20221020/11d6eb1f/attachment.bin>
More information about the Openmp-commits
mailing list