Repository navigation
Use the linker and LLVM tools from the compiler's own toolchain - #130659
Conversation
`ch_find_program` was a plain `find_program` with the versioned name first
(`ld.lld-22`, then `ld.lld`). `find_program` tries each name over all of PATH
before the next one, so a versioned tool anywhere in PATH wins over an
unversioned one in the compiler's own directory.
The CI build image compiles with its own PGO-optimized LLVM toolchain in
/usr/local/bin, which ships unversioned tool names only, while apt's lld-22
and llvm-22 put versioned names into /usr/bin. So CI compiled with the
toolchain's clang but linked, archived and stripped with the apt tools
("Using linker: /usr/bin/ld.lld-22" in the amd_release and arm_release
logs). In a ThinLTO build the optimizer and code generator run inside the
linker, so the release links ran on an lld built without PGO.
Search the compiler's directory first, then fall back to the previous search.
The Rust partial links in contrib/{prql,polyglot,pcodec,vortex}-cmake, which
had their own copy of the ld.lld lookup, use the same macro. Both are LLVM
22.1.8 from the same commit. Measured with the amd_release PR configuration
(-g0, ThinLTO, 16 pinned cores, the same objects, 4 runs each): the
`clickhouse` link takes 830 s instead of 1015 s (-18%), user CPU -16%, peak
RSS unchanged at 19 GiB, and the output is identical except `.comment` and the
build ID.
A build with an apt compiler from /usr/bin is unchanged: the versioned tools
are found in that directory first. `-DLINKER_NAME` still takes precedence. The
header of utils/download-ci-toolchain.sh, which keeps only the compiler, no
longer claims that CI uses the installed tools.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review (click to expand)
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20261109-141000 |
|
Workflow [PR], commit [ece1001] Summary: ✅
AI ReviewSummaryThe PR prefers tools beside the C++ compiler and applies the same lookup to the four Rust partial-link steps, allowing CI to use its PGO-optimized LLVM linker. No actionable findings at Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested; remaining CI results should be checked before merging. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline. |
48f9d3b
Related: #130064
Related: #130239
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
CMake now looks for
ld.lld,llvm-ar,llvm-objcopyand the other LLVM tools in the compiler's directory before searchingPATH, so a build with a self-contained LLVM toolchain uses that toolchain's linker. CI release builds now link with the PGO-optimizedlldof the CI toolchain, which makes the ThinLTO link ofclickhouseabout 18% faster.Description
CI compiles with its own PGO-optimized LLVM 22.1.8 toolchain in
/usr/local/bin, but links with apt'slld-22: masterBuild (amd_release)andBuild (arm_release)logs showUsing linker: /usr/bin/ld.lld-22, and the other LLVM tools come from/usr/bin.ch_find_programpasses the versioned name first (ld.lld-22, thenld.lld),find_programtries each name over all ofPATHbefore the next one, and the toolchain ships only unversioned names. In a ThinLTO build the optimizer and code generator run inside lld, so release links ran on apt's dynamically linked lld, built without PGO.ch_find_programnow searches the compiler's directory first and falls back to the previous search. The Rust partial links incontrib/{prql,polyglot,pcodec,vortex}-cmakenow usech_find_programtoo. Both linkers are LLVM 22.1.8 from the same commit.Measured with the
amd_releasePR configuration (no debug info, ThinLTO, 16 pinned cores, same objects, 4 runs each): theclickhouselink takes 830 s instead of 1015 s (-18%), peak RSS unchanged at 19 GiB. On ARM anarm_release-like link was reported 22% faster (#130064). The binaries differ only in.commentand the build ID, so PIE, RELRO,BIND_NOWand the non-executable stack are unchanged.Configured before and after: an apt compiler from
/usr/binand a compiler in a directory without tools keep their tools,-DLINKER_NAMEstill selects the linker, and the aarch64 cross build and the clang-tidy configuration switch to the toolchain's tools. Tools in the compiler's directory now win over tools elsewhere inPATH, even another LLVM version or GNUobjcopy/nm/strip.CMAKE_OBJCOPY, CMake's own lookup that the Rust symbol scripts take, is left to #126478.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/130659]
Version info
26.11.1.1923-master(included in26.11and later)