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.cfg40
1 files changed, 29 insertions, 11 deletions
diff --git a/test/asan/lit.cfg b/test/asan/lit.cfg
index f24e68037..7f47b43ed 100644
--- a/test/asan/lit.cfg
+++ b/test/asan/lit.cfg
@@ -11,6 +11,11 @@ def get_required_attr(config, attr_name):
"to lit.site.cfg " % attr_name)
return attr_value
+def push_ld_library_path(config, new_path):
+ new_ld_library_path = os.path.pathsep.join(
+ (new_path, config.environment['LD_LIBRARY_PATH']))
+ config.environment['LD_LIBRARY_PATH'] = new_ld_library_path
+
# Setup config name.
config.name = 'AddressSanitizer' + config.name_suffix
@@ -27,12 +32,21 @@ else:
# 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_cxxflags = config.cxx_mode_flags + target_cflags
-clang_asan_cflags = ["-fsanitize=address",
- "-mno-omit-leaf-frame-pointer",
- "-fno-omit-frame-pointer",
- "-fno-optimize-sibling-calls",
- "-g"] + target_cflags
-clang_asan_cxxflags = config.cxx_mode_flags + clang_asan_cflags
+clang_asan_static_cflags = ["-fsanitize=address",
+ "-mno-omit-leaf-frame-pointer",
+ "-fno-omit-frame-pointer",
+ "-fno-optimize-sibling-calls",
+ "-g"] + target_cflags
+clang_asan_static_cxxflags = config.cxx_mode_flags + clang_asan_static_cflags
+
+if config.asan_dynamic:
+ clang_asan_cflags = clang_asan_static_cflags + ['-shared-libasan']
+ clang_asan_cxxflags = clang_asan_static_cxxflags + ['-shared-libasan']
+ 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")
asan_lit_source_dir = get_required_attr(config, "asan_lit_source_dir")
if config.android == "TRUE":
@@ -49,6 +63,10 @@ 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))
+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)) )
# FIXME: De-hardcode this path.
asan_source_dir = os.path.join(
@@ -76,14 +94,14 @@ config.available_features.add("asan-" + config.bits + "-bits")
if config.host_os == 'Linux' and config.bits == '64':
config.environment['ASAN_OPTIONS'] = 'detect_leaks=1'
-# GCC-ASan uses dynamic runtime by default, so we have to set LD_LIBRARY_PATH
-# to pick it up properly.
+# Set LD_LIBRARY_PATH to pick dynamic runtime up properly.
+push_ld_library_path(config, config.compiler_rt_libdir)
+
+# GCC-ASan uses dynamic runtime by default.
if config.compiler_id == 'GNU':
gcc_dir = os.path.dirname(config.clang)
libasan_dir = os.path.join(gcc_dir, "..", "lib" + config.bits)
- new_ld_library_path = os.path.pathsep.join(
- (libasan_dir, config.environment['LD_LIBRARY_PATH']))
- config.environment['LD_LIBRARY_PATH'] = new_ld_library_path
+ push_ld_library_path(config, libasan_dir)
# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']