Commit 1cc4c9df

1cc4c9df6a9aMerged

Ryan Seys <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

build: split test/bench compile+link to enable compiler caching

Compiler caches like sccache and ccache only cache pure compile invocations (cc -c source.c -o out.o), not combined compile+link calls that produce executables. The previous test rule did both in one $(CC) call — sccache classified all 278 test compiles as "non-compilation calls" and skipped them, leaving only the 25 build-phase compiles cached.

Splitting the rule into a compile step (cacheable) followed by a link step (uncached, but cheap) unlocks per-test caching. On warm cache, this should drop the test phase from ~3min to ~1min on unchanged tests. Same split applied to the bench rule for consistency.

Verified: all 282 tests pass with the split rule (1m02s locally).

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
1cc4c9df6a9a
Parent
60f1b75ea8d0

MakefilemodifiedView file

@@ -229,7 +229,8 @@
229229 rm -f "[email protected]"; \
230230 ./spinel_parse$(EXE) "$<" "$$ast" 2>/dev/null && \
231231 ./spinel_codegen$(EXE) "$$ast" "$$cfile" 2>/dev/null && \
232- $(CC) $(CFLAGS) -Werror $(SEC_FLAGS) -Ilib "$$cfile" $(SP_RT_LIB) $(LDFLAGS) -lm $(GC_FLAGS) -o "$$bin" 2>/dev/null; \
232+ $(CC) $(CFLAGS) -Werror $(SEC_FLAGS) -Ilib -c "$$cfile" -o "$$cfile.o" 2>/dev/null && \
233+ $(CC) $(CFLAGS) "$$cfile.o" $(SP_RT_LIB) $(LDFLAGS) -lm $(GC_FLAGS) -o "$$bin" 2>/dev/null; \
233234 if [ $$? -eq 0 ]; then \
234235 if [ -f "$<.expected" ]; then \
235236 LC_ALL=C sed 's/\r$$//' "$<.expected" >"$$exp.n"; \
@@ -291,7 +292,8 @@
291292 if [ "$$tty" = 1 ]; then printf '\r\033[K [%d/%d] %s' "$$i" "$$total" "$$bn"; fi; \
292293 $(TIMEOUT10) ./spinel_parse$(EXE) "$$f" /tmp/_sp_b.ast 2>/dev/null && \
293294 $(TIMEOUT10) ./spinel_codegen$(EXE) /tmp/_sp_b.ast /tmp/_sp_b.c 2>/dev/null && \
294- $(CC) $(CFLAGS) -Werror $(SEC_FLAGS) -Ilib /tmp/_sp_b.c $(SP_RT_LIB) $(LDFLAGS) -lm $(GC_FLAGS) -o /tmp/_sp_b_bin$(EXE) 2>/dev/null; \
295+ $(CC) $(CFLAGS) -Werror $(SEC_FLAGS) -Ilib -c /tmp/_sp_b.c -o /tmp/_sp_b.c.o 2>/dev/null && \
296+ $(CC) $(CFLAGS) /tmp/_sp_b.c.o $(SP_RT_LIB) $(LDFLAGS) -lm $(GC_FLAGS) -o /tmp/_sp_b_bin$(EXE) 2>/dev/null; \
295297 if [ $$? -eq 0 ]; then \
296298 $(TIMEOUT60) $(REF_RUBY) "$$f" >/tmp/_sp_b_exp 2>/dev/null; \
297299 ruby_rc=$$?; \
@@ -321,7 +323,7 @@
321323 fi; \
322324 done; \
323325 if [ "$$tty" = 1 ]; then printf '\r\033[K'; fi; \
324- rm -f /tmp/_sp_b.ast /tmp/_sp_b.c /tmp/_sp_b_bin$(EXE) /tmp/_sp_b_exp /tmp/_sp_b_act /tmp/_sp_b_exp.n /tmp/_sp_b_act.n; \
326+ rm -f /tmp/_sp_b.ast /tmp/_sp_b.c /tmp/_sp_b.c.o /tmp/_sp_b_bin$(EXE) /tmp/_sp_b_exp /tmp/_sp_b_act /tmp/_sp_b_exp.n /tmp/_sp_b_act.n; \
325327 echo "Benchmarks: $$pass pass, $$fail fail, $$err error, $$skip skip"; \
326328 if [ $$fail -ne 0 ] || [ $$err -ne 0 ]; then exit 1; fi
327329