Skip to content

Fix compilation on armv7a-none-eabihf by making aarch64-cpu a target-conditional dependency#20

Merged
ZR233 merged 6 commits intomasterfrom
copilot/fix-armv7a-compile-issue
Feb 26, 2026
Merged

Fix compilation on armv7a-none-eabihf by making aarch64-cpu a target-conditional dependency#20
ZR233 merged 6 commits intomasterfrom
copilot/fix-armv7a-compile-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 26, 2026

  • Make aarch64-cpu a target-conditional dependency in Cargo.toml
  • Change v3 module gate to target_arch = "aarch64"
  • Gate sys_reg/ich submodule with #[cfg(target_arch = "aarch64")]
  • Update lib.rs doc comment
  • Add armv7a-none-eabihf to CI matrix targets
  • Gate aarch64-only CI steps (cargo-binutils, QEMU, ostool, apt packages, tests) with if: matrix.targets == 'aarch64-unknown-none-softfloat'
  • Gate clippy step to aarch64 only; armv7a job runs cargo build only
  • armv7a build step uses cargo build -p arm-gic-driver to scope to crate only (tests excluded)
  • Gate v3 rdif trait impls with #[cfg(target_arch = "aarch64")] so cargo build -p arm-gic-driver --target armv7a-none-eabihf --all-features compiles successfully
Original prompt

This section details on the original issue you should resolve

<issue_title>Does not compile on armv7a-none-eabihf</issue_title>
<issue_description>I think there needs to be a feature that disables the aarch64-cpu dependency entirely if not on aarch64 or something.</issue_description>

<agent_instructions>将 aarch64-cpu 依赖设为类似于 dependens.cfg(target_arch=aarch64) </agent_instructions>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…dependency

Co-authored-by: ZR233 <34859362+ZR233@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix compilation issue on armv7a-none-eabihf Fix compilation on armv7a-none-eabihf by making aarch64-cpu a target-conditional dependency Feb 26, 2026
@ZR233
Copy link
Copy Markdown
Member

ZR233 commented Feb 26, 2026

@copilot ci 中增加 armv7a-none-eabihf 编译测试

Co-authored-by: ZR233 <34859362+ZR233@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 26, 2026

@copilot ci 中增加 armv7a-none-eabihf 编译测试

Done in 81c55a2. Added armv7a-none-eabihf to the CI matrix. The aarch64-only steps (cargo-binutils, QEMU setup, libudev-dev, ostool, and the QEMU tests) are now gated with if: matrix.targets == 'aarch64-unknown-none-softfloat', so the armv7a job runs fmt/clippy/build only.

@ZR233
Copy link
Copy Markdown
Member

ZR233 commented Feb 26, 2026

@copilot ci armv7 只 cargo build 测试,不进行clippy

Co-authored-by: ZR233 <34859362+ZR233@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 26, 2026

@copilot ci armv7 只 cargo build 测试,不进行clippy

Done in 6dfab6a. The Clippy step is now gated to aarch64-unknown-none-softfloat only; the armv7a-none-eabihf job runs cargo build only.

@ZR233
Copy link
Copy Markdown
Member

ZR233 commented Feb 26, 2026

@copilot armv7 只验证 clippy build -p arm-gic-driver crate, 忽略测试

Co-authored-by: ZR233 <34859362+ZR233@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 26, 2026

@copilot armv7 只验证 clippy build -p arm-gic-driver crate, 忽略测试

Done in 9143e13. The armv7a Build step now runs cargo build -p arm-gic-driver --target armv7a-none-eabihf --all-features, scoped to the crate only. Tests are already gated to the aarch64 job only.

@ZR233
Copy link
Copy Markdown
Member

ZR233 commented Feb 26, 2026

@copilot 修复至 cargo build -p arm-gic-driver --target armv7a-none-eabihf --all-features 可以通过

Co-authored-by: ZR233 <34859362+ZR233@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 26, 2026

@copilot 修复至 cargo build -p arm-gic-driver --target armv7a-none-eabihf --all-features 可以通过

Fixed in dca795a. The root cause was that rdif.rs referenced super::v3::Gic without a cfg gate, causing a compile error when v3 was excluded on armv7a. Added #[cfg(target_arch = "aarch64")] to the two v3 trait impls — cargo build -p arm-gic-driver --target armv7a-none-eabihf --all-features now compiles successfully.

@ZR233 ZR233 marked this pull request as ready for review February 26, 2026 08:59
Copilot AI review requested due to automatic review settings February 26, 2026 08:59
@ZR233 ZR233 merged commit 17a763d into master Feb 26, 2026
5 checks passed
@ZR233 ZR233 deleted the copilot/fix-armv7a-compile-issue branch February 26, 2026 08:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make the arm-gic-driver workspace compile for armv7a-none-eabihf by making AArch64-only code and dependencies conditional, and by expanding CI to include an armv7 build job.

Changes:

  • Make aarch64-cpu a target-conditional dependency and gate AArch64-only modules/impls with #[cfg(target_arch = "aarch64")].
  • Update the v3 module’s compilation gate and adjust documentation to reflect AArch64-only availability.
  • Extend CI matrix to include armv7a-none-eabihf, with AArch64-only steps/tests gated accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
gic-driver/src/version/rdif.rs Gate GICv3 rdif trait impls to avoid referencing v3 on non-aarch64.
gic-driver/src/version/mod.rs Change v3 module cfg gate from pointer-width-based to target_arch = "aarch64".
gic-driver/src/sys_reg/mod.rs Gate ich module and re-exports to AArch64 only.
gic-driver/src/lib.rs Update crate-level docs to state v3 is AArch64-only.
gic-driver/Cargo.toml Make aarch64-cpu a target-conditional dependency on AArch64.
.github/workflows/ci.yml Add armv7a-none-eabihf to CI matrix; gate AArch64-only steps and use crate-scoped build for armv7.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


pub mod v2;
#[cfg(any(target_pointer_width = "64", doc))]
#[cfg(any(target_arch = "aarch64", doc))]
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

Changing the v3 gate from target_pointer_width = "64" to target_arch = "aarch64" means version::v3 no longer exists on non-aarch64 64-bit targets (e.g. x86_64). This breaks at least cargo test on such hosts because gic-driver/src/tests.rs imports version::v3::* unconditionally under cfg(test). It can also break cargo doc on non-aarch64 because cfg(doc) still enables v3 but aarch64-cpu is now a target-conditional dependency. Either (a) gate v3 (and the tests/docs) consistently so non-aarch64 builds don’t reference it, or (b) reconsider whether v3 really needs to be target_arch = "aarch64" rather than “any 64-bit target” for host-side compilation/testing.

Suggested change
#[cfg(any(target_arch = "aarch64", doc))]
#[cfg(target_arch = "aarch64")]

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci.yml
- name: Check rust version
run: rustc --version --verbose
- name: Check code format
run: cargo fmt --all -- --check
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

The matrix now runs the full job twice (one per target), so cargo fmt also runs twice even though it is target-independent. Consider gating the fmt step to a single matrix entry or splitting formatting into a separate non-matrix job to reduce CI time.

Suggested change
run: cargo fmt --all -- --check
run: cargo fmt --all -- --check
if: ${{ matrix.targets == 'aarch64-unknown-none-softfloat' }}

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci.yml
Comment on lines 49 to +54
- name: Build
run: cargo build --target aarch64-unknown-none-softfloat --all-features
run: cargo build --target ${{ matrix.targets }} --all-features
if: ${{ matrix.targets == 'aarch64-unknown-none-softfloat' }}
- name: Build
run: cargo build -p arm-gic-driver --target ${{ matrix.targets }} --all-features
if: ${{ matrix.targets == 'armv7a-none-eabihf' }}
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

There are two different build steps that both have the name "Build". Giving them distinct names (e.g., indicating the target) will make CI logs and failure triage clearer.

Copilot uses AI. Check for mistakes.
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.

Does not compile on armv7a-none-eabihf

3 participants