by _nhynes · 7y ago · 0 comments
If you don't want to pull in musl or a traditional libc, there's a more Wasm-y solution known as the Web Assembly System Interface (WASI) [0] that delegates the libc functionality to the runtime.
A WASI Wasm module can be compiled using clang, as in the article. The only difference is to use the WASI sysroot [1].
> optimization
LTO and -O3 are great! I've also found the Twiggy [2] tool useful for more "manual" optimization.
[0] https://wasi.dev [1] https://github.com/CraneStation/wasi-sdk/releases [2] https://rustwasm.github.io/twiggy/
And definitely agree with the shout-out to Twiggy (which I mention in the previous post in the series)!
Just may be the next step is like rust to have core and std so some minimum subset would be used. But without this option still excellent.
If size is really important, you probably want to try -Os (optimize for size) and -Oz (try harder to optimize for size, including at the expense of CPU) as well.
> LTO
If your project gets big enough that -flto results in unacceptable link times, try -flto=thin.
[1] https://gist.github.com/s-macke/6dd78c78be46214d418454abb667...