Skip to content

Commit 2ac5f67

Browse files
committed
Build now working with new rust
Apply missing patches from master and work around an issue in compiler_builtins
1 parent 3cee681 commit 2ac5f67

File tree

1 file changed

+83
-1
lines changed

1 file changed

+83
-1
lines changed

patches/rust.patch

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
diff --git a/Cargo.toml b/Cargo.toml
2+
index 5dd315ef2f7..680fb821c4c 100644
3+
--- a/Cargo.toml
4+
+++ b/Cargo.toml
5+
@@ -120,6 +120,7 @@ strip = true
6+
rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' }
7+
rustc-std-workspace-alloc = { path = 'library/rustc-std-workspace-alloc' }
8+
rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' }
9+
+compiler_builtins = { git = "https://github.com/rust-lang/compiler-builtins", rev = "0.1.105" }
10+
11+
[patch."https://github.com/rust-lang/rust-clippy"]
12+
clippy_lints = { path = "src/tools/clippy/clippy_lints" }
113
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
214
index 941d767b..1b4004c4 100644
315
--- a/compiler/rustc_target/src/spec/mod.rs
@@ -10,6 +22,21 @@ index 941d767b..1b4004c4 100644
1022
("riscv32i-unknown-none-elf", riscv32i_unknown_none_elf),
1123
("riscv32im-risc0-zkvm-elf", riscv32im_risc0_zkvm_elf),
1224
("riscv32im-unknown-none-elf", riscv32im_unknown_none_elf),
25+
diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs
26+
index 5ed6b357e20..a31645ab6e7 100644
27+
--- a/src/bootstrap/src/lib.rs
28+
+++ b/src/bootstrap/src/lib.rs
29+
@@ -91,6 +91,10 @@
30+
/* Extra values not defined in the built-in targets yet, but used in std */
31+
(Some(Mode::Std), "target_env", Some(&["libnx", "p2"])),
32+
// (Some(Mode::Std), "target_os", Some(&[])),
33+
+ // #[cfg(bootstrap)] zkvm
34+
+ (Some(Mode::Std), "target_os", Some(&["zkvm"])),
35+
+ // #[cfg(bootstrap)] athena
36+
+ (Some(Mode::Std), "target_vendor", Some(&["athena", "succinct"])),
37+
(Some(Mode::Std), "target_arch", Some(&["arm64ec", "spirv", "nvptx", "xtensa"])),
38+
/* Extra names used by dependencies */
39+
// FIXME: Used by serde_json, but we should not be triggering on external dependencies.
1340
diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs
1441
index eab9138b..60507063 100644
1542
--- a/src/tools/build-manifest/src/main.rs
@@ -18,7 +45,7 @@ index eab9138b..60507063 100644
1845
"powerpc-unknown-linux-gnu",
1946
"powerpc64-unknown-linux-gnu",
2047
"powerpc64le-unknown-linux-gnu",
21-
+ "riscv32e-athena-zkvm-elf",
48+
+ "riscv32em-athena-zkvm-elf",
2249
"riscv32i-unknown-none-elf",
2350
"riscv32im-risc0-zkvm-elf",
2451
"riscv32im-unknown-none-elf",
@@ -72,3 +99,58 @@ index 00000000..a84f76c2
7299
+ }
73100
+}
74101
+
102+
diff --git a/library/std/src/sys/pal/zkvm/args.rs b/library/std/src/sys/pal/zkvm/args.rs
103+
index 7753cf63840..583c16e3a47 100644
104+
--- a/library/std/src/sys/pal/zkvm/args.rs
105+
+++ b/library/std/src/sys/pal/zkvm/args.rs
106+
@@ -1,6 +1,7 @@
107+
use super::{abi, WORD_SIZE};
108+
use crate::ffi::OsString;
109+
use crate::fmt;
110+
+use crate::sys::os_str;
111+
use crate::sys_common::FromInner;
112+
113+
pub struct Args {
114+
@@ -33,7 +34,7 @@ fn argv(i: usize) -> OsString {
115+
// "os_str".
116+
let arg_bytes: &[u8] =
117+
unsafe { crate::slice::from_raw_parts(words.cast() as *const u8, arg_len) };
118+
- OsString::from_inner(super::os_str::Buf { inner: arg_bytes.to_vec() })
119+
+ OsString::from_inner(os_str::Buf { inner: arg_bytes.to_vec() })
120+
}
121+
}
122+
123+
diff --git a/library/std/src/sys/pal/zkvm/mod.rs b/library/std/src/sys/pal/zkvm/mod.rs
124+
index 228a976dbab..c5a1843d5ff 100644
125+
--- a/library/std/src/sys/pal/zkvm/mod.rs
126+
+++ b/library/std/src/sys/pal/zkvm/mod.rs
127+
@@ -12,8 +12,6 @@
128+
pub mod alloc;
129+
#[path = "../zkvm/args.rs"]
130+
pub mod args;
131+
-#[path = "../unix/cmath.rs"]
132+
-pub mod cmath;
133+
pub mod env;
134+
#[path = "../unsupported/fs.rs"]
135+
pub mod fs;
136+
diff --git a/library/std/src/sys/pal/zkvm/os.rs b/library/std/src/sys/pal/zkvm/os.rs
137+
index d8739ee3824..759beb2d306 100644
138+
--- a/library/std/src/sys/pal/zkvm/os.rs
139+
+++ b/library/std/src/sys/pal/zkvm/os.rs
140+
@@ -5,6 +5,7 @@
141+
use crate::io;
142+
use crate::marker::PhantomData;
143+
use crate::path::{self, PathBuf};
144+
+use crate::sys::os_str;
145+
use crate::sys_common::FromInner;
146+
147+
pub fn errno() -> i32 {
148+
@@ -111,7 +112,7 @@ pub fn getenv(varname: &OsStr) -> Option<OsString> {
149+
// reimplement "os_str" instead of just using the generic unix
150+
// "os_str".
151+
let u8s: &[u8] = unsafe { crate::slice::from_raw_parts(words.cast() as *const u8, nbytes) };
152+
- Some(OsString::from_inner(super::os_str::Buf { inner: u8s.to_vec() }))
153+
+ Some(OsString::from_inner(os_str::Buf { inner: u8s.to_vec() }))
154+
}
155+
156+
pub fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> {

0 commit comments

Comments
 (0)