build+test: -j/ccache build, drop 990 dup compile, add make smoke (#19)

Test-speed "immediate wins" from task #19 (build/test-infra only, no
compiler/cgen change — byte-id-neutral; all 237 pass, 950/990-997 +
combined_ww_fresh unchanged).

#1 Parallel build + ccache. MAKEFLAGS += -j$(NPROC) by default: the
C-compile DAG and the five wwstage builds write disjoint outputs (each
.o distinct; each wwstage tool's side files land at its own
selfhost/cmd/<tool>/main.* stem), so -j is order-independent.
test/run's Phase-2 byte-id gates are a single serial recipe that -j
does not reach. CC is wrapped with ccache when present (content-
addressed, byte-identical to plain cc); falls back to bare $(CC).

#2 Kill 990's duplicate ww1->ww2 compile. probe_ww1_to_ww2 recompiled
main.combined.ww (~70s) to assert the ww2 binary is executable — but
probe_bootstrap_fixed_point already compiles ww1->ww2, assembles,
links, and *runs* ww2 to produce ww3, so executability is proven and
the byte-id assertions (ww2.s==ww3.s, ww2==ww3) are untouched. Drop
the redundant probe. make test ~8:30 -> 7:39.

Add `make smoke [FIXTURE=x.ww]`: inner-loop cross-stage byte-id check
(cstage w6c vs wwstage w6c_ww .s diff) on a small self-contained
fixture, seconds. Catches cs!=ww emission divergence per fold; NOT a
substitute for the full 990-997 gate before landing a cgen/ABI fold.
This commit is contained in:
2026-06-01 14:05:32 +09:00
parent a937d67377
commit befb042647
2 changed files with 38 additions and 56 deletions

View File

@@ -7,6 +7,21 @@
PREFIX ?= /usr/local
CC ?= cc
AR ?= ar
# Parallelise the build by default. The C-compile DAG and the five
# wwstage builds write disjoint outputs (each .o is distinct; each
# wwstage tool's side files land at its own selfhost/cmd/<tool>/main.*
# stem), so -j is order-independent. test/run's Phase-2 byte-id gates
# (950/990-997) are a single serial recipe — MAKEFLAGS -j does not
# reach inside them. Override with `make -j1` if needed.
NPROC ?= $(shell nproc 2>/dev/null || echo 4)
MAKEFLAGS += -j$(NPROC)
# Wrap the C compiler with ccache when present — content-addressed, so
# byte-identical to plain cc; just skips recompiling unchanged TUs.
# Falls back cleanly to bare $(CC) when ccache is absent. A command-line
# CC= override wins and is left unwrapped.
CC := $(shell command -v ccache >/dev/null 2>&1 && echo "ccache $(CC)" || echo "$(CC)")
CFLAGS ?= -O0 -g -Wall -Wextra -Wpedantic -Wno-unused-parameter
CFLAGS += -std=c99 -fno-strict-aliasing -D_POSIX_C_SOURCE=200809L
INCS = -Icmd/wcc
@@ -1675,6 +1690,28 @@ test: all sizelint $(TESTS)
test-unit: all sizelint $(TESTS)
@WW=$(BIN)/ww BIN=$(BIN) UNIT=1 sh test/run
# ---- smoke: inner-loop cross-stage byte-id check on a SMALL input ------
# Compiles one self-contained fixture through cstage w6c AND wwstage
# w6c_ww and diffs the emitted .s. Catches a cs!=ww emission divergence
# (rule 10) in seconds — the per-fold inner-loop check Rob's cadence
# calls for. NOT a substitute for the full 990-997 byte-id gate, which
# self-compiles main.combined.ww: ALWAYS run `make test` before landing
# a cgen/ABI/compiler-lib fold. w6c consumes a flat unit (no import
# resolution), so FIXTURE must be import-free or a pre-built .combined.ww.
# make smoke # default: rt/malloc.ww
# make smoke FIXTURE=rt/ensure.ww # any self-contained .ww
FIXTURE ?= rt/malloc.ww
smoke: $(BIN)/w6c $(BIN)/w6c_ww
@$(BIN)/w6c $(FIXTURE) > $(OUT)/smoke.cs.s || { echo "smoke: cstage w6c failed on $(FIXTURE)"; exit 1; }
@$(BIN)/w6c_ww $(FIXTURE) > $(OUT)/smoke.ww.s || { echo "smoke: wwstage w6c_ww failed on $(FIXTURE)"; exit 1; }
@if cmp -s $(OUT)/smoke.cs.s $(OUT)/smoke.ww.s; then \
echo "smoke OK: cs == ww .s for $(FIXTURE) (`wc -l < $(OUT)/smoke.cs.s` lines)"; \
else \
echo "smoke FAIL: cs != ww .s for $(FIXTURE)"; \
diff -u $(OUT)/smoke.cs.s $(OUT)/smoke.ww.s | head -40; \
exit 1; \
fi
install: all
mkdir -p $(PREFIX)/bin $(PREFIX)/lib
cp $(BIN)/ww $(PREFIX)/bin/
@@ -1820,4 +1857,4 @@ nocc:
@echo
@echo "NOCC OK: $(STAGE0)/* reproduces itself from source. cc not invoked."
.PHONY: all cstage wwstage test test-unit sizelint install clean bootstrap nocc bootstrap-snapshot
.PHONY: all cstage wwstage test test-unit smoke sizelint install clean bootstrap nocc bootstrap-snapshot