From: Mehdi Amini Date: Sun, 3 Oct 2021 01:24:07 +0000 (+0000) Subject: Fix ASAN execution for the MLIR Python tests X-Git-Tag: upstream/15.0.7~29806 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bce0c6429ee3994a7376ab9e40d40477ef43cb31;p=platform%2Fupstream%2Fllvm.git Fix ASAN execution for the MLIR Python tests First the leak sanitizer has to be disabled, as even an empty script leads to leak detection with Python. Then we need to preload the ASAN runtime, as the main binary (python) won't be linked against it. This will only work on Linux right now. Differential Revision: https://reviews.llvm.org/D111004 --- diff --git a/mlir/test/lit.cfg.py b/mlir/test/lit.cfg.py index f6b8be3..2307192 100644 --- a/mlir/test/lit.cfg.py +++ b/mlir/test/lit.cfg.py @@ -68,7 +68,6 @@ tools = [ # The following tools are optional tools.extend([ - ToolSubst('%PYTHON', config.python_executable, unresolved='ignore'), ToolSubst('toy-ch1', unresolved='ignore'), ToolSubst('toy-ch2', unresolved='ignore'), ToolSubst('toy-ch3', unresolved='ignore'), @@ -80,6 +79,16 @@ tools.extend([ ToolSubst('%vulkan_wrapper_library_dir', config.vulkan_wrapper_library_dir, unresolved='ignore'), ToolSubst('%mlir_integration_test_dir', config.mlir_integration_test_dir, unresolved='ignore'), ]) + +python_executable = config.python_executable +# Python configuration with sanitizer requires some magic preloading. This will only work on clang/linux. +# TODO: detect Darwin/Windows situation (or mark these tests as unsupported on these platforms). +if "asan" in config.available_features and "Linux" in config.host_os: + python_executable = f"LD_PRELOAD=$({config.host_cxx} -print-file-name=libclang_rt.asan-{config.host_arch}.so) {config.python_executable}" +tools.extend([ + ToolSubst('%PYTHON', python_executable, unresolved='ignore'), +]) + llvm_config.add_tool_substitutions(tools, tool_dirs) diff --git a/mlir/test/python/lit.local.cfg b/mlir/test/python/lit.local.cfg index fc4c987..8a98474 100644 --- a/mlir/test/python/lit.local.cfg +++ b/mlir/test/python/lit.local.cfg @@ -1,8 +1,4 @@ -# Disable with sanitizers for now, this require some more setup apparently. -for san in ['asan', 'msan', 'ubsan']: - if (san in config.available_features): - config.unsupported = True - +config.environment['ASAN_OPTIONS'] = 'detect_leaks=0' if not config.enable_bindings_python: config.unsupported = True config.excludes.add('python_test_ops.td')