Open eliot-akira opened 1 month ago
Actual errors if you build it correctly:
src/introspect.zig:41:9: error: this function is unsupported on WASI
@compileError("this function is unsupported on WASI");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/introspect.zig:85:9: error: on WASI the global cache dir must be resolved with preopens
@compileError("on WASI the global cache dir must be resolved with preopens");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/std/posix.zig:145:28: error: root struct of file 'c' has no member named 'sockaddr'
pub const sockaddr = system.sockaddr;
~~~~~~^~~~~~~~~
lib/std/c.zig:1:1: note: struct declared here
const std = @import("std");
Command (change your paths to whatever matches your system):
~/release.z/zig-linux-x86_64-0.14.0-dev.311+c50f30038/zig build -Dtarget=wasm32-wasi -Doptimize=ReleaseSmall --zig-lib-dir ~/git/ziglang/zig/lib
Thank you for the response.
OK, so I'll set the options as suggested, especially --zig-lib-dir
to point to lib
in the source directory. I did make sure to use the same version of the compiler as the source to compile itself.
Maybe this should have been posted as a question in the forums, or a feature request for an additional target in ziglang/zig-bootstrap.
Seems to be a regression
Zig Version
0.13.0
Steps to Reproduce and Observed Behavior
Clone Zig and compile the compiler to
wasm32-wasi
target.It results in errors.
Expected Behavior
The Zig compiler can be compiled to
wasm32-wasi
target for running in the browser.Attempts toward a solution
The closest solution I found is in the Zig Playground repo, specifically
ZIG_WASM.md
.It's a patch that allows the compilation to succeed. I'll include it below for reference.
Notably, I found the patch only works for Zig version
0.11
.Versions above
0.11
result in compile errors related toos.realpath()
. I think the following issue is related:On version
0.13
, for example, after applying the patch and running below (removed deprecated option-Dno-autodocs
and added option-freference-trace
recommended by the error message).The error: