Fix: add aarch64 guards for ARM64 inline assembly in AICPU files#1366
Fix: add aarch64 guards for ARM64 inline assembly in AICPU files#1366doraemonmj wants to merge 2 commits into
Conversation
- Wrap ARM64 cache instructions (dc civac, dc cvac, dsb, isb) in cache_ops.cpp with #if defined(__aarch64__) - Wrap ARM64 mrs cntvct_el0 instruction in device_time.cpp with #if defined(__aarch64__) - Provide empty stub implementations for x86_64 (onboard-only, so x86 path is unreachable at runtime) This fixes compilation failures on x86_64 CI runners that attempt to compile ARM64-specific inline assembly instructions. Closes hw-native-sys#1325
📝 WalkthroughWalkthroughAICPU cache maintenance and system-counter access are now conditionally compiled for AArch64. Non-AArch64 builds use no-op cache functions and ChangesAICPU architecture handling
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces platform-specific preprocessor guards for aarch64 architectures in cache_ops.cpp and device_time.cpp, providing fallback implementations for non-aarch64 platforms. A review comment suggests improving the fallback for get_sys_cnt_aicpu() by returning device_time_now_ticks() instead of a constant 0 to avoid potential infinite loops or hangs in timeout polling logic.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| #else | ||
| uint64_t get_sys_cnt_aicpu() { return 0; } | ||
| #endif |
There was a problem hiding this comment.
Returning a constant 0 in the x86 fallback stub can lead to infinite loops or hangs if any calling code uses get_sys_cnt_aicpu() for timeout polling (e.g., while (get_sys_cnt_aicpu() - start < timeout)). Since device_time_now_ticks() is already defined in aicpu/device_time.h and provides a proper monotonic clock fallback on non-aarch64 platforms, we should use it here to ensure robustness and prevent potential hangs during testing or simulation.
#else
uint64_t get_sys_cnt_aicpu() { return device_time_now_ticks(); }
#endifInstead of returning 0 in the x86_64 fallback (which could cause
infinite loops in timeout polling code), use device_time_now_ticks()
which provides a proper monotonic clock based on std::chrono::steady_clock.
Addresses review feedback about potential hangs in code like:
while (get_sys_cnt_aicpu() - start < timeout) { ... }
device_time_now_ticks() already handles the platform split correctly:
- aarch64: reads CNTVCT_EL0 hardware counter
- x86_64: returns nanoseconds from steady_clock
Problem
CI fails on x86_64 runners when compiling a2a3 hostbuild because files in
src/common/platform/onboard/aicpu/contain ARM64-specific inline assembly instructions that cannot be compiled on x86_64:Solution
Add
#if defined(__aarch64__)guards around ARM64 inline assembly:dc civac,dc cvac,dsb,isb)mrs cntvct_el0instructionNotes
cddf2b6c) worked around this issue by CI configuration (x86 runners skip compilation of ARM64 code), but that only fixes CI, not the code itself