Skip to content

Commit 403d3f5

Browse files
committed
feat: add target riscv32im-succinct-zkvm-elf
1 parent eeb90cd commit 403d3f5

File tree

10 files changed

+74
-4
lines changed

10 files changed

+74
-4
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,7 @@ supported_targets! {
17481748

17491749
("riscv32i-unknown-none-elf", riscv32i_unknown_none_elf),
17501750
("riscv32im-risc0-zkvm-elf", riscv32im_risc0_zkvm_elf),
1751+
("riscv32im-succinct-zkvm-elf", riscv32im_succinct_zkvm_elf),
17511752
("riscv32im-unknown-none-elf", riscv32im_unknown_none_elf),
17521753
("riscv32ima-unknown-none-elf", riscv32ima_unknown_none_elf),
17531754
("riscv32imc-unknown-none-elf", riscv32imc_unknown_none_elf),
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel};
2+
use crate::spec::{Target, TargetOptions};
3+
4+
pub fn target() -> Target {
5+
Target {
6+
data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(),
7+
llvm_target: "riscv32".into(),
8+
metadata: crate::spec::TargetMetadata {
9+
description: Some("Succinct's zero-knowledge Virtual Machine (RV32IM ISA)".into()),
10+
tier: Some(3),
11+
host_tools: Some(false),
12+
std: None, // ?
13+
},
14+
pointer_width: 32,
15+
arch: "riscv32".into(),
16+
17+
options: TargetOptions {
18+
os: "zkvm".into(),
19+
vendor: "succinct".into(),
20+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
21+
linker: Some("rust-lld".into()),
22+
cpu: "generic-rv32".into(),
23+
24+
// Some crates (*cough* crossbeam) assume you have 64 bit
25+
// atomics if the target name is not in a hardcoded list.
26+
// Since zkvm is singlethreaded and all operations are
27+
// atomic, I guess we can just say we support 64-bit
28+
// atomics.
29+
max_atomic_width: Some(64),
30+
atomic_cas: true,
31+
32+
features: "+m".into(),
33+
executables: true,
34+
panic_strategy: PanicStrategy::Abort,
35+
relocation_model: RelocModel::Static,
36+
emit_debug_gdb_scripts: false,
37+
eh_frame_header: false,
38+
singlethread: true,
39+
..Default::default()
40+
},
41+
}
42+
}

library/std/src/sys/pal/zkvm/abi.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
//! ABI definitions for symbols exported by risc0-zkvm-platform.
1+
//! ABI definitions for symbols exported by zkvm platforms.
22
3-
// Included here so we don't have to depend on risc0-zkvm-platform.
3+
// Included here so we don't have to depend on zkvm platform crates.
44
//
55
// FIXME: Should we move this to the "libc" crate? It seems like other
66
// architectures put a lot of this kind of stuff there. But there's
@@ -34,7 +34,10 @@ extern "C" {
3434
buf: *const u8,
3535
count: u32,
3636
);
37+
#[cfg(target_vendor = "risc0")]
3738
pub fn sys_rand(recv_buf: *mut u32, words: usize);
39+
#[cfg(target_vendor = "succinct")]
40+
pub fn sys_rand(recv_buf: *mut u8, words: usize);
3841
pub fn sys_panic(msg_ptr: *const u8, len: usize) -> !;
3942
pub fn sys_log(msg_ptr: *const u8, len: usize);
4043
pub fn sys_cycle_count() -> usize;

library/std/src/sys/pal/zkvm/mod.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! System bindings for the risc0 zkvm platform
1+
//! System bindings for the zkvm platform
22
//!
33
//! This module contains the facade (aka platform-specific) implementations of
44
//! OS level functionality for zkvm.
@@ -64,10 +64,23 @@ pub fn abort_internal() -> ! {
6464
core::intrinsics::abort();
6565
}
6666

