Skip to content

build: migrate to Zig 0.16.0#28

Merged
ratazzi merged 5 commits into
masterfrom
feat/zig-016
Jul 16, 2026
Merged

build: migrate to Zig 0.16.0#28
ratazzi merged 5 commits into
masterfrom
feat/zig-016

Conversation

@ratazzi

@ratazzi ratazzi commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Supersedes #27 (closed automatically when its stacked base branch was deleted after #26 merged; GitHub cannot reopen it). Content is identical — see #27 for the original description and green CI run.

Summary

Migrates the codebase from Zig 0.15.2 to 0.16.0. Also fixes CI: macos-latest runners now ship an Xcode whose libSystem.tbd only declares arm64e-macos, which 0.15.2's linker cannot resolve; 0.16.0 handles it (this is why #26's checks were red on unmodified code).

Commits

  • chore: ignore the local zig package mirror
  • build: zig 0.16.0 + dependency bumps (vaxis 0.6.0/uucode 0.2.0, clap 0.12.0, zeit 0.9.0, zig-toml 00c5715e — each the last revision supporting 0.16)
  • feat: std.process.Init main convention + src/global_io.zig process-wide Io accessor
  • refactor(dns): resolver ported to std.Io.net.HostName.lookup (behavior note: zig's own resolver instead of libc getaddrinfo)
  • refactor: bulk mechanical migration (~60 files) — fs/time/process/sync behind std.Io, Writergate fallout, unmanaged containers, libc fallbacks (Io.Dir.setFileOwner upstream bug, musl translate-c limits), CoreFoundation cImport consolidation with _MACH_MESSAGE_H_ guard

Verified

  • macOS aarch64: build (Debug + ReleaseSmall), tests 9/9, fmt clean
  • Cross-compile: x86_64-linux-musl, aarch64-linux-musl
  • Linux runtime smoke (Alpine, static aarch64): version + full provision run
  • macOS smoke: provision, node-info; host = macOS 26.5.1 + Xcode 26.6, no SDK workarounds

Known behavior deltas

  • DNS resolution path; custom-nameserver queries capped at 16 results
  • std.process.run forces stdin .ignore on capture-and-wait helpers
  • chown helpers pass -1 to preserve ids (drops a TOCTOU)
  • Guard-reap ECHILD no longer panics

ratazzi added 5 commits July 16, 2026 23:37
- zig 0.16.0 via mise; minimum_zig_version 0.16.0
- vaxis 0.5.1 -> 0.6.0 (pulls uucode 0.2.0), clap 0.11.0 -> 0.12.0,
  zeit 0.6.0 -> v0.9.0, zig-toml -> 00c5715e — each the last revision
  supporting zig 0.16 (masters already require 0.17-dev)
- build.zig: link/include APIs moved from Compile to root_module;
  zon parse via fromSliceAlloc; drop duplicate libgit2 config on the
  test step (it shares exe.root_module)
zig 0.16 threads an explicit std.Io through fs/time/process/net APIs.
main now uses the std.process.Init entry convention (gpa, io, environ,
args provided by start code) and stores io/environ in global_io.zig so
the rest of the codebase — including mruby C callbacks that cannot take
an io parameter — can access them. Unit tests fall back to the blocking
single-threaded Io. global_io also provides getEnv/getEnvOwned replacing
the removed std.process env APIs.
std.net was removed in zig 0.16. Hostname resolution now goes through
std.Io.net.HostName.lookup draining an Io.Queue (capped at 16 results),
replacing getAddressList; nameserver sockaddr conversion uses
std.Io.Threaded.addressToPosix; the raw UDP DNS query keeps its
behavior via libc std.c.socket/sendto/recv since the std.posix socket
wrappers were also removed.

Note: the system-resolver path previously used libc getaddrinfo; zig's
own resolver reads /etc/resolv.conf and /etc/hosts directly, so mDNS
(.local) and scoped-resolver setups may behave differently.
Mechanical migration of the removed/relocated 0.15 std APIs:

- std.fs.File/Dir/cwd -> std.Io.File/Dir with io threaded as first arg;
  makePath -> createDirPath; readToEndAlloc/readAll/writeAll -> reader/
  writeStreamingAll interfaces; stat fields (permissions, Timestamp)
- std.time sleep/timestamps and std.Thread sleep/Mutex/Condition ->
  Io equivalents (lockUncancelable for the previously-infallible lock)
- std.process Child.init/run/EnvMap/ArgIterator -> process.spawn(io)/
  run(gpa, io)/Environ.Map/Args.Iterator; lowercase Term/StdIo tags
- ArrayList .{} init -> .empty; ArrayList.writer -> Io.Writer.Allocating;
  std.io.fixedBufferStream -> Io.Writer.fixed; json ObjectMap unmanaged
- GeneralPurposeAllocator -> DebugAllocator; crypto.random -> io.random
- posix isatty/waitpid/fchmod/fstatat removed -> Io/libc equivalents;
  chown now passes -1 to preserve ids instead of stat'ing first (musl's
  struct stat does not survive translate-c, and this drops a TOCTOU)
- CoreFoundation cImports consolidated into cf.zig with narrow includes
  plus a _MACH_MESSAGE_H_ guard: 0.16 translate-c cannot handle the
  mach_msg descriptor types pulled in by the umbrella header
- Io.Dir.setFileOwner is broken upstream in 0.16.0 (declared error set
  narrower than the implementation's); link.zig uses libc fchownat
@ratazzi
ratazzi merged commit bb47705 into master Jul 16, 2026
13 checks passed
@ratazzi
ratazzi deleted the feat/zig-016 branch July 16, 2026 15: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.

1 participant