[coreboot-gerrit] Patch set updated for coreboot: buildgcc: Add option to bootstrap a host gcc

Nico Huber (nico.h@gmx.de) gerrit at coreboot.org
Tue Apr 19 13:22:26 CEST 2016


Nico Huber (nico.h at gmx.de) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13473

-gerrit

commit d93f18cb9bd3e194cea55a288fa311db3666ecc5
Author: Nico Huber <nico.huber at secunet.com>
Date:   Tue Jan 26 16:10:17 2016 +0100

    buildgcc: Add option to bootstrap a host gcc
    
    Bootstrapping gcc is the recommended way if your host gcc's version
    doesn't match the gcc version you're going to build. While a build
    with an outdated host gcc usually succeeds, an outdated gnat seems
    to be a bigger issue.
    
    Some library controversy: gcc likes the libraries it ships with most
    but we don't want to install shared libraries. So we build them static
    (--disable-shared) and install only the minimum (libgcc, libada,
    libstdc++). However, as the code of these libraries might be used to
    build a shared library we have to compile them with `-fPIC`.
    
    So far build tested with `make BUILDGCC_OPTIONS="-b -l c,ada"` on
      o Ubuntu 14.04 "Trusty Tahr"
      o Debian 8 "Jessie"
      o current Arch Linux
    
    Change-Id: Icb47d3e9dbafc55737fbc3ce62a084fb9d5f359a
    Signed-off-by: Nico Huber <nico.huber at secunet.com>
---
 util/crossgcc/buildgcc | 55 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 51 insertions(+), 4 deletions(-)

diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index eddafe5..860f3ea 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -18,8 +18,8 @@
 
 cd $(dirname $0)
 
-CROSSGCC_DATE="April 3rd, 2016"
-CROSSGCC_VERSION="1.38"
+CROSSGCC_DATE="April 19th, 2016"
+CROSSGCC_VERSION="1.39"
 CROSSGCC_COMMIT=$( git describe )
 
 # default settings
@@ -30,6 +30,7 @@ LANGUAGES=c
 DESTDIR=
 SAVETEMPS=0
 SKIPPYTHON=1
+BOOTSTRAP=0
 
 # GCC toolchain version numbers
 GMP_VERSION=6.1.0
@@ -342,6 +343,9 @@ build_for_target()
 build()
 {
 	if package_uses_targetarch $1; then
+		if [ $BOOTSTRAP -eq 1 -a ! -f "${TARGETDIR}/.GCC.success" ]; then
+			build_for_host GCC
+		fi
 		build_for_target $1
 	else
 		build_for_host $1
@@ -381,6 +385,8 @@ myhelp()
 	printf "    [-P|--package <package>]      Build a specific package: GCC, CLANG, IASL, GDB\n"
 	printf "                                  (defaults to $PACKAGE)\n"
 	printf "GCC specific options:\n"
+	printf "    [-b|--bootstrap]              bootstrap the host compiler before building\n"
+	printf "                                  the cross compiler\n"
 	printf "    [-p|--platform <platform>]    target platform to build cross compiler for\n"
 	printf "                                  (defaults to $TARGETARCH)\n"
 	printf "    [-l|--languages <languages>]  comma separated list of target languages\n"
@@ -493,8 +499,40 @@ build_BINUTILS() {
 	$MAKE install DESTDIR=$DESTDIR || touch .failed
 }
 
-
-build_GCC() {
+bootstrap_GCC() {
+	# Work around crazy code generator in GCC that confuses CLANG.
+	$CC --version | grep clang >/dev/null 2>&1 && \
+		LOCALCFLAGS="$HOSTCFLAGS -fbracket-depth=1024" || \
+		LOCALCFLAGS="$HOSTCFLAGS"
+
+	CC="$CC" \
+		CFLAGS="$LOCALCFLAGS" \
+		CFLAGS_FOR_BUILD="$LOCALCFLAGS" \
+		CFLAGS_FOR_TARGET="$LOCALCFLAGS -fPIC" \
+		CXXFLAGS="$LOCALCFLAGS" \
+		CXXFLAGS_FOR_BUILD="$LOCALCFLAGS" \
+		CXXFLAGS_FOR_TARGET="$LOCALCFLAGS -fPIC" \
+		../gcc-${GCC_VERSION}/configure \
+		--prefix=$TARGETDIR --libexecdir=$TARGETDIR/lib \
+		--enable-bootstrap \
+		--disable-werror --disable-nls \
+		--disable-shared --disable-multilib \
+		--disable-libssp --disable-libquadmath --disable-libcc1 \
+		${GCC_OPTIONS} --enable-languages="${LANGUAGES}" \
+		--with-gmp=$DESTDIR$TARGETDIR --with-mpfr=$DESTDIR$TARGETDIR \
+		--with-mpc=$DESTDIR$TARGETDIR --with-libelf=$DESTDIR$TARGETDIR \
+		--with-pkgversion="coreboot bootstrap v$CROSSGCC_VERSION $CROSSGCC_DATE" \
+		&& \
+	$MAKE $JOBS BOOT_CFLAGS="$LOCALCFLAGS" BUILD_CONFIG="" bootstrap && \
+	$MAKE	install-gcc \
+		install-target-libgcc \
+		maybe-install-target-libada \
+		maybe-install-target-libstdc++-v3 \
+		DESTDIR=$DESTDIR && \
+	ln -s gcc $DESTDIR$TARGETDIR/bin/cc || touch .failed
+}
+
+build_cross_GCC() {
 	# Work around crazy code generator in GCC that confuses CLANG.
 	$CC --version | grep clang >/dev/null 2>&1 && \
 		HOSTCFLAGS="$HOSTCFLAGS -fbracket-depth=1024"
@@ -532,6 +570,14 @@ build_GCC() {
 	fi
 }
 
+build_GCC() {
+	if [ "$1" = host ]; then
+		bootstrap_GCC
+	else
+		build_cross_GCC
+	fi
+}
+
 build_EXPAT() {
 	CC="$CC" CFLAGS="$HOSTCFLAGS" ../${EXPAT_DIR}/configure --disable-shared \
 		--prefix=$TARGETDIR --target=${TARGETARCH} || touch .failed
@@ -657,6 +703,7 @@ while true ; do
 		-c|--clean)	shift; clean=1;;
 		-t|--savetemps)	shift; SAVETEMPS=1;;
 		-d|--directory)	shift; TARGETDIR="$1"; shift;;
+		-b|--bootstrap) shift; BOOTSTRAP=1;;
 		-p|--platform)	shift; TARGETARCH="$1"; shift;;
 		-l|--languages)	shift; LANGUAGES="$1"; shift;;
 		-D|--destdir)	shift; DESTDIR="$1"; shift;;



More information about the coreboot-gerrit mailing list