added two scripts for building gnu gcc and mpss gcc (both are broken sofar)
[barrelfish] / tools / k1om / build-toolchain.sh
index 86c67cb..2150968 100755 (executable)
 set -e  # Die if any command fails.
 set -x  # Trace each command before execution.
 
-BASEDIR=$(pwd)
-BASEDIR=/home/acreto
+#-------------------------------------------------------------------------------
 
+# Modify these versions to match the corresponding patch.
+BINUTILS=binutils-2.22+mpss3.2
+GCC=gcc-4.7.0+mpss3.2
 
-export TARGET=x86_64-k1om-barrelfish
+export CC=gcc-4.6
 
 # Path of your Barrelfish source and build tree.
-BARRELFISH_SOURCE=$BASEDIR/barrelfish.xeon-phi
-BARRELFISH_BUILD=$BASEDIR/barrelfish.xeon-phi/build
+BARRELFISH_SOURCE=/home/acreto/barrelfish.xeon-phi
+BARRELFISH_BUILD=${BARRELFISH_SOURCE}/build
 
-# Modify these versions to match the corresponding patch.
-BINUTILS=binutils-2.24
-GCC=gcc-4.8.2
+# Where the toolchain will be built and installed.
+# Note: the toolchain is specific to the Barrelfish tree mentioned above.
+TOOLCHAIN_PREFIX=${BARRELFISH_SOURCE}/toolchain
 
+# Cross compiler target.
+#TARGET=x86_64-pc-barrelfish
+export TARGET=k1om-pc-barrelfish
+#TARGET=i586-pc-barrelfish
+#TARGET=i586-scc-barrelfish
 
 # Directory this shell script is stored in.
 # http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
@@ -38,13 +45,12 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 BINUTILS_PATCH="${SCRIPT_DIR}/${BINUTILS}-barrelfish.patch"
 GCC_PATCH="${SCRIPT_DIR}/${GCC}-barrelfish.patch"
 
-#-------------------------------------------------------------------------------
-
-# Where the toolchain will be built and installed.
-# Note: the toolchain is specific to the Barrelfish tree mentioned above.
-TOOLCHAIN_PREFIX=${BARRELFISH_SOURCE}/toolchain
-
-
+# Build parallelism
+MAKE_JOBS=
+if [[ -z "${MAKE_JOBS}" ]]; then
+  # Guess a sensible value - default: #cores + 2.
+  MAKE_JOBS=$(($(grep "^core id" /proc/cpuinfo | sort -u | wc -l) + 2))
+fi
 
 #-------------------------------------------------------------------------------
 
@@ -61,31 +67,23 @@ exit_with_error() { echo "error: $1" && exit 1; }
 [[ ! -f "${GCC_PATCH}" ]] && \
     exit_with_error "GCC patch not found (${GCC_PATCH})."
 
-
-# Build the toolchain.
-export PATH=${PATH}:${TOOLCHAIN_PREFIX}/bin
-export PREFIX=${TOOLCHAIN_PREFIX}
-
-
 TOOLCHAIN_BUILD="$(mktemp -d --tmpdir barrelfish-toolchain-build.XXXXXXXXXX)"
 
 
-# Build parallelism
-MAKE_JOBS=
-if [[ -z "${MAKE_JOBS}" ]]; then
-  # Guess a sensible value - default: #cores + 2.
-  MAKE_JOBS=$(($(grep "^core id" /proc/cpuinfo | sort -u | wc -l) + 2))
-fi
 
+# Build the toolchain.
+export PATH=${PATH}:${TOOLCHAIN_PREFIX}/bin
+export PREFIX=${TOOLCHAIN_PREFIX}
 
 pushd "${TOOLCHAIN_BUILD}"
 
 # 1. binutils - GNU Binary Utilities
