Skip to content

refactor(axbuild): 将构建与启动能力收敛到显式配置#1620

Merged
ZR233 merged 19 commits into
devfrom
axbuild
Jul 16, 2026
Merged

refactor(axbuild): 将构建与启动能力收敛到显式配置#1620
ZR233 merged 19 commits into
devfrom
axbuild

Conversation

@ZCShou

@ZCShou ZCShou commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

refactor(axbuild): 将构建与启动能力收敛到显式配置

背景

本 PR 的主要目的是移除 axbuild 根据目标架构、宿主机环境、包元数据或历史兼容规则自动补全构建参数的行为。此前这些隐式修正会让 Cargo feature、QEMU 启动方式和固件路径的真实来源不清晰:配置或代码缺少能力声明时,axbuild 仍可能构建或启动成功;一旦重构移除某个补丁,CI 才以超时或启动失败的方式暴露问题。

本次将能力声明回归到应用 manifest、board/build TOML、VM TOML 和 QEMU TOML,使 axbuild 只负责读取显式输入、转发命令参数、准备测试资产,以及拒绝不再支持的旧配置。

主要修改

1. 移除 axbuild 的隐式 feature 与平台补全

  • 删除按 package metadata 自动添加 ArceOS/ax-std 基线能力的逻辑。
  • 删除默认注入 smp、动态平台、静态平台和兼容 feature 的行为;仅当 max_cpu_num--smp 明确请求多核时,转发对应的 SMP 能力。
  • 拒绝已废弃的 plat-dynaxstd 等兼容 feature,而不是静默过滤或改写。
  • ArceOS C 应用不再由 axbuild 自动补 fd;将 pipeselectpollepollfd 的依赖收敛到 axlibc manifest。
  • C 应用的包固定为 ax-libc,对冲突的 --package 或配置选择器直接报错,不再在执行阶段静默覆盖用户请求。

2. 将运行能力声明回归到代码与配置

  • ArceOS 应用和 Rust 测试套件在各自 Cargo.toml 中声明 arceosstd-compat、文件系统等基础能力;Shell 明确选择 FAT32 后端。
  • StarryOS 与 Axvisor 在各自 manifest 中声明 std-compat;Starry perf 使用 package 定义的 qperf preset,而不是由 axbuild 拼装驱动 feature。
  • Axvisor x86_64 的 VMX/SVM 后端由 board/test build TOML 明确选择:普通 QEMU 与 ASUS NUC 测例选择 vmx,AMD 测例选择 svm。axbuild 不再默认注入 VMX。
  • VM 配置中的 LoongArch UEFI 固件路径保持为 VM TOML 的契约,运行时不再改写。

3. 将 QEMU 启动契约回归到 QEMU TOML

  • 删除按 target、/dev/kvm 或 Cargo feature 自动改写 QEMU 的逻辑,包括 UEFI、BIN、KVM、CPU 嵌套虚拟化 feature、默认设备和调试参数。
  • x86_64 与 LoongArch 的 ArceOS、StarryOS、Axvisor QEMU 测例显式声明 uefi = trueto_bin = true,并在 Axvisor VMX/SVM 测例中显式配置 CPU feature 和 UEFI 所需设备。
  • AArch64 ArceOS Rust 测例显式声明 to_bin = true,以 raw BIN 加载高半区内核,避免将高半区 ELF 直接交给 QEMU 后无输出超时。
  • Axvisor 对 uefi = true, to_bin = false 的矛盾配置直接报错,不再隐式把 UEFI 请求修正为 BIN。
  • UEFI 测试仍会将明确请求的快照隔离转换为逐 drive snapshot=on,避免全局 -snapshot 使可写 ESP 失效。

4. 清理与可维护性调整

  • 删除 axbuild 的固件缓存预热器;AIC8800 crate 的 build.rs 独立处理按需下载与校验,仓库内固件目录仅作为可选离线缓存。
  • ArceOS qemu 在没有 package/config 选择器时使用显式的 qemu-<arch> board 模板默认启动 Hello World;显式 --package--config 仍优先。
  • 恢复 spin 锁定版本至 dev 已采用的 0.12.2
  • 补充回归测试,覆盖显式 BIN 要求、废弃平台 feature 拒绝、VMX/SVM 启动配置与 ArceOS AArch64 QEMU 启动契约。

