Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Nixpkgs and Rust #192

Merged
merged 9 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Files:
hacking/nix/scope/capdl-tool/capDL-tool.nix
hacking/nix/scope/capdl-tool/base-compat-0-12-2.nix
hacking/nix/scope/capdl-tool/base-compat-batteries-0-12-2.nix
hacking/nix/scope/capdl-tool/MissingH-1.5.0.1.nix
Copyright: 2023, Colias Group, LLC
License: BSD-2-Clause

Expand Down
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ ifneq ($(J),)
jobs_args := -j$(J)
endif

ifneq ($(CORES),)
cores_args := --cores $(CORES)
ifneq ($(C),)
cores_args := --cores $(C)
endif

nix_args := $(keep_going_args) $(jobs_args) $(cores_args)
Expand Down Expand Up @@ -124,7 +124,13 @@ witness-fast-tests:

.PHONY: check-kani-proofs
check-kani-proofs:
$(run_in_nix_shell) "cargo kani -p sel4-bitfield-ops"
$(run_in_nix_shell) "\
cargo kani \
--enable-unstable \
--output-format=terse \
$(jobs_args) \
-p sel4-bitfield-ops \
"

.PHONY: everything-except-non-incremental
everything-except-non-incremental:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ cfg_if::cfg_if! {
unsafe extern "C" fn __rust_entry(bootinfo: *const sel4::BootInfo) -> ! {
let bootinfo = sel4::BootInfoPtr::new(bootinfo);
match main(&bootinfo) {
#[allow(unreachable_patterns)]
Ok(absurdity) => match absurdity {},
Err(err) => panic!("Error: {}", err),
}
Expand Down
4 changes: 2 additions & 2 deletions crates/examples/root-task/serial-device/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ struct FreePagePlaceHolder(#[allow(dead_code)] [u8; GRANULE_SIZE]);
static mut FREE_PAGE_PLACEHOLDER: FreePagePlaceHolder = FreePagePlaceHolder([0; GRANULE_SIZE]);

fn init_free_page_addr(bootinfo: &sel4::BootInfo) -> usize {
let addr = unsafe { ptr::addr_of!(FREE_PAGE_PLACEHOLDER) as usize };
let addr = ptr::addr_of!(FREE_PAGE_PLACEHOLDER) as usize;
get_user_image_frame_slot(bootinfo, addr)
.cap()
.frame_unmap()
Expand All @@ -204,7 +204,7 @@ fn get_user_image_frame_slot(
extern "C" {
static __executable_start: usize;
}
let user_image_addr = unsafe { ptr::addr_of!(__executable_start) as usize };
let user_image_addr = ptr::addr_of!(__executable_start) as usize;
bootinfo
.user_image_frames()
.index(addr / GRANULE_SIZE - user_image_addr / GRANULE_SIZE)
Expand Down
9 changes: 4 additions & 5 deletions crates/examples/root-task/spawn-task/child/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ fn inner_entry() -> ! {
}

match catch_unwind(main) {
#[allow(unreachable_patterns)]
Ok(never) => never,
Err(_) => abort!("main() panicked"),
}
Expand All @@ -60,9 +61,7 @@ fn get_ipc_buffer() -> *mut sel4::IpcBuffer {
extern "C" {
static _end: usize;
}
unsafe {
(ptr::addr_of!(_end) as usize)
.next_multiple_of(sel4::cap_type::Granule::FRAME_OBJECT_TYPE.bytes())
as *mut sel4::IpcBuffer
}
(ptr::addr_of!(_end) as usize)
.next_multiple_of(sel4::cap_type::Granule::FRAME_OBJECT_TYPE.bytes())
as *mut sel4::IpcBuffer
}
4 changes: 2 additions & 2 deletions crates/examples/root-task/spawn-task/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ struct FreePagePlaceHolder(#[allow(dead_code)] [u8; GRANULE_SIZE]);
static mut FREE_PAGE_PLACEHOLDER: FreePagePlaceHolder = FreePagePlaceHolder([0; GRANULE_SIZE]);

fn init_free_page_addr(bootinfo: &sel4::BootInfo) -> usize {
let addr = unsafe { ptr::addr_of!(FREE_PAGE_PLACEHOLDER) as usize };
let addr = ptr::addr_of!(FREE_PAGE_PLACEHOLDER) as usize;
get_user_image_frame_slot(bootinfo, addr)
.cap()
.frame_unmap()
Expand All @@ -115,7 +115,7 @@ fn get_user_image_frame_slot(
extern "C" {
static __executable_start: usize;
}
let user_image_addr = unsafe { ptr::addr_of!(__executable_start) as usize };
let user_image_addr = ptr::addr_of!(__executable_start) as usize;
bootinfo
.user_image_frames()
.index(addr / GRANULE_SIZE - user_image_addr / GRANULE_SIZE)
Expand Down
2 changes: 1 addition & 1 deletion crates/examples/root-task/spawn-thread/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ fn get_user_image_frame_slot(
extern "C" {
static __executable_start: usize;
}
let user_image_addr = unsafe { ptr::addr_of!(__executable_start) as usize };
let user_image_addr = ptr::addr_of!(__executable_start) as usize;
bootinfo
.user_image_frames()
.index(addr / GRANULE_SIZE - user_image_addr / GRANULE_SIZE)
Expand Down
2 changes: 1 addition & 1 deletion crates/private/tests/root-task/dafny/core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() {
let translated_src = env::var(TRANSLATED_ENV).unwrap();
let out_dir = env::var("OUT_DIR").unwrap();
let translated_dst = PathBuf::from(&out_dir).join("translated.rs");
fs::copy(&translated_src, &translated_dst).unwrap();
fs::copy(&translated_src, translated_dst).unwrap();

println!("cargo:rerun-if-env-changed={TRANSLATED_ENV}");
println!("cargo:rerun-if-changed={}", translated_src);
Expand Down
1 change: 1 addition & 0 deletions crates/sel4-async/block-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ impl<T: AsRef<[u8]>> ByteIO<ReadOnly> for SliceByteIO<T> {
Operation::Read { buf, .. } => {
buf.copy_from_slice(&self.inner().as_ref()[offset..][..buf.len()]);
}
#[allow(unreachable_patterns)]
Operation::Write { witness, .. } => witness.absurd(),
}
Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn with_bit_width<T: object::read::elf::FileHeader<Word: NumCast + PatchValue>>(
image_elf: &object::read::elf::ElfFile<T>,
content: &[u8],
) -> Vec<u8> {
let mut builder = Builder::new(&image_elf).unwrap();
let mut builder = Builder::new(image_elf).unwrap();

builder.discard_p_align(true);

Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-capdl-initializer/add-spec/src/render_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl<'a> RenderElfArgs<'a> {
&self,
orig_elf: &object::read::elf::ElfFile<T>,
) -> Vec<u8> {
let mut builder = Builder::new(&orig_elf).unwrap();
let mut builder = Builder::new(orig_elf).unwrap();

builder.discard_p_align(true);

Expand Down
19 changes: 10 additions & 9 deletions crates/sel4-generate-target-specs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ enum Arch {
}

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[allow(clippy::upper_case_acronyms)]
enum RiscVArch {
IMAC,
IMAFC,
Expand Down Expand Up @@ -194,15 +195,15 @@ impl Arch {
}

fn all() -> Vec<Self> {
let mut v = vec![];
v.push(Self::AArch64);
v.push(Self::Armv7a);
v.push(Self::RiscV64(RiscVArch::IMAC));
v.push(Self::RiscV64(RiscVArch::GC));
v.push(Self::RiscV32(RiscVArch::IMAC));
v.push(Self::RiscV32(RiscVArch::IMAFC));
v.push(Self::X86_64);
v
vec![
Self::AArch64,
Self::Armv7a,
Self::RiscV64(RiscVArch::IMAC),
Self::RiscV64(RiscVArch::GC),
Self::RiscV32(RiscVArch::IMAC),
Self::RiscV32(RiscVArch::IMAFC),
Self::X86_64,
]
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-kernel-loader/add-payload/src/render_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ where
{
let orig_elf_file = &object::read::elf::ElfFile::<T>::parse(orig_elf_buffer).unwrap();

let mut builder = Builder::new(&orig_elf_file).unwrap();
let mut builder = Builder::new(orig_elf_file).unwrap();

builder.discard_p_align(true);

Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-microkit/base/src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,5 @@ pub fn ipc_buffer_ptr() -> *mut sel4::IpcBuffer {
static mut __sel4_ipc_buffer_obj: sel4::IpcBuffer;
}

unsafe { ptr::addr_of_mut!(__sel4_ipc_buffer_obj) }
ptr::addr_of_mut!(__sel4_ipc_buffer_obj)
}
2 changes: 1 addition & 1 deletion crates/sel4-microkit/driver-adapters/src/net/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<Device: phy::Device + HandleInterrupt + GetNetDeviceMeta> Handler for Handl
self.client_region
.as_mut_ptr()
.index(buf_range)
.copy_from_slice(&rx_buf);
.copy_from_slice(rx_buf);
});

self.rx_ring_buffers
Expand Down
1 change: 1 addition & 0 deletions crates/sel4-microkit/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ macro_rules! declare_init {
#[allow(clippy::missing_safety_doc)]
pub fn run_main<T: Handler>(init: impl FnOnce() -> T + UnwindSafe) -> ! {
let result = catch_unwind(|| match init().run() {
#[allow(unreachable_patterns)]
Ok(absurdity) => match absurdity {},
Err(err) => err,
});
Expand Down
30 changes: 22 additions & 8 deletions crates/sel4-panicking/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,34 @@

use core::cmp::Reverse;

// Determine whether rustc includes https://github.com/rust-lang/rust/pull/121598
// Determine whether rustc includes the following changes:
// - https://blog.rust-lang.org/2024/05/06/check-cfg.html
// - https://github.com/rust-lang/rust/pull/121598
// - https://github.com/rust-lang/rust/pull/126732

fn main() {
let version_meta = rustc_version::version_meta().unwrap();
let semver = version_meta.semver;
let commit_date = order_date(version_meta.commit_date);
let key = (semver.major, semver.minor, semver.patch, commit_date);
let first_with_change = (1, 78, 0, order_date(Some("2024-02-28".to_owned())));
if key < first_with_change {
let key = {
let version_meta = rustc_version::version_meta().unwrap();
let semver = version_meta.semver;
let commit_date = order_date(version_meta.commit_date);
(semver.major, semver.minor, semver.patch, commit_date)
};
let check_cfg_required = (1, 80, 0, order_date(Some("2024-05-05".to_owned())));
let unwind_intrinsic_renamed = (1, 78, 0, order_date(Some("2024-02-28".to_owned())));
let panic_info_message_stabilized = (1, 81, 0, order_date(Some("2024-07-01".to_owned())));
if key >= check_cfg_required {
println!("cargo:rustc-check-cfg=cfg(catch_unwind_intrinsic_still_named_try)");
println!("cargo:rustc-check-cfg=cfg(panic_info_message_stable)");
}
if key < unwind_intrinsic_renamed {
println!("cargo:rustc-cfg=catch_unwind_intrinsic_still_named_try");
}
if key >= panic_info_message_stabilized {
println!("cargo:rustc-cfg=panic_info_message_stable");
}
}

// assume no build date means more recent
// no build date means more recent
fn order_date(date: Option<String>) -> Reverse<Option<Reverse<String>>> {
Reverse(date.map(Reverse))
}
23 changes: 16 additions & 7 deletions crates/sel4-panicking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#![feature(core_intrinsics)]
#![feature(lang_items)]
#![feature(panic_can_unwind)]
#![feature(panic_info_message)]
#![feature(thread_local)]
#![cfg_attr(not(panic_info_message_stable), feature(panic_info_message))]
#![allow(internal_features)]

#[cfg(feature = "alloc")]
Expand All @@ -21,6 +21,9 @@ use core::mem::ManuallyDrop;
use core::panic::Location;
use core::panic::{PanicInfo, UnwindSafe};

#[cfg(panic_info_message_stable)]
use core::panic::PanicMessage;

use cfg_if::cfg_if;

use sel4_panicking_env::abort;
Expand All @@ -38,9 +41,12 @@ use strategy::{panic_cleanup, start_panic};
pub use hook::{set_hook, PanicHook};
pub use payload::{Payload, SmallPayload, UpcastIntoPayload, SMALL_PAYLOAD_MAX_SIZE};

#[cfg(not(panic_info_message_stable))]
type PanicMessage<'a> = &'a fmt::Arguments<'a>;

pub struct ExternalPanicInfo<'a> {
payload: Payload,
message: Option<&'a fmt::Arguments<'a>>,
message: Option<PanicMessage<'a>>,
location: Option<&'a Location<'a>>,
can_unwind: bool,
}
Expand All @@ -50,8 +56,8 @@ impl<'a> ExternalPanicInfo<'a> {
&self.payload
}

pub fn message(&self) -> Option<&fmt::Arguments> {
self.message
pub fn message(&self) -> Option<&PanicMessage> {
self.message.as_ref()
}

pub fn location(&self) -> Option<&Location> {
Expand All @@ -66,14 +72,14 @@ impl<'a> ExternalPanicInfo<'a> {
impl fmt::Display for ExternalPanicInfo<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("panicked at ")?;
if let Some(location) = self.location {
if let Some(location) = self.location() {
location.fmt(f)?;
} else {
f.write_str("unknown location")?;
}
if let Some(message) = self.message {
if let Some(message) = self.message() {
f.write_str(":\n")?;
f.write_fmt(*message)?;
message.fmt(f)?;
}
Ok(())
}
Expand All @@ -83,6 +89,9 @@ impl fmt::Display for ExternalPanicInfo<'_> {
fn panic(info: &PanicInfo) -> ! {
do_panic(ExternalPanicInfo {
payload: NoPayload.upcast_into_payload(),
#[cfg(panic_info_message_stable)]
message: Some(info.message()),
#[cfg(not(panic_info_message_stable))]
message: info.message(),
location: info.location(),
can_unwind: info.can_unwind(),
Expand Down
4 changes: 2 additions & 2 deletions crates/sel4-reset/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ where

let persistent_section = elf.section_by_name(".persistent");

let mut builder = Builder::empty(&elf);
let mut builder = Builder::empty(elf);

let mut regions_builder = RegionsBuilder::<T>::new();

Expand Down Expand Up @@ -82,7 +82,7 @@ where
}
}

assert!(!(persistent_section.is_some() && !persistent_section_placed));
assert!(persistent_section.is_none() || persistent_section_placed);

let regions = regions_builder.build(endian);

Expand Down
2 changes: 2 additions & 0 deletions crates/sel4-root-task/src/termination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ impl<E> Termination for Result<!, E> {

fn report(self) -> Self::Error {
match self {
#[allow(unreachable_patterns)]
Ok(absurdity) => match absurdity {},
Err(err) => err,
}
Expand All @@ -44,6 +45,7 @@ impl<E> Termination for Result<Never, E> {

fn report(self) -> Self::Error {
match self {
#[allow(unreachable_patterns)]
Ok(absurdity) => match absurdity {},
Err(err) => err,
}
Expand Down
1 change: 1 addition & 0 deletions crates/sel4-shared-ring-buffer/smoltcp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impl<A, R: RawMutex, P: AbstractRcT> Clone for DeviceImpl<A, R, P> {
}

impl<A: AbstractBounceBufferAllocator, R: RawMutex, P: AbstractRcT> DeviceImpl<A, R, P> {
#[allow(clippy::too_many_arguments)]
pub fn new(
raw_mutex: R,
dma_region: ExternallySharedRef<'static, [u8]>,
Expand Down
1 change: 1 addition & 0 deletions crates/sel4-sync/src/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub trait MutexSyncOps {
unsafe impl<O: MutexSyncOps> lock_api::RawMutex for GenericRawMutex<O> {
type GuardMarker = lock_api::GuardNoSend; // TODO

#[allow(clippy::declare_interior_mutable_const)]
const INIT: Self = unimplemented!();

fn lock(&self) {
Expand Down
Loading
Loading