Skip to content

Provide a way to rebuild the sysroot with specific compiler flags #582

@valadaptive

Description

@valadaptive

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions