Skip to content

fix(build): set CGO_ENABLED=0 in Makefile to produce static gcluster binary - #6259

Open
Neelabh94 wants to merge 1 commit into
GoogleCloudPlatform:developfrom
Neelabh94:build-disable-cgo-static-binary
Open

fix(build): set CGO_ENABLED=0 in Makefile to produce static gcluster binary#6259
Neelabh94 wants to merge 1 commit into
GoogleCloudPlatform:developfrom
Neelabh94:build-disable-cgo-static-binary

Conversation

@Neelabh94

Copy link
Copy Markdown
Contributor

Description

The official gcluster Linux amd64 release binary (v1.102.0) fails on Debian 11 (Bullseye) due to missing GLIBC symbols:

/gcluster: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /gcluster)
/gcluster: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /gcluster)

Root Cause

  1. In PR Go version updated to the 1.26 #6173 and Provision go 1.26 cloud build infrastructure #6174 (Go 1.26 upgrade), build environments were updated to golang:1.26-trixie (Debian 13 Trixie, which has GLIBC 2.40+).
  2. When building for linux/amd64 on a linux/amd64 builder host, Go defaults to CGO_ENABLED=1, dynamically linking gcluster against the builder's glibc (Debian Trixie) and embedding requirements for GLIBC_2.32 and GLIBC_2.34. Debian 11 ships with GLIBC 2.31.
  3. In contrast, .github/workflows/os-support-validation.yml explicitly builds with CGO_ENABLED=0 go build -o gcluster ., which is why PR CI passed on debian:11-slim while release binaries were dynamically linked.

Solution

Explicitly set CGO_ENABLED=0 in the Makefile for the gcluster target. This ensures that:

  • All Linux amd64 binaries built via make (including Cloud Build release pipelines and local builds) are fully static ELF executables with zero GLIBC dependencies.
  • Binaries run portably on older Linux distributions like Debian 11, CentOS, RHEL, and minimal container environments.

Testing

  • Verified make gcluster produces a statically linked ELF executable (file gcluster).
  • Verified execution of ./gcluster --version inside a clean debian:11 container.
  • Full test suite passed with CGO_ENABLED=0 go test ./cmd/... ./pkg/....
  • Pre-commit hooks passed cleanly.

@Neelabh94 Neelabh94 added go Pull requests that update Go code release-bugfix Added to release notes under the "Bug fixes" heading. labels Sep 3, 2026
@Neelabh94 Neelabh94 self-assigned this Sep 3, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a runtime failure in the gcluster binary on older Linux distributions caused by dynamic linking against newer GLIBC versions. By forcing a static build, the change ensures portability across various environments and aligns the Makefile build process with the existing CI validation logic.

Highlights

  • Static Binary Compilation: Updated the Makefile to explicitly set CGO_ENABLED=0 when building the gcluster binary.
  • Compatibility Improvement: Ensures the binary is statically linked, resolving GLIBC version dependency issues on older Linux distributions like Debian 11.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Makefile to build the gcluster binary with CGO_ENABLED=0, ensuring a statically linked binary. There are no review comments to evaluate, and I have no additional feedback to provide.

@Neelabh94
Neelabh94 marked this pull request as ready for review September 3, 2026 08:27
@Neelabh94
Neelabh94 requested a review from a team as a code owner September 3, 2026 08:27
@Neelabh94 Neelabh94 assigned ishitachail and unassigned Neelabh94 Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code release-bugfix Added to release notes under the "Bug fixes" heading.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants