Re: [PATCH 07/14] go-env.eclass: go-module.eclass: Move GOFLAGS handling between eclasses
James Le Cuirot <[email protected]>
| Newsgroups | gmane.linux.gentoo.devel |
|---|---|
| Message-ID | <[email protected]> |
On Sat, 2026-03-14 at 09:31 +0000, James Le Cuirot wrote: > We should set this together with the other environment variables, > especially as -buildmode=pie is arch-specific. We now set that based on > the tuple rather than USE flags. Parallelism is now set via GOMAXPROCS > instead of GOFLAGS because why not. > > Signed-off-by: James Le Cuirot <[email protected]> > --- > eclass/go-env.eclass | 17 +++++++++++++++-- > eclass/go-module.eclass | 15 +-------------- > 2 files changed, 16 insertions(+), 16 deletions(-) > > diff --git a/eclass/go-env.eclass b/eclass/go-env.eclass > index 548c59e69f1d..1c0a4be56005 100644 > --- a/eclass/go-env.eclass > +++ b/eclass/go-env.eclass > @@ -20,7 +20,7 @@ esac > if [[ -z ${_GO_ENV_ECLASS} ]]; then > _GO_ENV_ECLASS=1 > > -inherit flag-o-matic toolchain-funcs > +inherit flag-o-matic multiprocessing toolchain-funcs > > # @FUNCTION: go-env_set_compile_environment > # @DESCRIPTION: > @@ -35,7 +35,20 @@ inherit flag-o-matic toolchain-funcs > go-env_set_compile_environment() { > tc-export AR CC CXX FC PKG_CONFIG > > - export GOARCH=$(go-env_goarch) > + # The following GOFLAGS should be used for all builds. > + # -x prints commands as they are executed > + # -v prints the names of packages as they are compiled > + # -modcacherw makes the build cache read/write > + # -buildvcs=false omits version control information > + # -buildmode=pie builds position independent executables > + export \ > + GOFLAGS="-x -v -modcacherw -buildvcs=false" \ > + GOMAXPROCS=$(get_makeopts_jobs) \ > + GOARCH=$(go-env_goarch) > + > + case ${GOARCH} in > + 386|amd64|arm*|ppc64le|s390*) GOFLAGS+=" -buildmode=pie" ;; > + esac > > case ${GOARCH} in > 386) export GO386=$(go-env_go386) ;; > diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass > index 2399fb56e9a9..5294f50d8ad8 100644 > --- a/eclass/go-module.eclass > +++ b/eclass/go-module.eclass > @@ -68,7 +68,7 @@ esac > if [[ -z ${_GO_MODULE_ECLASS} ]]; then > _GO_MODULE_ECLASS=1 > > -inherit multiprocessing toolchain-funcs go-env > +inherit toolchain-funcs go-env > > if [[ ! ${GO_OPTIONAL} ]]; then > BDEPEND=">=dev-lang/go-1.20:=" > @@ -93,14 +93,6 @@ export GOCACHE="${T}/go-build" > # See "go help environment" for information on this setting > export GOMODCACHE="${WORKDIR}/go-mod" > > -# The following go flags should be used for all builds. > -# -buildmode=pie builds position independent executables > -# -buildvcs=false omits version control information > -# -modcacherw makes the build cache read/write > -# -v prints the names of packages as they are compiled > -# -x prints commands as they are executed > -export GOFLAGS="-buildvcs=false -modcacherw -v -x" > - > # Do not complain about CFLAGS etc since go projects do not use them. > QA_FLAGS_IGNORED='.*' > > @@ -362,11 +354,6 @@ go-module_setup_proxy() { > # 3. Otherwise, call 'ego mod verify' and then do a normal unpack. > # Set compile env via go-env. > go-module_src_unpack() { > - if use amd64 || use arm || use arm64 || > - ( use ppc64 && [[ $(tc-endian) == "little" ]] ) || use s390 || use x86; then > - GOFLAGS="-buildmode=pie ${GOFLAGS}" > - fi > - GOFLAGS="${GOFLAGS} -p=$(makeopts_jobs)" > if [[ "${#EGO_SUM[@]}" -gt 0 ]]; then > eqawarn "QA Notice: This ebuild uses EGO_SUM which is deprecated" > eqawarn "Please migrate to a dependency tarball" It's been pointed out to me that GOMAXPROCS is unhelpful because Go doesn't support the make jobserver. This change doesn't make things any worse for users setting GOMAXPROCS because the old GOFLAGS="-p=$(makeopts_jobs)" line overrode GOMAXPROCS anyway. There is no right answer here until Go does support the make jobserver, but I'll change this to respect GOMAXPROCS, which will slightly improve the situation for tinderbox builds.
signature.asc
(application/pgp-signature, 1 KB)
-----BEGIN PGP SIGNATURE----- iQLBBAABCgCrFiEEPxcZ3tkwcedKm2a8EiZBXQDdMTcFAmm2ck8bFIAAAAAABAAO bWFudTIsMi41KzEuMTIsMiwyXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25z Lm9wZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQzRjE3MTlERUQ5MzA3MUU3NEE5QjY2 QkMxMjI2NDE1RDAwREQzMTM3ERxjaGV3aUBnZW50b28ub3JnAAoJEBImQV0A3TE3 ik4P/jr2l3VsKR1IlIEzbWzb5/As3IaSyERtCoP1VZQb/G92P1RhPAjfbyrJm4+f PQbP2xmE+hO49LP8XejtDlFrVSuOD9vdC/zoz+UujLj/T4Ng8V5vf7+43UbVTv8q Sw4yGydoQVOHblwAHWISfggk26Cn4XTZRN+ZGoMEalAdQC8QyieNrT+BV9eG7YSI KFNnmXkA6vjh4QsgMJBg8gyMxij7JdSgCOLk3difllsFwfTheuzxW7hOuPxNllU0 UwHqgLoadcL/+WMAiZ4KqQr+MhFLDBTy5t3fLmk9OgoUVMlNnH4rgwyYu1oESIiA ePid3QQqzTly4Y9faLZsu7S5V4xVcP/EOiHAstRrNupFyO00yg/6LeGXBcR4vYQW FWu7A1oASqFxtdnBjq+JWfD+dndc36l51ZH7OqHhBb8Xt5mbnoS4BWKK7Hzox1E2 AYkB2f90A3bwzAZix0/qEp+KcArdaJSQHpOYr9jXEFZPKJwBhaF9YXbKdBjuuUEq 38VennqoLYSFIWoWyN1cUl1UEyXTsLiGdvZ+wPq0C94naEjGzxyw2vnydyrfvklm hpaOhIIujXqIb6g2nboiG3PAmswuIlwpYX15eXz+cyYaZ5CfwBt3bdZEvN+3VUjD drX6uxM28wmJg5a4tgIf3ylgh6/YIFXrY0fcE9XvSIlAWi7L =li/x -----END PGP SIGNATURE-----