diff --git a/.cargo/config b/.cargo/config index 89070681fb..42399c1716 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,5 +1,6 @@ [unstable] build-std = ["core", "alloc"] +build-std-features = ["compiler-builtins-mem"] [build] target = "x86_64-unknown-hermit-kernel" diff --git a/.github/workflows/experimental.yml b/.github/workflows/nightly.yml similarity index 94% rename from .github/workflows/experimental.yml rename to .github/workflows/nightly.yml index ae5414b0b7..a584861d59 100644 --- a/.github/workflows/experimental.yml +++ b/.github/workflows/nightly.yml @@ -1,4 +1,4 @@ -name: Tests (experimental) +name: Tests (nightly) on: pull_request: @@ -10,11 +10,11 @@ on: jobs: build: - name: Tests (experimental) + name: Tests runs-on: ${{ matrix.os }} # these tests based on the nightly compiler, which can be broken # consequently, we continue on an error - continue-on-error: true + #continue-on-error: true strategy: matrix: @@ -31,7 +31,7 @@ jobs: targets: 'x86_64-pc-windows-msvc' - os: ubuntu-latest rust: 'nightly' - components: 'rust-src, llvm-tools-preview, rustfmt' + components: 'rust-src, llvm-tools-preview' targets: 'x86_64-unknown-linux-gnu' @@ -116,8 +116,12 @@ jobs: qemu-system-x86_64 -display none -smp 2 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/debug/rusty-loader -initrd target/x86_64-unknown-hermit/release/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr timeout-minutes: 20 - name: Integration Tests + working-directory: libhermit-rs run: cargo test --tests --no-fail-fast -Z build-std=core,alloc --target x86_64-unknown-hermit-kernel -- --bootloader_path=../loader/target/x86_64-unknown-hermit-loader/debug/rusty-loader + if: ${{ matrix.os == 'ubuntu-latest' }} - name: Integration Tests (smp) + working-directory: libhermit-rs run: cargo test --tests --no-fail-fast -Z build-std=core,alloc --target x86_64-unknown-hermit-kernel -- --bootloader_path=../loader/target/x86_64-unknown-hermit-loader/debug/rusty-loader --num_cores 2 + if: ${{ matrix.os == 'ubuntu-latest' }} diff --git a/Cargo.lock b/Cargo.lock index 6872f80f52..cdfcb15d77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,9 +20,9 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "cc" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c" +checksum = "ed67cbde08356238e75fc4656be4749481eeffb09e19f320a25237d5221c985d" [[package]] name = "cfg-if" @@ -131,9 +131,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ef7cd2518ead700af67bf9d1a658d90b6037d77110fd9c0445429d0ba1c6c9" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" dependencies = [ "unicode-xid", ] @@ -149,9 +149,9 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "8.1.1" +version = "8.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cee2c7710d96f9f90f56824fca5438b301dc0fb49ece4cf9dfa044e54067e10" +checksum = "1fdf7d9dbd43f3d81d94a49c1c3df73cc2b3827995147e6cf7f89d4ec5483e73" dependencies = [ "bitflags", "cc", @@ -205,9 +205,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "syn" -version = "1.0.42" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c51d92969d209b54a98397e1b91c8ae82d8c87a7bb87df0b29aa2ad81454228" +checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" dependencies = [ "proc-macro2", "quote", diff --git a/bors.toml b/bors.toml index f53631b8d9..256b290f6e 100644 --- a/bors.toml +++ b/bors.toml @@ -1,5 +1,8 @@ status = [ "Tests", + "Tests (macOS-latest, nightly)", + "Tests (windows-latest, nightly)", + "Tests (ubuntu-latest, nightly)", "Format check (ubuntu-latest, nightly)", "continuous-integration/travis-ci/push" ] diff --git a/src/lib.rs b/src/lib.rs index ae81c07528..7998321e7c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -95,8 +95,6 @@ pub mod environment; mod errno; mod kernel_message_buffer; mod mm; -#[cfg(not(feature = "newlib"))] -mod rlib; #[cfg(target_os = "hermit")] mod runtime_glue; mod scheduler; diff --git a/src/rlib.rs b/src/rlib.rs deleted file mode 100644 index 1ed6a41e9f..0000000000 --- a/src/rlib.rs +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! This library is derived from rlibc, not intended for general use, -//! and is superseded by a system libc if one is available. In a -//! freestanding context, however, common functions such as memset, memcpy, -//! etc are not implemented. This library provides an implementation of -//! these functions which are either required by libcore or called by rustc -//! implicitly. - -#[no_mangle] -pub unsafe extern "C" fn memcpy(dest: *mut u8, src: *const u8, n: usize) -> *mut u8 { - let mut i = 0; - while i < n { - *dest.add(i) = *src.add(i); - i += 1; - } - dest -} - -#[no_mangle] -pub unsafe extern "C" fn memmove(dest: *mut u8, src: *const u8, n: usize) -> *mut u8 { - if src < dest as *const u8 { - // copy from end - let mut i = n; - while i != 0 { - i -= 1; - *dest.add(i) = *src.add(i); - } - } else { - // copy from beginning - let mut i = 0; - while i < n { - *dest.add(i) = *src.add(i); - i += 1; - } - } - dest -} - -#[no_mangle] -pub unsafe extern "C" fn memset(s: *mut u8, c: i32, n: usize) -> *mut u8 { - let mut i = 0; - while i < n { - *s.add(i) = c as u8; - i += 1; - } - s -} - -#[no_mangle] -pub unsafe extern "C" fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 { - let mut i = 0; - while i < n { - let a = *s1.add(i); - let b = *s2.add(i); - if a != b { - return a as i32 - b as i32; - } - i += 1; - } - 0 -} - -#[cfg(not(target_os = "hermit"))] -#[cfg(test)] -mod test { - use super::{memcmp, memcpy, memmove, memset}; - - #[cfg(not(target_os = "hermit"))] - #[test] - fn memcmp_single_byte_pointers() { - unsafe { - assert_eq!(memcmp(&0xFAu8, &0xFAu8, 1), 0x00); - assert!(memcmp(&0xEFu8, &0xFEu8, 1) < 0x00); - } - } - - #[cfg(not(target_os = "hermit"))] - #[test] - fn memcmp_strings() { - { - let (x, z) = ("Hello!", "Good Bye."); - let l = x.len(); - unsafe { - assert_eq!(memcmp(x.as_ptr(), x.as_ptr(), l), 0); - assert!(memcmp(x.as_ptr(), z.as_ptr(), l) > 0); - assert!(memcmp(z.as_ptr(), x.as_ptr(), l) < 0); - } - } - { - let (x, z) = ("hey!", "hey."); - let l = x.len(); - unsafe { - assert!(memcmp(x.as_ptr(), z.as_ptr(), l) < 0); - } - } - } - - #[cfg(not(target_os = "hermit"))] - #[test] - fn memset_single_byte_pointers() { - let mut x: u8 = 0xFF; - unsafe { - memset(&mut x, 0xAA, 1); - assert_eq!(x, 0xAA); - memset(&mut x, 0x00, 1); - assert_eq!(x, 0x00); - x = 0x01; - memset(&mut x, 0x12, 0); - assert_eq!(x, 0x01); - } - } - - #[cfg(not(target_os = "hermit"))] - #[test] - fn memset_array() { - let mut buffer = [b'X'; 100]; - unsafe { - memset(buffer.as_mut_ptr(), b'#' as i32, buffer.len()); - } - for byte in buffer.iter() { - assert_eq!(*byte, b'#'); - } - } - - #[cfg(not(target_os = "hermit"))] - #[test] - fn memcpy_and_memcmp_arrays() { - let (src, mut dst) = ([b'X'; 100], [b'Y'; 100]); - unsafe { - assert_ne!(memcmp(src.as_ptr(), dst.as_ptr(), 100), 0); - let _ = memcpy(dst.as_mut_ptr(), src.as_ptr(), 100); - assert_eq!(memcmp(src.as_ptr(), dst.as_ptr(), 100), 0); - } - } - - #[cfg(not(target_os = "hermit"))] - #[test] - fn memmove_overlapping() { - { - let mut buffer = [b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9']; - unsafe { - memmove(&mut buffer[4], &buffer[0], 6); - let mut i = 0; - for byte in b"0123012345".iter() { - assert_eq!(buffer[i], *byte); - i += 1; - } - } - } - { - let mut buffer = [b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9']; - unsafe { - memmove(&mut buffer[0], &buffer[4], 6); - let mut i = 0; - for byte in b"4567896789".iter() { - assert_eq!(buffer[i], *byte); - i += 1; - } - } - } - } -}