-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Get the ASAN toolchain working again #7604
Changes from 9 commits
373f0d1
16895e5
aacfa7a
402c5f5
b518dcb
82fb264
5979b7d
7c116e8
c196d81
410cd53
2bb54ed
9797db2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -33,3 +33,16 @@ set(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/env) | |||||||||||
|
||||||||||||
# Can't mix -fsanitize=address with -fsanitize=fuzzer | ||||||||||||
set(WITH_TEST_FUZZ OFF) | ||||||||||||
|
||||||||||||
if (NOT DEFINED Halide_SHARED_ASAN_RUNTIME_LIBRARY) | ||||||||||||
execute_process( | ||||||||||||
COMMAND ${CMAKE_CXX_COMPILER} "-print-file-name=libclang_rt.asan.so" | ||||||||||||
OUTPUT_VARIABLE Halide_SHARED_ASAN_RUNTIME_LIBRARY | ||||||||||||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||||||||||||
) | ||||||||||||
endif () | ||||||||||||
|
||||||||||||
set(Halide_SHARED_ASAN_RUNTIME_LIBRARY "${Halide_SHARED_ASAN_RUNTIME_LIBRARY}" | ||||||||||||
CACHE FILEPATH "Library to preload when running Python tests.") | ||||||||||||
|
||||||||||||
set(Halide_SANITIZER_ENV_VARS "LD_PRELOAD=${Halide_SHARED_ASAN_RUNTIME_LIBRARY}") | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
As described above. |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -62,35 +62,15 @@ endif () | |||||||
# A helper for creating tests with correct PYTHONPATH and sanitizer preloading | ||||||||
## | ||||||||
|
||||||||
if (Halide_ASAN_ENABLED) | ||||||||
if (NOT DEFINED Halide_Python_ASAN_LIBRARY) | ||||||||
# TODO: this assumes clang-on-Linux, we could be smarter here and check | ||||||||
# CMAKE_CXX_COMPILER_ID to behave differently on GNU, AppleClang, or | ||||||||
# MSVC. | ||||||||
execute_process( | ||||||||
COMMAND ${CMAKE_CXX_COMPILER} "-print-file-name=libclang_rt.asan.so" | ||||||||
OUTPUT_VARIABLE Halide_Python_ASAN_LIBRARY | ||||||||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||||||||
) | ||||||||
endif () | ||||||||
|
||||||||
set(Halide_Python_ASAN_LIBRARY "${Halide_Python_ASAN_LIBRARY}" | ||||||||
CACHE FILEPATH "Library to preload when running Python tests.") | ||||||||
endif () | ||||||||
|
||||||||
function(add_python_test) | ||||||||
cmake_parse_arguments(ARG "" "FILE;LABEL" "PYTHONPATH;ENVIRONMENT;TEST_ARGS" ${ARGN}) | ||||||||
|
||||||||
list(PREPEND ARG_PYTHONPATH "$<TARGET_FILE_DIR:Halide::Python>/..") | ||||||||
list(TRANSFORM ARG_PYTHONPATH PREPEND "PYTHONPATH=path_list_prepend:") | ||||||||
|
||||||||
list(PREPEND ARG_ENVIRONMENT "HL_TARGET=${Halide_TARGET}") | ||||||||
if (Halide_Python_ASAN_LIBRARY) | ||||||||
if (APPLE) | ||||||||
list(PREPEND ARG_ENVIRONMENT "DYLD_INSERT_LIBRARIES=${Halide_Python_ASAN_LIBRARY}") | ||||||||
else () | ||||||||
list(PREPEND ARG_ENVIRONMENT "LD_PRELOAD=${Halide_Python_ASAN_LIBRARY}") | ||||||||
endif () | ||||||||
if (Halide_SANITIZER_ENV_VARS) | ||||||||
list(PREPEND ARG_ENVIRONMENT ${Halide_SANITIZER_ENV_VARS}) | ||||||||
endif () | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Then, below (GitHib won't let me comment there 😠), in the call to
with
|
||||||||
|
||||||||
cmake_path(GET ARG_FILE STEM test_name) | ||||||||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -40,6 +40,7 @@ if (WITH_PYTHON_BINDINGS) | |||
|
||||
set_tests_properties(li2018_gradient_autoscheduler_test_py PROPERTIES | ||||
LABELS "li2018;autoschedulers;auto_schedule" | ||||
ENVIRONMENT "${Halide_SANITIZER_ENV_VARS}" | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Same deal with |
||||
ENVIRONMENT_MODIFICATION "${PYTHONPATH}") | ||||
endif() | ||||
endif () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is code is part of our downstream package interface, the
Halide_SHARED_ASAN_RUNTIME_LIBRARY
variable would need to be documented. I think a more flexible design would be to add aHalide_PYTHON_LAUNCHER
variable that works like the familiarCMAKE_CXX_COMPILER_LAUNCHER
variable.To implement that, this code would be:
Then, in our toolchain file, we could set: