Skip to content

Commit 39a6f12

Browse files
committed
Switch to succinct rust toolchain
Still getting errors related to atomics from the newer toolchain
1 parent e9b8f74 commit 39a6f12

File tree

3 files changed

+49
-79
lines changed

3 files changed

+49
-79
lines changed

clone.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euo pipefail
44

55
source config.sh -rust_commit
66

7-
git clone --depth 1 "https://github.com/rust-lang/rust.git"
7+
git clone --depth 1 "https://github.com/succinctlabs/rust.git"
88
cd rust
99
git fetch --depth 1 origin $RUST_COMMIT
1010
git checkout FETCH_HEAD

config.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
param1=${1:-}
44

5-
export RUST_COMMIT=aedd173a2c086e558c2b66d3743b344f977621a7
5+
export RUST_COMMIT=295b693dfe72d0ac2d0924eb84af39e364d9c3e3
66

77
# If -rust_commit specified then only export the rust commit variable
88
if [ "$param1" == "-rust_commit" ]; then
@@ -21,13 +21,13 @@ regex='([0-9]{4}-[0-9]{2}-[0-9]{2})'
2121
if [[ $commit_show_output =~ $regex ]]; then
2222
rust_commit_date="${BASH_REMATCH[1]}"
2323
else
24-
echo "Impossible extracting date from rustc commit"
24+
echo "Could not extract date from rustc commit"
2525
exit 1
2626
fi
2727

2828
# Toolchain itself does not need to be versioned by default. It makes referencing it from
2929
# various other projects harder while things are in development. Version can be queried by
30-
# calling `rustc --version anyways`. If someone needs to keep an older version they can
30+
# calling `rustc --version` anyway. If someone needs to keep an older version they can
3131
# always rename the folder at install time.
3232
export TOOLCHAIN_NAME=rve-nightly
3333

patches/rust.patch

