zigself icon indicating copy to clipboard operation
zigself copied to clipboard

Build fails for WASM

Open russellallen opened this issue 2 years ago • 1 comments

This is more a placeholder, but it would be really interesting if this could be made to work.

Anyway:

$ zig build -Dtarget='wasm64-freestanding' 

/snap/zig/5245/lib/std/os.zig:148:24: error: container 'system' has no member called 'fd_t'
pub const fd_t = system.fd_t;
                       ^
self...The following command exited with error code 1:
/snap/zig/5245/zig build-exe /home/ubuntu/unsynced/zigself/src/main.zig --cache-dir /home/ubuntu/unsynced/zigself/zig-cache --global-cache-dir /home/ubuntu/.cache/zig --name self -target wasm64-freestanding -mcpu generic --pkg-begin zig-args /home/ubuntu/unsynced/zigself/vendor/zig-args/args.zig --pkg-end --enable-cache 
error: the following build command failed with exit code 1:
/home/ubuntu/unsynced/zigself/zig-cache/o/18529e68d6f8a7e61818891986977bb7/build /snap/zig/5245/zig /home/ubuntu/unsynced/zigself /home/ubuntu/unsynced/zigself/zig-cache /home/ubuntu/.cache/zig -Dtarget=wasm64-freestanding

Or:

$ zig build -Dtarget='wasm64-wasi'

./src/runtime/primitives/system_call.zig:69:29: error: container 'std.os.wasi' has no member called 'open'
    const rc = std.os.system.open(&null_terminated_path, @intCast(u32, flags), 0);
                            ^
./src/runtime/primitives.zig:116:88: error: expected type 'fn(runtime.primitives.PrimitiveContext) std.mem.Allocator.Error!?runtime.Completion', found 'fn(runtime.primitives.PrimitiveContext) @typeInfo(@typeInfo(@TypeOf(runtime.primitives.system_call.Open_WithFlags_IfFail)).Fn.return_type.?).ErrorUnion.error_set!?runtime.Completion'
    .{ .name = "Open:WithFlags:IfFail:", .arity = 3, .function = system_call_primitives.Open_WithFlags_IfFail },
                                                                                       ^
self...The following command exited with error code 1:
/snap/zig/5245/zig build-exe /home/ubuntu/unsynced/zigself/src/main.zig --cache-dir /home/ubuntu/unsynced/zigself/zig-cache --global-cache-dir /home/ubuntu/.cache/zig --name self -target wasm64-wasi -mcpu generic --pkg-begin zig-args /home/ubuntu/unsynced/zigself/vendor/zig-args/args.zig --pkg-end --enable-cache 
error: the following build command failed with exit code 1:
/home/ubuntu/unsynced/zigself/zig-cache/o/18529e68d6f8a7e61818891986977bb7/build /snap/zig/5245/zig /home/ubuntu/unsynced/zigself /home/ubuntu/unsynced/zigself/zig-cache /home/ubuntu/.cache/zig -Dtarget=wasm64-wasi

russellallen avatar May 18 '22 06:05 russellallen

I think the problem is that WASM does not have any syscalls so we will have to shim those somehow. I don't know whether we can use _RunScript on WASM either, as there is no filesystem.

sin-ack avatar May 18 '22 06:05 sin-ack