Skip to content

feat: add thread sanitizer build support with tsan-clang-conda preset - #1196

Merged
riclarsson merged 3 commits into
atmtools:mainfrom
olemke:add-tsan-preset
Oct 20, 2026
Merged

riclarsson merged 3 commits into
atmtools:mainfrom
olemke:add-tsan-preset

Conversation

@olemke

@olemke olemke commented Oct 16, 2026

Copy link
Copy Markdown
Member

Summary

This PR adds first-class thread sanitizer (TSAN) support to the ARTS build system, complementing the existing address sanitizer support. A new ENABLE_TSAN option and tsan-clang-conda preset 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 the ENABLE_TSAN option (Clang only, mutually exclusive with ENABLE_ASAN), and refactored the compiler-rt sanitizer runtime lookup into a shared arts_sanitizer_runtime function that resolves architecture-specific runtime names (x86_64, aarch64, armhf, macOS) instead of the previous hardcoded x86_64/macOS ASAN paths
  • CMakeLists.txt: Renamed the ASAN-specific ASAN_PRELOAD_ENV/ASAN_PRELOAD_LIB variables to the sanitizer-generic SANITIZER_PRELOAD_ENV/SANITIZER_PRELOAD_LIB, and updated the configure-time status messages to cover both sanitizers
  • CMakePresets.json: Added the tsan-clang-conda preset, inheriting from reldeb-clang-conda
  • cmake/modules/ArtsTestcases.cmake and python/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 Python
  • python/CMakeLists.txt: check-deps now depends on the pyarts target, ensuring the Python package is up to date before any check target runs
  • HOWTO-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 agent
  • README.md: New "Thread sanitizer" section with preset usage and preload instructions, plus the missing aarch64 ASAN preload line

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.
@riclarsson
riclarsson merged commit f10c309 into atmtools:main Oct 20, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants