[libcxx] r221966 - Setup llvm-symbolizer when running the tests with sanitizers

Eric Fiselier eric at efcs.ca
Thu Nov 13 18:47:08 PST 2014


Author: ericwf
Date: Thu Nov 13 20:47:08 2014
New Revision: 221966

URL: http://llvm.org/viewvc/llvm-project?rev=221966&view=rev
Log:
Setup llvm-symbolizer when running the tests with sanitizers

Modified:
    libcxx/trunk/test/lit.cfg

Modified: libcxx/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.cfg?rev=221966&r1=221965&r2=221966&view=diff
==============================================================================
--- libcxx/trunk/test/lit.cfg (original)
+++ libcxx/trunk/test/lit.cfg Thu Nov 13 20:47:08 2014
@@ -425,16 +425,30 @@ class Configuration(object):
     def configure_sanitizer(self):
         san = self.get_lit_conf('llvm_use_sanitizer', '').strip()
         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(self.cxx)
+            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)
+            # Setup the sanitizer compile flags
             self.compile_flags += ['-fno-omit-frame-pointer']
             if sys.platform.startswith('linux'):
                 self.link_flags += ['-ldl']
             if san == 'Address':
                 self.compile_flags += ['-fsanitize=address']
+                if llvm_symbolizer is not None:
+                    self.env['ASAN_SYMBOLIZER_PATH'] = llvm_symbolizer
                 self.config.available_features.add('asan')
             elif san == 'Memory' or san == 'MemoryWithOrigins':
                 self.compile_flags += ['-fsanitize=memory']
                 if san == 'MemoryWithOrigins':
                     self.compile_flags += ['-fsanitize-memory-track-origins']
+                if llvm_symbolizer is not None:
+                    self.env['MSAN_SYMBOLIZER_PATH'] = llvm_symbolizer
                 self.config.available_features.add('msan')
             elif san == 'Undefined':
                 self.compile_flags += ['-fsanitize=undefined',





More information about the cfe-commits mailing list