Skip to content

Commit 458929b

Browse files
committed
fix: apply 1.85 diffs
1 parent 7525864 commit 458929b

File tree

10 files changed

+35
-77
lines changed

10 files changed

+35
-77
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
@@ -7,7 +7,7 @@ pub(crate) fn target() -> Target {
77
data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(),
88
llvm_target: "riscv32".into(),
99
metadata: TargetMetadata {
10-
description: Some("RISC Zero's zero-knowledge Virtual Machine (RV32IM ISA)".into()),
10+
description: Some("Succinct's zero-knowledge Virtual Machine (RV32IM ISA)".into()),
1111
tier: Some(3),
1212
host_tools: Some(false),
1313
std: None, // ?

library/panic_abort/src/zkvm.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ pub(crate) unsafe fn zkvm_set_abort_message(payload: &mut dyn PanicPayload) {
1212
None => &[],
1313
},
1414
};
15-
if msg.is_empty() {
16-
return;
17-
}
1815

1916
unsafe extern "C" {
2017
fn sys_panic(msg_ptr: *const u8, len: usize) -> !;

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,15 @@ pub mod fileno {
2020

2121
unsafe extern "C" {
2222
// Wrappers around syscalls provided by sp1-zkvm-platform:
23-
pub fn sys_halt();
24-
pub fn sys_output(output_id: u32, output_value: u32);
25-
pub fn sys_sha_compress(
26-
out_state: *mut [u32; DIGEST_WORDS],
27-
in_state: *const [u32; DIGEST_WORDS],
28-
block1_ptr: *const [u32; DIGEST_WORDS],
29-
block2_ptr: *const [u32; DIGEST_WORDS],
30-
);
31-
pub fn sys_sha_buffer(
32-
out_state: *mut [u32; DIGEST_WORDS],
33-
in_state: *const [u32; DIGEST_WORDS],
34-
buf: *const u8,
35-
count: u32,
36-
);
3723
pub fn sys_rand(recv_buf: *mut u8, words: usize);
3824
pub fn sys_panic(msg_ptr: *const u8, len: usize) -> !;
39-
pub fn sys_log(msg_ptr: *const u8, len: usize);
40-
pub fn sys_cycle_count() -> usize;
41-
pub fn sys_read(fd: u32, recv_buf: *mut u8, nrequested: usize) -> usize;
4225
pub fn sys_write(fd: u32, write_buf: *const u8, nbytes: usize);
4326
pub fn sys_getenv(
4427
recv_buf: *mut u32,
4528
words: usize,
4629
varname: *const u8,
4730
varname_len: usize,
4831
) -> usize;
49-
pub fn sys_argc() -> usize;
50-
pub fn sys_argv(out_words: *mut u32, out_nwords: usize, arg_index: usize) -> usize;
5132

5233
// Allocate memory from global HEAP.
5334
pub fn sys_alloc_words(nwords: usize) -> *mut u32;

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

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
use super::{WORD_SIZE, abi};
21
use crate::ffi::OsString;
32
use crate::fmt;
4-
use crate::sys::os_str;
5-
use crate::sys_common::FromInner;
63

74
pub struct Args {
85
i_forward: usize,
@@ -11,30 +8,13 @@ pub struct Args {
118
}
129

1310
pub fn args() -> Args {
14-
let count = unsafe { abi::sys_argc() };
15-
Args { i_forward: 0, i_back: 0, count }
11+
Args { i_forward: 0, i_back: 0, count: 0 }
1612
}
1713

1814
impl Args {
19-
/// Use sys_argv to get the arg at the requested index. Does not check that i is less than argc
20-
/// and will not return if the index is out of bounds.
21-
fn argv(i: usize) -> OsString {
22-
let arg_len = unsafe { abi::sys_argv(crate::ptr::null_mut(), 0, i) };
23-
24-
let arg_len_words = (arg_len + WORD_SIZE - 1) / WORD_SIZE;
25-
let words = unsafe { abi::sys_alloc_words(arg_len_words) };
26-
27-
let arg_len2 = unsafe { abi::sys_argv(words, arg_len_words, i) };
28-
debug_assert_eq!(arg_len, arg_len2);
29-
30-
// Convert to OsString.
31-
//
32-
// FIXME: We can probably get rid of the extra copy here if we
33-
// reimplement "os_str" instead of just using the generic unix
34-
// "os_str".
35-
let arg_bytes: &[u8] =
36-
unsafe { crate::slice::from_raw_parts(words.cast() as *const u8, arg_len) };
37-
OsString::from_inner(os_str::Buf { inner: arg_bytes.to_vec() })
15+
/// Args::argv is currently not implemented.
16+
fn argv(_i: usize) -> OsString {
17+
panic!("Args::argv is currently not implemented");
3818
}
3919
}
4020

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
use crate::sys::pal::abi;
22

33
pub fn fill_bytes(bytes: &mut [u8]) {
4-
let (pre, words, post) = unsafe { bytes.align_to_mut::<u8>() };
5-
if !words.is_empty() {
6-
unsafe {
7-
abi::sys_rand(words.as_mut_ptr(), words.len());
8-
}
9-
}
4+
unsafe { abi::sys_rand(bytes.as_mut_ptr(), bytes.len()) };
5+
}
106

11-
let mut buf = [0u8; 8];
12-
let len = (pre.len() + post.len() + size_of::<u32>() - 1) / size_of::<u32>();
13-
if len != 0 {
14-
unsafe { abi::sys_rand(buf.as_mut_ptr(), len) };
15-
}
7+
// pub fn fill_bytes(bytes: &mut [u8]) {
8+
// let (pre, words, post) = unsafe { bytes.align_to_mut::<u32>() };
9+
// if !words.is_empty() {
10+
// unsafe { abi::sys_rand(words.as_mut_ptr(), words.len()) };
11+
// }
12+
// }
13+
// let mut buf = [0u32; 2];
14+
// let len = (pre.len() + post.len() + size_of::<u32>() - 1) / size_of::<u32>();
15+
// if len != 0 {
16+
// unsafe { abi::sys_rand(buf.as_mut_ptr(), len) };
17+
// }
1618

17-
let buf = buf.map(u8::to_ne_bytes);
18-
let buf = buf.as_flattened();
19-
pre.copy_from_slice(&buf[..pre.len()]);
20-
post.copy_from_slice(&buf[pre.len()..pre.len() + post.len()]);
21-
}
19+
// let buf = buf.map(u32::to_ne_bytes);
20+
// let buf = buf.as_flattened();
21+
// pre.copy_from_slice(&buf[..pre.len()]);
22+
// post.copy_from_slice(&buf[pre.len()..pre.len() + post.len()]);
23+
// }

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::io::{self, BorrowedCursor};
1+
use crate::io;
22
use crate::sys::pal::abi::{self, fileno};
33

44
pub struct Stdin;
@@ -12,16 +12,11 @@ impl Stdin {
1212
}
1313

1414
impl io::Read for Stdin {
15-
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
16-
Ok(unsafe { abi::sys_read(fileno::STDIN, buf.as_mut_ptr(), buf.len()) })
17-
}
18-
19-
fn read_buf(&mut self, mut buf: BorrowedCursor<'_>) -> io::Result<()> {
20-
unsafe {
21-
let n = abi::sys_read(fileno::STDIN, buf.as_mut().as_mut_ptr().cast(), buf.capacity());
22-
buf.advance_unchecked(n);
23-
}
24-
Ok(())
15+
fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {
16+
return Err(io::Error::new(
17+
io::ErrorKind::Other,
18+
"io::Read for Stdin is currently not implemented",
19+
));
2520
}
2621
}
2722

src/bootstrap/Cargo.lock

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ dependencies = [
8989
[[package]]
9090
name = "cc"
9191
version = "1.2.17"
92-
source = "registry+https://github.com/rust-lang/crates.io-index"
93-
checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a"
92+
source = "git+https://github.com/leruaa/cc-rs?branch=aurelien%2Fadd-succinct-target#1cdaea42e4044e135817d49005f8b7e812e4cbfa"
9493
dependencies = [
9594
"shlex",
9695
]

src/bootstrap/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,6 @@ debug = 0
9292
[profile.dev.package]
9393
# Only use debuginfo=1 to further reduce compile times.
9494
bootstrap.debug = 1
95+
96+
[patch.crates-io]
97+
cc = { git = "https://github.com/leruaa/cc-rs", branch = "aurelien/add-succinct-target" }

src/bootstrap/src/core/sanity.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub struct Finder {
3434
// Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap).
3535
const STAGE0_MISSING_TARGETS: &[&str] = &[
3636
// just a dummy comment so the list doesn't get onelined
37+
"riscv32im-succinct-zkvm-elf",
3738
"wasm32-wali-linux-musl",
3839
];
3940

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ target | std | host | notes
366366
[`riscv32emc-unknown-none-elf`](platform-support/riscv32e-unknown-none-elf.md) | * | | Bare RISC-V (RV32EMC ISA)
367367
`riscv32gc-unknown-linux-gnu` | ✓ | | RISC-V Linux (kernel 5.4, glibc 2.33)
368368
`riscv32gc-unknown-linux-musl` | ? | | RISC-V Linux (kernel 5.4, musl 1.2.3 + RISCV32 support patches)
369-
[`riscv32im-succinct-zkvm-elf`](platform-support/riscv32im-succinct-zkvm-elf.md) | ? | | RISC Zero's zero-knowledge Virtual Machine (RV32IM ISA)
369+
[`riscv32im-succinct-zkvm-elf`](platform-support/riscv32im-succinct-zkvm-elf.md) | ? | | Succinct's zero-knowledge Virtual Machine (RV32IM ISA)
370370
[`riscv32ima-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | | Bare RISC-V (RV32IMA ISA)
371371
[`riscv32imac-esp-espidf`](platform-support/esp-idf.md) | ✓ | | RISC-V ESP-IDF
372372
[`riscv32imac-unknown-nuttx-elf`](platform-support/nuttx.md) | ✓ | | RISC-V 32bit with NuttX

0 commit comments

Comments
 (0)