mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-05 20:26:44 +02:00
eclasses: Sync with Gentoo
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
This commit is contained in:
parent
acee470d2a
commit
26f37b2cf2
@ -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
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user