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

feat: Replace CGO_ENABLED=0 with //go:build ignore #950

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

timraymond
Copy link
Member

It will soon become necessary to enable CGO in builds in order to use the MS Go distribution. Disabling CGO was always somewhat of a hack since we didn't need it anyway for eBPF. Now that we do, another solution is necessary. This uses the //go:build ignore directive to exclude all C source files from the Go toolchain. This is necessary even within C source files even though these C source files exist within an underscore-prefixed directory. Go's behavior here is likely erroneous, and an issue has been filed for its repair:
golang/go#69639

It will soon become necessary to enable CGO in builds in order to use
the MS Go distribution. Disabling CGO was always somewhat of a hack
since we didn't need it anyway for eBPF. Now that we do, another
solution is necessary. This uses the `//go:build ignore` directive to
exclude all C source files from the Go toolchain. This is necessary even
within C source files even though these C source files exist within an
underscore-prefixed directory. Go's behavior here is likely erroneous,
and an issue has been filed for its repair:
golang/go#69639
@timraymond timraymond requested a review from a team as a code owner November 5, 2024 21:42
Copy link
Collaborator

@rbtr rbtr left a comment

Choose a reason for hiding this comment

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

does this change anything wrt the produced binary now being dynamically vs statically linked and needing a libc in our final image?

@timraymond
Copy link
Member Author

@rbtr I had wondered the same, but my testing in KIND of the images produced was successful. I would like to see the windows images functioning, but I currently lack a handy environment to test them.

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