Skip to content

build: support rv64im zkVM target via lower-atomic pass#27

Open
Andrurachi wants to merge 1 commit into
paradigmxyz:mainfrom
Andrurachi:feat-support-rv64im-llvm-4
Open

build: support rv64im zkVM target via lower-atomic pass#27
Andrurachi wants to merge 1 commit into
paradigmxyz:mainfrom
Andrurachi:feat-support-rv64im-llvm-4

Conversation

@Andrurachi
Copy link
Copy Markdown
Contributor

addresses #4

Adds support for compiling to rv64im (without atomics) by utilizing the LLVM lower-atomic pass.

  • Adds custom target riscv64im-unknown-none-elf.json (features: +m).
  • Uses RUSTFLAGS="-C passes=lower-atomic" to lower atomics in upstream dependencies (safe for single-threaded zkVMs).
  • Updates check_no_std.sh and CI to use nightly and -Zbuild-std=core,alloc.

@Andrurachi Andrurachi force-pushed the feat-support-rv64im-llvm-4 branch from aadb22b to 19f7c6c Compare May 20, 2026 20:21
@Andrurachi
Copy link
Copy Markdown
Contributor Author

Taking over the rv64im effort from @lazovicff PR #26. Implemented the lower-atomic LLVM pass as suggested by @kevaundray in issue #4

Comment thread README.md Outdated

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.
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.

this reads as if users can pass the built-in --target riscv64im-unknown-none-elf, but that target still fails here because alloc::sync is cfg-gated off

Comment thread scripts/check_no_std.sh
target=targets/riscv64im-unknown-none-elf.json

cmd=(cargo +stable build --no-default-features --target "$target" -p stateless)
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

@Andrurachi Andrurachi force-pushed the feat-support-rv64im-llvm-4 branch from 19f7c6c to 03d8eaa Compare May 28, 2026 20:22
@Andrurachi
Copy link
Copy Markdown
Contributor Author

Great catches. Thanks!

I just pushed a commit that updates the README and adds a warning comment above the RUSTFLAGS export.

@Andrurachi Andrurachi requested a review from figtracer May 28, 2026 21:06
Copy link
Copy Markdown
Collaborator

@figtracer figtracer left a comment

Choose a reason for hiding this comment

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

i believe this is ready to merge as-is

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