Skip to content

Commit

Permalink
Merge pull request arceos-org#151 from rcore-os/update-toolchain
Browse files Browse the repository at this point in the history
Update rust toolchain to nightly-2024-05-02
  • Loading branch information
chyyuu authored May 12, 2024
2 parents 1d05532 + 662dcae commit ba8f1fc
Show file tree
Hide file tree
Showing 35 changed files with 185 additions and 97 deletions.
69 changes: 40 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust-toolchain: [nightly, nightly-2024-01-19]
matrix:
rust-toolchain: [nightly, nightly-2024-05-02]
env:
RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }}
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: ${{ matrix.rust-toolchain }}
components: rust-src, clippy, rustfmt
targets: x86_64-unknown-none, riscv64gc-unknown-none-elf, aarch64-unknown-none, aarch64-unknown-none-softfloat
- name: Check rust version
run: rustc --version --verbose
- name: Clippy for the default target
run: make clippy
- name: Clippy for x86_64
Expand All @@ -34,19 +38,18 @@ jobs:
matrix:
os: [ubuntu-latest]
arch: [x86_64, riscv64, aarch64]
rust-toolchain: [nightly, nightly-2024-01-19]
rust-toolchain: [nightly, nightly-2024-05-02]
env:
RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }}
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: ${{ matrix.rust-toolchain }}
components: rust-src
- uses: actions-rs/[email protected]
with:
crate: cargo-binutils
version: latest
use-tool-cache: true
components: rust-src, llvm-tools
targets: x86_64-unknown-none, riscv64gc-unknown-none-elf, aarch64-unknown-none, aarch64-unknown-none-softfloat
- uses: Swatinem/rust-cache@v2
- run: cargo install cargo-binutils
- name: Build helloworld
run: make ARCH=${{ matrix.arch }} A=apps/helloworld
- name: Build memtest
Expand Down Expand Up @@ -80,20 +83,28 @@ jobs:
with:
arch: ${{ matrix.arch }}
- name: Build c/helloworld
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }}
run: make ARCH=${{ matrix.arch }} A=apps/c/helloworld
- name: Build c/memtest
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }}
run: make ARCH=${{ matrix.arch }} A=apps/c/memtest
- name: Build c/sqlite3
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }}
run: make ARCH=${{ matrix.arch }} A=apps/c/sqlite3
- name: Build c/httpclient
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }}
run: make ARCH=${{ matrix.arch }} A=apps/c/httpclient
- name: Build c/httpserver
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }}
run: make ARCH=${{ matrix.arch }} A=apps/c/httpserver
- name: Build c/udpserver
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }}
run: make ARCH=${{ matrix.arch }} A=apps/c/udpserver
- name: Build c/iperf
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }}
run: make ARCH=${{ matrix.arch }} A=apps/c/iperf
- name: Build c/redis
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }}
run: make ARCH=${{ matrix.arch }} A=apps/c/redis SMP=4

build-apps-for-other-platforms:
Expand All @@ -102,19 +113,18 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
rust-toolchain: [nightly, nightly-2024-01-19]
rust-toolchain: [nightly, nightly-2024-05-02]
env:
RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }}
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: ${{ matrix.rust-toolchain }}
components: rust-src
- uses: actions-rs/[email protected]
with:
crate: cargo-binutils
version: latest
use-tool-cache: true
components: rust-src, llvm-tools
targets: x86_64-unknown-none, riscv64gc-unknown-none-elf, aarch64-unknown-none, aarch64-unknown-none-softfloat
- uses: Swatinem/rust-cache@v2
- run: cargo install cargo-binutils
- uses: ./.github/workflows/actions/setup-musl
with:
arch: x86_64
Expand Down Expand Up @@ -143,12 +153,13 @@ jobs:
matrix:
os: [ubuntu-latest]
arch: [x86_64]
rust-toolchain: [nightly, nightly-2024-01-19]
rust-toolchain: [nightly, nightly-2024-05-02]
env:
RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }}
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: ${{ matrix.rust-toolchain }}
- name: Build helloworld
run: cargo build -p arceos-helloworld
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build & Deploy docs
on: [push, pull_request]

env:
rust-toolchain: nightly-2024-01-19
rust-toolchain: nightly-2024-05-02

jobs:
doc:
Expand All @@ -15,10 +15,9 @@ jobs:
env:
default-branch: ${{ format('refs/heads/{0}', github.event.repository.default_branch) }}
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: ${{ env.rust-toolchain }}
- name: Build docs
continue-on-error: ${{ github.ref != env.default-branch && github.event_name != 'pull_request' }}
Expand Down
19 changes: 7 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ on: [push, pull_request]

env:
qemu-version: 8.2.0
rust-toolchain: nightly-2024-01-19
rust-toolchain: nightly-2024-05-02

jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: ${{ env.rust-toolchain }}
components: rust-src
- name: Run unit tests
Expand All @@ -27,17 +26,13 @@ jobs:
os: [ubuntu-latest]
arch: [x86_64, riscv64, aarch64]
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: ${{ env.rust-toolchain }}
components: rust-src
- uses: actions-rs/[email protected]
with:
crate: cargo-binutils
version: latest
use-tool-cache: true
- uses: Swatinem/rust-cache@v2
- run: cargo install cargo-binutils
- uses: ./.github/workflows/actions/setup-qemu
with:
qemu-version: ${{ env.qemu-version }}
Expand Down
5 changes: 3 additions & 2 deletions Cargo.lock

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

21 changes: 17 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ else
APP_TYPE := c
endif

# Architecture, platform and target
# Architecture and platform
ifneq ($(filter $(MAKECMDGOALS),unittest unittest_no_fail_fast),)
PLATFORM_NAME :=
else ifneq ($(PLATFORM),)
Expand Down Expand Up @@ -97,20 +97,33 @@ ifeq ($(ARCH), x86_64)
# Don't enable kvm for WSL/WSL2.
ACCEL ?= $(if $(findstring -microsoft, $(shell uname -r | tr '[:upper:]' '[:lower:]')),n,y)
PLATFORM_NAME ?= x86_64-qemu-q35
TARGET := x86_64-unknown-none
BUS := pci
else ifeq ($(ARCH), riscv64)
ACCEL ?= n
PLATFORM_NAME ?= riscv64-qemu-virt
TARGET := riscv64gc-unknown-none-elf
else ifeq ($(ARCH), aarch64)
ACCEL ?= n
PLATFORM_NAME ?= aarch64-qemu-virt
TARGET := aarch64-unknown-none-softfloat
else
$(error "ARCH" must be one of "x86_64", "riscv64", or "aarch64")
endif

# Feature parsing
include scripts/make/features.mk

# Target
ifeq ($(ARCH), x86_64)
TARGET := x86_64-unknown-none
else ifeq ($(ARCH), riscv64)
TARGET := riscv64gc-unknown-none-elf
else ifeq ($(ARCH), aarch64)
ifeq ($(findstring fp_simd,$(FEATURES)),)
TARGET := aarch64-unknown-none-softfloat
else
TARGET := aarch64-unknown-none
endif
endif

export AX_ARCH=$(ARCH)
export AX_PLATFORM=$(PLATFORM_NAME)
export AX_SMP=$(SMP)
Expand Down
1 change: 1 addition & 0 deletions api/arceos_posix_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ repository = "https://github.com/rcore-os/arceos/tree/main/api/arceos_posix_api"
default = []

smp = ["axfeat/smp"]
irq = ["axfeat/irq"]
alloc = ["dep:axalloc", "axfeat/alloc"]
multitask = ["axtask/multitask", "axfeat/multitask", "axsync/multitask"]
fd = ["alloc"]
Expand Down
1 change: 1 addition & 0 deletions api/arceos_posix_api/src/imp/fd_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::ctypes;

pub const AX_FILE_LIMIT: usize = 1024;

