Skip to content

Commit b163725

Browse files
dmakarovLucasSte
authored andcommitted
[SOL] Adjust SBF customization after upgrading to rust 1.65.0
1 parent 2c6f8c3 commit b163725

File tree

36 files changed

+262
-195
lines changed

36 files changed

+262
-195
lines changed

compiler/rustc_codegen_ssa/src/back/metadata.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
249249
"loongarch64" => (Architecture::LoongArch64, None),
250250
"csky" => (Architecture::Csky, None),
251251
"arm64ec" => (Architecture::Aarch64, Some(SubArchitecture::Arm64EC)),
252+
"bpf" => (Architecture::Bpf, None),
253+
"sbf" => (Architecture::Bpf, None),
252254
// Unsupported architecture.
253255
_ => return None,
254256
};

compiler/rustc_target/src/callconv/sbf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
2626
classify_ret(&mut fn_abi.ret);
2727
}
2828

29-
for arg in &mut fn_abi.args {
29+
for arg in fn_abi.args.iter_mut() {
3030
if arg.is_ignore() {
3131
continue;
3232
}

compiler/rustc_target/src/spec/sbf_base.rs

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

44
pub fn opts() -> TargetOptions {
55
let linker_script = r"
@@ -33,6 +33,7 @@ SECTIONS
3333
lld_args.push("-z".into());
3434
lld_args.push("notext".into());
3535
let mut pre_link_args = LinkArgs::new();
36+
pre_link_args.insert(LinkerFlavor::Ld, lld_args.clone());
3637
pre_link_args.insert(LinkerFlavor::Lld(LldFlavor::Ld), lld_args);
3738

3839
TargetOptions {
@@ -46,6 +47,7 @@ SECTIONS
4647
env: "".into(),
4748
executables: true,
4849
features: "+solana".into(),
50+
families: cvs!["solana"],
4951
link_script: Some(linker_script.into()),
5052
linker: Some("rust-lld".into()),
5153
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),

compiler/rustc_target/src/spec/tests/tests_impl.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ impl Target {
2828
matches!(self.linker_flavor, LinkerFlavor::WasmLld(..))
2929
);
3030
assert_eq!(self.os == "emscripten", matches!(self.linker_flavor, LinkerFlavor::EmCc));
31-
assert_eq!(self.arch == "bpf", matches!(self.linker_flavor, LinkerFlavor::Bpf));
31+
assert_eq!(self.arch == "bpf" && self.features != "+solana",
32+
matches!(self.linker_flavor, LinkerFlavor::Bpf));
3233
assert_eq!(self.arch == "nvptx64", matches!(self.linker_flavor, LinkerFlavor::Ptx));
3334

3435
for args in [

library/core/benches/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// wasm32 does not support benches (no time).
22
// Disabling in Miri as these would take too long.
33
#![cfg(not(miri))]
4-
#![cfg(not(any(target_arch = "wasm32", target_arch = "bpf", target_arch = "sbf")))]
4+
#![cfg(not(any(target_arch = "wasm32", target_family = "solana")))]
55
#![feature(flt2dec)]
66
#![feature(test)]
77
#![feature(trusted_random_access)]

library/core/benches/num/int_log/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
1+
#![cfg(not(target_family = "solana"))]
22
use rand::Rng;
33
use test::{Bencher, black_box};
44

library/core/src/fmt/num.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ mod imp {
542542
);
543543
}
544544

545-
#[cfg(not(any(target_pointer_width = "64", target_arch = "wasm32", target_arch = "bpf", target_arch = "sbf")))]
545+
#[cfg(not(any(target_pointer_width = "64", target_arch = "wasm32", target_family = "solana")))]
546546
mod imp {
547547
use super::*;
548548
impl_Display!(

library/core/tests/array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ fn array_rsplit_array_mut_out_of_bounds() {
514514
}
515515

516516
#[test]
517-
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
517+
#[cfg(not(target_family = "solana"))]
518518
fn array_intoiter_advance_by() {
519519
use std::cell::Cell;
520520
struct DropCounter<'a>(usize, &'a Cell<usize>);
@@ -568,7 +568,7 @@ fn array_intoiter_advance_by() {
568568
}
569569

570570
#[test]
571-
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
571+
#[cfg(not(target_family = "solana"))]
572572
fn array_intoiter_advance_back_by() {
573573
use std::cell::Cell;
574574
struct DropCounter<'a>(usize, &'a Cell<usize>);

library/core/tests/atomic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ fn ptr_bitops_tagging() {
213213
}
214214

215215
// SBF does not support mustable static data
216-
#[cfg(not(any(target_arch = "bpf", target_arch = "sbf")))]
216+
#[cfg(not(target_family = "solana"))]
217217
mod statik {
218218
use super::*;
219219

library/core/tests/lazy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn once_cell_get_mut() {
2424
}
2525

2626
// sbf doesn't have mutable static data
27-
#[cfg(not(any(target_arch = "bpf", target_arch = "sbf")))]
27+
#[cfg(not(target_family = "solana"))]
2828
#[test]
2929
fn once_cell_drop() {
3030
static DROP_CNT: AtomicUsize = AtomicUsize::new(0);

0 commit comments

Comments
 (0)