• Sources: mlugg.co.uk, ziglang/zig issue 1535, HN 49085666
  • Summary: A Zig core team member describes how the compiler detects which individual functions and declarations changed, recompiles only those, and patches the resulting bytes into the output binary. The stated measurements are a roughly 5 second initial build of the Fizzy pixel editor followed by 50 to 70 millisecond rebuilds, shown in a silent screen recording. Source files are parsed and lowered to ZIR by AstGen, which is a pure function of file contents, so that stage is parallel and cacheable on disk and has been on by default for years. Semantic analysis is split into four kinds of analysis unit: the layout of a struct or union, the type of a container-level declaration, the value of a container-level const, and the body of a runtime function. Units record dependencies on other units and on hashes of specific source regions, so an edit marks the dependent units outdated. The author states that language design decisions were changed to make this tractable, including some that were contested. The demo requires Zig master, because 0.16.0 has incremental compilation but lacks linker features added since, so users on tagged releases wait for 0.17.0. The work is tracked as ziglang/zig issue 1535, open since 2018.
  • Why it matters: Rebuild latency sets the edit-compile-run loop for every Zig user, and the post names which language rules exist to keep dependency tracking sound rather than presenting the result as a build-system tweak.
  • Follow-up: Watch for 0.17.0 to carry the linker support the demo needs.

send feedback on this story