Ensure llvm-sanitizer is found by the tests when using sanitizers.

llvm-svn: 222496
This commit is contained in:
Eric Fiselier 2014-11-21 02:16:19 +00:00
parent 7f013bcd60
commit 5c24658328
1 changed files with 22 additions and 6 deletions

View File

@ -203,7 +203,15 @@ llvm_unwinder = getattr(config, 'llvm_unwinder', None)
if llvm_unwinder is None:
lit_config.fatal("llvm_unwinder must be defined")
# Compiler parameters
include_paths = ['-I' + libcxxabi_src_root + '/include',
'-I' + libcxx_includes]
library_paths = ['-L' + libcxxabi_obj_root + '/lib']
compile_flags = ['-std=c++11']
link_flags = []
exec_env = {}
link_flags_str = lit_config.params.get('link_flags', None)
if link_flags_str is None:
link_flags_str = getattr(config, 'link_flags', None)
@ -228,24 +236,32 @@ if link_flags_str is not None:
link_flags += shlex.split(link_flags_str)
# Configure extra compiler flags.
include_paths = ['-I' + libcxxabi_src_root + '/include',
'-I' + libcxx_includes]
library_paths = ['-L' + libcxxabi_obj_root + '/lib']
compile_flags = ['-std=c++11']
san = lit_config.params.get('llvm_use_sanitizer', None)
if san is None:
san = getattr(config, 'llvm_use_sanitizer', None)
if san:
# Search for llvm-symbolizer along the compiler path first
# and then along the PATH env variable.
symbolizer_search_paths = os.environ.get('PATH', '')
cxx_path = lit.util.which(cxx_under_test)
if cxx_path is not None:
symbolizer_search_paths = os.path.dirname(cxx_path) + \
os.pathsep + symbolizer_search_paths
llvm_symbolizer = lit.util.which('llvm-symbolizer',
symbolizer_search_paths)
compile_flags += ['-g', '-fno-omit-frame-pointer']
if sys.platform.startswith('linux'):
link_flags += ['-ldl']
if san == 'Address':
compile_flags += ['-fsanitize=address']
if llvm_symbolizer is not None:
exec_env['ASAN_SYMBOLIZER_PATH'] = llvm_symbolizer
config.available_features.add('asan')
elif san == 'Memory' or san == 'MemoryWithOrigins':
compile_flags += ['-fsanitize=memory']
if llvm_symbolizer is not None:
exec_env['MSAN_SYMBOLIZER_PATH'] = llvm_symbolizer
config.available_features.add('msan')
if san == 'MemoryWithOrigins':
compile_flags += ['-fsanitize-memory-track-origins']
@ -263,7 +279,7 @@ if san:
# Configure extra linker parameters.
exec_env = {}
if sys.platform == 'darwin':
exec_env['DYLD_LIBRARY_PATH'] = os.path.join(libcxxabi_obj_root, 'lib')
elif sys.platform.startswith('linux'):