4 ms·
Despite the title, this blog post goes very deep into how a compiler generates WASM and what that looks like. Lots of hacks as WASM is pretty unfinished as it
by brabel 3y ago
Despite the title, this blog post goes very deep into how a compiler generates WASM and what that looks like.
Lots of hacks as WASM is pretty unfinished as it is, specially regarding linking different modules and the calling convention. The author used the Zig compiler to figure out how to do those things (Zig just does what C does, it seems).
I've tried doing something similar, but gave up because of that.
- chubot 3y agoYeah I guess the problem is that WASM has only i32 i64 f32 f64, so there's no consensus on what a char* argument or return value looks like? I'm a little surprised that hasn't been worked out by now Most C structs seem to have obvious encodings in WASM ? Or is that not the right way to think about it? There are all sorts of problems with linking with C++ exceptions and so forth, and probably varargs, but I would have thought basic C / Zig stuff would be worked out