Hello ziggit community,
I’m upgrading a small library to Zig 0.16.0 and it mostly works. However I cannot get it to compile for wasm32-freestanding target. So I tried to make a minimal reproducible example like so:
$ zig init
$ zig build -Dtarget=wasm32-freestanding
The above build fails already with:
~/zig/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:2064:45: error: struct ‘posix.system__struct_7663’ has no member named ‘getrandom’
and
~/zig/zig-x86_64-linux-0.16.0/lib/std/posix.zig:90:27: error: struct ‘posix.system__struct_7663’ has no member named 'IOV_MAX’
(Note that the same commands work with Zig 0.15.2).
Even after removing juicy main and setting exe.entry = disabled in build.zig somehow Io.Threaded gets pulled into the exe/wasm library. And it looks like wasm32-freestanding does not provide all the posix stuff that std.Io.Threaded needs. I honestly don’t fully understand what’s going on or even how to fix it.
I guess my question is: How to compile a zig library for wasm32-freestanding in 0.16.0?
Thanks!