Skip to content

Commit d9154bd

Browse files
dmakarovLucasSte
authored andcommitted
[SOL] Adjust SBF customization after upgrading to rust 1.68.0
1 parent 8577f44 commit d9154bd

File tree

21 files changed

+75
-37
lines changed

21 files changed

+75
-37
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ jobs:
128128
- name: checkout the source code
129129
uses: actions/checkout@v4
130130
with:
131-
<<<<<<< HEAD
132131
fetch-depth: 2
133132

134133
# Free up disk space on Linux by removing preinstalled components that
@@ -142,9 +141,6 @@ jobs:
142141
# Rust Log Analyzer can't currently detect the PR number of a GitHub
143142
# Actions build on its own, so a hint in the log message is needed to
144143
# point it in the right direction.
145-
=======
146-
fetch-depth: 0
147-
>>>>>>> 04bf0475aa2 ([SOL] Fix Ci error caused by insufficient git history fetched)
148144
- name: configure the PR in which the error message will be posted
149145
run: echo "[CI_PR_NUMBER=$num]"
150146
env:

compiler/rustc_target/src/spec/sbf_base.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::abi::Endian;
2-
use super::{cvs, LinkArgs, LinkerFlavor, PanicStrategy, TargetOptions, LldFlavor};
2+
use super::{Cc, cvs, LinkerFlavor, Lld, PanicStrategy, TargetOptions};
33

44
pub fn opts() -> TargetOptions {
55
let linker_script = r"
@@ -28,13 +28,10 @@ SECTIONS
2828
}
2929
}
3030
";
31-
let mut lld_args = Vec::new();
32-
lld_args.push("--threads=1".into());
33-
lld_args.push("-z".into());
34-
lld_args.push("notext".into());
35-
let mut pre_link_args = LinkArgs::new();
36-
pre_link_args.insert(LinkerFlavor::Ld, lld_args.clone());
37-
pre_link_args.insert(LinkerFlavor::Lld(LldFlavor::Ld), lld_args);
31+
let pre_link_args = TargetOptions::link_args(
32+
LinkerFlavor::Gnu(Cc::No, Lld::No),
33+
&["--threads=1", "-z", "notext"],
34+
);
3835

