[compiler-rt] dcf11af - [Sanitizer] Disable LSan when testing on iOS simulators

Julian Lettner via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 16 12:38:08 PST 2021


Author: Julian Lettner
Date: 2021-12-16T12:37:45-08:00
New Revision: dcf11af24beff812c18ccd7f714028aedbdfc5e0

URL: https://github.com/llvm/llvm-project/commit/dcf11af24beff812c18ccd7f714028aedbdfc5e0
DIFF: https://github.com/llvm/llvm-project/commit/dcf11af24beff812c18ccd7f714028aedbdfc5e0.diff

LOG: [Sanitizer] Disable LSan when testing on iOS simulators

LSan (`ASAN_OPTIONS=detect_leaks=1`) is supported on macOS, but disabled
by default on Darwin (`SANITIZER_MAC`):
```
COMMON_FLAG(bool, detect_leaks, !SANITIZER_MAC, "Enable memory leak detection.")
```

We enable it here for ASan tests to prevent regressions (per comment).
However, LSan is not supported for the iOS simulator and the tests fail
when it is enabled.

Make this "Is macOS?" check more precise since the current one (`Darwin
&& x86_64`) has two issues:
 * Includes the simulators
 * Excludes macOS on Apple Silicon

This will allow us to (re)enable simulator testing on Green dragon to
give open source better feedback about sanitizer changes:
https://green.lab.llvm.org

rdar://86529234

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

Added: 
    

Modified: 
    compiler-rt/test/asan/lit.cfg.py

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/asan/lit.cfg.py b/compiler-rt/test/asan/lit.cfg.py
index 497c5e5f07069..b437a151e16a9 100644
--- a/compiler-rt/test/asan/lit.cfg.py
+++ b/compiler-rt/test/asan/lit.cfg.py
@@ -59,9 +59,9 @@ def push_dynamic_library_lookup_path(config, new_path):
 # Platform-specific default ASAN_OPTIONS for lit tests.
 default_asan_opts = list(config.default_sanitizer_opts)
 
-# On Darwin, leak checking is not enabled by default. Enable for x86_64
+# On Darwin, leak checking is not enabled by default. Enable on macOS
 # tests to prevent regressions
-if config.host_os == 'Darwin' and config.target_arch == 'x86_64':
+if config.host_os == 'Darwin' and config.apple_platform == 'osx':
   default_asan_opts += ['detect_leaks=1']
 
 default_asan_opts_str = ':'.join(default_asan_opts)
@@ -203,7 +203,7 @@ def build_invocation(compile_flags):
 # Turn on leak detection on 64-bit Linux.
 leak_detection_android = config.android and 'android-thread-properties-api' in config.available_features and (config.target_arch in ['x86_64', 'i386', 'i686', 'aarch64'])
 leak_detection_linux = (config.host_os == 'Linux') and (not config.android) and (config.target_arch in ['x86_64', 'i386', 'riscv64'])
-leak_detection_mac = (config.host_os == 'Darwin') and (config.target_arch == 'x86_64')
+leak_detection_mac = (config.host_os == 'Darwin') and (config.apple_platform == 'osx')
 leak_detection_netbsd = (config.host_os == 'NetBSD') and (config.target_arch in ['x86_64', 'i386'])
 if leak_detection_android or leak_detection_linux or leak_detection_mac or leak_detection_netbsd:
   config.available_features.add('leak-detection')


        


More information about the llvm-commits mailing list