Index: compiler-rt/lib/msan/tests/CMakeLists.txt =================================================================== --- compiler-rt/lib/msan/tests/CMakeLists.txt +++ compiler-rt/lib/msan/tests/CMakeLists.txt @@ -114,12 +114,14 @@ endif() get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS) add_compiler_rt_test(MsanUnitTests "Msan-${arch}${kind}-Test" ${arch} - OBJECTS ${MSAN_TEST_OBJECTS} ${MSAN_LIBCXX_SO} + OBJECTS ${MSAN_TEST_OBJECTS} "${MSAN_LIBCXX_SO_DIR}/libc++.so" DEPS ${MSAN_TEST_DEPS} LINK_FLAGS ${MSAN_UNITTEST_LINK_FLAGS} ${TARGET_LINK_FLAGS} + "-L${MSAN_LIBCXX_SO_DIR}" "-Wl,-rpath=${CMAKE_CURRENT_BINARY_DIR}" - "-Wl,-rpath=${LIBCXX_PREFIX}/lib") + "-Wl,-rpath=${MSAN_LIBCXX_SO_DIR}" + "-Wl,-rpath=${LLVM_LIBRARY_OUTPUT_INTDIR}") endmacro() # We should only build MSan unit tests if we can build instrumented libcxx. @@ -131,7 +133,7 @@ DEPS ${MSAN_RUNTIME_LIBRARIES} CFLAGS ${MSAN_LIBCXX_CFLAGS} ${TARGET_CFLAGS} USE_TOOLCHAIN) - set(MSAN_LIBCXX_SO ${LIBCXX_PREFIX}/lib/libc++.so) + set(MSAN_LIBCXX_SO_DIR ${LIBCXX_PREFIX}/lib/) add_msan_tests_for_arch(${arch} "" "") add_msan_tests_for_arch(${arch} "-with-call" Index: compiler-rt/test/msan/Unit/lit.site.cfg.in =================================================================== --- compiler-rt/test/msan/Unit/lit.site.cfg.in +++ compiler-rt/test/msan/Unit/lit.site.cfg.in @@ -11,3 +11,6 @@ # FIXME: Don't use hardcoded path to MSan unit tests. config.test_exec_root = "@COMPILER_RT_BINARY_DIR@/lib/msan/tests" config.test_source_root = config.test_exec_root + +# Clean LD_LIBRARY_PATH to avoid using un-sanitized libc++ versions. +config.environment['LD_LIBRARY_PATH'] = ''