crates-build-env
crates-build-env copied to clipboard
Missing WASI SDK support
Affected crates: quickjs-wasm-sys, quickjs-wasm-rs, javy, javy-apis
The four crates above need access to a WASI SDK to compile some vendored C source code to the wasm32-wasi target. Unfortunately I can't find an Ubuntu package for the WASI SDK. There is a wasi-libc package but that's not sufficient since Clang also requires an additional runtime archive file to be installed and that archive file is not part of an Ubuntu package.
From https://github.com/WebAssembly/wasi-sdk:
One could also use a standard Clang installation, build a sysroot from the sources mentioned above, and compile with --target=wasm32-wasi --sysroot=/path/to/sysroot. In this scenario, one would also need the libclang_rt.builtins-wasm32.a objects available separately in the release downloads which must be extracted into $CLANG_INSTALL_DIR/$CLANG_VERSION/lib/wasi/.
The compiled WASI SDK is also too large to vendor given cargo's size limits on crates.
I'm not sure how to proceed.
Hi @jeffcharles
from what I know, there are two typical solutions to this:
- check how other crates that depend on WASI SDK solve the same issue
- use conditional compilation ( with
#[cfg(docsrs)]) to make the crate compile without the SDK, only for docs.rs
I've opened https://github.com/rust-lang/crates-build-env/pull/137 to add a couple packages. I think with those two packages and vendoring the libclang_rt.builtins-wasm32.a archive in the crate, it should be possible to build the C code. It worked in an Ubuntu 22.02 Docker container. I did have to copy the system LLVM to the crate's OUT_DIR to install the vendored archive and use that copy of clang and llvm-ar to build the code but it worked.
Sorry for the delay in responding.
I merged the pr above, though I can only get to deploying the image to our build server next week.
Until then you could try the build using the crates-build-env docker image, when the build is finished.