-
Notifications
You must be signed in to change notification settings - Fork 215
Description
This is a follow-up to #547. I've determined that the difference in code size is down to libc and libcxx being compiled using -O3 instead of -Oz.
Emscripten rebuilds and caches the sysroot libraries based on the compiler flags you provide, so if you compile your own code using -Oz, Emscripten will too. wasi-sdk, on the other hand, builds the toolchain and the sysroot as part of the same process and ships precompiled libraries. It's not straightforward to build the sysroot using a prebuilt toolchain.
Building wasi-libc using custom settings isn't too difficult, although pointing future builds to use the custom-built wasi-libc is a bit annoying. It's pretty easy for a WebAssembly project to include wasi-libc as a Git submodule and build it as part of their own build process.
Building libcxx is more involved, since it's part of LLVM. The CMake configurations and such are part of this repo. Building libcxx requires:
- Cloning this repo, including all of
llvm-project. Even a shallow clone takes a while because LLVM is huge. - Making sure you check out the repo version corresponding to the released wasi-sdk version you'll use to build it.
- Using the prebuilt wasi-sdk toolchain to build the wasi-sdk sysroot using your desired settings.
As such, I'm wondering if it would make sense to release source distributions of wasi-libc, libcxx, libcxxabi, and compiler-rt (plus wasi-sdk-sysroot.cmake). This would allow for easily rebuilding the full sysroot without cloning the entire LLVM repo.