Lines changed: 45 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,48 @@
11
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
2-
index 6c698c5b0..357cd0e3e 100644
2+
index 235ab0b6e7d..87b204d711a 100644
33
--- a/compiler/rustc_target/src/spec/mod.rs
44
+++ b/compiler/rustc_target/src/spec/mod.rs
5-
@@ -1596,6 +1596,7 @@ fn $module() {
5+
@@ -1635,6 +1635,7 @@ fn $module() {
66

77
("x86_64-unikraft-linux-musl", x86_64_unikraft_linux_musl),
88

99
+ ("riscv32em-athena-zkvm-elf", riscv32em_athena_zkvm_elf),
1010
("riscv32i-unknown-none-elf", riscv32i_unknown_none_elf),
11-
("riscv32im-risc0-zkvm-elf", riscv32im_risc0_zkvm_elf),
11+
("riscv32im-succinct-zkvm-elf", riscv32im_succinct_zkvm_elf),
1212
("riscv32im-unknown-none-elf", riscv32im_unknown_none_elf),
13+
diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs
14+
index 8e9d342e65d..d2dae37d73a 100644
15+
--- a/src/bootstrap/src/lib.rs
16+
+++ b/src/bootstrap/src/lib.rs
17+
@@ -101,7 +101,7 @@
18+
// #[cfg(bootstrap)] zkvm
19+
(Some(Mode::Std), "target_os", Some(&["zkvm"])),
20+
// #[cfg(bootstrap)] succinct
21+
- (Some(Mode::Std), "target_vendor", Some(&["succinct"])),
22+
+ (Some(Mode::Std), "target_vendor", Some(&["athena", "succinct"])),
23+
(Some(Mode::Std), "target_arch", Some(&["asmjs", "spirv", "nvptx", "xtensa"])),
24+
/* Extra names used by dependencies */
25+
// FIXME: Used by serde_json, but we should not be triggering on external dependencies.
26+
diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs
27+
index ea620c64f3c..28363a2cb8a 100644
28+
--- a/src/tools/build-manifest/src/main.rs
29+
+++ b/src/tools/build-manifest/src/main.rs
30+
@@ -119,6 +119,7 @@
31+
"powerpc-unknown-linux-gnu",
32+
"powerpc64-unknown-linux-gnu",
33+
"powerpc64le-unknown-linux-gnu",
34+
+ "riscv32e-athena-zkvm-elf",
35+
"riscv32i-unknown-none-elf",
36+
"riscv32im-succinct-zkvm-elf",
37+
"riscv32im-unknown-none-elf",
1338
diff --git a/compiler/rustc_target/src/spec/targets/riscv32em_athena_zkvm_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32em_athena_zkvm_elf.rs
1439
new file mode 100644
15-
index 000000000..7a09c78a4
40+
index 00000000000..0ac603543b9
1641
--- /dev/null
1742
+++ b/compiler/rustc_target/src/spec/targets/riscv32em_athena_zkvm_elf.rs
18-
@@ -0,0 +1,29 @@
19-
+use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
43+
@@ -0,0 +1,38 @@
44+
+use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel};
45+
+use crate::spec::{Target, TargetOptions};
2046
+
2147
+pub fn target() -> Target {
2248
+ Target {
@@ -26,86 +52,30 @@ index 000000000..7a09c78a4
2652
+ arch: "riscv32".into(),
2753
+
2854
+ options: TargetOptions {
55+
+ os: "zkvm".into(),
56+
+ vendor: "athena".into(),
2957
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
3058
+ linker: Some("rust-lld".into()),
3159
+ cpu: "generic-rv32".into(),
32-
+ features: "+e,+m".into(),
33-
+ llvm_abiname: "ilp32e".into(),
60+
+
61+
+ // Some crates (*cough* crossbeam) assume you have 64 bit
62+
+ // atomics if the target name is not in a hardcoded list.
63+
+ // Since zkvm is singlethreaded and all operations are
64+
+ // atomic, I guess we can just say we support 64-bit
65+
+ // atomics.
3466
+ max_atomic_width: Some(64),
35-
+ os: "zkvm".into(),
36-
+ vendor: "athena".into(),
37-
+ singlethread: true,
3867
+ atomic_cas: true,
68+
+
69+
+ features: "+e,+m".into(),
70+
+ llvm_abiname: "ilp32e".into(),
3971
+ executables: true,
4072
+ panic_strategy: PanicStrategy::Abort,
4173
+ relocation_model: RelocModel::Static,
4274
+ emit_debug_gdb_scripts: false,
4375
+ eh_frame_header: false,
76+
+ singlethread: true,
4477
+ ..Default::default()
4578
+ },
4679
+ }
4780
+}
48-
diff --git a/library/std/src/sys/pal/zkvm/args.rs b/library/std/src/sys/pal/zkvm/args.rs
49-
index 7753cf63840..583c16e3a47 100644
50-
--- a/library/std/src/sys/pal/zkvm/args.rs
51-
+++ b/library/std/src/sys/pal/zkvm/args.rs
52-
@@ -1,6 +1,7 @@
53-
use super::{abi, WORD_SIZE};
54-
use crate::ffi::OsString;
55-
use crate::fmt;
56-
+use crate::sys::os_str;
57-
use crate::sys_common::FromInner;
58-
59-
pub struct Args {
60-
@@ -33,7 +34,7 @@ fn argv(i: usize) -> OsString {
61-
// "os_str".
62-
let arg_bytes: &[u8] =
63-
unsafe { crate::slice::from_raw_parts(words.cast() as *const u8, arg_len) };
64-
- OsString::from_inner(super::os_str::Buf { inner: arg_bytes.to_vec() })
65-
+ OsString::from_inner(os_str::Buf { inner: arg_bytes.to_vec() })
66-
}
67-
}
68-
69-
diff --git a/library/std/src/sys/pal/zkvm/os.rs b/library/std/src/sys/pal/zkvm/os.rs
70-
index d8739ee3824..759beb2d306 100644
71-
--- a/library/std/src/sys/pal/zkvm/os.rs
72-
+++ b/library/std/src/sys/pal/zkvm/os.rs
73-
@@ -5,6 +5,7 @@
74-
use crate::io;
75-
use crate::marker::PhantomData;
76-
use crate::path::{self, PathBuf};
77-
+use crate::sys::os_str;
78-
use crate::sys_common::FromInner;
79-
80-
pub fn errno() -> i32 {
81-
@@ -111,7 +112,7 @@ pub fn getenv(varname: &OsStr) -> Option<OsString> {
82-
// reimplement "os_str" instead of just using the generic unix
83-
// "os_str".
84-
let u8s: &[u8] = unsafe { crate::slice::from_raw_parts(words.cast() as *const u8, nbytes) };
85-
- Some(OsString::from_inner(super::os_str::Buf { inner: u8s.to_vec() }))
86-
+ Some(OsString::from_inner(os_str::Buf { inner: u8s.to_vec() }))
87-
}
88-
89-
pub fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> {
90-
diff --git a/library/std/src/sys/pal/zkvm/mod.rs b/library/std/src/sys/pal/zkvm/mod.rs
91-
index 7f221dc4fd9..ebdcb6abbdb 100644
92-
--- a/library/std/src/sys/pal/zkvm/mod.rs
93-
+++ b/library/std/src/sys/pal/zkvm/mod.rs
94-
@@ -12,8 +12,6 @@
95-
pub mod alloc;
96-
#[path = "../zkvm/args.rs"]
97-
pub mod args;
98-
-#[path = "../unix/cmath.rs"]
99-
-pub mod cmath;
100-
pub mod env;
101-
#[path = "../unsupported/fs.rs"]
102-
pub mod fs;
103-
@@ -24,8 +22,6 @@
104-
#[path = "../unsupported/once.rs"]
105-
pub mod once;
106-
pub mod os;
107-
-#[path = "../unix/os_str.rs"]
108-
-pub mod os_str;
109-
#[path = "../unix/path.rs"]
110-
pub mod path;
111-
#[path = "../unsupported/pipe.rs"]
81+
+

0 commit comments

Comments
 (0)