Description
Ref. #65895
We need a way to ship the WASI SDK to users (as a nupkg). Currently, for builds, we're using binaries shipped out of the WebAssembly wasi-sdk.git releases page.
I'm investigating this process.
wasi-sdk consists of three git submodules:
- Upstream
llvm/llvm-project.git
- Upstream
WebAssembly/wasi-libc.git
- Upstream
https://git.savannah.gnu.org/git/config.git
(GNUconfig.guess
/config.sub
scripts)
These are used to build FIVE projects in turn (or three, depending on how you count):
- LLVM Clang (
lld;clang;clang-tools-extra
subsets) withWebAssembly
codegen andwasm32-wasi
default compiler triple. This needs to be built once for every platform we want to be able to build Wasi apps on - Wasi libc (twice, one threaded one not), using the above Clang, to instantiate a sysroot folder. This only needs to be built once, and can be consumed on any OS
- LLVM Compiler-RT (lib/builtins folder specifically, i.e. to generate
libclang_rt.builtins-wasm32.a
). This only needs to be built once, and can be consumed on any OS - LLVM libc++. This only needs to be built once, and can be consumed on any OS.
- GNU config. This isn't compiled, a few files are just copied around.
The existing metabuild system in charge of dispatching the above builds is GNU Make. This needs replacing with something we support, e.g. MSBuild (we have experience using MSBuild as a metabuild system, e.g. for LLVM or ICU)
There are a few approaches we can take on how best to get this built.
- Treat wasi-sdk as its own standalone thing, which means at least another full-scale build of LLVM. We have changes we would want to apply to the LLVM repo (like support for overriding the copyright on produced executables), so the easiest route here might be altering the submodule reference to point at our LLVM fork, either a new branch or an existing branch
- Try to build a suitable LLVM as part of our existing LLVM build, i.e. add WebAssembly to the list of codegen targets and add any needed binaries to the LLVM.Sdk nupkgs. A major downside is if we add functionality to our existing LLVM binaries, we can't change default settings like "use this target by default and this sysroot by default"), which would alter the behaviour of our binaries vs. upstream wasi-sdk. We might be able to squeeze a completely alternative build out of the existing LLVM repo, which means more disk consumption for end users (who would have duplicate copies of binaries, some from the vanilla LLVM build and some from the special Wasi build). Additionally, our LLVM version does not necessarily match what WASI has integration-tested. The documentation claims it's fine to do so, but we're into uncharted waters
- Something more drastic, e.g. build the whole wasi-sdk package out of our llvm-project.git by pulling in the needed files (and not using wasi-sdk.git itself directly at all, since all it provides by itself is a metabuild which we need to rewrite anyway)
I'm starting to lean towards option 2, with a "damn the consequences" approach to command line flags, but I think the discussion is worth having.