[PATCH] D52597: [XRay] Add LD_LIBRARY_PATH to env variables for Unit Tests

Dean Michael Berris via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 27 03:26:48 PDT 2018


dberris created this revision.
dberris added reviewers: mboerger, eizan.
Herald added subscribers: jfb, mgorny.

This change allows us to use the library path from which the LLVM
libraries are installed, in case the LLVM installation generates shared
libraries.

This should address llvm.org/PR39070.


https://reviews.llvm.org/D52597

Files:
  compiler-rt/lib/xray/tests/CMakeLists.txt
  compiler-rt/test/xray/Unit/lit.site.cfg.in
  compiler-rt/unittests/lit.common.unit.configured.in


Index: compiler-rt/unittests/lit.common.unit.configured.in
===================================================================
--- compiler-rt/unittests/lit.common.unit.configured.in
+++ compiler-rt/unittests/lit.common.unit.configured.in
@@ -10,6 +10,7 @@
 config.llvm_build_mode = "@LLVM_BUILD_MODE@"
 config.host_arch = "@HOST_ARCH@"
 config.host_os = "@HOST_OS@"
+config.llvm_lib_dir = "@LLVM_LIBRARY_DIR@"
 
 # LLVM tools dir and build mode can be passed in lit parameters,
 # so try to apply substitution.
Index: compiler-rt/test/xray/Unit/lit.site.cfg.in
===================================================================
--- compiler-rt/test/xray/Unit/lit.site.cfg.in
+++ compiler-rt/test/xray/Unit/lit.site.cfg.in
@@ -14,3 +14,11 @@
 # Do not patch the XRay unit tests pre-main, and also make the error logging
 # verbose to get a more accurate error logging mechanism.
 config.environment['XRAY_OPTIONS'] = 'patch_premain=false'
+
+# Add the LLVM Library directory to the LD_LIBRARY_PATH to allow tests to look
+# up the shared libraries.
+if 'LD_LIBRARY_PATH' in os.environ:
+  libdirs = os.path.pathsep.join((config.llvm_lib_dir, os.environ['LD_LIBRARY_PATH']))
+  config.environment['LD_LIBRARY_PATH'] = libdirs
+else:
+  config.environment['LD_LIBRARY_PATH'] = config.llvm_lib_dir
Index: compiler-rt/lib/xray/tests/CMakeLists.txt
===================================================================
--- compiler-rt/lib/xray/tests/CMakeLists.txt
+++ compiler-rt/lib/xray/tests/CMakeLists.txt
@@ -52,11 +52,6 @@
   -l${SANITIZER_CXX_ABI_LIBRARY})
 
 if (NOT APPLE)
-  append_list_if(COMPILER_RT_HAS_LIBM -lm XRAY_UNITTEST_LINK_FLAGS)
-  append_list_if(COMPILER_RT_HAS_LIBRT -lrt XRAY_UNITTEST_LINK_FLAGS)
-  append_list_if(COMPILER_RT_HAS_LIBDL -ldl XRAY_UNITTEST_LINK_FLAGS)
-  append_list_if(COMPILER_RT_HAS_LIBPTHREAD -pthread XRAY_UNITTEST_LINK_FLAGS)
-
   # Needed by LLVMSupport.
   append_list_if(
     COMPILER_RT_HAS_TERMINFO
@@ -74,6 +69,11 @@
     # We also add the actual libraries to link as dependencies.
     list(APPEND XRAY_UNITTEST_LINK_FLAGS -lLLVMXRay -lLLVMSupport -lLLVMTestingSupport)
   endif()
+
+  append_list_if(COMPILER_RT_HAS_LIBM -lm XRAY_UNITTEST_LINK_FLAGS)
+  append_list_if(COMPILER_RT_HAS_LIBRT -lrt XRAY_UNITTEST_LINK_FLAGS)
+  append_list_if(COMPILER_RT_HAS_LIBDL -ldl XRAY_UNITTEST_LINK_FLAGS)
+  append_list_if(COMPILER_RT_HAS_LIBPTHREAD -pthread XRAY_UNITTEST_LINK_FLAGS)
 endif()
 
 macro(add_xray_unittest testname)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52597.167266.patch
Type: text/x-patch
Size: 2470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180927/29eec989/attachment.bin>


More information about the llvm-commits mailing list