cd /news/developer-tools/zig-gpu-kernel-for-macos-via-spirv · home › topics › developer-tools › article
[ARTICLE · art-165816] src=ziggit.dev ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

Zig gpu kernel for macOS (via spirv)

Developer Danielkonge published a Zig example on Codeberg that runs GPU kernels on macOS by compiling through the spirv64-vulkan target and converting to Metal with spirv-cross. The developer reported the build system was straightforward, but the main difficulty was finding a clean way to use slices inside the kernel, a limitation that does not arise when compiling directly for amdgcn-amdhsa-none or nvptx64-cuda-none. The developer noted the setup should work cross-platform if spirv-cross is used only to produce .metal files without compiling them via xcrun, and pointed to spirv-cross's recent addition to allyourcodebase as a possible way to simplify the build steps.

read1 min views2 publishedNov 8, 2026

I finally got some time to look at this a bit more, see here. (LLM disclosure: I got lazy with comments and docstrings, and some of the setup was done with LLM help, since I didn’t want to really focus on writing a proper SHA256 implementation without slices that I could use. What I was interested in was just playing with mac GPU kernels in zig code.)

The build system stuff ended up all being pretty easy, and the main annoyance was actually that I couldn’t find a nice way to use slices in the kernel. When compiling directly for amdgcn-amdhsa-none or nvptx64-cuda-none you don’t run into this, but going through spirv64-vulkan it is a problem.

Overall I thought the setup worked pretty well, and if you only use spirv-cross to get .metal files and don’t compile them with xcrun, I guess everything should work well cross platform too.

[As an aside, I saw recently that spirv-cross was added to allyourcodebase, so the build steps might be nicer with that now: https://codeberg.org/allyourcodebase/spirv-cross]

── more in #developer-tools 4 stories · sorted by recency
── more on @zig 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/zig-gpu-kernel-for-m…] indexed:0 read:1min 2026-11-08 · —