Skip to content

Conversation

@marxin
Copy link
Contributor

@marxin marxin commented Aug 29, 2025

The PR adds the rudimentary support for RISC-V 64-bit target into the SinglePass compiler. Even though, the code still needs some polishing and various TODOs must be addressed, the compiler can pass all (104) the spec tests.

TODOs:

  • unwinding support
  • FP status register - save/restore
  • a general location_cmp + jmp_on_X needs polishing as RISC-V target does not provide a FLAGS register (Singlepass: refactor condition jumps to single fn (jmp_on_condition) #5750).
  • spec/address.wast is flaky (sometimes trap is not properly triggered)
  • basic testing - all compiler tests (including the WASI tests) are green now
  • include RISCV-V in CI by running the tests in qemu

Minor improvements:

  • CLZ, CTZ and POPCOUNT have sub-optimal performance - could be implemented as builtins in the run-time (fn call overhead)
  • still some unimplemented entry points for the Machine trait - wipe unused entry points in the Trait
  • more intensive testing needed (including real hardware + valgrind)

@marxin marxin requested a review from syrusakbary as a code owner August 29, 2025 17:23
theduke and others added 29 commits September 10, 2025 19:37
This is only the basic plumbing and architecture, the actual
implementation is to follow.
@marxin
Copy link
Contributor Author

marxin commented Oct 22, 2025

@syrusakbary The PR is basically ready to be merged. However, it depends on a smaller tweaks to the CI when it comes to testing of riscv64gc target: #5817 #5815 #5809

@marxin marxin force-pushed the singlepass-add-rv64-target branch from 99e77da to 490d62d Compare October 22, 2025 12:57
@marxin
Copy link
Contributor Author

marxin commented Oct 22, 2025

The CI job Run WAST tests on linux-riscv64 is green when running in CI under QEMU. Yay!

Clarify terms regarding Generated Code and licensing conditions.
Copilot AI review requested due to automatic review settings November 13, 2025 14:38
Copilot finished reviewing on behalf of syrusakbary November 13, 2025 14:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds experimental RISC-V 64-bit support to the Wasmer SinglePass compiler, enabling WebAssembly compilation for RISC-V architecture. The implementation includes core instruction encoding, trap handling, unwinding support, and comprehensive test coverage.

Key changes:

  • New RISC-V machine backend with full instruction set implementation (6219 lines)
  • Trap handling and unwinding support for RISC-V architecture
  • CI/CD integration with QEMU-based testing for RISC-V target
  • Test suite adaptations for RISC-V-specific limitations (jump instruction range)

Reviewed Changes

Copilot reviewed 23 out of 26 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/compiler-singlepass/src/machine_riscv.rs Core RISC-V machine implementation with instruction encoding and code generation
lib/compiler-singlepass/src/riscv_decl.rs RISC-V register definitions and calling convention support
lib/compiler-singlepass/src/emitter_riscv.rs RISC-V instruction emitter (not shown in diff)
lib/vm/src/trap/traphandlers.rs Added RISC-V trap code extraction from illegal instructions
lib/compiler-singlepass/src/unwind.rs RISC-V DWARF unwinding support
tests/compilers/issues.rs Test adaptations for RISC-V limitations and Cranelift workaround
lib/compiler-singlepass/Cargo.toml Added tempfile dependency and riscv feature flag
.cargo/config.toml RISC-V cross-compilation and QEMU runner configuration
.github/workflows/build.yml CI integration for RISC-V WAST test suite
lib/compiler-singlepass/README.md Updated documentation to list riscv64 as experimental target

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@marxin
Copy link
Contributor Author

marxin commented Nov 24, 2025

The PR received a couple of fixed that very identified and reduced from running the RISC-V Singlepass compiler on tests for the following Rust crates:

  • aho-corasick
  • bstr
  • bytesize
  • glob
  • indexmap
  • itertools
  • itoa
  • memchr
  • quickcheck
  • rustc-demangle
  • rust-shlex
  • rust-url
  • ryu
  • strsim-rs
  • strum
  • time
  • tinyvec
  • unicode-ident
  • uuid

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.

4 participants