I recently discovered Gynvael’s Summer GameDev Challenge, which has
a fairly tight limit on the total size for game submissions: 64KiB, all-in.
wasm experience painless. I found out that
clang natively supports compiling
to webassembly without any help from Emscripten, so I decided to see if I could
get it working. The result is a trivial helloworld example using WebAssembly
To start with, we’ll look at the C code:
Next, we need to turn this into a WebAssembly module. Here is the Makefile:
With this, we can build a binary blob
hello.wasm. We can make this much
smaller by adding the various optimization flags but I omitted those for
this to be much harder than it actually is, and was pleasantly surprised with
what it actually took:
Altogether, with various compiler optimizations enabled and all the HTML minified, the hello world program is only 517 bytes.