Skip to content

Commit c4de18b

Browse files
committed
feat: 64bit
1 parent b12c91e commit c4de18b

File tree

9 files changed

+90
-23
lines changed

9 files changed

+90
-23
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,16 @@ jobs:
4343
fetch-depth: 0
4444
ref: ${{ github.ref }}
4545

46-
- name: Check out succinctlabs/sp1
47-
uses: actions/checkout@v3
48-
with:
49-
repository: succinctlabs/sp1
50-
ref: dev
51-
path: sp1
52-
5346
- name: Build
5447
run: |
55-
cd sp1/crates/cli
56-
GITHUB_ACTIONS=false SP1_BUILD_DIR=$GITHUB_WORKSPACE cargo run --bin cargo-prove -- prove build-toolchain
48+
cd rust
49+
./build_toolchain_succinct.sh
5750
5851
- name: Archive build output
5952
uses: actions/upload-artifact@v4
6053
with:
6154
name: rust-toolchain-${{ matrix.triple }}
62-
path: sp1/crates/cli/rust-toolchain-${{ matrix.triple }}.tar.gz
55+
path: rust/rust-toolchain-${{ matrix.triple }}.tar.gz
6356

6457
build-runs-on:
6558
strategy:
@@ -91,20 +84,13 @@ jobs:
9184
fetch-depth: 0
9285
ref: ${{ github.ref }}
9386

94-
- name: Check out succinctlabs/sp1
95-
uses: actions/checkout@v3
96-
with:
97-
repository: succinctlabs/sp1
98-
ref: dev
99-
path: sp1
100-
10187
- name: Build
10288
run: |
103-
cd sp1/crates/cli
104-
GITHUB_ACTIONS=false SP1_BUILD_DIR=$GITHUB_WORKSPACE cargo run --bin cargo-prove -- prove build-toolchain
89+
cd rust
90+
./build_toolchain_succinct.sh
10591
10692
- name: Archive build output
10793
uses: actions/upload-artifact@v4
10894
with:
10995
name: rust-toolchain-aarch64-unknown-linux-gnu
110-
path: sp1/crates/cli/rust-toolchain-aarch64-unknown-linux-gnu.tar.gz
96+
path: rust/rust-toolchain-aarch64-unknown-linux-gnu.tar.gz

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
jobs:
77
build:
88
uses: ./.github/workflows/ci.yml
9+
secrets: inherit
910
release:
1011
needs: build
1112
runs-on: ubuntu-latest
@@ -36,4 +37,4 @@ jobs:
3637
else
3738
echo "No files to release. Exiting."
3839
exit 1
39-
fi
40+
fi

build_toolchain_succinct.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
# rust/build-toolchain.sh
3+
# Builds the SP1 custom toolchain and packs stage2 into rust-toolchain-<host>.tar.gz
4+
5+
set -euo pipefail
6+
7+
TARGET_RISCV="riscv64im-succinct-zkvm-elf"
8+
HOST_TRIPLE="$(rustc -vV | awk '/^host:/ {print $2}')"
9+
10+
echo "==> host triple: $HOST_TRIPLE"
11+
echo "==> building rust stage2 for targets: $TARGET_RISCV, $HOST_TRIPLE"
12+
13+
##############################
14+
# 1. one-line sanity work-arounds
15+
##############################
16+
TMP_TARGET_DIR="$(mktemp -d)"
17+
touch "$TMP_TARGET_DIR/${TARGET_RISCV}.json" # bypass target-sanity check
18+
export RUST_TARGET_PATH="$TMP_TARGET_DIR"
19+
export CARGO_TARGET_RISCV64IM_SUCCINCT_ZKVM_ELF_RUSTFLAGS="-Cpasses=lower-atomic"
20+
21+
##############################
22+
# 2. compile
23+
##############################
24+
python3 x.py build --stage 2 library \
25+
--target "${TARGET_RISCV},${HOST_TRIPLE}"
26+
27+
##############################
28+
# 3. pack artifact
29+
##############################
30+
STAGE2_DIR="$(find build -maxdepth 2 -type d -name stage2 | head -n1)"
31+
[[ -d "$STAGE2_DIR" ]] || { echo "error: stage2 not found"; exit 1; }
32+
33+
OUT_TAR="rust-toolchain-${HOST_TRIPLE}.tar.gz"
34+
tar --exclude 'lib/rustlib/src' \
35+
--exclude 'lib/rustlib/rustc-src' \
36+
-hczvf "$OUT_TAR" -C "$STAGE2_DIR" .
37+
38+
echo "==> done – artifact: $OUT_TAR"

compiler/rustc_target/src/spec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,7 @@ supported_targets! {
19741974
("riscv32gc-unknown-linux-gnu", riscv32gc_unknown_linux_gnu),
19751975
("riscv32gc-unknown-linux-musl", riscv32gc_unknown_linux_musl),
19761976
("riscv64imac-unknown-none-elf", riscv64imac_unknown_none_elf),
1977+
("riscv64im-succinct-zkvm-elf", riscv64im_succinct_zkvm_elf),
19771978
("riscv64gc-unknown-none-elf", riscv64gc_unknown_none_elf),
19781979
("riscv64gc-unknown-linux-gnu", riscv64gc_unknown_linux_gnu),
19791980
("riscv64gc-unknown-linux-musl", riscv64gc_unknown_linux_musl),
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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:64:64-i64:64-i128:128-n32:64-S128".into(),
8+
llvm_target: "riscv64".into(),
9+
metadata: TargetMetadata {
10+
description: Some("Succinct's zero-knowledge Virtual Machine (RV64IM ISA)".into()),
11+
tier: Some(3),
12+
host_tools: Some(false),
13+
std: None, // ?
14+
},
15+
pointer_width: 64,
16+
arch: "riscv64".into(),
17+
18+
options: TargetOptions {
19+
os: "zkvm".into(),
20+
vendor: "succinct".into(),
21+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
22+
linker: Some("rust-lld".into()),
23+
cpu: "generic-rv64".into(),
24+
25+
max_atomic_width: Some(64),
26+
atomic_cas: true,
27+
28+
features: "+m".into(),
29+
llvm_abiname: "lp64".into(),
30+
executables: true,
31+
panic_strategy: PanicStrategy::Abort,
32+
relocation_model: RelocModel::Static,
33+
emit_debug_gdb_scripts: false,
34+
eh_frame_header: false,
35+
singlethread: true,
36+
..Default::default()
37+
},
38+
}
39+
}

src/bootstrap/Cargo.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ dependencies = [
9090
[[package]]
9191
name = "cc"
9292
version = "1.2.17"
93-
source = "git+https://github.com/leruaa/cc-rs?branch=aurelien%2Fadd-succinct-target#1cdaea42e4044e135817d49005f8b7e812e4cbfa"
93+
source = "git+https://github.com/succinctlabs/cc-rs?branch=add-succinct-target#a182366ce32d9bac95bfd2d65cf212262a809257"
9494
dependencies = [
9595
"shlex",
9696
]

src/bootstrap/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,4 @@ debug = 0
9595
bootstrap.debug = 1
9696

9797
[patch.crates-io]
98-
cc = { git = "https://github.com/leruaa/cc-rs", branch = "aurelien/add-succinct-target" }
98+
cc = { git = "https://github.com/succinctlabs/cc-rs", branch = "add-succinct-target" }

src/bootstrap/src/core/sanity.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub struct Finder {
3535
const STAGE0_MISSING_TARGETS: &[&str] = &[
3636
// just a dummy comment so the list doesn't get onelined
3737
"riscv32im-succinct-zkvm-elf",
38+
"riscv64im-succinct-zkvm-elf",
3839
"x86_64-lynx-lynxos178",
3940
];
4041

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ static TARGETS: &[&str] = &[
145145
"riscv32imafc-unknown-none-elf",
146146
"riscv32gc-unknown-linux-gnu",
147147
"riscv64imac-unknown-none-elf",
148+
"riscv64im-succinct-zkvm-elf",
148149
"riscv64gc-unknown-hermit",
149150
"riscv64gc-unknown-none-elf",
150151
"riscv64gc-unknown-linux-gnu",

0 commit comments

Comments
 (0)