diff --git a/compiler-rt/test/asan/TestCases/Linux/global-overflow-bfd.cpp b/compiler-rt/test/asan/TestCases/Linux/global-overflow-bfd.cpp --- a/compiler-rt/test/asan/TestCases/Linux/global-overflow-bfd.cpp +++ b/compiler-rt/test/asan/TestCases/Linux/global-overflow-bfd.cpp @@ -1,6 +1,6 @@ // Test that gc-sections-friendly instrumentation of globals does not introduce // false negatives with the BFD linker. -// RUN: %clangxx_asan -fuse-ld=bfd -Wl,-gc-sections -ffunction-sections -fdata-sections -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan_fuseld -fuse-ld=bfd -Wl,-gc-sections -ffunction-sections -fdata-sections -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s #include int main(int argc, char **argv) { diff --git a/compiler-rt/test/asan/lit.cfg.py b/compiler-rt/test/asan/lit.cfg.py --- a/compiler-rt/test/asan/lit.cfg.py +++ b/compiler-rt/test/asan/lit.cfg.py @@ -75,6 +75,12 @@ else: extra_link_flags = [] +# If the default linker for clang is LLD, we want to turn off threading since +# these tests will likely run in parallel. Running nCPU instances of LLD, each +# of which in turn runs nCPU threads, can cause failures to spawn threads. +if config.clang_linker == 'lld': + extra_link_flags.append("-Wl,--no-threads") + # 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_link_flags @@ -112,10 +118,18 @@ def build_invocation(compile_flags): return " " + " ".join([config.clang] + compile_flags) + " " +linker_override_cflags = clang_asan_cflags +linker_override_cxxflags = clang_asan_cxxflags +if config.clang_linker == 'lld': + linker_override_cflags.remove("-Wl,--no-threads") + linker_override_cxxflags.remove("-Wl,--no-threads") + config.substitutions.append( ("%clang ", build_invocation(target_cflags)) ) config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) ) config.substitutions.append( ("%clang_asan ", build_invocation(clang_asan_cflags)) ) config.substitutions.append( ("%clangxx_asan ", build_invocation(clang_asan_cxxflags)) ) +config.substitutions.append( ("%clang_asan_fuseld ", build_invocation(linker_override_cflags)) ) +config.substitutions.append( ("%clangxx_asan_fuseld ", build_invocation(linker_override_cxxflags)) ) if config.asan_dynamic: if config.host_os in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']: shared_libasan_path = os.path.join(config.compiler_rt_libdir, "libclang_rt.asan{}.so".format(config.target_suffix)) diff --git a/compiler-rt/test/lit.common.configured.in b/compiler-rt/test/lit.common.configured.in --- a/compiler-rt/test/lit.common.configured.in +++ b/compiler-rt/test/lit.common.configured.in @@ -44,6 +44,7 @@ set_default("have_rpc_xdr_h", @HAVE_RPC_XDR_H@) set_default("gwp_asan", @COMPILER_RT_HAS_GWP_ASAN_PYBOOL@) set_default("expensive_checks", @LLVM_ENABLE_EXPENSIVE_CHECKS_PYBOOL@) +set_default("clang_linker", "@CLANG_DEFAULT_LINKER@") config.available_features.add('target-is-%s' % config.target_arch) if config.enable_per_target_runtime_dir: diff --git a/compiler-rt/test/lsan/lit.common.cfg.py b/compiler-rt/test/lsan/lit.common.cfg.py --- a/compiler-rt/test/lsan/lit.common.cfg.py +++ b/compiler-rt/test/lsan/lit.common.cfg.py @@ -52,7 +52,13 @@ if lit.util.which('strace'): config.available_features.add('strace') -clang_cflags = ["-O0", config.target_cflags] + config.debug_info_flags +# If the default linker for clang is LLD, we want to turn off threading since +# these tests will likely run in parallel. Running nCPU instances of LLD, each +# of which in turn runs nCPU threads, can cause failures to spawn threads. +if config.clang_linker == 'lld': + clang_cflags = ["-O0 -Wl,--no-threads", config.target_cflags] + config.debug_info_flags +else: + clang_cflags = ["-O0", config.target_cflags] + config.debug_info_flags clang_cxxflags = config.cxx_mode_flags + clang_cflags lsan_incdir = config.test_source_root + "/../" clang_lsan_cflags = clang_cflags + lsan_cflags + ["-I%s" % lsan_incdir] diff --git a/compiler-rt/test/msan/lit.cfg.py b/compiler-rt/test/msan/lit.cfg.py --- a/compiler-rt/test/msan/lit.cfg.py +++ b/compiler-rt/test/msan/lit.cfg.py @@ -18,6 +18,13 @@ # Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD. if config.host_os == 'FreeBSD': clang_msan_cflags += ["-lexecinfo", "-fPIC"] + +# If the default linker for clang is LLD, we want to turn off threading since +# these tests will likely run in parallel. Running nCPU instances of LLD, each +# of which in turn runs nCPU threads, can cause failures to spawn threads. +if config.clang_linker == 'lld': + clang_msan_cflags += ["-Wl,--no-threads"] + clang_msan_cxxflags = config.cxx_mode_flags + clang_msan_cflags # Flags for KMSAN invocation. This is C-only, we're not interested in C++. diff --git a/compiler-rt/test/tsan/lit.cfg.py b/compiler-rt/test/tsan/lit.cfg.py --- a/compiler-rt/test/tsan/lit.cfg.py +++ b/compiler-rt/test/tsan/lit.cfg.py @@ -42,6 +42,12 @@ else: extra_cflags = [] +# If the default linker for clang is LLD, we want to turn off threading since +# these tests will likely run in parallel. Running nCPU instances of LLD, each +# of which in turn runs nCPU threads, can cause failures to spawn threads. +if config.clang_linker == 'lld': + extra_cflags.append("-Wl,--no-threads") + tsan_incdir = config.test_source_root + "/../" # Setup default compiler flags used with -fsanitize=thread option. clang_tsan_cflags = (["-fsanitize=thread", diff --git a/compiler-rt/test/ubsan/lit.common.cfg.py b/compiler-rt/test/ubsan/lit.common.cfg.py --- a/compiler-rt/test/ubsan/lit.common.cfg.py +++ b/compiler-rt/test/ubsan/lit.common.cfg.py @@ -55,6 +55,12 @@ def build_invocation(compile_flags): return " " + " ".join([config.clang] + compile_flags) + " " +# If the default linker for clang is LLD, we want to turn off threading since +# these tests will likely run in parallel. Running nCPU instances of LLD, each +# of which in turn runs nCPU threads, can cause failures to spawn threads. +if config.clang_linker == 'lld': + clang_ubsan_cflags.append("-Wl,--no-threads") + target_cflags = [get_required_attr(config, "target_cflags")] clang_ubsan_cflags += target_cflags clang_ubsan_cxxflags = config.cxx_mode_flags + clang_ubsan_cflags