WebAssembly / WebAssembly/wasi-sdk

Provide a way to rebuild the sysroot with specific compiler flags

Open
#582 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
CMake
Stars
1.6k
Forks
237
Avg merge
18h 26m
Merged PRs (30d)
5

Description

This is a follow-up to https://github.com/WebAssembly/wasi-sdk/issues/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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read issue #547 and the repository's CMake configurations, especially wasi-sdk-sysroot.cmake, to understand the current sysroot packaging and release inputs. Identify how source distributions for wasi-libc, libcxx, libcxxabi, and compiler-rt could be provided; done means the full sysroot can be rebuilt with custom compiler flags without cloning all of llvm-project.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, wasm
Domain
build-system, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.