[LSAN] Make sure HWASAN tests are linked with lld
authorKirill Stoimenov <kstoimenov@google.com>
Fri, 17 Feb 2023 19:33:20 +0000 (19:33 +0000)
committerKirill Stoimenov <kstoimenov@google.com>
Wed, 22 Feb 2023 19:40:59 +0000 (19:40 +0000)
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D144289

compiler-rt/test/lsan/lit.common.cfg.py

index 92f6f6b..c3df68f 100644 (file)
@@ -34,7 +34,7 @@ elif lsan_lit_test_mode == "AddressSanitizer":
     config.substitutions.insert(0, ('%run', config.netbsd_noaslr_prefix))
 elif lsan_lit_test_mode == "HWAddressSanitizer":
   config.name = "LeakSanitizer-HWAddressSanitizer"
-  lsan_cflags = ["-fsanitize=hwaddress"]
+  lsan_cflags = ["-fsanitize=hwaddress", "-fuse-ld=lld"]
   if target_arch == "x86_64":
     lsan_cflags = lsan_cflags + [ '-fsanitize-hwaddress-experimental-aliasing']
   config.available_features.add('hwasan')
@@ -98,4 +98,9 @@ if not (supported_android or supported_linux or supported_darwin or supported_ne
 if re.search('mthumb', config.target_cflags) is not None:
   config.unsupported = True
 
+# HWASAN tests require lld because without D65857, ld.bfd and ld.gold would
+# generate a corrupted binary. Mark them unsupported if lld is not available.
+if 'hwasan' in config.available_features and not config.has_lld:
+  config.unsupported = True
+
 config.suffixes = ['.c', '.cpp', '.mm']