build-gcc.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. gcc_version=4.8.5
  3. binutils_version=2.25.1
  4. this_path=$(readlink -f $(dirname $0))
  5. make_flags='-j12'
  6. root_dir="$1"
  7. if [ -z "$root_dir" -o ! -d "$root_dir" ]; then
  8. root_dir=$(mktemp -d)
  9. fi
  10. cd $root_dir
  11. if test -z $TMPDIR; then
  12. TMPDIR=/tmp/
  13. fi
  14. wget -c -P $TMPDIR ftp://ftp.gnu.org/gnu/binutils/binutils-$binutils_version.tar.bz2 || exit 1
  15. tar xjf $TMPDIR/binutils-$binutils_version.tar.bz2
  16. mkdir binutils-objdir
  17. cd binutils-objdir
  18. # gold is disabled because we don't use it on automation, and also we ran into
  19. # some issues with it using this script in build-clang.py.
  20. ../binutils-$binutils_version/configure --prefix /tools/gcc/ --disable-gold --enable-plugins --disable-nls || exit 1
  21. make $make_flags || exit 1
  22. make install $make_flags DESTDIR=$root_dir || exit 1
  23. cd ..
  24. case "$gcc_version" in
  25. *-*)
  26. wget -c -P $TMPDIR ftp://gcc.gnu.org/pub/gcc/snapshots/$gcc_version/gcc-$gcc_version.tar.bz2 || exit 1
  27. ;;
  28. *)
  29. wget -c -P $TMPDIR ftp://ftp.gnu.org/gnu/gcc/gcc-$gcc_version/gcc-$gcc_version.tar.bz2 || exit 1
  30. ;;
  31. esac
  32. tar xjf $TMPDIR/gcc-$gcc_version.tar.bz2
  33. cd gcc-$gcc_version
  34. ./contrib/download_prerequisites
  35. patch -p1 < "${this_path}/PR64905.patch" || exit 1
  36. cd ..
  37. mkdir gcc-objdir
  38. cd gcc-objdir
  39. ../gcc-$gcc_version/configure --prefix=/tools/gcc --enable-languages=c,c++ --disable-nls --disable-gnu-unique-object --enable-__cxa_atexit --with-arch-32=pentiumpro || exit 1
  40. make $make_flags || exit 1
  41. make $make_flags install DESTDIR=$root_dir || exit 1
  42. cd $root_dir/tools
  43. tar caf $root_dir/gcc.tar.xz gcc/