cgm-zig / What changes

What changes

cgm-zig is a patch set on Zig 0.16.0. Every new compiler behaviour sits behind a new flag, so a stock invocation behaves like stock Zig.

The rows below are drawn from the repository’s commit messages and verification records. Where the record holds no measurement of a change’s effect, the row says not yet measured and does not claim one. The full table, with every file and commit, is in the README.

“Ships off” means the change is in the build but only runs when you ask for it, because its own measurement came out slower.

A crash becomes a named message

The index grows from 30 to 31 bits, and the limit the report line prints grows with it. assert message 30 to 31 bits 67,108,863 to 134,217,727
Crash and index limit
ChangeWhat the record showsStatus
Running out of room in the compiler’s index table stops with a message naming the thread, the index reached, the limit and the remedy. Stock Zig has only an assert, which release builds remove.Fired live in production twice. The 1,800-module workload then completed where every stock compiler died: exit 0, 18 min 10 s, 18.4 GiB peak (commit a7f31c36).In the promoted build
The index grows from 30 to 31 bits, and the limit the report line prints grows with it.The per-partition ceiling goes from 67,108,863 to 134,217,727. The plan predicted 4 times; the tree measured 2 times, and the correction is recorded where the prediction was made. The functional suite matched its control: identical failure sets, none unique to this tree.In the promoted build

Source rows: (a) in the README.

Messages and reports that name the thing

The error for a file owned by two modules names that file, not whichever importer was scanned first. mod_b.zig:1:1 dupe.zig:1:1 -femit-module-graph JSON before any analysis --time-report-json time report to a file --listen stays quiet
Diagnostics
ChangeWhat the record showsStatus
The error for a file owned by two modules names that file, not whichever importer was scanned first.Before: mod_b.zig:1:1. After: dupe.zig:1:1. Two test snapshots that had pinned the wrong text are tightened, not weakened.In the promoted build
-femit-module-graph writes the resolved module graph as JSON before any analysis.Stock invocations are byte-identical. Effect on a real workload: not yet measured.In the promoted build
--time-report-json <path> writes the time report to a file, without needing a live listener.It made one finding measurable: the linker’s CPU time was 11.2 times its wall time, so it ran beside analysis.In the promoted build
The thread-plan report line stays quiet under --listen, as --time-report already does.A green zig build of a 13-step fixture went from 6 error lines to 0.In the promoted build

Source rows: (b) in the README.

Threading and ordering

The worker count is separated from the number of index partitions, so -j moves workers and leaves the limit alone. std.Thread.Topology physical cores and SMT siblings -j moves workers --step-order layered order by default --analysis-order=layered Ships off reserve of slots linker --child-jobs=keep|share|N Default keep thread-id pool refused by name
Threading
ChangeWhat the record showsStatus
std.Thread.Topology reads physical cores and SMT siblings, limited to the cores the process may use. Unknown stays unknown: never guessed as 1 or half the logical count.7 of 7 test masks match the sysfs reference. The affinity sabotage control: not yet measured.In the promoted build
The worker count is separated from the number of index partitions, so -j moves workers and leaves the limit alone.-j1 gives 8 partitions. 1,200 files at -j64 give the same result as -j1. On a 6-core, 12-thread host the derived limit is 4.00 times the crash’s ceiling, derived from constants; the real workload’s reproduction is not yet measured in the harness. Race freedom is read and type verified only, and named as a residual.In the promoted build
Build steps run in layered order by default (--step-order).13 steps: 3.567 s layered, 3.631 s random, 3.760 s declared. A weak result, inside the noise against random.In the promoted build
--analysis-order=layered, a priority over work that would be analysed anyway.+6.59% slower than insertion order in 3 of 3 paired runs, so it stays off. The new optional index behind it has no end-to-end timing yet.Ships off
A reserve of slots keeps the linker from being starved by bulk work.0 of 881 thread samples were parked waiting. The deliberate-failure controls: not yet measured.In the promoted build
zig build --child-jobs=keep|share|N passes -j to child compilers. Default keep.share cut peak worker threads from 35 to 10 but was 6.55% slower in 3 of 3 paired runs, so the default stays keep. A small fixture is where share costs most; a large project could invert it.share ships off
A hang the patch set itself caused (a starved thread-id pool) is refused by name.Found by the harness and fixed in the same run: 0 hangs in 6 configurations, where the first build hung.In the promoted build

Source rows: (c) in the README.

Checks before compiling