#[allow(dead_code)]
pub trait FileLike: Send + Sync {
fn read(&self, buf: &mut [u8]) -> LinuxResult<usize>;
fn write(&self, buf: &[u8]) -> LinuxResult<usize>;
Expand Down
2 changes: 1 addition & 1 deletion api/arceos_posix_api/src/imp/io_mpx/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl FdSets {
let nfds = nfds.min(FD_SETSIZE);
let nfds_usizes = nfds.div_ceil(BITS_PER_USIZE);
let mut bits = core::mem::MaybeUninit::<[usize; FD_SETSIZE_USIZES * 3]>::uninit();
let bits_ptr = unsafe { core::mem::transmute(bits.as_mut_ptr()) };
let bits_ptr: *mut usize = unsafe { core::mem::transmute(bits.as_mut_ptr()) };

let copy_from_fd_set = |bits_ptr: *mut usize, fds: *const ctypes::fd_set| unsafe {
let dst = core::slice::from_raw_parts_mut(bits_ptr, nfds_usizes);
Expand Down
2 changes: 1 addition & 1 deletion apps/task/priority/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::sync::Arc;
use std::{thread, time};
use std::{vec, vec::Vec};

#[cfg(any(feature = "axstd", target_os = "arceos"))]
#[cfg(feature = "axstd")]
use std::os::arceos::api::task::ax_set_current_priority;

struct TaskParam {
Expand Down
9 changes: 5 additions & 4 deletions apps/task/tls/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#[cfg(feature = "axstd")]
extern crate axstd as std;

use std::{ptr::addr_of, str::from_utf8_unchecked};
use std::{thread, vec::Vec};

#[thread_local]
Expand Down Expand Up @@ -56,14 +57,14 @@ fn main() {
get!(U16),
get!(U32),
get!(U64),
get!(std::str::from_utf8_unchecked(&STR))
get!(from_utf8_unchecked(&*addr_of!(STR)))
);
assert!(get!(BOOL));
assert_eq!(get!(U8), 0xAA);
assert_eq!(get!(U16), 0xcafe);
assert_eq!(get!(U32), 0xdeadbeed);
assert_eq!(get!(U64), 0xa2ce05_a2ce05);
assert_eq!(get!(&STR), b"Hello, world!");
assert_eq!(get!(&*addr_of!(STR)), b"Hello, world!");

let mut tasks = Vec::new();
for i in 1..=10 {
Expand All @@ -85,7 +86,7 @@ fn main() {
get!(U16),
get!(U32),
get!(U64),
get!(std::str::from_utf8_unchecked(&STR))
get!(from_utf8_unchecked(&*addr_of!(STR)))
);
assert_eq!(get!(BOOL), i % 2 == 0);
assert_eq!(get!(U8), 0xAA + i as u8);
Expand All @@ -105,7 +106,7 @@ fn main() {
assert_eq!(get!(U16), 0xcafe);
assert_eq!(get!(U32), 0xdeadbeed);
assert_eq!(get!(U64), 0xa2ce05_a2ce05);
assert_eq!(get!(&STR), b"Hello, world!");
assert_eq!(get!(&*addr_of!(STR)), b"Hello, world!");

println!("TLS tests run OK!");
}
2 changes: 1 addition & 1 deletion crates/axerrno/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl TryFrom<i32> for AxError {
#[inline]
fn try_from(value: i32) -> Result<Self, Self::Error> {
if value > 0 && value <= core::mem::variant_count::<AxError>() as i32 {
Ok(unsafe { core::mem::transmute(value) })
Ok(unsafe { core::mem::transmute::<i32, AxError>(value) })
} else {
Err(value)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/driver_pci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ repository = "https://github.com/rcore-os/arceos/tree/main/crates/driver_pci"
documentation = "https://rcore-os.github.io/arceos/driver_pci/index.html"

[dependencies]
virtio-drivers = { git = "https://github.com/rcore-os/virtio-drivers.git", rev = "4b60f5d" }
virtio-drivers = "0.7.2"
2 changes: 1 addition & 1 deletion crates/driver_virtio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ driver_common = { path = "../driver_common" }
driver_block = { path = "../driver_block", optional = true }
driver_net = { path = "../driver_net", optional = true }
driver_display = { path = "../driver_display", optional = true}
virtio-drivers = { git = "https://github.com/rcore-os/virtio-drivers.git", rev = "4b60f5d" }
virtio-drivers = "0.7.2"
2 changes: 1 addition & 1 deletion crates/kernel_guard/src/arch/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(not(target_os = "none"), allow(dead_code))]
#![cfg_attr(not(target_os = "none"), allow(dead_code, unused_imports))]

cfg_if::cfg_if! {
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
Expand Down
6 changes: 3 additions & 3 deletions crates/linked_list/src/unsafe_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl<A: Adapter + ?Sized> List<A> {
// SAFETY: The safety requirements of this function satisfy those of `insert_after`.
unsafe { self.insert_after(self.inner_ref(existing).prev, new) };

if self.first.unwrap() == existing {
if core::ptr::eq(self.first.unwrap().as_ptr(), existing.as_ptr()) {
// Update the pointer to the first element as we're inserting before it.
self.first = Some(NonNull::from(new));
}
Expand Down Expand Up @@ -459,7 +459,7 @@ impl<A: Adapter + ?Sized> CommonCursor<A> {
if let Some(head) = list.first {
// SAFETY: Per the function safety requirements, `cur` is in the list.
let links = unsafe { list.inner_ref(cur) };
if links.next != head {
if !core::ptr::eq(links.next.as_ptr(), head.as_ptr()) {
self.cur = Some(links.next);
}
}
Expand All @@ -480,7 +480,7 @@ impl<A: Adapter + ?Sized> CommonCursor<A> {
let next = match self.cur.take() {
None => head,
Some(cur) => {
if cur == head {
if core::ptr::eq(cur.as_ptr(), head.as_ptr()) {
return;
}
cur
Expand Down
1 change: 0 additions & 1 deletion crates/memory_addr/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![no_std]
#![feature(const_mut_refs)]
#![doc = include_str!("../README.md")]

use core::fmt;
Expand Down
1 change: 0 additions & 1 deletion crates/scheduler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//! - [`CFScheduler`]: Completely Fair Scheduler (preemptive).
#![cfg_attr(not(test), no_std)]
#![feature(const_mut_refs)]

mod cfs;
mod fifo;
Expand Down
Loading

0 comments on commit ba8f1fc

Please sign in to comment.