Artifact c9209a03dfa889fc6af8cda93eb32bd033751cc252a4fc3efc9c857708ad15b5:
- File
Makefile
— part of check-in
[6d70dcc76a]
at
2026-11-12 19:36:41
on branch trunk
— Phase 1: the config parser, the no-change run and the speed bench
suit check parses suit.conf strictly and prints a canonical dump. Any unknown kind or key, duplicate, cycle or dangling name rejects the whole file with its line number.
suit run compares a stamp against the files it names and exits without writing, allocating or printing when nothing changed.
suit bench times suit run against an empty program built the same way and against /usr/bin/true, interleaved, and fails the build when the no-change run costs more than 1 ms over the empty program or 1 MiB more memory. It measured 0.65 to 0.94 ms over, quiet and under load. A system binary starts 0.6 to 1.5 ms faster than any built binary on macOS, so it is shown for information and is not the baseline.
94 unit checks, 100 shell cases and a libFuzzer target for the parser. (user: dmestas, size: 2506) [annotate] [blame] [check-ins using]
# suit: no configure step. Output goes in build/.
CC ?= cc
STD := -std=c23 -Wall -Wextra -Wpedantic -Werror -D_DEFAULT_SOURCE
REL := $(STD) -O2
SAN := $(STD) -O1 -g -fno-omit-frame-pointer -fsanitize=address,undefined \
-fno-sanitize-recover=all
LIB_SRC := src/conf.c src/stamp.c src/bench.c src/platform.c
ALL_SRC := $(LIB_SRC) src/main.c
# Apple's clang has no libFuzzer; Homebrew's llvm does.
FUZZ_CC := /opt/homebrew/opt/llvm/bin/clang
FUZZ_TIME := 60
MUTATE_ITER := 300000
.PHONY: suit check check-budget fuzz clean
suit: build/suit build/empty
# The bench baseline: same compiler and flags as build/suit, nothing in main.
build/empty: test/empty.c Makefile
@mkdir -p build
$(CC) $(REL) -o $@ test/empty.c
build/suit: $(ALL_SRC) src/*.h Makefile
@mkdir -p build
$(CC) $(REL) -o $@ $(ALL_SRC)
build/suit-san: $(ALL_SRC) src/*.h Makefile
@mkdir -p build
$(CC) $(SAN) -o $@ $(ALL_SRC)
build/unit: test/unit.c $(LIB_SRC) src/*.h Makefile
@mkdir -p build
$(CC) $(SAN) -Isrc -o $@ test/unit.c $(LIB_SRC)
check: build/unit build/suit-san build/empty
ASAN_OPTIONS=detect_leaks=0 build/unit
ASAN_OPTIONS=detect_leaks=0 SUIT=build/suit-san sh test/run.sh
check-budget: build/suit build/empty
SUIT=build/suit sh test/budget.sh
fuzz:
@mkdir -p build
@if "$(FUZZ_CC)" $(STD) -fsanitize=fuzzer -x c - -o build/fuzz-probe \
>/dev/null 2>&1 <<< 'int LLVMFuzzerTestOneInput(const unsigned char *d, unsigned long n) { (void)d; (void)n; return 0; }'; then \
$(MAKE) --no-print-directory fuzz-libfuzzer; \
else \
$(MAKE) --no-print-directory fuzz-mutate; \
fi
fuzz-libfuzzer: build/fuzz
@echo "fuzz: libFuzzer, $(FUZZ_TIME) seconds"
@rm -rf build/corpus && mkdir -p build/corpus
@ASAN_OPTIONS=detect_leaks=0 build/fuzz build/corpus test/corpus \
-max_total_time=$(FUZZ_TIME) -max_len=16384 -timeout=10 \
-artifact_prefix=build/ -print_final_stats=1 > build/fuzz.log 2>&1 \
|| { tail -30 build/fuzz.log; exit 1; }
@grep -E 'number_of_executed_units' build/fuzz.log | sed 's/^stat::/fuzz: /'
fuzz-mutate: build/mutate
@echo "fuzz: mutation loop (no libFuzzer available), fixed seed"
@ASAN_OPTIONS=detect_leaks=0 build/mutate test/corpus $(MUTATE_ITER)
build/fuzz: test/fuzz.c $(LIB_SRC) src/*.h
"$(FUZZ_CC)" $(STD) -O1 -g -fsanitize=fuzzer,address,undefined \
-fno-sanitize-recover=all -Isrc -o $@ test/fuzz.c $(LIB_SRC)
build/mutate: test/fuzz.c $(LIB_SRC) src/*.h
$(CC) $(SAN) -DMUTATE_MAIN -Isrc -o $@ test/fuzz.c $(LIB_SRC)
clean:
rm -rf build