[PATCH 3/4] go-env.eclass: Set CGO_ENABLED to 1 by default for EAPI 9
James Le Cuirot <[email protected]>
| Newsgroups | gmane.linux.gentoo.devel |
|---|---|
| Message-ID | <[email protected]> |
Upstream Go enables this by default for native builds anyway, but it is disabled by default for cross builds, and some projects may disable it by default. Signed-off-by: James Le Cuirot <[email protected]> --- eclass/go-env.eclass | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/eclass/go-env.eclass b/eclass/go-env.eclass index f5c84c3abbb0..f8de40a596d0 100644 --- a/eclass/go-env.eclass +++ b/eclass/go-env.eclass @@ -86,6 +86,26 @@ _GO_ENV_ECLASS=1 inherit flag-o-matic multiprocessing sysroot toolchain-funcs +# @ECLASS_VARIABLE: CGO_ENABLED +# @DESCRIPTION: +# Whether to enable the cgo tool that lets Go packages call C code. Upstream Go +# enables this by default for native builds when a C compiler is found. Some +# projects will forcibly enable it by necessity. Other projects may disable it +# by default or even forcibly disable it to make the resulting binaries more +# portable. When enabled, certain standard library packages will use the libc +# over their own built-in code for things like DNS resolution, which is +# generally preferable. It makes sense for a distribution to enable it where +# possible, even when cross-compiling. Ebuilds may force this setting one way or +# the other before inheriting this eclass where necessary, although upstream +# projects will likely do this for you. If you believe that a project should not +# force it, then please work with upstream to have the variable respected. +# Ebuilds may also disable it by default if this is more appropriate. See +# https://pkg.go.dev/cmd/cgo. +case ${EAPI} in + 7|8) : ;; + *) export CGO_ENABLED="${CGO_ENABLED:-1}" ;; +esac + # @FUNCTION: go-env_set_compile_environment # @DESCRIPTION: # Sets up the environment to build Go code for CHOST. This includes variables -- 2.53.0