From dd49c523e4e4656750f266c529468213814b9679 Mon Sep 17 00:00:00 2001 From: Nitjsefnie Date: Sat, 1 Aug 2026 11:08:39 +0200 Subject: [PATCH] build: carry -Werror=switch in build.sh and sanitizer/valgrind legs #779 made -Werror=switch a hard CI error via make http|gfx|zlib|lsp|full (the $(CFLAGS) legs), but the legs contributors run locally use hand-written flag lists that omit it, so a non-exhaustive ASTType switch only warned there: - build.sh (minimal, full, lsp compile lines) - make asan, make asan-http, make tsan, make valgrind Add -Werror=switch to those lists so the gate bites locally too. No other warning flag changed; no -Werror generally. All legs still build clean (gcc + clang), and the suite passes 3275/3275 on the armed minimal build, so no switch on these paths is non-exhaustive. Co-Authored-By: Kimi K3 --- Makefile | 8 ++++---- build.sh | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index d60e162..48107cf 100644 --- a/Makefile +++ b/Makefile @@ -182,7 +182,7 @@ embed-smoke: amalgamation # The full suite runs leak-clean, so leave leak detection on: # make asan && cd tests && ASAN_OPTIONS=detect_leaks=1 bash run_all_tests.sh asan: - $(CC) -fsanitize=address,undefined -g -O1 -o $(BINARY) $(SOURCES) \ + $(CC) -fsanitize=address,undefined -Werror=switch -g -O1 -o $(BINARY) $(SOURCES) \ -DEIGENSCRIPT_EXT_HTTP=0 \ -DEIGENSCRIPT_EXT_MODEL=0 \ -DEIGENSCRIPT_EXT_DB=0 \ @@ -203,7 +203,7 @@ asan: # therefore remains unsanitized — a separate, smaller gap. # make asan-http && cd tests && ASAN_OPTIONS=detect_leaks=1 bash run_all_tests.sh asan-http: - $(CC) -fsanitize=address,undefined -g -O1 -o $(BINARY) $(SOURCES) \ + $(CC) -fsanitize=address,undefined -Werror=switch -g -O1 -o $(BINARY) $(SOURCES) \ $(SRC_DIR)/ext_http.c \ $(SRC_DIR)/model_io.c $(SRC_DIR)/model_infer.c $(SRC_DIR)/model_train.c \ -DEIGENSCRIPT_EXT_HTTP=1 \ @@ -217,7 +217,7 @@ asan-http: # Complements ASan (which is not run with the thread checker). Run the tests # under `setarch -R` — ThreadSanitizer needs ASLR disabled here (CLAUDE.md). tsan: - $(CC) -fsanitize=thread -g -O1 -o $(BINARY) $(SOURCES) \ + $(CC) -fsanitize=thread -Werror=switch -g -O1 -o $(BINARY) $(SOURCES) \ -DEIGENSCRIPT_EXT_HTTP=0 \ -DEIGENSCRIPT_EXT_MODEL=0 \ -DEIGENSCRIPT_EXT_DB=0 \ @@ -231,7 +231,7 @@ tsan: # system without instrumented libs. -O1 keeps optimizer-induced false positives # down while giving usable stacks. Same minimal extension surface as asan. valgrind: - $(CC) -g -O1 -o $(BINARY) $(SOURCES) \ + $(CC) -Werror=switch -g -O1 -o $(BINARY) $(SOURCES) \ -DEIGS_VALGRIND \ -DEIGENSCRIPT_EXT_HTTP=0 \ -DEIGENSCRIPT_EXT_MODEL=0 \ diff --git a/build.sh b/build.sh index 9888273..d69accd 100755 --- a/build.sh +++ b/build.sh @@ -42,7 +42,7 @@ if [ "$1" = "lsp" ]; then LSP_SOURCES=" $SOURCES " for u in $CLI_ONLY; do LSP_SOURCES="${LSP_SOURCES/ $u / }"; done LSP_SOURCES="$LSP_SOURCES eigenlsp.c" - $CC -Wall -Wextra -Werror=implicit-function-declaration -O2 -fstack-protector-strong -o eigenlsp $LSP_SOURCES \ + $CC -Wall -Wextra -Werror=implicit-function-declaration -Werror=switch -O2 -fstack-protector-strong -o eigenlsp $LSP_SOURCES \ -DEIGENSCRIPT_EXT_HTTP=0 \ -DEIGENSCRIPT_EXT_MODEL=0 \ -DEIGENSCRIPT_EXT_DB=0 \ @@ -52,7 +52,7 @@ if [ "$1" = "lsp" ]; then echo "EigenScript LSP $VERSION built. Binary: $(du -sh eigenlsp | cut -f1)" elif [ "$1" = "full" ]; then # Full build: all extensions. Requires libpq-dev. - $CC -Wall -Wextra -Werror=implicit-function-declaration -O2 -fstack-protector-strong -o eigenscript $SOURCES ext_http.c ext_db.c \ + $CC -Wall -Wextra -Werror=implicit-function-declaration -Werror=switch -O2 -fstack-protector-strong -o eigenscript $SOURCES ext_http.c ext_db.c \ model_io.c model_infer.c model_train.c \ -I/usr/include/postgresql \ -DEIGENSCRIPT_EXT_HTTP=1 \ @@ -64,7 +64,7 @@ elif [ "$1" = "full" ]; then echo "EigenScript $VERSION (full) built. Binary: $(du -sh eigenscript | cut -f1)" else # Minimal build: language + stdlib only. - $CC -Wall -Wextra -Werror=implicit-function-declaration -O2 -fstack-protector-strong -o eigenscript $SOURCES \ + $CC -Wall -Wextra -Werror=implicit-function-declaration -Werror=switch -O2 -fstack-protector-strong -o eigenscript $SOURCES \ -DEIGENSCRIPT_EXT_HTTP=0 \ -DEIGENSCRIPT_EXT_MODEL=0 \ -DEIGENSCRIPT_EXT_DB=0 \