Skip to content

Commit ee8c629

Browse files
committed
Add ThreadSanitizer CI builds for GCC and Clang
Add TSan variants to the build matrix for GCC 15 (shared) and Clang 20 (static), mirroring the existing ASan link modes.
1 parent 8645de4 commit ee8c629

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

.github/generate-matrix.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ def generate_name(compiler_family, entry):
9898
macos_ver = runner.replace("macos-", "macOS ")
9999
modifiers.append(macos_ver)
100100

101-
if entry.get("asan") and entry.get("ubsan"):
101+
if entry.get("tsan"):
102+
modifiers.append("tsan")
103+
elif entry.get("asan") and entry.get("ubsan"):
102104
modifiers.append("asan+ubsan")
103105
elif entry.get("asan"):
104106
modifiers.append("asan")
@@ -139,6 +141,20 @@ def generate_sanitizer_variant(compiler_family, spec):
139141
return make_entry(compiler_family, spec, **overrides)
140142

141143

144+
def generate_tsan_variant(compiler_family, spec):
145+
"""Generate TSan variant for the latest compiler in a family (Linux only)."""
146+
overrides = {
147+
"tsan": True,
148+
"build-type": "RelWithDebInfo",
149+
"shared": True,
150+
}
151+
152+
if compiler_family == "clang":
153+
overrides["shared"] = False
154+
155+
return make_entry(compiler_family, spec, **overrides)
156+
157+
142158
def generate_coverage_variant(compiler_family, spec):
143159
"""Generate coverage variant (GCC only)."""
144160
return make_entry(compiler_family, spec, **{
@@ -185,6 +201,10 @@ def main():
185201
if spec.get("is_latest"):
186202
matrix.append(generate_sanitizer_variant(family, spec))
187203

204+
# TSan is incompatible with ASan; separate variant for Linux
205+
if family in ("gcc", "clang"):
206+
matrix.append(generate_tsan_variant(family, spec))
207+
188208
if family == "gcc":
189209
matrix.append(generate_coverage_variant(family, spec))
190210

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ jobs:
152152
if: ${{ !matrix.coverage && !matrix.time-trace }}
153153
env:
154154
ASAN_OPTIONS: ${{ ((matrix.compiler == 'apple-clang' || matrix.compiler == 'clang' || matrix.compiler == 'mingw') && 'detect_invalid_pointer_pairs=0:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1') || 'detect_invalid_pointer_pairs=2:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1' }}
155+
TSAN_OPTIONS: ${{ matrix.tsan && 'halt_on_error=1:second_deadlock_stack=1' || '' }}
155156
with:
156157
source-dir: boost-root
157158
modules: capy
@@ -162,6 +163,7 @@ jobs:
162163
address-model: ${{ (matrix.x86 && '32') || '64' }}
163164
asan: ${{ matrix.asan }}
164165
ubsan: ${{ matrix.ubsan }}
166+
tsan: ${{ matrix.tsan }}
165167
shared: ${{ matrix.shared }}
166168
rtti: on
167169
cxxflags: ${{ (matrix.asan && matrix.compiler != 'msvc' && matrix.compiler != 'clang-cl' && '-fsanitize-address-use-after-scope -fsanitize=pointer-subtract') || '' }}

0 commit comments

Comments
 (0)