67+
#[cfg(target_vendor = "risc0")]
6768
pub fn hashmap_random_keys() -> (u64, u64) {
6869
let mut buf = [0u32; 4];
6970
unsafe {
7071
abi::sys_rand(buf.as_mut_ptr(), 4);
7172
};
7273
((buf[0] as u64) << 32 + buf[1] as u64, (buf[2] as u64) << 32 + buf[3] as u64)
7374
}
75+
76+
#[cfg(target_vendor = "succinct")]
77+
pub fn hashmap_random_keys() -> (u64, u64) {
78+
let mut buf = [0u8; 16];
79+
unsafe {
80+
abi::sys_rand(buf.as_mut_ptr(), buf.len());
81+
};
82+
83+
let a = u64::from_le_bytes(buf[0..8].try_into().unwrap());
84+
let b = u64::from_le_bytes(buf[8..16].try_into().unwrap());
85+
(a, b)
86+
}

src/doc/rustc/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
- [powerpc-unknown-openbsd](platform-support/powerpc-unknown-openbsd.md)
6464
- [powerpc64-ibm-aix](platform-support/aix.md)
6565
- [riscv32im-risc0-zkvm-elf](platform-support/riscv32im-risc0-zkvm-elf.md)
66+
- [riscv32im-succinct-zkvm-elf](platform-support/riscv32im-succinct-zkvm-elf.md)
6667
- [riscv32imac-unknown-xous-elf](platform-support/riscv32imac-unknown-xous-elf.md)
6768
- [riscv32*-unknown-none-elf](platform-support/riscv32-unknown-none-elf.md)
6869
- [sparc-unknown-none-elf](./platform-support/sparc-unknown-none-elf.md)

src/doc/rustc/src/platform-support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ target | std | host | notes
346346
`riscv32gc-unknown-linux-gnu` | | | RISC-V Linux (kernel 5.4, glibc 2.33)
347347
`riscv32gc-unknown-linux-musl` | | | RISC-V Linux (kernel 5.4, musl 1.2.3 + RISCV32 support patches)
348348
[`riscv32im-risc0-zkvm-elf`](platform-support/riscv32im-risc0-zkvm-elf.md) | ? | | RISC Zero's zero-knowledge Virtual Machine (RV32IM ISA)
349+
[`riscv32im-succinct-zkvm-elf`](platform-support/riscv32im-succinct-zkvm-elf.md) | ? | | Succinct's zero-knowledge Virtual Machine (RV32IM ISA)
349350
[`riscv32ima-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | | Bare RISC-V (RV32IMA ISA)
350351
[`riscv32imac-unknown-xous-elf`](platform-support/riscv32imac-unknown-xous-elf.md) | ? | | RISC-V Xous (RV32IMAC ISA)
351352
[`riscv32imc-esp-espidf`](platform-support/esp-idf.md) | ✓ | | RISC-V ESP-IDF
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# `riscv32im-succinct-zkvm-elf`
2+
3+
**Tier: 3**
4+
5+
Succinct's Zero Knowledge Virtual Machine (zkVM) implementing the RV32IM instruction set.

src/tools/build-manifest/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ static TARGETS: &[&str] = &[
131131
"powerpc64le-unknown-linux-gnu",
132132
"riscv32i-unknown-none-elf",
133133
"riscv32im-risc0-zkvm-elf",
134+
"riscv32im-succinct-zkvm-elf",
134135
"riscv32im-unknown-none-elf",
135136
"riscv32ima-unknown-none-elf",
136137
"riscv32imc-unknown-none-elf",

tests/assembly/targets/targets-elf.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,9 @@
369369
//@ revisions: riscv32im_risc0_zkvm_elf
370370
//@ [riscv32im_risc0_zkvm_elf] compile-flags: --target riscv32im-risc0-zkvm-elf
371371
//@ [riscv32im_risc0_zkvm_elf] needs-llvm-components: riscv
372+
//@ revisions: riscv32im_succinct_zkvm_elf
373+
//@ [riscv32im_succinct_zkvm_elf] compile-flags: --target riscv32im-succinct-zkvm-elf
374+
//@ [riscv32im_succinct_zkvm_elf] needs-llvm-components: riscv
372375
//@ revisions: riscv32im_unknown_none_elf
373376
//@ [riscv32im_unknown_none_elf] compile-flags: --target riscv32im-unknown-none-elf
374377
//@ [riscv32im_unknown_none_elf] needs-llvm-components: riscv

tests/ui/check-cfg/well-known-values.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
230230
LL | target_vendor = "_UNEXPECTED_VALUE",
231231
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
232232
|
233-
= note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs`
233+
= note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `succinct`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs`
234234
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
235235

236236
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`

0 commit comments

Comments
 (0)