mirror of
https://github.com/flatcar/scripts.git
synced 2025-12-08 10:52:03 +01:00
eclass/toolchain-funcs: Sync with gentoo
It's from gentoo commit d87f2b9b24207f175f68f17b6cdb7befc9254841.
This commit is contained in:
parent
87d3be7e89
commit
fca1b3d2a6
@ -1,9 +1,10 @@
|
|||||||
# Copyright 2002-2019 Gentoo Authors
|
# Copyright 2002-2021 Gentoo Authors
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
# @ECLASS: toolchain-funcs.eclass
|
# @ECLASS: toolchain-funcs.eclass
|
||||||
# @MAINTAINER:
|
# @MAINTAINER:
|
||||||
# Toolchain Ninjas <toolchain@gentoo.org>
|
# Toolchain Ninjas <toolchain@gentoo.org>
|
||||||
|
# @SUPPORTED_EAPIS: 5 6 7 8
|
||||||
# @BLURB: functions to query common info about the toolchain
|
# @BLURB: functions to query common info about the toolchain
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# The toolchain-funcs aims to provide a complete suite of functions
|
# The toolchain-funcs aims to provide a complete suite of functions
|
||||||
@ -12,6 +13,12 @@
|
|||||||
# in such a way that you can rely on the function always returning
|
# in such a way that you can rely on the function always returning
|
||||||
# something sane.
|
# something sane.
|
||||||
|
|
||||||
|
case ${EAPI:-0} in
|
||||||
|
# EAPI=0 is still used by crossdev, bug #797367
|
||||||
|
0|5|6|7|8) ;;
|
||||||
|
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
if [[ -z ${_TOOLCHAIN_FUNCS_ECLASS} ]]; then
|
if [[ -z ${_TOOLCHAIN_FUNCS_ECLASS} ]]; then
|
||||||
_TOOLCHAIN_FUNCS_ECLASS=1
|
_TOOLCHAIN_FUNCS_ECLASS=1
|
||||||
|
|
||||||
@ -505,12 +512,21 @@ tc-ld-is-lld() {
|
|||||||
# If the gold linker is currently selected, configure the compilation
|
# If the gold linker is currently selected, configure the compilation
|
||||||
# settings so that we use the older bfd linker instead.
|
# settings so that we use the older bfd linker instead.
|
||||||
tc-ld-disable-gold() {
|
tc-ld-disable-gold() {
|
||||||
if ! tc-ld-is-gold "$@" ; then
|
tc-ld-is-gold "$@" && tc-ld-force-bfd "$@"
|
||||||
# They aren't using gold, so nothing to do!
|
}
|
||||||
|
|
||||||
|
# @FUNCTION: tc-ld-force-bfd
|
||||||
|
# @USAGE: [toolchain prefix]
|
||||||
|
# @DESCRIPTION:
|
||||||
|
# If the gold or lld linker is currently selected, configure the compilation
|
||||||
|
# settings so that we use the bfd linker instead.
|
||||||
|
tc-ld-force-bfd() {
|
||||||
|
if ! tc-ld-is-gold "$@" && ! tc-ld-is-lld "$@" ; then
|
||||||
|
# They aren't using gold or lld, so nothing to do!
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ewarn "Forcing usage of the BFD linker instead of GOLD"
|
ewarn "Forcing usage of the BFD linker"
|
||||||
|
|
||||||
# Set up LD to point directly to bfd if it's available.
|
# Set up LD to point directly to bfd if it's available.
|
||||||
# We need to extract the first word in case there are flags appended
|
# We need to extract the first word in case there are flags appended
|
||||||
@ -520,7 +536,7 @@ tc-ld-disable-gold() {
|
|||||||
local path_ld=$(which "${bfd_ld}" 2>/dev/null)
|
local path_ld=$(which "${bfd_ld}" 2>/dev/null)
|
||||||
[[ -e ${path_ld} ]] && export LD=${bfd_ld}
|
[[ -e ${path_ld} ]] && export LD=${bfd_ld}
|
||||||
|
|
||||||
# Set up LDFLAGS to select gold based on the gcc / clang version.
|
# Set up LDFLAGS to select bfd based on the gcc / clang version.
|
||||||
local fallback="true"
|
local fallback="true"
|
||||||
if tc-is-gcc; then
|
if tc-is-gcc; then
|
||||||
local major=$(gcc-major-version "$@")
|
local major=$(gcc-major-version "$@")
|
||||||
@ -548,7 +564,7 @@ tc-ld-disable-gold() {
|
|||||||
ln -sf "${path_ld}" "${d}"/ld
|
ln -sf "${path_ld}" "${d}"/ld
|
||||||
export LDFLAGS="${LDFLAGS} -B${d}"
|
export LDFLAGS="${LDFLAGS} -B${d}"
|
||||||
else
|
else
|
||||||
die "unable to locate a BFD linker to bypass gold"
|
die "unable to locate a BFD linker"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -665,7 +681,7 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
|
|||||||
mips*) echo mips;;
|
mips*) echo mips;;
|
||||||
nios2*) echo nios2;;
|
nios2*) echo nios2;;
|
||||||
nios*) echo nios;;
|
nios*) echo nios;;
|
||||||
or1k|or32*) echo openrisc;;
|
or1k*|or32*) echo openrisc;;
|
||||||
powerpc*)
|
powerpc*)
|
||||||
# Starting with linux-2.6.15, the 'ppc' and 'ppc64' trees
|
# Starting with linux-2.6.15, the 'ppc' and 'ppc64' trees
|
||||||
# have been unified into simply 'powerpc', but until 2.6.16,
|
# have been unified into simply 'powerpc', but until 2.6.16,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user