-wget "http://ftp.gnu.org/gnu/binutils/${BINUTILS}.tar.gz"
-tar xzvf ${BINUTILS}.tar.gz
+cp "${SCRIPT_DIR}/${BINUTILS}.tar.bz2" "${TOOLCHAIN_BUILD}/${BINUTILS}.tar.bz2"
+tar xjvf "${TOOLCHAIN_BUILD}/${BINUTILS}.tar.bz2"
 pushd ${BINUTILS}/
 patch -p1 < "${BINUTILS_PATCH}"
 popd  # ${BINUTILS}/
+
 mkdir -p ${BINUTILS}-build/
 pushd ${BINUTILS}-build/
 ../${BINUTILS}/configure \
@@ -93,15 +91,23 @@ pushd ${BINUTILS}-build/
     --target="${TARGET}" \
     --enable-threads \
     --enable-lto \
+    --with-cpu-64=k1om \
+    --with-arch-64=k1om \
+    --with-tune-64=k1om \
+    --with-cpu=k1om \
+    --with-arch=k1om \
+    --with-tune=k1om \
     --enable-plugins \
-    --disable-nls
-make -j${MAKE_JOBS}
-make install-strip
+    --disable-nls \
+    --disable-doc \
+    MAKEINFO=missing
+make MAKEINFO=true ARCH=k1om -j${MAKE_JOBS}
+make MAKEINFO=true install-strip 
 popd  # ${BINUTILS}-build/
 
 # 2. GCC - GNU Compiler Collection
-wget "ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/${GCC}/${GCC}.tar.bz2"
-tar xjvf ${GCC}.tar.bz2
+cp "${SCRIPT_DIR}/${GCC}.tar.bz2" "${TOOLCHAIN_BUILD}/${GCC}.tar.bz2"
+tar xjvf "${TOOLCHAIN_BUILD}/${GCC}.tar.bz2"
 pushd ${GCC}/
 source ./contrib/download_prerequisites
 # http://stackoverflow.com/questions/407523/escape-a-string-for-sed-search-pattern
@@ -117,17 +123,55 @@ pushd ${GCC}-build/
 ../${GCC}/configure \
     --prefix="${TOOLCHAIN_PREFIX}" \
     --target="${TARGET}" \
-    --enable-languages=c,c++ \
+    --enable-languages=c \
     --enable-initfini-array \
     --disable-nls \
+    --with-multilib-list=m64 \
     --disable-libssp \
     --with-newlib \
-    --disable-multilib # from xeon phi inside cluster
-make -j$MAKE_JOBS
-make install-strip
+    --with-gnu-as \
+    --with-gnu-ld \
+    --with-cpu-64=k1om \
+    --with-arch-64=k1om \
+    --with-tune-64=k1om \
+    --with-cpu=k1om \
+    --with-arch=k1om \
+    --with-tune=k1om \
+    MAKEINFO=missing
 
+#    --disable-multilib \
+
+make MAKEINFO=true ARCH=k1om all-gcc -j$MAKE_JOBS
+make MAKEINFO=true ARCH=k1om install-gcc -j$MAKE_JOBS
+
+
+../${GCC}/configure \
+    --prefix="${TOOLCHAIN_PREFIX}" \
+    --target="${TARGET}" \
+    --enable-languages=c \
+    --enable-initfini-array \
+    --disable-nls \
+    --with-multilib-list=m64 \
+    --disable-libssp \
+    --with-newlib \
+    --with-gnu-as \
+    --with-gnu-ld \
+    --disable-shared \
+    --with-cpu-64=k1om \
+    --with-arch-64=k1om \
+    --with-tune-64=k1om \
+    --with-cpu=k1om \
+    --with-arch=k1om \
+    --with-tune=k1om \
+    MAKEINFO=missing
+
+#    --disable-multilib \
+
+make MAKEINFO=true all -j$MAKE_JOBS
+make MAKEINFO=true install-strip -j$MAKE_JOBS
 popd  # ${GCC}-build/
 
 popd  # ${TOOLCHAIN_BUILD}
 
 rm -rf "${TOOLCHAIN_BUILD}"
+rm -rf "${TOOLCHAIN_BUILD}"