Skip to content

Commit 30505ec

Browse files
committed
Switch Windows CI to CLANG64 for ASan/UBSan support
MinGW GCC does not ship ASan runtime on Windows. MSYS2 CLANG64 provides full sanitizer support via compiler-rt. All platforms now run tests with ASan + UBSan — no exceptions.
1 parent fdb83f8 commit 30505ec

4 files changed

Lines changed: 33 additions & 32 deletions

File tree

.github/workflows/dry-run.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,17 @@ jobs:
8888

8989
- uses: msys2/setup-msys2@v2
9090
with:
91-
msystem: UCRT64
91+
msystem: CLANG64
9292
path-type: inherit
9393
install: >-
94-
mingw-w64-ucrt-x86_64-gcc
95-
mingw-w64-ucrt-x86_64-zlib
94+
mingw-w64-clang-x86_64-clang
95+
mingw-w64-clang-x86_64-compiler-rt
96+
mingw-w64-clang-x86_64-zlib
9697
make
9798
9899
- name: Test
99100
shell: msys2 {0}
100-
run: scripts/test.sh
101+
run: scripts/test.sh CC=clang CXX=clang++ WIN32_LIBS="-lws2_32 -lpsapi"
101102

102103
# ── Step 3: Build binaries (standard + UI, all OS) ──────────
103104
build-unix:
@@ -166,11 +167,11 @@ jobs:
166167

167168
- uses: msys2/setup-msys2@v2
168169
with:
169-
msystem: UCRT64
170+
msystem: CLANG64
170171
path-type: inherit
171172
install: >-
172-
mingw-w64-ucrt-x86_64-gcc
173-
mingw-w64-ucrt-x86_64-zlib
173+
mingw-w64-clang-x86_64-clang
174+
mingw-w64-clang-x86_64-zlib
174175
make
175176
176177
- uses: actions/setup-node@v4
@@ -179,7 +180,7 @@ jobs:
179180

180181
- name: Build standard binary
181182
shell: msys2 {0}
182-
run: scripts/build.sh
183+
run: scripts/build.sh CC=clang CXX=clang++ WIN32_LIBS="-lws2_32 -lpsapi"
183184

184185
- name: Archive standard binary
185186
shell: pwsh
@@ -189,7 +190,7 @@ jobs:
189190
190191
- name: Build UI binary
191192
shell: msys2 {0}
192-
run: scripts/build.sh --with-ui
193+
run: scripts/build.sh --with-ui CC=clang CXX=clang++ WIN32_LIBS="-lws2_32 -lpsapi"
193194

194195
- name: Archive UI binary
195196
shell: pwsh

.github/workflows/release.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,17 @@ jobs:
102102

103103
- uses: msys2/setup-msys2@v2
104104
with:
105-
msystem: UCRT64
105+
msystem: CLANG64
106106
path-type: inherit
107107
install: >-
108-
mingw-w64-ucrt-x86_64-gcc
109-
mingw-w64-ucrt-x86_64-zlib
108+
mingw-w64-clang-x86_64-clang
109+
mingw-w64-clang-x86_64-compiler-rt
110+
mingw-w64-clang-x86_64-zlib
110111
make
111112
112113
- name: Test
113114
shell: msys2 {0}
114-
run: scripts/test.sh
115+
run: scripts/test.sh CC=clang CXX=clang++ WIN32_LIBS="-lws2_32 -lpsapi"
115116

116117
# ── Step 3: Build binaries (standard + UI, all OS) ──────────
117118
build-unix:
@@ -180,11 +181,11 @@ jobs:
180181

181182
- uses: msys2/setup-msys2@v2
182183
with:
183-
msystem: UCRT64
184+
msystem: CLANG64
184185
path-type: inherit
185186
install: >-
186-
mingw-w64-ucrt-x86_64-gcc
187-
mingw-w64-ucrt-x86_64-zlib
187+
mingw-w64-clang-x86_64-clang
188+
mingw-w64-clang-x86_64-zlib
188189
make
189190
190191
- uses: actions/setup-node@v4
@@ -193,7 +194,7 @@ jobs:
193194

194195
- name: Build standard binary
195196
shell: msys2 {0}
196-
run: scripts/build.sh --version ${{ inputs.version }}
197+
run: scripts/build.sh --version ${{ inputs.version }} CC=clang CXX=clang++ WIN32_LIBS="-lws2_32 -lpsapi"
197198

198199
- name: Archive standard binary
199200
shell: pwsh
@@ -203,7 +204,7 @@ jobs:
203204
204205
- name: Build UI binary
205206
shell: msys2 {0}
206-
run: scripts/build.sh --with-ui --version ${{ inputs.version }}
207+
run: scripts/build.sh --with-ui --version ${{ inputs.version }} CC=clang CXX=clang++ WIN32_LIBS="-lws2_32 -lpsapi"
207208

208209
- name: Archive UI binary
209210
shell: pwsh

Makefile.cbm

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,10 @@ CXXFLAGS_COMMON = -std=c++14 -Wall -Wextra -Werror \
6161
CFLAGS_PROD = $(CFLAGS_COMMON) -O2 $(CFLAGS_EXTRA)
6262
CXXFLAGS_PROD = $(CXXFLAGS_COMMON) -O2
6363

64-
# Test flags: debug + sanitizers
65-
CFLAGS_TEST = $(CFLAGS_COMMON) -g -O1 \
66-
-fsanitize=address,undefined \
67-
-fno-omit-frame-pointer
68-
CXXFLAGS_TEST = $(CXXFLAGS_COMMON) -g -O1 \
69-
-fsanitize=address,undefined \
70-
-fno-omit-frame-pointer
64+
# Test flags: debug + sanitizers (override SANITIZE= to disable on Windows)
65+
SANITIZE = -fsanitize=address,undefined -fno-omit-frame-pointer
66+
CFLAGS_TEST = $(CFLAGS_COMMON) -g -O1 $(SANITIZE)
67+
CXXFLAGS_TEST = $(CXXFLAGS_COMMON) -g -O1 $(SANITIZE)
7168

7269
# TSan (can't combine with ASan)
7370
CFLAGS_TSAN = $(CFLAGS_COMMON) -g -O1 \
@@ -80,7 +77,7 @@ CXXFLAGS_TSAN = $(CXXFLAGS_COMMON) -g -O1 \
8077
WIN32_LIBS ?=
8178

8279
LDFLAGS = -lm -lstdc++ -lpthread -lz $(LIBGIT2_LIBS) $(WIN32_LIBS)
83-
LDFLAGS_TEST = -lm -lstdc++ -lpthread -lz -fsanitize=address,undefined $(LIBGIT2_LIBS) $(WIN32_LIBS)
80+
LDFLAGS_TEST = -lm -lstdc++ -lpthread -lz $(SANITIZE) $(LIBGIT2_LIBS) $(WIN32_LIBS)
8481
LDFLAGS_TSAN = -lm -lstdc++ -lpthread -lz -fsanitize=thread $(LIBGIT2_LIBS) $(WIN32_LIBS)
8582

8683
# ── Source files ─────────────────────────────────────────────────
@@ -195,7 +192,7 @@ UI_SRCS = \
195192
MONGOOSE_SRC = vendored/mongoose/mongoose.c
196193
MONGOOSE_CFLAGS = -std=c11 -D_DEFAULT_SOURCE -O2 -w -Ivendored -DMG_ENABLE_LOG=0
197194
MONGOOSE_CFLAGS_TEST = -std=c11 -D_DEFAULT_SOURCE -g -O1 -w -Ivendored -DMG_ENABLE_LOG=0 \
198-
-fsanitize=address,undefined -fno-omit-frame-pointer
195+
$(SANITIZE)
199196

200197
# mimalloc (vendored, global allocator override)
201198
MIMALLOC_SRC = vendored/mimalloc/src/static.c
@@ -291,7 +288,7 @@ BUILD_DIR = build/c
291288
# Grammar + tree-sitter runtime: compiled without -Werror (upstream code has warnings)
292289
GRAMMAR_CFLAGS = -std=c11 -D_DEFAULT_SOURCE -O2 -w -I$(CBM_DIR) -I$(TS_INCLUDE) -I$(TS_SRC)
293290
GRAMMAR_CFLAGS_TEST = -std=c11 -D_DEFAULT_SOURCE -g -O1 -w -I$(CBM_DIR) -I$(TS_INCLUDE) -I$(TS_SRC) \
294-
-fsanitize=address,undefined -fno-omit-frame-pointer
291+
$(SANITIZE)
295292
GRAMMAR_CFLAGS_TSAN = -std=c11 -D_DEFAULT_SOURCE -g -O1 -w -I$(CBM_DIR) -I$(TS_INCLUDE) -I$(TS_SRC) \
296293
-fsanitize=thread -fno-omit-frame-pointer
297294

@@ -325,7 +322,7 @@ $(BUILD_DIR)/ts_runtime.o: $(CBM_DIR)/ts_runtime.c | $(BUILD_DIR)
325322
$(CC) $(GRAMMAR_CFLAGS_TEST) -c -o $@ $<
326323

327324
$(BUILD_DIR)/lsp_all.o: $(CBM_DIR)/lsp_all.c | $(BUILD_DIR)
328-
$(CC) $(GRAMMAR_CFLAGS_TEST) -fsanitize=address,undefined -fno-omit-frame-pointer -c -o $@ $<
325+
$(CC) $(GRAMMAR_CFLAGS_TEST) $(SANITIZE) -c -o $@ $<
329326

330327
$(BUILD_DIR)/preprocessor.o: $(CBM_DIR)/preprocessor.cpp | $(BUILD_DIR)
331328
$(CXX) $(CXXFLAGS_TEST) -w -I$(CBM_DIR)/vendored -c -o $@ $<
@@ -357,7 +354,7 @@ SQLITE3_OBJ_TEST = $(BUILD_DIR)/sqlite3.o
357354
SQLITE3_OBJ_PROD = $(BUILD_DIR)/prod_sqlite3.o
358355

359356
$(BUILD_DIR)/sqlite3.o: $(SQLITE3_SRC) | $(BUILD_DIR)
360-
$(CC) $(SQLITE3_CFLAGS_TEST) -fsanitize=address,undefined -fno-omit-frame-pointer -c -o $@ $<
357+
$(CC) $(SQLITE3_CFLAGS_TEST) $(SANITIZE) -c -o $@ $<
361358

362359
$(BUILD_DIR)/prod_sqlite3.o: $(SQLITE3_SRC) | $(BUILD_DIR)
363360
$(CC) $(SQLITE3_CFLAGS) -c -o $@ $<

scripts/test.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ done
3838
# shellcheck source=env.sh
3939
source "$ROOT/scripts/env.sh"
4040

41-
# Forward CC/CXX from args
41+
# Forward CC/CXX and collect make-passthrough args (WIN32_LIBS=)
42+
MAKE_ARGS=""
4243
for arg in "$@"; do
4344
case "$arg" in
4445
CC=*|CXX=*) export "${arg}" ;;
46+
WIN32_LIBS=*) MAKE_ARGS="$MAKE_ARGS $arg" ;;
4547
--arch|--arch=*) ;; # already handled
4648
arm64|x86_64) ;; # already handled
4749
esac
@@ -56,6 +58,6 @@ verify_compiler "$CC"
5658
scripts/clean.sh
5759

5860
# Step 2 + 3: Build and run tests (with arch prefix on macOS)
59-
$ARCH_PREFIX make -j"$NPROC" -f Makefile.cbm test
61+
$ARCH_PREFIX make -j"$NPROC" -f Makefile.cbm test $MAKE_ARGS
6062

6163
echo "=== All tests passed ==="

0 commit comments

Comments
 (0)