add riscv64im-unknown-openvm-elf tier 3 target#3
Conversation
0edc748 to
f1281db
Compare
22b86aa to
8f068e6
Compare
|
Should we change the target to some |
ada9892 to
a5da1ed
Compare
can't we just close the pr after review and maintain the changes in the branch?
probably not, but the release workflow did work and we have a tarball |
We can, but given that this is a target we want to maintain, I'd just say we rename the branch to something more official |
jonathanpwang
left a comment
There was a problem hiding this comment.
The change in platform-support.md is the main fix. Otherwise please address the other more minor comments and it will be good for me
df4da48 to
0b54c11
Compare
There was a problem hiding this comment.
added stubs for now. we can consider adding a HINT_TIME later
|
i addressed all comments. can you take a look again? i had to squash the commits so it's easier to trigger a release |
Add the OpenVM RV64IM tier-3 Rust target, std/PAL support, panic_abort integration, release workflows for prebuilt toolchains, and target documentation. The prebuilt guest std is built with lower-atomic and the release workflow verifies shipped guest rlibs do not contain unsupported RISC-V A-extension atomics before packaging.
0b54c11 to
f967520
Compare
jonathanpwang
left a comment
There was a problem hiding this comment.
I did targeted re-review, LGTM. I made follow-up ticket around hint time.
49930ba
into
riscv64im-unknown-openvm-elf
… build system (#2765) ## Summary Integrate the built-in Rust target `riscv64im-unknown-openvm-elf` (`target_os = "openvm"`) into the OpenVM build system and guest crates, enabling `std` support for guest programs. The target itself was added to the OpenVM Rust fork in [openvm-org/rust#3](openvm-org/rust#3). Prebuilt toolchain tarballs are published on the fork's [Releases](https://github.com/openvm-org/rust/releases) page — install via `cargo openvm toolchain install` (this PR) or the CI helper script. ### Changes - **Build system** (`crates/toolchain/build/src/lib.rs`): - Set `DEFAULT_RUSTC_TARGET = "riscv64im-unknown-openvm-elf"` (overridable via `OPENVM_TARGET`). - Set `DEFAULT_RUSTUP_TOOLCHAIN_NAME = "openvm-nightly-2026-01-18"` (overridable via `OPENVM_RUST_TOOLCHAIN`); guest builds invoke `cargo +<toolchain> build --target <target>` directly, using the prebuilt `std`/`core`/`alloc`/`panic_abort` rlibs that ship in the toolchain. - Add `ensure_openvm_toolchain_linked()` — verifies the linked toolchain has the guest target's prebuilt rlibs in its sysroot before invoking cargo. - **Guest runtime** (`crates/toolchain/openvm/`): - New `pal_abi.rs`: provides `sys_write`, `sys_panic`, `sys_rand`, `sys_halt`, `sys_argc`/`sys_argv`, `sys_getenv`, `sys_read`, and `sys_alloc_aligned` symbols that the upstream `std` PAL declares. Bridges to OpenVM's custom RISC-V instructions via `openvm_riscv_guest`. `sys_rand` uses a byte-level ABI (`*mut u8, nbytes: usize`) with a `hint_buffer_bytes` helper that handles non-dword-aligned tails via a stack scratch buffer; `sys_getenv` returns `usize::MAX` per the upstream "unset" contract. - Simplify the `entry!` macro: a single `cfg(openvm_intrinsics)` branch emits `#[no_mangle] fn main()` for both `std` and `no_std` guests. The custom `_start` defined via `global_asm!` (now using `asm_const` for `STACK_TOP`) replaces std's default entry. - **Platform** (`crates/toolchain/platform/`): - Update `target_os = "none"` cfg gates to `any(target_os = "none", target_os = "openvm")` so target-gated deps (e.g. `libm`) resolve under either form. - Change `fileno` constants from `u32` to `i32` to match POSIX `RawFd` / the PAL's `sys_write(fd: i32, …)` signature. Drop unused `JOURNAL` fd. - **CLI** (`crates/cli/src/commands/toolchain.rs`): - New `cargo openvm toolchain {install, uninstall, list}` subcommand. `install` downloads the prebuilt tarball from openvm-org/rust Releases for the host triple, extracts it under `~/.openvm/toolchains/`, and runs `rustup toolchain link`. Supports `--version <tag>` and `--force`; idempotent re-installs skip the relink via an `is_link_to` check. - **CI helper** (`ci/install-openvm-toolchain.sh`): - Bash equivalent of `cargo openvm toolchain install` for repo workflows. Linux/macOS host detection, idempotent installs (skips the download when the target's rlib dir already exists). Wired into the `extension-tests`, `continuations`, `sdk.cuda`, `guest-lib-tests`, `riscv`, and `cli` workflows. - **Guest programs (~100 files)**: - Update `no_main` cfg gate to `cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)`. - Update 45 guest `Cargo.toml`s' `unexpected_cfgs` check-cfg to include `cfg(openvm_intrinsics)` and `cfg(target_os, values("openvm"))` so stable-rustc host checks recognise the new `target_os` value. - **`riscv-guest`** (`extensions/riscv/guest/src/io.rs`): - New `hint_buffer_bytes(*mut u8, nbytes)` — byte-granular wrapper over the dword-granular `hint_buffer_chunked`, with a stack scratch dword for the trailing `0..8` bytes. - Mark `hint_buffer_chunked` `unsafe fn` (raw pointer write) and add SAFETY blocks at the three callers in `crates/toolchain/openvm/src/io/{mod,read}.rs`; existing callers in `moduli-macros` codegen and the pairing libs were already inside `unsafe` blocks. ## Test plan ### Install the toolchain ```bash cargo openvm toolchain install # or `bash ci/install-openvm-toolchain.sh` ``` This downloads `rust-toolchain-<host>.tar.gz` from the [openvm-org/rust release](https://github.com/openvm-org/rust/releases/tag/openvm-nightly-2026-01-18) and links it as `openvm-nightly-2026-01-18`. ### Test results - `cargo nextest run -p openvm-riscv-integration-tests --run-ignored all` — local pass. - Guest builds: `cargo openvm build` on `examples/algebra` (moduli-macros path) and `examples/pairing` (direct `hint_buffer_chunked` callers) compile clean against the linked toolchain. - CI: all guest-touching workflows (`extension-tests`, `continuations`, `sdk.cuda`, `guest-lib-tests`, `riscv`, `cli`) install the toolchain via the script and pass on this branch. - Benchmarks show no regression. - [x] Toolchain install path works end-to-end via both the CLI and the bash helper - [x] Guest builds succeed with `cargo openvm build` - [x] CI passes (all non-CUDA-gated checks) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Resolves INT-7635, INT-7654 --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Ayush Shukla <ayush@axiom.xyz>
Add riscv64im-unknown-openvm-elf as a tier 3 Rust target for the OpenVM zero-knowledge virtual machine (RV64IM ISA). The target includes std support via the OpenVM platform abstraction layer.