Skip to content

Commit 5c1dbd3

Browse files
committed
feat: succinct target
1 parent 249cb84 commit 5c1dbd3

File tree

30 files changed

+457
-15
lines changed

30 files changed

+457
-15
lines changed

compiler/rustc_target/src/spec/mod.rs

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

19551955
("riscv32i-unknown-none-elf", riscv32i_unknown_none_elf),
19561956
("riscv32im-risc0-zkvm-elf", riscv32im_risc0_zkvm_elf),
1957+
("riscv32im-succinct-zkvm-elf", riscv32im_succinct_zkvm_elf),
19571958
("riscv32im-unknown-none-elf", riscv32im_unknown_none_elf),
19581959
("riscv32ima-unknown-none-elf", riscv32ima_unknown_none_elf),
19591960
("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::{
2+
Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions,
3+
};
4+
5+
pub(crate) fn target() -> Target {
6+
Target {
7+
data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(),
8+
llvm_target: "riscv32".into(),
9+
metadata: TargetMetadata {
10+
description: Some("Succinct's zero-knowledge Virtual Machine (RV32IM ISA)".into()),
11+
tier: Some(3),
12+
host_tools: Some(false),
13+
std: Some(true),
14+
},
15+
pointer_width: 32,
16+
arch: "riscv32".into(),
17+
18+
options: TargetOptions {
19+
os: "succinct-zkvm".into(),
20+
vendor: "succinct".into(),
21+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
22+
linker: Some("rust-lld".into()),
23+
cpu: "generic-rv32".into(),
24+
25+
// The zkvm is singlethreaded and all operations are atomic.
26+
// The std-lib is compiled with lowered atomicsa and the default Succinct build tools
27+
// enforce this on programs.
28+
max_atomic_width: Some(64),
29+
atomic_cas: true,
30+
31+
features: "+m".into(),
32+
llvm_abiname: "ilp32".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/panic_abort/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ compiler_builtins = "0.1.0"
1919

2020
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
2121
libc = { version = "0.2", default-features = false }
22+
23+
[lints.rust.unexpected_cfgs]
24+
level = "warn"
25+
check-cfg = [
26+
'cfg(bootstrap)',
27+
'cfg(target_os, values("succinct-zkvm"))'
28+
]

library/panic_abort/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#[cfg(target_os = "android")]
2121
mod android;
2222

23-
#[cfg(target_os = "zkvm")]
23+
#[cfg(any(target_os = "zkvm", target_os = "succinct-zkvm"))]
2424
mod zkvm;
2525

2626
use core::any::Any;
@@ -40,7 +40,7 @@ pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 {
4040
unsafe {
4141
android::android_set_abort_message(_payload);
4242
}
43-
#[cfg(target_os = "zkvm")]
43+
#[cfg(any(target_os = "zkvm", target_os = "succinct-zkvm"))]
4444
unsafe {
4545
zkvm::zkvm_set_abort_message(_payload);
4646
}

library/panic_abort/src/zkvm.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use alloc::string::String;
22
use core::panic::PanicPayload;
33

4-
// Forward the abort message to zkVM's sys_panic. This is implemented by RISC Zero's
5-
// platform crate which exposes system calls specifically for the zkVM.
4+
/// Note this function works with both `zkvm` and `succinct-zkvm`.
65
pub(crate) unsafe fn zkvm_set_abort_message(payload: &mut dyn PanicPayload) {
76
let payload = payload.get();
87
let msg = match payload.downcast_ref::<&'static str>() {

library/std/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,6 @@ check-cfg = [
163163
# and to the `backtrace` crate which messes-up with Cargo list
164164
# of declared features, we therefor expect any feature cfg
165165
'cfg(feature, values(any()))',
166+
'cfg(target_os, values("succinct-zkvm"))'
166167
]
168+

library/std/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ fn main() {
5959
|| target_os == "uefi"
6060
|| target_os == "teeos"
6161
|| target_os == "zkvm"
62+
|| target_os == "succinct-zkvm"
6263
|| target_os == "rtems"
6364
|| target_os == "nuttx"
64-
6565
// See src/bootstrap/src/core/build_steps/synthetic_targets.rs
6666
|| env::var("RUSTC_BOOTSTRAP_SYNTHETIC_TARGET").is_ok()
6767
{

library/std/src/random.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ use crate::sys::random as sys;
4848
/// VxWorks | `randABytes` after waiting for `randSecure` to become ready
4949
/// WASI | [`random_get`](https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#-random_getbuf-pointeru8-buf_len-size---result-errno)
5050
/// ZKVM | `sys_rand`
51+
/// SUCCINCT-ZKVM | `sys_rand`
5152
///
5253
/// Note that the sources used might change over time.
5354
///

library/std/src/sys/alloc/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::ptr;
77
// add fast paths for low alignment values.
88
#[allow(dead_code)]
99
const MIN_ALIGN: usize = if cfg!(any(
10-
all(target_arch = "riscv32", any(target_os = "espidf", target_os = "zkvm")),
10+
all(target_arch = "riscv32", any(target_os = "espidf", target_os = "zkvm", target_os = "succinct-zkvm")),
1111
all(target_arch = "xtensa", target_os = "espidf"),
1212
)) {
1313
// The allocator on the esp-idf and zkvm platforms guarantees 4 byte alignment.
@@ -88,7 +88,7 @@ cfg_if::cfg_if! {
8888
mod wasm;
8989
} else if #[cfg(target_os = "xous")] {
9090
mod xous;
91-
} else if #[cfg(target_os = "zkvm")] {
91+
} else if #[cfg(any(target_os = "zkvm", target_os = "succinct-zkvm"))] {
9292
mod zkvm;
9393
}
9494
}

library/std/src/sys/alloc/zkvm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::alloc::{GlobalAlloc, Layout, System};
22
use crate::sys::pal::abi;
33

4+
/// Note this allocator works with both `zkvm` and `succinct-zkvm`.
45
#[stable(feature = "alloc_system_type", since = "1.28.0")]
56
unsafe impl GlobalAlloc for System {
67
#[inline]

0 commit comments

Comments
 (0)