Skip to content

Build the toolchain with zlib so clang supports -gz - #109596

Merged
murphy-4o merged 8 commits into
ClickHouse:masterfrom
murphy-4o:toolchain-enable-zlib
Jul 8, 2026
Merged

murphy-4o merged 8 commits into
ClickHouse:masterfrom
murphy-4o:toolchain-enable-zlib

Conversation

@murphy-4o

@murphy-4o murphy-4o commented Jul 7, 2026 •

Copy link
Copy Markdown
Member

The bundled LLVM toolchain is built with LLVM_ENABLE_ZLIB=OFF, so its clang can't do -gz=zlib. Enable zlib (FORCE_ON) for the stage-2 (shipped) clang and add zlib1g-dev to the binary-builder image, so #109306's COMPRESS_DEBUG_SECTIONS auto-detects support and compresses object-file debug sections in CI and default builds (objects ≈ −50%, build dir ≈ −26%; binaries left uncompressed, so symbolization is unaffected).

Also fixes a compiler-mismatch bug that #109306 surfaced. LLVM installs the versioned clang-21 plus unversioned clang++ → clang → clang-21, but no versioned clang++-21. Since ClickHouse selects compilers by versioned name, CMake finds this toolchain's clang-21 for C/ASM but falls through PATH to a different clang++-21 (the distro's) for C++ — so C and C++ are compiled by two different clang installs. It's normally invisible (both report Clang 21.1.8; only the resolved paths /usr/local/bin/clang-21 vs /usr/bin/clang++-21 differ), and -gz only exposed it because one of the pair had zlib and the other didn't. Symlink clang++-21 → clang before packaging so C and C++ resolve to the same toolchain.

Stage 1 (the instrumented clang used for PGO profile collection) is also built with zlib, so the profile-collection build compiles with -gz and the resulting PGO profile covers those code paths.

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

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

Built the bundled LLVM toolchain with zlib so the shipped clang accepts -gz=zlib (compressed DWARF debug sections), and added the missing clang++-21 symlink so the toolchain's C and C++ compilers are the same install.

Version info

  • Merged into: 26.7.1.644 (included in 26.7 and later)

… sections)

The bundled LLVM toolchain is built LLVM_ENABLE_ZLIB=OFF, so its clang rejects
-gz=zlib. Enable zlib for the stage-2 (shipped) clang and add zlib1g-dev to the
binary-builder image so LLVM finds it. This lets COMPRESS_DEBUG_SECTIONS (root
CMakeLists) auto-detect support and compress object-file debug sections in CI
and standard dev builds, not only with a zlib-enabled system clang.

Stage 1 (instrumented, profile-generation only) is left without zlib.

Co-Authored-By: Claude <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b033f8b]

Summary: ✅


AI Review

Summary

This PR updates the build_toolchain.py recipe to require zlib in both LLVM stages, adds zlib1g-dev to the binary-builder image, and packages the missing clang++-21 symlink. The implementation itself looks reasonable, but the branch still does not roll the bundled toolchain artifact that CI/default builds actually consume, so the title/body/changelog overstate the user-visible effect of merging this PR.

Findings

⚠️ Majors

  • [ci/docker/binary-builder/Dockerfile:48-57] [dismissed by author -- https://github.com/Build the toolchain with zlib so clang supports -gz #109596#discussion_r3533442668] The PR contract says the bundled/shipped clang now accepts -gz=zlib and that C/C++ resolve to the same toolchain install, but the image still downloads the old prebuilt toolchain from TOOLCHAIN_COMMIT=19da6af712ebc2678cc34b8f2f4251e8056766ba here. Until this SHA is advanced to an artifact built from the new recipe, CI and default builds keep using the old compiler, so #109306 is not actually fixed by this merge. Suggested fix: either update TOOLCHAIN_COMMIT in the same PR, or narrow the title/body/changelog so they explicitly say this only prepares the next toolchain rebuild.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required action: either ship the rebuilt toolchain in this PR by updating TOOLCHAIN_COMMIT, or rewrite the PR title/body/changelog so they no longer claim the shipped/default compiler is fixed yet.

@clickhouse-gh clickhouse-gh Bot added the pr-build Pull request with build/testing/packaging improvement label Jul 7, 2026
Comment thread ci/jobs/build_toolchain.py Resolved
LLVM_ENABLE_ZLIB=ON is best-effort - if zlib is not found it silently
disables and the build still succeeds, producing a clang without -gz
support. FORCE_ON errors at configure instead, so we cannot publish a
toolchain that claims -gz support it does not have.

Co-Authored-By: Claude <[email protected]>
Comment thread ci/jobs/build_toolchain.py Resolved
@murphy-4o
murphy-4o marked this pull request as ready for review July 7, 2026 04:57
@murphy-4o
murphy-4o marked this pull request as draft July 7, 2026 07:11
LLVM installs the versioned clang-21 and the unversioned clang++ (-> clang ->
clang-21), but no versioned clang++-21. Since ClickHouse selects compilers by
versioned name, CMake finds this toolchain's clang-21 for C/ASM but falls
through PATH to a different clang++-21 (e.g. the distro's) for C++ - a silent
mismatch (it caused tidy builds to pair a zlib-less clang with a zlib-enabled
clang++). Symlink clang++-21 -> clang before packaging so both resolve here.

Co-Authored-By: Claude <[email protected]>
Comment thread ci/jobs/build_toolchain.py Resolved
Comment thread ci/docker/binary-builder/Dockerfile Resolved
@murphy-4o
murphy-4o marked this pull request as ready for review July 7, 2026 11:41
@azat azat self-assigned this Jul 7, 2026
Comment thread ci/jobs/build_toolchain.py Resolved
@murphy-4o murphy-4o changed the title Build the toolchain with zlib so clang supports -gz (compressed debug sections) Build the toolchain with zlib so clang supports -gz Jul 8, 2026
murphy-4o and others added 5 commits July 8, 2026 10:35
Reviewer nit (azat): use the shorter name, matching clangpp_inst above.

Co-Authored-By: Claude <[email protected]>
build_toolchain.py now needs zlib1g-dev from ci/docker/binary-builder, but
the Build Toolchain job's cache digest hashed only build_toolchain.py, so a
Dockerfile-only change could skip the one job that validates the toolchain
still configures in its real container. Add the image dir to include_paths
(same pattern other jobs use for their docker dirs) so image changes re-run it.

Co-Authored-By: Claude <[email protected]>
Adopt azat's review suggestion. Stage 1 is the instrumented clang used to
build ClickHouse for PGO profile collection. With zlib on it, that build
emits -gz=zlib (COMPRESS_DEBUG_SECTIONS auto-enables now that the compiler
supports it), so the profile covers the debug-compression paths and stage 2
is tuned for them. FORCE_ON to match stage 2 and fail closed; zlib1g-dev is
in the binary-builder image. Also corrects the profile-merge comment (stage 1
no longer lacks zlib).

Co-Authored-By: Claude <[email protected]>
The option name plus FORCE_ON is self-explanatory; the rationale lives in
the commit history and PR description.

Co-Authored-By: Claude <[email protected]>
Out of scope for this PR - a CI cache-digest hygiene point the bot raised,
not part of the zlib/-gz change. The review thread is resolved; keep the PR
focused.

Co-Authored-By: Claude <[email protected]>
@murphy-4o
murphy-4o added this pull request to the merge queue Jul 8, 2026
Merged via the queue into ClickHouse:master with commit 0633b44 Jul 8, 2026
175 checks passed
@murphy-4o
murphy-4o deleted the toolchain-enable-zlib branch July 8, 2026 07:12
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 8, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…zlib

Build the toolchain with zlib so clang supports -gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants