File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,22 @@ def find_runtime(name):
7171 return path
7272
7373
74+ # Find path to the ASan runtime required for the Python interpreter.
75+ def find_asan_runtime ():
76+ if not "asan" in config .available_features or not "Linux" in config .host_os :
77+ return ""
78+ # Find the asan rt lib
79+ return (
80+ subprocess .check_output (
81+ [
82+ config .host_cxx .strip (),
83+ f"-print-file-name=libclang_rt.asan-{ config .host_arch } .so" ,
84+ ]
85+ )
86+ .decode ("utf-8" )
87+ .strip ()
88+ )
89+
7490# Searches for a runtime library with the given name and returns a tool
7591# substitution of the same name and the found path.
7692def add_runtime (name ):
@@ -177,7 +193,8 @@ def add_runtime(name):
177193# Python configuration with sanitizer requires some magic preloading. This will only work on clang/linux.
178194# TODO: detect Darwin/Windows situation (or mark these tests as unsupported on these platforms).
179195if "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 } "
196+ _asan_rt = find_asan_runtime ()
197+ python_executable = f"env LD_PRELOAD={ _asan_rt } { config .python_executable } "
181198# On Windows the path to python could contains spaces in which case it needs to be provided in quotes.
182199# This is the equivalent of how %python is setup in llvm/utils/lit/lit/llvm/config.py.
183200elif "Windows" in config .host_os :
You can’t perform that action at this time.
0 commit comments