20
20
config .test_source_root = os .path .dirname (__file__ )
21
21
config .test_exec_root = config .test_source_root
22
22
23
- if 'Address' in config .llvm_use_sanitizer :
24
- config .environment ['ASAN_OPTIONS' ] = 'detect_stack_use_after_return=1'
25
- # macOS flags needed for LLDB built with address sanitizer.
26
- if 'Darwin' in config .host_os and 'x86' in config .host_triple :
27
- import subprocess
28
- resource_dir = subprocess .check_output (
29
- [config .cmake_cxx_compiler ,
30
- '-print-resource-dir' ]).decode ('utf-8' ).strip ()
31
- runtime = os .path .join (resource_dir , 'lib' , 'darwin' ,
32
- 'libclang_rt.asan_osx_dynamic.dylib' )
33
- config .environment ['DYLD_INSERT_LIBRARIES' ] = runtime
23
+
24
+ def find_sanitizer_runtime (name ):
25
+ import subprocess
26
+ resource_dir = subprocess .check_output (
27
+ [config .cmake_cxx_compiler ,
28
+ '-print-resource-dir' ]).decode ('utf-8' ).strip ()
29
+ return os .path .join (resource_dir , 'lib' , 'darwin' , name )
34
30
35
31
36
32
def find_shlibpath_var ():
@@ -42,6 +38,17 @@ def find_shlibpath_var():
42
38
yield 'PATH'
43
39
44
40
41
+ if 'Address' in config .llvm_use_sanitizer :
42
+ config .environment ['ASAN_OPTIONS' ] = 'detect_stack_use_after_return=1'
43
+ if 'Darwin' in config .host_os and 'x86' in config .host_triple :
44
+ config .environment ['DYLD_INSERT_LIBRARIES' ] = find_sanitizer_runtime (
45
+ 'libclang_rt.asan_osx_dynamic.dylib' )
46
+
47
+ if 'Thread' in config .llvm_use_sanitizer :
48
+ if 'Darwin' in config .host_os and 'x86' in config .host_triple :
49
+ config .environment ['DYLD_INSERT_LIBRARIES' ] = find_sanitizer_runtime (
50
+ 'libclang_rt.tsan_osx_dynamic.dylib' )
51
+
45
52
# Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
46
53
if config .shared_libs :
47
54
for shlibpath_var in find_shlibpath_var ():
0 commit comments