Skip to content

docs: add riscv64 native build instructions#608

Open
gounthar wants to merge 1 commit intoWebAssembly:mainfrom
gounthar:feat/riscv64-linux-support
Open

docs: add riscv64 native build instructions#608
gounthar wants to merge 1 commit intoWebAssembly:mainfrom
gounthar:feat/riscv64-linux-support

Conversation

@gounthar
Copy link

Summary

Add documentation for building WASI SDK from source on native riscv64 Linux hardware.

The build completes with zero source patches — only cmake configuration flags are needed:

  1. -DCMAKE_C_COMPILER_WORKS=ON to skip compiler test (Stage 1 Clang only targets wasm32)
  2. -DWASI_SDK_TARGETS="wasm32-wasi;wasm32-wasip1" to skip WASIP2 (wit-bindgen/wasm-tools/wkg don't ship riscv64 binaries)
  3. Post-install symlink for the Clang resource directory

Tested on Banana Pi F3 (SpacemiT K1, rv64gc, 8 cores, 16 GB RAM, Debian Trixie) with WASI SDK v30. Full self-hosted loop verified: C → Clang (native rv64) → .wasm → iwasm (native rv64).

Ref: #607

What this enables

Self-hosted WebAssembly development on RISC-V hardware without needing an x86 or ARM host for compilation.

Test plan

  • Built WASI SDK v30 on Banana Pi F3 (rv64gc) following these instructions
  • Compiled hello-world.c to .wasm using the native riscv64 toolchain
  • Ran the .wasm with iwasm on the same board

Document how to build WASI SDK from source on native riscv64 Linux
hardware. The build requires zero source patches — only cmake flags
for skipping compiler tests and limiting to WASIP1 targets.

Tested on Banana Pi F3 (SpacemiT K1, rv64gc, 16 GB RAM, Debian Trixie)
with WASI SDK v30. Stage 1 (LLVM) takes ~8-10 hours, Stage 2 (sysroot)
takes ~15-20 minutes.

Ref: WebAssembly#607
@alexcrichton
Copy link
Collaborator

Thanks for this! I'm not sure that this documentation is all that much different from the README.md though? The extra parts here I think boil down to (a) wasip2/wasip3 can't be built due to host tools not being available and (b) the clang-resource-dir bit which can be fixed by configuring with -DWASI_SDK_INSTALL_TO_CLANG_RESOURCE_DIR=ON.

Given that I think it might be reasonable to add a note in the README about disabling wasip2/wasip3 for non-allow-listed architectures (or perhaps better yet, codify that in CMake). Another possible alternative would be implementing/documenting downloading the wasi-sysroot from this repository and plopping it into a toolchain. There's no need to build the sysroot on all platforms, for example.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants