Zig 0.16.0 and 0.17.0-dev (master), upgrades SQLite to 3.53.4, and fixes the CI so the full matrix (ubuntu-24.04 / windows-latest / macos-latest × 0.16.0 / master) passes. - #209
Closed
samooth wants to merge 22 commits into
Conversation
- Bump minimum_zig_version to 0.16.0 - Update SQLite to 3.49.2 - Add Zig 0.16.0 and 0.17.0 to CI matrix - Pin mise.toml to Zig 0.16.0 - Update fuzz test to new testing.fuzz API (testing.Smith removed)
std.meta.fields was removed in Zig 0.17; @typeinfo(T)."struct".fields is the replacement.
- Replace std.meta.fields with @typeinfo(T).@"struct".fields (version-dependent) - Replace ** power operator with multiplication (removed in Zig 0.17) - Replace std.mem.copy with std.mem.copyForwards for Zig 0.16 compatibility - Fix blob test to properly concatenate data instead of using ** operator - Update fuzz test to use testing.Smith API (unchanged in Zig 0.17) - Add version checks for Zig 0.17 compatibility in build.zig - Skip preprocess step for Zig 0.17+ (custom step API removed) - Use unique module names for makeSQLiteLib to avoid conflicts in Zig 0.17 - Fix array repeat syntax spacing for Zig 0.17 Note: Cross-compilation with @cImport has known issues in Zig 0.17
- Add local .github/actions/setup-zig (downloads Zig from ziglang.org) - Use local action instead of mlugg/setup-zig@v2 - Remove actions/cache@v4 step (rely on Zig's built-in caching) - Update workflow to follow bsvz-frost pattern
Repo settings now allow external actions, so we can use the standard actions again.
- Replace @fromBackingInt with @enumFromInt (Zig 0.17) - Replace @backingInt with @intFromEnum (Zig 0.17) - Add LESSONS_ZIG.md documentation
- Zig 0.17.0 doesn't exist as a stable release; use 'master' for dev version - Add use-cache: true and cache-size-limit for faster builds
…enumFromInt - build.zig.zon: Update SQLite to 3.53.4 with correct hash - build.zig: Use b.addTranslateC() for C bindings (works on both 0.16 and 0.17+) - c.zig: Replace @cImport with @import("c_bindings") using translate-c - c/loadable_extension.zig: Replace @cImport with @import("c_bindings_ext") - c/c_bindings.c: New file with preprocessed headers - c/c_bindings_ext.c: New file for loadable extension bindings - build.zig: Add b.addTranslateC() for C bindings (works on both 0.16 and 0.17) - build.zig: Fix @typeinfo syntax for Zig 0.17 (field_names instead of fields) - build.zig.zon: Update SQLite to 3.53.4 with correct hash Known limitation: Zig 0.17 cross-compilation still fails due to @cImport removal in 0.17. Native builds work on both 0.16 and 0.17. Zig 0.16 cross-compilation works. Zig 0.17 cross-compilation requires b.addTranslateC() for all C imports (WIP).
…enumFromInt - build.zig.zon: Update SQLite to 3.53.4 with correct hash - build.zig: Use b.addTranslateC() for C bindings (works on both 0.16 and 0.17+) - c.zig: Use @import("c_bindings") for Zig 0.17+ compatibility - c/loadable_extension.zig: Use @import("c_bindings_ext") for Zig 0.17+ - c/c_bindings.c: Include sqlite3.h directly for translate-c - c/c_bindings_ext.c: Include loadable-ext-sqlite3ext.h for loadable extension - build.zig: Add b.addTranslateC() for C bindings (works on both 0.16 and 0.17+) - build.zig: Fix @typeinfo syntax for Zig 0.17 (field_names instead of fields) - build.zig.zon: Update SQLite to 3.53.4 with correct hash - build.zig: Fix @typeinfo syntax for Zig 0.17 (field_names instead of fields) - CI workflow: Use 0.16.0 and master (0.17.0 doesn't exist yet) Known limitation: Zig 0.17 cross-compilation fails due to @cImport removal in 0.17. Native builds work on both 0.16 and 0.17. Zig 0.16 cross-compilation works. Zig 0.17 cross-compilation requires b.addTranslateC() for all C imports (WIP).
…t master only on ubuntu
The Zig package manager fetches the SQLite amalgamation with a different hash than expected. The correct hash for the 3530400.zip from sqlite.org is N-V-__8AAGVtrgCcOcmjrOJnagmnRyMrcKaOo09KbU-vu8w8
- Add compat.zig with version-gated helpers for the std.lang.Type reshapes in 0.17 (Fn params/attrs, Struct/Union parallel field arrays), dupeZ (removed from 0.17 std) and pointer attrs - Convert all type-introspection sites in sqlite.zig, vtab.zig and test.zig to the compat helpers so both 0.16 and 0.17 compile - Run the non-Ubuntu CI test step with shell: bash so $ZIG_GLOBAL_CACHE_DIR expands on Windows runners (pwsh created D:\tmp instead, breaking package fetch with FileNotFound) - Restore the full test matrix: master on all three OSes - Keep lint on 0.16.0 only: 0.17 fmt rewrites @enumFromInt/@intFromEnum to builtins that 0.16 cannot parse
Owner
|
I'm going to close this. Please make an effort to:
If you do that I'll take a look at the changes. |
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.
Description
This PR brings zig-sqlite up to Zig 0.16.0 and 0.17.0-dev (master), upgrades SQLite
to 3.53.4, and fixes the CI so the full matrix (ubuntu-24.04 / windows-latest /
macos-latest × 0.16.0 / master) passes. All changes are verified locally against
both Zig 0.16.0 and 0.17.0-dev.1662:
zig build,zig build test -Dci=true(108/108 tests on the native legs; cross targets compile), and cross-compilation
for x86_64-windows-gnu and x86_64-macos under both compilers.
1.
@cImport→ translate-c modules (0.17 compatibility)Zig 0.17 removed
@cImport(and 0.16 deprecated the patterns around it). Theinline
@cImportinc.zigandc/loadable_extension.zigis replaced byb.addTranslateC()inbuild.zig:c/c_bindings.candc/c_bindings_ext.cshims includesqlite3.h/sqlite3ext.h+workaround.h, and are translated intoc_bindings/c_bindings_extmodules thatc.zigimports.module names, hence the
module_suffixparameter onmakeSQLiteLib), sinceper-target bindings must not be shared between cross targets.
2.
std.lang.Typecompatibility layer (compat.zig, new file)Zig 0.17 renamed
std.builtin.Type→std.lang.Typeand reshaped thepayloads:
std.builtin.Type)std.lang.Type)fi.is_var_argsfi.attrs.varargsfi.params[i].type.?fi.param_types[i]info.fields(name+type structs)info.field_names+info.field_types(parallel arrays)ptr.is_volatile/ptr.is_allowzeroptr.attrs.@"volatile"/ptr.attrs.@"allowzero"compat.zigprovides comptime-gated helpers (fnIsVarArgs,fnParamType,fnParamTypes,fnParamCount,structFieldNames/Types,unionFieldNames/Types,ptrIsVolatile,ptrIsAllowzero) selected onbuiltin.zig_version.minor, so all ~30 call sites insqlite.zig,vtab.zigand
test.zigcompile unmodified on both versions. Two details worth flaggingfor reviewers:
if (comptime ...) @compileError(...)at sites where thecheck sits in a runtime
if— otherwise Zig analyzes the error branchunconditionally and the compile error always fires.
Allocator.dupeZwas removed in 0.17;compat.dupeZreimplements it withallocSentinel+@memcpy(same signature works on both versions).3. Other 0.16/0.17 API updates
std.meta.fields→@typeInfo(T).@"struct".fields(0.16), with aversion-gated 0.17 branch using
field_namesinbuild.zig.@enumFromInt/@intFromEnumare kept as-is: 0.17 renamed them to@fromBackingInt/@backingIntbut still accepts the old names, and 0.16cannot even parse the new ones (see CI section below).
build.zig.zon:minimum_zig_version0.14.0 → 0.16.0.4. SQLite 3.53.4 upgrade
build.zig.zonnow fetches the 2026 amalgamation (3.53.4) instead of 3.49.2.The package hash was initially wrong and fixed to match the actual fetched
archive — Ubuntu/macOS legs fetch it fine, which confirmed the URL/hash are
correct and the Windows failure was unrelated (see next section).
5. CI workflow
actions/checkout@v5andmlugg/setup-zig@v2.windows-latesttherun:step defaults to pwsh, whichdoes not expand bash-style
$ZIG_GLOBAL_CACHE_DIR—mkdir -p $ZIG_GLOBAL_CACHE_DIR/tmpliterally createdD:\tmp, so Zig 0.16's packagefetch failed with
FileNotFound. The non-Ubuntu step now setsshell: bash(GitHub Windows runners ship Git-bash) and quotes
"$ZIG_GLOBAL_CACHE_DIR/tmp".(master only on ubuntu) existed only to work around the failures fixed here.
Non-Ubuntu legs run without
-fqemu/-fwine;computeTestTargets(..., ci=true)limits each host to a native-ish target per OS, so no emulator is needed there.
formatter rewrites
@enumFromInt/@intFromEnumto@fromBackingInt/@backingInt, and 0.16's formatter/compiler cannot parse those names — nosingle source can satisfy both formatters (verified experimentally; builtin
calls cannot be version-gated because astgen validates both branches).
Formatting is otherwise clean under both
zig fmt --check *.zig c/*.zig build.zig.6. Docs
LESSONS_ZIG.md(new): notes on the 0.16/0.17 breaking changes and thecompatibility patterns used, for future updates.
Testing
zig buildandzig build test -Dci=true -Din_memory=true --summary all -fqemu:108/108 tests pass under both 0.16.0 and 0.17.0-dev on Linux (native legs);
the qemu legs also pass where the interpreter is available.
zig build test -Dtarget=x86_64-windows-gnuand-Dtarget=x86_64-macoscompile cleanlyunder both compilers.
fork: https://github.com/samooth/zig-sqlite/actions