util/xcompile: Look for the host compiler in XGCCPATH, too (and first)

If there's a host compiler in XGCCPATH, it's likely the same
relatively-current version we use for coreboot, and it's a well-known
quantity, so let's prefer that over alternatives by default.

In addition, look for the C++ host compiler as well.

Change-Id: If50341df169a476899b5a5ffd4c4fb6d21c3f4ac
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/43144
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Patrick Georgi 2020-07-06 16:37:33 +02:00
parent fca0cba6a1
commit 793bf7e605
1 changed files with 18 additions and 1 deletions

View File

@ -56,7 +56,9 @@ elif [ "$(iasl 2>/dev/null | grep -c ACPI)" -gt 0 ]; then
IASL=iasl
fi
if program_exists gcc; then
if program_exists "${XGCCPATH}/gcc"; then
HOSTCC="${XGCCPATH}/gcc"
elif program_exists gcc; then
HOSTCC=gcc
elif program_exists cc; then
HOSTCC=cc
@ -64,6 +66,20 @@ else
die "no host compiler found"
fi
# Look for a C++ compiler (for kconfig's qconf), but don't fail if there is
# none, just set the compiler to false(1) which will break early enough if
# used while being less confusing than errors about "g not found" when
# "$HOSTCXX -g" evaluates to "-g" and make drops the leading dash.
if program_exists "${XGCCPATH}/g++"; then
HOSTCXX="${XGCCPATH}/g++"
elif program_exists g++; then
HOSTCXX=g++
elif program_exists c++; then
HOSTCXX=c++
else
HOSTCXX=false
fi
# try to find the core count using various methods
CORES="$(getconf _NPROCESSORS_ONLN 2>/dev/null)"
if [ -z "$CORES" ]; then
@ -87,6 +103,7 @@ cat <<EOF
XGCCPATH:=${XGCCPATH}
IASL:=${IASL}
HOSTCC?=${HOSTCC}
HOSTCXX?=${HOSTCXX}
CPUS?=${CORES}
EOF