Skip to content

Commit 7e2578b

Browse files
dmakarovLucasSte
authored andcommitted
[SOL] Adjust SBF customization after upgrading to rust 1.72.0
1 parent ce2ef4e commit 7e2578b

File tree

22 files changed

+767
-336
lines changed

22 files changed

+767
-336
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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,18 @@ pub(crate) unsafe fn codegen(
8383
let llval = llvm::LLVMConstInt(i8, val as u64, False);
8484
llvm::LLVMSetInitializer(ll_g, llval);
8585

86+
<<<<<<< HEAD
8687
let name = NO_ALLOC_SHIM_IS_UNSTABLE;
8788
let ll_g = llvm::LLVMRustGetOrInsertGlobal(llmod, name.as_c_char_ptr(), name.len(), i8);
8889
llvm::set_visibility(ll_g, llvm::Visibility::from_generic(tcx.sess.default_visibility()));
90+
=======
91+
if tcx.sess.target.arch != "sbf" {
92+
let name = NO_ALLOC_SHIM_IS_UNSTABLE;
93+
let ll_g = llvm::LLVMRustGetOrInsertGlobal(llmod, name.as_ptr().cast(), name.len(), i8);
94+
if tcx.sess.default_hidden_visibility() {
95+
llvm::LLVMRustSetVisibility(ll_g, llvm::Visibility::Hidden);
96+
}
97+
>>>>>>> 9cabb400053 ([SOL] Adjust SBF customization after upgrading to rust 1.72.0)
8998
let llval = llvm::LLVMConstInt(i8, 0, False);
9099
llvm::LLVMSetInitializer(ll_g, llval);
91100
}

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/core/src/fmt/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
use crate::cell::{Cell, Ref, RefCell, RefMut, SyncUnsafeCell, UnsafeCell};
66
use crate::char::EscapeDebugExtArgs;
7+
<<<<<<< HEAD
8+
=======
9+
use crate::iter;
10+
>>>>>>> 9cabb400053 ([SOL] Adjust SBF customization after upgrading to rust 1.72.0)
711
use crate::marker::PhantomData;
812
use crate::num::fmt as numfmt;
913
use crate::ops::Deref;

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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
33
use super::select::Selected;
44
use super::waker::current_thread_id;
5+
<<<<<<< HEAD
6+
=======
7+
8+
#[cfg(not(target_family = "solana"))]
9+
>>>>>>> 9cabb400053 ([SOL] Adjust SBF customization after upgrading to rust 1.72.0)
510
use crate::cell::Cell;
611
use crate::ptr;
712
use crate::sync::Arc;
@@ -33,6 +38,7 @@ struct Inner {
3338

3439
impl Context {
3540
/// Creates a new context for the duration of the closure.
41+
#[cfg(not(target_family = "solana"))]
3642
#[inline]
3743
pub fn with<F, R>(f: F) -> R
3844
where
@@ -62,6 +68,15 @@ impl Context {
6268
.unwrap_or_else(|_| f(&Context::new()))
6369
}
6470

71+
#[cfg(target_family = "solana")]
72+
#[inline]
73+
pub fn with<F, R>(f: F) -> R
74+
where
75+
F: FnOnce(&Context) -> R,
76+
{
77+
f(&Context::new())
78+
}
79+
6580
/// Creates a new `Context`.
6681
#[cold]
6782
fn new() -> Context {
@@ -76,6 +91,7 @@ impl Context {
7691
}
7792

7893
/// Resets `select` and `packet`.
94+
#[cfg(not(target_family = "solana"))]
7995
#[inline]
8096
fn reset(&self) {
8197
self.inner.select.store(Selected::Waiting.into(), Ordering::Release);

0 commit comments

Comments
 (0)