Skip to content

Commit c6d34c5

Browse files
authored
Merge pull request #436 from Xilinx/philippjh.fix-asan-lit
asan: replace used python in mlir lit.cfg with shim script
2 parents bada367 + cdc7f63 commit c6d34c5

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

mlir/test/lit.cfg.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff 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.
7692
def 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).
179195
if "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.
183200
elif "Windows" in config.host_os:

0 commit comments

Comments
 (0)