Capnproto on wasi/emscripten?

45 views
Skip to first unread message

pepij...@gmail.com

unread,
Jan 22, 2022, 3:43:56 PM1/22/22
to Cap'n Proto
Hey,

I was playing around a bit to see if I could compile capnproto with the wasi-sdk or emscripten. wasi is a "web assembly system interface" that allows running wasm code completely without a JS runtime, while emscripten requires a browser/nodejs runtime. I think both options could be interesting for distributing software in a platform independent way.

However, it seems capnproto doesn't compile out of the box with either. When targeting wasi, it is missing a bunch of things such as pipes, signals, and exceptions as far as I understand from compile errors in kj exception and unix abstraction code. When targeting emscripting it actually compiles but has some missing symbols during linking, also related to exceptions: https://github.com/emscripten-core/emscripten/issues/11985#issuecomment-1019317541

Would there be a way to compile capnproto without these problematic features, or a feasible way to provide wasi-specific stubs for them?

Cheers,
Pepijn

Kenton Varda

unread,
Jan 24, 2022, 5:52:24 PM1/24/22
to pepij...@gmail.com, Cap'n Proto
WASI is essentially a different operating system, POSIX-like but not exactly the same. We will need to add support for it alongside POSIX and Windows.

There's actually a PR open to create a build mode which mostly avoids OS dependencies altogether, which might be a good starting point:

https://github.com/capnproto/capnproto/pull/1376

I'm a little confused about exceptions, though. Exceptions are not an OS feature, they're a programming language feature... how could they not be supported? Cap'n Proto actually does support building with `-fno-exceptions`, so maybe that's a path forward, but there are a lot of caveats...

-Kenton

--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/52be11e2-9fb9-4a9c-831b-f7798703c5c3n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages