Skip to content

zig: move the pin to 0.17.0 - #2600

Merged
whilp merged 6 commits into
mainfrom
zig-0.17
Oct 3, 2026
Merged

whilp merged 6 commits into
mainfrom
zig-0.17

Conversation

@whilp

@whilp whilp commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Moves bin/zig.pin (and build/bom/zig.pin) to zig 0.17.0, with sha256s from ziglang.org's index. The x86_64-linux one was checked against a download.

zig 0.17 splits zig build into a configurer and a maker, renames OptimizeMode, and reworks its cache. This PR follows each change:

  • build.zig:

    • uses b.root in place of b.build_root and std.lang.Optimize (.debug/.safe/.fast) in place of OptimizeMode
    • getInstallPath is gone, because the install prefix belongs to the maker and isn't known when build.zig runs. The checked boot now gets the sanitized directory as an install-prefix LazyPath (make_absolute).
    • configure cache: 0.17 caches build.zig's configuration, keyed only by what it reads through the build API. build.zig lists core/'s headers and reads o/patched.tsv directly, so neither keyed it. I reproduced the first: a header added to core/ went uncopied and its compile failed. A changed vendor patch would have silently built the old trees. Both are now declared with dependOnDirectoryContents / dependOnFileContents, and after the fix the same header case builds.
    • moves off the calls 0.17 deprecates (addDirectoryArg, addFileArg, addPrefixedDirectoryArg, addOutputFileArg, b.dupe, .cwd_relative) to their replacements
  • build/zig.tl:

    • zig build no longer takes --global-cache-dir, so the shared global cache goes in ZIG_GLOBAL_CACHE_DIR instead (Zig.build_environment)
    • passes --cache-poison=disallowed, so a build.zig that would turn the configure cache off (findProgram, say) fails instead of reconfiguring on every build. I checked that a probe poisonCache() panics.
  • ci/cosmic_ci/zig_prune.tl: the pruner now reads 0.17's manifest format:

    • manifests are binary Manifest.File records, named by bare hex, under a new hasher_init key; an input may have an empty path (a prefix's own root)
    • zig build's configuration cache: a manifest that vouches for the file c/<digest>
    • an older zig's <name>.txt manifests, in a cache restored from a build on it, are removed ahead of any output. 0.17 never reads them, so their outputs are orphans here and may go. Leaving them behind would make the older zig trust outputs that are gone. The queue's first 0.17 entry is seeded from main's 0.16 one, so this path is real. An adversarial review found it, and a regression test covers it.

    The known answers come from a cache 0.17 wrote. Run over that cache, the reader resolved all 5,411 non-empty manifests to their outputs.

  • core/compress.c: 0.17's clang analyzer adds core.NullPointerArithm, which flagged data + in_pos when deflate_chunk is called with NULL to flush. The flush now passes "" instead.

Known cost: a restored cache recompiles its C files

After a tar round trip at the same path, bin/zig build boot takes about 100 s on 0.17, against 8 s on 0.16; a second run takes 7 s. The cause is in zig itself, in both 0.17.0 and upstream master. Cache.Manifest.checkInputPath re-hashes a direct input whose stat changed, then compares the result against input_file.digest. addInputPath never computes that digest; it starts as zeros. So any input with a new inode misses, and the compiler adds every C source that way (src/Compilation.zig:1323, :3378). The compile is correct, only slower. Local checkouts share one cache with stable inodes and aren't affected; each CI leg pays it once per restore. A TODO at .github/workflows/ci.yml records it. A minimal reproducer and an upstream report are drafted and not yet filed.

Validation

  • bin/zig build boot, analyze and sanitized pass.
  • o/bin/cosmic test: 3450 tests pass (sandboxed).
  • fix --check ., ci/'s fix --check and build/workflows_test.tl pass.
  • ci/cosmic_ci/zig_prune_test.tl: all 8 pass as CI runs it (unsandboxed). Under the sandbox, test_the_answers_are_the_pinned_zigs can't read ../bin/zig.pin, which fails the same way on main.
  • ci/run-local passes on the head (19df425), fixtures included.
  • Fuzzing: 77 properties across 26 modules, FUZZ_ITERS=1000 and FUZZ_SEED=2600, on the sanitized 0.17 core. All pass.
  • Pruner on a real mixed 0.16 + 0.17 cache: it shrank the caches from 977 MB to 533 MB and 323 MB to 261 MB. Of what it removed, 0.17 rebuilt only strnlen-check (0.2 s).
  • bin/perf, main (0.16) against this branch (0.17), 50 pairs: no regression. All 15 workloads are within noise, and 12 of 15 medians are slightly faster.
  • Core size: +0.4% on x86_64-linux, +0.6% on aarch64-linux, unchanged on aarch64-macos.
  • Adversarial review: a separate agent checked the diff against the 0.16 and 0.17 sources. It found the .txt defect, now fixed; the rest checked out.

TODOs

o/bin/cosmic todos over the changed paths lists one added:

  • .github/workflows/ci.yml:304: a restored cache recompiles every C file. It waits on zig fixing Cache.checkInputPath, which is not yet reported upstream.

Three existing ones were re-checked against 0.17:

  • build.zig:151 (musl debug info): still holds. The checked core has 294 musl units naming the checkout, and 0.17 has no way to pass flags to its libc build.
  • build/zig.tl:616 (SIGINT): still holds, with new wording. zig build execs its maker in zig's pid, which exits on the signal; its compile jobs were seen orphaned and still compiling.
  • .github/workflows/ci.yml:293 (cache growth): the suspect is now named as 0.17's maker (11 MB, global cache) and configurer (22 MB, project cache), each built for the runner's CPU.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CA9Ta9WPb5KjCoDaYyN7qE

claude added 6 commits October 3, 2026 01:37
zig 0.17 splits `zig build` into a configurer and a maker, renames
OptimizeMode to Optimize (with lower-case tags), and reworks its cache:

- build.zig: `b.root` for `b.build_root`; the checked boot's install
  directory as an install-prefix LazyPath, since `getInstallPath` is gone
  (the prefix is the maker's, unknown when build.zig runs).
- build/zig.tl: `zig build` takes no `--global-cache-dir`; the shared
  global cache goes in ZIG_GLOBAL_CACHE_DIR instead.
- ci/cosmic_ci/zig_prune.tl: read 0.17's binary manifests (named by bare
  hex, keyed anew) and its configuration cache (`c/<digest>`); pass by
  the `.txt` manifests an older zig left in a restored cache. Known
  answers taken from a cache 0.17 wrote.
- core/compress.c: the flush passes "" rather than NULL to
  deflate_chunk, which 0.17's analyzer (core.NullPointerArithm) flags.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CA9Ta9WPb5KjCoDaYyN7qE
zig 0.17 caches build.zig's configuration, keyed only by what it reads
through the build API. build.zig lists core/'s headers and reads the
patched-trees manifest directly, so a new header went uncopied (its
compile failed) and a new vendor patch would have built the old trees.
Declare both as configure dependencies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CA9Ta9WPb5KjCoDaYyN7qE
build.zig moves off the calls 0.17 deprecates (addDirectoryArg,
addFileArg, addPrefixedDirectoryArg, addOutputFileArg, b.dupe,
.cwd_relative) to their replacements, ahead of their removal.

bin/zig passes --cache-poison=disallowed, so a build.zig that would
make zig configure again on every build (findProgram, say) fails
instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CA9Ta9WPb5KjCoDaYyN7qE
bin/zig's SIGINT now reaches the maker `zig build` execs in its place,
which exits and leaves its compile jobs orphaned (checked on 0.17). The
CI cache-growth suspect is now the maker and the configurer, each built
for the runner's CPU.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CA9Ta9WPb5KjCoDaYyN7qE
zig 0.17's Cache.checkInputPath compares a direct input whose stat
moved, re-hashed, against a digest nothing computed, so every vendored
source a tar restore gives a new inode recompiles (a 100 s boot where
0.16 took 8 s). Nothing here can keep the inodes; the fix is zig's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CA9Ta9WPb5KjCoDaYyN7qE
…h for

A cache restored from a 0.16 build holds `<name>.txt` manifests that
0.17 never reads; their outputs were orphans here, and superseded ones
were removed while the manifests stayed, so 0.16 restoring the saved
entry would trust an output that was gone (the queue's first 0.17 entry
is seeded from main's 0.16 one). Each such manifest now goes too, ahead
of any output. Also accept an input with an empty path, which 0.17
writes for a prefix's own root, rather than keeping every cache whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CA9Ta9WPb5KjCoDaYyN7qE
@whilp
whilp marked this pull request as ready for review October 3, 2026 04:34
@whilp
whilp added this pull request to the merge queue Oct 3, 2026
Merged via the queue into main with commit 15df85e Oct 3, 2026
9 checks passed
@whilp
whilp deleted the zig-0.17 branch October 3, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants