From a8a788d6b79c7231dc20e869684491dca0333e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 1 Dec 2021 22:42:53 +0100 Subject: [PATCH 1/4] Upgrade toolchain channel to nightly-2021-10-20 CI: Explicitly set build-std without std Else, cargo unifies with rusty-hermit's outer .cargo/config.toml and tries to build std for the kernel, which fails with: error[E0432]: unresolved import `crate::sys::hermit::thread_local_dtor` --> /home/mkroening/.rustup/toolchains/nightly-2021-10-20-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/hermit/thread.rs:9:25 | 9 | use crate::sys::hermit::thread_local_dtor::run_dtors; | ^^^^^^^^^^^^^^^^^ could not find `thread_local_dtor` in `hermit` error[E0432]: unresolved import `crate::sys::hermit::thread_local_dtor` --> /home/mkroening/.rustup/toolchains/nightly-2021-10-20-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/hermit/mod.rs:122:29 | 122 | use crate::sys::hermit::thread_local_dtor::run_dtors; | ^^^^^^^^^^^^^^^^^ could not find `thread_local_dtor` in `hermit` --- .cargo/config.toml | 1 + .github/workflows/x86.yml | 2 +- rust-toolchain.toml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 334b3e8f5b..4b1b35d413 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,4 +1,5 @@ [unstable] +# Keep in sync with CI! build-std = ["core", "alloc"] build-std-features = ["compiler-builtins-mem"] diff --git a/.github/workflows/x86.yml b/.github/workflows/x86.yml index 554fd66f67..04b3a29cca 100644 --- a/.github/workflows/x86.yml +++ b/.github/workflows/x86.yml @@ -39,7 +39,7 @@ jobs: run: rustup show - name: Build minimal kernel working-directory: libhermit-rs - run: cargo build --no-default-features + run: cargo build --no-default-features -Z build-std=core,alloc - name: Build dev profile run: cargo build - name: Unittests on host (ubuntu) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index fe707619c2..37093c294d 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2021-09-29" +channel = "nightly-2021-10-20" components = [ "rust-src", "llvm-tools-preview", From c8eb43a48ebbf42a3e7fa4762532b0b4a8d231fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 1 Dec 2021 23:09:43 +0100 Subject: [PATCH 2/4] Upgrade toolchain channel to nightly-2021-11-01 The kernel's target os was removed in https://github.com/rust-lang/rust/pull/90404. It is only used for x86_64 and not for aarch64. Adjust filter on __rg_oom since the filter for `target_os = "hermit"` does not work anymore for the kernel target: https://github.com/rust-lang/rust/commit/bc6b2ac449a0f6d9a8bd87788a0eae9516cb58ce --- rust-toolchain.toml | 2 +- src/arch/mod.rs | 8 ++++-- src/arch/x86_64/kernel/apic.rs | 4 +-- src/arch/x86_64/kernel/irq.rs | 2 +- src/arch/x86_64/kernel/mod.rs | 25 ++++++++++--------- src/arch/x86_64/kernel/percore.rs | 4 +-- src/arch/x86_64/kernel/processor.rs | 6 ++--- src/arch/x86_64/kernel/scheduler.rs | 4 +-- src/console.rs | 2 +- src/lib.rs | 38 +++++++++++++++++------------ src/mm/allocator.rs | 4 +-- src/mm/freelist.rs | 6 ++--- src/mm/hole.rs | 6 ++--- src/mm/mod.rs | 2 +- src/mm/test.rs | 30 +++++++++++------------ src/runtime_glue.rs | 3 ++- src/syscalls/interfaces/uhyve.rs | 2 +- src/syscalls/mod.rs | 8 +++--- 18 files changed, 85 insertions(+), 71 deletions(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 37093c294d..bb73df0cf8 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2021-10-20" +channel = "nightly-2021-11-01" components = [ "rust-src", "llvm-tools-preview", diff --git a/src/arch/mod.rs b/src/arch/mod.rs index d9c5496b98..8d6d741739 100644 --- a/src/arch/mod.rs +++ b/src/arch/mod.rs @@ -44,7 +44,11 @@ pub use crate::arch::x86_64::*; #[cfg(target_arch = "x86_64")] pub use crate::arch::x86_64::kernel::apic::{set_oneshot_timer, wakeup_core}; -#[cfg(all(target_arch = "x86_64", target_os = "hermit", feature = "smp"))] +#[cfg(all( + target_arch = "x86_64", + any(target_os = "none", target_os = "hermit"), + feature = "smp" +))] pub use crate::arch::x86_64::kernel::application_processor_init; #[cfg(target_arch = "x86_64")] pub use crate::arch::x86_64::kernel::gdt::set_current_kernel_stack; @@ -60,7 +64,7 @@ pub use crate::arch::x86_64::kernel::scheduler; pub use crate::arch::x86_64::kernel::switch; #[cfg(target_arch = "x86_64")] pub use crate::arch::x86_64::kernel::systemtime::get_boot_time; -#[cfg(all(target_arch = "x86_64", target_os = "hermit"))] +#[cfg(all(target_arch = "x86_64", any(target_os = "none", target_os = "hermit")))] pub use crate::arch::x86_64::kernel::{boot_application_processors, boot_processor_init}; #[cfg(target_arch = "x86_64")] pub use crate::arch::x86_64::kernel::{ diff --git a/src/arch/x86_64/kernel/apic.rs b/src/arch/x86_64/kernel/apic.rs index 688e87ad50..8b222ecec6 100644 --- a/src/arch/x86_64/kernel/apic.rs +++ b/src/arch/x86_64/kernel/apic.rs @@ -2,7 +2,7 @@ use crate::arch; #[cfg(feature = "acpi")] use crate::arch::x86_64::kernel::acpi; use crate::arch::x86_64::kernel::irq::IrqStatistics; -#[cfg(all(target_os = "hermit", feature = "smp"))] +#[cfg(all(any(target_os = "none", target_os = "hermit"), feature = "smp"))] use crate::arch::x86_64::kernel::smp_boot_code::SMP_BOOT_CODE; use crate::arch::x86_64::kernel::IRQ_COUNTERS; use crate::arch::x86_64::mm::paging::{BasePageSize, PageSize, PageTableEntryFlags}; @@ -568,7 +568,7 @@ extern "C" { /// This algorithm is derived from Intel MultiProcessor Specification 1.4, B.4, but testing has shown /// that a second STARTUP IPI and setting the BIOS Reset Vector are no longer necessary. /// This is partly confirmed by https://wiki.osdev.org/Symmetric_Multiprocessing -#[cfg(all(target_os = "hermit", feature = "smp"))] +#[cfg(all(any(target_os = "none", target_os = "hermit"), feature = "smp"))] pub fn boot_application_processors() { // We shouldn't have any problems fitting the boot code into a single page, but let's better be sure. assert!( diff --git a/src/arch/x86_64/kernel/irq.rs b/src/arch/x86_64/kernel/irq.rs index 6d9e0ec3ac..b8e96d03bc 100644 --- a/src/arch/x86_64/kernel/irq.rs +++ b/src/arch/x86_64/kernel/irq.rs @@ -90,7 +90,7 @@ pub fn disable() { /// were not activated before calling this function. #[inline] pub fn nested_disable() -> bool { - cfg!(target_os = "hermit") && { + cfg!(any(target_os = "none", target_os = "hermit")) && { let ret = rflags::read().contains(RFlags::FLAGS_IF); disable(); ret diff --git a/src/arch/x86_64/kernel/mod.rs b/src/arch/x86_64/kernel/mod.rs index cc57b123b6..7f95415aa0 100644 --- a/src/arch/x86_64/kernel/mod.rs +++ b/src/arch/x86_64/kernel/mod.rs @@ -119,14 +119,14 @@ impl BootInfo { } /// Kernel header to announce machine features -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] static mut BOOT_INFO: *mut BootInfo = ptr::null_mut(); -#[cfg(all(target_os = "hermit", not(feature = "newlib")))] +#[cfg(all(any(target_os = "none", target_os = "hermit"), not(feature = "newlib")))] #[link_section = ".data"] static mut BOOT_INFO: *mut BootInfo = ptr::null_mut(); -#[cfg(all(target_os = "hermit", feature = "newlib"))] +#[cfg(all(any(target_os = "none", target_os = "hermit"), feature = "newlib"))] #[link_section = ".mboot"] static mut BOOT_INFO: *mut BootInfo = ptr::null_mut(); @@ -298,7 +298,10 @@ pub fn message_output_init() { } } -#[cfg(all(not(target_os = "hermit"), not(target_os = "windows")))] +#[cfg(all( + not(any(target_os = "none", target_os = "hermit")), + not(target_os = "windows") +))] pub fn output_message_byte(byte: u8) { extern "C" { fn write(fd: i32, buf: *const u8, count: usize) -> isize; @@ -320,7 +323,7 @@ pub fn output_message_byte(byte: u8) { } } -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn test_output() { output_message_byte('t' as u8); @@ -330,7 +333,7 @@ fn test_output() { output_message_byte('\n' as u8); } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub fn output_message_byte(byte: u8) { if environment::is_single_kernel() { // Output messages to the serial port and VGA screen in unikernel mode. @@ -348,7 +351,7 @@ pub fn output_message_byte(byte: u8) { } } -//#[cfg(target_os = "hermit")] +//#[cfg(any(target_os = "none", target_os = "hermit"))] pub fn output_message_buf(buf: &[u8]) { for byte in buf { output_message_byte(*byte); @@ -356,7 +359,7 @@ pub fn output_message_buf(buf: &[u8]) { } /// Real Boot Processor initialization as soon as we have put the first Welcome message on the screen. -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub fn boot_processor_init() { processor::detect_features(); processor::configure(); @@ -403,7 +406,7 @@ pub fn boot_processor_init() { /// Boots all available Application Processors on bare-metal or QEMU. /// Called after the Boot Processor has been fully initialized along with its scheduler. -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub fn boot_application_processors() { #[cfg(feature = "smp")] apic::boot_application_processors(); @@ -411,7 +414,7 @@ pub fn boot_application_processors() { } /// Application Processor initialization -#[cfg(all(target_os = "hermit", feature = "smp"))] +#[cfg(all(any(target_os = "none", target_os = "hermit"), feature = "smp"))] pub fn application_processor_init() { percore::init(); processor::configure(); @@ -466,7 +469,7 @@ pub fn print_statistics() { } } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[inline(never)] #[no_mangle] unsafe fn pre_init(boot_info: &'static mut BootInfo) -> ! { diff --git a/src/arch/x86_64/kernel/percore.rs b/src/arch/x86_64/kernel/percore.rs index aa3324faad..7bee11e01e 100644 --- a/src/arch/x86_64/kernel/percore.rs +++ b/src/arch/x86_64/kernel/percore.rs @@ -137,13 +137,13 @@ impl PerCoreVariableMethods for PerCoreVariable { } } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[inline] pub fn core_id() -> CoreId { unsafe { PERCORE.core_id.get() } } -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] pub fn core_id() -> CoreId { 0 } diff --git a/src/arch/x86_64/kernel/processor.rs b/src/arch/x86_64/kernel/processor.rs index 13bc22e4bd..936d0d4a07 100644 --- a/src/arch/x86_64/kernel/processor.rs +++ b/src/arch/x86_64/kernel/processor.rs @@ -337,14 +337,14 @@ impl CpuFrequency { pic::eoi(pit::PIT_INTERRUPT_NUMBER); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] fn measure_frequency(&mut self) -> Result<(), ()> { // return just Ok because the real implementation must run in ring 0 self.source = CpuFrequencySources::Measurement; Ok(()) } - #[cfg(target_os = "hermit")] + #[cfg(any(target_os = "none", target_os = "hermit"))] fn measure_frequency(&mut self) -> Result<(), ()> { // The PIC is not initialized for uhyve, so we cannot measure anything. if environment::is_uhyve() { @@ -865,7 +865,7 @@ pub fn print_information() { infofooter!(); } -/*#[cfg(not(target_os = "hermit"))] +/*#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn print_cpu_information() { ::logging::init(); diff --git a/src/arch/x86_64/kernel/scheduler.rs b/src/arch/x86_64/kernel/scheduler.rs index 2aabfe14d8..bfcfa8bda4 100644 --- a/src/arch/x86_64/kernel/scheduler.rs +++ b/src/arch/x86_64/kernel/scheduler.rs @@ -305,12 +305,12 @@ impl Clone for TaskTLS { } } -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] extern "C" fn task_start(_f: extern "C" fn(usize), _arg: usize, _user_stack: u64) -> ! { unimplemented!() } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[naked] extern "C" fn task_start(_f: extern "C" fn(usize), _arg: usize, _user_stack: u64) -> ! { // `f` is in the `rdi` register diff --git a/src/console.rs b/src/console.rs index 0682612aa4..d9155c703c 100644 --- a/src/console.rs +++ b/src/console.rs @@ -31,7 +31,7 @@ impl Console { pub static CONSOLE: SpinlockIrqSave = SpinlockIrqSave::new(Console(())); -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn test_console() { println!("HelloWorld"); diff --git a/src/lib.rs b/src/lib.rs index 897f28dc48..ae5f6d6e6f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,13 +30,19 @@ #![feature(llvm_asm)] #![feature(global_asm)] #![no_std] -#![cfg_attr(target_os = "hermit", feature(custom_test_frameworks))] -#![cfg_attr(target_os = "hermit", cfg_attr(test, test_runner(crate::test_runner)))] #![cfg_attr( - target_os = "hermit", + any(target_os = "none", target_os = "hermit"), + feature(custom_test_frameworks) +)] +#![cfg_attr( + any(target_os = "none", target_os = "hermit"), + cfg_attr(test, test_runner(crate::test_runner)) +)] +#![cfg_attr( + any(target_os = "none", target_os = "hermit"), cfg_attr(test, reexport_test_harness_main = "test_main") )] -#![cfg_attr(target_os = "hermit", cfg_attr(test, no_main))] +#![cfg_attr(any(target_os = "none", target_os = "hermit"), cfg_attr(test, no_main))] // EXTERNAL CRATES #[macro_use] @@ -47,7 +53,7 @@ extern crate bitflags; extern crate log; #[macro_use] extern crate num_derive; -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[macro_use] extern crate std; #[cfg(target_arch = "aarch64")] @@ -88,7 +94,7 @@ mod errno; mod ffi; mod kernel_message_buffer; mod mm; -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] mod runtime_glue; mod scheduler; mod synch; @@ -102,7 +108,7 @@ pub fn _print(args: ::core::fmt::Arguments<'_>) { } #[cfg(test)] -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[no_mangle] extern "C" fn runtime_entry(_argc: i32, _argv: *const *const u8, _env: *const *const u8) -> ! { println!("Executing hermit unittests. Any arguments are dropped"); @@ -120,14 +126,14 @@ pub fn test_runner(tests: &[&dyn Fn()]) { sys_exit(0); } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[test_case] fn trivial_test() { println!("Test test test"); panic!("Test called"); } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[global_allocator] static ALLOCATOR: LockedHeap = LockedHeap::empty(); @@ -137,7 +143,7 @@ static ALLOCATOR: LockedHeap = LockedHeap::empty(); /// Returning a null pointer indicates that either memory is exhausted or /// `size` and `align` do not meet this allocator's size or alignment constraints. /// -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub extern "C" fn __sys_malloc(size: usize, align: usize) -> *mut u8 { let layout_res = Layout::from_size_align(size, align); if layout_res.is_err() || size == 0 { @@ -179,7 +185,7 @@ pub extern "C" fn __sys_malloc(size: usize, align: usize) -> *mut u8 { /// # Errors /// Returns null if the new layout does not meet the size and alignment constraints of the /// allocator, or if reallocation otherwise fails. -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub extern "C" fn __sys_realloc( ptr: *mut u8, size: usize, @@ -224,7 +230,7 @@ pub extern "C" fn __sys_realloc( /// /// # Errors /// May panic if debug assertions are enabled and invalid parameters `size` or `align` where passed. -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub extern "C" fn __sys_free(ptr: *mut u8, size: usize, align: usize) { unsafe { let layout_res = Layout::from_size_align(size, align); @@ -247,7 +253,7 @@ pub extern "C" fn __sys_free(ptr: *mut u8, size: usize, align: usize) { } } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] extern "C" { static mut __bss_start: usize; } @@ -259,7 +265,7 @@ fn has_ipdevice() -> bool { } /// Entry point of a kernel thread, which initialize the libos -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] extern "C" fn initd(_arg: usize) { extern "C" { #[cfg(not(test))] @@ -319,7 +325,7 @@ fn synch_all_cores() { } /// Entry Point of HermitCore for the Boot Processor -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] fn boot_processor_main() -> ! { // Initialize the kernel and hardware. arch::message_output_init(); @@ -372,7 +378,7 @@ fn boot_processor_main() -> ! { } /// Entry Point of HermitCore for an Application Processor -#[cfg(all(target_os = "hermit", feature = "smp"))] +#[cfg(all(any(target_os = "none", target_os = "hermit"), feature = "smp"))] fn application_processor_main() -> ! { arch::application_processor_init(); scheduler::add_current_core(); diff --git a/src/mm/allocator.rs b/src/mm/allocator.rs index 6a31d99e27..ce2c14e2a7 100644 --- a/src/mm/allocator.rs +++ b/src/mm/allocator.rs @@ -31,9 +31,9 @@ pub struct Heap { index: usize, bottom: usize, size: usize, - #[cfg(target_os = "hermit")] + #[cfg(any(target_os = "none", target_os = "hermit"))] holes: HoleList, - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] pub holes: HoleList, } diff --git a/src/mm/freelist.rs b/src/mm/freelist.rs index 5dd5b2576e..7db3bd02fc 100644 --- a/src/mm/freelist.rs +++ b/src/mm/freelist.rs @@ -190,7 +190,7 @@ impl FreeList { } } -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn add_element() { let mut freelist = FreeList::new(); @@ -208,7 +208,7 @@ fn add_element() { } } -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn allocate() { let mut freelist = FreeList::new(); @@ -241,7 +241,7 @@ fn allocate() { } } -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn deallocate() { let mut freelist = FreeList::new(); diff --git a/src/mm/hole.rs b/src/mm/hole.rs index 86a9337221..c1fa95c422 100644 --- a/src/mm/hole.rs +++ b/src/mm/hole.rs @@ -80,7 +80,7 @@ impl HoleList { } /// Returns information about the first hole for test purposes. - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[cfg(test)] pub fn first_hole(&self) -> Option<(usize, usize)> { self.first @@ -91,13 +91,13 @@ impl HoleList { } /// A block containing free memory. It points to the next hole and thus forms a linked list. -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub struct Hole { size: usize, next: Option<&'static mut Hole>, } -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] pub struct Hole { pub size: usize, pub next: Option<&'static mut Hole>, diff --git a/src/mm/mod.rs b/src/mm/mod.rs index 97a04f9627..4299bec47e 100644 --- a/src/mm/mod.rs +++ b/src/mm/mod.rs @@ -71,7 +71,7 @@ fn map_heap(virt_addr: VirtAddr, size: usize) -> usize { i } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub fn init() { // Calculate the start and end addresses of the 2 MiB page(s) that map the kernel. unsafe { diff --git a/src/mm/test.rs b/src/mm/test.rs index a17d6ab2fb..dda0e90562 100644 --- a/src/mm/test.rs +++ b/src/mm/test.rs @@ -5,7 +5,7 @@ // To avoid false sharing, our version allocate as smallest block 64 byte (= cache line). // In addition, for pre -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[cfg(test)] mod tests { use super::*; @@ -42,7 +42,7 @@ mod tests { heap } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn empty() { let mut heap = Heap::empty(); @@ -55,7 +55,7 @@ mod tests { assert!(addr.is_err()); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn oom() { let mut heap = new_heap(); @@ -64,7 +64,7 @@ mod tests { assert!(addr.is_err()); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn allocate_double_usize() { let mut heap = new_heap(); @@ -86,7 +86,7 @@ mod tests { } } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn allocate_and_free_double_usize() { let mut heap = new_heap(); @@ -102,7 +102,7 @@ mod tests { } } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn deallocate_right_before() { let mut heap = new_heap(); @@ -129,7 +129,7 @@ mod tests { } } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn deallocate_right_behind() { let mut heap = new_heap(); @@ -151,7 +151,7 @@ mod tests { } } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn deallocate_middle() { let mut heap = new_heap(); @@ -178,7 +178,7 @@ mod tests { } } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn reallocate_double_usize() { let mut heap = new_heap(); @@ -198,7 +198,7 @@ mod tests { assert_eq!(x, y); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn allocate_usize() { let mut heap = new_heap(); @@ -208,7 +208,7 @@ mod tests { assert!(heap.allocate_first_fit(layout.clone()).is_ok()); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn allocate_usize_in_bigger_block() { let mut heap = new_heap(); @@ -233,7 +233,7 @@ mod tests { } } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] // see https://github.com/phil-opp/blog_os/issues/160 fn align_from_small_to_big() { @@ -248,7 +248,7 @@ mod tests { assert!(heap.allocate_first_fit(layout_2.clone()).is_ok()); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn extend_empty_heap() { let mut heap = new_max_heap(); @@ -262,7 +262,7 @@ mod tests { assert!(heap.allocate_first_fit(layout.clone()).is_ok()); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn extend_full_heap() { let mut heap = new_max_heap(); @@ -277,7 +277,7 @@ mod tests { assert!(heap.allocate_first_fit(layout.clone()).is_ok()); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn extend_fragmented_heap() { let mut heap = new_max_heap(); diff --git a/src/runtime_glue.rs b/src/runtime_glue.rs index 8a9e65271d..c81cbcd2f3 100644 --- a/src/runtime_glue.rs +++ b/src/runtime_glue.rs @@ -7,7 +7,7 @@ use alloc::alloc::Layout; use core::panic::PanicInfo; // see https://users.rust-lang.org/t/psa-breaking-change-panic-fmt-language-item-removed-in-favor-of-panic-implementation/17875 -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[panic_handler] fn panic(info: &PanicInfo<'_>) -> ! { print!("[{}][!!!PANIC!!!] ", arch::percore::core_id()); @@ -44,6 +44,7 @@ fn rust_oom(layout: Layout) -> ! { } } +#[cfg(target_os = "hermit")] #[no_mangle] pub unsafe extern "C" fn __rg_oom(size: usize, align: usize) -> ! { let layout = Layout::from_size_align_unchecked(size, align); diff --git a/src/syscalls/interfaces/uhyve.rs b/src/syscalls/interfaces/uhyve.rs index a13bcc74d9..bad7c4df05 100644 --- a/src/syscalls/interfaces/uhyve.rs +++ b/src/syscalls/interfaces/uhyve.rs @@ -207,7 +207,7 @@ impl SyscallInterface for Uhyve { /// /// ToDo: Add Safety section under which circumctances this is safe/unsafe to use /// ToDo: Add an Errors section - What happens when e.g. malloc fails, how is that handled (currently it isn't) - #[cfg(target_os = "hermit")] + #[cfg(any(target_os = "none", target_os = "hermit"))] fn get_application_parameters(&self) -> (i32, *const *const u8, *const *const u8) { // determine the number of arguments and environment variables let mut syscmdsize = SysCmdsize::new(); diff --git a/src/syscalls/mod.rs b/src/syscalls/mod.rs index 2ba403ce44..b61ee7f251 100644 --- a/src/syscalls/mod.rs +++ b/src/syscalls/mod.rs @@ -6,7 +6,7 @@ use crate::environment; #[cfg(feature = "newlib")] use crate::synch::spinlock::SpinlockIrqSave; use crate::syscalls::interfaces::SyscallInterface; -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] use crate::{__sys_free, __sys_malloc, __sys_realloc}; pub use self::condvar::*; @@ -60,19 +60,19 @@ pub fn init() { sbrk_init(); } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[no_mangle] pub extern "C" fn sys_malloc(size: usize, align: usize) -> *mut u8 { __sys_malloc(size, align) } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[no_mangle] pub extern "C" fn sys_realloc(ptr: *mut u8, size: usize, align: usize, new_size: usize) -> *mut u8 { __sys_realloc(ptr, size, align, new_size) } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[no_mangle] pub extern "C" fn sys_free(ptr: *mut u8, size: usize, align: usize) { __sys_free(ptr, size, align) From e5cceb583cb2b6560f6800efe91ab407ca290e4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 1 Dec 2021 23:26:24 +0100 Subject: [PATCH 3/4] Upgrade toolchain channel to nightly-2021-11-08 Experimental features have been split off of the `asm` feature gate. --- rust-toolchain.toml | 2 +- src/lib.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index bb73df0cf8..cf9f83138f 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2021-11-01" +channel = "nightly-2021-11-08" components = [ "rust-src", "llvm-tools-preview", diff --git a/src/lib.rs b/src/lib.rs index ae5f6d6e6f..9750430b2b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,6 +11,8 @@ #![feature(abi_x86_interrupt)] #![feature(allocator_api)] #![feature(asm)] +#![feature(asm_const)] +#![feature(asm_sym)] #![feature(const_btree_new)] #![feature(const_fn_trait_bound)] #![feature(const_mut_refs)] From e13eaaaf1992f79ad7e1941d70522de1d5264e9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Sun, 5 Dec 2021 01:08:06 +0100 Subject: [PATCH 4/4] Upgrade toolchain channel to nightly-2021-12-04 --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index cf9f83138f..36d415aa2c 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2021-11-08" +channel = "nightly-2021-12-04" components = [ "rust-src", "llvm-tools-preview",