summaryrefslogtreecommitdiff
path: root/test/asan/lit.cfg
diff options
context:
space:
mode:
Diffstat (limited to 'test/asan/lit.cfg')
-rw-r--r--test/asan/lit.cfg56
1 files changed, 51 insertions, 5 deletions
diff --git a/test/asan/lit.cfg b/test/asan/lit.cfg
index 894c3f859fbdb..1059f393ab34f 100644
--- a/test/asan/lit.cfg
+++ b/test/asan/lit.cfg
@@ -37,6 +37,12 @@ if config.host_os == 'Darwin':
# Also, make sure we do not overwhelm the syslog while testing.
default_asan_opts = 'abort_on_error=0'
default_asan_opts += ':log_to_syslog=0'
+elif config.android:
+ # The same as on Darwin, we default to "abort_on_error=1" which slows down
+ # testing. Also, all existing tests are using "not" instead of "not --crash"
+ # which does not work for abort()-terminated programs.
+ default_asan_opts = 'abort_on_error=0'
+
if default_asan_opts:
config.environment['ASAN_OPTIONS'] = default_asan_opts
default_asan_opts += ':'
@@ -77,14 +83,26 @@ if config.target_arch == 's390x':
clang_asan_static_cflags.append("-mbackchain")
clang_asan_static_cxxflags = config.cxx_mode_flags + clang_asan_static_cflags
+asan_dynamic_flags = []
if config.asan_dynamic:
- clang_asan_cflags = clang_asan_static_cflags + ['-shared-libasan']
- clang_asan_cxxflags = clang_asan_static_cxxflags + ['-shared-libasan']
+ asan_dynamic_flags = ["-shared-libasan"]
+ # On Windows, we need to simulate "clang-cl /MD" on the clang driver side.
+ if platform.system() == 'Windows':
+ asan_dynamic_flags += ["-D_MT", "-D_DLL", "-Wl,-nodefaultlib:libcmt,-defaultlib:msvcrt,-defaultlib:oldnames"]
config.available_features.add("asan-dynamic-runtime")
else:
- clang_asan_cflags = clang_asan_static_cflags
- clang_asan_cxxflags = clang_asan_static_cxxflags
config.available_features.add("asan-static-runtime")
+clang_asan_cflags = clang_asan_static_cflags + asan_dynamic_flags
+clang_asan_cxxflags = clang_asan_static_cxxflags + asan_dynamic_flags
+
+# Add win32-(static|dynamic)-asan features to mark tests as passing or failing
+# in those modes. lit doesn't support logical feature test combinations.
+if platform.system() == 'Windows':
+ if config.asan_dynamic:
+ win_runtime_feature = "win32-dynamic-asan"
+ else:
+ win_runtime_feature = "win32-static-asan"
+ config.available_features.add(win_runtime_feature)
asan_lit_source_dir = get_required_attr(config, "asan_lit_source_dir")
if config.android == "1":
@@ -98,11 +116,16 @@ else:
def build_invocation(compile_flags):
return " " + " ".join([clang_wrapper, config.clang] + compile_flags) + " "
+# Clang driver link 'x86' (i686) architecture to 'i386'.
+target_arch = config.target_arch
+if (target_arch == "i686"):
+ target_arch = "i386"
+
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( ("%shared_libasan", "libclang_rt.asan-%s.so" % config.target_arch))
+config.substitutions.append( ("%shared_libasan", "libclang_rt.asan-%s.so" % target_arch))
if config.asan_dynamic:
config.substitutions.append( ("%clang_asan_static ", build_invocation(clang_asan_static_cflags)) )
config.substitutions.append( ("%clangxx_asan_static ", build_invocation(clang_asan_static_cxxflags)) )
@@ -124,6 +147,14 @@ if platform.system() == 'Windows':
config.substitutions.append( ("%asan_cxx_lib", base_lib % "_cxx") )
config.substitutions.append( ("%asan_dll_thunk", base_lib % "_dll_thunk") )
+if platform.system() == 'Windows':
+ # Don't use -std=c++11 on Windows, as the driver will detect the appropriate
+ # default needed to use with the STL.
+ config.substitutions.append(("%stdcxx11 ", ""))
+else:
+ # Some tests uses C++11 features such as lambdas and need to pass -std=c++11.
+ config.substitutions.append(("%stdcxx11 ", "-std=c++11 "))
+
# FIXME: De-hardcode this path.
asan_source_dir = os.path.join(
get_required_attr(config, "compiler_rt_src_root"), "lib", "asan")
@@ -186,12 +217,27 @@ if config.compiler_id == 'GNU':
libasan_dir = os.path.join(gcc_dir, "..", "lib" + config.bits)
push_dynamic_library_lookup_path(config, libasan_dir)
+# Add the RT libdir to PATH directly so that we can successfully run the gtest
+# binary to list its tests.
+if config.host_os == 'Windows' and config.asan_dynamic:
+ os.environ['PATH'] = os.path.pathsep.join([config.compiler_rt_libdir,
+ os.environ.get('PATH', '')])
+
# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']
if config.host_os == 'Darwin':
config.suffixes.append('.mm')
+if config.host_os == 'Windows':
+ config.substitutions.append(('%fPIC', ''))
+ config.substitutions.append(('%fPIE', ''))
+ config.substitutions.append(('%pie', ''))
+else:
+ config.substitutions.append(('%fPIC', '-fPIC'))
+ config.substitutions.append(('%fPIE', '-fPIE'))
+ config.substitutions.append(('%pie', '-pie'))
+
# Only run the tests on supported OSs.
if config.host_os not in ['Linux', 'Darwin', 'FreeBSD', 'Windows']:
config.unsupported = True