Skip to content

Commit

Permalink
[fix] Fix nightly build for riscv64, update toolchain to nightly-2024…
Browse files Browse the repository at this point in the history
…-12-25
  • Loading branch information
equation314 committed Dec 25, 2024
1 parent e755c02 commit 78f234a
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 67 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: false
matrix:
arch: [x86_64, riscv64, aarch64]
rust-toolchain: [nightly, nightly-2024-12-12]
rust-toolchain: [nightly, nightly-2024-12-25]
env:
RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }}
steps:
Expand All @@ -19,6 +19,7 @@ jobs:
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
- uses: Swatinem/rust-cache@v2
- name: Check rust version
run: rustc --version --verbose
- name: Check code format
Expand All @@ -40,7 +41,7 @@ jobs:
matrix:
os: [ubuntu-latest]
arch: [x86_64, riscv64, aarch64]
rust-toolchain: [nightly, nightly-2024-12-12]
rust-toolchain: [nightly, nightly-2024-12-25]
env:
RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }}
steps:
Expand All @@ -51,6 +52,7 @@ jobs:
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
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }}
run: make ARCH=${{ matrix.arch }} A=examples/helloworld
Expand Down Expand Up @@ -83,7 +85,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
rust-toolchain: [nightly, nightly-2024-12-12]
rust-toolchain: [nightly, nightly-2024-12-25]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -92,6 +94,7 @@ jobs:
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 for x86_64-pc-oslab
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }}
run: make PLATFORM=x86_64-pc-oslab A=examples/helloworld
Expand Down
3 changes: 2 additions & 1 deletion .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-12-12
rust-toolchain: nightly-2024-12-25

jobs:
doc:
Expand All @@ -19,6 +19,7 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.rust-toolchain }}
- uses: Swatinem/rust-cache@v2
- name: Build docs
continue-on-error: ${{ github.ref != env.default-branch && github.event_name != 'pull_request' }}
run: make doc_check_missing
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

env:
qemu-version: 8.2.0
rust-toolchain: nightly-2024-12-12
rust-toolchain: nightly-2024-12-25
arceos-apps: '57c8074'

jobs:
Expand All @@ -16,6 +16,7 @@ jobs:
with:
toolchain: ${{ env.rust-toolchain }}
components: rust-src
- uses: Swatinem/rust-cache@v2
- name: Run unit tests
run: make unittest_no_fail_fast