3936
TargetOptions {
4037
allow_asm: true,
@@ -50,8 +47,7 @@ SECTIONS
5047
families: cvs!["solana"],
5148
link_script: Some(linker_script.into()),
5249
linker: Some("rust-lld".into()),
53-
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
54-
linker_is_gnu: true,
50+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
5551
main_needs_argc_argv: false,
5652
max_atomic_width: Some(64),
5753
no_default_libraries: true,

config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ link-shared = false
108108
# Which LLVM projects to build along with the LLVM base libraries/tools
109109
enable-projects = "clang;lld;lldb"
110110

111+
download-ci-llvm = false
112+
111113
# =============================================================================
112114
# General build configuration options
113115
# =============================================================================

library/coretests/tests/slice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,9 +1810,9 @@ fn select_nth_unstable() {
18101810
use rand::Rng;
18111811
use rand::seq::IndexedRandom;
18121812

1813-
let mut rng = StdRng::seed_from_u64(0);
1813+
let mut rng = crate::test_rng();
18141814

1815-
for len in (2..21).chain(200..201) {
1815+
for len in (2..21).chain(500..501) {
18161816
let mut orig = vec![0; len];
18171817

18181818
for &modulus in &[5, 10, 1000] {

library/std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ std_detect = { path = "../stdarch/crates/std_detect", default-features = false,
2727
] }
2828

2929
# Dependencies of the `backtrace` crate
30-
[target.'cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))'.dependencies]
30+
[target.'cfg(not(target_family = "solana"))'.dependencies]
3131
addr2line = { version = "0.22.0", optional = true, default-features = false }
3232
rustc-demangle = { version = "0.1.24", features = ['rustc-dep-of-std'] }
3333

library/std/src/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ impl<E> Report<E>
447447
where
448448
E: Error,
449449
{
450+
#[cfg(not(target_family = "solana"))]
450451
fn backtrace(&self) -> Option<&Backtrace> {
451452
// have to grab the backtrace on the first error directly since that error may not be
452453
// 'static
@@ -497,6 +498,7 @@ where
497498
}
498499
}
499500

501+
#[cfg(not(target_family = "solana"))]
500502
if self.show_backtrace {
501503
if let Some(backtrace) = self.backtrace() {
502504
write!(f, "\n\nStack backtrace:\n{}", backtrace.to_string().trim_end())?;

library/std/src/io/stdio.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mod tests;
77
#[cfg(not(target_family = "solana"))]
88
use crate::cell::{Cell, RefCell};
99
use crate::fmt;
10+
#[cfg(not(target_family = "solana"))]
1011
use crate::fs::File;
1112
use crate::io::prelude::*;
1213
use crate::panic::{RefUnwindSafe, UnwindSafe};
@@ -1378,6 +1379,7 @@ where
13781379
}
13791380
}
13801381

1382+
#[cfg(not(target_family = "solana"))]
13811383
fn print_to_buffer_if_capture_used(args: fmt::Arguments<'_>) -> bool {
13821384
OUTPUT_CAPTURE_USED.load(Ordering::Relaxed)
13831385
&& OUTPUT_CAPTURE.try_with(|s| {
@@ -1394,6 +1396,7 @@ fn print_to_buffer_if_capture_used(args: fmt::Arguments<'_>) -> bool {
13941396
/// Used by impl Termination for Result to print error after `main` or a test
13951397
/// has returned. Should avoid panicking, although we can't help it if one of
13961398
/// the Display impls inside args decides to.
1399+
#[cfg(not(target_family = "solana"))]
13971400
pub(crate) fn attempt_print_to_stderr(args: fmt::Arguments<'_>) {
13981401
if print_to_buffer_if_capture_used(args) {
13991402
return;
@@ -1459,6 +1462,7 @@ pub trait IsTerminal: crate::sealed::Sealed {
14591462
fn is_terminal(&self) -> bool;
14601463
}
14611464

1465+
#[cfg(not(target_family = "solana"))]
14621466
macro_rules! impl_is_terminal {
14631467
($($t:ty),*$(,)?) => {$(
14641468
#[unstable(feature = "sealed", issue = "none")]
@@ -1474,6 +1478,7 @@ macro_rules! impl_is_terminal {
14741478
)*}
14751479
}
14761480

1481+
#[cfg(not(target_family = "solana"))]
14771482
impl_is_terminal!(File, Stdin, StdinLock<'_>, Stdout, StdoutLock<'_>, Stderr, StderrLock<'_>);
14781483

14791484
#[unstable(

library/std/src/panicking.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
use core::panic::Location;
1313
#[cfg(not(target_os = "solana"))]
14-
use core::panic::PanicPayload;
1514
// make sure to use the stderr output configured
1615
// by libtest in the real copy of std
1716
#[cfg(all(test, not(target_family = "solana")))]
@@ -110,15 +109,15 @@ impl Hook {
110109
}
111110
}
112111

113-
#[cfg(not(target_os = "solana"))]
112+
#[cfg(not(target_family = "solana"))]
114113
impl Default for Hook {
115114
#[inline]
116115
fn default() -> Hook {
117116
Hook::Default
118117
}
119118
}
120119

121-
#[cfg(not(target_os = "solana"))]
120+
#[cfg(not(target_family = "solana"))]
122121
static HOOK: RwLock<Hook> = RwLock::new(Hook::Default);
123122

124123
/// Registers a custom panic hook, replacing the previously registered hook.
@@ -477,7 +476,7 @@ pub mod panic_count {
477476
//
478477
// This also updates thread-local state to keep track of whether a panic
479478
// hook is currently executing.
480-
#[cfg(not(target_os = "solana"))]
479+
#[cfg(not(target_family = "solana"))]
481480
pub fn increase(run_panic_hook: bool) -> Option<MustAbort> {
482481
let global_count = GLOBAL_PANIC_COUNT.fetch_add(1, Ordering::Relaxed);
483482
if global_count & ALWAYS_ABORT_FLAG != 0 {
@@ -545,7 +544,7 @@ pub mod panic_count {
545544

546545
// Slow path is in a separate function to reduce the amount of code
547546
// inlined from `count_is_zero`.
548-
#[cfg(not(target_os = "solana"))]
547+
#[cfg(not(target_family = "solana"))]
549548
#[inline(never)]
550549
#[cold]
551550
fn is_zero_slow_path() -> bool {

library/std/src/process.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,10 +2577,15 @@ impl<T: Termination, E: fmt::Debug> Termination for Result<T, E> {
25772577
fn report(self) -> ExitCode {
25782578
match self {
25792579
Ok(val) => val.report(),
2580+
#[cfg(not(target_family = "solana"))]
25802581
Err(err) => {
25812582
io::attempt_print_to_stderr(format_args_nl!("Error: {err:?}"));
25822583
ExitCode::FAILURE
25832584
}
2585+
#[cfg(target_family = "solana")]
2586+
Err(_err) => {
2587+
ExitCode::FAILURE
2588+
}
25842589
}
25852590
}
25862591
}

library/std/src/rt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ fn lang_start<T: crate::process::Termination + 'static>(
226226
main: fn() -> T,
227227
_argc: isize,
228228
_argv: *const *const u8,
229+
_sigpipe: u8,
229230
) -> isize {
230231
main().report().to_i32() as isize
231232
}

0 commit comments

Comments
 (0)