Skip to content

Drop .llvm_addrsig in localize_rust_c_symbols.sh so clang-21 builds link - #130174

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/localize-rust-drop-llvm-addrsig
Nov 8, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/localize-rust-drop-llvm-addrsig

Conversation

@groeneai

@groeneai groeneai commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #130064
Related: #126478
Related: #122904

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

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

Building with clang/lld 21, the minimum supported compiler, no longer fails at the final clickhouse link: cmake/localize_rust_c_symbols.sh now removes the .llvm_addrsig sections that objcopy invalidates, as cmake/strip_rust_symbols.sh already does.

Description

A default build with clang/lld 21.1.8 (cmake -G Ninja -DCMAKE_C_COMPILER=clang-21 -DCMAKE_CXX_COMPILER=clang++-21, RelWithDebInfo, CMAKE_OBJCOPY=llvm-objcopy-21) fails on master:

ld.lld-21: error: rust/workspace/lib_ch_rust_skim_rust.a(c16f17691ff6f04b-cxx.o): --icf=safe conservatively ignores SHT_LLVM_ADDRSIG [index 1337] with sh_link=0 (likely created using objcopy or ld -r)

and the same for 885040bead2806a0-lib.rs.o. clang-21 puts the C++ exception glue (DW.ref.__gxx_personality_v0, __clang_call_terminate) into llvm-libc's memmem.cpp.o (clang-22 does not, with the same flags), so these weak symbols join the localize set. The cxx-bridge objects of skim define them too, and when llvm-objcopy localizes them it sets sh_link of their .llvm_addrsig to 0; --fatal-warnings turns lld's warning into an error. CI (clang-22) is not affected.

The patch removes the section in both objcopy calls of the script. lld then treats these objects conservatively, as it does when it ignores the table. Patch by @ snelheidai from #130064.

Validation, master vs this PR: the clang-21 build fails / links (no .llvm_addrsig left in the 8 localized archives, localization unchanged, clickhouse local runs), and the clang-22 Debug build links both ways. The price is +19 KB of .text (+0.003%) in the clang-22 Debug build and +128 bytes in the clang-21 RelWithDebInfo build.

#126478 is independent and still needed: with GNU objcopy this patch removes the addrsig errors too, but the link then fails on relocation refers to a symbol in a discarded section (DW.ref.rust_eh_personality, __clang_call_terminate), which master already has behind the addrsig errors (measured with clang-21) and which selecting the LLVM objcopy avoids.


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

Version info

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

With clang/lld 21 (the minimum supported version), a default build fails
at the final link of clickhouse:

  ld.lld-21: error: rust/workspace/lib_ch_rust_skim_rust.a(c16f17691ff6f04b-cxx.o):
  --icf=safe conservatively ignores SHT_LLVM_ADDRSIG [index 1337] with sh_link=0
  (likely created using objcopy or ld -r)

and the same for 885040bead2806a0-lib.rs.o (the cxx bridge of skim).

clang-21 emits the C++ exception glue (DW.ref.__gxx_personality_v0,
__clang_call_terminate) into llvm-libc's memmem.cpp.o; clang-22 does not
with the same flags. These two weak symbols are then in the reference set
of localize_rust_c_symbols.sh, the cxx bridge objects define them too, so
llvm-objcopy-21 localizes them there. Rewriting the symbol table makes
the non-empty .llvm_addrsig table stale and objcopy sets its sh_link to 0,
which lld --icf=safe reports, and --fatal-warnings turns into an error.
GNU objcopy zeroes sh_link on every table it rewrites.

Remove the section in both objcopy calls of the script, as
strip_rust_symbols.sh already does (ClickHouse#122904). lld then treats these
objects conservatively, as it does when it ignores the table.

Patch by @ snelheidai in ClickHouse#130064.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

groeneai commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (1 nit).

# Sev Finding Verdict Evidence / action
1 💡 Dropping .llvm_addrsig from every member of a localized archive also discards tables that llvm-objcopy left valid, so --icf=safe cannot fold those C/C++ members (cmake/localize_rust_c_symbols.sh:131,136) AGREE, not blocking Needed anyway for GNU objcopy, which zeroes every table it rewrites; same as cmake/strip_rust_symbols.sh (#122904). Measured price: +19,328 bytes .text (+0.0027%) in a clang-22 Debug build, +128 bytes in clang-21 RelWithDebInfo.

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-10:20261108-161900

@groeneai

groeneai commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. cmake -G Ninja -DCMAKE_C_COMPILER=clang-21 -DCMAKE_CXX_COMPILER=clang++-21 (RelWithDebInfo, llvm-objcopy-21, ld.lld-21 21.1.8) + ninja clickhouse on master fails 2/2 with --icf=safe conservatively ignores SHT_LLVM_ADDRSIG ... sh_link=0 on lib_ch_rust_skim_rust.a(c16f17691ff6f04b-cxx.o) and (885040bead2806a0-lib.rs.o). llvm-readobj --sections on the localized archive: 39 tables, 2 with Link: 0.
b Root cause explained? clang-21 emits DW.ref.__gxx_personality_v0 / __clang_call_terminate into llvm-libc's memmem.cpp.o (clang-22 does not, same flags), so they enter the localize set; the cxx-bridge objects define them, llvm-objcopy rewrites their symbol table and sets sh_link of the non-empty .llvm_addrsig to 0; --fatal-warnings makes lld's warning an error.
c Fix matches root cause? Yes. The script that invalidates the table now removes it, as strip_rust_symbols.sh does (#122904). No --no-fatal-warnings or --icf change.
d Test intent preserved / new tests added? No in-tree test: build-script change with no test harness for cmake/*.sh; validated by local builds and the PR's CI build jobs. No existing test touched.
e Both directions demonstrated? Yes. clang-21: master RC=1 (2 errors), patch RC=0 (0 diagnostics, 0 tables left, clickhouse local runs). clang-22 Debug links both ways. Forced per-member fallback path: master script 2 zeroed, patched 0 tables.
f Fix is general across code paths? Yes. Both objcopy calls (archive fast path and per-member fallback) are changed and were exercised; the strip script already drops the section; nothing else rewrites link inputs in place.
g Fix generalizes across inputs (params/datatypes/wrappers)? Checked with llvm-objcopy-21 and GNU objcopy, clang-21 RelWithDebInfo and clang-22 Debug, all 8 Rust archives (removing an absent section is a no-op). With GNU objcopy a separate pre-existing COMDAT error remains, which #126478 avoids.
h Backward compatible? (maintainer-approved exception only) Yes. No settings or formats; only .llvm_addrsig of Rust-archive members changes. Cost: +19 KB .text (clang-22 Debug), +128 bytes (clang-21 RelWithDebInfo).
i Invariants and contracts preserved? Yes. Same localized symbol set, all 620 skim members kept, localized symbols still local; a table is now either valid or absent, never stale, and lld folds objects without one conservatively.

Session id: cron:clickhouse-impl-slot-5:20261108-141000

@groeneai

groeneai commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

cc @thevar1able @pamarcos, could you review this and add the can be tested label so CI runs? With clang-21, llvm-objcopy localizes the C++ EH glue symbols in the skim cxx-bridge objects and leaves their .llvm_addrsig with sh_link=0, which lld --icf=safe --fatal-warnings rejects; the script now removes that section in both objcopy calls, as strip_rust_symbols.sh already does.

@clickhouse-gh

clickhouse-gh Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [385c54f]

Summary: ✅


AI Review

Summary

Reviewed #130174 at 385c54fada7622ab0be17ec2a1f0a356dc1ea140. Both objcopy paths now remove .llvm_addrsig when localizing symbols. Removing this optional table preserves conservative address handling under the LLVM contract. Consumers checked include archive repacking, the downstream partial-link/strip pipeline, and the final lld link; each accepts an absent table. No actionable findings. Nine focused GNU-binutils cases passed, covering both paths, inputs with and without the section, repeated processing, symbol/member preservation, linked runtime behavior, and an empty localization set.

Missing context / blind spots
  • ⚠️ This environment has no LLVM toolchain, so the full clang/lld-21 regression was not independently reproduced. The author's validation records before/after clang-21 builds, clang-22 builds, both processing paths, and binary-size measurements; the local fixture verifies archive processing with GNU binutils.
Final Verdict

✅ Approve. No new inline findings to post.

@clickhouse-gh clickhouse-gh Bot added pr-build Pull request with build/testing/packaging improvement can be tested Allows running workflows for external contributors manual approve Manual approve required to run CI labels Nov 8, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-build-system Build system (CMake, compilation, platform builds). label Nov 8, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 385c54fad with master 5b46d2537 (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

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

Job report

@alexey-milovidov alexey-milovidov self-assigned this Nov 8, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 8, 2026
Merged via the queue into ClickHouse:master with commit 5d6ef30 Nov 8, 2026
376 of 377 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-build-system Build system (CMake, compilation, platform builds). manual approve Manual approve required to run CI pr-build Pull request with build/testing/packaging improvement pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants