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

go_install, go_build: Support CGO_ENABLED #3448

Open
suzuki-shunsuke opened this issue Jan 9, 2025 · 0 comments
Open

go_install, go_build: Support CGO_ENABLED #3448

suzuki-shunsuke opened this issue Jan 9, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@suzuki-shunsuke
Copy link
Member

Feature Overview

Support configuring CGO_ENABLED when install go_install and go_build packages.

Why is the feature needed?

The cgo tool is enabled by default for native builds on systems where it is expected to work.
It is disabled by default when cross-compiling as well as when the CC environment variable is unset and the default C compiler (typically gcc or clang) cannot be found on the system PATH.
You can override the default by setting the CGO_ENABLED environment variable when running the go tool: set it to 1 to enable the use of cgo, and to 0 to disable it.
The go tool will set the build constraint "cgo" if cgo is enabled.
The special import "C" implies the "cgo" build constraint, as though the file also said "//go:build cgo".
Therefore, if cgo is disabled, files that import "C" will not be built by the go tool.
(For more about build constraints see https://golang.org/pkg/go/build/#hdr-Build_Constraints).

Example Code

No response

Note

⚠️ This issue is just an idea.
I haven't considered it seriously yet.
I think this is rarely necessary.

@suzuki-shunsuke suzuki-shunsuke added the enhancement New feature or request label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant