Skip to content

Commit 619f702

Browse files
committed
build: rebuild when a project header changes
test-runner, test-repro-runner, test-runner-tsan, codebase-memory-mcp and test-foundation are each built in a single compiler invocation from their sources, and their rules listed only .c files as prerequisites. Editing a header therefore changed nothing make could see, so the target was not rebuilt and an incremental build silently kept testing the OLD header value. Found while revert-checking the label-allowlist change in this branch: the check passed, which was wrong. Shrinking CBM_SQL_TYPE_LIKE_LABELS should have turned the pin test red and did not, because nothing had recompiled. Forcing a rebuild produced the expected failure. A revert-check that cannot fail is worse than no revert-check, because it reports confidence it did not earn. This is the same class as the lsp_all.o staleness that #662 fixed with an explicit dep list; that fix was per-object, this one covers the whole-program targets. PROJECT_HDRS globs src/, internal/cbm/ and tests/ headers and is added to the five affected targets. Vendored trees are deliberately excluded: they are pinned, they already carry explicit dep lists (LSP_UNITY_DEPS, TS_RUNTIME_DEPS), and globbing tens of thousands of grammar headers would cost more than it protects. Verified: editing only src/foundation/constants.h, with no source file touched, now rebuilds and turns the pin test red -- the exact edit that was invisible to make before. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 63eda54 commit 619f702

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

‎Makefile.cbm‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,19 @@ PROD_SRCS = $(FOUNDATION_SRCS) $(STORE_SRCS) $(CYPHER_SRCS) $(MCP_SRCS) $(DAEMON
417417
EXISTING_C_SRCS = $(EXTRACTION_SRCS) $(LSP_SRCS) $(TS_RUNTIME_SRC) \
418418
$(GRAMMAR_SRCS) $(AC_LZ4_SRCS) $(ZSTD_SRCS) $(SQLITE_WRITER_SRC)
419419

420+
# Project headers, as prerequisites for the targets built in one compiler
421+
# invocation from sources (test-runner, test-repro-runner, test-runner-tsan,
422+
# codebase-memory-mcp, test-foundation). Those rules list only .c files, so
423+
# editing a header changed nothing make could see and the target was NOT
424+
# rebuilt — an incremental build then silently tested the OLD header value.
425+
# Found while revert-checking a constants.h change: the check passed because
426+
# nothing had recompiled.
427+
#
428+
# Vendored trees are deliberately excluded — they are pinned, they carry their
429+
# own explicit dep lists (LSP_UNITY_DEPS, TS_RUNTIME_DEPS), and globbing tens of
430+
# thousands of grammar headers would cost more than it protects.
431+
PROJECT_HDRS = $(wildcard src/*.h src/*/*.h $(CBM_DIR)/*.h tests/*.h tests/repro/*.h)
432+
420433
# ── Test sources ─────────────────────────────────────────────────
421434

422435
TEST_FOUNDATION_SRCS = \
@@ -645,7 +658,7 @@ $(BUILD_DIR):
645658

646659
# ── Foundation-only test (fast, no extraction) ───────────────────
647660

648-
$(BUILD_DIR)/test-foundation: $(TEST_FOUNDATION_SRCS) $(FOUNDATION_SRCS) | $(BUILD_DIR)
661+
$(BUILD_DIR)/test-foundation: $(TEST_FOUNDATION_SRCS) $(FOUNDATION_SRCS) $(PROJECT_HDRS) | $(BUILD_DIR)
649662
$(CC) $(CFLAGS_TEST) -o $@ $(TEST_FOUNDATION_SRCS) $(FOUNDATION_SRCS) $(LDFLAGS_TEST)
650663

651664
test-foundation: $(BUILD_DIR)/test-foundation
@@ -761,7 +774,7 @@ $(UNIXCODER_OBJ): $(UNIXCODER_BLOB_SRC) vendored/nomic/code_vectors.bin | $(BUIL
761774
OBJS_VENDORED_TEST = $(MIMALLOC_OBJ_TEST) $(SQLITE3_OBJ_TEST) $(TRE_OBJ_TEST) $(GRAMMAR_OBJS_TEST) $(TS_RUNTIME_OBJ_TEST) $(LSP_OBJ_TEST) $(PP_OBJ_TEST) $(LZ4_OBJ_TEST) $(ZSTD_OBJ_TEST) $(UNIXCODER_OBJ)
762775
OBJS_VENDORED_TSAN = $(MIMALLOC_OBJ_TSAN) $(SQLITE3_OBJ_TSAN) $(TRE_OBJ_TSAN) $(GRAMMAR_OBJS_TSAN) $(TS_RUNTIME_OBJ_TSAN) $(LSP_OBJ_TSAN) $(PP_OBJ_TSAN) $(LZ4_OBJ_TSAN) $(ZSTD_OBJ_TSAN) $(UNIXCODER_OBJ)
763776

764-
$(BUILD_DIR)/test-runner: $(ALL_TEST_SRCS) $(PROD_SRCS) $(EXTRACTION_SRCS) $(AC_LZ4_SRCS) $(ZSTD_SRCS) $(SQLITE_WRITER_SRC) $(OBJS_VENDORED_TEST) | $(BUILD_DIR)
777+
$(BUILD_DIR)/test-runner: $(ALL_TEST_SRCS) $(PROD_SRCS) $(EXTRACTION_SRCS) $(AC_LZ4_SRCS) $(ZSTD_SRCS) $(SQLITE_WRITER_SRC) $(OBJS_VENDORED_TEST) $(PROJECT_HDRS) | $(BUILD_DIR)
765778
$(CC) $(CFLAGS_TEST) -Itests -Itests/repro -o $@ \
766779
$(ALL_TEST_SRCS) $(PROD_SRCS) \
767780
$(EXTRACTION_SRCS) $(AC_LZ4_SRCS) $(ZSTD_SRCS) $(SQLITE_WRITER_SRC) \
@@ -789,7 +802,7 @@ test-focused: $(BUILD_DIR)/test-runner
789802
# Mirrors test-runner's link line but uses repro_main.c (own main + counters)
790803
# and TEST_REPRO_SRCS instead of ALL_TEST_SRCS. Exits non-zero while any bug is
791804
# still reproduced (the expected state); bug-repro.yml surfaces it as a board.
792-
$(BUILD_DIR)/test-repro-runner: $(TEST_REPRO_SRCS) $(PROD_SRCS) $(EXTRACTION_SRCS) $(AC_LZ4_SRCS) $(ZSTD_SRCS) $(SQLITE_WRITER_SRC) $(OBJS_VENDORED_TEST) | $(BUILD_DIR)
805+
$(BUILD_DIR)/test-repro-runner: $(TEST_REPRO_SRCS) $(PROD_SRCS) $(EXTRACTION_SRCS) $(AC_LZ4_SRCS) $(ZSTD_SRCS) $(SQLITE_WRITER_SRC) $(OBJS_VENDORED_TEST) $(PROJECT_HDRS) | $(BUILD_DIR)
793806
$(CC) $(CFLAGS_TEST) -Itests -o $@ \
794807
$(TEST_REPRO_SRCS) $(PROD_SRCS) \
795808
$(EXTRACTION_SRCS) $(AC_LZ4_SRCS) $(ZSTD_SRCS) $(SQLITE_WRITER_SRC) \
@@ -831,7 +844,7 @@ TSAN_OPTIONS ?= halt_on_error=1
831844
# Normal ASan/native/soak paths remain uncapped. High-worker TSan diagnostics
832845
# invoke test-runner-tsan directly so release gates cannot drift accidentally.
833846

834-
$(BUILD_DIR)/test-runner-tsan: $(ALL_TEST_SRCS) $(PROD_SRCS) $(EXTRACTION_SRCS) $(AC_LZ4_SRCS) $(ZSTD_SRCS) $(SQLITE_WRITER_SRC) $(OBJS_VENDORED_TSAN) | $(BUILD_DIR)
847+
$(BUILD_DIR)/test-runner-tsan: $(ALL_TEST_SRCS) $(PROD_SRCS) $(EXTRACTION_SRCS) $(AC_LZ4_SRCS) $(ZSTD_SRCS) $(SQLITE_WRITER_SRC) $(OBJS_VENDORED_TSAN) $(PROJECT_HDRS) | $(BUILD_DIR)
835848
$(CC) $(CFLAGS_TSAN) -Itests -Itests/repro -o $@ \
836849
$(ALL_TEST_SRCS) $(PROD_SRCS) \
837850
$(EXTRACTION_SRCS) $(AC_LZ4_SRCS) $(ZSTD_SRCS) $(SQLITE_WRITER_SRC) \
@@ -904,7 +917,7 @@ $(BUILD_DIR)/.build-config: build-config-check | $(BUILD_DIR)
904917
else mv -f $@.tmp $@; rm -f $(BUILD_DIR)/codebase-memory-mcp; \
905918
echo "=== build config changed -> full rebuild: $(BUILD_CONFIG_SIG) ==="; fi
906919

907-
$(BUILD_DIR)/codebase-memory-mcp: $(MAIN_SRC) $(PROD_SRCS) $(EXTRACTION_SRCS) $(AC_LZ4_SRCS) $(ZSTD_SRCS) $(SQLITE_WRITER_SRC) $(OBJS_VENDORED_PROD) $(BUILD_DIR)/.build-config | $(BUILD_DIR)
920+
$(BUILD_DIR)/codebase-memory-mcp: $(MAIN_SRC) $(PROD_SRCS) $(EXTRACTION_SRCS) $(AC_LZ4_SRCS) $(ZSTD_SRCS) $(SQLITE_WRITER_SRC) $(OBJS_VENDORED_PROD) $(BUILD_DIR)/.build-config $(PROJECT_HDRS) | $(BUILD_DIR)
908921
$(CC) $(CFLAGS_PROD) -o $@ \
909922
$(MAIN_SRC) $(PROD_SRCS) \
910923
$(EXTRACTION_SRCS) $(AC_LZ4_SRCS) $(ZSTD_SRCS) $(SQLITE_WRITER_SRC) \

0 commit comments

Comments
 (0)