From 1386c91314ecad4b09b74e38977f419fb8d7767d Mon Sep 17 00:00:00 2001 From: Nitjsefnie Date: Sun, 2 Aug 2026 23:46:30 +0200 Subject: [PATCH] build: carry -Werror=switch in the last six Makefile compile legs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #786 armed the sanitizer/valgrind legs and build.sh; the flag is now on every $(CFLAGS) leg plus asan/asan-http/tsan/valgrind. Six hand-written flag lists in the Makefile still omitted it, so a non-exhaustive switch only warned when built through them: - FLAGS_poison — the one entry in VARIANTS without it. Its siblings asan/asan-http/tsan/valgrind are all armed (#786); poison predates that PR and was simply missed, so the uninit-read hunter build was the one debug variant where a new ValType/ASTType/opcode case only warned. - jit-smoke — compiles src/jit.c standalone against the smoke stubs. - coverage — compiles all of $(SOURCES) at -O0 --coverage. - fuzz — compiles $(FUZZ_SOURCES) under ASan/UBSan. - fuzz-libfuzzer — same sources under clang/libFuzzer. - freestanding-libc-diff — compiles src/freestanding/mini_*.c. Every $(CC)/clang compile line in the Makefile now carries the flag; the only remaining bare line is coverage's link step, which compiles nothing. No other warning flag changed and no general -Werror is added. All six legs build clean with the flag armed: make poison, jit-smoke (JIT smoke all cases passed), fuzz, fuzz-libfuzzer (clang 17), and freestanding-libc-diff (mini-libc differential ALL SECTIONS PASS); the coverage leg's 24-TU compile loop and link both exit 0. No switch on any of these paths is non-exhaustive. Suite 3397/3397 on the release build. Co-Authored-By: Claude Opus 5 --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index bd55f8de..1e5ca044 100644 --- a/Makefile +++ b/Makefile @@ -107,7 +107,7 @@ FLAGS_valgrind := -Werror=switch -g -O1 -DEIGS_VALGRIND $(DEFS_OFF) $(VERDEF) LIBS_valgrind := -lm -lpthread SRC_V_poison := $(SOURCES) -FLAGS_poison := -g -O1 -DEIGS_POISON $(DEFS_OFF) $(VERDEF) +FLAGS_poison := -Werror=switch -g -O1 -DEIGS_POISON $(DEFS_OFF) $(VERDEF) LIBS_poison := -lm -lpthread VARIANTS := release full http zlib net gfx asan asan-http tsan valgrind poison @@ -230,7 +230,7 @@ dap: @echo "EigenScript DAP $(VERSION) built. Binary: $$(du -sh $(DAP_BINARY) | cut -f1)" jit-smoke: - $(CC) -Wall -Wextra -O2 -o /tmp/jit_smoke $(SRC_DIR)/jit.c $(SRC_DIR)/jit_smoke.c -lm + $(CC) -Wall -Wextra -Werror=switch -O2 -o /tmp/jit_smoke $(SRC_DIR)/jit.c $(SRC_DIR)/jit_smoke.c -lm /tmp/jit_smoke EMBED_SOURCES := $(filter-out $(CLI_ONLY),$(SOURCES)) @@ -349,7 +349,7 @@ coverage-clean: coverage: coverage-clean @for src in $(SOURCES); do \ obj=$${src%.c}.o; \ - $(CC) -O0 -g --coverage -Wall -Wextra -c $$src -o $$obj \ + $(CC) -O0 -g --coverage -Wall -Wextra -Werror=switch -c $$src -o $$obj \ -DEIGENSCRIPT_EXT_HTTP=0 \ -DEIGENSCRIPT_EXT_MODEL=0 \ -DEIGENSCRIPT_EXT_DB=0 \ @@ -377,7 +377,7 @@ coverage: coverage-clean FUZZ_SOURCES := $(filter-out $(CLI_ONLY),$(SOURCES)) fuzz: fuzz/fuzz_stdin.c $(FUZZ_SOURCES) - $(CC) -g -fsanitize=address,undefined -o fuzz/fuzz_stdin \ + $(CC) -g -fsanitize=address,undefined -Werror=switch -o fuzz/fuzz_stdin \ fuzz/fuzz_stdin.c $(FUZZ_SOURCES) \ -DEIGENSCRIPT_EXT_HTTP=0 \ -DEIGENSCRIPT_EXT_MODEL=0 \ @@ -394,7 +394,7 @@ fuzz-run: fuzz # $$LIB_FUZZING_ENGINE provides main(). Locally we just pass everything # explicitly so a clean clone can reproduce the OSS-Fuzz build. fuzz-libfuzzer: fuzz/fuzz_eigenscript.c $(FUZZ_SOURCES) - clang -g -O1 -fsanitize=fuzzer,address,undefined -fno-sanitize-recover=all \ + clang -g -O1 -fsanitize=fuzzer,address,undefined -fno-sanitize-recover=all -Werror=switch \ -o fuzz/fuzz_eigenscript \ fuzz/fuzz_eigenscript.c $(FUZZ_SOURCES) \ -DEIGENSCRIPT_EXT_HTTP=0 \ @@ -419,7 +419,7 @@ freestanding-check: # for mem/str/ctype/strtol/strtod/qsort/rand48/snprintf and the exact libm # subset; ulp-bounded for the transcendentals (bounds pinned in the harness). freestanding-libc-diff: - $(CC) -O2 -fno-builtin -ffp-contract=off -Wall -Wextra \ + $(CC) -O2 -fno-builtin -ffp-contract=off -Wall -Wextra -Werror=switch \ -o /tmp/eigs_libc_diff tests/freestanding_libc_diff.c \ src/freestanding/mini_libc.c src/freestanding/mini_libm.c \ src/freestanding/mini_fmt.c src/freestanding/mini_strtod.c -lm