Skip to content

feat: always disable cgo support (static builds)#10426

Closed
powersj wants to merge 2 commits intoinfluxdata:masterfrom
powersj:feat/static-builds
Closed

feat: always disable cgo support (static builds)#10426
powersj wants to merge 2 commits intoinfluxdata:masterfrom
powersj:feat/static-builds

Conversation

@powersj
Copy link
Copy Markdown
Contributor

@powersj powersj commented Jan 12, 2022

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.

Because Telegraf does not need to depend on dynamic libraries,
we can ensure Telegraf builds statically.

MacOS and Windows do not have official static build support and
by default builds on those systems are already as static as they
can be. This primarily affects the Linux/*BSD builds.

Finally, this removes the no longer necessary static specific
build.

@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Jan 12, 2022
@archoversight
Copy link
Copy Markdown

One thing to note is that with this, there is no support for split DNS on macOS since the Go DNS resolver only uses /etc/resolv.conf

@powersj
Copy link
Copy Markdown
Contributor Author

powersj commented Jan 13, 2022

One thing to note is that with this, there is no support for split DNS on macOS since the Go DNS resolver only uses /etc/resolv.conf

Per net/net.go it looks like the Go DNS resolve is the default. The only line of concern here was that Windows uses the C library functions by default. In that case, it makes me want to update this so Windows is excluded.

Thoughts?

@archoversight
Copy link
Copy Markdown

I haven't had a chance to test telegraf in a split DNS scenario, but I imagine that it currently fails since it is using the Go DNS resolver by default.

For macOS builds, it may be beneficial to use cgo to build with CGO_ENABLED=1 so that it uses libc and thus getaddrinfo and thereby split DNS works.

I just happened to drive by this pull request, as I was looking for another issue. Split DNS is fairly common with corporate VPN for example.

This is an issue a lot of Go binaries have because they bypass libc on macOS, and therefor don't work in split DNS scenarios.

@powersj
Copy link
Copy Markdown
Contributor Author

powersj commented Jan 20, 2022

For macOS builds, it may be beneficial to use cgo to build with CGO_ENABLED=1 so that it uses libc and thus getaddrinfo and thereby split DNS works.

I agree, thanks for bringing this up. I'll update this to change only builds for linux.

@powersj powersj force-pushed the feat/static-builds branch from 78a1833 to d0b9d18 Compare January 21, 2022 22:17
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.

Because Telegraf does not need to depend on dynamic libraries,
we can ensure Telegraf builds statically.

MacOS and Windows do not have official static build support and
by default builds on those systems are already as static as they
can be. This primarily affects the Linux/*BSD builds.

Finally, this removes the no longer necessary static specific
build.
@powersj powersj force-pushed the feat/static-builds branch from d0b9d18 to abec12f Compare January 27, 2022 23:23
@telegraf-tiger
Copy link
Copy Markdown
Contributor

@powersj
Copy link
Copy Markdown
Contributor Author

powersj commented Jun 29, 2022

next steps: update this, added as a part of 2.0 breaking changes, verify size is not greatly changed

@powersj
Copy link
Copy Markdown
Contributor Author

powersj commented Aug 11, 2022

I'm going to close this for now, and once we get our 2.0 branch up and started I'll re-post it.

@powersj powersj closed this Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants