From 26f37b2cf24ae84483ede7d94a662fc39c70b345 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Fri, 13 Mar 2026 09:48:34 +0000 Subject: [PATCH] eclasses: Sync with Gentoo Signed-off-by: James Le Cuirot --- .../portage-stable/eclass/go-env.eclass | 113 +++++++++++++----- .../portage-stable/eclass/go-module.eclass | 15 +-- .../eclass/toolchain-funcs.eclass | 4 +- 3 files changed, 83 insertions(+), 49 deletions(-) diff --git a/sdk_container/src/third_party/portage-stable/eclass/go-env.eclass b/sdk_container/src/third_party/portage-stable/eclass/go-env.eclass index b2b240b5ef..3dca4ffc39 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/go-env.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/go-env.eclass @@ -1,4 +1,4 @@ -# Copyright 2023-2025 Gentoo Authors +# Copyright 2023-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @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: @@ -33,35 +33,63 @@ inherit flag-o-matic toolchain-funcs # (e.g. "emerge-aarch64-cross-linux-gnu foo" run on x86_64 will emerge "foo" for x86_64 # instead of aarch64) go-env_set_compile_environment() { - tc-export CC CXX PKG_CONFIG + tc-export AR CC CXX FC PKG_CONFIG - export GOARCH="$(go-env_goarch)" - use arm && export GOARM=$(go-env_goarm) - use x86 && export GO386=$(go-env_go386) + # 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) \ + GOOS=$(go-env_goos) + + case ${GOARCH} in + 386|amd64|arm*|ppc64le|s390*) GOFLAGS+=" -buildmode=pie" ;; + esac + + case ${GOARCH} in + 386) export GO386=$(go-env_go386) ;; + arm|armbe) export GOARM=$(go-env_goarm) ;; + mips64*) export GOMIPS64=$(go-env_gomips) ;; + mips*) export GOMIPS=$(go-env_gomips) ;; + esac + + # Don't modify the non-Go variables outside this function. + local -I $(all-flag-vars) - # XXX: Hack for checking ICE (bug #912152, gcc PR113204) if tc-is-gcc ; then + # XXX: Hack for checking ICE (bug #912152, gcc PR113204) # For either USE=debug or an unreleased compiler, non-default # checking will trigger. - if has_version -b "sys-devel/gcc[debug]" || [[ $(gcc-minor-version) -eq 0 ]] ; then - filter-lto - fi + $(tc-getCC) -v 2>&1 | grep -Eqe "--enable-checking=\S*\byes\b" && filter-lto + + # bug #929219 + replace-flags -g3 -g + replace-flags -ggdb3 -ggdb fi - export CGO_CFLAGS="${CGO_CFLAGS:-$CFLAGS}" - export CGO_CPPFLAGS="${CGO_CPPFLAGS:-$CPPFLAGS}" - export CGO_CXXFLAGS="${CGO_CXXFLAGS:-$CXXFLAGS}" - export CGO_LDFLAGS="${CGO_LDFLAGS:-$LDFLAGS}" + export \ + CGO_CFLAGS=${CFLAGS} \ + CGO_CPPFLAGS=${CPPFLAGS} \ + CGO_CXXFLAGS=${CXXFLAGS} \ + CGO_LDFLAGS=${LDFLAGS} +} - # bug #929219 - if tc-is-gcc ; then - CGO_CFLAGS=$( - CFLAGS=${CGO_CFLAGS} - replace-flags -g3 -g - replace-flags -ggdb3 -ggdb - printf %s "${CFLAGS}" - ) - fi +# @FUNCTION: go-env_run +# @DESCRIPTION: +# Run the given command under a localised environment configured by +# go-env_set_compile_environment(). +go-env_run() { + local -I AR CC CXX FC PKG_CONFIG \ + GO{FLAGS,MAXPROCS,ARCH,386,ARM,MIPS,MIPS64} \ + CGO_{CFLAGS,CPPFLAGS,CXXFLAGS,LDFLAGS} + + go-env_set_compile_environment + "${@}" } # @FUNCTION: go-env_goos @@ -129,19 +157,38 @@ go-env_go386() { } # @FUNCTION: go-env_goarm -# @USAGE: [CHOST-value] +# @USAGE: [tuple] # @DESCRIPTION: -# Returns the appropriate GOARM setting for the CHOST given, or the default -# CHOST. +# Returns the appropriate GOARM setting for given target or CHOST. go-env_goarm() { - case "${1:-${CHOST}}" in - armv5*) echo 5;; - armv6*) echo 6;; - armv7*) echo 7;; - *) - die "unknown GOARM for ${1:-${CHOST}}" - ;; + local CTARGET=${1:-${CHOST}} + + case ${CTARGET} in + armv5*) echo -n 5 ;; + armv6*) echo -n 6 ;; + armv7*) echo -n 7 ;; + *) die "unknown GOARM for ${CTARGET}" ;; esac + + if [[ $(tc-is-softfloat) == no ]]; then + echo ,hardfloat + else + echo ,softfloat + fi +} + +# @FUNCTION: go-env_gomips +# @USAGE: [tuple] +# @DESCRIPTION: +# Returns the appropriate GOMIPS or GOMIPS64 setting for given target or CHOST. +go-env_gomips() { + local CTARGET=${1:-${CHOST}} + + if [[ $(tc-is-softfloat) == no ]]; then + echo hardfloat + else + echo softfloat + fi } fi diff --git a/sdk_container/src/third_party/portage-stable/eclass/go-module.eclass b/sdk_container/src/third_party/portage-stable/eclass/go-module.eclass index 2399fb56e9..5294f50d8a 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/go-module.eclass +++ b/sdk_container/src/third_party/portage-stable/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" diff --git a/sdk_container/src/third_party/portage-stable/eclass/toolchain-funcs.eclass b/sdk_container/src/third_party/portage-stable/eclass/toolchain-funcs.eclass index 89da26b867..2b57fc1187 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/toolchain-funcs.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/toolchain-funcs.eclass @@ -402,6 +402,7 @@ tc-env_build() { PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) \ RANLIB=$(tc-getBUILD_RANLIB) \ READELF=$(tc-getBUILD_READELF) \ + CHOST=${CBUILD:-${CHOST}} \ "$@" } @@ -445,8 +446,7 @@ tc-env_build() { # @CODE econf_build() { local CBUILD=${CBUILD:-${CHOST}} - econf_env() { CHOST=${CBUILD} econf "$@"; } - tc-env_build econf_env "$@" + tc-env_build econf "$@" } # @FUNCTION: tc-ld-is-bfd