Skip to content

Conversation

elevran
Copy link
Contributor

@elevran elevran commented Jun 29, 2025

The Go race detector is implemented in C/C++ and requires CGO to work.

However, even if CGO_ENABLED isn't explicitly set, Go assumes CGO_ENABLED=1 by default when:

  • C compiler (like gcc) is available
  • go env setup allows it (e.g., see output of go env | grep CGO)

So if (e.g.,) gcc installed, go test -race just quietly uses CGO under the hood. While this is not needed for local runs, the change makes CGO_ENABLED=1 explicit and portable (e.g., for containers, CI, or cross compile).

Without it make test-unit failed on a fresh system (i.e., without a C compiler) with a somewhat cryptic message:

# runtime/cgo
cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH

Using CGO_ENABLED=1 is meant to make this dependency explicit.

The Go race detector is implemented in C/C++ and requires CGO_ENABLED to work.

However, even if CGO_ENABLED isn't explicitly set, Go assumes CGO_ENABLED=1 by default when:
- C compiler (like gcc) is available
- go env setup allows it (e.g., go env | grep CGO)

This failed on a fresh system without a C compiler.

So if (e.g.,) gcc installed, `go test -race` just quietly uses CGO under the hood.
While this is not needed for local runs, the change makes CGO_ENABLED=1 explicit and
portable (e.g., for containers, CI, or cross compile).

Signed-off-by: Etai Lev Ran <elevran@gmail.com>
Copy link

netlify bot commented Jun 29, 2025

Deploy Preview for gateway-api-inference-extension ready!

Name Link
🔨 Latest commit b55f3ff
🔍 Latest deploy log https://app.netlify.com/projects/gateway-api-inference-extension/deploys/68612d56e6b73300083e2932
😎 Deploy Preview https://deploy-preview-1089--gateway-api-inference-extension.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 29, 2025
@k8s-ci-robot k8s-ci-robot requested review from ahg-g and kfswain June 29, 2025 12:11
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 29, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @elevran. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 29, 2025
@nirrozenbaum
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 29, 2025
@ahg-g
Copy link
Contributor

ahg-g commented Jun 29, 2025

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 29, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahg-g, elevran

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 29, 2025
@k8s-ci-robot k8s-ci-robot merged commit 1ca6875 into kubernetes-sigs:main Jun 29, 2025
9 checks passed
@elevran elevran deleted the cgo_race_detection branch July 2, 2025 12:25
EyalPazz pushed a commit to EyalPazz/gateway-api-inference-extension that referenced this pull request Jul 9, 2025
…kubernetes-sigs#1089)

The Go race detector is implemented in C/C++ and requires CGO_ENABLED to work.

However, even if CGO_ENABLED isn't explicitly set, Go assumes CGO_ENABLED=1 by default when:
- C compiler (like gcc) is available
- go env setup allows it (e.g., go env | grep CGO)

This failed on a fresh system without a C compiler.

So if (e.g.,) gcc installed, `go test -race` just quietly uses CGO under the hood.
While this is not needed for local runs, the change makes CGO_ENABLED=1 explicit and
portable (e.g., for containers, CI, or cross compile).

Signed-off-by: Etai Lev Ran <elevran@gmail.com>
BenjaminBraunDev pushed a commit to BenjaminBraunDev/gateway-api-inference-extension that referenced this pull request Aug 12, 2025
…kubernetes-sigs#1089)

The Go race detector is implemented in C/C++ and requires CGO_ENABLED to work.

However, even if CGO_ENABLED isn't explicitly set, Go assumes CGO_ENABLED=1 by default when:
- C compiler (like gcc) is available
- go env setup allows it (e.g., go env | grep CGO)

This failed on a fresh system without a C compiler.

So if (e.g.,) gcc installed, `go test -race` just quietly uses CGO under the hood.
While this is not needed for local runs, the change makes CGO_ENABLED=1 explicit and
portable (e.g., for containers, CI, or cross compile).

Signed-off-by: Etai Lev Ran <elevran@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants