Skip to content

Commit 33b0cee

Browse files
dmakarovLucasSte
authored andcommitted
[SOL] Adjust SBF customization after upgrading to rust 1.68.0
1 parent 77b153a commit 33b0cee

File tree

21 files changed

+76
-38
lines changed

21 files changed

+76
-38
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ jobs:
104104
- name: checkout the source code
105105
uses: actions/checkout@v4
106106
with:
107-
<<<<<<< HEAD
108107
fetch-depth: 2
109108

110109
# Free up disk space on Linux by removing preinstalled components that
@@ -118,9 +117,6 @@ jobs:
118117
# Rust Log Analyzer can't currently detect the PR number of a GitHub
119118
# Actions build on its own, so a hint in the log message is needed to
120119
# point it in the right direction.
121-
=======
122-
fetch-depth: 0
123-
>>>>>>> 04bf0475aa2 ([SOL] Fix Ci error caused by insufficient git history fetched)
124120
- name: configure the PR in which the error message will be posted
125121
run: echo "[CI_PR_NUMBER=$num]"
126122
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/core/tests/slice.rs

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

1812-
let mut rng = StdRng::seed_from_u64(0);
1812+
let mut rng = crate::test_rng();
18131813

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

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

library/std/Cargo.toml

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

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

library/std/src/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ impl<E> Report<E>
450450
where
451451
E: Error,
452452
{
453+
#[cfg(not(target_family = "solana"))]
453454
fn backtrace(&self) -> Option<&Backtrace> {
454455
// have to grab the backtrace on the first error directly since that error may not be
455456
// 'static
@@ -500,6 +501,7 @@ where
500501
}
501502
}
502503

504+
#[cfg(not(target_family = "solana"))]
503505
if self.show_backtrace {
504506
if let Some(backtrace) = self.backtrace() {
505507
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};
@@ -1340,6 +1341,7 @@ where
13401341
}
13411342
}
13421343

1344+
#[cfg(not(target_family = "solana"))]
13431345
fn print_to_buffer_if_capture_used(args: fmt::Arguments<'_>) -> bool {
13441346
OUTPUT_CAPTURE_USED.load(Ordering::Relaxed)
13451347
&& OUTPUT_CAPTURE.try_with(|s| {
@@ -1356,6 +1358,7 @@ fn print_to_buffer_if_capture_used(args: fmt::Arguments<'_>) -> bool {
13561358
/// Used by impl Termination for Result to print error after `main` or a test
13571359
/// has returned. Should avoid panicking, although we can't help it if one of
13581360
/// the Display impls inside args decides to.
1361+
#[cfg(not(target_family = "solana"))]
13591362
pub(crate) fn attempt_print_to_stderr(args: fmt::Arguments<'_>) {
13601363
if print_to_buffer_if_capture_used(args) {
13611364
return;
@@ -1420,6 +1423,7 @@ pub trait IsTerminal: crate::sealed::Sealed {
14201423
fn is_terminal(&self) -> bool;
14211424
}
14221425

1426+
#[cfg(not(target_family = "solana"))]
14231427
macro_rules! impl_is_terminal {
14241428
($($t:ty),*$(,)?) => {$(
14251429
#[unstable(feature = "sealed", issue = "none")]
@@ -1435,6 +1439,7 @@ macro_rules! impl_is_terminal {
14351439
)*}
14361440
}
14371441

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

14401445
#[unstable(

library/std/src/panicking.rs

Lines changed: 5 additions & 6 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")))]
@@ -72,7 +71,7 @@ extern "C" fn __rust_foreign_exception() -> ! {
7271
rtabort!("Rust cannot catch foreign exceptions");
7372
}
7473

75-
#[cfg(not(target_os = "solana"))]
74+
#[cfg(not(target_family = "solana"))]
7675
enum Hook {
7776
Default,
7877
Custom(Box<dyn Fn(&PanicHookInfo<'_>) + 'static + Sync + Send>),
@@ -89,15 +88,15 @@ impl Hook {
8988
}
9089
}
9190

92-
#[cfg(not(target_os = "solana"))]
91+
#[cfg(not(target_family = "solana"))]
9392
impl Default for Hook {
9493
#[inline]
9594
fn default() -> Hook {
9695
Hook::Default
9796
}
9897
}
9998

100-
#[cfg(not(target_os = "solana"))]
99+
#[cfg(not(target_family = "solana"))]
101100
static HOOK: RwLock<Hook> = RwLock::new(Hook::Default);
102101

103102
/// Registers a custom panic hook, replacing the previously registered hook.
@@ -437,7 +436,7 @@ pub mod panic_count {
437436
//
438437
// This also updates thread-local state to keep track of whether a panic
439438
// hook is currently executing.
440-
#[cfg(not(target_os = "solana"))]
439+
#[cfg(not(target_family = "solana"))]
441440
pub fn increase(run_panic_hook: bool) -> Option<MustAbort> {
442441
let global_count = GLOBAL_PANIC_COUNT.fetch_add(1, Ordering::Relaxed);
443442
if global_count & ALWAYS_ABORT_FLAG != 0 {
@@ -505,7 +504,7 @@ pub mod panic_count {
505504

506505
// Slow path is in a separate function to reduce the amount of code
507506
// inlined from `count_is_zero`.
508-
#[cfg(not(target_os = "solana"))]
507+
#[cfg(not(target_family = "solana"))]
509508
#[inline(never)]
510509
#[cold]
511510
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
@@ -2452,10 +2452,15 @@ impl<T: Termination, E: fmt::Debug> Termination for Result<T, E> {
24522452
fn report(self) -> ExitCode {
24532453
match self {
24542454
Ok(val) => val.report(),
2455+
#[cfg(not(target_family = "solana"))]
24552456
Err(err) => {
24562457
io::attempt_print_to_stderr(format_args_nl!("Error: {err:?}"));
24572458
ExitCode::FAILURE
24582459
}
2460+
#[cfg(target_family = "solana")]
2461+
Err(_err) => {
2462+
ExitCode::FAILURE
2463+
}
24592464
}
24602465
}
24612466
}

library/std/src/rt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ fn lang_start<T: crate::process::Termination + 'static>(
216216
main: fn() -> T,
217217
_argc: isize,
218218
_argv: *const *const u8,
219+
_sigpipe: u8,
219220
) -> isize {
220221
main().report().to_i32() as isize
221222
}

0 commit comments

Comments
 (0)