Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ jobs:
run: ./scripts/run_ef_tests.sh ${{ matrix.trie }}

no-std:
name: no_std (RISC-V)
name: no_std (RISC-V rv64im)
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@nightly
with:
targets: riscv32imac-unknown-none-elf
components: rust-src
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Build stateless for riscv32imac
- name: Build stateless for riscv64im
run: ./scripts/check_no_std.sh
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ let block_access_list = validation.block_access_list;

## `no_std`

The `stateless` crate is `#![no_std]` compatible and builds for RISC-V targets (`riscv32imac-unknown-none-elf`), making it suitable for use in zkVM environments.
The `stateless` crate is `#![no_std]` compatible and builds for the 64-bit RISC-V target (`riscv64im-unknown-none-elf`), making it suitable for use in zkVM environments. Because upstream dependencies currently require atomics, it must be built using the custom target specification provided in `targets/riscv64im-unknown-none-elf.json`.

> **Note:** The build temporarily relies on the LLVM `lower-atomic` pass
> to lower atomic instructions into non-atomic equivalents.

## Running EF tests

Expand Down
14 changes: 12 additions & 2 deletions scripts/check_no_std.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
#!/usr/bin/env bash
set -eo pipefail

target=riscv32imac-unknown-none-elf
target=targets/riscv64im-unknown-none-elf.json

cmd=(cargo +stable build --no-default-features --target "$target" -p stateless)
# Required to prevent __atomic_* references from ending up in the final rlib.
export RUSTFLAGS="-C passes=lower-atomic"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the build still passes if this flag is removed, but the resulting rlibs contain __atomic_* references


cmd=(
cargo +nightly build
--no-default-features
--target "$target"
-Zbuild-std=core,alloc
-Zjson-target-spec
-p stateless
)

echo "Running: ${cmd[*]}"
"${cmd[@]}"
29 changes: 29 additions & 0 deletions targets/riscv64im-unknown-none-elf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"arch": "riscv64",
"code-model": "medium",
"cpu": "generic-rv64",
"crt-objects-fallback": "false",
"data-layout": "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128",
"eh-frame-header": false,
"emit-debug-gdb-scripts": false,
"features": "+m",
"linker": "rust-lld",
"linker-flavor": "gnu-lld",
"llvm-abiname": "lp64",
"llvm-target": "riscv64-unknown-none-elf",
"max-atomic-width": 64,
"metadata": {
"description": "Bare RISC-V (RV64IM ISA)",
"host_tools": false,
"std": false,
"tier": 2
},
"os": "none",
"panic-strategy": "abort",
"relocation-model": "static",
"supported-sanitizers": [
"shadow-call-stack",
"kernel-address"
],
"target-pointer-width": 64
}
Loading