Skip to content

Commit

Permalink
feat: succinct target
Browse files Browse the repository at this point in the history
  • Loading branch information
jtguibas committed Jan 25, 2024
1 parent f950d92 commit fa4c666
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 21 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,9 +756,9 @@ impl StackProbeType {
.and_then(|o| o.as_array())
.ok_or_else(|| "expected `min-llvm-version-for-inline` to be an array")?;
let mut iter = min_version.into_iter().map(|v| {
let int = v.as_u64().ok_or_else(
|| "expected `min-llvm-version-for-inline` values to be integers",
)?;
let int = v.as_u64().ok_or_else(|| {
"expected `min-llvm-version-for-inline` values to be integers"
})?;
u32::try_from(int)
.map_err(|_| "`min-llvm-version-for-inline` values don't convert to u32")
});
Expand Down Expand Up @@ -1197,7 +1197,7 @@ supported_targets! {
("x86_64-unknown-hermit", x86_64_unknown_hermit),

("riscv32i-unknown-none-elf", riscv32i_unknown_none_elf),
("riscv32im-risc0-zkvm-elf", riscv32im_risc0_zkvm_elf),
("riscv32im-succinct-zkvm-elf", riscv32im_succinct_zkvm_elf),
("riscv32im-unknown-none-elf", riscv32im_unknown_none_elf),
("riscv32imc-unknown-none-elf", riscv32imc_unknown_none_elf),
("riscv32imc-esp-espidf", riscv32imc_esp_espidf),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/riscv32im_risc0_zkvm_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {

options: TargetOptions {
os: "zkvm".into(),
vendor: "risc0".into(),
vendor: "succinct".into(),
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
cpu: "generic-rv32".into(),
Expand Down
14 changes: 5 additions & 9 deletions library/std/src/sys/zkvm/abi.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! ABI definitions for symbols exported by risc0-zkvm-platform.
//! ABI definitions for symbols exported by succinct-zkvm-platform.
// Included here so we don't have to depend on risc0-zkvm-platform.
// Included here so we don't have to depend on succinct-zkvm-platform.
//
// FIXME: Should we move this to the "libc" crate? It seems like other
// architectures put a lot of this kind of stuff there. But there's
// currently no risc0 fork of the libc crate, so we'd either have to
// currently no succinct fork of the libc crate, so we'd either have to
// fork it or upstream it.

#![allow(dead_code)]
Expand All @@ -19,7 +19,7 @@ pub mod fileno {
}

extern "C" {
// Wrappers around syscalls provided by risc0-zkvm-platform:
// Wrappers around syscalls provided by succinct-zkvm-platform:
pub fn sys_halt();
pub fn sys_output(output_id: u32, output_value: u32);
pub fn sys_sha_compress(
Expand Down Expand Up @@ -47,11 +47,7 @@ extern "C" {
varname_len: usize,
) -> usize;
pub fn sys_argc() -> usize;
pub fn sys_argv(
out_words: *mut u32,
out_nwords: usize,
arg_index: usize,
) -> usize;
pub fn sys_argv(out_words: *mut u32, out_nwords: usize, arg_index: usize) -> usize;

// Allocate memory from global HEAP.
pub fn sys_alloc_words(nwords: usize) -> *mut u32;
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/zkvm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! System bindings for the risc0 zkvm platform
//! System bindings for the succinct zkvm platform
//!
//! This module contains the facade (aka platform-specific) implementations of
//! OS level functionality for zkvm.
Expand Down
14 changes: 11 additions & 3 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &'static str, Option<&[&'static str]>)]
/* Extra values not defined in the built-in targets yet, but used in std */
(Some(Mode::Std), "target_env", Some(&["libnx"])),
(Some(Mode::Std), "target_os", Some(&["zkvm"])),
(Some(Mode::Std), "target_vendor", Some(&["risc0"])),
(Some(Mode::Std), "target_vendor", Some(&["succinct"])),
// #[cfg(bootstrap)] loongarch64
(Some(Mode::Std), "target_arch", Some(&["asmjs", "spirv", "nvptx", "xtensa", "loongarch64"])),
/* Extra names used by dependencies */
Expand Down Expand Up @@ -786,7 +786,11 @@ impl Build {
/// Component directory that Cargo will produce output into (e.g.
/// release/debug)
fn cargo_dir(&self) -> &'static str {
if self.config.rust_optimize { "release" } else { "debug" }
if self.config.rust_optimize {
"release"
} else {
"debug"
}
}

fn tools_dir(&self, compiler: Compiler) -> PathBuf {
Expand Down Expand Up @@ -1566,7 +1570,11 @@ impl Build {
use std::os::unix::fs::symlink as symlink_file;
#[cfg(windows)]
use std::os::windows::fs::symlink_file;
if !self.config.dry_run() { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) }
if !self.config.dry_run() {
symlink_file(src.as_ref(), link.as_ref())
} else {
Ok(())
}
}

/// Returns if config.ninja is enabled, and checks for ninja existence,
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ target | std | host | notes
`riscv32im-unknown-none-elf` | * | | Bare RISC-V (RV32IM ISA)
[`riscv32imac-unknown-xous-elf`](platform-support/riscv32imac-unknown-xous-elf.md) | ? | | RISC-V Xous (RV32IMAC ISA)
`riscv32imc-esp-espidf` | ✓ | | RISC-V ESP-IDF
`riscv32im-risc0-zkvm-elf` | * | | RISC-V running on the Risc Zero Zero-Knowledge Virtual Machine
`riscv32im-succinct-zkvm-elf` | * | | RISC-V running on the Succinct Zero-Knowledge Virtual Machine
`riscv64gc-unknown-freebsd` | | | RISC-V FreeBSD
`riscv64gc-unknown-fuchsia` | | | RISC-V Fuchsia
`riscv64gc-unknown-linux-musl` | | | RISC-V Linux (kernel 4.20, musl 1.2.0)
Expand Down
2 changes: 1 addition & 1 deletion src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static TARGETS: &[&str] = &[
"powerpc64-unknown-linux-gnu",
"powerpc64le-unknown-linux-gnu",
"riscv32i-unknown-none-elf",
"riscv32im-risc0-zkvm-elf",
"riscv32im-succinct-zkvm-elf",
"riscv32im-unknown-none-elf",
"riscv32imc-unknown-none-elf",
"riscv32imac-unknown-none-elf",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/extdeps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn check(root: &Path, bad: &mut bool) {
let source = line.split_once('=').unwrap().1.trim();

// Ensure source is allowed.
if !ALLOWED_SOURCES.contains(&&*source) && !source.contains("risc0") {
if !ALLOWED_SOURCES.contains(&&*source) && !source.contains("succinct") {
tidy_error!(bad, "invalid source: {}", source);
}
}
Expand Down

0 comments on commit fa4c666

Please sign in to comment.