[Lldb-commits] [lldb] 8d8ec55 - [lldb/Test] Unify DYLD_INSERT_LIBRARIES solution for ASan and TSan

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 11 16:04:54 PDT 2020


Author: Jonas Devlieghere
Date: 2020-06-11T16:04:46-07:00
New Revision: 8d8ec55035bda2cff5ef446cfacec93c67665c52

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

LOG: [lldb/Test] Unify DYLD_INSERT_LIBRARIES solution for ASan and TSan

Add the same fix for loading the sanitizer runtime for TSan as we
currently have for ASan and unify the code with a helper function.

Added: 
    

Modified: 
    lldb/test/API/lit.cfg.py

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index f0cfe69511ac..288d667c18dd 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -20,17 +20,13 @@
 config.test_source_root = os.path.dirname(__file__)
 config.test_exec_root = config.test_source_root
 
-if 'Address' in config.llvm_use_sanitizer:
-  config.environment['ASAN_OPTIONS'] = 'detect_stack_use_after_return=1'
-  # macOS flags needed for LLDB built with address sanitizer.
-  if 'Darwin' in config.host_os and 'x86' in config.host_triple:
-    import subprocess
-    resource_dir = subprocess.check_output(
-        [config.cmake_cxx_compiler,
-         '-print-resource-dir']).decode('utf-8').strip()
-    runtime = os.path.join(resource_dir, 'lib', 'darwin',
-                           'libclang_rt.asan_osx_dynamic.dylib')
-    config.environment['DYLD_INSERT_LIBRARIES'] = runtime
+
+def find_sanitizer_runtime(name):
+  import subprocess
+  resource_dir = subprocess.check_output(
+      [config.cmake_cxx_compiler,
+       '-print-resource-dir']).decode('utf-8').strip()
+  return os.path.join(resource_dir, 'lib', 'darwin', name)
 
 
 def find_shlibpath_var():
@@ -42,6 +38,17 @@ def find_shlibpath_var():
     yield 'PATH'
 
 
+if 'Address' in config.llvm_use_sanitizer:
+  config.environment['ASAN_OPTIONS'] = 'detect_stack_use_after_return=1'
+  if 'Darwin' in config.host_os and 'x86' in config.host_triple:
+    config.environment['DYLD_INSERT_LIBRARIES'] = find_sanitizer_runtime(
+        'libclang_rt.asan_osx_dynamic.dylib')
+
+if 'Thread' in config.llvm_use_sanitizer:
+  if 'Darwin' in config.host_os and 'x86' in config.host_triple:
+    config.environment['DYLD_INSERT_LIBRARIES'] = find_sanitizer_runtime(
+        'libclang_rt.tsan_osx_dynamic.dylib')
+
 # Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
 if config.shared_libs:
   for shlibpath_var in find_shlibpath_var():


        


More information about the lldb-commits mailing list