So many different wasm build targets

Hi everyone! I’ve built two games for the web using Odin, one with TIC-80 and my own bindings and one with Raylib template. When i was building the TIC-80 game i’ve struggled trying to make a compatible wasm build for that fantasy console. There are many diffrent wasm targets like “freestanding_wasm32” (that one worked for me with TIC-80), “js_wasm32”, “wasi_wasm32” etc. But I couldn’t understand the whole thing about what’s different between them. The only thing that I got is that in the freestanding_wasm32 there’s no default context.allocator available and you need to provide one by yourself, wile js_wasm32 has some allocator that uses browser API.

So I’ve got interested what else is or is not available when using different targets but couldn’t find any information about that. Is there something i’ve missed? I know they’re for different use cases (browser, no-browser, wasi runtime, etc) but I think there should be better explanation what can be done with each of them and what requires your attention.

Thanks you!

1 Like

Only has two wasm architectures:

  • wasm32
  • wasm64p32

That latter is a pseudo-architecture which still has the normal 32-bit pointers but has a 64-bit int (i.e. size_of(uint) > size_of(uintptr)). This is kind of similar to say x32 on Linux (x32 ABI - Wikipedia).

The first part of any target is the “OS”, as such. The current supported ones are:

2 Likes

Would it be possible to also do an “OS” for Emscripten, similar to how Zig does it?

Would make it easier to use from Odin some of the libraries that depend on Emscripten JS APIs for their WASM builds. There are ways to do it, but not as straightforward as it could be.

We are never going to support Emscripten. It’s effectively a set of bodges bodged together. I would never recommend it for anyone.

3 Likes