Skip to content

Commit 6663b45

Browse files
dmakarovLucasSte
authored andcommitted
[SOL] Adjust SBF customization after upgrading to rust 1.68.0
1 parent 15d5b4d commit 6663b45

File tree

24 files changed

+97
-47
lines changed

24 files changed

+97
-47
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ jobs:
6363
os: ubuntu-20.04-16core-64gb
6464
env: {}
6565
- name: sbf-solana-solana
66+
tidy: false
6667
os: ubuntu-latest
6768
env: {}
6869
- name: x86_64-gnu-tools
@@ -239,6 +240,9 @@ jobs:
239240
- name: install sccache
240241
run: src/ci/scripts/install-sccache.sh
241242
if: success() && !env.SKIP_JOB
243+
- name: select Xcode
244+
run: src/ci/scripts/select-xcode.sh
245+
if: success() && !env.SKIP_JOB
242246
- name: install clang
243247
run: src/ci/scripts/install-clang.sh
244248
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
@@ -1802,19 +1802,19 @@ fn brute_force_rotate_test_1() {
18021802
}
18031803

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

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

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

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

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

1886-
let mut rng = StdRng::seed_from_u64(0);
1886+
let mut rng = crate::test_rng();
18871887

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

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

library/std/Cargo.toml

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

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

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

@@ -458,6 +458,7 @@ impl<E> Report<E>
458458
where
459459
E: Error,
460460
{
461+
#[cfg(not(target_family = "solana"))]
461462
fn backtrace(&self) -> Option<&Backtrace> {
462463
// have to grab the backtrace on the first error directly since that error may not be
463464
// 'static
@@ -508,6 +509,7 @@ where
508509
}
509510
}
510511

512+
#[cfg(not(target_family = "solana"))]
511513
if self.show_backtrace {
512514
let backtrace = self.backtrace();
513515

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 crate::sys_common::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
#[unstable(feature = "internal_output_capture", issue = "none")]
315316
#[doc(no_inline, hidden)]

library/std/src/io/stdio.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ 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;
12-
#[cfg(not(target_os = "solana"))]
13+
#[cfg(not(target_family = "solana"))]
1314
use crate::io::{self, BorrowedCursor, BufReader, IoSlice, IoSliceMut, LineWriter, Lines};
14-
#[cfg(target_os = "solana")]
15+
#[cfg(target_family = "solana")]
1516
use crate::io::{self, BufReader, IoSlice, IoSliceMut};
1617
#[cfg(not(target_family = "solana"))]
1718
use crate::sync::atomic::{AtomicBool, Ordering};
@@ -1240,6 +1241,7 @@ where
12401241
}
12411242
}
12421243

1244+
#[cfg(not(target_family = "solana"))]
12431245
fn print_to_buffer_if_capture_used(args: fmt::Arguments<'_>) -> bool {
12441246
OUTPUT_CAPTURE_USED.load(Ordering::Relaxed)
12451247
&& OUTPUT_CAPTURE.try_with(|s| {
@@ -1256,6 +1258,7 @@ fn print_to_buffer_if_capture_used(args: fmt::Arguments<'_>) -> bool {
12561258
/// Used by impl Termination for Result to print error after `main` or a test
12571259
/// has returned. Should avoid panicking, although we can't help it if one of
12581260
/// the Display impls inside args decides to.
1261+
#[cfg(not(target_family = "solana"))]
12591262
pub(crate) fn attempt_print_to_stderr(args: fmt::Arguments<'_>) {
12601263
if print_to_buffer_if_capture_used(args) {
12611264
return;
@@ -1287,6 +1290,7 @@ pub trait IsTerminal: crate::sealed::Sealed {
12871290
fn is_terminal(&self) -> bool;
12881291
}
12891292

1293+
#[cfg(not(target_family = "solana"))]
12901294
macro_rules! impl_is_terminal {
12911295
($($t:ty),*$(,)?) => {$(
12921296
#[unstable(feature = "sealed", issue = "none")]
@@ -1302,6 +1306,7 @@ macro_rules! impl_is_terminal {
13021306
)*}
13031307
}
13041308

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

13071312
#[unstable(

library/std/src/panicking.rs

Lines changed: 8 additions & 9 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.
@@ -441,7 +440,7 @@ pub mod panic_count {
441440
//
442441
// This also updates thread-local state to keep track of whether a panic
443442
// hook is currently executing.
444-
#[cfg(not(target_os = "solana"))]
443+
#[cfg(not(target_family = "solana"))]
445444
pub fn increase(run_panic_hook: bool) -> Option<MustAbort> {
446445
let global_count = GLOBAL_PANIC_COUNT.fetch_add(1, Ordering::Relaxed);
447446
if global_count & ALWAYS_ABORT_FLAG != 0 {
@@ -508,7 +507,7 @@ pub mod panic_count {
508507

509508
// Slow path is in a separate function to reduce the amount of code
510509
// inlined from `count_is_zero`.
511-
#[cfg(not(target_os = "solana"))]
510+
#[cfg(not(target_family = "solana"))]
512511
#[inline(never)]
513512
#[cold]
514513
fn is_zero_slow_path() -> bool {
@@ -661,7 +660,7 @@ pub fn panicking() -> bool {
661660
}
662661

663662
/// Entry point of panics from the core crate (`panic_impl` lang item).
664-
#[cfg(not(any(test, target_os = "solana")))]
663+
#[cfg(not(any(test, target_family = "solana")))]
665664
#[panic_handler]
666665
pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
667666
struct FormatStringPayload<'a> {

library/std/src/process.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,10 +2361,15 @@ impl<T: Termination, E: fmt::Debug> Termination for Result<T, E> {
23612361
fn report(self) -> ExitCode {
23622362
match self {
23632363
Ok(val) => val.report(),
2364+
#[cfg(not(target_family = "solana"))]
23642365
Err(err) => {
23652366
io::attempt_print_to_stderr(format_args_nl!("Error: {err:?}"));
23662367
ExitCode::FAILURE
23672368
}
2369+
#[cfg(target_family = "solana")]
2370+
Err(_err) => {
2371+
ExitCode::FAILURE
2372+
}
23682373
}
23692374
}
23702375
}

0 commit comments

Comments
 (0)