Skip to content

Compress the debug sections of the packaged .debug files with zstd - #131720

Merged
alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
groeneai:compress-split-debug-sections
Nov 16, 2026
Merged

alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
groeneai:compress-split-debug-sections

Conversation

@groeneai

@groeneai groeneai commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #126943
Related: #131710

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

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

The debug sections of clickhouse.debug and clickhouse-keeper.debug in the -dbg packages are now compressed with zstd (4.3 GB -> 1.3 GB; zlib if the build's objcopy lacks zstd), so the clickhouse-common-static-dbg rpm stays under the 4 GiB file size limit of the rpm packager and can be installed again. Reading zstd-compressed files with gdb requires gdb 13 or newer built with zstd support.

Description

Install packages (amd_release, rpm) / (arm_release, rpm) fails with cpio: Digest mismatch on clickhouse.debug on master since #117346 and on every 26.10 build since 2026-11-13 (report). The file grew over 2^32 bytes and nfpm 2.20.0 stores 32-bit file sizes in rpm.

The split debug file is now produced with --compress-debug-sections=zstd, in the same objcopy call so the .gnu_debuglink CRC covers the shipped file; CMake falls back to zlib when that objcopy has no zstd. Two CI tools lacked zstd and are now built with it: the gdb in clickhouse/cctools, and the PGO toolchain, whose llvm-objcopy the release builds use when it provides the compiler (clang-22, #131710); until it is rebuilt, those builds write zlib.

SymbolIndex bounded the executable by the size of its .debug file (238 MB in a PR build, below the 768 MB image), so higher frames lost their names; it now uses the PT_LOAD segments. The symbolizer skips compressed sections, so installed packages' stack traces keep function names but lose file:line until the follow-up PR from #126943, which should merge first or together.

Reverting #117346 (#131710) restores only 85 MB (amd64) / 55 MB (arm64) of headroom.

Validation on master edfbc33b's packages rebuilt with nfpm 2.20.0: the dbg rpm installs with the CI command and rpm -V is clean (the uncompressed one reproduces Digest mismatch); the rebuilt gdb resolves file:line from it; LLVM 23 built with zstd in the toolchain's image writes the sections; the current toolchain's llvm-objcopy takes the zlib fallback, which CI's gdb 18.1 reads. A green Install packages here does not exercise the 4 GiB case.


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

Version info

  • Merged into: 26.11.1.2398-master (included in 26.11 and later)
  • Backported to: 26.10.5.36

groeneai and others added 2 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` (ClickHouse#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 ClickHouse#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]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; round 1: 2 findings, round 2 on the final head: 0 findings) plus my own review (1 blocker, fixed).

# Sev Finding Verdict Evidence / action
1 ❌ The PGO toolchain's llvm-objcopy (built with LLVM_ENABLE_ZSTD=OFF) cannot write zstd sections and is the objcopy CI picks whenever that toolchain provides the compiler AGREE, fixed both toolchain stages are built with LLVM_ENABLE_ZSTD=FORCE_ON; LLVM 23 configured so in the builder image writes zstd sections, the configure fails without libzstd-dev; this PR's Build toolchain jobs check both arches
2 ❌ ClickHouse's own Dwarf reader skips compressed sections, so installed-package stack traces lose file:line DISAGREE requested as a separate PR in #126943; the body states it should merge before or together with this one
3 ⚠️ No proof of the over-4-GiB rpm fix or of gdb reading the new format DISAGREE measured on master edfbc33b packages: uncompressed rpm fails with Digest mismatch, compressed installs and rpm -V is clean; rebuilt gdb resolves file:line, lldb and llvm-symbolizer unchanged
4 💡 Merge order with #131710 not stated AGREE, fixed the body says clang-22 builds would use the current toolchain's llvm-objcopy and fail until the toolchain is rebuilt

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. master edfbc33b amd64 packages rebuilt with nfpm 2.20.0, installed with the Install server rpm command in clickhouse/install-rpm-test: cpio: Digest mismatch on clickhouse.debug every time; rpm -qp --dump shows its size as 16,139,696 = 4,311,106,992 - 2^32.
b Root cause explained? clickhouse.debug is over 2^32 bytes and nfpm 2.20.0 writes 32-bit rpm file sizes, so the header disagrees with the payload and rpm's digest check fails.
c Fix matches root cause? Yes. The debug sections are compressed with zstd where the file is produced (1.32 GB amd64, 1.37 GB arm64), for every package format and both split targets.
d Test intent preserved / new tests added? Build/packaging change, no in-tree test (test infrastructure ships no self-test). Regression gate: the existing Install packages (*, rpm) jobs on master/release builds.
e Both directions demonstrated? Yes. Uncompressed rpm fails, compressed rpm installs and rpm -V is clean; the macro's old command gives 0/11 compressed sections, the new one 11/11 with a matching debuglink CRC; the old CI gdb prints ?? on the compressed file, the rebuilt one prints file:line; the current toolchain's llvm-objcopy rejects zstd, one built with LLVM_ENABLE_ZSTD=FORCE_ON writes it, and that configure fails without libzstd-dev.
f Fix is general across code paths? One producer for clickhouse and clickhouse-keeper, deb/rpm/tgz and every SPLIT_DEBUG_SYMBOLS=ON build; SYMBOL_SECTIONS=compact and gnu_debugdata both build and verify. The objcopy CI selects can be the PGO toolchain's, so the toolchain is built with zstd too. Consumers checked: CI gdb (fixed here), lldb, llvm-symbolizer, distro gdb 15. ClickHouse's own symbolizer loses file:line until the follow-up PR from #126943.
g Fix generalizes across inputs (params/datatypes/wrappers)? Both arches and both debug files measured; builds without split debug symbols are unchanged.
h Backward compatible? (maintainer-approved exception only) No setting or format change, same package layout. Reading the files needs a zstd-capable reader (gdb 13 or newer); stated in the changelog entry.
i Invariants and contracts preserved? .gnu_debuglink CRC matches the shipped file, build-id equal in binary and .debug, linked binary unchanged, rpm -V and dpkg --verify clean.

Session id: cron:clickhouse-impl-slot-5:20261115-014200

@clickhouse-gh

clickhouse-gh Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [afa8dc6]

Summary: ✅


AI Review

Summary

Compresses packaged debug sections with zstd, selects zlib for tools without zstd support, and enables zstd in CI's debugger and toolchain. Reviewed head afa8dc66ab4cd10069864d1dd46302e9a0214c65, including all prior discussion and the latest fix. No remaining blockers or majors found. The previous object-range finding is fixed: collectSymbolsFromELF now derives the runtime end from loaded PT_LOAD segments, independently of debug-file size.

Compressed-file consumer coverage: SymbolIndex, system.symbols, and addressToSymbol use the retained symbol tables; StackTrace, system.stack_trace, and trace-log storage use the corrected runtime bounds. Dwarf, AddressToLineCache, addressToLine, and addressToLineWithInlines need the companion change below. CI's GDB gains zstd support; LLDB and llvm-symbolizer compatibility is covered by the author's reported validation. The gnu_debugdata producer strips debug sections before creating MiniDebugInfo; compact-symbol generation reads the stripped executable.

Missing context / blind spots
  • ⚠️ The full CI rerun is pending. The reported workflow failure is the review-thread gate requesting a full rerun after the earlier thread was resolved. No local ClickHouse build or tests were run; package installation, debugger compatibility, and the object-range regression have focused before/after evidence in the PR discussion.
ClickHouse-Specific Rule Notes
  • Compressed DWARF remains unreadable by the built-in symbolizer at this head. The maintainer explicitly requested a separate implementation, tracked in PR #131722, which remains open. Preserve the documented merge order: merge that PR first or together with this one to retain file/line information and inline frames for installed debug packages. This accepted dependency is not a new inline finding.
Final Verdict

✅ Approve the reviewed changes. No additional code changes requested; retain the documented companion-PR merge order and complete the full CI rerun.

@clickhouse-gh clickhouse-gh Bot added pr-build Pull request with build/testing/packaging improvement can be tested Allows running workflows for external contributors manual approve Manual approve required to run CI comp-build-system Build system (CMake, compilation, platform builds). labels Nov 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing afa8dc66a with master abc7ede4c (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 7 s compile time in total, 7 of them have a recent master baseline.

Job report

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexey-milovidov alexey-milovidov self-assigned this Nov 15, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 15, 2026
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 ClickHouse#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]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

The merge queue entry stacked on #131710 failed Build (amd_illumos) (report): with clang-22, objcopy comes from the PGO toolchain, which has no zstd until it is rebuilt. affc13b makes CMake fall back to zlib when objcopy lacks zstd (measured: the toolchain's objcopy then writes zlib sections, which CI's current gdb reads).

Comment thread cmake/split_debug_symbols.cmake Resolved
…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: ClickHouse#131720 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 15, 2026
Merged via the queue into ClickHouse:master with commit e7e1427 Nov 16, 2026
378 of 379 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 16, 2026
@Algunenano Algunenano self-assigned this Nov 16, 2026
@Algunenano

Copy link
Copy Markdown
Member

This is needed in 26.10, which is failing constantly on Install server:

error: unpacking of archive failed on file /usr/lib/debug/usr/bin/clickhouse.debug;...: cpio: Digest mismatch
error: clickhouse-common-static-dbg-...: install failed

@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 16, 2026
robot-clickhouse added a commit that referenced this pull request Nov 16, 2026
Cherry pick #131720 to 26.10: Compress the debug sections of the packaged `.debug` files with zstd
robot-clickhouse added a commit that referenced this pull request Nov 16, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 16, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 16, 2026
Backport #131720 to 26.10: Compress the debug sections of the packaged `.debug` files with zstd
@snelheidai snelheidai mentioned this pull request Nov 17, 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). manual approve Manual approve required to run CI pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-build Pull request with build/testing/packaging improvement pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.10-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The clickhouse-common-static-dbg rpm cannot be installed: clickhouse.debug is over 4 GiB and nfpm writes 32-bit file sizes

6 participants