diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2015-04-25 13:05:10 -0700 |
---|---|---|
committer | Vadim Bendebury <vbendeb@chromium.org> | 2015-04-28 03:21:59 +0200 |
commit | 05a8472900ab2a57218b5f3affdaad1df10ed44e (patch) | |
tree | a11f6a32a4ad81bea4537ba4d9d9f4755fc70d3d | |
parent | d2cb1f93fb9c911a386d12bd9cb1a86e3b7767fa (diff) | |
download | coreboot-staging-05a8472900ab2a57218b5f3affdaad1df10ed44e.zip coreboot-staging-05a8472900ab2a57218b5f3affdaad1df10ed44e.tar.gz |
xcompile: improve mips toolchain handling
The mips toolchain used by coreboot so far comes from Chrome OS chroot
and is built explicitly for little endian code generation.
Other flavors of MIPS toolchain usually generate big endian code by
default and require command line options to switch to little endian
mode.
This patch adds another variable to the set of compiler flags examined
to determine compiler compatibility. This results in adding another
nested for loop in test_architecture(). To avoid the need to break
from different levels of nesting, processing of the successful case is
taken out from test_architecture().
With this change the Mentor Graphics provided mips GCC toolchain is
accepted by xcompile, resulting in the following output:
ARCH_SUPPORTED+=mips
SUBARCH_SUPPORTED+=mips mipsel
CC_mips:=mips-linux-gnu-gcc
CFLAGS_mips:= -Wno-unused-but-set-variable -fno-stack-protector -Wl,--build-id=none -mno-abicalls -fno-pic -EL
CPP_mips:=mips-linux-gnu-cpp
AS_mips:=mips-linux-gnu-as
LD_mips:=mips-linux-gnu-ld
NM_mips:=mips-linux-gnu-nm
OBJCOPY_mips:=mips-linux-gnu-objcopy
OBJDUMP_mips:=mips-linux-gnu-objdump
READELF_mips:=mips-linux-gnu-readelf
STRIP_mips:=mips-linux-gnu-strip
AR_mips:=mips-linux-gnu-ar
Change-Id: I4da384b366880929693c59dc0e1c522b35c41bea
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/9997
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
-rwxr-xr-x | util/xcompile/xcompile | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile index 4a0fcf7..e079c9d 100755 --- a/util/xcompile/xcompile +++ b/util/xcompile/xcompile @@ -80,13 +80,15 @@ testas() { local twidth="$2" local arch="$3" local use_dash_twidth="$4" + local endian="$5" local obj_file="$TMPFILE.o" local full_arch="elf$twidth-$arch" rm -f "$obj_file" [ -n "$use_dash_twidth" ] && use_dash_twidth="--$twidth" - ${gccprefix}as $use_dash_twidth -o "$obj_file" $TMPFILE 2>/dev/null || - return 1 + [ -n "$endian" ] && endian="-$endian" + ${gccprefix}as $use_dash_twidth $endian -o "$obj_file" $TMPFILE \ + 2>/dev/null || return 1 # Check output content type. local obj_type="$(${gccprefix}objdump -p $obj_file)" @@ -147,6 +149,10 @@ detect_special_flags() { mipsel) testcc "$CC" "$CFLAGS -mno-abicalls -fno-pic" && \ CFLAGS+=" -mno-abicalls -fno-pic" + + # Enforce little endian mode. + testcc "$CC" "$CFLAGS -EL" && \ + CFLAGS+=" -EL" ;; esac } @@ -215,14 +221,15 @@ arch_config_mipsel() { TWIDTH="32" TSUPP="mips mipsel" TABI="elf" + TENDIAN="EL" } test_architecture() { local architecture=$1 - local gccprefix search + local endian gccprefix search GCCPREFIX="invalid" - unset TARCH TBFDARCH TCLIST TWIDTH TSUPP TABI + unset TABI TARCH TBFDARCH TCLIST TENDIAN TSUPP TWIDTH if type arch_config_$architecture > /dev/null; then arch_config_$architecture else @@ -247,23 +254,24 @@ test_architecture() { for TBFDARCH in $TBFDARCHS; do for gccprefix in $search ""; do program_exists "${gccprefix}as" || continue - testas "$gccprefix" "$TWIDTH" "$TBFDARCH" "" && break - testas "$gccprefix" "$TWIDTH" "$TBFDARCH" "TRUE" && break + for endian in $TENDIAN ""; do + testas "$gccprefix" "$TWIDTH" "$TBFDARCH" \ + "" "$endian" && return 0 + testas "$gccprefix" "$TWIDTH" "$TBFDARCH" \ + "TRUE" "$endian" && return 0 + done done - [ "$GCCPREFIX" = "invalid" ] || break done - if [ "$GCCPREFIX" = "invalid" ]; then - echo "Warning: no suitable GCC for $architecture." >&2 - continue - fi - CC="${GCCPREFIX}"gcc - - detect_special_flags "$architecture" - report_arch_toolchain + echo "Warning: no suitable GCC for $architecture." >&2 + return 1 } # This loops over all supported architectures. for architecture in $SUPPORTED_ARCHITECTURES; do - test_architecture $architecture + if test_architecture $architecture; then + CC="${GCCPREFIX}"gcc + detect_special_flags "$architecture" + report_arch_toolchain + fi done |