Repository navigation
Enable -mbranch-protection=pac-ret on ARM, except for SimSIMD - #131784
Conversation
|
Workflow [PR], commit [643cefd] Summary: ✅
AI ReviewSummaryPR #131784, reviewed at Missing context / blind spots
Final Verdict✅ Approve. No unresolved code findings; the normal ARM CI checks still need to complete. |
#119685 was reverted in #131765 because the `arm_release` binary died with SIGILL on cores without `FEAT_PAuth` (Graviton2, Ampere Altra) on the first SimSIMD call: SimSIMD compiles its CPU probe `_simsimd_capabilities_arm` and five bf16 NEON kernels for ARMv8.3+, where clang folds `autiasp; ret` into `retaa`, which is not in the `NOP` space. Build `_simsimd` with `-mbranch-protection=none` (the same fix as #131762). Compiled with the `arm_release` flags, `c/lib.c` goes from 7 `retaa` to 0. Add a check to the `arm_release` compatibility check that scans the code sections of the packaged binary for `retaa` and `retab` and names the functions through `system.symbols`. A test run on Graviton3 would never notice the next such case. On the `arm_release` package of #131745 (pac-ret on) it reports exactly the 6 SimSIMD functions; on that of d88a8f1 (the master commit before #119685) it passes. Closes: #131748 Related: #131762 Related: #131765 Co-Authored-By: Claude Opus 5.5 <[email protected]>
-mbranch-protection=pac-ret on ARM""-mbranch-protection=pac-ret on ARM, except for SimSIMD
Building all of `_simsimd` with `-mbranch-protection=none` broke the `arm_release` link: a callee whose branch protection differs from the caller's is not inlined, so ThinLTO stopped inlining `simsimd_bf16_to_f32` from `c/lib.c` into the `vectorize(enable)` loops of usearch, and `-Wpass-failed` turned "loop not vectorized" into a link error (also in #131762). Reproduced with a two-file ThinLTO example on clang 21. Revert that and bump `contrib/SimSIMD` to ClickHouse/SimSIMD@7cd5fbe8bb08 (branch `pac-ret-no-retaa`, on top of the previous pin e81e1c2de244), which adds `branch-protection=none` to the ARMv8.3+ targets only: the CPU probe (`arch=armv8.5-a+sve`) and the bf16 kernels (`arch=armv8.6-a+...`). Compiled with the `arm_release` flags plus `pac-ret`, `c/lib.c` has 0 `retaa` (7 before) and 102 signed functions (109 before). CI report: https://github.com/ClickHouse/ClickHouse/actions/runs/43723362796/job/132846622615 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. The official master build is compiled with Compile time of recompiled translation units21 translation units recompiled, 214 s compile time in total, 21 of them have a recent master baseline. |
|
@groeneai, send PRs to SIMSIMD upstream. |
|
I've merged the submodule PR. |
|
Acknowledged. I'm checking which ClickHouse/SimSIMD fork fixes (including the merged ClickHouse/SimSIMD#32) are still missing in upstream |
|
I checked every fix of the
For #128293, which moves to unpatched v7.8.6: built the way its |
…h protection Bumps `contrib/SimSIMD` to the merge of ClickHouse/SimSIMD#33. The CPU probe `_simsimd_capabilities_arm` reads `ID_AA64ZFR0_EL1` by its encoding instead of being compiled for `arch=armv8.5-a+sve`, and the bf16 kernels use `+simd+bf16` / `+sve+sve2+bf16` instead of `arch=armv8.6-a+...`. Nothing in `SimSIMD` is compiled for ARMv8.3 or later anymore, so it no longer needs `branch-protection=none` and all of its functions are signed under `-mbranch-protection=pac-ret`, without `retaa` that would raise SIGILL on cores without `FEAT_PAuth`. The bump also brings ClickHouse/SimSIMD#30 (typed kernel dispatch). Related: ClickHouse/SimSIMD#33 Related: ClickHouse#131748 Related: ClickHouse#131784 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Re-lands #119685 (
-mbranch-protection=pac-reton ARM), which was reverted in #131765 because the binary died with SIGILL on cores withoutFEAT_PAuth(Graviton2, Ampere Altra) on the first SimSIMD call.The cause: SimSIMD compiles its CPU probe
_simsimd_capabilities_armand five bf16 NEON kernels for ARMv8.3+ (target("arch=armv8.5-a+sve")and the like), and in such functions clang foldsautiasp; retintoretaa, which, unlikepaciasp/autiasp, is not in theNOPspace. This PR adds on top of the original change:contrib/SimSIMDis bumped to ClickHouse/SimSIMD@7cd5fbe8bb08 (Do not sign return addresses in functions built for ARMv8.3 and later SimSIMD#32, on top of the previous pin), which addsbranch-protection=noneto the ARMv8.3+ targets only. With thearm_releaseflags,c/lib.cgoes from 7retaato 0, and 102 of its 109 signed functions stay signed. Opting out all of_simsimdwith-mbranch-protection=none, as Fix SIGILL in the SimSIMD CPU probe on AArch64 cores without PAuth #131762 does, fails thearm_releaselink: a callee with different branch protection is not inlined, so ThinLTO no longer inlinessimsimd_bf16_to_f32into usearch'svectorize(enable)loops and-Wpass-failederrors out.arm_releasecompatibility check scans the code sections of the packaged binary forretaa/retaband names the functions throughsystem.symbols, because a test run on Graviton3 would never notice the next case. On thearm_releasepackage of Build the CI toolchain with jemalloc 5.4.0 using transparent huge pages #131745 (pac-ret on, no fix) it fails with exactly the 6 SimSIMD functions found in Revert "Enable-mbranch-protection=pac-reton ARM" #131765; on the package of d88a8f1 (master before Enable-mbranch-protection=pac-reton ARM #119685) it passes.Closes: #131748
Related: #119685
Related: #131765
Related: #131762
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Build the
CandC++code of the ARM binaries with-mbranch-protection=pac-ret, which signs the return address so that overwriting it on the stack cannot redirect control flow. Code compiled for ARMv8.3 and later (SimSIMD) is excluded, so the binary still runs on cores without pointer authentication. Sanitizer builds are excluded, because the sanitizer runtimes do not strip the signature when they unwind.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/131784]
Version info
26.11.1.2377-master(included in26.11and later)