Index: lib/xray/tests/CMakeLists.txt =================================================================== --- lib/xray/tests/CMakeLists.txt +++ 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) Index: test/xray/Unit/lit.site.cfg.in =================================================================== --- test/xray/Unit/lit.site.cfg.in +++ 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: unittests/lit.common.unit.configured.in =================================================================== --- unittests/lit.common.unit.configured.in +++ 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.