Skip to content

Commit 7d3f9bd

Browse files
dmakarovLucasSte
authored andcommitted
[SOL] Adjust BPF customization after upgrading to rust 1.59.0
1 parent 8d24a58 commit 7d3f9bd

File tree

11 files changed

+54
-40
lines changed

11 files changed

+54
-40
lines changed

compiler/rustc_codegen_gcc/src/type_.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
2626
}
2727
}
2828

29-
pub fn type_void(&self) -> Type<'gcc> {
30-
self.context.new_type::<()>()
31-
}
32-
3329
pub fn type_size_t(&self) -> Type<'gcc> {
3430
self.context.new_type::<usize>()
3531
}
@@ -136,6 +132,10 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
136132
unimplemented!("f16_f128")
137133
}
138134

135+
fn type_void(&self) -> Type<'gcc> {
136+
self.context.new_type::<()>()
137+
}
138+
139139
fn type_func(&self, params: &[Type<'gcc>], return_type: Type<'gcc>) -> Type<'gcc> {
140140
self.context.new_function_pointer_type(None, return_type, params, false)
141141
}

library/core/tests/array.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ fn array_rsplit_array_mut_out_of_bounds() {
511511
}
512512

513513
#[test]
514+
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
514515
fn array_intoiter_advance_by() {
515516
use std::cell::Cell;
516517
struct DropCounter<'a>(usize, &'a Cell<usize>);
@@ -564,6 +565,7 @@ fn array_intoiter_advance_by() {
564565
}
565566

566567
#[test]
568+
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
567569
fn array_intoiter_advance_back_by() {
568570
use std::cell::Cell;
569571
struct DropCounter<'a>(usize, &'a Cell<usize>);

library/std/src/io/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ mod util;
344344

345345
const DEFAULT_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE;
346346

347+
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
347348
pub(crate) use stdio::cleanup;
348349

349350
struct Guard<'a> {

library/std/src/io/stdio.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,10 +632,6 @@ impl Read for Stdin {
632632
fn is_read_vectored(&self) -> bool {
633633
false
634634
}
635-
#[inline]
636-
unsafe fn initializer(&self) -> Initializer {
637-
Initializer::nop()
638-
}
639635
fn read_to_end(&mut self, _buf: &mut Vec<u8>) -> io::Result<usize> {
640636
Ok(0)
641637
}

library/std/src/panicking.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -944,23 +944,6 @@ pub fn rust_begin_panic(info: &PanicInfo<'_>) -> ! {
944944
crate::sys::panic(info);
945945
}
946946

947-
/// The entry point for panicking with a formatted message SBF version.
948-
#[cfg(any(target_arch = "bpf", target_arch = "sbf"))]
949-
#[unstable(feature = "libstd_sys_internals", reason = "used by the panic! macro", issue = "none")]
950-
#[cold]
951-
// If panic_immediate_abort, inline the abort call,
952-
// otherwise avoid inlining because of it is cold path.
953-
#[cfg_attr(not(feature = "panic_immediate_abort"), track_caller)]
954-
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
955-
#[cfg_attr(feature = "panic_immediate_abort", inline)]
956-
pub fn begin_panic_fmt(msg: &fmt::Arguments<'_>) -> ! {
957-
let info = PanicInfo::internal_constructor(
958-
Some(msg),
959-
Location::caller(),
960-
);
961-
crate::sys::panic(&info);
962-
}
963-
964947
/// Entry point of panicking for panic!() and assert!() SBF version.
965948
#[cfg(any(target_arch = "bpf", target_arch = "sbf"))]
966949
#[unstable(feature = "libstd_sys_internals", reason = "used by the panic! macro", issue = "none")]
@@ -978,3 +961,20 @@ pub fn begin_panic<M: Any + Send>(_msg: M) -> ! {
978961
);
979962
crate::sys::panic(&info);
980963
}
964+
965+
/// The entry point for panicking with a formatted message SBF version.
966+
#[cfg(any(target_arch = "bpf", target_arch = "sbf"))]
967+
#[unstable(feature = "libstd_sys_internals", reason = "used by the panic! macro", issue = "none")]
968+
#[cold]
969+
// If panic_immediate_abort, inline the abort call,
970+
// otherwise avoid inlining because of it is cold path.
971+
#[cfg_attr(not(feature = "panic_immediate_abort"), track_caller)]
972+
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
973+
#[cfg_attr(feature = "panic_immediate_abort", inline)]
974+
pub fn begin_panic_fmt(msg: &fmt::Arguments<'_>) -> ! {
975+
let info = PanicInfo::internal_constructor(
976+
Some(msg),
977+
Location::caller(),
978+
);
979+
crate::sys::panic(&info);
980+
}

library/std/src/rt.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
pub use crate::panicking::{begin_panic, panic_count};
2121
pub use core::panicking::{panic_display, panic_fmt};
2222

23+
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
2324
use crate::sync::Once;
25+
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
2426
use crate::sys;
27+
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
2528
use crate::thread::{self, Thread};
2629

2730
// Prints to the "panic output", depending on the platform this may be:
@@ -89,6 +92,7 @@ macro_rules! rtunwrap {
8992
// Even though it is an `u8`, it only ever has 4 values. These are documented in
9093
// `compiler/rustc_session/src/config/sigpipe.rs`.
9194
#[cfg_attr(test, allow(dead_code))]
95+
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
9296
unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
9397
unsafe {
9498
sys::init(argc, argv, sigpipe);
@@ -102,6 +106,7 @@ unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
102106
// One-time runtime cleanup.
103107
// Runs after `main` or at program exit.
104108
// NOTE: this is not guaranteed to run, for example when the program aborts.
109+
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
105110
pub(crate) fn cleanup() {
106111
static CLEANUP: Once = Once::new();
107112
CLEANUP.call_once(|| unsafe {

library/std/src/sys/sbf/fs.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::ffi::OsString;
22
use crate::fmt;
33
use crate::hash::{Hash, Hasher};
4-
use crate::io::{self, SeekFrom, IoSlice, IoSliceMut};
4+
use crate::io::{self, SeekFrom, IoSlice, IoSliceMut, ReadBuf};
55
use crate::path::{Path, PathBuf};
66
use crate::sys::time::SystemTime;
77
use crate::sys::{unsupported, Void};
@@ -209,6 +209,10 @@ impl File {
209209
false
210210
}
211211

212+
pub fn read_buf(&self, _buf: &mut ReadBuf<'_>) -> io::Result<()> {
213+
match self.0 {}
214+
}
215+
212216
pub fn write(&self, _buf: &[u8]) -> io::Result<usize> {
213217
match self.0 {}
214218
}

library/std/src/sys/sbf/thread.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ impl Thread {
3131
}
3232
}
3333

34-
pub fn available_concurrency() -> io::Result<NonZeroUsize> {
34+
pub fn available_parallelism() -> io::Result<NonZeroUsize> {
3535
unsupported()
3636
}
37-
38-
pub mod guard {
39-
pub type Guard = !;
40-
pub unsafe fn current() -> Option<Guard> {
41-
None
42-
}
43-
}

library/std/src/thread/mod.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ use crate::str;
175175
use crate::sync::atomic::{AtomicUsize, Ordering};
176176
use crate::sync::Arc;
177177
use crate::sys::thread as imp;
178+
use crate::sys_common::thread;
178179
use crate::sys_common::thread_parking::Parker;
179180
use crate::sys_common::{AsInner, IntoInner};
180181
use crate::time::{Duration, Instant};
@@ -595,17 +596,15 @@ impl Builder {
595596
{
596597
let Builder { name, stack_size } = self;
597598
let stack_size = stack_size.unwrap_or_else(thread::min_stack);
598-
let my_thread = Thread::new(name);
599+
let my_thread = Thread::new(name.map(|name| {
600+
CString::new(name).expect("thread name may not contain interior null bytes")
601+
}));
599602
let their_thread = my_thread.clone();
600603
let my_packet: Arc<UnsafeCell<Option<Result<T>>>> = Arc::new(UnsafeCell::new(None));
601604
let main = move || {
602605
if let Some(name) = their_thread.cname() {
603606
imp::Thread::set_name(name);
604607
}
605-
// SAFETY: the stack guard passed is the one for the current thread.
606-
// This means the current thread's stack and the new thread's stack
607-
// are properly set and protected from each other.
608-
thread_info::set(unsafe { imp::guard::current() }, their_thread);
609608
};
610609

611610
Ok(JoinHandle(JoinInner {
@@ -789,13 +788,23 @@ pub(crate) fn try_current() -> Option<Thread> {
789788
/// ```
790789
#[must_use]
791790
#[stable(feature = "rust1", since = "1.0.0")]
791+
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
792792
pub fn current() -> Thread {
793793
try_current().expect(
794794
"use of std::thread::current() is not possible \
795795
after the thread's local data has been destroyed",
796796
)
797797
}
798798

799+
/// SBF dummy version
800+
///
801+
#[must_use]
802+
#[stable(feature = "rust1", since = "1.0.0")]
803+
#[cfg(any(target_arch = "bpf", target_arch = "sbf"))]
804+
pub fn current() -> Thread {
805+
Thread::new(None)
806+
}
807+
799808
/// Cooperatively gives up a timeslice to the OS scheduler.
800809
///
801810
/// This calls the underlying OS scheduler's yield primitive, signaling

library/test/src/cli.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ macro_rules! unstable_optflag {
239239
}
240240

241241
// Gets the option value and checks if unstable features are enabled.
242+
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
242243
macro_rules! unstable_optopt {
243244
($matches:ident, $allow_unstable:ident, $option_name:literal) => {{
244245
let opt = $matches.opt_str($option_name);
@@ -325,6 +326,8 @@ fn parse_opts_impl(_matches: getopts::Matches) -> OptRes {
325326
nocapture: true,
326327
color: ColorConfig::NeverColor,
327328
format: OutputFormat::Pretty,
329+
shuffle: false,
330+
shuffle_seed: None,
328331
test_threads: Some(1),
329332
skip: Vec::new(),
330333
time_options: None,
@@ -366,6 +369,7 @@ fn get_time_options(
366369
Ok(options)
367370
}
368371

372+
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
369373
fn get_shuffle(matches: &getopts::Matches, allow_unstable: bool) -> OptPartRes<bool> {
370374
let mut shuffle = unstable_optflag!(matches, allow_unstable, "shuffle");
371375
if !shuffle && allow_unstable {
@@ -378,6 +382,7 @@ fn get_shuffle(matches: &getopts::Matches, allow_unstable: bool) -> OptPartRes<b
378382
Ok(shuffle)
379383
}
380384

385+
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
381386
fn get_shuffle_seed(matches: &getopts::Matches, allow_unstable: bool) -> OptPartRes<Option<u64>> {
382387
let mut shuffle_seed = match unstable_optopt!(matches, allow_unstable, "shuffle-seed") {
383388
Some(n_str) => match n_str.parse::<u64>() {

0 commit comments

Comments
 (0)