From 6820949a1280595a795fac3b9df014e573aa0b4c Mon Sep 17 00:00:00 2001 From: wolfwood Date: Mon, 19 Sep 2011 00:30:20 -0400 Subject: [PATCH] build a native binutils and gcc that at least runs 'g++ --help' on xomb. assumes a previous build of the xomb branch in a separate location, which supplies a cross compiler. --- cloog.patch | 22 ++++ gmp.patch | 20 ++++ mpc.patch | 11 ++ mpfr.patch | 11 ++ native-build.sh | 312 ++++++++++++++++++++++++++++++++++++++++++++++++ ppl.patch | 22 ++++ 6 files changed, 398 insertions(+) create mode 100644 cloog.patch create mode 100644 gmp.patch create mode 100644 mpc.patch create mode 100644 mpfr.patch create mode 100755 native-build.sh create mode 100644 ppl.patch diff --git a/cloog.patch b/cloog.patch new file mode 100644 index 0000000..7d7bdad --- /dev/null +++ b/cloog.patch @@ -0,0 +1,22 @@ +diff -rupN ../../cloog-0.16.3/autoconf/config.sub ./autoconf/config.sub +--- ../../cloog-0.16.3/autoconf/config.sub 2011-09-30 23:58:48.765922513 -0400 ++++ ./autoconf/config.sub 2011-10-01 00:15:25.789236074 -0400 +@@ -1298,6 +1298,7 @@ case $os in + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ ++ | -xomb* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -rupN ../../cloog-0.16.3/isl/config.sub ./isl/config.sub +--- ../../cloog-0.16.3/isl/config.sub 2011-09-30 23:58:48.442589186 -0400 ++++ ./isl/config.sub 2011-10-01 00:29:19.405886210 -0400 +@@ -1298,6 +1298,7 @@ case $os in + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ ++ | -xomb* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ diff --git a/gmp.patch b/gmp.patch new file mode 100644 index 0000000..37ddbf3 --- /dev/null +++ b/gmp.patch @@ -0,0 +1,20 @@ +diff -rupN gmp-5.0.2.orig/configfsf.sub gmp-5.0.2/configfsf.sub +--- gmp-5.0.2.orig/configfsf.sub 2011-09-20 02:48:37.224034311 -0400 ++++ gmp-5.0.2/configfsf.sub 2011-09-20 02:53:08.140695606 -0400 +@@ -4,7 +4,7 @@ + # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, + # 2011 Free Software Foundation, Inc. + +-timestamp='2011-03-23' ++timestamp='2011-09-20' + + # This file is (in principle) common to ALL GNU software. + # The presence of a machine in this file suggests that SOME GNU software +@@ -1327,6 +1327,7 @@ case $os in + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ ++ | -xomb* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ diff --git a/mpc.patch b/mpc.patch new file mode 100644 index 0000000..4625a44 --- /dev/null +++ b/mpc.patch @@ -0,0 +1,11 @@ +diff -rupN ../../mpc-0.9/config.sub ./config.sub +--- ../../mpc-0.9/config.sub 2011-09-20 03:10:22.527341760 -0400 ++++ ./config.sub 2011-09-20 03:18:05.710665907 -0400 +@@ -1291,6 +1291,7 @@ case $os in + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ ++ | -xomb* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ diff --git a/mpfr.patch b/mpfr.patch new file mode 100644 index 0000000..419f7c0 --- /dev/null +++ b/mpfr.patch @@ -0,0 +1,11 @@ +diff -rupN ../../mpfr-3.0.1/config.sub ./config.sub +--- ../../mpfr-3.0.1/config.sub 2011-09-20 03:10:10.274008670 -0400 ++++ ./config.sub 2011-09-20 03:16:00.840668383 -0400 +@@ -1291,6 +1291,7 @@ case $os in + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ ++ | -xomb* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ diff --git a/native-build.sh b/native-build.sh new file mode 100755 index 0000000..f81ec60 --- /dev/null +++ b/native-build.sh @@ -0,0 +1,312 @@ + +# --- resources --- +function title { + echo -en "\033]0;$@\007" +} + +function setphase { + title $1 + echo ">>>>>>> $1" +} + +# --- Argument processing --- +NOTEST=1 +EXTRAS=1 + +for arg in $@; do + case $arg in + --clean) rm -rf local/ build/*/;; + --notest) NOTEST=1;; + --extras) EXTRA=1;; + esac +done + + +# --- Variables --- + +# EDIT THESE +OSNAME=xomb +NCPU=4 + +BINUTILS_VER=2.21.1 +GCC_VER=4.6.1 +GMP_VER=5.0.2 +MPFR_VER=3.1.0 +NEWLIB_VER=1.19.0 +MPC_VER=0.9 +PPL_VER=0.11.2 +CLOOG_VER=0.16.3 +# NO M0AR EDITS PLZ + +TARGET=x86_64-pc-${OSNAME} +PREFIX=`pwd`/local + +#export PATH=$PREFIX/bin:$PATH + +WFLAGS=-c + + +XOMBPATH=/home/wolfwood/repos/xomb +CROSSPATH=/home/wolfwood/repos/buildtools/local + +if [ ! -d $XOMBPATH ]; then + XOMBPATH=`pwd`/../xomb +fi + +if [ ! -f $XOMBPATH/app/build/elf.ld ]; then + echo "cannot find xomb $XOMBPATH" + exit +fi + + +#export LIBS="-l:drt0.a -l:syscall.a -l:mindrt.a" +export SHAREDLDFLAGS="-T$XOMBPATH/app/build/elf.ld" +# -L$XOMBPATH/user/c/lib -L$XOMBPATH/runtimes/mindrt" +export LDFLAGS="-static $SHAREDLDFLAGS -L$CROSSPATH/$TARGET" + +export CPPFLAGS="-I$CROSSPATH/$TARGET/include/c++ -I$CROSSPATH/$TARGET/include/c++/$GCC_VER" + +export CFLAGS="-static -O2 $CPPFLAGS" +export CXXFLAGS="$CFLAGS -lsupc++ -lstdc++ -L$CROSSPATH/$TARGET" + + +export CC=$TARGET-gcc +export CXX=$TARGET-g++ + +export AR=$TARGET-ar +export AS=$TARGET-as +#DLLTOOL +export LD=$TARGET-ld +#LIPO +export NM=$TARGET-nm +export RANLIB=$TARGET-ranlib +export STRIP=$TARGET-strip +#WINDRES +#WINDMC +export OBJCOPY=$TARGET-objcopy +export OBJDUMP=$TARGET-objdump + + +export CC_FOR_TARGET=$TARGET-gcc +export CXX_FOR_TARGET=$TARGET-g++ + +export AR_FOR_TARGET=$TARGET-ar +export AS_FOR_TARGET=$TARGET-as +#DLLTOOL +export LD_FOR_TARGET=$TARGET-ld +#LIPO +export NM_FOR_TARGET=$TARGET-nm +export RANLIB_FOR_TARGET=$TARGET-ranlib +export STRIP_FOR_TARGET=$TARGET-strip +#WINDRES +#WINDMC +export OBJCOPY_FOR_TARGET=$TARGET-objcopy +export OBJDUMP_FOR_TARGET=$TARGET-objdump + + +# --- Directory creation --- + +mkdir -p build +mkdir -p local +cd build + +setphase "MAKE OBJECT DIRECTORIES" +mkdir -p binutils-obj +mkdir -p gcc-obj +mkdir -p newlib-obj +mkdir -p gmp-obj +mkdir -p mpfr-obj +mkdir -p mpc-obj +if [ $EXTRAS -eq 1 ]; then +mkdir -p ppl-obj +mkdir -p cloog-obj +fi + +# --- Fetch and extract each package --- + +setphase "FETCH BINUTILS" +wget $WFLAGS http://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VER}.tar.bz2 +tar -xf binutils-${BINUTILS_VER}.tar.bz2 + +setphase "FETCH GCC" +wget $WFLAGS http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VER}/gcc-core-${GCC_VER}.tar.gz +tar -xf gcc-core-${GCC_VER}.tar.gz +wget $WFLAGS http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VER}/gcc-g++-${GCC_VER}.tar.gz +tar -xf gcc-g++-${GCC_VER}.tar.gz +wget $WFLAGS http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VER}/gcc-fortran-${GCC_VER}.tar.gz +tar -xf gcc-fortran-${GCC_VER}.tar.gz + +setphase "FETCH GMP" +wget $WFLAGS http://ftp.gnu.org/gnu/gmp/gmp-${GMP_VER}.tar.gz +tar -xf gmp-${GMP_VER}.tar.gz + +setphase "FETCH MPFR" +wget $WFLAGS http://ftp.gnu.org/gnu/mpfr/mpfr-${MPFR_VER}.tar.gz +tar -xf mpfr-${MPFR_VER}.tar.gz + +setphase "FETCH MPC" +wget $WFLAGS http://www.multiprecision.org/mpc/download/mpc-${MPC_VER}.tar.gz +tar -xf mpc-${MPC_VER}.tar.gz + +setphase "FETCH NEWLIB" +wget $WFLAGS ftp://sources.redhat.com/pub/newlib/newlib-${NEWLIB_VER}.tar.gz +tar -xf newlib-${NEWLIB_VER}.tar.gz + +if [ $EXTRAS -eq 1 ]; then +setphase "FETCH PPL" +wget $WFLAGS ftp://ftp.cs.unipr.it/pub/ppl/releases/${PPL_VER}/ppl-${PPL_VER}.tar.bz2 +tar -xf ppl-${PPL_VER}.tar.bz2 + +setphase "FETCH CLooG" +wget $WFLAGS http://www.bastoul.net/cloog/pages/download/count.php3?url=./cloog-${CLOOG_VER}.tar.gz -O cloog-${CLOOG_VER}.tar.gz +tar -xf cloog-${CLOOG_VER}.tar.gz +fi + +# --- Patch and push new code into each package --- + +# Fix patches with osname +#PERLCMD="s/{{OSNAME}}/${OSNAME}/g" +#perl -pi -e $PERLCMD *.patch +#perl -pi -e $PERLCMD gcc-files/gcc/config/os.h + +# diff -rupN + + +setphase "PATCH BINUTILS" +patch -p0 -d binutils-${BINUTILS_VER} < ../binutils.patch || exit +cp ../binutils-files/ld/emulparams/os_x86_64.sh binutils-${BINUTILS_VER}/ld/emulparams/${OSNAME}_x86_64.sh + +setphase "PATCH GMP" +patch -p1 -d gmp-${GMP_VER} < ../gmp.patch || exit + +setphase "PATCH MPFR" +patch -p0 -d mpfr-${MPFR_VER} < ../mpfr.patch || exit + +setphase "PATCH MPC" +patch -p0 -d mpc-${MPC_VER} < ../mpc.patch || exit + +if [ $EXTRAS -eq 1 ]; then +setphase "PATCH PPL" +patch -p0 -d ppl-${PPL_VER} < ../ppl.patch || exit + +setphase "PATCH CLOOG" +patch -p0 -d cloog-${CLOOG_VER} < ../cloog.patch || exit +fi + +setphase "PATCH GCC" +patch -p0 -d gcc-${GCC_VER} < ../gcc.patch || exit +cp ../gcc-files/gcc/config/os.h gcc-${GCC_VER}/gcc/config/${OSNAME}.h + +setphase "PATCH NEWLIB" +patch -p0 -d newlib-${NEWLIB_VER} < ../newlib.patch || exit +mkdir -p newlib-${NEWLIB_VER}/newlib/libc/sys/${OSNAME} +cp -r ../newlib-files/* newlib-${NEWLIB_VER}/newlib/libc/sys/${OSNAME}/. +cp ../newlib-files/vanilla-syscalls.c newlib-${NEWLIB_VER}/newlib/libc/sys/${OSNAME}/syscalls.c + + +# --- Compile all packages --- + +# relevant thread for building static bin utils (and dealing with ppl :) +# http://sources.redhat.com/ml/binutils/2011-08/msg00182.html +setphase "COMPILE _static_ BINUTILS" +cd binutils-obj +#--enable-plugins: Building BFD with plugin support requires a host that supports -ldl. +../binutils-${BINUTILS_VER}/configure --host=$TARGET --prefix=$PREFIX --enable-gold --disable-werror || exit +make configure-host || exit +make -j$NCPU all-gold LDFLAGS="-all-static $SHAREDLDFLAGS" || exit +make -j$NCPU LDFLAGS="-all-static $SHAREDLDFLAGS" || exit +make install || exit +cd .. + +setphase "COMPILE GMP" +cd gmp-obj +../gmp-${GMP_VER}/configure --host=$TARGET --prefix=$PREFIX --enable-cxx --disable-shared || exit +make -j$NCPU || exit +if [ $NOTEST -ne 1 ]; then + make check || exit +fi +make install || exit +cd .. + +setphase "COMPILE MPFR" +cd mpfr-obj +../mpfr-${MPFR_VER}/configure --host=$TARGET --prefix=$PREFIX --with-gmp=$PREFIX --disable-shared +make -j$NCPU || exit +if [ $NOTEST -ne 1 ]; then + make check || exit +fi +make install || exit +cd .. + +setphase "COMPILE MPC" +cd mpc-obj +../mpc-${MPC_VER}/configure --host=$TARGET --prefix=$PREFIX --with-gmp=$PREFIX --with-mpfr=$PREFIX --disable-shared || exit +make -j$NCPU || exit +if [ $NOTEST -ne 1 ]; then + make check || exit +fi +make install || exit +cd .. + +if [ $EXTRAS -eq 1 ]; then +setphase "COMPILE PPL" +cd ppl-obj +../ppl-${PPL_VER}/configure --host=$TARGET --prefix=$PREFIX --with-gmp-prefix=$PREFIX --disable-shared || exit +make -j$NCPU || exit +if [ $NOTEST -ne 1 ]; then + make check || exit +fi +make install || exit +cd .. + +setphase "COMPILE CLOOG" +cd cloog-obj +../cloog-${CLOOG_VER}/configure --host=$TARGET --prefix=$PREFIX --with-gmp-prefix=$PREFIX --disable-shared || exit +make -j$NCPU || exit +if [ $NOTEST -ne 1 ]; then + make check || exit +fi +make install || exit +cd .. +fi + +setphase "AUTOCONF GCC" +cd gcc-${GCC_VER}/libstdc++-v3 +#autoreconf || exit +#autoconf || exit +cd ../.. + +setphase "COMPILE GCC" +cd gcc-obj +../gcc-${GCC_VER}/configure --prefix=$PREFIX --host=$TARGET --enable-languages=c,c++ --disable-libssp --with-gmp=$PREFIX --with-mpfr=$PREFIX --with-mpc=$PREFIX --with-ppl=$PREFIX --enable-cloog-backend=isl --disable-nls --with-newlib --without-headers --disable-shared || exit +#--with-cloog=$PREFIX +make -j$NCPU all-gcc LDFLAGS="$LDFLAGS" || exit +make install-gcc LDFLAGS="$LDFLAGS" || exit +cd .. + +setphase "AUTOCONF NEWLIB-XOMB" +cd newlib-${NEWLIB_VER}/newlib/libc/sys +autoconf || exit +cd ${OSNAME} +autoreconf || exit +cd ../../../../.. + +setphase "CONFIGURE NEWLIB" +cp ../newlib-files/syscalls.c newlib-${NEWLIB_VER}/newlib/libc/sys/${OSNAME}/syscalls.c +cd newlib-obj +../newlib-${NEWLIB_VER}/configure --target=$TARGET --host=$TARGET --prefix=$PREFIX --with-gmp=$PREFIX --with-mpfr=$PREFIX -enable-newlib-hw-fp || exit + +setphase "COMPILE NEWLIB" +make -j$NCPU || exit +make install || exit +cd .. + +setphase "PASS-2 COMPILE GCC" +cd gcc-obj +#make all-target-libgcc +#make install-target-libgcc +make -j$NCPU all-target-libstdc++-v3 LDFLAGS="$LDFLAGS" || exit +make install-target-libstdc++-v3 LDFLAGS="$LDFLAGS" || exit +make -j$NCPU all LDFLAGS="$LDFLAGS" || exit +make install LDFLAGS="$LDFLAGS" || exit +cd .. diff --git a/ppl.patch b/ppl.patch new file mode 100644 index 0000000..157d579 --- /dev/null +++ b/ppl.patch @@ -0,0 +1,22 @@ +diff -rupN ../../ppl-0.11.2/config.sub ./config.sub +--- ../../ppl-0.11.2/config.sub 2011-02-27 04:07:47.000000000 -0500 ++++ ./config.sub 2011-09-30 22:36:38.336020289 -0400 +@@ -1306,6 +1306,7 @@ case $os in + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ ++ | -xomb* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -rupN ../../ppl-0.11.2/Watchdog/config.sub ./Watchdog/config.sub +--- ../../ppl-0.11.2/Watchdog/config.sub 2011-02-27 04:07:47.000000000 -0500 ++++ ./Watchdog/config.sub 2011-09-30 22:35:51.082687892 -0400 +@@ -1306,6 +1306,7 @@ case $os in + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ ++ | -xomb* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \