util/xcompile: Allow overriding default compiler path

When looking for C compilers, xcompile uses the "" prefix to "gcc" and
"clang" as a last-resort option. This fails in environments where such
default names are blocked to prevent "unclean" builds - such as Chrome
OS.

Allow overriding this prefix using the GENERIC_COMPILER_PREFIX variable
that is hopefully both descriptive enough to suggest what it is for and
unusual enough to not trigger by chance.

Change-Id: I16239f66730f1dbcb7482f223cea4ee5957af10c
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/56643
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Patrick Georgi 2021-07-27 22:30:34 +02:00
parent 340cb9ae2c
commit 719d85bf56
1 changed files with 4 additions and 2 deletions

View File

@ -10,6 +10,8 @@ if [ "$1" = "--debug" ]; then
set -x set -x
fi fi
# GENERIC_COMPILER_PREFIX defaults to empty but can be used to override
# compiler search behavior
TMPFILE="" TMPFILE=""
XGCCPATH=$1 XGCCPATH=$1
@ -421,7 +423,7 @@ test_architecture() {
# Search toolchain by checking assembler capability. # Search toolchain by checking assembler capability.
for TBFDARCH in $TBFDARCHS; do for TBFDARCH in $TBFDARCHS; do
for gccprefix in $search ""; do for gccprefix in $search "$GENERIC_COMPILER_PREFIX"; do
program_exists "${gccprefix}as" || continue program_exists "${gccprefix}as" || continue
for endian in $TENDIAN ""; do for endian in $TENDIAN ""; do
{ testas "$gccprefix" "$TWIDTH" "$TBFDARCH" \ { testas "$gccprefix" "$TWIDTH" "$TBFDARCH" \
@ -439,7 +441,7 @@ test_architecture() {
fi fi
for clang_arch in $TCLIST invalid; do for clang_arch in $TCLIST invalid; do
for clang_prefix in $search $XGCCPATH ""; do for clang_prefix in $search $XGCCPATH "$GENERIC_COMPILER_PREFIX"; do
testcc "${clang_prefix}clang" "-target ${clang_arch}-$TABI -c" && break 2 testcc "${clang_prefix}clang" "-target ${clang_arch}-$TABI -c" && break 2
done done
done done