Repository navigation
Use the resolved LLVM objcopy for the Rust symbol scripts - #126478
Conversation
`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.
|
Workflow [PR], commit [df2a743] Summary: ✅
AI ReviewSummaryThe PR assigns the resolved Final VerdictStatus: ✅ Approve |
|
Independently hit this on vanilla Debian 12 and Ubuntu 24.04 (clang/lld from apt.llvm.org, binutils installed): plus Verified with this patch applied: a fresh configure generates |
cmake/tools.cmakeresolvesobjcopyintoOBJCOPY_PATH(LLVM first, GNU binutils as a fallback) and already overridesCMAKE_ARandCMAKE_RANLIBwith the LLVM tools, but it never overridesCMAKE_OBJCOPY. The Rust symbol post-processing scripts (localize_rust_c_symbols.shfromcontrib/corrosion-cmake/CMakeLists.txt,strip_rust_symbols.shfromcontrib/rust-contrib-workspace/CMakeLists.txt) are invoked with${CMAKE_OBJCOPY}, so they get whateverobjcopyCMake detected during compiler detection (GNU binutils on many Linux distributions), even though both scripts expect the LLVM toolchain. This setsCMAKE_OBJCOPYto the resolvedOBJCOPY_PATH, so all callers use the sameobjcopy.The link error that originally motivated this (
--icf=safe conservatively ignores SHT_LLVM_ADDRSIG [...] with sh_link=0with GNUobjcopy) is already fixed in master by dropping.llvm_addrsiginlocalize_rust_c_symbols.sh, so this is now a consistency fix.Related: #130174
Related: #122904
Related: #101081
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Use the resolved LLVM
objcopyin the Rust symbol post-processing scripts instead of theobjcopydetected by CMake.Workflow [PR]
Sync PR [sync-upstream/pr/126478]
Version info
26.11.1.2899-master(included in26.11and later)