File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -177,7 +177,19 @@ def add_runtime(name):
177177# Python configuration with sanitizer requires some magic preloading. This will only work on clang/linux.
178178# TODO: detect Darwin/Windows situation (or mark these tests as unsupported on these platforms).
179179if "asan" in config .available_features and "Linux" in config .host_os :
180- python_executable = f"LD_PRELOAD=$({ config .host_cxx } -print-file-name=libclang_rt.asan-{ config .host_arch } .so) { config .python_executable } "
180+ # Write shim script that preloads the necessary shared object for ASAN tests. Fallback to such script for two reasons:
181+ #
182+ # (1) Provide full support for LLVM's test utils like `not`, which are prepended to the original statement containing the `LD_PRELOAD` env definition.
183+ # Having environment definitions in the middle of a command line is syntactically illegal.
184+ # (2) Mitigate issues with LIT's internal shell that puts single quotes around the environment definition,
185+ # which leads to malformed command lines:
186+ # `LD_PRELOAD=$(/usr/bin/clang++-17' '-print-file-name=libclang_rt.asan-x86_64.so)' python (...)`
187+ with open ("python-asan-shim" , "w" ) as file :
188+ file .write (
189+ f"#!/usr/bin/env bash\n LD_PRELOAD=$({ config .host_cxx } -print-file-name=libclang_rt.asan-{ config .host_arch } .so) { python_executable } $@\n "
190+ )
191+ os .chmod (os .path .abspath ("python-asan-shim" ), 0o700 )
192+ python_executable = os .path .abspath ("python-asan-shim" )
181193# On Windows the path to python could contains spaces in which case it needs to be provided in quotes.
182194# This is the equivalent of how %python is setup in llvm/utils/lit/lit/llvm/config.py.
183195elif "Windows" in config .host_os :
You can’t perform that action at this time.
0 commit comments