Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing WASI SDK support #136

Open
jeffcharles opened this issue Aug 14, 2023 · 3 comments
Open

Missing WASI SDK support #136

jeffcharles opened this issue Aug 14, 2023 · 3 comments

Comments

@jeffcharles
Copy link
Contributor

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.

@syphar
Copy link
Member

syphar commented Aug 15, 2023

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

@jeffcharles
Copy link
Contributor Author

I've opened #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.

@syphar
Copy link
Member

syphar commented Aug 18, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants