zig: migrate to Zig 0.17 nightly - #140
Open
ajroetker wants to merge 6 commits into
Open
Conversation
ajroetker
force-pushed
the
claude/zig-0.17-nightly-install-35lAX
branch
9 times, most recently
from
June 4, 2026 23:40
b346569 to
c2d7cf9
Compare
ajroetker
force-pushed
the
claude/zig-0.17-nightly-install-35lAX
branch
from
June 5, 2026 00:14
c2d7cf9 to
d4dbcf9
Compare
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
benches now always add their defaults and append passthru args after.
option, declared once and threaded into selectTestFilters.
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.