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

Always set CGO_ENABLED=0 #630

Merged
merged 1 commit into from
Mar 5, 2024
Merged

Always set CGO_ENABLED=0 #630

merged 1 commit into from
Mar 5, 2024

Conversation

fujiwara
Copy link
Contributor

@fujiwara fujiwara commented Mar 5, 2024

Hi!

The latest release binaries seems to be build dynamic linked.
For example https://github.com/mackerelio/mkr/releases/download/v0.55.0/mkr_linux_amd64.tar.gz

$ curl -sLO https://github.com/mackerelio/mkr/releases/download/v0.55.0/mkr_linux_amd64.tar.gz
$ tar xvf mkr_linux_amd64.tar.gz
$ ldd mkr_linux_amd64/mkr
linux-vdso.so.1 (0x00007ffe0359c000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6c654a7000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f6c656de000)

But, the mkr binary in Debian packages are statically linked.

$ ldd /usr/bin/mkr
        not a dynamic executable

I hope to use the release binaries in non-glibc environments (like Alpine Linux).

Currently, CGO_ENABLED=0 is set only when building via 'make build'. But the setting does not affect 'make cross', so release binaries seems dynamically linked.

This PR sets CGO_ENABLED=0 always.

refs #515

Currently, CGO_ENABLED=0 is set only when building via 'make build'.
But the setting does not affect 'make cross', so release binaries are dynamically linked.

refs mackerelio#515
Copy link
Member

@lufia lufia left a comment

Choose a reason for hiding this comment

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

Understanding.

CGO_ENABLED is set to 1 by default when both build host's GOOS and GOARCH is same with target's them.

@lufia
Copy link
Member

lufia commented Mar 5, 2024

Thank you!

@lufia lufia merged commit 675f852 into mackerelio:master Mar 5, 2024
13 checks passed
@fujiwara fujiwara deleted the disable_cgo branch March 5, 2024 09:36
This was referenced Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants