Skip to content

Commit 5501652

Browse files
committed
feat: succinct-zkvm std-lib support
1 parent ea4c160 commit 5501652

File tree

25 files changed

+401
-13
lines changed

25 files changed

+401
-13
lines changed

compiler/rustc_target/src/spec/targets/riscv32im_succinct_zkvm_elf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub(crate) fn target() -> Target {
1010
description: Some("Succinct's zero-knowledge Virtual Machine (RV32IM ISA)".into()),
1111
tier: Some(3),
1212
host_tools: Some(false),
13-
std: None,
13+
std: Some(true),
1414
},
1515
pointer_width: 32,
1616
arch: "riscv32".into(),

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
@@ -60,9 +60,9 @@ fn main() {
6060
|| target_os == "uefi"
6161
|| target_os == "teeos"
6262
|| target_os == "zkvm"
63+
|| target_os == "succinct-zkvm"
6364
|| target_os == "rtems"
6465
|| target_os == "nuttx"
65-
6666
// See src/bootstrap/src/core/build_steps/synthetic_targets.rs
6767
|| env::var("RUSTC_BOOTSTRAP_SYNTHETIC_TARGET").is_ok()
6868
{

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.
@@ -89,7 +89,7 @@ cfg_if::cfg_if! {
8989
mod wasm;
9090
} else if #[cfg(target_os = "xous")] {
9191
mod xous;
92-
} else if #[cfg(target_os = "zkvm")] {
92+
} else if #[cfg(any(target_os = "zkvm", target_os = "succinct-zkvm"))] {
9393
mod zkvm;
9494
}
9595
}

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]

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ cfg_if::cfg_if! {
6464
} else if #[cfg(target_os = "zkvm")] {
6565
mod zkvm;
6666
pub use self::zkvm::*;
67+
} else if #[cfg(target_os = "succinct-zkvm")] {
68+
mod succinct_zkvm;
69+
pub use self::succinct_zkvm::*;
6770
} else {
6871
mod unsupported;
6972
pub use self::unsupported::*;

0 commit comments

Comments
 (0)