Hacker News new | past | comments | ask | show | jobs | submit login

There's nothing really standard, every environment will have its own APIs. WASI is not going to run in a web browser without additional modules.

If system calls are not required, code can be compiled to `wasm32-freestanding`. That works everywhere, as it ensures that there are no dependencies on external APIs.

When specifically targeting WASI, the code should be compiled to `wasm32-wasi`. That can be done using `clang`, with the addition of a specific libc and the `libclang_rt.builtins-wasm32.a` file.

But the easiest and probably most common way is to use `zig cc`, followed by `-target wasm32-wasi` or `-target wasm32-freestanding`.

For the web, or any environment with Javascript around, Emscripten remains by far the easiest way to go, since it provides a really amazing POSIX emulation.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: