You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/doc/rustc/src/platform-support/riscv32im-unknown-openvm-elf.md
+33-26Lines changed: 33 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
**Tier: 3**
4
4
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.
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.
19
19
20
20
## Requirements
21
21
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).
25
24
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
28
27
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
30
33
in the [RISC-V specification].
31
34
32
-
## Building for the zkVM
35
+
## Building the target
36
+
The target can be built by enabling it for a `rustc` build.
33
37
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
+
```
38
42
39
43
## Building Rust programs
40
44
41
45
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.
44
52
45
53
## Testing
46
54
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.
48
56
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].
53
58
54
59
The target currently does not support running the Rust test suite.
55
60
@@ -61,5 +66,7 @@ target. On clang and ld.lld linker, it can be generated using the
0 commit comments