Repository navigation
feat: add thread sanitizer build support with tsan-clang-conda preset - #1196
Merged
Merged
Conversation
Added pyarts as a dependency to the check-deps target for convenience.
Add an ENABLE_TSAN option and a tsan-clang-conda preset so ARTS can be built with -fsanitize=thread to find data races. TSAN and ASAN are mutually exclusive, and TSAN requires Clang. The compiler-rt sanitizer runtime name depends on the target architecture, so factor the ASAN lookup into an arts_sanitizer_runtime() function that resolves the right runtime for asan and tsan on macOS and Linux (x86_64, aarch64, armhf). Rename ASAN_PRELOAD_ENV to SANITIZER_PRELOAD_ENV and use it for both sanitizers in the test runner, test properties and Sphinx doc target, so the runtime is preloaded when pyarts is loaded into Python.
Add a "Thread sanitizer" section to the README covering the tsan-clang-conda preset and the per-architecture preload lines for the TSan runtime, and fix the ASAN preload examples to show the aarch64 runtime name alongside x86_64. Add HOWTO-ARCHER.md, which explains why TSan reports false-positive races around OpenMP barriers and how to build Archer from the LLVM OpenMP tree so TSan learns about libomp synchronization without disabling OpenMP. It also includes a prompt for delegating the setup to a coding agent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds first-class thread sanitizer (TSAN) support to the ARTS build system, complementing the existing address sanitizer support. A new
ENABLE_TSANoption andtsan-clang-condapreset instrument the build with-fsanitize=thread, and the sanitizer runtime preloading machinery is generalized so both ASAN and TSAN work for Python-based tests, docs, and manual script execution. Because TSan does not understand OpenMP runtime synchronization, the PR also documents how to use LLVM's Archer OMPT tool to eliminate the resulting false positives.Changes
CMakeLists.txt: Added theENABLE_TSANoption (Clang only, mutually exclusive withENABLE_ASAN), and refactored the compiler-rt sanitizer runtime lookup into a sharedarts_sanitizer_runtimefunction that resolves architecture-specific runtime names (x86_64, aarch64, armhf, macOS) instead of the previous hardcoded x86_64/macOS ASAN pathsCMakeLists.txt: Renamed the ASAN-specificASAN_PRELOAD_ENV/ASAN_PRELOAD_LIBvariables to the sanitizer-genericSANITIZER_PRELOAD_ENV/SANITIZER_PRELOAD_LIB, and updated the configure-time status messages to cover both sanitizersCMakePresets.json: Added thetsan-clang-condapreset, inheriting fromreldeb-clang-condacmake/modules/ArtsTestcases.cmakeandpython/doc/CMakeLists.txt: Propagate the generic sanitizer preload environment to ctest test processes and the Sphinx docs build, so the sanitizer runtime is preloaded when the instrumented pyarts extension is loaded into Pythonpython/CMakeLists.txt:check-depsnow depends on thepyartstarget, ensuring the Python package is up to date before any check target runsHOWTO-ARCHER.md: New guide for building and using Archer (LLVM's OMPT tool) with TSAN, including verification programs, a troubleshooting table, and a prompt for delegating the setup to a coding agentREADME.md: New "Thread sanitizer" section with preset usage and preload instructions, plus the missing aarch64 ASAN preload line