Set `libos` as the default feature, update CI

This commit is contained in:
Yuekai Jia 2021-10-26 01:26:28 +08:00
parent 169088dc31
commit 9b6c1f5928
24 changed files with 158 additions and 165 deletions

96
.github/workflows/build-20210727.yml vendored Normal file
View File

@ -0,0 +1,96 @@
name: Build CI
on:
push:
pull_request:
schedule:
- cron: '40 3 * * *' # every day at 3:40
jobs:
check:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-07-27
override: true
components: rust-src, rustfmt, clippy
- name: Check code format
run: cargo fmt --all -- --check
- name: Clippy LibOS
run: cargo clippy --all-features
- name: Clippy x86_64 bare-metal
run: cd zCore && make clippy ARCH=x86_64
- name: Clippy riscv64 bare-metal
run: cd zCore && make clippy ARCH=riscv64 LINUX=1
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-latest]
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-07-27
components: rust-src, llvm-tools-preview
- uses: actions-rs/install@v0.1
with:
crate: cargo-binutils
version: latest
- name: Build all packages
run: cargo build
- name: Build linux LibOS
run: cargo build --features "linux libos"
- name: Build zircon LibOS
run: cargo build --features "zircon libos"
- name: Build x86_64 bare-metal
run: cd zCore && make build ARCH=x86_64
- name: Build riscv64 bare-metal
run: cd zCore && make build ARCH=riscv64 LINUX=1
build-aarch64:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-07-27
override: true
target: aarch64-unknown-linux-gnu
- uses: actions-rs/cargo@v1
with:
command: build
use-cross: true
args: -p zircon-loader --target aarch64-unknown-linux-gnu --workspace --exclude linux-syscall --exclude linux-loader --exclude zcore
build-user:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-latest]
steps:
- uses: actions/checkout@v2
- name: Pull prebuilt images
run: git lfs pull -I prebuilt/zircon/x64/libc.so,prebuilt/zircon/x64/libfdio.so,prebuilt/zircon/x64/libunwind.so,prebuilt/zircon/x64/libzircon.so,prebuilt/zircon/x64/Scrt1.o
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-07-27
target: x86_64-fuchsia
- name: Build Zircon user programs
run: cd zircon-user && make build MODE=release
build-doc:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Build docs
run: cargo doc --no-deps --all-features

View File

@ -1,4 +1,4 @@
name: deploy CI
name: Deploy docs
on:
push:

View File

@ -1,4 +1,4 @@
name: current CI
name: Test CI
on:
push:
@ -7,90 +7,6 @@ on:
- cron: '40 3 * * *' # every day at 3:40
jobs:
check:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-07-27
override: true
components: rust-src, rustfmt, clippy
- name: Check code format
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Clippy LibOS
run: cargo clippy --all-features
- name: Clippy x86_64 bare-metal
run: cd zCore && make clippy ARCH=x86_64
- name: Clippy riscv64 bare-metal
run: cd zCore && make clippy ARCH=riscv64 LINUX=1
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-latest]
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-07-27
components: rust-src, llvm-tools-preview
- uses: actions-rs/install@v0.1
with:
crate: cargo-binutils
version: latest
- name: Build linux LibOS
run: cargo build --features "linux libos"
- name: Build zircon LibOS
run: cargo build --features "zircon libos"
- name: Build x86_64 bare-metal
run: cd zCore && make build ARCH=x86_64
- name: Build riscv64 bare-metal
run: cd zCore && make build ARCH=riscv64 LINUX=1
build-aarch64:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-07-27
override: true
target: aarch64-unknown-linux-gnu
- uses: actions-rs/cargo@v1
with:
command: build
use-cross: true
args: -p zircon-loader --target aarch64-unknown-linux-gnu
build-user:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-latest]
steps:
- uses: actions/checkout@v2
- name: Pull prebuilt images
run: git lfs pull -I prebuilt/zircon/x64/libc.so,prebuilt/zircon/x64/libfdio.so,prebuilt/zircon/x64/libunwind.so,prebuilt/zircon/x64/libzircon.so,prebuilt/zircon/x64/Scrt1.o
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-07-27
target: x86_64-fuchsia
- name: Build Zircon user programs
run: |
cd zircon-user
make build MODE=release
test:
runs-on: ubuntu-20.04
steps:
@ -145,17 +61,14 @@ jobs:
sudo apt update
sudo apt install qemu-system-x86
- name: Build zCore
run: |
cd zCore
make build MODE=release
cd ..
run: cd zCore && make build MODE=release
- name: Run core-tests
run: |
cd scripts
pip3 install pexpect
pip3 install -r requirements.txt
python3 core-tests.py
core-test-libos:
libos-core-test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
@ -166,13 +79,13 @@ jobs:
profile: minimal
toolchain: nightly-2021-07-27
components: rust-src
- name: Run core-tests
- name: Run libos-core-tests
run: |
cd scripts
pip3 install pexpect
pip3 install -r requirements.txt
python3 unix-core-tests.py
libc-test:
libos-libc-test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
@ -182,38 +95,13 @@ jobs:
run: sudo apt-get install musl-tools musl-dev -y
- name: Prepare rootfs and libc-test
run: make rootfs && make libc-test
- name: Build
run: cargo build --release -p linux-loader
# uses: actions-rs/cargo@v1
# with:
# command: build
# args: --release -p linux-loader
- name: Run libc-tests
- name: Run libos-libc-tests
run: |
cd scripts
pip3 install -r requirements.txt
python3 libc-tests.py
python3 libos-libc-tests.py
cat linux/test-result.txt
doc:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Build docs
run: cargo doc --no-deps --all-features
# uses: actions-rs/cargo@v1
# with:
# command: doc
# args: --no-deps --all-features
# - name: Deploy to Github Pages
# if: ${{ github.ref == 'refs/heads/master' }}
# uses: JamesIves/github-pages-deploy-action@releases/v3
# with:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# BRANCH: gh-pages
# FOLDER: target/doc
baremetal-libc-test:
runs-on: ubuntu-20.04
steps:
@ -241,6 +129,7 @@ jobs:
run: |
cd scripts
python3 ./baremetal-libc-test.py
baremetal-rv64-oscomp-test:
runs-on: ubuntu-20.04
steps:

View File

@ -8,8 +8,9 @@ description = "Kernel HAL interface definations."
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
default = ["libos"]
smp = []
libos = ["async-std", "bitmap-allocator", "zcore-drivers/mock"]
libos = ["nix", "tempfile", "async-std", "bitmap-allocator", "zcore-drivers/mock"]
graphic = ["zcore-drivers/graphic"]
[dependencies]
@ -25,8 +26,8 @@ zcore-drivers = { path = "../drivers", features = ["virtio"] }
# LibOS mode
[target.'cfg(not(target_os = "none"))'.dependencies]
nix = "0.23"
tempfile = "3"
nix = { version = "0.23", optional = true }
tempfile = { version = "3", optional = true }
async-std = { version = "1.10", optional = true }
bitmap-allocator = { git = "https://github.com/rcore-os/bitmap-allocator", rev = "b3f9f51", optional = true }

View File

@ -12,7 +12,7 @@ log = "0.4"
linux-syscall = { path = "../linux-syscall" }
linux-object = { path = "../linux-object" }
zircon-object = { path = "../zircon-object" }
kernel-hal = { path = "../kernel-hal" }
kernel-hal = { path = "../kernel-hal", default-features = false }
[features]
default = ["libos"]

View File

@ -16,7 +16,7 @@ bitflags = "1.3"
hashbrown = "0.9"
numeric-enum-macro = "0.2"
zircon-object = { path = "../zircon-object", features = ["elf"] }
kernel-hal = { path = "../kernel-hal" }
kernel-hal = { path = "../kernel-hal", default-features = false }
downcast-rs = { version = "1.2", default-features = false }
lazy_static = { version = "1.4", features = ["spin_no_std"] }
rcore-fs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7c232ec" }

View File

@ -1,5 +1,6 @@
//! Process init info
#![allow(unsafe_code)]
#![allow(dead_code)]
use alloc::collections::btree_map::BTreeMap;
use alloc::string::String;

View File

@ -14,7 +14,7 @@ bitflags = "1.3"
numeric-enum-macro = "0.2"
zircon-object = { path = "../zircon-object" }
linux-object = { path = "../linux-object" }
kernel-hal = { path = "../kernel-hal" }
kernel-hal = { path = "../kernel-hal", default-features = false }
rcore-fs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7c232ec" }
lazy_static = { version = "1.4", features = ["spin_no_std"] }
bitvec = { version = "0.22", default-features = false, features = ["alloc"] }

View File

@ -7,9 +7,9 @@
//! let args = [regs.rdi, regs.rsi, regs.rdx, regs.r10, regs.r8, regs.r9];
//! let mut syscall = Syscall {
//! thread,
//! #[cfg(feature = "std")]
//! #[cfg(feature = "libos")]
//! syscall_entry: kernel_hal::context::syscall_entry as usize,
//! #[cfg(not(feature = "std"))]
//! #[cfg(not(feature = "libos"))]
//! syscall_entry: 0,
//! thread_fn,
//! regs,

View File