Expand All @@ -33,6 +34,7 @@ jobs:
toolchain: ${{ env.rust-toolchain }}
components: rust-src
- uses: Swatinem/rust-cache@v2
- run: cargo install cargo-binutils
- uses: ./.github/workflows/actions/setup-qemu
with:
qemu-version: ${{ env.qemu-version }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ else
endif

clean: clean_c
rm -rf $(APP)/*.bin $(APP)/*.elf
rm -rf $(APP)/*.bin $(APP)/*.elf $(OUT_CONFIG)
cargo clean

clean_c::
Expand Down
1 change: 1 addition & 0 deletions modules/axconfig/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::path::Path;

fn main() {
println!("cargo:rerun-if-env-changed=AX_CONFIG_PATH");
if let Ok(config_path) = std::env::var("AX_CONFIG_PATH") {
println!("cargo:rerun-if-changed={}", config_path);
} else {
Expand Down
4 changes: 3 additions & 1 deletion modules/axhal/src/arch/aarch64/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
mod context;
pub(crate) mod trap;

#[cfg(target_os = "none")]
mod trap;

use core::arch::asm;

Expand Down
3 changes: 1 addition & 2 deletions modules/axhal/src/arch/riscv/context.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use core::arch::naked_asm;
use memory_addr::VirtAddr;

include_asm_marcos!();

/// General registers of RISC-V.
#[allow(missing_docs)]
#[repr(C)]
Expand Down Expand Up @@ -123,6 +121,7 @@ impl TaskContext {
#[naked]
unsafe extern "C" fn context_switch(_current_task: &mut TaskContext, _next_task: &TaskContext) {
naked_asm!(
include_asm_marcos!(),
"
// save old context (callee-saved registers)
STR ra, a0, 0
Expand Down
62 changes: 8 additions & 54 deletions modules/axhal/src/arch/riscv/macros.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#[cfg(target_arch = "riscv32")]
macro_rules! include_asm_marcos {
() => {
#[cfg(target_arch = "riscv32")]
core::arch::global_asm!(
r"
r"
.ifndef XLENB
.equ XLENB, 4
Expand All @@ -14,11 +13,13 @@ macro_rules! include_asm_marcos {
.endm
.endif"
);
};
}

#[cfg(target_arch = "riscv64")]
core::arch::global_asm!(
r"
#[cfg(target_arch = "riscv64")]
macro_rules! include_asm_marcos {
() => {
r"
.ifndef XLENB
.equ XLENB, 8
Expand All @@ -29,53 +30,6 @@ macro_rules! include_asm_marcos {
sd \rs2, \off*XLENB(\rs1)
.endm
.endif",
);

core::arch::global_asm!(
r"
.ifndef .LPUSH_POP_GENERAL_REGS
.equ .LPUSH_POP_GENERAL_REGS, 0
.macro PUSH_POP_GENERAL_REGS, op
\op ra, sp, 0
\op t0, sp, 4
\op t1, sp, 5
\op t2, sp, 6
\op s0, sp, 7
\op s1, sp, 8
\op a0, sp, 9
\op a1, sp, 10
\op a2, sp, 11
\op a3, sp, 12
\op a4, sp, 13
\op a5, sp, 14
\op a6, sp, 15
\op a7, sp, 16
\op s2, sp, 17
\op s3, sp, 18
\op s4, sp, 19
\op s5, sp, 20
\op s6, sp, 21
\op s7, sp, 22
\op s8, sp, 23
\op s9, sp, 24
\op s10, sp, 25
\op s11, sp, 26
\op t3, sp, 27
\op t4, sp, 28
\op t5, sp, 29
\op t6, sp, 30
.endm
.macro PUSH_GENERAL_REGS
PUSH_POP_GENERAL_REGS STR
.endm
.macro POP_GENERAL_REGS
PUSH_POP_GENERAL_REGS LDR
.endm
.endif"
);
};
}
39 changes: 39 additions & 0 deletions modules/axhal/src/arch/riscv/trap.S
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
.macro PUSH_POP_GENERAL_REGS, op
\op ra, sp, 0
\op t0, sp, 4
\op t1, sp, 5
\op t2, sp, 6
\op s0, sp, 7
\op s1, sp, 8
\op a0, sp, 9
\op a1, sp, 10
\op a2, sp, 11
\op a3, sp, 12
\op a4, sp, 13
\op a5, sp, 14
\op a6, sp, 15
\op a7, sp, 16
\op s2, sp, 17
\op s3, sp, 18
\op s4, sp, 19
\op s5, sp, 20
\op s6, sp, 21
\op s7, sp, 22
\op s8, sp, 23
\op s9, sp, 24
\op s10, sp, 25
\op s11, sp, 26
\op t3, sp, 27
\op t4, sp, 28
\op t5, sp, 29
\op t6, sp, 30
.endm

.macro PUSH_GENERAL_REGS
PUSH_POP_GENERAL_REGS STR
.endm

.macro POP_GENERAL_REGS
PUSH_POP_GENERAL_REGS LDR
.endm

.macro SAVE_REGS, from_user
addi sp, sp, -{trapframe_size}
PUSH_GENERAL_REGS
Expand Down
3 changes: 1 addition & 2 deletions modules/axhal/src/arch/riscv/trap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use riscv::register::stval;

use super::TrapFrame;

include_asm_marcos!();

core::arch::global_asm!(
include_asm_marcos!(),
include_str!("trap.S"),
trapframe_size = const core::mem::size_of::<TrapFrame>(),
);
Expand Down
2 changes: 1 addition & 1 deletion modules/axhal/src/arch/x86_64/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl TaskContext {
#[naked]
unsafe extern "C" fn context_switch(_current_stack: &mut u64, _next_stack: &u64) {
naked_asm!(
"
".code64
push rbp
push rbx
push r12
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
profile = "minimal"
channel = "nightly-2024-12-12"
channel = "nightly-2024-12-25"
components = ["rust-src", "llvm-tools", "rustfmt", "clippy"]
targets = ["x86_64-unknown-none", "riscv64gc-unknown-none-elf", "aarch64-unknown-none", "aarch64-unknown-none-softfloat"]

0 comments on commit 78f234a

Please sign in to comment.