Without the flag, output is byte-identical to upstream. ast-check --module-graph file’s imports ast-check many files at once Compilation.resolveEmitPath pub
Pre-compile tooling
ChangeWhat the record showsStatus
zig ast-check --module-graph=<path> file.zig checks a file’s imports against the module graph and ends with one summary you can reconcile.Without the flag, output is byte-identical to upstream. Effect on a workload: not yet measured.In the promoted build
zig ast-check takes many files at once, with a machine-readable --json report.Memory stays flat: 400 files at 7.6 MB. Beyond that: not yet measured.In the promoted build
One word: Compilation.resolveEmitPath becomes pub, because the module graph code calls it from another file.After the fix the type check reports 0 errors and the stage 3 build exits 0.In the promoted build

Source rows: (d) and (e) in the README.

Every change to the compiler’s source since Zig 0.16.0 was imported: 20 commits, 22 files, 4,618 lines added and 285 removed across those commits. Read from the repository’s history by a script, not typed by hand.
Commits that change the compiler
DateChangeFilesLines
2026-08-22InternPool: refuse by name when the per-thread Index space is exhaustedsrc/InternPool.zig+44 −1
2026-08-22Crown stage 0: -femit-module-graph — the compiler emits its resolved module graph as JSONlib/std/zig.zig, src/Compilation.zig, src/Compilation/EmitModuleGraph.zig and 2 more+230 −0
2026-08-22Crown stage 0.5 rung 1: import-aware ast-check (--module-graph)src/AstCheckImports.zig, src/main.zig+293 −0
2026-08-22Crown stage 0.5 rung 3: ast-check batch mode with honest denominators + --jsonsrc/AstCheckBatch.zig, src/AstCheckImports.zig, src/main.zig+778 −38
2026-08-22Zcu: name the double-owned file in the file-exists-in-multiple-modules diagnosticsrc/Zcu.zig, src/Zcu/PerThread.zig+14 −1
2026-08-22patch/005a: std.Thread.Topology -- physical cores and SMT siblings, affinity-maskedlib/std/Thread.zig, lib/std/Thread/Topology.zig, src/ThreadPlan.zig and 1 more+823 −22
2026-08-22patch/005b: split the worker count from the InternPool partition countsrc/Compilation.zig, src/InternPool.zig, src/Sema.zig and 4 more+420 −52
2026-08-22patch/005c: edges-first ordering -- layered at the step level, ranked inside the compilationlib/compiler/build_runner.zig, src/Compilation.zig, src/Compilation/ModuleRanking.zig and 3 more+620 −7
2026-08-22rider 1: Io.Threaded -- stop io.async from eating io.concurrent's admission budgetlib/std/Io/Threaded.zig, src/main.zig+59 −2
2026-08-22rider 2: -j reaches child compilers -- share the machine instead of handing out N copieslib/compiler/build_runner.zig, lib/std/Build.zig, lib/std/Build/Step/Compile.zig+138 −0
2026-08-23Compilation: resolveEmitPath becomes pub -- main has not compiled since Crown stage 0src/Compilation.zig+1 −1
2026-08-23ThreadPlan: the topology line stops speaking into the build runner's IPC channelsrc/ThreadPlan.zig, src/main.zig+39 −10
2026-08-23main: --time-report-json -- the timing instrument becomes readable by a scriptsrc/main.zig+103 −2
2026-08-23rider 2: the --child-jobs default reverts to keep -- share lost its own gatelib/compiler/build_runner.zig+40 −8
2026-08-23InternPool: CaptureValue widening -- Index goes 30 -> 31 bits, and the 32nd bit has an ownersrc/Air.zig, src/InternPool.zig+213 −59
2026-08-23main: --time-report-json refuses --listen by name instead of silently writing nothingsrc/main.zig+13 −0
2026-08-23ThreadPlan: index_bits 30 -> 31, and every published ceiling doubles with itsrc/ThreadPlan.zig+19 −6
2026-08-23ThreadPlan: a starved tid pool is now impossible to derive and refused when asked forsrc/ThreadPlan.zig, src/Zcu.zig, src/main.zig+205 −18
2026-09-06Ready-set index and diagnostic release preparationsrc/InternPool.zig, src/Zcu.zig, src/Zcu/PerThread.zig and 2 more+546 −51
2026-09-06Fix opt-in debug logging admission in safe compiler buildssrc/main.zig+20 −7

How it was checked

The repository keeps a verification harness of 38 rows that register themselves. After three defects in the harness were fixed without relaxing any row, its final table reads 22 green, 2 red, 9 unknown and 4 inconclusive. The two reds are the two features that ship off. The harness found the hang and the noisy report line above; neither was a row someone had queued. Source: (f) in the README.

What is not claimed

Which Zig version

0.16.0 is the base and the patch target. Version 0.17 enters only after upstream promotes it to stable; the 0.17 development line failed on the motivating workload from language changes alone, before reaching the crash. Source: README, “What the fork does not change”.