Skip to content

Cherry pick #131720 to 26.10: Compress the debug sections of the packaged .debug files with zstd - #132042

Merged
robot-clickhouse merged 6 commits into
backport/26.10/131720from
cherrypick/26.10/131720
Nov 16, 2026
Merged

robot-clickhouse merged 6 commits into
backport/26.10/131720from
cherrypick/26.10/131720

Conversation

@robot-ch-test-poll4

Copy link
Copy Markdown
Contributor

Original pull-request #131720

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 5 commits November 15, 2026 01:44
`clickhouse.debug` grew over 2^32 bytes (4,311,106,992 on amd64 at
edfbc33), and nfpm 2.20.0 stores 32-bit file sizes in rpm packages, so
the `clickhouse-common-static-dbg` rpm records the size modulo 2^32 and
fails to install with `cpio: Digest mismatch` (#126943).

Produce the split debug file with `--compress-debug-sections=zstd`
(1.32 GB on amd64, 1.37 GB on arm64). The flag is in the
`--only-keep-debug` call, before `--add-gnu-debuglink`, so the debuglink
CRC is computed over the shipped file. The unstripped binary is
unchanged.

CI's gdb in `clickhouse/cctools` was built without zstd: bfd's configure
looks for libzstd with pkg-config, and neither `libzstd-dev` nor
`pkg-config` was installed, so the support was dropped silently. Install
both and pass `--with-zstd`, so a missing libzstd fails the image build.
Without this, the Upgrade check's gdb cannot read the compressed debug
file and prints `??` for every frame of the stripped packaged binary.

A SPLIT_DEBUG_SYMBOLS=ON build with an objcopy that lacks zstd support
now fails in the post-build step. ClickHouse's own Dwarf reader skips
compressed sections, so stack traces of installed packages lose
file:line until it can read them (follow-up requested in #126943).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The release builds produce the split debug files with
`--compress-debug-sections=zstd`. `ch_find_program` takes llvm-objcopy
from the compiler's directory first, so whenever the PGO+BOLT toolchain
in /usr/local/bin provides the compiler (with clang-22: `Using objcopy:
/usr/local/bin/llvm-objcopy` in the 58726cc release build logs), the
release builds use its llvm-objcopy, which is built with
LLVM_ENABLE_ZSTD=OFF and fails with "LLVM was not built with
LLVM_ENABLE_ZSTD". Build both toolchain stages with zstd and install
libzstd-dev in the image the toolchain is built in, as was done for
zlib. It applies from the next toolchain rebuild; until then the
clang-23 builds use apt's llvm-objcopy-23, which has zstd.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The release builds take `llvm-objcopy` from the compiler's directory. With
clang-22 that is the PGO toolchain, built with `LLVM_ENABLE_ZSTD=OFF` until
it is rebuilt with the previous commit, so `--compress-debug-sections=zstd`
failed the build ("LLVM was not built with LLVM_ENABLE_ZSTD"): the merge
queue entry stacked on #131710 (Revert "Use clang-23") failed
`Build (amd_illumos)` this way.

CMake now checks that `objcopy` accepts zstd by compressing a copy of
itself and uses zlib otherwise. zlib-compressed sections are readable by
the gdb CI has today.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…le size

`collectSymbolsFromELF` set `address_end` from the size of the file it reads symbols
from, which is the separate `.debug` file when one exists. With compressed debug
sections that file is smaller than the executable's code, so `SymbolIndex::thisObject`
and `findObject` returned `nullptr`: stack frames lost their names and
`StackTrace::resolveAddressForStorage` stored zero offsets.

Derive the end from the highest loaded segment in the program headers instead.

Verified on aarch64 with a 240 MB zstd-compressed `clickhouse.debug` next to a binary
whose segments end at ~670 MB: `system.stack_trace` threads with nonzero, symbolized
frames went from 0/29 to 25/29 (the same as without a debug file).

Review: #131720 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Compress the debug sections of the packaged `.debug` files with zstd
@robot-ch-test-poll4 robot-ch-test-poll4 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request labels Nov 16, 2026
Resolve the Dockerfile conflicts against the 26.10 images and add `ProgramHeaderType::LOAD`,
which `getLoadedSegmentsEnd` needs and 26.10 lacks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robot-clickhouse
robot-clickhouse merged commit db02d39 into backport/26.10/131720 Nov 16, 2026
2 checks passed
@robot-clickhouse
robot-clickhouse deleted the cherrypick/26.10/131720 branch November 16, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants