libxev
libxev copied to clipboard
How to embed this in wasi
Real goal: I want to implement event loop in wasi and use webassembly as serverless runtime (handling multiple http calls in the same invocation, aggregate / transform the response)
Is there a way I can use this? What would you suggest the approach would be, to port this to a wasi runtime? Like porting to Spin (fermyon) for instance
It seems like libxev has some support for wasi32-wasm. After moving const examples into the if (emit_examples) statement in the build.zig, I managed to get these errors:
/home/ross/.cache/zig/p/libxev-0.0.0-86vtc4b1EgCl0Kvo2Ixmjfl5PgAaJmvCXRIn_n89nCaR/src/backend/wasi_poll.zig:255:32: error: root source file struct 'os.wasi' has no member named 'EVENTTYPE_CLOCK'
.tag = wasi.EVENTTYPE_CLOCK,
~~~~^~~~~~~~~~~~~~~~
/nix/store/hdavfjjqry2czgk7m7g8q7z0nv7g81wd-zig-0.14.0/lib/zig/std/os/wasi.zig:1:1: note: struct declared here
//! wasi_snapshot_preview1 spec available (in witx format) here:
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ross/.cache/zig/p/libxev-0.0.0-86vtc4b1EgCl0Kvo2Ixmjfl5PgAaJmvCXRIn_n89nCaR/src/backend/wasi_poll.zig:377:34: error: root source file struct 'os.wasi' has no member named 'SHUT'
.both => wasi.SHUT.WR | wasi.SHUT.RD,
~~~~^~~~~
/nix/store/hdavfjjqry2czgk7m7g8q7z0nv7g81wd-zig-0.14.0/lib/zig/std/os/wasi.zig:1:1: note: struct declared here
//! wasi_snapshot_preview1 spec available (in witx format) here:
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ross/.cache/zig/p/libxev-0.0.0-86vtc4b1EgCl0Kvo2Ixmjfl5PgAaJmvCXRIn_n89nCaR/src/backend/wasi_poll.zig:583:66: error: cannot @bitCast from 'os.wasi.clockid_t'
switch (wasi.clock_time_get(@as(u32, @bitCast(posix.CLOCK.MONOTONIC)), 1, &now_ts)) {
~~~~~~~~~~~^~~~~~~~~~
/home/ross/.cache/zig/p/libxev-0.0.0-86vtc4b1EgCl0Kvo2Ixmjfl5PgAaJmvCXRIn_n89nCaR/src/backend/wasi_poll.zig:583:66: note: use @intFromEnum to cast to 'u32'
/home/ross/.cache/zig/p/libxev-0.0.0-86vtc4b1EgCl0Kvo2Ixmjfl5PgAaJmvCXRIn_n89nCaR/src/backend/wasi_poll.zig:668:32: error: root source file struct 'os.wasi' has no member named 'EVENTTYPE_FD_READ'
.tag = wasi.EVENTTYPE_FD_READ,
~~~~^~~~~~~~~~~~~~~~~~
/nix/store/hdavfjjqry2czgk7m7g8q7z0nv7g81wd-zig-0.14.0/lib/zig/std/os/wasi.zig:1:1: note: struct declared here
//! wasi_snapshot_preview1 spec available (in witx format) here:
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~