release: build every artifact with cgo disabled - #30
Merged
Merged
Conversation
The published clickhouse-diagnostic-linux-amd64 binary is dynamically linked and carries GLIBC_2.32 and GLIBC_2.34 version requirements, so on a RHEL-8-era host it exits before running any of our code: ./clickhouse-diagnostic: /lib64/libc.so.6: version `GLIBC_2.34' not found The release loop ran a plain `go build` for six targets. Go turns cgo off by itself when cross-compiling, so five came out static; linux/amd64 matches the release runner, is therefore not a cross-compile, kept cgo on and picked up a dynamic link to the runner's glibc. Setting CGO_ENABLED=0 makes the choice explicit and independent of whichever host cuts the release. Matched arms, same source tree and same amd64 container (glibc 2.36), only the flag differing: without CGO_ENABLED=0 dynamically linked GLIBC_2.2.5 2.3.2 2.32 2.34 with CGO_ENABLED=0 statically linked no GLIBC references After the change `make release` produces all six archives; both Linux binaries are statically linked with zero glibc references, darwin stays Mach-O and windows stays PE32+, and the linux-amd64 archive holds the same 229 entries as v0.5.0. The packaged binary starts on a glibc 2.28 userland. `go test ./...` passes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
davidhogeg-ch
requested review from
CamiloSierraH
and
a lite review from Copilot
September 22, 2026 16:13
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Release paths remain inconsistently configured and are not covered by PR checks.
Review effort: Lite
Findings: None
What changed in this PR
This PR disables cgo for release builds to produce statically linked Linux artifacts without newer glibc requirements.
Changes:
- Sets
CGO_ENABLED=0for release builds. - Documents the glibc compatibility rationale.
| File | Summary |
|---|---|
Makefile |
Release builds disable cgo; documented single-target commands and PR coverage still need alignment. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The
clickhouse-diagnostic-linux-amd64asset we publish is dynamically linked and carriesGLIBC_2.32andGLIBC_2.34version requirements. On a RHEL-8-era host it exits before any of our code runs:This came off a live self-managed case where the customer was asked to run the collector, could not start it, and went to their sysadmin team to have glibc upgraded — for a tool that needs no C library at all. Measured on the downloaded tarballs of both v0.4.5 and v0.5.0, so it is not new and upgrading does not clear it.
The cause
The release loop ran a plain
go buildfor six targets. Go disables cgo on its own when cross-compiling, so five came out static.linux/amd64is the same platform as the release runner, so it is not a cross-compile, cgo stayed on, and that one binary picked up a dynamic link to the runner's glibc. Nothing in the tool asks for cgo — thelinux/arm64build of the same source has always been static with zero glibc references.What changed
Makefile—CGO_ENABLED=0on the releasego build, plus a comment recording why. Two lines of behaviour; the rest is the comment.The
buildandinstalltargets are deliberately untouched: those produce a local dev binary, not a shipped artifact, and a dev build linking the local libc is harmless.Verification
Matched arms, same source tree, same amd64 container (
golang:1.23.9,ldd (Debian GLIBC 2.36-9+deb12u10) 2.36), only the flag differing:fileGOOS=linux GOARCH=amd64 go builddynamically linkedGLIBC_2.2.5 2.3.2 2.32 2.34CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go buildstatically linkedThe first arm reproduces the published artifact's requirement, including the exact two versions the customer's loader rejected.
Then
make releaseon this branch, in an amd64 container so the native target is the one that used to break:All six archives are produced, the
linux-amd64archive holds the same 229 entries as the official v0.5.0 one, and the packaged binary starts underldd (GNU libc) 2.28on a native amd64 Rocky Linux 8 container.go test ./...passes (all packagesok).Note on the stopgap
v0.5.0-static-amd64is a pre-release holding a hand-built static amd64 archive, cut for that customer before this fix existed. It can be deleted once the next tagged release carries the change:gh release delete v0.5.0-static-amd64 --cleanup-tag.🤖 Generated with Claude Code