[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
Thu Apr 21 14:29:07 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 b07a023bc2b8a2b52eb5eff5e3d6a364b281c465
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.
    
    v3: 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`.
    
    v4: o Updated getopt strings.
        o The workaround for clang (-fbracket-depth=1024) isn't needed
          for bootstrapping and also breaks the build, as clang is only
          used for the first stage in that case and gcc doesn't know
          that option.
    
    So far build tested with `make BUILDGCC_OPTIONS="-b -l c,ada"` on
      o Ubuntu 14.04 "Trusty Tahr" (i386)
      o Debian 8 "Jessie" (x86_64) (building python (-S) works too)
      o current Arch Linux (x86_64)
    
    and with clang host compiler, thus C only: `make BUILDGCC_OPTIONS="-b"`
    on
      o Debian 8 "Jessie" (x86_64)
      o FreeBSD 10.3 (x86_64)
    
    Change-Id: Icb47d3e9dbafc55737fbc3ce62a084fb9d5f359a
    Signed-off-by: Nico Huber <nico.huber at secunet.com>
---
 util/crossgcc/buildgcc | 54 ++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 48 insertions(+), 6 deletions(-)

diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index fae8bd3..df5aa45 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 20th, 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
@@ -386,6 +390,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"
@@ -498,8 +504,35 @@ build_BINUTILS() {
 	$MAKE install DESTDIR=$DESTDIR || touch .failed
 }
 
-
-build_GCC() {
+bootstrap_GCC() {
+	CC="$CC" \
+		CFLAGS="$HOSTCFLAGS" \
+		CFLAGS_FOR_BUILD="$HOSTCFLAGS" \
+		CFLAGS_FOR_TARGET="$HOSTCFLAGS -fPIC" \
+		CXXFLAGS="$HOSTCFLAGS" \
+		CXXFLAGS_FOR_BUILD="$HOSTCFLAGS" \
+		CXXFLAGS_FOR_TARGET="$HOSTCFLAGS -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="$HOSTCFLAGS" 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"
@@ -537,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
@@ -642,11 +683,11 @@ getopt - > /dev/null 2>/dev/null || gcc -o getopt getopt.c
 getoptbrand="$(getopt -V | sed -e '1!d' -e 's,^\(......\).*,\1,')"
 if [ "${getoptbrand}" = "getopt" ]; then
 	# Detected GNU getopt that supports long options.
-	args=$(getopt -l version,help,clean,directory:,platform:,languages:,package:,jobs:,destdir:,savetemps,scripting,ccache,supported: Vhcd:p:l:P:j:D:tSys: -- "$@")
+	args=$(getopt -l version,help,clean,directory:,bootstrap,platform:,languages:,package:,jobs:,destdir:,savetemps,scripting,ccache,supported: Vhcd:bp:l:P:j:D:tSys: -- "$@")
 	eval set "$args"
 else
 	# Detected non-GNU getopt
-	args=$(getopt Vhcd:p:l:P:j:D:tSys: $*)
+	args=$(getopt Vhcd:bp:l:P:j:D:tSys: $*)
 	set -- $args
 fi
 
@@ -662,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