Skip to content

zig: migrate to Zig 0.17 nightly - #140

Open
ajroetker wants to merge 6 commits into
mainfrom
claude/zig-0.17-nightly-install-35lAX
Open

zig: migrate to Zig 0.17 nightly#140
ajroetker wants to merge 6 commits into
mainfrom
claude/zig-0.17-nightly-install-35lAX

Conversation

@ajroetker

Copy link
Copy Markdown
Contributor

Bring the Zig build files up to the 0.17.0 configurer/maker split announced in
the 2026-05-26 devlog, tested against nightly 0.17.0-dev.607+456b2ec07:

  • Replace removed b.args observation with run.addPassthruArgs(); default-arg
    benches now always add their defaults and append passthru args after.
  • Replace removed b.getInstallPath() with b.graph.path(.install_prefix, ...).
  • Move compile-time test filtering from b.args to a repeatable -Dtest-filter
    option, declared once and threaded into selectTestFilters.
  • Drop the now-unused *std.Build param from forwardBuildArgs.

Both the top-level and delegated pkg/inference builds now configure cleanly
under the nightly. These files now require Zig 0.17+. Documents the remaining
blocker (removal of the ** repeat operator, ~1646 sites) in zig/ZIG.md.

@ajroetker
ajroetker force-pushed the claude/zig-0.17-nightly-install-35lAX branch 9 times, most recently from b346569 to c2d7cf9 Compare June 4, 2026 23:40
@ajroetker
ajroetker force-pushed the claude/zig-0.17-nightly-install-35lAX branch from c2d7cf9 to d4dbcf9 Compare June 5, 2026 00:14
ajroetker added 5 commits June 9, 2026 21:35
The branch targeted 0.17.0-dev.607, which is no longer available and no
longer compiles against current 0.17 nightlies. Update the source to build
against 0.17.0-dev.813, covering the std.builtin.Type reflection redesign
and related API changes:

- std.builtin.Type reflection: the old `.fields` slice was replaced by
  parallel `field_names` / `field_types` / `field_values` / `field_attrs`
  arrays. Migrate all reflection sites (enum/struct/union) to the new API.
  `.fields.len` -> `.field_names.len`; loops iterate the parallel arrays.
  A handful of reflection-heavy files (json/simd_typed, prometheus,
  structlog, handlebars) use a small file-local helper that rebuilds the
  old field-descriptor shape on top of the new arrays.
- std.meta.fields was removed; replace callers with native @typeinfo access.
- std.builtin.Type.StructField.Attributes -> Type.Struct.FieldAttributes
  (protobuf codegen).
- std.builtin.Type.Pointer.is_const -> Pointer.attrs.@"const" (simd_typed).
- build.zig: snowball module registered with createModule instead of
  addModule (addModule now rejects duplicate names).
- Bump minimum_zig_version to 0.17.0-dev.813.

Builds clean with `zig build install`; unit tests pass (one pre-existing
async enrichment test is flaky and passes on re-run in isolation).

https://claude.ai/code/session_01FLxCviUvUYVetVy9NMy8qi
…ly-install-35lAX

Brings 76 commits from main onto the Zig 0.17 (dev.813) migration branch.

Conflict resolution / dev.813 fixups for code merged from main:
- build.zig (recall-harness run step): kept main's `stdio = .inherit` and the
  branch's idiomatic `addPassthruArgs()` (the two are complementary).
- backends.zig: `std.meta.fields(BackendType).len` -> `std.meta.fieldNames(...).len`
  (std.meta.fields was removed in 0.17).
- index.zig / segment.zig test helpers: `[_]u8{0} ** 64` -> `@as([64]u8, @Splat(0))`
  (the `**` repeat operator no longer parses in dev.813).
- pkg/inference/build.zig: drop `b.sysroot` (removed from std.Build in 0.17),
  matching the top-level build.zig's darwin-SDK handling.
- inference cache nowNs(): `std.posix.clock_gettime` -> `std.c.clock_gettime`
  (std.posix.clock_gettime / std.time.Instant were removed in 0.17; clocks moved
  behind std.Io). Latent until main added a ResultCache caller in the test path.

Builds clean with `zig build install`; `zig build unit-test` passes on dev.813.

https://claude.ai/code/session_01FLxCviUvUYVetVy9NMy8qi
The branch's build.zig.zon requires 0.17.0-dev.813 but CI still pinned
0.17.0-dev.607, so every job failed on the new reflection APIs. Bump all
workflow pins (zig-tests, release, release-preflight, container) and fix
the port gaps that dev.607 never exercised:

- std.fmt.bufPrintZ was removed; migrate to bufPrintSentinel in the
  Metal decoder runtime and bench helpers.
- Provide the onnx_c/ortgenai_c/mlx_c/blas_c translate-c binding modules
  to inference_internal and the inference test root (previously only the
  inference module got them, breaking -Dsystem-blas=true test builds).
- The dev.813 build runner passes output file args as cwd-relative
  paths; resolve explicitly-relative join_openapi/join_public_openapi
  args against cwd instead of the repo root.
- The table create/drop test fake stored the handler's transient
  schema_json slice, which the handler frees; dev.813's allocator unmaps
  freed pages, turning the latent use-after-free into a segfault. Keep
  an owned copy.
Two intermittent unit-test failures under load, both memory-safety bugs:

1. HBC getVectorInto/getVectorViewOrScratchWithCursor/getVectorScratch
   returned the vector cache's internal copy on a cache miss instead of
   the caller-scratch-backed view. The cache entry is unpinned, so any
   later vector load can evict it and free the memory while the caller
   still holds the view. Split paths batch vector views before consuming
   them (loadTransformedVectorIdsIntoMatrix), so once a leaf accumulated
   more members than the cache budget, earlier views dangled and splits
   computed centroids from recycled heap. The garbage centroids were
   committed, making every routing distance inf and eventually failing
   descent with error.Corrupted. Timing-gated split deferral only grows
   leaves that large under load, which is why this never reproduced
   solo. Cache as a side effect and return the stable view.

2. collectLiveIndexStatusSnapshot and dbIndexStats read text index
   state via the raw snapshot() accessor, which is only safe without
   concurrent writes; merge finish swaps the writer snapshot and
   releases the old one mid-read on the applied-sequence persist path.
   Hold a refcounted acquireSnapshot()/release() around all field reads
   and take doc_count and term_count from the same held snapshot.
…ly-install-35lAX

Conflict resolutions and 0.17 port of newly merged main code:
- c_file.zig: keep the posix_c.zig shim (0.17 removed @cImport); main's
  _FORTIFY_SOURCE workaround only applied to the translate-c path.
- db.zig: main independently fixed the text snapshot race with
  acquireSnapshot(); take main's cheaper persist-path snapshot (no
  term_count walk) and keep the refcounted stats-path read.
- lsm_backend.zig: keep @Splat initializers (0.17 removed the ** repeat
  operator) and add main's new bulk-ingest scan clone stats fields.
- Port merge-introduced 0.16 idioms: ** array repeats -> @Splat,
  Allocator.dupeZ -> dupeSentinel, @typeinfo(...).@"enum".fields ->
  field_names.
@ajroetker ajroetker changed the title zig: migrate build system for Zig 0.17 nightly (b.args -> addPassthruArgs) zig: migrate to Zig 0.17 nightly Jun 11, 2026
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