Index: tools/trusted_cross_toolchains/mips_tc_build.sh |
diff --git a/tools/trusted_cross_toolchains/mips_tc_build.sh b/tools/trusted_cross_toolchains/mips_tc_build.sh |
new file mode 100755 |
index 0000000000000000000000000000000000000000..af069fcb5cb93025d73d5672df8fd7ab9592fb71 |
--- /dev/null |
+++ b/tools/trusted_cross_toolchains/mips_tc_build.sh |
@@ -0,0 +1,184 @@ |
+#!/bin/bash |
+# |
+# Copyright 2012 The Native Client Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can |
+# be found in the LICENSE file. |
+ |
+# This script is intended to build a mipsel-linux-gnu cross compilation |
+# toolchain that runs on x86 linux and generates code for a little-endian, |
+# hard-float, mips32 target. |
+# |
+# It expects the host machine to have relatively recent versions of GMP (4.2.0 |
+# or later), MPFR (2.4.2), and MPC (0.8.1) in order to build the GCC. |
+# |
+# Common way to get those is: |
+# sudo apt-get install libmpfr-dev libmpc-dev libgmp3-dev |
+set -eu |
Mark Seaborn
2012/10/04 15:10:46
Nit: add an empty line before this to separate it
|
+ |
+arch="mips32" |
+ |
+top_dir=`pwd` |
+bld_dir="$top_dir/obj" |
Mark Seaborn
2012/10/04 15:10:46
Can you make these less cryptic, please? i.e. "bu
|
+tar_dir="$top_dir/tars" |
+src_dir="$top_dir/src" |
+ins_nam="mips-toolchain" |
+ins_dir="$top_dir/$ins_nam" |
+sys_dir="$ins_dir/sysroot" |
+ |
+export PATH=$ins_dir/bin:/usr/sbin:/usr/bin:/sbin:/bin |
Mark Seaborn
2012/10/04 15:10:46
Please do
export PATH=$ins_dir/bin:$PATH
so that t
|
+ |
+echo -n "cleaning up" |
+rm -rf $bld_dir |
+echo -n "." |
+rm -rf $sys_dir |
+echo -n "." |
+rm -rf $ins_dir |
+echo -n "." |
+rm -rf $src_dir |
+echo "done" |
+ |
+# get the code |
+echo "downloading the sources" |
+ |
+mkdir -p $tar_dir |
+cd $tar_dir |
+ |
+ |
+ |
+if [ ! -f 'binutils-2.22.tar.bz2' ]; then |
+ wget http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.bz2 |
Mark Seaborn
2012/10/04 15:10:46
Can you write
wget http://ftp.gnu.org/gnu/binuti
|
+fi |
+checksum=`sha1sum binutils-2.22.tar.bz2 | cut -d ' ' -f 1` |
+if [ "$checksum" != "65b304a0b9a53a686ce50a01173d1f40f8efe404" ]; then |
+ echo "binutils-2.22.tar.bz2 sha1sum failed, file deleted" |
Mark Seaborn
2012/10/04 15:10:46
Please indent blocks by 2 spaces
|
+ rm -f binutils-2.22.tar.bz2 |
+ exit |
Mark Seaborn
2012/10/04 15:10:46
This should be "exit 1" since this is an error
|
+fi |
+ |
+ |
+ |
+if [ ! -f 'gcc-4.6.3.tar.bz2' ]; then |
Mark Seaborn
2012/10/04 15:10:46
There's a lot of duplication here. Can you factor
|
+ wget http://ftp.gnu.org/gnu/gcc/gcc-4.6.3/gcc-4.6.3.tar.bz2 |
+fi |
+checksum=`sha1sum gcc-4.6.3.tar.bz2 | cut -d ' ' -f 1` |
+if [ "$checksum" != "ce317ca5c8185b58bc9300182b534608c578637f" ]; then |
+ echo "gcc-4.6.3.tar.bz2 sha1sum failed, file deleted" |
+ rm -f gcc-4.6.3.tar.bz2 |
+ exit |
+fi |
+ |
+ |
+ |
+if [ ! -f 'linux-2.6.38.4.tar.gz' ]; then |
+ wget http://www.linux-mips.org/pub/linux/mips/kernel/v2.6/linux-2.6.38.4.tar.gz |
+fi |
+checksum=`sha1sum linux-2.6.38.4.tar.gz | cut -d ' ' -f 1` |
+if [ "$checksum" != "377fa5cf5f1d0c396759b1c4d147330e7e5b6d7f" ]; then |
+ echo "linux-2.6.38.4.tar.gz sha1sum failed, file deleted" |
+ rm -f linux-2.6.38.4.tar.gz |
+ exit |
+fi |
+ |
+ |
+ |
+if [ ! -f 'gdb-7.5.tar.gz' ]; then |
+ wget http://ftp.gnu.org/gnu/gdb/gdb-7.5.tar.gz |
+fi |
+checksum=`sha1sum gdb-7.5.tar.gz | cut -d ' ' -f 1` |
+if [ "$checksum" != "57b58bc5b959e420d9aeb4cfeaa3b2fd7c685a10" ]; then |
+ echo "gdb-7.5.tar.gz sha1sum failed, file deleted" |
+ rm -f gdb-7.5.tar.gz |
+ exit |
+fi |
+ |
+svn export -r 20996 svn://svn.eglibc.org/branches/eglibc-2_14 eglibc-2_14 |
+ |
+ |
+ |
+cd $top_dir |
+ |
+#untar all |
Mark Seaborn
2012/10/04 15:10:46
Please put a space after '#' in comments. And cap
|
+echo -n "unpacking the sources" |
+mkdir -p $src_dir |
+cd $src_dir |
+tar xjf $tar_dir/binutils-2.22.tar.bz2 |
+echo -n "." |
+tar xjf $tar_dir/gcc-4.6.3.tar.bz2 |
+echo -n "." |
+tar xzf $tar_dir/linux-2.6.38.4.tar.gz linux-2.6.38.4 |
+echo -n "." |
+tar xzf $tar_dir/gdb-7.5.tar.gz |
+echo -n "." |
+#tar xzf $tar_dir/eglibc-2_14.tar.gz |
Mark Seaborn
2012/10/04 15:10:46
Please remove this commented-out line
|
+mv $tar_dir/eglibc-2_14 . |
+echo "done" |
+cd $top_dir |
+ |
+#prepare the code |
+cd $src_dir/eglibc-2_14/libc/ && ln -s ../ports ports && cd - |
Mark Seaborn
2012/10/04 15:10:46
Can you replace "&&" with a newline, please? Same
|
+ |
+cd $src_dir/binutils-2.22/gas/config && OLD_TEXT="as_warn_where (fragp->fr_file, fragp->fr_line, msg);" && NEW_TEXT="as_warn_where (fragp->fr_file, fragp->fr_line, \"%s\", msg);" && FILE_NAME="$PWD/tc-mips.c" && sed -i "s/$OLD_TEXT/$NEW_TEXT/g" "$FILE_NAME" && cd - |
+ |
+ |
+#build the toolchain |
+echo "building the toolchain" |
+mkdir -p $bld_dir/binutils/ |
+cd $bld_dir/binutils/ |
+$src_dir/binutils-2.22/configure --prefix=$ins_dir --target=mipsel-linux-gnu --with-sysroot=$sys_dir |
+make --jobs=3 all-binutils all-gas all-ld || exit 1 |
Mark Seaborn
2012/10/04 15:10:46
"|| exit 1" isn't necessary since you have "set -e
|
+make --jobs=3 install-binutils install-gas install-ld || exit 1 |
+mkdir -p $bld_dir/gcc/initial |
Mark Seaborn
2012/10/04 15:10:46
For readability, can you separate the build of eac
|
+cd $bld_dir/gcc/initial |
+$src_dir/gcc-4.6.3/configure --prefix=$ins_dir --disable-libssp --disable-libgomp --disable-libmudflap --disable-fixed-point --disable-decimal-float --with-mips-plt --with-endian=little --with-arch=$arch --target=mipsel-linux-gnu --enable-languages=c --with-newlib --without-headers --disable-shared --disable-threads --disable-libquadmath --disable-libatomic |
+make --jobs=3 all || exit 1 |
+make --jobs=3 install || exit 1 |
+cd $src_dir/linux-2.6.38.4 |
+make headers_install ARCH=mips INSTALL_HDR_PATH=$sys_dir/usr || exit 1 |
+export BUILD_CC=gcc |
+export AR=mipsel-linux-gnu-ar |
+export RANLIB=mipsel-linux-gnu-ranlib |
+export CC=mipsel-linux-gnu-gcc |
+export CXX=mipsel-linux-gnu-g++ |
+mkdir -p $bld_dir/eglibc/initial |
+cd $bld_dir/eglibc/initial |
+$src_dir/eglibc-2_14/libc/configure --prefix=/usr --with-headers=$sys_dir/usr/include --build=i686-pc-linux-gnu --host=mipsel-linux-gnu --disable-profile --without-gd --without-cvs --enable-add-ons |
+make --jobs=3 install-headers install_root=$sys_dir install-bootstrap-headers=yes || exit 1 |
+mkdir -p $sys_dir/usr/lib |
+make csu/subdir_lib && cp csu/crt1.o csu/crti.o csu/crtn.o $sys_dir/usr/lib || exit 1 |
+mipsel-linux-gnu-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $sys_dir/usr/lib/libc.so |
+unset BUILD_CC AR RANLIB CC CXX |
+mkdir -p $bld_dir/gcc/intermediate |
+cd $bld_dir/gcc/intermediate |
+$src_dir/gcc-4.6.3/configure --prefix=$ins_dir --disable-libssp --disable-libgomp --disable-libmudflap --disable-fixed-point --disable-decimal-float --with-mips-plt --with-endian=little --with-arch=$arch --target=mipsel-linux-gnu --enable-languages=c --with-sysroot=$sys_dir --disable-libquadmath --disable-libatomic |
+make --jobs=3 all || exit 1 |
+make --jobs=3 install || exit 1 |
+export BUILD_CC=gcc |
+export AR=mipsel-linux-gnu-ar |
+export RANLIB=mipsel-linux-gnu-ranlib |
+export CC=mipsel-linux-gnu-gcc |
+export CXX=mipsel-linux-gnu-g++ |
+mkdir -p $bld_dir/eglibc/final |
+cd $bld_dir/eglibc/final |
+$src_dir/eglibc-2_14/libc/configure --prefix=/usr --with-headers=$sys_dir/usr/include --build=i686-pc-linux-gnu --host=mipsel-linux-gnu --disable-profile --without-gd --without-cvs --enable-add-ons |
+make --jobs=3 all || exit 1 |
+make --jobs=3 install install_root=$sys_dir || exit 1 |
+unset BUILD_CC AR RANLIB CC CXX |
+mkdir -p $bld_dir/gcc/final |
+cd $bld_dir/gcc/final |
+$src_dir/gcc-4.6.3/configure --prefix=$ins_dir --disable-libssp --disable-libgomp --disable-libmudflap --disable-fixed-point --disable-decimal-float --with-mips-plt --with-endian=little --with-arch=$arch --target=mipsel-linux-gnu --enable-languages=c,c++ --with-sysroot=$sys_dir --enable-__cxa_atexit |
+make --jobs=3 all || exit 1 |
+make --jobs=3 install || exit 1 |
+mkdir -p $bld_dir/gdb/ |
+cd $bld_dir/gdb/ |
+$src_dir/gdb-7.5/configure --prefix=$ins_dir --target=mipsel-linux-gnu |
+make --jobs=3 all-gdb |
+make --jobs=3 install-gdb |
+echo "done" |
+ |
+#Make toolchain tarball |
+echo -n "packing the toolchain..." |
+cd $top_dir |
+tar czf mips-toolchain.tar.gz $ins_nam |
+ |
+echo "done" |
+echo |