Skip to content

Commit f9accfb

Browse files
committed
fix: include platform-summary
1 parent 9007968 commit f9accfb

File tree

4 files changed

+94
-4
lines changed

4 files changed

+94
-4
lines changed

src/bootstrap/Cargo.lock

+2-3
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ dependencies = [
8888

8989
[[package]]
9090
name = "cc"
91-
version = "1.1.22"
92-
source = "registry+https://github.com/rust-lang/crates.io-index"
93-
checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0"
91+
version = "1.2.0"
92+
source = "git+https://github.com/nhtyy/cc-rs?branch=n%2Fadd-succinct-target#424acb084e212c330de96e06cab69be0d9df55f4"
9493
dependencies = [
9594
"shlex",
9695
]

src/bootstrap/Cargo.toml

+8-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ test = false
3939
# otherwise, some targets will fail. That's why these dependencies are explicitly pinned.
4040
#
4141
# Do not upgrade this crate unless https://github.com/rust-lang/cc-rs/issues/1317 is fixed.
42-
cc = "=1.1.22"
42+
#
43+
# todo(succinct): remove this change that was explicity against the rules.
44+
# This just happens to work, and ideally cc-rs will fix the target parsing issue before our target is merged.
45+
cc = "=1.2.0"
46+
# cc = "=1.1.22"
4347
cmake = "=0.1.48"
4448

4549
build_helper = { path = "../build_helper" }
@@ -73,6 +77,9 @@ tracing-chrome = { version = "0.7", optional = true }
7377
tracing-subscriber = { version = "0.3", optional = true, features = ["env-filter", "fmt", "registry", "std"] }
7478
tracing-tree = { version = "0.4.0", optional = true }
7579

80+
[patch.crates-io]
81+
cc = { git = "https://github.com/nhtyy/cc-rs", branch = "n/add-succinct-target" }
82+
7683
[target.'cfg(windows)'.dependencies.junction]
7784
version = "1.0.0"
7885

src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
- [riscv32e\*-unknown-none-elf](platform-support/riscv32e-unknown-none-elf.md)
7878
- [riscv32i\*-unknown-none-elf](platform-support/riscv32-unknown-none-elf.md)
7979
- [riscv32im-risc0-zkvm-elf](platform-support/riscv32im-risc0-zkvm-elf.md)
80+
- [riscv32im-succinct-zkvm-elf](platform-support/riscv32im-succinct-zkvm-elf.md)
8081
- [riscv32imac-unknown-xous-elf](platform-support/riscv32imac-unknown-xous-elf.md)
8182
- [riscv64gc-unknown-linux-gnu](platform-support/riscv64gc-unknown-linux-gnu.md)
8283
- [riscv64gc-unknown-linux-musl](platform-support/riscv64gc-unknown-linux-musl.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# `riscv32im-risc0-zkvm-elf`
2+
3+
**Tier: 3**
4+
5+
Succinct's ISA for the SP1 zkVM (Zero Knowledge Virtual Machine).
6+
7+
## Target maintainers
8+
9+
- John Guibas, `[email protected]`, https://github.com/jtguibas
10+
- Nathan Bustamante, `[email protected]`, https://github.com/nhtyy
11+
12+
## Background
13+
14+
This target is an execution environment to produce a proof of execution of
15+
a RISC-V ELF binary and any output that the developer of the binary wishes to
16+
display publicly. In order to do this, the target will execute the ELF and
17+
create a cryptographic proof of the "trace" of the programs runtime.
18+
19+
We have a cargo extension called [cargo-prove] that allow users to generate
20+
project templates, install tools for improved user experience and build binaries.
21+
22+
## Requirements
23+
24+
The target only supports cross compilation and no host tools. The target
25+
supports `alloc` with a default allocator and will have support for std soon.
26+
27+
The target's execution environment is single threaded, non-preemptive, and does
28+
not support any privileged instructions, nor unaligned accesses. At the time of
29+
writing the VM has 192 MB of memory and text/data, heap, and stack need to be
30+
with in the address range `0x400` - `0x0C000000`. The binaries themselves expect
31+
no operating system and can be thought of as running on bare-metal. The target
32+
does not use `#[target_feature(...)]` or `-C target-feature=` values.
33+
34+
Calling `extern "C"` on the target uses the C calling convention outlined in the
35+
[RISC-V specification].
36+
37+
## Building for the zkVM
38+
39+
Programs for the zkVM could be built by adding it to the `target` list in
40+
`config.toml`. However, we recommend building programs in our starter template
41+
generated by the [cargo-prove] utility and the [sp1-build] crate. This
42+
crate calls `rustc` with `-C "link-arg=-Ttext=` so that it maps the text in the
43+
appropriate location as well as generating variables that represent the ELF and
44+
a unique ID associated with the ELF.
45+
46+
The starter template provides developers with system calls that are useful
47+
to zero knowledge computing such as writing to
48+
the public output, hashing using sha256, and multiply big integers.
49+
50+
## Building Rust programs
51+
52+
Rust does not yet ship pre-compiled artifacts for this target. To compile for
53+
this target, you will either need to build Rust with the target enabled (see
54+
"Building the target" above). We do not recommend using `build-std` as we have
55+
run into issues building core in the past on our starter template. An alternate
56+
solution is to download the risc0 tool chain by running `cargo prove install-toolchain`.
57+
58+
## Testing
59+
60+
Note: the target is implemented as a software emulator called the zkVM and there
61+
is no hardware implementation of the target.
62+
63+
The most practical way to test the target program is to use our starter template
64+
that can be generated by using the `cargo prove new` command. The template
65+
generates a sample "host" and "guest" code. The guest code compiled to the
66+
target (which is RV32IM) whereas the "host" code is compiled to run on the
67+
programmer's machine running either a Linux distribution or macOS.
68+
69+
The host program is responsible for running the guest binary on the zkVM and retrieving
70+
its public output.
71+
72+
The target currently does not support running the Rust test suite.
73+
74+
## Cross-compilation toolchains and C code
75+
76+
Compatible C code can be built for this target on any compiler that has a RV32IM
77+
target. On clang and ld.lld linker, it can be generated using the
78+
`-march=rv32im`, `-mabi=ilp32` with llvm features flag `features=+m` and llvm
79+
target `riscv32-unknown-none`.
80+
81+
[RISC-V specification]: https://riscv.org/wp-content/uploads/2015/01/riscv-calling.pdf
82+
[cargo-prove]: https://docs.succinct.xyz/docs/sp1/getting-started/install
83+
[sp1-build]: https://crates.io/crates/sp1-build

0 commit comments

Comments
 (0)