Skip to content

Commit be84ef8

Browse files
dmakarovLucasSte
authored andcommitted
[SOL] Adjust SBF customization after upgrading to rust 1.68.0
1 parent f6029a3 commit be84ef8

File tree

24 files changed

+94
-44
lines changed

24 files changed

+94
-44
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ jobs:
7676
os: ubuntu-20.04-16core-64gb
7777
env: {}
7878
- name: sbf-solana-solana
79+
tidy: false
7980
os: ubuntu-latest
8081
env: {}
8182
- name: x86_64-gnu-tools
@@ -235,6 +236,9 @@ jobs:
235236
- name: install sccache
236237
run: src/ci/scripts/install-sccache.sh
237238
if: success() && !env.SKIP_JOB
239+
- name: select Xcode
240+
run: src/ci/scripts/select-xcode.sh
241+
if: success() && !env.SKIP_JOB
238242
- name: install clang
239243
run: src/ci/scripts/install-clang.sh
240244
if: success() && !env.SKIP_JOB

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: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,19 +1801,19 @@ fn brute_force_rotate_test_1() {
18011801
}
18021802

18031803
#[test]
1804-
#[cfg(not(target_arch = "wasm32"))]
1804+
#[cfg(not(any(target_arch = "wasm32", target_family = "solana")))]
18051805
fn sort_unstable() {
18061806
use core::cmp::Ordering::{Equal, Greater, Less};
18071807
use core::slice::heapsort;
18081808
use rand::{seq::SliceRandom, Rng};
18091809

18101810
// Miri is too slow (but still need to `chain` to make the types match)
1811-
let lens = if cfg!(miri) { (2..20).chain(0..0) } else { (2..25).chain(200..210) };
1811+
let lens = if cfg!(miri) { (2..20).chain(0..0) } else { (2..25).chain(500..510) };
18121812
let rounds = if cfg!(miri) { 1 } else { 100 };
18131813

1814-
let mut v = [0; 300];
1815-
let mut tmp = [0; 300];
1816-
let mut rng = StdRng::seed_from_u64(0);
1814+
let mut v = [0; 600];
1815+
let mut tmp = [0; 600];
1816+
let mut rng = crate::test_rng();
18171817

18181818
for len in lens {
18191819
let v = &mut v[0..len];
@@ -1875,16 +1875,16 @@ fn sort_unstable() {
18751875
}
18761876

18771877
#[test]
1878-
#[cfg(not(target_arch = "wasm32"))]
1878+
#[cfg(not(any(target_arch = "wasm32", target_family = "solana")))]
18791879
#[cfg_attr(miri, ignore)] // Miri is too slow
18801880
fn select_nth_unstable() {
18811881
use core::cmp::Ordering::{Equal, Greater, Less};
18821882
use rand::seq::SliceRandom;
18831883
use rand::Rng;
18841884

1885-
let mut rng = StdRng::seed_from_u64(0);
1885+
let mut rng = crate::test_rng();
18861886

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

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

library/std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ hashbrown = { version = "0.14", default-features = false, features = ['rustc-dep
2323
std_detect = { path = "../stdarch/crates/std_detect", default-features = false, features = ['rustc-dep-of-std'] }
2424

2525
# Dependencies of the `backtrace` crate
26-
[target.'cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))'.dependencies]
26+
[target.'cfg(not(target_family = "solana"))'.dependencies]
2727
addr2line = { version = "0.21.0", optional = true, default-features = false }
2828
rustc-demangle = { version = "0.1.21", features = ['rustc-dep-of-std'] }
2929

library/std/src/error.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#[cfg(test)]
55
mod tests;
66

7-
#[cfg(not(target_os = "solana"))]
7+
#[cfg(not(target_family = "solana"))]
88
use crate::backtrace::Backtrace;
99
use crate::fmt::{self, Write};
1010

@@ -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
let backtrace = self.backtrace();
505507

library/std/src/io/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ use core::slice::memchr;
310310
pub use self::buffered::WriterPanicked;
311311
#[unstable(feature = "raw_os_error_ty", issue = "107792")]
312312
pub use self::error::RawOsError;
313+
#[cfg(not(target_family = "solana"))]
313314
pub(crate) use self::stdio::attempt_print_to_stderr;
314315
#[stable(feature = "is_terminal", since = "1.70.0")]
315316
pub use self::stdio::IsTerminal;

library/std/src/io/stdio.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::io::prelude::*;
88
#[cfg(not(target_family = "solana"))]
99
use crate::cell::{Cell, RefCell};
1010
use crate::fmt;
11+
#[cfg(not(target_family = "solana"))]
1112
use crate::fs::File;
1213
#[cfg(not(target_os = "solana"))]
1314
use crate::io::{
@@ -1337,6 +1338,7 @@ where
13371338
}
13381339
}
13391340

1341+
#[cfg(not(target_family = "solana"))]
13401342
fn print_to_buffer_if_capture_used(args: fmt::Arguments<'_>) -> bool {
13411343
OUTPUT_CAPTURE_USED.load(Ordering::Relaxed)
13421344
&& OUTPUT_CAPTURE.try_with(|s| {
@@ -1353,6 +1355,7 @@ fn print_to_buffer_if_capture_used(args: fmt::Arguments<'_>) -> bool {
13531355
/// Used by impl Termination for Result to print error after `main` or a test
13541356
/// has returned. Should avoid panicking, although we can't help it if one of
13551357
/// the Display impls inside args decides to.
1358+
#[cfg(not(target_family = "solana"))]
13561359
pub(crate) fn attempt_print_to_stderr(args: fmt::Arguments<'_>) {
13571360
if print_to_buffer_if_capture_used(args) {
13581361
return;
@@ -1384,6 +1387,7 @@ pub trait IsTerminal: crate::sealed::Sealed {
13841387
fn is_terminal(&self) -> bool;
13851388
}
13861389

1390+
#[cfg(not(target_family = "solana"))]
13871391
macro_rules! impl_is_terminal {
13881392
($($t:ty),*$(,)?) => {$(
13891393
#[unstable(feature = "sealed", issue = "none")]
@@ -1399,6 +1403,7 @@ macro_rules! impl_is_terminal {
13991403
)*}
14001404
}
14011405

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

14041409
#[unstable(

library/std/src/panicking.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ use crate::mem;
2525
use crate::process;
2626
#[cfg(not(target_family = "solana"))]
2727
use crate::sync::atomic::{AtomicBool, Ordering};
28+
#[cfg(not(target_family = "solana"))]
2829
use crate::sync::{PoisonError, RwLock};
29-
#[cfg(not(target_os = "solana"))]
30+
#[cfg(not(target_family = "solana"))]
3031
use crate::sys::stdio::panic_output;
3132
#[cfg(not(target_family = "solana"))]
3233
use crate::sys_common::backtrace;
3334
#[cfg(not(target_family = "solana"))]
34-
use crate::sys_common::rwlock::StaticRwLock;
35-
#[cfg(not(target_family = "solana"))]
3635
use crate::sys_common::thread_info;
3736
#[cfg(not(target_family = "solana"))]
3837
use crate::thread;
@@ -83,7 +82,7 @@ extern "C" fn __rust_foreign_exception() -> ! {
8382
rtabort!("Rust cannot catch foreign exceptions");
8483
}
8584

86-
#[cfg(not(target_os = "solana"))]
85+
#[cfg(not(target_family = "solana"))]
8786
enum Hook {
8887
Default,
8988
Custom(Box<dyn Fn(&PanicInfo<'_>) + 'static + Sync + Send>),
@@ -100,15 +99,15 @@ impl Hook {
10099
}
101100
}
102101

103-
#[cfg(not(target_os = "solana"))]
102+
#[cfg(not(target_family = "solana"))]
104103
impl Default for Hook {
105104
#[inline]
106105
fn default() -> Hook {
107106
Hook::Default
108107
}
109108
}
110109

111-
#[cfg(not(target_os = "solana"))]
110+
#[cfg(not(target_family = "solana"))]
112111
static HOOK: RwLock<Hook> = RwLock::new(Hook::Default);
113112

114113
/// Registers a custom panic hook, replacing the previously registered hook.
@@ -448,7 +447,7 @@ pub mod panic_count {
448447
//
449448
// This also updates thread-local state to keep track of whether a panic
450449
// hook is currently executing.
451-
#[cfg(not(target_os = "solana"))]
450+
#[cfg(not(target_family = "solana"))]
452451
pub fn increase(run_panic_hook: bool) -> Option<MustAbort> {
453452
let global_count = GLOBAL_PANIC_COUNT.fetch_add(1, Ordering::Relaxed);
454453
if global_count & ALWAYS_ABORT_FLAG != 0 {
@@ -516,7 +515,7 @@ pub mod panic_count {
516515

517516
// Slow path is in a separate function to reduce the amount of code
518517
// inlined from `count_is_zero`.
519-
#[cfg(not(target_os = "solana"))]
518+
#[cfg(not(target_family = "solana"))]
520519
#[inline(never)]
521520
#[cold]
522521
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
@@ -2441,10 +2441,15 @@ impl<T: Termination, E: fmt::Debug> Termination for Result<T, E> {
24412441
fn report(self) -> ExitCode {
24422442
match self {
24432443
Ok(val) => val.report(),
2444+
#[cfg(not(target_family = "solana"))]
24442445
Err(err) => {
24452446
io::attempt_print_to_stderr(format_args_nl!("Error: {err:?}"));
24462447
ExitCode::FAILURE
24472448
}
2449+
#[cfg(target_family = "solana")]
2450+
Err(_err) => {
2451+
ExitCode::FAILURE
2452+
}
24482453
}
24492454
}
24502455
}

0 commit comments

Comments
 (0)