[Lldb-commits] [PATCH] D50997: Automatically set path to sanitizer runtime when running tests on macOS.

Adrian Prantl via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 20 14:38:04 PDT 2018


aprantl created this revision.
aprantl added a reviewer: vsk.

Automatically set path to sanitizer runtime when running tests on macOS.

rdar://problem/42984739


https://reviews.llvm.org/D50997

Files:
  lit/Suite/lit.cfg
  lit/Suite/lit.site.cfg.in


Index: lit/Suite/lit.site.cfg.in
===================================================================
--- lit/Suite/lit.site.cfg.in
+++ lit/Suite/lit.site.cfg.in
@@ -9,6 +9,10 @@
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.lldb_obj_root = "@LLDB_BINARY_DIR@"
 config.lldb_src_root = "@LLDB_SOURCE_DIR@"
+config.cmake_cxx_compiler = "@CMAKE_CXX_COMPILER@"
+config.host_os = "@HOST_OS@"
+config.host_triple = "@LLVM_HOST_TRIPLE@"
+config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.dotest_path = "@LLDB_SOURCE_DIR@/test/dotest.py"
Index: lit/Suite/lit.cfg
===================================================================
--- lit/Suite/lit.cfg
+++ lit/Suite/lit.cfg
@@ -19,6 +19,18 @@
                                        'Python', 'lldbsuite', 'test')
 config.test_exec_root = config.test_source_root
 
+# macOS flags needed for LLDB built with address sanitizer.
+if 'Address' in config.llvm_use_sanitizer and \
+   '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', shell=True)
+  runtime = os.path.join(resource_dir[:-1],
+                         'lib/darwin/libclang_rt.asan_osx_dynamic.dylib')
+  config.environment['ASAN_OPTIONS'] =  'detect_stack_use-after_return=1'
+  config.environment['DYLD_INSERT_LIBRARIES'] = runtime
+
 # Build dotest command.
 dotest_cmd = [config.dotest_path, '-q']
 dotest_cmd.extend(config.dotest_args_str.split(';'))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50997.161566.patch
Type: text/x-patch
Size: 1640 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180820/7a221260/attachment.bin>


More information about the lldb-commits mailing list