Zig Runtime
Zig runtime requirements, setup, and gotchas for poly-bench
This guide walks through using Zig with poly-bench, from init through run. It covers what gets created, how dependencies work, and common gotchas.
You need Zig installed and available on your PATH. The table below summarizes the requirements.
| Requirement | Details |
|---|---|
| Binary | zig on PATH |
| Version | Zig 0.15+ recommended |
| Verify | zig version |
Install from ziglang.org. If Zig is missing when you run init, poly-bench can offer to install it interactively during poly-bench init.
When you run poly-bench init --languages zig (or select Zig in the interactive flow), poly-bench creates a Zig project under .polybench/runtime-env/zig/:
1.polybench/runtime-env/zig/2├── build.zig3├── build.zig.zon4└── src/5 └── main.zigModern Zig expects the build.zig.zon format to use .name = .pkg_name (enum literal). poly-bench normalizes legacy .name = "pkg" syntax for compatibility.
To add Zig dependencies, use the add command with the --zig flag:
$poly-bench add --zig git+https://github.com/example/pkg.gitThe spec format is git+https://... or https://.... Dependencies are fetched using zig fetch --save=<dep_name> <url>.
Running poly-bench install (or poly-bench build) runs zig fetch to download dependencies into the Zig cache (typically under ~/.cache/zig/p/<hash>/).
When you run poly-bench run, poly-bench generates Zig code and compiles with zig build. The generated code targets Zig 0.15+ primarily. 0.13 and 0.14 use different ArrayList and File APIs, so the generated code includes an __is_zig_13_or_14 branch for compatibility.
For packages written for Zig 0.13 or 0.14, poly-bench patches the loop syntax from for (items) |item, i| to for (items, 0..) |item, i| in cached dependencies for 0.15 compatibility.
ArrayList/File APIs.for (items) |item, i| → for (items, 0..) |item, i| in cached deps for 0.15 compatibility..name = .pkg_name (enum literal). poly-bench normalizes legacy .name = "pkg" syntax.zig fetch --save=<dep_name> <url>. Format: git+https://... or https://....