buildgcc: Deal with gmp on 32bit Linux on 64bit CPUs

GMP is overeager to detect 64bit ABIs even if the entire running codebase is
32bit (but on a 64bit CPU). Enforce a 32bit build in that situation.

Change-Id: I23e9e57f3c8b0e3ad2e4e1e3eb106f7830aa76a1
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Reviewed-on: http://review.coreboot.org/10792
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index b78b141..e0b4ed4 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -615,6 +615,12 @@
 	if $CC -v 2>&1 | grep -q LLVM; then
 		CC=llvm-gcc
 	fi
+elif [ $UNAME = "Linux" ]; then
+	# gmp is overeager with detecting 64bit CPUs even if they run
+	# a 32bit kernel and userland.
+	if [ "$(uname -m 2>/dev/null)" = "i686" ]; then
+		OPTIONS="ABI=32"
+	fi
 fi
 fi # GCC