[Openmp-commits] [openmp] 718e5a9 - [libomptarget] Set runpath on libomptarget, use that to drop LD_LIBRARY_PATH from test runner

Jon Chesterfield via Openmp-commits openmp-commits at lists.llvm.org
Wed Sep 1 10:48:06 PDT 2021


Author: Jon Chesterfield
Date: 2021-09-01T18:47:56+01:00
New Revision: 718e5a9883eb7f21638315db638d7a7615a3f247

URL: https://github.com/llvm/llvm-project/commit/718e5a9883eb7f21638315db638d7a7615a3f247
DIFF: https://github.com/llvm/llvm-project/commit/718e5a9883eb7f21638315db638d7a7615a3f247.diff

LOG: [libomptarget] Set runpath on libomptarget, use that to drop LD_LIBRARY_PATH from test runner

Using rpath instead of LD_LIBRARY_PATH to find libomp.so and
libomptarget.so lets one rerun the already built test executables without
setting environment variables and removes the risk of the test runner picking
up different libraries to the developer debugging the failure.

rpath usually means runpath, which is not transitive, so set runpath on
libomptarget itself so that it can find the plugins located next to it,
spelled $ORIGIN. This provides sufficient functionality to drop D102043

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D109071

Added: 
    

Modified: 
    openmp/libomptarget/src/CMakeLists.txt
    openmp/libomptarget/test/lit.cfg

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/src/CMakeLists.txt b/openmp/libomptarget/src/CMakeLists.txt
index dd3655fafa92a..c1ed7861076b1 100644
--- a/openmp/libomptarget/src/CMakeLists.txt
+++ b/openmp/libomptarget/src/CMakeLists.txt
@@ -30,6 +30,7 @@ include_directories(${LIBOMPTARGET_LLVM_INCLUDE_DIRS})
 
 # Build libomptarget library with libdl dependency.
 add_library(omptarget SHARED ${LIBOMPTARGET_SRC_FILES})
+set_target_properties(omptarget PROPERTIES INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN")
 if (OPENMP_ENABLE_LIBOMPTARGET_PROFILING)
   # Add LLVMSupport dependency if profiling is enabled.
   # Linking with LLVM component libraries also requires

diff  --git a/openmp/libomptarget/test/lit.cfg b/openmp/libomptarget/test/lit.cfg
index 63bb8cec52319..d4f63dd6c6de2 100644
--- a/openmp/libomptarget/test/lit.cfg
+++ b/openmp/libomptarget/test/lit.cfg
@@ -85,11 +85,10 @@ elif config.operating_system == 'Darwin':
     config.test_flags += " -Wl,-rpath," + config.library_dir
     config.test_flags += " -Wl,-rpath," + config.omp_host_rtl_directory
 else: # Unices
-    append_dynamic_library_path('LD_LIBRARY_PATH', config.library_dir, ":")
-    append_dynamic_library_path('LD_LIBRARY_PATH', \
-        config.omp_host_rtl_directory, ":")
+    config.test_flags += " -Wl,-rpath," + config.library_dir
+    config.test_flags += " -Wl,-rpath," + config.omp_host_rtl_directory
     if config.cuda_libdir:
-        append_dynamic_library_path('LD_LIBRARY_PATH', config.cuda_libdir, ":")
+        config.test_flags += " -Wl,-rpath," + config.cuda_libdir
     append_dynamic_library_path('LIBRARY_PATH', config.library_dir, ":")
     append_dynamic_library_path('LIBRARY_PATH', \
         config.omp_host_rtl_directory, ":")


        


More information about the Openmp-commits mailing list