[PATCH] D38703: [lit] Only enable LSan on darwin when clang supports it

Francis Ricci via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 9 13:07:39 PDT 2017


fjricci created this revision.
Herald added a reviewer: modocache.

LSan on darwin doesn't exist on older versions of clang,
causing non-boostrapped sanitized buildbots to fail


https://reviews.llvm.org/D38703

Files:
  utils/lit/lit/llvm/config.py


Index: utils/lit/lit/llvm/config.py
===================================================================
--- utils/lit/lit/llvm/config.py
+++ utils/lit/lit/llvm/config.py
@@ -80,7 +80,7 @@
 
         if target_triple:
             if re.match(r'^x86_64.*-apple', target_triple):
-                if 'address' in sanitizers:
+                if 'address' in sanitizers and get_clang_has_lsan(config.host_cxx, target_triple):
                     self.with_environment(
                         'ASAN_OPTIONS', 'detect_leaks=1', append_path=True)
             if re.match(r'^x86_64.*-linux', target_triple):
@@ -200,6 +200,21 @@
         # Ensure the result is an ascii string, across Python2.5+ - Python3.
         return clang_dir
 
+    # On macOS, LSan is only supported on clang versions 5 and higher
+    def get_clang_has_lsan(self, clang, triple):
+        if re.match(r'*-linux', triple):
+            return True
+
+        if re.match(r'^x86_64.*-apple', triple):
+            version_string, _ = self.get_process_output([clang, '--version'])
+            version_number = int(re.search( r'version (\number+)\.', version_string).group(1))
+            if re.match(r'^Apple LLVM', version_string):
+                return version_number >= 9
+            else:
+                return version_number >= 5
+
+        return False
+
     def make_itanium_abi_triple(self, triple):
         m = re.match(r'(\w+)-(\w+)-(\w+)', triple)
         if not m:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38703.118260.patch
Type: text/x-patch
Size: 1457 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171009/b65609a2/attachment.bin>


More information about the llvm-commits mailing list