v4: mkf18a, the host tool that builds a train's F18 artifact (ADR step 3, task 3)
Build / Image RASPI (push) Successful in 3m59s
Build / Image PC (push) Successful in 3m58s
Build / Image MILKV (push) Successful in 4m7s
Build / v4 tests (32- and 64-bit cells) (push) Successful in 16m5s

The artifact's layout and its check (artifact.h, artifact.c), the tool
(tools/f18a.c, mkf18a.c) and make -C v4 artifacts. test_mkf18a, 83
checks at both widths, failed against a stub first. Gates: test,
test-32 and sanitize pass, POST 990/990. Plan section 11.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-19 21:09:22 +00:00
parent 84f119a1b3
commit dc3803ab47
12 changed files with 2924 additions and 3 deletions
+44 -3
View File
@@ -31,7 +31,7 @@ HERE := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
SRCS := $(wildcard $(HERE)/src/*.c)
# test_mesh_boot.c is the kernel's boot of the fabric, linked as the hosted product is (its own rule,
# `mesh-boot`, below), not one of the per-width tests.
TESTS := $(filter-out %/test_mesh_boot.c %/test_inference.c,$(wildcard $(HERE)/tests/test_*.c))
TESTS := $(filter-out %/test_mesh_boot.c %/test_inference.c %/test_mkf18a.c,$(wildcard $(HERE)/tests/test_*.c))
# Cell widths to build and verify. 32 is the F18/Zynq case, 64 the aarch64
# host case; see DECOMPOSITION.md D-5.
@@ -357,7 +357,7 @@ $(foreach w,$(WIDTHS),$(foreach t,$(TESTS),$(eval $(call TEST_RULE,$(w),$(t)))))
$(foreach w,$(WIDTHS),$(foreach t,$(TESTS),$(eval $(call RUN_RULE,$(w),$(t)))))
$(foreach w,$(WIDTHS),$(foreach t,$(TESTS),$(eval $(call SAN_RULE,$(w),$(t)))))
sanitize: $(foreach w,$(WIDTHS),$(foreach t,$(TESTS),san-$(w)-$(notdir $(t)))) san-mesh-boot
sanitize: $(foreach w,$(WIDTHS),$(foreach t,$(TESTS),san-$(w)-$(notdir $(t)))) san-mesh-boot $(foreach w,$(WIDTHS),san-mkf18a-$(w))
@echo "all v4 tests passed under ASan+UBSan"
.PHONY: $(foreach w,$(WIDTHS),$(foreach t,$(TESTS),run-$(w)-$(notdir $(t)) san-$(w)-$(notdir $(t))))
@@ -424,7 +424,48 @@ $(BINDIR)/test_inference: $(HERE)/tests/test_inference.c $(HERE)/system/inferenc
inference: $(BINDIR)/test_inference
@$(BINDIR)/test_inference
test: $(addprefix test-,$(WIDTHS)) mesh-boot mesh-boot-on mesh-boot-noop inference
# THE HOST TOOL (docs/v4.0.0/plans/2026-11-19-f18-artifact-build.md section 2): mkf18a builds a train's
# engine, its F18 artifact, off the node, as mkrom builds the ROM -- one per cell width, with the host
# node's size. It hashes with the kernel's SHA-512 and names trains with its XXHash64, as mkcapsule does.
# test_mkf18a (section 4, test 3) builds two small trains with the same code and reads them back.
F18A_SRCS := $(HERE)/tools/f18a.c $(ROOT_DIR)/kernel/src/crypto/sha512.c $(ROOT_DIR)/kernel/src/hash/xxhash64.c
F18A_INC := -isystem $(ROOT_DIR)/kernel/include
F18A_DEPS := $(HERE)/tools/f18a.c $(HERE)/tools/f18a.h $(SRCS) $(wildcard $(HERE)/include/v4/*.h) $(HERE)/Makefile
define F18A_RULE
$(BINDIR)/mkf18a-$(1): $(HERE)/tools/mkf18a.c $$(F18A_DEPS)
@mkdir -p $(BINDIR)
$$(CC) $$(CFLAGS) -I$(HERE)/include $(F18A_INC) -DV4_CELL_BITS=$(1) $(HOST_DEFS) -DV4_ROOT='"$(HERE)"' \
$(HERE)/tools/mkf18a.c $(F18A_SRCS) $$(SRCS) -o $$@
$(BINDIR)/$(1)-test_mkf18a: $(HERE)/tests/test_mkf18a.c $$(F18A_DEPS)
@mkdir -p $(BINDIR)
$$(CC) $$(CFLAGS) -I$(HERE)/include $(F18A_INC) -DV4_CELL_BITS=$(1) -DSCRATCH='"$(BINDIR)/scratch-mkf18a-$(1)"' -DV4_ROOT='"$(HERE)"' \
$(HERE)/tests/test_mkf18a.c $(F18A_SRCS) $$(SRCS) -o $$@
$(BINDIR)/san-$(1)-test_mkf18a: $(HERE)/tests/test_mkf18a.c $$(F18A_DEPS)
@mkdir -p $(BINDIR)
$$(CC) $$(CSTD) $$(WARN) -O1 -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=all \
-I$(HERE)/include $(F18A_INC) -DV4_CELL_BITS=$(1) -DSCRATCH='"$(BINDIR)/scratch-san-mkf18a-$(1)"' -DV4_ROOT='"$(HERE)"' \
$(HERE)/tests/test_mkf18a.c $(F18A_SRCS) $$(SRCS) -o $$@
.PHONY: mkf18a-$(1) san-mkf18a-$(1)
mkf18a-$(1): $(BINDIR)/$(1)-test_mkf18a
@echo " [V4_CELL_BITS=$(1) mkf18a]"
@$(BINDIR)/$(1)-test_mkf18a
san-mkf18a-$(1): $(BINDIR)/san-$(1)-test_mkf18a
@echo " [ASan+UBSan V4_CELL_BITS=$(1) mkf18a]"
@$(BINDIR)/san-$(1)-test_mkf18a
endef
$(foreach w,$(WIDTHS),$(eval $(call F18A_RULE,$(w))))
# The artifacts of each width (section 3). No train has a .f18 directory of its own yet, so this is the
# tool; the first train comes with task 4.
.PHONY: artifacts
artifacts: $(foreach w,$(WIDTHS),$(BINDIR)/mkf18a-$(w))
test: $(addprefix test-,$(WIDTHS)) mesh-boot mesh-boot-on mesh-boot-noop inference artifacts $(foreach w,$(WIDTHS),mkf18a-$(w))
@echo "all v4 tests passed"
clean: