Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asan: replace used python in mlir lit.cfg with shim script #436

Merged
merged 3 commits into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion mlir/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ def find_runtime(name):
return path


# Find path to the ASan runtime required for the Python interpreter.
def find_asan_runtime():
if not "asan" in config.available_features or not "Linux" in config.host_os:
return ""
# Find the asan rt lib
return (
subprocess.check_output(
[
config.host_cxx.strip(),
f"-print-file-name=libclang_rt.asan-{config.host_arch}.so",
]
)
.decode("utf-8")
.strip()
)

# Searches for a runtime library with the given name and returns a tool
# substitution of the same name and the found path.
def add_runtime(name):
Expand Down Expand Up @@ -177,7 +193,8 @@ def add_runtime(name):
# 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}"
philippjh marked this conversation as resolved.
Show resolved Hide resolved
_asan_rt = find_asan_runtime()
python_executable = f"env LD_PRELOAD={_asan_rt} {config.python_executable}"
# On Windows the path to python could contains spaces in which case it needs to be provided in quotes.
# This is the equivalent of how %python is setup in llvm/utils/lit/lit/llvm/config.py.
elif "Windows" in config.host_os:
Expand Down
Loading