@ -25,7 +25,7 @@ def print_cases(cases, file=None):
print(case, file=file)
subprocess.run("cd .. && cargo build -p zcore --release --features 'linux libos'",
subprocess.run("cargo build -p zcore --release --features 'linux libos'",
shell=True, check=True)
for path in sorted(glob.glob("../rootfs/libc-test/src/*/*.exe")):

View File

@ -1 +1,2 @@
pexpect
termcolor

View File

@ -12,7 +12,7 @@ parser = argparse.ArgumentParser()
parser.add_argument('testcase', nargs=1)
args = parser.parse_args()
child = pexpect.spawn("cargo run -p zcore --features 'zircon libos' -- '%s' '%s'" %
child = pexpect.spawn("cargo run -p zcore --release --features 'zircon libos' -- '%s' '%s'" %
(ZBI_PATH, CMDLINE_BASE+args.testcase[0]),
timeout=TIMEOUT, encoding='utf-8')

View File

@ -2,6 +2,7 @@ import pexpect
import sys
import re
import os
import subprocess
TIMEOUT = 300
ZIRCON_LOADER_PATH = 'zircon-loader'
@ -40,9 +41,11 @@ with open(TEST_CASE_EXCEPTION, "r") as tcf:
exception_case = set([case.strip() for case in tcf.readlines()])
check_case = all_case - exception_case
subprocess.run("cargo build -p zcore --release --features 'zircon libos'",
shell=True, check=True)
for line in check_case:
child = pexpect.spawn("cargo run -p zcore --features 'zircon libos' -- '%s' '%s'" %
(ZBI_PATH, CMDLINE_BASE+line),
child = pexpect.spawn("../target/release/zcore", [ZBI_PATH, CMDLINE_BASE+line],
timeout=TIMEOUT, encoding='utf-8')
child.logfile = Tee(OUTPUT_FILE, 'a')

View File

@ -15,18 +15,18 @@ bench = false
doc = false
[features]
default = ["color_log"]
color_log = []
default = ["libos"]
colorless-log = []
graphic = ["kernel-hal/graphic"]
init_ram_disk = []
link_user_img = ["init_ram_disk"]
init-ram-disk = []
link-user-img = ["init-ram-disk"]
zircon = ["zircon-loader"]
linux = ["linux-loader", "linux-object", "rcore-fs", "rcore-fs-sfs"]
libos = ["async-std", "chrono", "rcore-fs-hostfs", "linux-loader/libos", "zircon-loader/libos"]
board_qemu = []
board_d1 = ["link_user_img"]
libos = ["async-std", "chrono", "rcore-fs-hostfs", "kernel-hal/libos", "linux-loader/libos", "zircon-loader/libos"]
board-qemu = []
board-d1 = ["link-user-img"]
[dependencies]
log = "0.4"
@ -34,7 +34,7 @@ spin = "0.9"
cfg-if = "1.0"
lazy_static = { version = "1.4", features = ["spin_no_std" ] }
bitmap-allocator = { git = "https://github.com/rcore-os/bitmap-allocator", rev = "b3f9f51" }
kernel-hal = { path = "../kernel-hal", features = ["smp"] }
kernel-hal = { path = "../kernel-hal", default-features = false, features = ["smp"] }
zircon-object = { path = "../zircon-object" }
linux-object = { path = "../linux-object", optional = true }
zircon-loader = { path = "../zircon-loader", default-features = false, optional = true }

View File

@ -80,12 +80,12 @@ ifeq ($(LIBOS), 1)
features += libos
else
ifeq ($(ARCH), x86_64)
features += init_ram_disk
features += init-ram-disk
else ifeq ($(ARCH), riscv64)
ifeq ($(PLATFORM), d1)
features += board_d1 link_user_img
features += board-d1 link-user-img
else
features += board_qemu
features += board-qemu
endif
endif
endif
@ -106,7 +106,7 @@ endif
build_args := --features "$(features)"
ifneq ($(LIBOS), 1) # no_std
build_args += --target $(ARCH).json -Z build-std=core,alloc -Z build-std-features=compiler-builtins-mem
build_args += --no-default-features --target $(ARCH).json -Z build-std=core,alloc -Z build-std-features=compiler-builtins-mem
endif
ifeq ($(MODE), release)

View File

@ -1,6 +1,6 @@
#[allow(dead_code)]
fn init_ram_disk() -> &'static mut [u8] {
if cfg!(feature = "link_user_img") {
if cfg!(feature = "link-user-img") {
extern "C" {
fn _user_img_start();
fn _user_img_end();
@ -36,7 +36,7 @@ cfg_if! {
use linux_object::fs::rcore_fs_wrapper::{Block, BlockCache, MemBuf};
use rcore_fs::dev::Device;
let device: Arc<dyn Device> = if cfg!(feature = "init_ram_disk") {
let device: Arc<dyn Device> = if cfg!(feature = "init-ram-disk") {
Arc::new(MemBuf::new(init_ram_disk()))
} else {
let block = kernel_hal::drivers::all_block().first_unwrap();
@ -66,7 +66,7 @@ cfg_if! {
// Hard link rootfs img
#[cfg(not(feature = "libos"))]
#[cfg(feature = "link_user_img")]
#[cfg(feature = "link-user-img")]
global_asm!(concat!(
r#"
.section .data.img

View File

@ -52,10 +52,10 @@ enum ColorCode {
/// Add escape sequence to print with color in Linux console
macro_rules! with_color {
($color_code:expr, $($arg:tt)*) => {{
#[cfg(feature = "color_log")]
#[cfg(feature = "colorless-log")]
{ let _ = $color_code; format_args!($($arg)*) }
#[cfg(not(feature = "colorless-log"))]
{ format_args!("\u{1B}[{}m{}\u{1B}[m", $color_code as u8, format_args!($($arg)*)) }
#[cfg(not(feature = "color_log"))]
{ format_args!($($arg)*) }
}};
}

View File

@ -14,6 +14,9 @@ type FrameAlloc = bitmap_allocator::BitAlloc16M; // max 64G
#[cfg(target_arch = "riscv64")]
type FrameAlloc = bitmap_allocator::BitAlloc1M; // max 4G
#[cfg(target_arch = "aarch64")]
type FrameAlloc = bitmap_allocator::BitAlloc1M; // max 4G
const PAGE_SIZE: usize = 4096;
/// Global physical frame allocator

View File

@ -1,5 +1,5 @@
cfg_if! {
if #[cfg(not(target_os = "none"))] {
if #[cfg(feature = "libos")] {
#[path = "libos/entry.rs"]
mod entry;
#[path = "libos/consts.rs"]

View File

@ -1,11 +1,11 @@
// RISCV
cfg_if! {
if #[cfg(feature = "board_qemu")] {
if #[cfg(feature = "board-qemu")] {
pub const KERNEL_OFFSET: usize = 0xFFFF_FFFF_8000_0000;
pub const PHYS_MEMORY_BASE: usize = 0x8000_0000;
pub const PHYS_MEMORY_END: usize = 0x8800_0000; // TODO: get memory end from device tree
} else if #[cfg(feature = "board_d1")] {
} else if #[cfg(feature = "board-d1")] {
pub const KERNEL_OFFSET: usize = 0xFFFF_FFFF_C000_0000;
pub const PHYS_MEMORY_BASE: usize = 0x4000_0000;
pub const PHYS_MEMORY_END: usize = 0x6000_0000; // 512M

View File

@ -1,6 +1,6 @@
#[cfg(feature = "board_qemu")]
#[cfg(feature = "board-qemu")]
global_asm!(include_str!("boot/boot_qemu.asm"));
#[cfg(feature = "board_d1")]
#[cfg(feature = "board-d1")]
global_asm!(include_str!("boot/boot_d1.asm"));
global_asm!(include_str!("boot/entry64.asm"));

View File

@ -13,11 +13,11 @@ cfg-if = "1.0"
xmas-elf = "0.7"
zircon-object = { path = "../zircon-object", features = ["elf"] }
zircon-syscall = { path = "../zircon-syscall" }
kernel-hal = { path = "../kernel-hal" }
kernel-hal = { path = "../kernel-hal", default-features = false }
[features]
default = ["libos"]
libos = ["kernel-hal/libos", "zircon-object/aspace-separate", "zircon-syscall/std"]
libos = ["kernel-hal/libos", "zircon-object/aspace-separate", "zircon-syscall/libos"]
[dev-dependencies]
env_logger = "0.9"

View File

@ -18,7 +18,7 @@ spin = "0.9"
log = "0.4"
hashbrown = "0.9"
downcast-rs = { version = "1.2", default-features = false }
kernel-hal = { path = "../kernel-hal" }
kernel-hal = { path = "../kernel-hal", default-features = false }
numeric-enum-macro = "0.2"
futures = { version = "0.3", default-features = false, features = ["alloc", "async-await"] }
xmas-elf = { version = "0.7", optional = true }

View File

@ -11,8 +11,7 @@ description = "Zircon syscalls implementation"
# hypervisor = ["zircon-object/hypervisor"]
default = []
deny-page-fault = []
std = ["deny-page-fault"]
libos = ["deny-page-fault", "kernel-hal/libos"]
[dependencies]
log = "0.4"
@ -20,6 +19,6 @@ spin = "0.9"
bitflags = "1.3"
numeric-enum-macro = "0.2"
zircon-object = { path = "../zircon-object" }
kernel-hal = { path = "../kernel-hal" }
kernel-hal = { path = "../kernel-hal", default-features = false }
futures = { version = "0.3", default-features = false, features = ["alloc", "async-await"] }
cfg-if = "1.0"