Notes on incremental builds
July 2, 2026
An incremental build is only as good as its idea of what changed. Most of the trouble I have seen comes from inputs the build tool does not know about: environment variables, generated files, the current date baked into a version string.
A short checklist I now go through when a build is "randomly" slow:
- Are timestamps used anywhere instead of content hashes?
- Does any step write into the source tree?
- Is the compiler version part of the cache key?
- Do tests depend on files outside the declared inputs?
Fixing the second point alone made our rebuilds after a branch switch go from minutes to seconds. Generated code now lives in build/gen and nothing outside build/ is ever written.