Zig's build system rewrite: incremental by default, cache-first

4 min read 1 source explainer
├── "Treating the build as a stateful, long-running program is the right architectural bet for modern languages"
│  ├── Andrew Kelley / Zig core team (ziglang.org devlog) → read

The Zig team argues that incremental compilation must be a first-class property of the build system, not a bolted-on optimization. By making the compiler a persistent process that holds the AST and semantic graph in memory across invocations, and by content-addressing every step against its full input set, they claim `zig build` can deliver order-of-magnitude faster edit-compile cycles than a Make-style step graph ever could.

│  └── top10.dev editorial (top10.dev) → read below

The editorial frames Zig's move as staking out a third position between Rust's bolt-on incrementalism and Go's keep-it-simple compiler — treating the build itself as a stateful program rather than a script that re-runs from zero. It positions this as a defining strategic bet for the language's developer experience.

├── "Unifying C/C++ and Zig caching through `zig cc` is the underrated win"
│  ├── Andrew Kelley / Zig core team (ziglang.org devlog) → read

The devlog highlights that `zig cc` object files now share the same content-addressed store as Zig code, giving mixed-language projects unified incremental behavior without a separate caching layer. The team presents this as a practical advantage for real-world codebases that span multiple languages, where build-system fragmentation is usually the bottleneck.

│  └── top10.dev editorial (top10.dev) → read below

The editorial calls out the `zig cc` integration as a meaningful differentiator, noting that the unified cache spans Zig and C/C++ without bolting on a separate system like sccache. This is positioned as evidence that Zig is designing for real polyglot codebases rather than only greenfield Zig-only projects.

└── "Zig is moving toward Bazel-style content-addressed builds, validating that approach for general-purpose toolchains"
  └── top10.dev editorial (top10.dev) → read below

The editorial draws the explicit comparison to Bazel's content-addressed action graph, arguing that Zig is bringing hermetic, cache-keyed build semantics out of the monorepo-tooling niche and into a general-purpose language toolchain. The implication is that the techniques large companies built for Bazel are becoming table stakes for any serious language ecosystem.

What happened

The Zig devlog entry dated 2026-05-26 lays out a ground-up rework of the language's build system. Andrew Kelley and the core team are replacing the existing `std.Build` step-graph model — the one most Zig users know from `build.zig` files — with an execution engine designed around incremental compilation as a first-class property, not an afterthought. The HN thread hit 334 points within hours, which for a build-system post is a meaningful signal.

The headline mechanical changes: the compiler now runs as a persistent process during a build, holding the parsed AST and analyzed semantic graph in memory across invocations. Build steps are content-addressed against their full input set (source files, compiler flags, transitive dependencies) and cached in a shared on-disk store. File watching is wired in directly rather than left to editor plugins. The net effect is that `zig build` stops looking like Make and starts looking like a long-running daemon that happens to expose a CLI.

The rework also normalizes how `zig cc` — Zig's drop-in C/C++ cross-compiler frontend over LLVM — participates in the cache. C and C++ object files compiled through `zig cc` now share the same content-addressed store as Zig code, meaning a mixed-language project gets unified incremental behavior without a separate caching layer.

Why it matters

Build systems are where ambitious languages either earn a developer base or lose one. Rust spent years convincing people that 10-minute cold builds were the price of safety; the Cargo team has been clawing that back ever since with incremental compilation, sccache, and the still-experimental `cargo-build-server`. Go went the opposite direction — fast compiles were a founding constraint, and the toolchain has barely changed in a decade. Zig is now staking out a third position: treat the build itself as a stateful program, not a script that re-runs from zero.

The practical comparison is Bazel. Bazel's content-addressed action cache and remote execution model are what large monorepos at Google, Stripe, and Pinterest depend on for sub-minute incremental builds across millions of lines of code. The cost is the ecosystem: WORKSPACE files, Starlark rules, the need for a dedicated build team. Zig's pitch is that you can get most of the cache discipline without leaving `build.zig` — a normal Zig file with normal control flow. Whether that scales past hobby projects is the open question, and the devlog is honest that the answer isn't proven yet.

The community reaction on HN clustered around three reactions. The Zig believers see this as the missing piece that makes the language viable for large C/C++ replacement projects — the kind of work TigerBeetle and Bun have been doing in production. The skeptics point out that persistent compiler processes have a long history of memory leaks and cache invalidation bugs (the Scala incremental compiler, Zinc, took the better part of a decade to stabilize). And the C/C++ contingent showed up specifically for `zig cc`: for a lot of teams, Zig's most useful export is not the language but a sane, cacheable cross-compiler for their existing C codebase.

It's worth noting what this is not. It's not remote execution — there's no distributed cache server in this rework, no Bazel-style RBE. It's not a hermeticity model — Zig builds still touch the host filesystem in ways Bazel sandboxes prevent. And it's not 1.0. Andrew Kelley has consistently refused to ship a 1.0 until self-hosted, incremental, and the build system are all solid. This devlog is one of the last big pieces of that picture.

What this means for your stack

If you're already using Zig: expect `build.zig` files to mostly keep working, but watch the migration notes carefully. The step-graph API is being preserved as a compatibility layer, but the underlying execution model has changed enough that subtle behaviors — particularly around custom build steps that shell out to other tools — will need to be audited. The win is real: full rebuilds of large projects should drop from tens of seconds to single digits once the cache is warm.

If you're using `zig cc` as a cross-compiler for a C or C++ project — and a lot of teams quietly are, because it's the easiest way to target musl-libc Linux from a Mac — you get the new cache for free. A mid-sized C project that takes 90 seconds with `make` and `gcc` can routinely land under 10 seconds incremental with `zig cc` plus the new cache, with zero changes to your existing Makefiles beyond the compiler swap. That's a meaningful productivity delta for embedded and systems work where compile cycles dominate the inner loop.

If you're evaluating Zig against Rust for a greenfield systems project, the build story just got materially better. Rust's incremental compilation is mature but still painful at scale; Cargo's caching is per-crate and doesn't easily share across CI runners without third-party tooling like sccache or `cargo-chef`. Zig's content-addressed cache is shareable across machines by design, even if the remote-cache server doesn't exist yet — someone will build it within a year, and the protocol surface is small enough that it won't be a heavyweight dependency.

Looking ahead

The interesting second-order effect is what this does to the `zig cc` use case. Right now, Zig's biggest growth vector isn't new Zig code — it's existing C and C++ projects adopting `zig cc` as a better cross-compiler. Incremental builds on top of that means the on-ramp gets shorter and the value lands sooner. Andrew Kelley's long-running thesis has been that Zig wins by being the best toolchain for C, not by replacing C — and this rework is that thesis compiling. Watch for the 0.15 or 0.16 release where this actually ships; that's the version where the language stops being a curiosity and starts being a serious build-system option for teams that have given up on Bazel but still want sub-second incremental builds.

Hacker News 355 pts 239 comments

Zig: Build System Reworked

→ read on Hacker News

// share this

// get daily digest

Top 10 dev stories every morning at 8am UTC. AI-curated. Retro terminal HTML email.