Skip to content

Commit 5b5e109

Browse files
jonathanpwangarayikhalatyan
authored andcommitted
feat(docs): update target docs (#2)
1 parent 0bd4f94 commit 5b5e109

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

‎src/doc/rustc/src/platform-support/riscv32im-unknown-openvm-elf.md‎

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**Tier: 3**
44

5-
OpenVM's zero-knowledge Virtual Machine (zkVM) implementing the RV32IM instruction set.
5+
Target for [OpenVM](https://github.com/openvm-org/openvm/) virtual machines with the RV32IM ISA and custom RISC-V extensions defined through OpenVM's extension framework.
66

77
## Target maintainers
88

@@ -11,45 +11,50 @@ OpenVM's zero-knowledge Virtual Machine (zkVM) implementing the RV32IM instructi
1111

1212
## Background
1313

14-
This target is an execution environment to produce a verifiable proof of execution of
15-
an RV32IM RISC‑V ELF binary and any output that the developer wishes to make public.
16-
The VM executes the ELF and emits artifacts that can be verified to ensure the integrity
17-
of the computation and its results. This target is implemented in software only; there is
18-
no hardware implementation. See the [OpenVM Book] for architecture and usage.
14+
This target is an execution environment to produce a verifiable cryptographic proof of execution of
15+
a RISC‑V ELF binary and any output that the developer wishes to make public.
16+
The execution environment is implemented as a virtual machine in software only. The target is not intended for bare metal hardware. The virtual machine may be extended to support custom RISC-V instruction sets, which may be invoked from Rust via the `asm!` macro. See the [OpenVM Book] for further documentation on the architecture and usage.
17+
18+
We provide a cargo extension called [cargo-openvm] that provides tools for cross-compilation, execution, and generating cryptographic proofs of execution.
1919

2020
## Requirements
2121

22-
The target only supports cross-compilation (no host tools). It supports `alloc` with a
23-
default allocator; availability of `std` depends on the OpenVM environment and is not
24-
guaranteed. Binaries are expected to be ELF.
22+
The target supports cross-compilation from any host and does not support host tools. It supports `alloc` with a
23+
default allocator. Partial support for the Rust `std` library is provided using custom RISC-V instructions and requires the `openvm` crate with the `"std"` feature enabled. Further details and limitations of `std` support are documented [here](https://docs.openvm.dev/book/writing-apps/writing-a-program#rust-std-library-support).
2524

26-
The execution environment is single-threaded, non-preemptive, and does not support
27-
privileged instructions. The binaries expect no operating system and can be thought
25+
The target's execution environment is single-threaded, non-preemptive, and does not support
26+
privileged instructions. At present, unaligned accesses are not supported and will result in execution traps. The binaries expect no operating system and can be thought
2827
of as running on bare-metal. The target does not use `#[target_feature(...)]` or
29-
`-C target-feature=` values. Calling `extern "C"` uses the C calling convention outlined
28+
`-C target-feature=` values.
29+
30+
Binaries are expected to be ELF.
31+
32+
Calling `extern "C"` uses the C calling convention outlined
3033
in the [RISC-V specification].
3134

32-
## Building for the zkVM
35+
## Building the target
36+
The target can be built by enabling it for a `rustc` build.
3337

34-
You can add this target to the `target` list in `bootstrap.toml` to build with the compiler.
35-
However, most users should follow the tooling and starter templates in the [OpenVM Book],
36-
which provide a streamlined developer experience for building, linking, and packaging
37-
OpenVM guests.
38+
```toml
39+
[build]
40+
target = ["riscv32im-unknown-openvm-elf"]
41+
```
3842

3943
## Building Rust programs
4044

4145
Rust does not yet ship pre-compiled artifacts for this target. To compile for
42-
this target, either build Rust with the target enabled (see "Building for the zkVM" above)
43-
or use the toolchain and instructions provided in the [OpenVM Book].
46+
this target, you will need to do one of the following:
47+
- Build Rust with the target enabled (see "Building the target" above)
48+
- Build your own copy of `core` by passing args `-Zbuild-std=alloc,core,proc_macro,panic_abort,std -Zbuild-std-features=compiler-builtins-mem`
49+
- Use `cargo openvm build` provided by the cargo extension [cargo-openvm].
50+
51+
The `cargo-openvm` utility is a command-line interface that calls `cargo` with the `build-std` flags above together with `rustc` flags `-C passes=lower-atomic -C link-arg=-Ttext=<TEXT_START>` to map text to the appropriate location. The text start (presently `0x0020_0800`) must be set to start above the stack top, and heap begins right after the text. The utility also includes the `rustc` flag `--cfg getrandom_backend="custom"` to enable a custom backend for the `getrandom` crate.
4452

4553
## Testing
4654

47-
Note: this target is implemented as a software zkVM; there is no hardware implementation.
55+
Note: this target is implemented as a software virtual machine; there is no hardware implementation.
4856

49-
The most practical way to test programs is to use the OpenVM host runner and starter
50-
templates described in the [OpenVM Book]. Typically, a "host" program runs on your
51-
development machine (Linux or macOS) and invokes the OpenVM to execute the "guest"
52-
binary compiled for this target, retrieving any public output.
57+
Guest programs cross-compiled to the target must be run on the host inside OpenVM virtual machines, which are software emulators. The most practical way to do this is via either the [cargo-openvm] command-line interface or the [OpenVM SDK].
5358

5459
The target currently does not support running the Rust test suite.
5560

@@ -61,5 +66,7 @@ target. On clang and ld.lld linker, it can be generated using the
6166
target `riscv32-unknown-none`.
6267

6368
[RISC-V specification]: https://riscv.org/wp-content/uploads/2015/01/riscv-calling.pdf
64-
[OpenVM]: https://openvm.dev/
65-
[OpenVM Book]: https://docs.openvm.dev/book/getting-started/introduction
69+
[OpenVM]: https://github.com/openvm-org/openvm/
70+
[OpenVM Book]: https://docs.openvm.dev/book/
71+
[OpenVM SDK]: https://docs.openvm.dev/book/advanced-usage/sdk
72+
[cargo-openvm]: https://docs.openvm.dev/book/getting-started/install

0 commit comments

Comments
 (0)