Skip to content

Add percore attribute macro feature - #37

Merged
qwandor merged 4 commits into
google:mainfrom
imre-kis-arm:percore-derive
Jul 24, 2026
Merged

Add percore attribute macro feature#37
qwandor merged 4 commits into
google:mainfrom
imre-kis-arm:percore-derive

Conversation

@imre-kis-arm

Copy link
Copy Markdown
Contributor

Add a new derive feature backed by the percore-derive proc-macro crate. The #[percore::percore] attribute places statics in the .percore section, generates a wrapper type, and exposes per-core access through the runtime offset hook.

Comment thread src/derive.rs Outdated
Comment thread src/derive.rs Outdated
@imre-kis-arm
imre-kis-arm force-pushed the percore-derive branch 2 times, most recently from de389be to aae4ffb Compare July 17, 2026 11:25
Comment thread src/derive/aarch64.rs
Comment thread src/derive.rs Outdated
Comment thread src/derive.rs Outdated
Comment thread percore-derive/src/lib.rs Outdated
Comment thread percore-derive/src/lib.rs Outdated
Comment thread src/derive.rs
// This project is dual-licensed under Apache 2.0 and MIT terms.
// See LICENSE-APACHE and LICENSE-MIT for details.

#[cfg(all(target_arch = "aarch64", target_os = "none"))]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is target_os = "none" actually required? What stops this from running under an OS?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This prevents including these parts when building for AArch64 based Macs. The Mach-O format handles sections differently and this causes a build failure in dependent projects like RF-A when running cargo test.
Per-core tests don't work on aarch64-apple-darwin to begin with, but that's a separate issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I looked into this and this is the error on Mac when running cargo test in the RF-A repo:

rustc-LLVM ERROR: Global variable '_ZN9rf_a_bl318services3ffa4spmd15SPMD_CORE_LOCAL17h1940126bd1185568E' has an invalid section specifier '.percore': mach-o section specifier requires a segment and section separated by a comma.
error: could not compile rf-a-bl31 (lib test)

If I use __DATA,.percore, it works.

The rest of the #[cfg(all(target_arch = "aarch64", target_os = "none"))] guarded parts would fail in Mac because it uses a different relocation model and it doesn't work with adrp and add ... :lo12:....

Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md
Comment thread README.md Outdated
Add a new `derive` feature backed by the `percore-derive` proc-macro
crate. The `#[percore::percore]` attribute places statics in the
`.percore` section, generates a wrapper type, and exposes per-core
access through the runtime offset hook.

Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I6acca7a5d5b835b92592174aeed303bc5e57dcb4
* Documentation fixes
* Added PerCoreWrapper
* percore_local_offset_hook -> PercoreLocalOffsetImpl
* Require using ExceptionLock
* Fixed BTI use case

Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I7bf8fa841f152e87d3a7b8a18e7d1d00dd9b19d3
Comment thread percore-derive/src/lib.rs Outdated
Comment thread README.md Outdated
Comment thread src/derive.rs
Comment thread src/derive.rs Outdated
Comment thread src/derive.rs Outdated
Comment thread src/derive.rs Outdated
* Merged the variable and it's wrapper
* Renamed PerCoreWrapper to LinkedPerCore
* Added documentation

Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: Ibcca7429e64cb84629acd3f96e733e0b80606cc9
Comment thread percore-derive/src/lib.rs Outdated
Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I862dd933a36083ebcbd542773283cb002e6ca714
@qwandor
qwandor merged commit 767e76b into google:main Jul 24, 2026
8 checks passed
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.

3 participants