# SPDX-License-Identifier: AGPL-3.0-or-later # Copyright (C) 2026 David (Corey) Herrera # Foundry TT backend — the off-hardware mapping suite: coordinates, the # architecture seam, and the harvesting matrix. # # NONE OF THESE TOUCH A DEVICE. They are pure unit tests of ft_tt_coord.{h,c} # and ft_tt_arch.{h,c}, and they run anywhere, which is the whole point: a wrong # NoC coordinate hangs the chip and costs a physical power cycle (spec §7.3), so # the mapping has to be proven wrong here rather than on silicon. # # test_harvesting matters most of the three, because it is the only coverage # that exists for code THIS CARD CANNOT RUN: all 14 columns are enabled here, so # the harvesting remap is a no-op on this board and would otherwise ship # unexecuted onto somebody's 120-core p150. # # Kept separate from `Makefile` so this file and the device tests can be edited # independently; fold it in whenever that is convenient. # # make -f Makefile.coord check build and run all three # make -f Makefile.coord red full rebuild, then run all three # make -f Makefile.coord check-coord just the coordinate oracle # make -f Makefile.coord check-arch just the architecture seam # make -f Makefile.coord check-harvest just the harvesting matrix # # `red` exists because a green test nobody has watched fail is not evidence # (coding-best-practices.md §9), and it rebuilds from scratch because Apple # ships GNU make 3.81, whose one-second mtime granularity silently skips a # rebuild of a source edited in the same second as its object — a mutation loop # that relies on incremental make can be testing the PREVIOUS binary. CC ?= cc SRC_DIR := .. BUILD := build-coord CFLAGS := -std=c99 -O1 -g \ -Wall -Wextra -Werror -pedantic \ -Wshadow -Wconversion -Wstrict-prototypes -Wformat=2 \ -fstack-protector-strong \ -I$(SRC_DIR) # Header dependency tracking. Without it, editing a HEADER rebuilds nothing and # the link silently mixes objects compiled against two different struct layouts # — which is not a build error, it is a wrong offset and a segfault (or worse, a # wrong answer). Adding a field to ft_tt_grid_info reproduced exactly that on # 2026-08-12. `-MMD -MP` makes every .o depend on the headers it read. DEPFLAGS := -MMD -MP # ft_tt_device.c and ft_tt_kmd.c are linked only for ft_tt_log_error, the # FT_TT_* status codes and the ft_tt_kmd_arch enum. Nothing here opens a device. BACKEND := $(SRC_DIR)/ft_tt_kmd.c \ $(SRC_DIR)/ft_tt_arch.c \ $(SRC_DIR)/ft_tt_arch_blackhole.c \ $(SRC_DIR)/ft_tt_device.c \ $(SRC_DIR)/ft_tt_tlb.c \ $(SRC_DIR)/ft_tt_coord.c BACKEND_OBJECTS := $(addprefix $(BUILD)/,$(notdir $(BACKEND:.c=.o))) COORD_TARGET := $(BUILD)/test_coord ARCH_TARGET := $(BUILD)/test_arch HARVEST_TARGET := $(BUILD)/test_harvesting TARGETS := $(COORD_TARGET) $(ARCH_TARGET) $(HARVEST_TARGET) .PHONY: all check red clean check-coord check-arch check-harvest all: $(TARGETS) $(BUILD): mkdir -p $(BUILD) $(BUILD)/%.o: $(SRC_DIR)/%.c | $(BUILD) $(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@ $(BUILD)/%.o: %.c | $(BUILD) $(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@ $(COORD_TARGET): $(BACKEND_OBJECTS) $(BUILD)/test_coord.o $(CC) $(CFLAGS) $^ -o $@ $(ARCH_TARGET): $(BACKEND_OBJECTS) $(BUILD)/test_arch.o $(CC) $(CFLAGS) $^ -o $@ $(HARVEST_TARGET): $(BACKEND_OBJECTS) $(BUILD)/test_harvesting.o $(CC) $(CFLAGS) $^ -o $@ check: check-coord check-arch check-harvest check-coord: $(COORD_TARGET) ./$(COORD_TARGET) check-arch: $(ARCH_TARGET) ./$(ARCH_TARGET) check-harvest: $(HARVEST_TARGET) ./$(HARVEST_TARGET) # Full rebuild, then run. Use this for every red/green pass. red: clean $(TARGETS) -./$(COORD_TARGET) -./$(ARCH_TARGET) -./$(HARVEST_TARGET) clean: rm -rf $(BUILD) -include $(wildcard $(BUILD)/*.d)