@@ -135,6 +135,18 @@ EXTRACTION_SRCS = \
135135# LSP resolvers (compiled as one unit via lsp_all.c)
136136LSP_SRCS = $(CBM_DIR)/lsp_all.c
137137
138+ # Header/source dependencies of the lsp_all unity object. lsp_all.c #includes
139+ # every lsp/*.c resolver, which in turn include cbm.h — and CBMCall is copied
140+ # BY VALUE across the lsp -> pipeline boundary (cbm_calls_push). This object is
141+ # compiled standalone and linked in, NOT recompiled with the rest on every link,
142+ # so it must list the headers/sources it pulls in. Without this, a changed struct
143+ # layout (e.g. a new CBMCall field) leaves a stale lsp_all.o with the old layout —
144+ # an ODR mismatch that under-reads the by-value struct copy. Explicit because this
145+ # Makefile does not use compiler auto-dependency (-MMD) generation.
146+ LSP_UNITY_DEPS = $(CBM_DIR)/lsp_all.c \
147+ $(wildcard $(CBM_DIR)/lsp/*.c $(CBM_DIR)/lsp/*.h \
148+ $(CBM_DIR)/lsp/generated/*.c $(CBM_DIR)/*.h)
149+
138150# Tree-sitter runtime
139151TS_RUNTIME_SRC = $(CBM_DIR)/ts_runtime.c
140152
@@ -492,7 +504,7 @@ $(BUILD_DIR)/%.o: $(CBM_DIR)/%.c | $(BUILD_DIR)
492504$(BUILD_DIR)/ts_runtime.o: $(CBM_DIR)/ts_runtime.c | $(BUILD_DIR)
493505 $(CC) $(GRAMMAR_CFLAGS_TEST) -c -o $@ $<
494506
495- $(BUILD_DIR)/lsp_all.o: $(CBM_DIR)/lsp_all.c | $(BUILD_DIR)
507+ $(BUILD_DIR)/lsp_all.o: $(LSP_UNITY_DEPS) | $(BUILD_DIR)
496508 $(CC) $(GRAMMAR_CFLAGS_TEST) $(SANITIZE) -c -o $@ $<
497509
498510$(BUILD_DIR)/preprocessor.o: $(CBM_DIR)/preprocessor.cpp | $(BUILD_DIR)
@@ -596,7 +608,7 @@ $(BUILD_DIR)/prod_%.o: $(CBM_DIR)/%.c | $(BUILD_DIR)
596608$(BUILD_DIR)/prod_ts_runtime.o: $(CBM_DIR)/ts_runtime.c | $(BUILD_DIR)
597609 $(CC) $(GRAMMAR_CFLAGS) -c -o $@ $<
598610
599- $(BUILD_DIR)/prod_lsp_all.o: $(CBM_DIR)/lsp_all.c | $(BUILD_DIR)
611+ $(BUILD_DIR)/prod_lsp_all.o: $(LSP_UNITY_DEPS) | $(BUILD_DIR)
600612 $(CC) $(GRAMMAR_CFLAGS) -c -o $@ $<
601613
602614$(BUILD_DIR)/prod_preprocessor.o: $(CBM_DIR)/preprocessor.cpp | $(BUILD_DIR)
0 commit comments