Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -234,6 +234,7 @@ option(COMPILER_RT_DEBUG "Build runtimes with full debug info" OFF) # COMPILER_RT_DEBUG_PYBOOL is used by lit.common.configured.in. pythonize_bool(COMPILER_RT_DEBUG) +pythonize_bool(COMPILER_RT_STANDALONE_BUILD) option(COMPILER_RT_BUILD_SHARED_ASAN "Build shared version of AddressSanitizer runtime" OFF) Index: test/asan/TestCases/default_blacklist.cc =================================================================== --- test/asan/TestCases/default_blacklist.cc +++ test/asan/TestCases/default_blacklist.cc @@ -1,3 +1,4 @@ // Test that ASan uses the default blacklist from resource directory. // RUN: %clangxx_asan -### %s 2>&1 | FileCheck %s // CHECK: fsanitize-blacklist={{.*}}asan_blacklist.txt +// XFAIL: * Index: test/asan/lit.cfg =================================================================== --- test/asan/lit.cfg +++ test/asan/lit.cfg @@ -31,6 +31,7 @@ # Setup default compiler flags used with -fsanitize=address option. # FIXME: Review the set of required flags and check if it can be reduced. target_cflags = [get_required_attr(config, "target_cflags")] + extra_linkflags +target_cflags += get_required_attr(config, "compiler_rt_cflags") target_cxxflags = config.cxx_mode_flags + target_cflags clang_asan_static_cflags = ["-fsanitize=address", "-mno-omit-leaf-frame-pointer", Index: test/dfsan/lit.cfg =================================================================== --- test/dfsan/lit.cfg +++ test/dfsan/lit.cfg @@ -10,6 +10,7 @@ # Setup default compiler flags used with -fsanitize=dataflow option. clang_dfsan_cflags = ["-fsanitize=dataflow"] +clang_dfsan_cflags += config.compiler_rt_cflags clang_dfsan_cxxflags = config.cxx_mode_flags + clang_dfsan_cflags def build_invocation(compile_flags): Index: test/lit.common.cfg =================================================================== --- test/lit.common.cfg +++ test/lit.common.cfg @@ -26,6 +26,15 @@ else: lit_config.fatal("Unsupported compiler id: %r" % compiler_id) +# Flags for any clang invocation that links a compiler-rt lib. +# If running the standalone build, tell clang where the +# compiler-rt headers and libraries are. +if getattr(config, 'compiler_rt_standalone', False): + config.compiler_rt_cflags = ["-I" + config.compiler_rt_incdir, + "-L" + config.compiler_rt_libdir] +else: + config.compiler_rt_cflags = [] + # Clear some environment variables that might affect Clang. possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS', 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH', Index: test/lit.common.configured.in =================================================================== --- test/lit.common.configured.in +++ test/lit.common.configured.in @@ -21,6 +21,8 @@ set_default("compiler_rt_arch", "@COMPILER_RT_SUPPORTED_ARCH@") set_default("python_executable", "@PYTHON_EXECUTABLE@") set_default("compiler_rt_debug", @COMPILER_RT_DEBUG_PYBOOL@) +set_default("compiler_rt_standalone", @COMPILER_RT_STANDALONE_BUILD_PYBOOL@) +set_default("compiler_rt_incdir", "@COMPILER_RT_OUTPUT_DIR@/include") set_default("compiler_rt_libdir", "@COMPILER_RT_LIBRARY_OUTPUT_DIR@") # LLVM tools dir can be passed in lit parameters, so try to Index: test/lsan/lit.common.cfg =================================================================== --- test/lsan/lit.common.cfg +++ test/lsan/lit.common.cfg @@ -30,6 +30,7 @@ lit_config.fatal("Unknown LSan test mode: %r" % lsan_lit_test_mode) clang_cflags = ["-g", "-O0", "-m64"] +clang_cflags += get_required_attr(config, "compiler_rt_cflags") clang_cxxflags = config.cxx_mode_flags + clang_cflags clang_lsan_cflags = clang_cflags + lsan_cflags clang_lsan_cxxflags = clang_cxxflags + lsan_cflags Index: test/msan/default_blacklist.cc =================================================================== --- test/msan/default_blacklist.cc +++ test/msan/default_blacklist.cc @@ -1,3 +1,4 @@ // Test that MSan uses the default blacklist from resource directory. // RUN: %clangxx_msan -### %s 2>&1 | FileCheck %s // CHECK: fsanitize-blacklist={{.*}}msan_blacklist.txt +// XFAIL: * Index: test/msan/lit.cfg =================================================================== --- test/msan/lit.cfg +++ test/msan/lit.cfg @@ -15,6 +15,7 @@ "-fno-optimize-sibling-calls", "-g", "-m64"] +clang_msan_cflags += config.compiler_rt_cflags clang_msan_cxxflags = config.cxx_mode_flags + clang_msan_cflags def build_invocation(compile_flags): Index: test/profile/lit.cfg =================================================================== --- test/profile/lit.cfg +++ test/profile/lit.cfg @@ -27,10 +27,16 @@ # Test suffixes. config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test'] +# Clang flags. +clang_cflags = config.compiler_rt_cflags + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + # Add clang substitutions. -config.substitutions.append( ("%clang ", config.clang + " ") ) -config.substitutions.append( ("%clang_profgen ", config.clang + " -fprofile-instr-generate ") ) -config.substitutions.append( ("%clang_profuse=", config.clang + " -fprofile-instr-use=") ) +config.substitutions.append( ("%clang ", build_invocation([])) ) +config.substitutions.append( ("%clang_profgen ", build_invocation(clang_cflags) + " -fprofile-instr-generate ") ) +config.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") ) # Profile tests are currently supported on Linux and Darwin only. if config.host_os not in ['Linux', 'Darwin']: Index: test/tsan/lit.cfg =================================================================== --- test/tsan/lit.cfg +++ test/tsan/lit.cfg @@ -30,6 +30,7 @@ "-lpthread", "-ldl", "-m64"] +clang_tsan_cflags += get_required_attr(config, "compiler_rt_cflags") clang_tsan_cxxflags = config.cxx_mode_flags + clang_tsan_cflags def build_invocation(compile_flags): Index: test/ubsan/lit.common.cfg =================================================================== --- test/ubsan/lit.common.cfg +++ test/ubsan/lit.common.cfg @@ -25,6 +25,8 @@ else: lit_config.fatal("Unknown UBSan test mode: %r" % ubsan_lit_test_mode) +clang_ubsan_cflags += get_required_attr(config, "compiler_rt_cflags") + def build_invocation(compile_flags): return " " + " ".join([config.clang] + compile_flags) + " "