[all-commits] [llvm/llvm-project] ca4403: [Clang] Support `-shared-libsan` for offload CSan
Joseph Huber via All-commits
all-commits at lists.llvm.org
Thu Oct 1 13:00:59 PDT 2026
Branch: refs/heads/users/jhuber6/csan
Home: https://github.com/llvm/llvm-project
Commit: ca440372de005045115ca16278df5aca4ae0bc5a
https://github.com/llvm/llvm-project/commit/ca440372de005045115ca16278df5aca4ae0bc5a
Author: Joseph Huber <huberjn at outlook.com>
Date: 2026-10-01 (Thu, 01 Oct 2026)
Changed paths:
M clang/lib/Driver/ToolChains/CommonArgs.cpp
M clang/test/Driver/fsanitize-concurrency-offload.c
M clang/test/Driver/fsanitize.c
Log Message:
-----------
[Clang] Support `-shared-libsan` for offload CSan
Summary:
Follow the UBSan handling. The shared runtime embeds the HSA
interceptors, so `csan_offload` is only linked with static runtimes and
executables pull in `csan_offload-preinit` to initialize early.
Commit: d332d94921f913acb95142b5bb947cf82453ca64
https://github.com/llvm/llvm-project/commit/d332d94921f913acb95142b5bb947cf82453ca64
Author: Joseph Huber <huberjn at outlook.com>
Date: 2026-10-01 (Thu, 01 Oct 2026)
Changed paths:
M compiler-rt/cmake/caches/AMDGPU.cmake
M compiler-rt/cmake/config-ix.cmake
A compiler-rt/lib/csan/CMakeLists.txt
A compiler-rt/lib/csan/csan.cpp
A compiler-rt/lib/csan/csan.h
A compiler-rt/lib/csan/csan_defs.h
A compiler-rt/lib/csan/csan_flags.inc
A compiler-rt/lib/csan/csan_gpu.cpp
A compiler-rt/lib/csan/csan_offload_packet.h
A compiler-rt/lib/csan/csan_report.cpp
A compiler-rt/lib/csan/csan_watch.h
A compiler-rt/lib/csan/offload/CMakeLists.txt
A compiler-rt/lib/csan/offload/csan_offload.h
A compiler-rt/lib/csan/offload/csan_offload_hsa_interceptors.cpp
A compiler-rt/lib/csan/offload/csan_offload_report.cpp
M compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
M compiler-rt/lib/sanitizer_common/sanitizer_offload.cpp
M compiler-rt/lib/sanitizer_common/sanitizer_offload.h
M compiler-rt/lib/sanitizer_common/sanitizer_offload_hsa.h
M compiler-rt/lib/sanitizer_common/sanitizer_offload_image.cpp
M compiler-rt/lib/sanitizer_common/sanitizer_offload_opcodes.h
M compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
M compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
A compiler-rt/test/csan/AMDGPU/aba-race.hip
A compiler-rt/test/csan/AMDGPU/array-race.hip
A compiler-rt/test/csan/AMDGPU/atomic-nonatomic.hip
A compiler-rt/test/csan/AMDGPU/atomic.hip
A compiler-rt/test/csan/AMDGPU/disjoint.hip
A compiler-rt/test/csan/AMDGPU/global-race.hip
A compiler-rt/test/csan/AMDGPU/helper-race.hip
A compiler-rt/test/csan/AMDGPU/lds-disjoint.hip
A compiler-rt/test/csan/AMDGPU/lds-race.hip
A compiler-rt/test/csan/AMDGPU/lit.local.cfg.py
A compiler-rt/test/csan/AMDGPU/memcpy-large-race.hip
A compiler-rt/test/csan/AMDGPU/memcpy-race.hip
A compiler-rt/test/csan/AMDGPU/memmove-race.hip
A compiler-rt/test/csan/AMDGPU/openmp-race.cpp
A compiler-rt/test/csan/AMDGPU/race.h
A compiler-rt/test/csan/AMDGPU/shared-watchpoints.hip
A compiler-rt/test/csan/AMDGPU/single-thread.hip
A compiler-rt/test/csan/AMDGPU/write-read-race.hip
A compiler-rt/test/csan/CMakeLists.txt
A compiler-rt/test/csan/access-sizes.cpp
A compiler-rt/test/csan/atomic-nonatomic.cpp
A compiler-rt/test/csan/atomic.cpp
A compiler-rt/test/csan/halt-on-error.cpp
A compiler-rt/test/csan/ignore-thread.cpp
A compiler-rt/test/csan/large-access.cpp
A compiler-rt/test/csan/large-range-race.cpp
A compiler-rt/test/csan/lit.common.cfg.py
A compiler-rt/test/csan/lit.site.cfg.py.in
A compiler-rt/test/csan/race.cpp
A compiler-rt/test/csan/read-read.cpp
A compiler-rt/test/csan/single-thread.cpp
A compiler-rt/test/csan/unknown-origin.cpp
M compiler-rt/test/lit.common.cfg.py
Log Message:
-----------
[compiler-rt] Add 'csan' library for the concurrency sanitizer
Summary:
Adds the runtime for the concurrency sanitizer, both CPU and GPU.
Fundamentally, this works using the following pseudocode:
```c
static u64 watchpoints[N]; // Hash-indexed, zero is empty.
// Emitted before the access, so we never trip on our own write.
void check_access(volatile void *addr, u32 size, u32 type) {
// Every access probes. A read conflicts only with a watched write, a
// write conflicts with either.
if (u64 *wp = find_watchpoint(addr, size, type))
consume(wp, this_pc()); // Hand our location to the owner.
if (!should_sample()) // Wave-uniform, 1-in-N chance.
return;
u64 *wp = arm_watchpoint(addr, size, type);
if (!wp) // Slot is already taken.
return;
auto old = read(addr, size);
delay(ctx.rand()); // Randomized, bounded.
if (void *peer = disarm(wp))
report_race(addr, this_pc(), peer);
else if (read(addr, size) != old)
report_race(addr, this_pc(), UNKNOWN);
}
```
This implementation is kept intentionally minimal to simplify the review
process. Many options are planned for later. The intended use is for
users to pass `-fsanitize=concurrency` for supported compilations.
Commit: b8f52e5246e70b649164cd7ed3458039be79569a
https://github.com/llvm/llvm-project/commit/b8f52e5246e70b649164cd7ed3458039be79569a
Author: Joseph Huber <huberjn at outlook.com>
Date: 2026-10-01 (Thu, 01 Oct 2026)
Changed paths:
M compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
M compiler-rt/cmake/config-ix.cmake
M compiler-rt/lib/csan/CMakeLists.txt
M compiler-rt/lib/csan/csan_gpu.cpp
M compiler-rt/lib/csan/offload/CMakeLists.txt
M compiler-rt/test/csan/CMakeLists.txt
Log Message:
-----------
comments
Commit: 188aefa51f6249209f5293fd9e4245310e1e4ed5
https://github.com/llvm/llvm-project/commit/188aefa51f6249209f5293fd9e4245310e1e4ed5
Author: Joseph Huber <huberjn at outlook.com>
Date: 2026-10-01 (Thu, 01 Oct 2026)
Changed paths:
M compiler-rt/lib/csan/CMakeLists.txt
A compiler-rt/lib/csan/csan.syms.extra
M compiler-rt/lib/csan/offload/CMakeLists.txt
M compiler-rt/lib/csan/offload/csan_offload_hsa_interceptors.cpp
A compiler-rt/lib/csan/offload/csan_offload_preinit.cpp
M compiler-rt/test/csan/AMDGPU/global-race.hip
M compiler-rt/test/csan/AMDGPU/openmp-race.cpp
A compiler-rt/test/csan/hsa-load-order.cpp
A compiler-rt/test/csan/hsa-missing.cpp
M compiler-rt/test/csan/lit.common.cfg.py
M compiler-rt/test/csan/race.cpp
Log Message:
-----------
[compiler-rt] Remove dlsym interceptor and support `-shared-libsan` for CSan
Summary:
Follow the UBSan offload runtime. Offload now resolves HSA through the
global scope, so the `dlsym` interceptor is no longer needed. The real
HSA entry points are still taken from the loaded HSA library rather than
`RTLD_NEXT`, since every DSO with a static runtime exports the same
wrappers and they would otherwise chain back into each other.
Build `libclang_rt.csan.so` with the offload objects folded in. The
exported HSA wrappers report failure when HSA is absent and warn when HSA
was loaded ahead of the runtime. The preinit hook moves to a separate
`csan_offload-preinit` archive for executables.
Compare: https://github.com/llvm/llvm-project/compare/87c5d0f252bd...188aefa51f62
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list