Skip to content

chore: upgrade Zig 0.15 → 0.16#89

Merged
MatteoMer merged 4 commits into
mainfrom
chore/zig-0.16-upgrade
Apr 27, 2026
Merged

chore: upgrade Zig 0.15 → 0.16#89
MatteoMer merged 4 commits into
mainfrom
chore/zig-0.16-upgrade

Conversation

@MatteoMer
Copy link
Copy Markdown
Owner

Summary

  • Upgrade Zig toolchain from 0.15.2 to 0.16.0 across all build configs and CI
  • Migrate ~50 files to Zig 0.16's new std.Io interface, stdlib renames, and language changes
  • Zero external dependency changes (all internal path packages)

Key migrations

Old (0.15) New (0.16)
std.Thread.Futex Custom NativeFutex (OS syscalls)
std.time.Timer MonotonicTimer (clock_gettime)
std.fs.cwd().openFile(path, .{}) std.Io.Dir.cwd().openFile(io, path, .{})
std.heap.GeneralPurposeAllocator std.process.Init (main receives allocator)
std.posix.getenv() std.c.getenv()
std.fmt.FormatOptions std.fmt.Options
ArrayListUnmanaged(T){} ArrayListUnmanaged(T).empty
buf.writer(allocator) std.Io.Writer.Allocating pattern
file.writeAll(data) file.writeStreamingAll(io, data)
reader.readNoEof(buf) reader.readSliceAll(buf) / SliceReader

Added utilities

  • MonotonicTimer in debug.zig — cross-platform monotonic timer using clock_gettime
  • NativeFutex in thread_pool.zig — direct OS futex calls (macOS __ulock / Linux futex(2))
  • SliceReader in utils/mod.zig — byte-slice reader with readInt/readByte/readAll for deserialization code

Test plan

  • zig build compiles cleanly (all targets)
  • zig build test passes (all unit tests)
  • zig build fmt clean
  • CI passes (16 jobs)

🤖 Generated with Claude Code

MatteoMer and others added 4 commits April 25, 2026 10:35
Migrate the entire codebase to Zig 0.16.0. Key changes:

- std.Thread.Futex removed → custom NativeFutex using OS syscalls (__ulock on macOS, futex(2) on Linux)
- std.time.Timer removed → MonotonicTimer using clock_gettime(MONOTONIC)
- std.time.nanoTimestamp removed → clock_gettime-based replacement
- std.fs.cwd() → std.Io.Dir.cwd() with io parameter threading
- File operations (openFile, createFile, close, stat, writeAll, readAll) now require io parameter
- std.heap.GeneralPurposeAllocator removed → main() accepts std.process.Init
- std.posix.getenv removed → std.c.getenv
- std.fmt.FormatOptions → std.fmt.Options
- std.fmt.format(writer, ...) → writer.print(...)
- std.io.fixedBufferStream removed → SliceReader utility + std.Io.Writer.fixed
- ArrayListUnmanaged .{} init → .empty (Zig 0.16 requires explicit fields)
- ArrayListUnmanaged .writer(allocator) → std.Io.Writer.Allocating pattern
- reader.readNoEof → reader.readSliceAll
- Build.Step.Compile.addLibraryPath → root_module.addLibraryPath

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace std.c.clock_gettime and std.c.getenv (which require libc) with
Zig-native alternatives that work on Linux without libc:

- Timer: use std.Io.Timestamp.now(io, .boot) via global_single_threaded
- Getenv: scan process environ block from Threaded global (no libc)

This fixes CI failures on Linux where libc is not linked by default.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace ad-hoc workarounds from the 0.15→0.16 migration with proper
std.Io usage:

- Consolidate 6 duplicate MonotonicTimer copies into a single
  io-accepting definition in zolt-pool/timer.zig
- Replace custom SliceReader with std.Io.Reader.fixed(); use concrete
  *std.Io.Writer / *std.Io.Reader in serialization signatures
- Thread io: std.Io from main(init) through prove/verify/run commands,
  ELFLoader, and DoryCommitmentScheme SRS functions
- Replace 70-line NativeFutex (raw __ulock/futex syscalls) with
  std.Io.futexWake / futexWaitUncancelable / futexWaitTimeout
- Remove duplicate nativeGetenv from jolt_device.zig

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use Io.Limit's .limited(n) constructor and ArrayListUnmanaged's
.empty initializer to match the rest of the 0.16 migration.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@MatteoMer MatteoMer merged commit 8bc2fd1 into main Apr 27, 2026
17 checks passed
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