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"
-- 
2.53.0


Reply via email to