Skip to content

Enable return address signing on ARM fully: drop the SimSIMD and compiler-rt exclusions - #131996

Merged
Algunenano merged 4 commits into
ClickHouse:masterfrom
Algunenano:pac-ret-simsimd-fix
Nov 17, 2026
Merged

Algunenano merged 4 commits into
ClickHouse:masterfrom
Algunenano:pac-ret-simsimd-fix

Conversation

@Algunenano

@Algunenano Algunenano commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

#131784 enabled -mbranch-protection=pac-ret on ARM. To avoid retaa (SIGILL on cores without FEAT_PAuth, such as Graviton2 and Ampere Altra), it turned off branch protection in the SimSIMD functions compiled for ARMv8.3 or later. It also didn't cover compiler-rt. This PR removes both exclusions:

  • SimSIMD is bumped to Keep ARMv8.3+ code out of SimSIMD instead of disabling branch protection SimSIMD#33, which fixes the root cause instead of disabling protection. The CPU probe reads ID_AA64ZFR0_EL1 by its encoding, so it doesn't need arch=armv8.5-a+sve. The bf16 kernels use +simd+bf16 / +sve+sve2+bf16 instead of arch=armv8.6-a+.... Nothing is compiled for ARMv8.3 or later anymore, and all of its functions are signed. The bump also brings Cache each dispatched kernel with its exact type SimSIMD#30.
  • compiler-rt: contrib/compiler-rt-cmake keeps only an allowlist of the inherited flags, and that allowlist dropped -mbranch-protection. The builtins and the XRay runtime are linked into the release binary, so their return addresses were unsigned. Now every compile command of the arm_release build has the flag. Only hand-written assembly stays unsigned: the XRay trampolines and the __emupac_* wrappers.
  • Comments and checks from Enable -mbranch-protection=pac-ret on ARM, except for SimSIMD #131784 are simplified: the comment in CMakeLists.txt goes from ~70 lines to 7. The compatibility check still fails the arm_release package on any retaa/retab, in ~20 lines.

Verification, on a build with the arm_release cmake flags (ThinLTO, clang-22):

  • Link: no -Wpass-failed.
  • Full disassembly: no PAuth instruction outside the HINT space. The new check passes on this binary in ~2 s and fails on a binary containing retaa.
  • Native Neoverse N1 (Graviton2, no FEAT_PAuth):
    • clickhouse local builds a bf16 HNSW vector index and computes the distance functions correctly. That exercises the SimSIMD probe and dispatch, where the binary from Build the CI toolchain with jemalloc 5.4.0 using transparent huge pages #131745 raised SIGILL.
    • The server starts and shuts down cleanly.
    • Exception stack traces, system.stack_trace and the query profiler (system.trace_log) all symbolize correctly.
    • A control binary containing retaa dies with SIGILL on the same machine.
  • Neoverse V2: the same queries pass.

Related: #131784
Related: #131748
Related: #131765
Related: ClickHouse/SimSIMD#33
Related: ClickHouse/SimSIMD#32

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Sign return addresses on ARM also in SimSIMD and compiler-rt, which were previously excluded. The binary still runs on cores without pointer authentication, such as Graviton2.


Workflow [PR]
Sync PR [sync-upstream/pr/131996]

Version info

  • Merged into: 26.11.1.2508-master (included in 26.11 and later)

Algunenano and others added 4 commits November 16, 2026 12:22
…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]>
With `SimSIMD` no longer compiled for ARMv8.3 or later, the long explanation of the exclusions is
not needed. Keep only what a reader needs: why the flag is safe on cores without `FEAT_PAuth`, the
rule that no code may be compiled for ARMv8.3 or later, and why sanitizer builds are excluded.
Scan the executable sections of the binary for the two fixed encodings and report the count,
without `mmap` and without naming the functions through `system.symbols`.
`contrib/compiler-rt-cmake` keeps only an allowlist of the inherited flags, which dropped
`-mbranch-protection=pac-ret`, so the builtins and the `XRay` runtime linked into the release
binary had unsigned return addresses. Keep the flag. Now all compile commands of the
`arm_release` build have it; only the hand-written assembly in `compiler-rt` (the `XRay`
trampolines and the `__emupac_*` wrappers) stays unsigned.
@clickhouse-gh

clickhouse-gh Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0c5771b]

Summary: ✅


AI Review

Summary

PR #131996, reviewed at 0c5771b65d8d08a8a26a9906d35f37981b5f1c7c, extends ARM return address signing to SimSIMD and compiler-rt, removes the SimSIMD architecture bumps that generated incompatible returns, and simplifies the packaged instruction check. No actionable findings.

Missing context / blind spots
  • ⚠️ A full build and runtime tests were not run locally. The PR describes native validation on Neoverse N1 and V2, including a failing retaa control binary. The current Build (arm_release) and Compatibility check (arm_release) results are still pending in the underlying Praktika report; successful results will close validation of the packaged artifact.
Final Verdict

✅ Approve. No unresolved code findings; normal ARM CI validation remains pending.

@clickhouse-gh clickhouse-gh Bot added pr-build Pull request with build/testing/packaging improvement submodule changed At least one submodule changed in this PR. comp-build-system Build system (CMake, compilation, platform builds). labels Nov 16, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 0c5771b65 with master 68d5b2e0a (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

11 translation units recompiled, 78 s compile time in total, 11 of them have a recent master baseline.

Job report

@Algunenano
Algunenano enabled auto-merge November 16, 2026 17:53
@Algunenano
Algunenano added this pull request to the merge queue Nov 16, 2026
Merged via the queue into ClickHouse:master with commit 5c2375b Nov 17, 2026
198 checks passed
@Algunenano
Algunenano deleted the pac-ret-simsimd-fix branch November 17, 2026 01:37
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-build-system Build system (CMake, compilation, platform builds). pr-build Pull request with build/testing/packaging improvement pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants