Skip to content

Add riscv64 host platform support #607

@gounthar

Description

@gounthar

Summary

WASI SDK currently ships pre-built binaries for six host platforms (x86_64 and arm64 on Linux, macOS, Windows). I'd like to request adding riscv64-linux as a supported host platform.

Context

I successfully built WASI SDK v30 from source on native RISC-V hardware (Banana Pi F3, SpacemiT K1, rv64gc, 16 GB RAM, Debian Trixie). The build completes with zero source code patches ; only cmake flags and one post-install symlink are needed.

The full process is documented in a blog post: Building WASI SDK on RISC-V

Four workarounds required

All are cmake flags or symlinks, no source modifications:

  1. Stage 2 needs Stage 1 Clang (not system GCC):
    -DCMAKE_C_COMPILER="$INSTALL_DIR/bin/clang" / -DCMAKE_CXX_COMPILER="$INSTALL_DIR/bin/clang++"

  2. Skip native compiler test (Stage 1 Clang only targets wasm32):
    -DCMAKE_C_COMPILER_WORKS=ON / -DCMAKE_CXX_COMPILER_WORKS=ON

  3. Skip WASIP2 targets (wit-bindgen/wasm-tools/wkg don't ship riscv64 binaries):
    -DWASI_SDK_TARGETS="wasm32-wasi;wasm32-wasip1"

  4. Fix resource dir path: symlink clang-resource-dir/liblib/clang/21/lib

Build stats

Metric Value
Stage 1 (LLVM+Clang+LLD) ~8-10 hours
Stage 2 (wasi-libc sysroot) ~15-20 minutes
Installed SDK size 244 MB
hello-world.wasm output 105 KB
Source patches needed 0
WASI SDK version built 30.2g1033443e5c36
Clang version 21.1.4-wasi-sdk

What this enables

With WASI SDK on riscv64, developers can do fully self-hosted WebAssembly development on RISC-V: C/C++ source → Clang (native rv64) → .wasm → iwasm (native rv64), with no x86 or ARM host needed.

This is part of a broader effort proving the full WebAssembly stack works on RISC-V, including WAMR and the Ocre runtime.

Proposal

I'd be happy to contribute:

  • A CI workflow (or additions to existing CI) for riscv64 builds (likely QEMU-based initially)
  • Build documentation for native riscv64 compilation
  • Testing on real RISC-V hardware

The main blocker for full WASIP2 support is the lack of riscv64 binaries for wit-bindgen, wasm-tools, and wkg (Rust tools from bytecodealliance). WASIP1 works fully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions