Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.7: build: ensure that binaries are always statically built #402

Merged
merged 1 commit into from
Oct 20, 2020

Conversation

rolinh
Copy link
Member

@rolinh rolinh commented Oct 20, 2020

This is a backport of #397 to the v0.7 branch.

Current make release iterates over supported OS/Arch versions to
cross-compile release binaries. For all platforms that are NOT the same
as the one from which the build is run, CGO is automatically disabled.
This is expected as per the reference documentation[0]:

> The cgo tool is enabled by default for native builds on systems where
> it is expected to work. It is disabled by default when
> cross-compiling.

However, when GOOS and GOARCH are the same as the host doing the build,
it seems that CGO is NOT automatically disabled. As we create release
binaries using an Alpine image, this means that the release binary for
Linux/AMD64 is dynamically linked against the musl libc. Example:

    $ file hubble
    hubble: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, Go BuildID=VA3fxK4tBsB4Zv8nGvhH/7h_TRfu0LvM0YKIBgvPu/uAObRaQQw0vOXYy0NVTF/6uhxSQlWDiL3MyvZeamO, stripped

This renders the binary unusable on most platforms. To address this,
ensure we always disable CGO.

[0]: https://golang.org/cmd/cgo/#hdr-Go_references_to_C

Signed-off-by: Robin Hahling <robin.hahling@gw-computing.net>
@rolinh rolinh added 🧰 kind/backport This PR backports changes to a release branch backport/0.7 This PR is a backport for Hubble v0.7. labels Oct 20, 2020
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label PR is blocked until the release note is set label Oct 20, 2020
@rolinh rolinh added the release-note/misc This PR makes changes that have no direct user impact. label Oct 20, 2020
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label PR is blocked until the release note is set label Oct 20, 2020
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Oct 20, 2020
@gandro gandro merged commit c0c7356 into v0.7 Oct 20, 2020
@gandro gandro deleted the pr/rolinh/v0.7-static-build branch October 20, 2020 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/0.7 This PR is a backport for Hubble v0.7. 🧰 kind/backport This PR backports changes to a release branch ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants