[libcxxabi] r222496 - Ensure llvm-sanitizer is found by the tests when using sanitizers.

Eric Fiselier eric at efcs.ca
Thu Nov 20 18:16:19 PST 2014


Author: ericwf
Date: Thu Nov 20 20:16:19 2014
New Revision: 222496

URL: http://llvm.org/viewvc/llvm-project?rev=222496&view=rev
Log:
Ensure llvm-sanitizer is found by the tests when using sanitizers.

Modified:
    libcxxabi/trunk/test/lit.cfg

Modified: libcxxabi/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/lit.cfg?rev=222496&r1=222495&r2=222496&view=diff
==============================================================================
--- libcxxabi/trunk/test/lit.cfg (original)
+++ libcxxabi/trunk/test/lit.cfg Thu Nov 20 20:16:19 2014
@@ -203,7 +203,15 @@ llvm_unwinder = getattr(config, 'llvm_un
 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'):





More information about the cfe-commits mailing list