Skip to content

Fix build with Zig 0.17.0 - #719

Merged
AlbertShown merged 3 commits into
mainfrom
fix/zig-0.17
Oct 5, 2026
Merged

AlbertShown merged 3 commits into
mainfrom
fix/zig-0.17

Conversation

@jinzhongjia

Copy link
Copy Markdown
Member

Follow-up to #703. With the Zig 0.17.0 release, build.zig still fails to compile, both for this repository and for every package that depends on webui (for example zig-webui):

build.zig:83:52: error: no field named 'Debug' in enum 'lang.Optimize'

Changes

  • Optimize mode tags: Zig 0.17 renamed std.builtin.OptimizeMode to std.lang.Optimize and lowercased its tags. addLinkerFlags now picks .debug or .Debug based on the Zig version.
  • Configure cache: Zig 0.17 caches the configure phase, so zig build examples did not notice example directories added or removed under examples/C after the first run. The directory listing is now declared with b.dependOnDirectoryContents.
  • CI: added 0.17.0 to the Zig matrix, alongside 0.16.0.

Verification (macOS arm64, Zig 0.16.0 and 0.17.0)

Command 0.16.0 0.17.0
zig build -Dverbose=debug pass pass
zig build -Ddynamic -Dverbose=debug pass pass
zig build examples pass pass
zig build -Doptimize=ReleaseSafe pass pass
zig fmt --check build.zig pass see note
  • -Ddebug=civetweb drops -DNDEBUG in Debug and keeps it in ReleaseSafe, so the debug check behaves the same as before.
  • On 0.17, adding examples/C/<new> is now picked up by the next zig build examples; before this change the new example was silently skipped.
  • Note: 0.17's zig fmt wants to rewrite the existing @intFromEnum calls to @backingInt, which does not exist on 0.16. @intFromEnum is only deprecated on 0.17, so it is kept as is.

Zig 0.17 renamed `std.builtin.OptimizeMode` to `std.lang.Optimize` and
lowercased its tags, so comparing against `.Debug` no longer compiles.
This breaks every package that depends on webui as well. Pick the tag
by Zig version to keep 0.16 building.
Zig 0.17 caches the configure phase, so `zig build examples` did not
pick up example directories added or removed after the first run.
Declare the directory listing with `dependOnDirectoryContents`.
@jinzhongjia

Copy link
Copy Markdown
Member Author

@AlbertShown Hey, can you merge this? The zig 0.17.0 has been released!

@AlbertShown
AlbertShown merged commit f1b28ee into main Oct 5, 2026
52 checks passed
@AlbertShown

Copy link
Copy Markdown
Member

Thank you @jinzhongjia for the Zig upgrade

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.

2 participants