From 0d0cad58be9668f4f1f68b4571257db2d3b264c8 Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Wed, 27 Dec 2023 00:11:00 +0800 Subject: [PATCH 01/17] feat: set specific rust-toolchain version, fix some clippy warning, update qemu version in ci --- .github/workflows/test.yml | 4 ++-- api/arceos_api/src/lib.rs | 1 - api/arceos_posix_api/src/imp/pthread/mutex.rs | 4 ++-- api/arceos_posix_api/src/lib.rs | 1 - crates/driver_net/src/ixgbe.rs | 8 +++++--- modules/axnet/src/lib.rs | 1 - rust-toolchain.toml | 2 +- ulib/axstd/src/lib.rs | 1 - 8 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 73e36bc02e..b88d57adf2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,8 +3,8 @@ name: Test CI on: [push, pull_request] env: - qemu-version: 7.1.0 - rust-toolchain: nightly + qemu-version: 8.2.0 + rust-toolchain: nightly-2023-12-25 jobs: unit-test: diff --git a/api/arceos_api/src/lib.rs b/api/arceos_api/src/lib.rs index 69fec6eaf4..eacf0f5f2d 100644 --- a/api/arceos_api/src/lib.rs +++ b/api/arceos_api/src/lib.rs @@ -3,7 +3,6 @@ //! [ArceOS]: https://github.com/rcore-os/arceos #![no_std] -#![feature(ip_in_core)] #![feature(doc_auto_cfg)] #![feature(doc_cfg)] #![allow(unused_imports)] diff --git a/api/arceos_posix_api/src/imp/pthread/mutex.rs b/api/arceos_posix_api/src/imp/pthread/mutex.rs index f22a8f55d4..528779a091 100644 --- a/api/arceos_posix_api/src/imp/pthread/mutex.rs +++ b/api/arceos_posix_api/src/imp/pthread/mutex.rs @@ -7,8 +7,8 @@ use core::ffi::c_int; use core::mem::{size_of, ManuallyDrop}; static_assertions::const_assert_eq!( - size_of::(), - size_of::() + size_of::(), + size_of::() ); #[repr(C)] diff --git a/api/arceos_posix_api/src/lib.rs b/api/arceos_posix_api/src/lib.rs index 75eb9bd7ce..668d144aaa 100644 --- a/api/arceos_posix_api/src/lib.rs +++ b/api/arceos_posix_api/src/lib.rs @@ -3,7 +3,6 @@ //! [ArceOS]: https://github.com/rcore-os/arceos #![cfg_attr(all(not(test), not(doc)), no_std)] -#![feature(ip_in_core)] #![feature(doc_cfg)] #![feature(doc_auto_cfg)] #![allow(clippy::missing_safety_doc)] diff --git a/crates/driver_net/src/ixgbe.rs b/crates/driver_net/src/ixgbe.rs index b6a2c1b3a0..40f994dd25 100644 --- a/crates/driver_net/src/ixgbe.rs +++ b/crates/driver_net/src/ixgbe.rs @@ -100,11 +100,13 @@ impl NetDriverOps for IxgbeNic { if recv_nums == 0 { // No packet is received, it is impossible things. diff --git a/modules/axnet/src/lib.rs b/modules/axnet/src/lib.rs index 301fd6091f..f716a027fc 100644 --- a/modules/axnet/src/lib.rs +++ b/modules/axnet/src/lib.rs @@ -18,7 +18,6 @@ //! [smoltcp]: https://github.com/smoltcp-rs/smoltcp #![no_std] -#![feature(ip_in_core)] #![feature(new_uninit)] #[macro_use] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 9cda0c1fe8..d9dc95ed69 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] profile = "minimal" -channel = "nightly" +channel = "nightly-2023-12-25" components = ["rust-src", "llvm-tools-preview", "rustfmt", "clippy"] targets = ["x86_64-unknown-none", "riscv64gc-unknown-none-elf", "aarch64-unknown-none-softfloat"] diff --git a/ulib/axstd/src/lib.rs b/ulib/axstd/src/lib.rs index ced516cd75..d256cd527f 100644 --- a/ulib/axstd/src/lib.rs +++ b/ulib/axstd/src/lib.rs @@ -49,7 +49,6 @@ #![cfg_attr(all(not(test), not(doc)), no_std)] #![feature(doc_cfg)] #![feature(doc_auto_cfg)] -#![feature(ip_in_core)] #[cfg(feature = "alloc")] extern crate alloc; From 82bd9d3b8455b5ac987051a04b212fbc4a5fb337 Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Wed, 27 Dec 2023 23:46:30 +0800 Subject: [PATCH 02/17] feat: add build-latest-nightly workflow --- .github/workflows/build-latest-nightly.yml | 176 +++++++++++++++++++++ .github/workflows/build.yml | 2 +- .github/workflows/docs.yml | 2 +- 3 files changed, 178 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build-latest-nightly.yml diff --git a/.github/workflows/build-latest-nightly.yml b/.github/workflows/build-latest-nightly.yml new file mode 100644 index 0000000000..70f3747579 --- /dev/null +++ b/.github/workflows/build-latest-nightly.yml @@ -0,0 +1,176 @@ +name: Build CI + +on: [push, pull_request] + +env: + rust-toolchain: nightly + +jobs: + clippy: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ env.rust-toolchain }} + components: rust-src, clippy, rustfmt + - name: Clippy for the default target + run: make clippy + - name: Clippy for x86_64 + run: make clippy ARCH=x86_64 + - name: Clippy for riscv64 + run: make clippy ARCH=riscv64 + - name: Clippy for aarch64 + run: make clippy ARCH=aarch64 + - name: Check code format + run: cargo fmt --all -- --check + + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + arch: [x86_64, riscv64, aarch64] + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ env.rust-toolchain }} + components: rust-src + - uses: actions-rs/install@v0.1 + with: + crate: cargo-binutils + version: latest + use-tool-cache: true + - name: Build helloworld + run: make ARCH=${{ matrix.arch }} A=apps/helloworld + - name: Build memtest + run: make ARCH=${{ matrix.arch }} A=apps/memtest + - name: Build exception + run: make ARCH=${{ matrix.arch }} A=apps/exception + - name: Build display + run: make ARCH=${{ matrix.arch }} A=apps/display + - name: Build task/yield + run: make ARCH=${{ matrix.arch }} A=apps/task/yield + - name: Build task/parallel + run: make ARCH=${{ matrix.arch }} A=apps/task/parallel + - name: Build task/sleep + run: make ARCH=${{ matrix.arch }} A=apps/task/sleep + - name: Build task/priority + run: make ARCH=${{ matrix.arch }} A=apps/task/priority + - name: Build task/tls + run: make ARCH=${{ matrix.arch }} A=apps/task/tls + - name: Build fs/shell + run: make ARCH=${{ matrix.arch }} A=apps/fs/shell + - name: Build net/echoserver + run: make ARCH=${{ matrix.arch }} A=apps/net/echoserver + - name: Build net/httpclient + run: make ARCH=${{ matrix.arch }} A=apps/net/httpclient + - name: Build net/httpserver + run: make ARCH=${{ matrix.arch }} A=apps/net/httpserver + - name: Build net/udpserver + run: make ARCH=${{ matrix.arch }} A=apps/net/udpserver + + - uses: ./.github/workflows/actions/setup-musl + with: + arch: ${{ matrix.arch }} + - name: Build c/helloworld + run: make ARCH=${{ matrix.arch }} A=apps/c/helloworld + - name: Build c/memtest + run: make ARCH=${{ matrix.arch }} A=apps/c/memtest + - name: Build c/sqlite3 + run: make ARCH=${{ matrix.arch }} A=apps/c/sqlite3 + - name: Build c/httpclient + run: make ARCH=${{ matrix.arch }} A=apps/c/httpclient + - name: Build c/httpserver + run: make ARCH=${{ matrix.arch }} A=apps/c/httpserver + - name: Build c/udpserver + run: make ARCH=${{ matrix.arch }} A=apps/c/udpserver + - name: Build c/iperf + run: make ARCH=${{ matrix.arch }} A=apps/c/iperf + - name: Build c/redis + run: make ARCH=${{ matrix.arch }} A=apps/c/redis SMP=4 + + build-apps-for-other-platforms: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ env.rust-toolchain }} + components: rust-src + - uses: actions-rs/install@v0.1 + with: + crate: cargo-binutils + version: latest + use-tool-cache: true + - uses: ./.github/workflows/actions/setup-musl + with: + arch: x86_64 + + - name: Build helloworld for x86_64-pc-oslab + run: make PLATFORM=x86_64-pc-oslab A=apps/helloworld + - name: Build net/httpserver for x86_64-pc-oslab + run: make PLATFORM=x86_64-pc-oslab A=apps/net/httpserver FEATURES=driver-ixgbe + - name: Build c/iperf for x86_64-pc-oslab + run: make PLATFORM=x86_64-pc-oslab A=apps/c/iperf FEATURES=driver-ixgbe,driver-ramdisk + - name: Build c/redis for x86_64-pc-oslab + run: make PLATFORM=x86_64-pc-oslab A=apps/c/redis FEATURES=driver-ixgbe,driver-ramdisk SMP=4 + + - name: Build helloworld for aarch64-raspi4 + run: make PLATFORM=aarch64-raspi4 A=apps/helloworld + - name: Build fs/shell for aarch64-raspi4 + run: make PLATFORM=aarch64-raspi4 A=apps/fs/shell FEATURES=driver-bcm2835-sdhci + + - name: Build helloworld for aarch64-bsta1000b + run: make PLATFORM=aarch64-bsta1000b A=apps/helloworld + + build-apps-for-std: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + arch: [x86_64] + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ env.rust-toolchain }} + - name: Build helloworld + run: cargo build -p arceos-helloworld + - name: Build memtest + run: cargo build -p arceos-memtest + - name: Build exception + run: cargo build -p arceos-exception + - name: Build task/yield + run: cargo build -p arceos-yield + - name: Build task/parallel + run: cargo build -p arceos-parallel + - name: Build task/sleep + run: cargo build -p arceos-sleep + - name: Build task/priority + run: cargo build -p arceos-priority + - name: Build task/tls + run: cargo build -p arceos-tls + - name: Build fs/shell + run: cargo build -p arceos-shell + - name: Build net/echoserver + run: cargo build -p arceos-echoserver + - name: Build net/httpclient + run: cargo build -p arceos-httpclient + - name: Build net/httpserver + run: cargo build -p arceos-httpserver + - name: Build net/udpserver + run: cargo build -p arceos-udpserver diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 70f3747579..de20af95a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build CI on: [push, pull_request] env: - rust-toolchain: nightly + rust-toolchain: nightly-2023-12-25 jobs: clippy: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index fdd060d056..86dd332a4d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,7 +3,7 @@ name: Build & Deploy docs on: [push, pull_request] env: - rust-toolchain: nightly + rust-toolchain: nightly-2023-12-25 jobs: doc: From 715d13b7a897cb99235c3bd0f768bde22880b13f Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Wed, 27 Dec 2023 23:58:35 +0800 Subject: [PATCH 03/17] fix: rename build-latest-nightly action --- .github/workflows/build-latest-nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-latest-nightly.yml b/.github/workflows/build-latest-nightly.yml index 70f3747579..2903fa6e1f 100644 --- a/.github/workflows/build-latest-nightly.yml +++ b/.github/workflows/build-latest-nightly.yml @@ -1,4 +1,4 @@ -name: Build CI +name: Build-Latest-Rust-Nightly CI on: [push, pull_request] From 3b7a00156ecfcc378e918fc8361d3b9a07ef7fe6 Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Fri, 29 Dec 2023 15:37:03 +0800 Subject: [PATCH 04/17] feat: use matrix to set rust-toolchain --- .github/workflows/build-latest-nightly.yml | 176 --------------------- .github/workflows/build.yml | 16 +- 2 files changed, 9 insertions(+), 183 deletions(-) delete mode 100644 .github/workflows/build-latest-nightly.yml diff --git a/.github/workflows/build-latest-nightly.yml b/.github/workflows/build-latest-nightly.yml deleted file mode 100644 index 2903fa6e1f..0000000000 --- a/.github/workflows/build-latest-nightly.yml +++ /dev/null @@ -1,176 +0,0 @@ -name: Build-Latest-Rust-Nightly CI - -on: [push, pull_request] - -env: - rust-toolchain: nightly - -jobs: - clippy: - runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ env.rust-toolchain }} - components: rust-src, clippy, rustfmt - - name: Clippy for the default target - run: make clippy - - name: Clippy for x86_64 - run: make clippy ARCH=x86_64 - - name: Clippy for riscv64 - run: make clippy ARCH=riscv64 - - name: Clippy for aarch64 - run: make clippy ARCH=aarch64 - - name: Check code format - run: cargo fmt --all -- --check - - build: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - arch: [x86_64, riscv64, aarch64] - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ env.rust-toolchain }} - components: rust-src - - uses: actions-rs/install@v0.1 - with: - crate: cargo-binutils - version: latest - use-tool-cache: true - - name: Build helloworld - run: make ARCH=${{ matrix.arch }} A=apps/helloworld - - name: Build memtest - run: make ARCH=${{ matrix.arch }} A=apps/memtest - - name: Build exception - run: make ARCH=${{ matrix.arch }} A=apps/exception - - name: Build display - run: make ARCH=${{ matrix.arch }} A=apps/display - - name: Build task/yield - run: make ARCH=${{ matrix.arch }} A=apps/task/yield - - name: Build task/parallel - run: make ARCH=${{ matrix.arch }} A=apps/task/parallel - - name: Build task/sleep - run: make ARCH=${{ matrix.arch }} A=apps/task/sleep - - name: Build task/priority - run: make ARCH=${{ matrix.arch }} A=apps/task/priority - - name: Build task/tls - run: make ARCH=${{ matrix.arch }} A=apps/task/tls - - name: Build fs/shell - run: make ARCH=${{ matrix.arch }} A=apps/fs/shell - - name: Build net/echoserver - run: make ARCH=${{ matrix.arch }} A=apps/net/echoserver - - name: Build net/httpclient - run: make ARCH=${{ matrix.arch }} A=apps/net/httpclient - - name: Build net/httpserver - run: make ARCH=${{ matrix.arch }} A=apps/net/httpserver - - name: Build net/udpserver - run: make ARCH=${{ matrix.arch }} A=apps/net/udpserver - - - uses: ./.github/workflows/actions/setup-musl - with: - arch: ${{ matrix.arch }} - - name: Build c/helloworld - run: make ARCH=${{ matrix.arch }} A=apps/c/helloworld - - name: Build c/memtest - run: make ARCH=${{ matrix.arch }} A=apps/c/memtest - - name: Build c/sqlite3 - run: make ARCH=${{ matrix.arch }} A=apps/c/sqlite3 - - name: Build c/httpclient - run: make ARCH=${{ matrix.arch }} A=apps/c/httpclient - - name: Build c/httpserver - run: make ARCH=${{ matrix.arch }} A=apps/c/httpserver - - name: Build c/udpserver - run: make ARCH=${{ matrix.arch }} A=apps/c/udpserver - - name: Build c/iperf - run: make ARCH=${{ matrix.arch }} A=apps/c/iperf - - name: Build c/redis - run: make ARCH=${{ matrix.arch }} A=apps/c/redis SMP=4 - - build-apps-for-other-platforms: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ env.rust-toolchain }} - components: rust-src - - uses: actions-rs/install@v0.1 - with: - crate: cargo-binutils - version: latest - use-tool-cache: true - - uses: ./.github/workflows/actions/setup-musl - with: - arch: x86_64 - - - name: Build helloworld for x86_64-pc-oslab - run: make PLATFORM=x86_64-pc-oslab A=apps/helloworld - - name: Build net/httpserver for x86_64-pc-oslab - run: make PLATFORM=x86_64-pc-oslab A=apps/net/httpserver FEATURES=driver-ixgbe - - name: Build c/iperf for x86_64-pc-oslab - run: make PLATFORM=x86_64-pc-oslab A=apps/c/iperf FEATURES=driver-ixgbe,driver-ramdisk - - name: Build c/redis for x86_64-pc-oslab - run: make PLATFORM=x86_64-pc-oslab A=apps/c/redis FEATURES=driver-ixgbe,driver-ramdisk SMP=4 - - - name: Build helloworld for aarch64-raspi4 - run: make PLATFORM=aarch64-raspi4 A=apps/helloworld - - name: Build fs/shell for aarch64-raspi4 - run: make PLATFORM=aarch64-raspi4 A=apps/fs/shell FEATURES=driver-bcm2835-sdhci - - - name: Build helloworld for aarch64-bsta1000b - run: make PLATFORM=aarch64-bsta1000b A=apps/helloworld - - build-apps-for-std: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - arch: [x86_64] - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ env.rust-toolchain }} - - name: Build helloworld - run: cargo build -p arceos-helloworld - - name: Build memtest - run: cargo build -p arceos-memtest - - name: Build exception - run: cargo build -p arceos-exception - - name: Build task/yield - run: cargo build -p arceos-yield - - name: Build task/parallel - run: cargo build -p arceos-parallel - - name: Build task/sleep - run: cargo build -p arceos-sleep - - name: Build task/priority - run: cargo build -p arceos-priority - - name: Build task/tls - run: cargo build -p arceos-tls - - name: Build fs/shell - run: cargo build -p arceos-shell - - name: Build net/echoserver - run: cargo build -p arceos-echoserver - - name: Build net/httpclient - run: cargo build -p arceos-httpclient - - name: Build net/httpserver - run: cargo build -p arceos-httpserver - - name: Build net/udpserver - run: cargo build -p arceos-udpserver diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index de20af95a3..24ca641b55 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,20 +2,19 @@ name: Build CI on: [push, pull_request] -env: - rust-toolchain: nightly-2023-12-25 - jobs: clippy: runs-on: ubuntu-latest strategy: fail-fast: false + matrix: + rust-toolchain: [nightly, nightly-2023-12-25] steps: - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: ${{ env.rust-toolchain }} + toolchain: ${{ matrix.rust-toolchain }} components: rust-src, clippy, rustfmt - name: Clippy for the default target run: make clippy @@ -35,12 +34,13 @@ jobs: matrix: os: [ubuntu-latest] arch: [x86_64, riscv64, aarch64] + rust-toolchain: [nightly, nightly-2023-12-25] steps: - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: ${{ env.rust-toolchain }} + toolchain: ${{ matrix.rust-toolchain }} components: rust-src - uses: actions-rs/install@v0.1 with: @@ -102,12 +102,13 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] + rust-toolchain: [nightly, nightly-2023-12-25] steps: - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: ${{ env.rust-toolchain }} + toolchain: ${{ matrix.rust-toolchain }} components: rust-src - uses: actions-rs/install@v0.1 with: @@ -142,12 +143,13 @@ jobs: matrix: os: [ubuntu-latest] arch: [x86_64] + rust-toolchain: [nightly, nightly-2023-12-25] steps: - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: ${{ env.rust-toolchain }} + toolchain: ${{ matrix.rust-toolchain }} - name: Build helloworld run: cargo build -p arceos-helloworld - name: Build memtest From d35b590cc8ab2c7b115049e582422b7eb2e69529 Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Tue, 2 Jan 2024 01:23:45 +0800 Subject: [PATCH 05/17] WIP: try to modify build_c.mk to fix c app compile error --- scripts/make/build_c.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/make/build_c.mk b/scripts/make/build_c.mk index cb92d16737..132e26d917 100644 --- a/scripts/make/build_c.mk +++ b/scripts/make/build_c.mk @@ -70,7 +70,7 @@ $(APP)/%.o: $(APP)/%.c $(ulib_hdr) $(OUT_ELF): $(c_lib) $(rust_lib) $(libgcc) $(app-objs) @printf " $(CYAN_C)Linking$(END_C) $(OUT_ELF)\n" - $(call run_cmd,$(LD),$(LDFLAGS) $^ -o $@) + $(call run_cmd,$(LD),$(LDFLAGS) $(c_lib) $(libgcc) $(app-objs) -o $@) $(APP)/axbuild.mk: ; From ef13f10e880d46e66d3c58263e145f91a69ab098 Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Tue, 2 Jan 2024 01:47:45 +0800 Subject: [PATCH 06/17] fix: add enable-slirp in setup-qemu, problem exists in build_c.mk --- .github/workflows/actions/setup-qemu/action.yml | 2 +- scripts/make/build_c.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/actions/setup-qemu/action.yml b/.github/workflows/actions/setup-qemu/action.yml index 8ac690e6de..29ee15f62e 100644 --- a/.github/workflows/actions/setup-qemu/action.yml +++ b/.github/workflows/actions/setup-qemu/action.yml @@ -25,7 +25,7 @@ runs: sudo apt-get update && sudo apt-get install -y ninja-build wget https://download.qemu.org/$QEMU_PATH.tar.xz && tar -xJf $QEMU_PATH.tar.xz cd $QEMU_PATH \ - && ./configure --prefix=$PREFIX --target-list=x86_64-softmmu,riscv64-softmmu,aarch64-softmmu \ + && ./configure --prefix=$PREFIX --target-list=x86_64-softmmu,riscv64-softmmu,aarch64-softmmu --enable-slirp \ && make -j > /dev/null 2>&1 \ && make install - uses: actions/cache/save@v3 diff --git a/scripts/make/build_c.mk b/scripts/make/build_c.mk index 132e26d917..cb92d16737 100644 --- a/scripts/make/build_c.mk +++ b/scripts/make/build_c.mk @@ -70,7 +70,7 @@ $(APP)/%.o: $(APP)/%.c $(ulib_hdr) $(OUT_ELF): $(c_lib) $(rust_lib) $(libgcc) $(app-objs) @printf " $(CYAN_C)Linking$(END_C) $(OUT_ELF)\n" - $(call run_cmd,$(LD),$(LDFLAGS) $(c_lib) $(libgcc) $(app-objs) -o $@) + $(call run_cmd,$(LD),$(LDFLAGS) $^ -o $@) $(APP)/axbuild.mk: ; From 2bde75372cd19e4b314f95011d34d29b3324cadb Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Thu, 4 Jan 2024 23:37:37 +0800 Subject: [PATCH 07/17] :feat: update cache key in setup-qemu action --- .github/workflows/actions/setup-qemu/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/actions/setup-qemu/action.yml b/.github/workflows/actions/setup-qemu/action.yml index 29ee15f62e..ef2d82fb08 100644 --- a/.github/workflows/actions/setup-qemu/action.yml +++ b/.github/workflows/actions/setup-qemu/action.yml @@ -14,7 +14,7 @@ runs: uses: actions/cache/restore@v3 with: path: qemu_build - key: qemu-${{ inputs.qemu-version }} + key: qemu-${{ inputs.qemu-version }}-slirp - name: Download and build QEMU if: steps.cache-qemu.outputs.cache-hit != 'true' env: @@ -32,7 +32,7 @@ runs: if: steps.cache-qemu.outputs.cache-hit != 'true' with: path: qemu_build - key: qemu-${{ inputs.qemu-version }} + key: qemu-${{ inputs.qemu-version }}-slirp - name: Install QEMU shell: bash From 8f313047ff7fda85c79351e3ff408f0bd122fd8b Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Wed, 10 Jan 2024 15:32:17 +0800 Subject: [PATCH 08/17] fix: qemu install bug by add libslirp-dev --- .github/workflows/actions/setup-qemu/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions/setup-qemu/action.yml b/.github/workflows/actions/setup-qemu/action.yml index ef2d82fb08..d78c8a0d0d 100644 --- a/.github/workflows/actions/setup-qemu/action.yml +++ b/.github/workflows/actions/setup-qemu/action.yml @@ -22,7 +22,7 @@ runs: PREFIX: ${{ github.workspace }}/qemu_build shell: bash run: | - sudo apt-get update && sudo apt-get install -y ninja-build + sudo apt-get update && sudo apt-get install -y ninja-build libslirp-dev wget https://download.qemu.org/$QEMU_PATH.tar.xz && tar -xJf $QEMU_PATH.tar.xz cd $QEMU_PATH \ && ./configure --prefix=$PREFIX --target-list=x86_64-softmmu,riscv64-softmmu,aarch64-softmmu --enable-slirp \ From 99af04575a807414fb62c43049780ba9dcfd4dee Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Wed, 10 Jan 2024 15:35:47 +0800 Subject: [PATCH 09/17] fix: update qemu_build cache key --- .github/workflows/actions/setup-qemu/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions/setup-qemu/action.yml b/.github/workflows/actions/setup-qemu/action.yml index d78c8a0d0d..b26eebd2f3 100644 --- a/.github/workflows/actions/setup-qemu/action.yml +++ b/.github/workflows/actions/setup-qemu/action.yml @@ -14,7 +14,7 @@ runs: uses: actions/cache/restore@v3 with: path: qemu_build - key: qemu-${{ inputs.qemu-version }}-slirp + key: qemu-${{ inputs.qemu-version }}-slirp-1 - name: Download and build QEMU if: steps.cache-qemu.outputs.cache-hit != 'true' env: From bdeda6c50ade16f6675ecc2429c0350fa7a3a9b6 Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Wed, 10 Jan 2024 15:36:24 +0800 Subject: [PATCH 10/17] fix: update qemu_build cache key in qemu run --- .github/workflows/actions/setup-qemu/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions/setup-qemu/action.yml b/.github/workflows/actions/setup-qemu/action.yml index b26eebd2f3..0f8bc4d1ca 100644 --- a/.github/workflows/actions/setup-qemu/action.yml +++ b/.github/workflows/actions/setup-qemu/action.yml @@ -32,7 +32,7 @@ runs: if: steps.cache-qemu.outputs.cache-hit != 'true' with: path: qemu_build - key: qemu-${{ inputs.qemu-version }}-slirp + key: qemu-${{ inputs.qemu-version }}-slirp-1 - name: Install QEMU shell: bash From 498f4ad3eda0a595cc28f87520bbe294801a7c11 Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Thu, 11 Jan 2024 17:20:29 +0800 Subject: [PATCH 11/17] fix: use -a in app_test.sh line37 grep --- scripts/test/app_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test/app_test.sh b/scripts/test/app_test.sh index d7a1d28ded..7a2d4a411b 100755 --- a/scripts/test/app_test.sh +++ b/scripts/test/app_test.sh @@ -34,7 +34,7 @@ function compare() { fi IFS='' while read -r line; do - local matched=$(grep -m1 "$line" < "$actual") + local matched=$(grep -m1 -a "$line" < "$actual") if [ -z "$matched" ]; then MSG="pattern \"${BLOD_C}$line${END_C}\" not matched!" unset IFS From 87e2ebeeca2ac8ad3cd8bc6b90369afa0e4df890 Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Thu, 25 Jan 2024 19:57:43 +0800 Subject: [PATCH 12/17] feat: change memory layout of pthread_mutex_t in build.rs --- api/arceos_posix_api/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/arceos_posix_api/build.rs b/api/arceos_posix_api/build.rs index 3c9aa161b8..7635eb8d7f 100644 --- a/api/arceos_posix_api/build.rs +++ b/api/arceos_posix_api/build.rs @@ -5,7 +5,7 @@ fn main() { // TODO: generate size and initial content automatically. let (mutex_size, mutex_init) = if cfg!(feature = "multitask") { if cfg!(feature = "smp") { - (6, "{0, 8, 0, 0, 0, 0}") // core::mem::transmute::<_, [usize; 6]>(axsync::Mutex::new(())) + (6, "{0, 0, 8, 0, 0, 0}") // core::mem::transmute::<_, [usize; 6]>(axsync::Mutex::new(())) } else { (5, "{8, 0, 0, 0, 0}") // core::mem::transmute::<_, [usize; 5]>(axsync::Mutex::new(())) } From 152f6f0c06a90759f5cc716161f9f2240b7f4f96 Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Thu, 25 Jan 2024 20:05:12 +0800 Subject: [PATCH 13/17] feat: change memory layout of pthread_mutex_t in build.rs under no smp --- api/arceos_posix_api/Cargo.toml | 1 + api/arceos_posix_api/build.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/api/arceos_posix_api/Cargo.toml b/api/arceos_posix_api/Cargo.toml index 03081419b9..1f33391731 100644 --- a/api/arceos_posix_api/Cargo.toml +++ b/api/arceos_posix_api/Cargo.toml @@ -50,3 +50,4 @@ flatten_objects = { path = "../../crates/flatten_objects" } [build-dependencies] bindgen ={ version = "0.66" } +axsync = { path = "../../modules/axsync" } diff --git a/api/arceos_posix_api/build.rs b/api/arceos_posix_api/build.rs index 7635eb8d7f..cb8c598948 100644 --- a/api/arceos_posix_api/build.rs +++ b/api/arceos_posix_api/build.rs @@ -7,7 +7,7 @@ fn main() { if cfg!(feature = "smp") { (6, "{0, 0, 8, 0, 0, 0}") // core::mem::transmute::<_, [usize; 6]>(axsync::Mutex::new(())) } else { - (5, "{8, 0, 0, 0, 0}") // core::mem::transmute::<_, [usize; 5]>(axsync::Mutex::new(())) + (5, "{0, 8, 0, 0, 0}") // core::mem::transmute::<_, [usize; 5]>(axsync::Mutex::new(())) } } else { (1, "{0}") From d0ff31112c3276f2e2339a818607d6796f0a866c Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Fri, 26 Jan 2024 15:41:41 +0800 Subject: [PATCH 14/17] feat: add #[cfg(feature = preempt)] in percpu_macros --- crates/percpu_macros/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/percpu_macros/src/lib.rs b/crates/percpu_macros/src/lib.rs index 6daeeaa906..c66340fff8 100644 --- a/crates/percpu_macros/src/lib.rs +++ b/crates/percpu_macros/src/lib.rs @@ -82,6 +82,7 @@ pub fn def_percpu(attr: TokenStream, item: TokenStream) -> TokenStream { /// Returns the value of the per-CPU data on the current CPU. Preemption will /// be disabled during the call. pub fn read_current(&self) -> #ty { + #[cfg(feature = "preempt")] #no_preempt_guard unsafe { self.read_current_raw() } } @@ -89,6 +90,7 @@ pub fn def_percpu(attr: TokenStream, item: TokenStream) -> TokenStream { /// Set the value of the per-CPU data on the current CPU. Preemption will /// be disabled during the call. pub fn write_current(&self, val: #ty) { + #[cfg(feature = "preempt")] #no_preempt_guard unsafe { self.write_current_raw(val) } } @@ -155,6 +157,7 @@ pub fn def_percpu(attr: TokenStream, item: TokenStream) -> TokenStream { where F: FnOnce(&mut #ty) -> T, { + #[cfg(feature = "preempt")] #no_preempt_guard f(unsafe { self.current_ref_mut_raw() }) } From 7967f32ce879497a1f0be47c0bf648c8713efaf5 Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Fri, 26 Jan 2024 15:51:54 +0800 Subject: [PATCH 15/17] fix: delete #[cfg(feature = preempt)] in percpu_macros --- crates/percpu_macros/src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/crates/percpu_macros/src/lib.rs b/crates/percpu_macros/src/lib.rs index c66340fff8..6daeeaa906 100644 --- a/crates/percpu_macros/src/lib.rs +++ b/crates/percpu_macros/src/lib.rs @@ -82,7 +82,6 @@ pub fn def_percpu(attr: TokenStream, item: TokenStream) -> TokenStream { /// Returns the value of the per-CPU data on the current CPU. Preemption will /// be disabled during the call. pub fn read_current(&self) -> #ty { - #[cfg(feature = "preempt")] #no_preempt_guard unsafe { self.read_current_raw() } } @@ -90,7 +89,6 @@ pub fn def_percpu(attr: TokenStream, item: TokenStream) -> TokenStream { /// Set the value of the per-CPU data on the current CPU. Preemption will /// be disabled during the call. pub fn write_current(&self, val: #ty) { - #[cfg(feature = "preempt")] #no_preempt_guard unsafe { self.write_current_raw(val) } } @@ -157,7 +155,6 @@ pub fn def_percpu(attr: TokenStream, item: TokenStream) -> TokenStream { where F: FnOnce(&mut #ty) -> T, { - #[cfg(feature = "preempt")] #no_preempt_guard f(unsafe { self.current_ref_mut_raw() }) } From 77d0cfedc30bca948416c69002d868e0adc40fd4 Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Fri, 26 Jan 2024 17:23:29 +0800 Subject: [PATCH 16/17] fix: delete async from build-dependencies --- api/arceos_posix_api/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/api/arceos_posix_api/Cargo.toml b/api/arceos_posix_api/Cargo.toml index 1f33391731..03081419b9 100644 --- a/api/arceos_posix_api/Cargo.toml +++ b/api/arceos_posix_api/Cargo.toml @@ -50,4 +50,3 @@ flatten_objects = { path = "../../crates/flatten_objects" } [build-dependencies] bindgen ={ version = "0.66" } -axsync = { path = "../../modules/axsync" } From e6e6283d5b996af72e31952d701c297845e94370 Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Fri, 26 Jan 2024 20:12:42 +0800 Subject: [PATCH 17/17] feat: update toolchain version, fix error in errno --- .github/workflows/build.yml | 8 ++++---- .github/workflows/docs.yml | 2 +- .github/workflows/test.yml | 2 +- rust-toolchain.toml | 2 +- ulib/axlibc/src/errno.rs | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 24ca641b55..37a71710e2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - rust-toolchain: [nightly, nightly-2023-12-25] + rust-toolchain: [nightly, nightly-2024-01-19] steps: - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 @@ -34,7 +34,7 @@ jobs: matrix: os: [ubuntu-latest] arch: [x86_64, riscv64, aarch64] - rust-toolchain: [nightly, nightly-2023-12-25] + rust-toolchain: [nightly, nightly-2024-01-19] steps: - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 @@ -102,7 +102,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - rust-toolchain: [nightly, nightly-2023-12-25] + rust-toolchain: [nightly, nightly-2024-01-19] steps: - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 @@ -143,7 +143,7 @@ jobs: matrix: os: [ubuntu-latest] arch: [x86_64] - rust-toolchain: [nightly, nightly-2023-12-25] + rust-toolchain: [nightly, nightly-2024-01-19] steps: - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 86dd332a4d..780d475d10 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,7 +3,7 @@ name: Build & Deploy docs on: [push, pull_request] env: - rust-toolchain: nightly-2023-12-25 + rust-toolchain: nightly-2024-01-19 jobs: doc: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b88d57adf2..60f34e8d19 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,7 @@ on: [push, pull_request] env: qemu-version: 8.2.0 - rust-toolchain: nightly-2023-12-25 + rust-toolchain: nightly-2024-01-19 jobs: unit-test: diff --git a/rust-toolchain.toml b/rust-toolchain.toml index d9dc95ed69..3170b4a5a5 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] profile = "minimal" -channel = "nightly-2023-12-25" +channel = "nightly-2024-01-19" components = ["rust-src", "llvm-tools-preview", "rustfmt", "clippy"] targets = ["x86_64-unknown-none", "riscv64gc-unknown-none-elf", "aarch64-unknown-none-softfloat"] diff --git a/ulib/axlibc/src/errno.rs b/ulib/axlibc/src/errno.rs index a804793269..5f38bee368 100644 --- a/ulib/axlibc/src/errno.rs +++ b/ulib/axlibc/src/errno.rs @@ -16,7 +16,7 @@ pub fn set_errno(code: i32) { /// Returns a pointer to the global errno variable. #[no_mangle] pub unsafe extern "C" fn __errno_location() -> *mut c_int { - &mut errno + core::ptr::addr_of_mut!(errno) } /// Returns a pointer to the string representation of the given error code.