-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
feat: always disable cgo support (static builds) #12600
Conversation
7b7182b
to
9cad4a6
Compare
This ensures that cgo is always disabled with builds using the Makefile. Telegraf does not support importing C libraries or depending on any of them in the first place. This is to ensure cross-platform and cross-OS support. Our official builds for Windows, macOS, and BSD are cross-compiled. In these cases, cgo is already disabled. This primarily affects the linux builds. This will enable us to deliver the much requested arm64 docker images for Alpine. In influxdata#8278, a check for the glibc version was added after a user noticed the binary was depending on newer versions of glibc. This removes those checks as static builds will not need these checks. Finally, this removes the no longer necessary static specific build.
9cad4a6
to
c6976f7
Compare
Download PR build artifacts for linux_amd64.tar.gz, darwin_amd64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll let @srebhan comment on the specifics, but I looked over the PR and it looks reasonable. I'm a fan of disabling CGO unless it is absolutely required and this should improve portability and maintenance in general.
Fyi, in an Ubuntu 20.04 container, I ran make
and CGO is disabled:
$ make
...
CGO_ENABLED=0 go build -ldflags " -X github.com/influxdata/telegraf/internal.Commit=c6976f77 -X github.com/influxdata/telegraf/internal.Branch=HEAD -X github.com/influxdata/telegraf/internal.Version=1.26.0-c6976f77" ./cmd/telegraf
$ go version -m ./telegraf | grep CGO_ENABLED
build CGO_ENABLED=0
# compare to current deb
$ go version -m ./usr/bin/telegraf |grep CGO_ENABLED
build CGO_ENABLED=1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I guess we need to use go env -w CGO_ENABLED="0"
to make this work on windows. I'll test that later...
This should not have been removed and not sure why it was part of a previous PR. fixes: influxdata#12600
This ensures that cgo is always disabled with builds using the Makefile. Telegraf does not support importing C libraries or depending on any of them in the first place. This is to ensure cross-platform and cross-OS support.
Our official builds for Windows, macOS, and BSD are cross-compiled. In these cases, cgo is already disabled. This primarily affects the linux builds. This will enable us to deliver the much requested arm64 docker images for Alpine.
In #8278, a check for the glibc version was added after a user noticed the binary was depending on newer versions of glibc. This removes those checks as static builds will not need these checks.
Finally, this removes the no longer necessary static specific build.
fixes: #8997