On this page

0210. Cache FFI builds with complete dependencies

Context

Repeated native programs and interpreter FFI helpers need not compile unchanged C again. ADR-0067 requires complete input identity; declared shims alone are not enough, nor does hashing yesterday's selected files detect new search-path inputs.

Decision

Support Linux GCC drivers and compiler-selected GNU bfd ld only, with understood CC/FFI flags. Capture system-inclusive GCC dependencies and bfd dependency/trace output during the single compile/link. Hash lexical input paths' resolved contents with SHA-256, including libraries, crt objects and simple GROUP/INPUT scripts and their referenced libraries. Symlinks are resolved again on validation.

Before reuse require a fresh preprocessing dependency set and hashes to match; compare nonrecursive, sorted name/type/symlink-target library-directory witnesses (compiler defaults, -L, LIBRARY_PATH, and cwd). Bound each listing to 20,000 entries. Reject time macros, thin archives, unknown scripts/search directives, unsupported options/toolchains and doubtful or missing captures. Never show linker traces. Capture-option failure retries the original command and keeps existing diagnostics.

The base SHA-256 covers the byte-identical ADR-0067 preimage, ordered resolved flags, format marker, compiler executable content, selected components and specs. Store one SHA-256-checked immutable dependency/executable/warnings bundle in ffi-v1, using ADR-0067 atomic publication/restoration and its own 256 MiB FIFO cap. Replay warnings once. Source distinguishes helpers from native programs. Ordinary v1 behavior and FMT_VERSION remain unchanged; HARNESS_NO_CACHE=1 disables both.

Alternatives considered

Consequences

Warm builds preprocess and hash inputs but do not compile/link. Cache errors are misses, never new user errors. Build inputs must remain stable during compilation; observed content/listing changes or post-start modification times stop publication, not arbitrary concurrent mutation or hidden stateful compiler-wrapper behavior.