Skip to content

Use the resolved LLVM objcopy for the Rust symbol scripts - #126478

Merged
Algunenano merged 1 commit into
ClickHouse:masterfrom
oleg-milanov:fix-llvm-objcopy-for-rust-scripts
Nov 19, 2026
Merged

Algunenano merged 1 commit into
ClickHouse:masterfrom
oleg-milanov:fix-llvm-objcopy-for-rust-scripts

Conversation

@oleg-milanov

@oleg-milanov oleg-milanov commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

cmake/tools.cmake resolves objcopy into OBJCOPY_PATH (LLVM first, GNU binutils as a fallback) and already overrides CMAKE_AR and CMAKE_RANLIB with the LLVM tools, but it never overrides CMAKE_OBJCOPY. The Rust symbol post-processing scripts (localize_rust_c_symbols.sh from contrib/corrosion-cmake/CMakeLists.txt, strip_rust_symbols.sh from contrib/rust-contrib-workspace/CMakeLists.txt) are invoked with ${CMAKE_OBJCOPY}, so they get whatever objcopy CMake detected during compiler detection (GNU binutils on many Linux distributions), even though both scripts expect the LLVM toolchain. This sets CMAKE_OBJCOPY to the resolved OBJCOPY_PATH, so all callers use the same objcopy.

The link error that originally motivated this (--icf=safe conservatively ignores SHT_LLVM_ADDRSIG [...] with sh_link=0 with GNU objcopy) is already fixed in master by dropping .llvm_addrsig in localize_rust_c_symbols.sh, so this is now a consistency fix.

Related: #130174
Related: #122904
Related: #101081

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

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

Use the resolved LLVM objcopy in the Rust symbol post-processing scripts instead of the objcopy detected by CMake.


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

Version info

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

`cmake/tools.cmake` resolves `llvm-nm`, `llvm-ar` and `llvm-objcopy` with `ch_find_program`
(LLVM first, GNU binutils as a fallback) and overrides `CMAKE_AR` and `CMAKE_RANLIB` with the
LLVM tools, but it never overrides `CMAKE_OBJCOPY` - which is the variable the Rust symbol
post-processing scripts actually receive. The scripts document that the tools must come from a
compatible LLVM toolchain, but `CMAKE_OBJCOPY` is whatever CMake detected during compiler
detection, i.e. GNU binutils on Linux distributions.

With GNU objcopy the localized Rust libraries end up with an `SHT_LLVM_ADDRSIG` section whose
`sh_link` is 0. The link uses `--icf=safe` together with `-Wl,--fatal-warnings`, so that warning
turns into an error at the final link:

    ld.lld-21: error: contrib/chdig-cmake/libchdig.a(e509d2bf2c02fe94-city.o): --icf=safe
    conservatively ignores SHT_LLVM_ADDRSIG [index 29] with sh_link=0 (likely created using
    objcopy or ld -r)

Set `CMAKE_OBJCOPY` from the resolved `OBJCOPY_PATH`, consistent with `CMAKE_AR` and
`CMAKE_RANLIB`, so the scripts get the LLVM objcopy they require.

Verified on current master: with GNU objcopy the final link of `programs/clickhouse` fails with
23 such errors (from `libchdig` and the wasmtime/prql/polyglot/pco/skim Rust libraries); with
this change the same build links successfully.
@clickhouse-gh clickhouse-gh Bot added the comp-build-system Build system (CMake, compilation, platform builds). label Oct 17, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 18, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [df2a743]

Summary: ✅


AI Review

Summary

The PR assigns the resolved OBJCOPY_PATH to CMAKE_OBJCOPY, ensuring Rust symbol localization and stripping use the selected tool. No actionable defects found. The author's before/after link reproduction provides focused evidence for this build fix.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-build Pull request with build/testing/packaging improvement external Author is not a member of the ClickHouse organization labels Oct 18, 2026
@yackushevas

Copy link
Copy Markdown
Contributor

Independently hit this on vanilla Debian 12 and Ubuntu 24.04 (clang/lld from apt.llvm.org, binutils installed): cmake/tools.cmake resolves OBJCOPY_PATH to llvm-objcopy but CMAKE_OBJCOPY stays GNU, contrib/corrosion-cmake passes it to localize_rust_c_symbols.sh, and the final link with -Wl,--icf=safe -Wl,--fatal-warnings fails with e.g.

ld.lld: error: contrib/chdig-cmake/libchdig.a(...): --icf=safe conservatively ignores SHT_LLVM_ADDRSIG [index 10] with sh_link=0 (likely created using objcopy or ld -r)

plus relocation refers to a symbol in a discarded section on other Rust archives.

Verified with this patch applied: a fresh configure generates localize_rust_c_symbols.sh … /usr/bin/llvm-ar-22 /usr/bin/llvm-objcopy-22 (and the same for strip_rust_symbols.sh), and the tree links cleanly. Would be great to see this merged — the failure mode is quite obscure outside the CI images.

@Algunenano
Algunenano added this pull request to the merge queue Nov 19, 2026
Merged via the queue into ClickHouse:master with commit 36e4cb0 Nov 19, 2026
179 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 19, 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). external Author is not a member of the ClickHouse organization 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.

5 participants