From 614824992749cc13ccbbd5e22f343746bdb0a12a Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Sat, 8 Aug 2026 04:09:21 +0900 Subject: [PATCH] =?UTF-8?q?make:=20test-incremental=20gate=20=E2=80=94=20-?= =?UTF-8?q?w=20reuse=20must=20equal=20a=20clean=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cold populate, full-skip rerun, surgical staleness (one package's artifacts deleted), and a 0-byte .o poison drill each build the w6a graph through a persistent workdir and must be byte-identical to a classic fresh-scratch build, on both driver stages, plus the cross-stage clean compare. Wired into test-all; the inner-loop targets stay untaxed. --- Makefile | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3c2ab7ef..1a734d7f 100644 --- a/Makefile +++ b/Makefile @@ -605,9 +605,49 @@ test-data-byteid: $(BIN)/ww $(BIN)/w6c $(BIN)/w6c_ww test-byteid: test-lang-byteid test-data-byteid test-native-byteid +# Incremental == clean. The -w reuse path must be byte-identical to a +# from-scratch build, or it is not a build-graph optimization but a +# correctness bug. Four warm shapes per driver stage — cold populate, +# full-skip rerun, surgical staleness (one package's artifacts deleted), +# and a 0-byte .o poison drill (must recompile, never reuse) — each +# compared against a classic fresh-scratch build, plus the cross-stage +# clean compare. The w6a graph keeps the gate small while covering the +# skip, recompile, commit, and legal-empty-.s (FFI-only rt) paths. +INCR_DIR = $(OUT)/incrcheck +test-incremental: $(BIN)/ww $(BIN)/ww_ww $(BIN)/w6c $(BIN)/w6c_ww \ + $(BIN)/w6a $(BIN)/w6a_ww $(BIN)/w6l $(BIN)/w6l_ww \ + $(LIB)/libwwrt.a + @rm -rf $(INCR_DIR) + @set -e; \ + src=$(CURDIR)/selfhost/cmd/w6a/main.ww; \ + inc=$(CURDIR)/selfhost/cmd/w6a; \ + for stage in cs ws; do \ + drv=$(CURDIR)/$(BIN)/ww; \ + if [ $$stage = ws ]; then drv=$(CURDIR)/$(BIN)/ww_ww; fi; \ + w=$(INCR_DIR)/$$stage.w; mkdir -p $$w; \ + $$drv build -w $$w -o $(INCR_DIR)/$$stage.cold -I $$inc $$src; \ + $$drv build -w $$w -o $(INCR_DIR)/$$stage.warm -I $$inc $$src; \ + rm $$w/strings.s $$w/strings.o $$w/strings.a; \ + $$drv build -w $$w -o $(INCR_DIR)/$$stage.surg -I $$inc $$src; \ + : > $$w/bytes.o; \ + $$drv build -w $$w -o $(INCR_DIR)/$$stage.heal -I $$inc $$src; \ + (cd $(INCR_DIR) && $$drv build -o $$stage.clean -I $$inc $$src); \ + for v in cold warm surg heal; do \ + cmp $(INCR_DIR)/$$stage.$$v $(INCR_DIR)/$$stage.clean || { \ + echo "test-incremental: $$stage.$$v differs from clean" >&2; \ + exit 1; }; \ + done; \ + done; \ + cmp $(INCR_DIR)/cs.clean $(INCR_DIR)/ws.clean || { \ + echo "test-incremental: cstage/wwstage clean builds differ" >&2; \ + exit 1; }; \ + rm -rf $(INCR_DIR) || { echo "test-incremental: cleanup failed" >&2; exit 1; }; \ + echo "test-incremental: -w reuse byte-identical to clean, both stages" + test-bootstrap: bootstrap test-bootstrap-native -test-all: test-commit test-byteid test-bootstrap test-platform test-wwfixture +test-all: test-commit test-byteid test-bootstrap test-platform \ + test-wwfixture test-incremental install: all mkdir -p $(PREFIX)/bin $(PREFIX)/lib @@ -768,5 +808,5 @@ nocc: test test-unit test-compiler-smoke test-compiler test-package \ test-lang test-library test-commit test-lang-byteid \ test-data-byteid test-native-byteid test-byteid \ - test-bootstrap-native test-bootstrap \ + test-bootstrap-native test-bootstrap test-incremental \ test-platform test-all install clean bootstrap nocc bootstrap-snapshot