设计原则

  • Cargo feature 的所有权属于 crate manifest 或显式 build/test 配置。
  • uefito_bin、CPU、设备、固件和加速方式属于选定的 QEMU TOML。
  • VM 后端和 VM 固件路径属于 board/build/VM TOML。
  • axbuild 只处理已选定的参数与配置;对于不再支持或互相矛盾的输入,提供明确错误,而不是猜测、回退或静默修正。

验证

已完成以下验证:

cargo test -p axbuild --lib
cargo xtask clippy --package axbuild
cargo fmt --all --check
git diff --check
cargo xtask arceos test qemu --arch aarch64
cargo xtask axvisor test qemu --arch x86_64 --test-group normal --test-case smoke-vmx
cargo xtask spin-lint

ZCShou added 13 commits July 15, 2026 13:10
…rceOS builds

Remove runtime feature injection from axbuild (arceos auto-enable, irq/paging/std-compat baseline, smp unconditional push, package.metadata.axstd parsing) and move feature ownership to applications via their `arceos` feature with `ax-std/arceos` baseline. Require explicit vmx/svm selection for x86_64 Axvisor, removing CPUID auto-detection and AXVISOR_X86_BACKEND env var. Add `fd` dependency to axlibc pipe/select/poll/epoll features and stop auto-injecting `fd` in cbuild.
…force feature validation

Remove `apply_dynamic_platform_qemu_boot` and all runtime QEMU/CPU/UEFI mutations that axbuild previously inferred from target architecture and host KVM availability. QEMU firmware, acceleration, and device configuration now comes solely from each `qemu-*.toml` contract. Replace silent feature alias normalization and removal with explicit `validate_features()` that rejects removed platform controls (`plat-dyn`, `axstd/*`, etc.) and legacy aliases as build errors. Move the ArceOS baseline (`ax-std/arceos`) into `test-suit`'s own Cargo feature, add a `qperf` preset owned by the StarryOS package, and remove the ArceOS x86_64 guest image injection from Axvisor tests.
… fs feature

Replace `ax-std/fs` with `ax-std/fatfs` in the shell's `arceos` feature so the application manifest declares the filesystem backend matching its QEMU FAT32 disk image, rather than relying on axbuild to infer it. Add a test guarding this declaration.
…efi config-driven

Replace the hard error for missing x86_64 virtualization backend with a
temporary vmx default for the generic QEMU board. Remove architecture-based
to_bin inference and instead propagate the explicit uefi/to_bin flags from
each qemu-*.toml config. Enable uefi and to_bin on the x86_64 QEMU configs
and update tests accordingly.

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审查总结

本 PR 对 axbuild 进行了大规模重构,主要方向是将 ArceOS feature 声明从 axbuild 运行时注入转移到应用程序 manifest 中,同时清理了动态平台 QEMU 注入、firmware 缓存预热、Axvisor x86 后端自动检测等旧逻辑。重构方向正确,测试更新到位,格式与 clippy 检查通过。

变更概要

  1. ArceOS app feature 模型改革:各 app 的 Cargo.toml 改为 default = ["arceos"] / arceos = ["dep:ax-std", "ax-std/arceos"],移除 [package.metadata.axstd]ax-std 新增 arceos feature 打包 irq + paging + std-compat + smp 基线。
  2. Axvisor x86 后端简化:删除 x86.rs(171 行),移除 CPUID 自动检测和 AXVISOR_X86_BACKEND 环境变量;通用 QEMU 配置临时默认 vmx
  3. UEFI 启动变更:LoongArch StarryOS、x86_64 ArceOS 测试等切换为 UEFI 启动。
  4. ArceOS QEMU 默认cargo xtask arceos qemu 不带 --package 时默认选择 board 模板的 hello world。
  5. Feature 验证强化:旧别名 axstdax-stdplat-dyn 等不再静默转换,改为直接报错。
  6. Firmware 缓存移除:删除 scripts/axbuild/src/firmware.rs,AIC8800 固件完全由 crate 内 build.rs 自行处理。
  7. C app 包解析收紧:C app 构建拒绝非 ax-libc 包并给出明确错误。

验证结果

  • cargo fmt --check:通过
  • cargo clippy --package axbuild -- -D warnings:通过
  • cargo test --package axbuild:735 通过,0 失败
  • 未发现 [patch.crates-io] 条目

CI 状态

当前 CI 仍在运行中(部分 job 为 in_progress,部分已 skipped)。Detect changed pathsCancel stale CI runs 通过。

重复与重叠分析

搜索了 open PR 中与 axbuild 相关的条目,未发现与本 PR 重叠或冲突的其他 PR。

阻塞问题

1. spin 版本回退(Cargo.toml:315 / spin_lint.rs)

本 PR 将 spin 依赖从 =0.12.2 降级为 =0.12.0,同时 spin_lint.rs 中的版本常量也相应改为 0.12.0dev 分支在 commit 465c09cd2("chore(repo): update spin to 0.12.2")中已明确将 spin 升级到 0.12.2。本 PR 在合并 dev 时保留了旧版本,这是合并冲突解决时的意外回退。

修复方向:将 Cargo.toml 中的 spin = { version = "=0.12.0", ... } 改回 spin = { version = "=0.12.2", ... },并将 scripts/axbuild/src/spin_lint.rs 中的 SPIN_VERSION_REQSPIN_LOCKFILE_VERSION 恢复为 "0.12.2",同时更新 Cargo.lock

非阻塞观察

  • 整体重构方向合理,将 feature 声明权从 axbuild 移到应用 manifest 使依赖关系更清晰。
  • 测试更新充分,新增了多个有针对性的回归测试(如 C app 包冲突拒绝、SVM 后端保留、UEFI 配置验证等)。
  • 文档更新与代码变更一致。

Powered by deepseek-v4-pro

@mai-team-app
mai-team-app Bot requested a review from ZR233 July 15, 2026 09:35
ZCShou added 4 commits July 16, 2026 08:49
…feature application

Remove `default_to_bin_for_target` and always produce ELF artifacts from
Cargo; BIN conversion is now an explicit runner/config concern. Unify
`apply_makefile_features` and `apply_makefile_features_with_metadata` into
a single function that no longer takes package or metadata parameters.
Simplify std-build env preparation by inlining `AX_TARGET` and removing
the unused `prepare_std_build_env_for_package` wrapper. Make SMP feature
propagation explicit based on `max_cpu_num` instead of metadata-driven.
…efaulting x86_64

Remove the temporary x86_64 vmx backend auto-selection from axbuild and
instead declare the `vmx` feature explicitly in each board configuration
that needs it (qemu-x86_64, qemu-x86_64-linux, and asus-nuc15crh). Update
the corresponding tests to assert that no backend is implicitly injected.

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审查总结

本轮审查确认上一轮审查中提出的阻塞问题(spin 版本回退)已修复,未发现新的阻塞问题。

上一轮阻塞问题验证

spin 版本回归已修复Cargo.tomlCargo.lockspin_lint.rs 中均已正确使用 0.12.2Cargo.toml 中为 spin = { version = "=0.12.2", ... }spin_lint.rsSPIN_VERSION_REQSPIN_LOCKFILE_VERSION 均为 "0.12.2"

变更概要

本 PR 对 axbuild 进行了大规模重构(106 文件,+803/-2421 行):

  1. ArceOS app feature 模型改革:各 app 的 Cargo.toml 改为 default = ["arceos"] / arceos = ["dep:ax-std", "ax-std/arceos"],移除 [package.metadata.axstd]ax-std 新增 arceos feature 打包 irq + paging + std-compat + smp 基线。
  2. Axvisor x86 后端简化:删除 x86.rs(171 行),移除 CPUID 自动检测和 AXVISOR_X86_BACKEND 环境变量;通用 QEMU 配置临时默认 vmx
  3. UEFI 启动变更:LoongArch StarryOS、x86_64 ArceOS 测试、Axvisor nimbos smoke test 等切换为 UEFI 启动,uefi/to_bin 由各 qemu-*.toml 显式声明。
  4. ArceOS QEMU 默认cargo xtask arceos qemu 不带 --package 时从 board 模板默认选择 hello world。
  5. Feature 验证强化:旧别名 axstdax-stdplat-dyn 等不再静默转换,改为 validate_features() 直接报错。
  6. Firmware 缓存移除:删除 scripts/axbuild/src/firmware.rs,AIC8800 固件完全由 crate 内 build.rs 自行处理。
  7. C app 包解析收紧:C app 构建拒绝非 ax-libc 包并给出明确错误。
  8. axlibc feature 依赖修复pipe/select/poll/epoll 增加 fd 依赖,不再由 axbuild 自动注入。
  9. StarryOS Cargo.toml:增加 std-compat feature 和 qperf/qperf-metrics 预设。
  10. 文档更新:README、quickstart、配置文档等同步更新。

代码审查

  • feature 声明权转移:将 feature 从 axbuild 运行时注入转移到应用 manifest 是正确的架构方向,使依赖关系更清晰、可审计。
  • ax-std arceos 基线 featurearceos = ["irq", "paging", "std-compat", "smp"] 设计合理,作为所有 ArceOS Rust 应用的共同基线。
  • Feature 验证validate_features() 对已移除的平台控制(plat-dynaxstd/* 等)和遗留别名直接报错,避免静默降级,有助于强制迁移。
  • Axvisor x86 后端:临时默认 vmx 的兼容策略明确标记为过渡方案,文档中注明了后续应删除该兼容逻辑。
  • UEFI/to_bin 配置化:将 QEMU 启动方式从架构推断改为各 qemu-*.toml 显式声明,符合 arch-platform-porting 技能中 "axbuild must not infer or overwrite them" 的要求。
  • 测试覆盖:新增了多个回归测试(C app 包冲突拒绝、SVM 后端保留、UEFI 配置验证、shell fatfs 后端声明等),测试更新与代码变更同步。
  • [patch.crates-io]:确认工作区 manifest 中未引入 crates.io patch。

CI 状态

CI 仍在运行中(30/58 jobs 完成)。已完成的 job 状态:

  • Detect changed paths:✅ success
  • Cancel stale CI runs:✅ success
  • artifact.ci:✅ success
  • 其余 skipped jobs 为预期的分支限制发布 job、互斥矩阵 job 和路径过滤 job。

重复与重叠分析

搜索了与 axbuild 相关的 open PR,未发现与本 PR 重复或冲突的其他 PR。

结论

上一轮阻塞问题已全部修复,代码质量良好,架构方向正确,文档同步更新。批准合并。

Powered by deepseek-v4-pro

@ZR233 ZR233 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码与启动契约本身未发现新的阻塞:显式 feature、UEFI/to_bin、VMX/SVM 和配置所有权方向符合 arch-platform-porting 规范;本地 cargo test -p axbuild --lib 为 738/738 通过,current-head CI 为 pass=32、skipped=32,涵盖 ArceOS/StarryOS/Axvisor 多架构及 x86_64 UEFI/self-hosted 流程。未发现 crates.io patch,开放 PR 搜索和与 #1607 的文件交集检查也未发现重复或冲突。

当前唯一阻塞是 PR 元数据:仓库明确要求 PR 标题使用 Conventional Commits 的 type(scope): content,现标题 Refactor axbuild for ArceOS features and UEFI boot improvements 不符合格式。请改为例如 refactor(axbuild): make feature and UEFI boot contracts explicit;标题更新且 head/CI 未变化后即可重新确认批准。

@ZR233
ZR233 requested a review from Josen-B July 16, 2026 03:27
@ZR233 ZR233 changed the title Refactor axbuild for ArceOS features and UEFI boot improvements refactor(axbuild): 将构建与启动能力收敛到显式配置 Jul 16, 2026
@ZR233
ZR233 merged commit c4ca93d into dev Jul 16, 2026
79 of 82 checks passed
@ZR233
ZR233 deleted the axbuild branch July 16, 2026 04:07
@github-actions github-actions Bot mentioned this pull request Jul 16, 2026
@github-actions github-actions Bot mentioned this pull request Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants