Hi,

after the recent troubles with various compilers miscompiling coreboot,
we decided to publish the script we use to build the compiler we use at
coresystems.
It requires a gnu compatible tar, gnu patch, wget and probably has
other, hidden dependencies on behaviour as found on Linux and Mac OS X.

Running buildgcc downloads the tarballs (tarball subdirectory), patches
the trees slightly (the attached patches must reside in the same
directory), links them together (in a totally unsupported but working
way), and builds and installs the toolchain (into $PWD/xgcc).
Add $PWD/xgcc/bin to your PATH, abuild should pick up the crosscompiler
automatically.


Regards,
Patrick
#!/bin/bash
GMPVER=4.2.4
MPFRVER=2.3.2
GCCVER=4.3.2
BINUTILSVER=2.18.50
BINUTILSTARVER=${BINUTILSVER}-20080109-2
TARGETDIR=`pwd`/xgcc

mkdir -p tarballs
if [ ! -f tarballs/gmp-${GMPVER}.tar.bz2 ]; then
        (cd tarballs; wget ftp://ftp.gmplib.org/pub/gmp-${GMPVER}.tar.bz2)
fi
if [ ! -f tarballs/mpfr-${MPFRVER}.tar.bz2 ]; then
        (cd tarballs; wget 
http://www.mpfr.org/mpfr-current/mpfr-${MPFRVER}.tar.bz2)
fi
if [ ! -f tarballs/gcc-core-${GCCVER}.tar.bz2 ]; then
        (cd tarballs; wget 
ftp://ftp.gwdg.de/pub/gnu/ftp/gnu/gcc/gcc-${GCCVER}/gcc-core-${GCCVER}.tar.bz2)
fi
if [ ! -f tarballs/binutils-${BINUTILSTARVER}-src.tar.gz ]; then
        (cd tarballs; wget 
http://switch.dl.sourceforge.net/sourceforge/mingw/binutils-${BINUTILSTARVER}-src.tar.gz)
fi
if [ ! -d gmp-${GMPVER} ]; then
        tar jxvf tarballs/gmp-${GMPVER}.tar.bz2
fi
if [ ! -d mpfr-${MPFRVER} ]; then
        tar jxvf tarballs/mpfr-${MPFRVER}.tar.bz2
fi
if [ ! -d gcc-${GCCVER} ]; then
        tar jxvf tarballs/gcc-core-${GCCVER}.tar.bz2
        patch -N -p0 < use-gnu-style-comments-in-assembly.patch
fi
if [ ! -d binutils-${BINUTILSVER} ]; then
        tar zxvf tarballs/binutils-${BINUTILSTARVER}-src.tar.gz
        patch -N -p0 < no-i386-svr4-asm-comments.patch
fi
if [ ! -d combined ]; then
        mkdir combined
        (cd combined
                ln -s ../gcc-${GCCVER}/* . 2>/dev/null
                ln -s ../binutils-${BINUTILSVER}/* . 2>/dev/null
                rm include
                mkdir include
                cd include
                ln -s ../../gcc-${GCCVER}/include/* . 2>/dev/null
                ln -s ../../binutils-${BINUTILSVER}/include/* . 2>/dev/null
        )
fi
mkdir -p build-gmp build-mpfr build-gcc
(cd build-gmp
        ../gmp-${GMPVER}/configure --disable-shared --prefix=$TARGETDIR ABI=32
        make
        make install
)
CFLAGS=`grep __GMP_CFLAGS $TARGETDIR/include/gmp.h |cut -d\" -f2`
test `uname` == "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL"
(cd build-mpfr
        ../mpfr-${MPFRVER}/configure --disable-shared --prefix=$TARGETDIR 
--with-gmp=$TARGETDIR CFLAGS="$CFLAGS"
        make
        make install
)
(cd build-gcc
        ../combined/configure --prefix=$TARGETDIR --target=i386-elf 
--disable-libssp --disable-bootstrap --with-gmp=$TARGETDIR 
--with-mpfr=$TARGETDIR CFLAGS="$CFLAGS"
        make
        make install
)
--- binutils-2.18.50/gas/config/tc-i386.c~      2009-01-20 14:19:04.000000000 
+0100
+++ binutils-2.18.50/gas/config/tc-i386.c       2009-01-20 14:20:47.000000000 
+0100
@@ -183,6 +183,7 @@
         && !defined (TE_GNU)                           \
         && !defined (TE_LINUX)                         \
         && !defined (TE_NETWARE)                       \
+        && 0                                           \
         && !defined (TE_FreeBSD)                       \
         && !defined (TE_NetBSD)))
 /* This array holds the chars that always start a comment.  If the
--- gcc-4.3.2/gcc/config/i386/unix.h~   2009-01-20 16:05:45.000000000 +0100
+++ gcc-4.3.2/gcc/config/i386/unix.h    2009-01-20 16:05:47.000000000 +0100
@@ -32,7 +32,7 @@
 
 /* String containing the assembler's comment-starter.  */
 
-#define ASM_COMMENT_START "/"
+#define ASM_COMMENT_START "#"
 
 /* Output to assembler file text saying following lines
    may contain character constants, extra white space, comments, etc.  */
-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to