Skip to content

Commit ad7e15c

Browse files
dmakarovLucasSte
authored andcommitted
[SOL] Adjust SBF customization after upgrading to rust 1.72.0
1 parent aeb53ff commit ad7e15c

File tree

21 files changed

+760
-341
lines changed

21 files changed

+760
-341
lines changed

.github/workflows/ci.yml

Lines changed: 690 additions & 0 deletions
Large diffs are not rendered by default.

compiler/rustc_codegen_llvm/src/allocator.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,15 @@ pub(crate) unsafe fn codegen(
8383
let llval = llvm::LLVMConstInt(i8, val as u64, False);
8484
llvm::LLVMSetInitializer(ll_g, llval);
8585

86-
let name = NO_ALLOC_SHIM_IS_UNSTABLE;
87-
let ll_g = llvm::LLVMRustGetOrInsertGlobal(llmod, name.as_c_char_ptr(), name.len(), i8);
88-
llvm::set_visibility(ll_g, llvm::Visibility::from_generic(tcx.sess.default_visibility()));
89-
let llval = llvm::LLVMConstInt(i8, 0, False);
90-
llvm::LLVMSetInitializer(ll_g, llval);
86+
if tcx.sess.target.arch != "sbf" {
87+
let name = NO_ALLOC_SHIM_IS_UNSTABLE;
88+
let ll_g = llvm::LLVMRustGetOrInsertGlobal(llmod, name.as_ptr().cast(), name.len(), i8);
89+
if tcx.sess.default_hidden_visibility() {
90+
llvm::LLVMRustSetVisibility(ll_g, llvm::Visibility::Hidden);
91+
}
92+
let llval = llvm::LLVMConstInt(i8, 0, False);
93+
llvm::LLVMSetInitializer(ll_g, llval);
94+
}
9195
}
9296

9397
if tcx.sess.opts.debuginfo != DebugInfo::None {

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2128,7 +2128,7 @@ fn patch_synthetic_object_file(sess: &Session, path: &PathBuf) {
21282128
sf.write(&EM_SBF).unwrap();
21292129
}
21302130
} else {
2131-
sess.fatal(&format!("failed to patch {}", path.display()));
2131+
sess.fatal(format!("failed to patch {}", path.display()));
21322132
}
21332133
}
21342134

config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ experimental-targets = "BPF;SBF"
7474
# each linker process.
7575
# If absent or 0, linker invocations are treated like any other job and
7676
# controlled by rustbuild's -j parameter.
77-
#link-jobs = 0
77+
link-jobs = 2
7878

7979
# When invoking `llvm-config` this configures whether the `--shared` argument is
8080
# passed to prefer linking to shared libraries.

library/alloc/src/alloc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ extern "Rust" {
3434
#[rustc_nounwind]
3535
fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;
3636

37+
#[cfg(not(target_family = "solana"))]
3738
static __rust_no_alloc_shim_is_unstable: u8;
3839
}
3940

@@ -94,6 +95,7 @@ pub unsafe fn alloc(layout: Layout) -> *mut u8 {
9495
unsafe {
9596
// Make sure we don't accidentally allow omitting the allocator shim in
9697
// stable code until it is actually stabilized.
98+
#[cfg(not(target_family = "solana"))]
9799
core::ptr::read_volatile(&__rust_no_alloc_shim_is_unstable);
98100

99101
__rust_alloc(layout.size(), layout.align())

library/std/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ crate-type = ["dylib", "rlib"]
1414
[dependencies]
1515
alloc = { path = "../alloc", public = true }
1616
cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
17+
panic_unwind = { path = "../panic_unwind", optional = true }
1718
panic_abort = { path = "../panic_abort" }
1819
core = { path = "../core", public = true }
1920
compiler_builtins = { version = "=0.1.138" }

library/std/src/io/stdio.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,9 @@ impl Read for Stdin {
521521
fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {
522522
Ok(0)
523523
}
524+
fn read_buf(&mut self, _buf: BorrowedCursor<'_>) -> io::Result<()> {
525+
Ok(())
526+
}
524527
fn read_vectored(&mut self, _bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
525528
Ok(0)
526529
}

library/std/src/panicking.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ pub mod panic_count {
454454
})
455455
}
456456

457+
#[cfg(not(target_family = "solana"))]
457458
pub fn finished_panic_hook() {
458459
LOCAL_PANIC_COUNT.with(|c| {
459460
let (count, _) = c.get();

library/std/src/sync/mpmc/context.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
33
use super::select::Selected;
44
use super::waker::current_thread_id;
5+
6+
#[cfg(not(target_family = "solana"))]
57
use crate::cell::Cell;
68
use crate::ptr;
79
use crate::sync::Arc;
@@ -33,6 +35,7 @@ struct Inner {
3335

3436
impl Context {
3537
/// Creates a new context for the duration of the closure.
38+
#[cfg(not(target_family = "solana"))]
3639
#[inline]
3740
pub fn with<F, R>(f: F) -> R
3841
where
@@ -62,6 +65,15 @@ impl Context {
6265
.unwrap_or_else(|_| f(&Context::new()))
6366
}
6467

68+
#[cfg(target_family = "solana")]
69+
#[inline]
70+
pub fn with<F, R>(f: F) -> R
71+
where
72+
F: FnOnce(&Context) -> R,
73+
{
74+
f(&Context::new())
75+
}
76+
6577
/// Creates a new `Context`.
6678
#[cold]
6779
fn new() -> Context {
@@ -76,6 +88,7 @@ impl Context {
7688
}
7789

7890
/// Resets `select` and `packet`.
91+
#[cfg(not(target_family = "solana"))]
7992
#[inline]
8093
fn reset(&self) {
8194
self.inner.select.store(Selected::Waiting.into(), Ordering::Release);

library/std/src/sync/mpmc/waker.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,18 @@ impl Drop for SyncWaker {
200200
}
201201

202202
/// Returns a unique id for the current thread.
203+
#[cfg(not(target_family = "solana"))]
203204
#[inline]
204205
pub fn current_thread_id() -> usize {
205206
// `u8` is not drop so this variable will be available during thread destruction,
206207
// whereas `thread::current()` would not be
207208
thread_local! { static DUMMY: u8 = 0 }
208209
DUMMY.with(|x| (x as *const u8).addr())
209210
}
211+
212+
/// Returns a unique id for the current thread.
213+
#[cfg(target_family = "solana")]
214+
#[inline]
215+
pub fn current_thread_id() -> usize {
216+
0
217+
}

0 commit comments

Comments
 (0)