From 061f22908efbceaaa472db900f2dba3938946780 Mon Sep 17 00:00:00 2001 From: LittleSand <1840309785@qq.com> Date: Tue, 2 Jun 2026 19:09:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=E5=9B=9E=E9=80=80=20Rust=20?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=93=BE=E8=87=B3=20nightly-2025-01-18?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 与评测机/参考项目 SanktaOS 对齐,将工具链从 nightly-2025-10-28 回退到 nightly-2025-01-18(1.86-nightly)。同步更新三个 workflow 的工具链版本。 该版本下若干特性尚未稳定,在 crate 根显式开启:let_chains、 trait_upcasting、unsigned_is_multiple_of、ip_from(业务代码不变)。 按旧版 rustfmt 归一化 stat_ops.rs / net/stack/mod.rs 的格式(结构体 字面量末参排版风格差异)。 验证:riscv/loongarch release 均编过;两架构预编译 std 在该版本均存在, 无需 build-std;fmt --check、clippy 均通过。 --- .github/workflows/ci.yml | 2 +- .github/workflows/docs-deployment.yml | 2 +- .github/workflows/mirror-to-gitlab.yml | 2 +- os/rust-toolchain.toml | 2 +- os/src/kernel/syscall/fs/stat_ops.rs | 15 ++++++--------- os/src/main.rs | 6 ++++++ os/src/net/stack/mod.rs | 11 ++++------- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aecdb8d3..cee687d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ on: env: CARGO_TERM_COLOR: always - RUST_TOOLCHAIN: nightly-2025-10-28 + RUST_TOOLCHAIN: nightly-2025-01-18 QEMU_VERSION: qemu-9.2.1 QEMU_BUILD_PATH: ${{ github.workspace }}/qemu-build-cache diff --git a/.github/workflows/docs-deployment.yml b/.github/workflows/docs-deployment.yml index 285b889c..0ee33a34 100644 --- a/.github/workflows/docs-deployment.yml +++ b/.github/workflows/docs-deployment.yml @@ -30,7 +30,7 @@ jobs: - name: 安装 Rust 工具链 uses: dtolnay/rust-toolchain@stable with: - toolchain: nightly-2025-10-28 + toolchain: nightly-2025-01-18 targets: riscv64gc-unknown-none-elf components: rust-src, rustfmt, clippy diff --git a/.github/workflows/mirror-to-gitlab.yml b/.github/workflows/mirror-to-gitlab.yml index b7157419..bec26a38 100644 --- a/.github/workflows/mirror-to-gitlab.yml +++ b/.github/workflows/mirror-to-gitlab.yml @@ -36,7 +36,7 @@ jobs: - name: Setup Rust toolchain (for cargo vendor) uses: dtolnay/rust-toolchain@master with: - toolchain: nightly-2025-10-28 + toolchain: nightly-2025-01-18 - name: Prepare mirror commit (vendor + README swap) env: diff --git a/os/rust-toolchain.toml b/os/rust-toolchain.toml index b3444f33..76a1eb1c 100644 --- a/os/rust-toolchain.toml +++ b/os/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly-2025-10-28" +channel = "nightly-2025-01-18" diff --git a/os/src/kernel/syscall/fs/stat_ops.rs b/os/src/kernel/syscall/fs/stat_ops.rs index fc0e5569..a4244ac8 100644 --- a/os/src/kernel/syscall/fs/stat_ops.rs +++ b/os/src/kernel/syscall/fs/stat_ops.rs @@ -82,15 +82,12 @@ pub fn getdents64(fd: usize, dirp: *mut u8, count: usize) -> isize { // 写入 dirent 头部 unsafe { - write_to_user( - dirp.add(written) as *mut LinuxDirent64, - LinuxDirent64 { - d_ino: entry.inode_no as u64, - d_off: current_off, - d_reclen: dirent_len as u16, - d_type: inode_type_to_d_type(entry.inode_type), - }, - ); + write_to_user(dirp.add(written) as *mut LinuxDirent64, LinuxDirent64 { + d_ino: entry.inode_no as u64, + d_off: current_off, + d_reclen: dirent_len as u16, + d_type: inode_type_to_d_type(entry.inode_type), + }); } // 写入文件名到 d_name 字段(从 LinuxDirent64 offset 19 开始) diff --git a/os/src/main.rs b/os/src/main.rs index e2d42ab3..c74a2d86 100644 --- a/os/src/main.rs +++ b/os/src/main.rs @@ -7,6 +7,12 @@ #![no_std] #![no_main] #![feature(custom_test_frameworks)] +// 下列特性在 nightly-2025-10-28 已稳定,但本项目固定的 nightly-2025-01-18 +// (1.86-nightly,与评测机/参考项目 SanktaOS 对齐) 仍需显式开启。 +#![feature(let_chains)] +#![feature(trait_upcasting)] +#![feature(unsigned_is_multiple_of)] +#![feature(ip_from)] #![test_runner(test_runner)] #![reexport_test_harness_main = "test_main"] diff --git a/os/src/net/stack/mod.rs b/os/src/net/stack/mod.rs index feefb716..87a2c3b8 100644 --- a/os/src/net/stack/mod.rs +++ b/os/src/net/stack/mod.rs @@ -370,13 +370,10 @@ impl NetworkStack { sockets.remove(h); return Err(NetworkError::AddressInUse); } - ports.insert( - port, - UdpPortEntry { - handle: h, - sockets: alloc::vec::Vec::new(), - }, - ); + ports.insert(port, UdpPortEntry { + handle: h, + sockets: alloc::vec::Vec::new(), + }); h } }; From a93a5b5f460e3a2085b80dcc0d5fc473a5215314 Mon Sep 17 00:00:00 2001 From: LittleSand <1840309785@qq.com> Date: Tue, 2 Jun 2026 19:48:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(asm):=20entry.S=20=E6=9C=AB=E5=B0=BE?= =?UTF-8?q?=E5=88=87=E5=9B=9E=20.text=EF=BC=8C=E9=81=BF=E5=85=8D=E6=AE=B5?= =?UTF-8?q?=E6=B3=84=E6=BC=8F=E5=88=B0=E5=90=8E=E7=BB=AD=20global=5Fasm=20?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit entry.S 预留启动栈后停在 .bss.*(NOBITS)段未恢复 .text。Rust 将所有 global_asm! 块拼接为同一汇编单元,switch.S 等纯代码 .S 无自身 .section 声明、继承前块段,导致其指令落入 .bss,触发 "SHT_NOBITS section cannot have instructions"。 新版 LLVM 容忍此情形,回退到 nightly-2025-01-18 后旧版 LLVM 严格报错、 CI 构建失败。在 riscv/loongarch 两个 entry.S 末尾显式切回 .text 根治: 无论 global_asm! 拼接顺序如何,后续代码块进入时均为 .text。 验证:两架构 release/test 构建均通过,usertest 510/510。 --- os/src/arch/loongarch/boot/entry.S | 3 +++ os/src/arch/riscv/boot/entry.S | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/os/src/arch/loongarch/boot/entry.S b/os/src/arch/loongarch/boot/entry.S index b27ae333..2edf4ea1 100644 --- a/os/src/arch/loongarch/boot/entry.S +++ b/os/src/arch/loongarch/boot/entry.S @@ -102,3 +102,6 @@ boot_stack_lower_bound: .space 4096 * 48 # 48 页 = 192KB 启动栈 .globl boot_stack_top boot_stack_top: + + # 切回 .text:与 riscv entry.S 同理,避免 global_asm! 拼接时后续代码块继承本 .bss 段。 + .section .text diff --git a/os/src/arch/riscv/boot/entry.S b/os/src/arch/riscv/boot/entry.S index ad02b70c..d2923c3e 100644 --- a/os/src/arch/riscv/boot/entry.S +++ b/os/src/arch/riscv/boot/entry.S @@ -126,4 +126,9 @@ secondary_sbi_entry: secondary_stacks_bottom: .space 65536 * 8 # 8 核 × 64KB .globl secondary_stacks_top -secondary_stacks_top: \ No newline at end of file +secondary_stacks_top: + + # 切回 .text:本文件经 global_asm! 与 switch.S 等纯代码 .S 拼接为同一汇编单元, + # 若停在 .bss.secondary_stack(NOBITS)结束,后续代码块会继承该段,触发 + # "SHT_NOBITS section cannot have instructions"(旧版 LLVM 严格报错)。 + .section .text \ No newline at end of file