Artifact ab1e62e993bc2598ec6bd7854ecddf93c2575baf3ea39c7a1c6945dc600bb121:
- File
Makefile
— part of check-in
[7e80bb990b]
at
2026-11-18 17:21:06
on branch stage-2
— Vendor zlib and drop iconv and dynamic loading
pic now compiles zlib in, builds libfossil without iconv and SQLite without extension loading, so the binary links only libc, libm and pthread. (user: dmestas, size: 6898) [annotate] [blame] [check-ins using]
# pic harness plus S0/S1 qualification gates.
CC ?= cc
PYTHON ?= python3
export CC
.PHONY: all check metadata test test-reporting replay dst sanitize coverage-mcdc \
fuzz-smoke bench filc-remote qualify help assertion-guard local-evidence test-context test-context-sanitize test-remote \
pic pic-dev test-pic test-sse test-decode fuzz-decode
all: check
check: test-pic metadata test-reporting replay coverage-mcdc assertion-guard test-remote
@printf '%s\n' 'PASS: pic crash/recovery suite and local qualification gates.'
metadata:
$(PYTHON) -I -B test/test_contracts.py
$(PYTHON) -I -B tools/check_contracts.py
test-reporting:
$(PYTHON) -I -B test/test_toolchain.py
test:
sh tools/test-native.sh normal
# The normal suite includes the fixed 100-seed deterministic replay campaign.
dst: test
replay: test
sh tools/test-native.sh replay
sanitize:
sh tools/test-native.sh sanitize
coverage-mcdc:
sh tools/mcdc.sh
assertion-guard:
sh tools/test-assertions.sh
fuzz-smoke:
sh tools/test-native.sh fuzz
bench:
sh tools/benchmark.sh
test-context:
sh test/context/test-driver.sh normal
test-context-sanitize:
sh test/context/test-driver.sh sanitize
test-remote:
sh test/test_remote_lifecycle.sh
$(PYTHON) -I -B test/remote/test_collect.py
# Run actual local gates before snapshotting metadata; never reuse a stale PASS.
local-evidence:
mkdir -p build/qualification
rm -f build/qualification/local-evidence.json
$(MAKE) check sanitize fuzz-smoke bench > build/qualification/local-checks.log 2>&1
$(PYTHON) -I -B tools/evidence.py --log build/qualification/local-checks.log
$(PYTHON) -I -B tools/check_contracts.py --evidence build/qualification/local-evidence.json
# Remote evidence gate; actual host operations remain explicit.
filc-remote:
@test -n "$(REMOTE_RUN)" || { printf '%s\n' 'GATED: supply REMOTE_RUN=/absolute/completed/filc-run; see docs/remote-lifecycle.md'; exit 2; }
sh tools/remote/run.sh reconcile "$(REMOTE_RUN)" > "$(REMOTE_RUN)/operator-reconcile.log"
$(PYTHON) -I -B tools/remote/report.py "$(REMOTE_RUN)"
$(PYTHON) -I -B tools/check_contracts.py --evidence "$(REMOTE_RUN)/qualification.json"
qualify: check sanitize fuzz-smoke bench
@printf '%s\n' 'GATED: local fixture evidence is not release qualification.' \
'Production runtime/release contracts remain unqualified; remote fixture evidence is a separate explicit gate.'
@exit 2
help:
@printf '%s\n' 'S0 only: check, metadata, test, dst, replay, sanitize, coverage-mcdc,' \
'fuzz-smoke, bench, test-context, test-context-sanitize, test-remote.' \
'filc-remote verifies an explicit REMOTE_RUN; full production qualify remains GATED.'
# ---- pic: the harness ------------------------------------------------------
# Release has no test code and no fault hooks; dev adds ASan/UBSan and crash points.
PIC_SRC := src/store.c src/loop.c src/provider_fake.c src/tools.c src/sse.c src/anthropic.c src/main.c
PIC_HDR := src/pic.h src/sse.h src/anthropic.h
PIC_VENDOR := vendor/libfossil
# Dependencies are vendored and compiled in (vendor/*/SHA256SUMS); the binary
# links only libc, libm and pthread. No iconv, no -ldl, no system zlib.
PIC_SQLITE := -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_THREADSAFE=1 \
-DSQLITE_OMIT_LOAD_EXTENSION
PIC_VFLAGS := $(PIC_SQLITE) -DHAVE_LIBFOSSIL_CONFIG_H -DWITHOUT_ICONV -DZ_HAVE_UNISTD_H -w \
-I$(PIC_VENDOR) -Ivendor/zlib
PIC_WARN := -std=c11 -Wall -Wextra -Wpedantic -Werror -Wshadow -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes -Wvla -Wcast-qual -D_DEFAULT_SOURCE -D_DARWIN_C_SOURCE
PIC_INC := -Isrc -isystem $(PIC_VENDOR) -DHAVE_LIBFOSSIL_CONFIG_H
PIC_SAN := -O1 -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=all
PIC_LIBS := -lm -lpthread
PIC_ZLIB := adler32 compress crc32 deflate inffast inflate inftrees trees uncompr zutil
build/pic/release/vendor/%.o: $(PIC_VENDOR)/%.c
@mkdir -p $(@D)
$(CC) -O2 $(PIC_VFLAGS) -c -o $@ $<
build/pic/dev/vendor/%.o: $(PIC_VENDOR)/%.c
@mkdir -p $(@D)
$(CC) $(PIC_SAN) $(PIC_VFLAGS) -c -o $@ $<
build/pic/release/vendor/zlib/%.o: vendor/zlib/%.c
@mkdir -p $(@D)
$(CC) -O2 $(PIC_VFLAGS) -c -o $@ $<
build/pic/dev/vendor/zlib/%.o: vendor/zlib/%.c
@mkdir -p $(@D)
$(CC) $(PIC_SAN) $(PIC_VFLAGS) -c -o $@ $<
PIC_REL_V := build/pic/release/vendor/sqlite3.o build/pic/release/vendor/libfossil.o \
$(PIC_ZLIB:%=build/pic/release/vendor/zlib/%.o)
PIC_DEV_V := build/pic/dev/vendor/sqlite3.o build/pic/dev/vendor/libfossil.o \
$(PIC_ZLIB:%=build/pic/dev/vendor/zlib/%.o)
build/pic/release/pic: $(PIC_SRC) $(PIC_HDR) $(PIC_REL_V)
@mkdir -p $(@D)
$(CC) $(PIC_WARN) -O2 $(PIC_INC) -o $@ $(PIC_SRC) $(PIC_REL_V) $(PIC_LIBS)
build/pic/dev/pic: $(PIC_SRC) $(PIC_HDR) $(PIC_DEV_V)
@mkdir -p $(@D)
$(CC) $(PIC_WARN) $(PIC_SAN) -DPIC_FAULTS $(PIC_INC) -o $@ $(PIC_SRC) $(PIC_DEV_V) $(PIC_LIBS)
pic: build/pic/release/pic
pic-dev: build/pic/dev/pic
test-pic: test-sse test-decode build/pic/dev/pic build/pic/release/pic
ASAN_OPTIONS=detect_leaks=0 PIC=$(CURDIR)/build/pic/dev/pic sh test/pic/crash.sh
PIC=$(CURDIR)/build/pic/release/pic sh test/pic/crash.sh --no-faults
build/pic/dev/test_sse: test/pic/test_sse.c src/sse.c src/sse.h
@mkdir -p $(@D)
$(CC) $(PIC_WARN) $(PIC_SAN) -Isrc -o $@ test/pic/test_sse.c src/sse.c
test-sse: build/pic/dev/test_sse
build/pic/dev/test_sse
build/pic/dev/decode_stream: test/pic/decode_stream.c src/anthropic.c src/anthropic.h src/sse.c src/sse.h $(PIC_DEV_V)
@mkdir -p $(@D)
$(CC) $(PIC_WARN) $(PIC_SAN) $(PIC_INC) -o $@ test/pic/decode_stream.c src/anthropic.c src/sse.c $(PIC_DEV_V) $(PIC_LIBS)
test-decode: build/pic/dev/decode_stream
sh test/pic/decode.sh build/pic/dev/decode_stream
# libFuzzer needs an LLVM clang (Apple's lacks it). SQLite is rebuilt with the
# same compiler so one sanitizer runtime is linked. FUZZ_SECONDS bounds a run;
# new findings land in build/pic/fuzz/ and become fixtures when fixed.
FUZZ_CC ?= $(firstword $(wildcard /opt/homebrew/opt/llvm/bin/clang /usr/local/opt/llvm/bin/clang) clang)
FUZZ_SECONDS ?= 60
FUZZ_FLAGS := -O1 -g -fsanitize=fuzzer,address,undefined -fno-sanitize-recover=all
build/pic/fuzz/sqlite3.o: $(PIC_VENDOR)/sqlite3.c
@mkdir -p $(@D)
$(FUZZ_CC) -O1 -g -fsanitize=fuzzer-no-link,address,undefined $(PIC_SQLITE) -w -c -o $@ $<
build/pic/fuzz/fuzz_decode: test/fuzz/fuzz_decode.c src/anthropic.c src/anthropic.h src/sse.c src/sse.h build/pic/fuzz/sqlite3.o
$(FUZZ_CC) $(PIC_WARN) $(FUZZ_FLAGS) -Isrc -isystem $(PIC_VENDOR) -o $@ test/fuzz/fuzz_decode.c src/anthropic.c src/sse.c build/pic/fuzz/sqlite3.o -lm -lpthread
fuzz-decode: build/pic/fuzz/fuzz_decode
@mkdir -p build/pic/fuzz/corpus build/pic/fuzz/findings
build/pic/fuzz/fuzz_decode -max_total_time=$(FUZZ_SECONDS) -max_len=8192 -timeout=10 -dict=test/fuzz/sse.dict \
-artifact_prefix=build/pic/fuzz/findings/ build/pic/fuzz/corpus test/fuzz/decode-seeds