GCC has one of the crappiest build processes ever devised by man, so I made this howto to help people build it as pleasantly as possible.
You will need about 4GB of disk space. It takes about 2.5 hours to build everything on a 16-processor Origin 3400 (8x 500MHz + 8x 400MHz, 16GB of RAM).
Most of that time is spent in "genattrtab", which is _glacially_ slow and should be rewritten. The rest of that time is spent by gmake re-running "configure" for the 2873517th time. There is also some compiling
You may skip the "gmake -j16 check" step while building gmp, mpfr, and mpc.
If you are building this on a machine with a different number of processors, replace every "gmake -j16" below with "gmake -j<your_number_of_cpus_here>".
You will need GCC 4.3.2 from Nekoware, or something newer to build this; GCC 3.x won't do. Binutils also need the 'texinfo' package for some reason.
Anyway, let's begin.
0. Make a build directory:
Code:
mkdir build-gcc && cd build-gcc
You can delete this directory after installation is complete.
1. Download prerequisites:
Code:
curl -O ftp://ftp.gmplib.org/pub/gmp-5.0.5/gmp-5.0.5.tar.bz2
curl -O http://ftp.gnu.org/gnu/binutils/binutils-2.18.tar.bz2
curl -O http://www.mpfr.org/mpfr-current/mpfr-3.1.1.tar.bz2
curl -O http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz
curl -O ftp://gcc.gnu.org/pub/gcc/infrastructure/ppl-0.11.tar.gz
curl -O ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-ppl-0.15.11.tar.gz
curl -O ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.6.3/gcc-4.6.3.tar.bz2
2. Extract packages:
This will take a while, make yourself some coffee
Code:
tar jxf gmp-5.0.5.tar.bz2 && tar jxf binutils-2.18.tar.bz2 && tar jxf mpfr-3.1.1.tar.bz2 && tar zxf mpc-1.0.1.tar.gz && tar zxf ppl-0.11.tar.gz && tar zxf cloog-ppl-0.15.11.tar.gz && tar jxf gcc-4.6.3.tar.bz2
You can now delete the archives to save disk space:
Code:
rm *.tar.bz2 *.tar.gz
3. Build gmp:
Code:
cd gmp-5.0.5
./configure --disable-shared --enable-static --prefix=/opt/gcc-4.6.3 --enable-cxx CPPFLAGS=-fexceptions
gmake -j16
gmake -j16 check
sudo gmake install
gmake clean
4. Build mpfr:
Code:
cd ../mpfr-3.1.1
./configure --disable-shared --enable-static --prefix=/opt/gcc-4.6.3 --with-gmp=/opt/gcc-4.6.3
gmake -j16
gmake -j16 check
sudo gmake install
gmake clean
5. Build mpc:
Code:
cd ../mpc-1.0.1
./configure --disable-shared --enable-static --prefix=/opt/gcc-4.6.3 --with-gmp=/opt/gcc-4.6.3 --with-mpfr=/opt/gcc-4.6.3
gmake -j16
gmake -j16 check
sudo gmake install
gmake clean
6. Build PPL:
Code:
cd ../ppl-0.11
./configure --disable-shared --enable-static --prefix=/opt/gcc-4.6.3 --with-gmp-prefix=/opt/gcc-4.6.3 --without-java --disable-watchdog --disable-ppl_lcdd --disable-ppl_lpsol --disable-ppl_pips CPPFLAGS=-fexceptions
The configure script thinks we have support for getopt_long, but we don't. Correct that error manually by editing
config.h
and
src/ppl.hh.dist
-- comment out the lines containing "HAVE_GETOPT_H". You also have to delete the line with D["HAVE_GETOPT_H"]=" 1" in
config.status
.
Code:
gmake -j16
sudo gmake install
sudo gmake clean
7. Build CLooG-PPL:
Code:
cd ../cloog-ppl-0.15.11
./configure --disable-shared --enable-static --prefix=/opt/gcc-4.6.3 --with-gmp=/opt/gcc-4.6.3 --with-ppl=/opt/gcc-4.6.3
gmake -j16
sudo gmake install
gmake clean
8. Build binutils:
Code:
cd .. && mkdir bu-objs && cd bu-objs
../binutils-2.18/configure --prefix=/opt/gcc-4.6.3 --with-gmp=/opt/gcc-4.6.3 --with-mpfr=/opt/gcc-4.6.3 --with-mpc=/opt/gcc-4.6.3 --disable-libssp --disable-nls --disable-werror --without-docdir
gmake -j16
sudo gmake install
gmake clean
9. Build gcc:
Code:
cd .. && mkdir gcc-objs && cd gcc-objs
../gcc-4.6.3/configure --prefix=/opt/gcc-4.6.3 --with-gmp=/opt/gcc-4.6.3 --with-mpfr=/opt/gcc-4.6.3 --with-mpc=/opt/gcc-4.6.3 --with-cloog=/opt/gcc-4.6.3 --with-ppl=/opt/gcc-4.6.3 --with-as=/opt/gcc-4.6.3/bin/as --with-ld=/opt/gcc-4.6.3/bin/ld --with-gnu-as --with-gnu-ld --with-host-libstdcxx=/usr/nekoware/gcc-4.3/lib32/libstdc++.a --disable-libssp --disable-nls --disable-lto --disable-shared --enable-static --enable-threads=posix --enable-libgomp --enable-languages=c,c++,fortran,objc,obj-c++ --with-arch=mips4 --with-abi=n32
gmake -j16
sudo gmake install
You may now delete the build directory:
Code:
cd ../..
rm -rf build-gcc
10. Free up lots of space:
This reduces the size of the install directory from almost 600MB to 175MB.
Code:
sudo rm -r /opt/gcc-4.6.3/share/doc /opt/gcc-4.6.3/share/aclocal /opt/gcc-4.6.3/share/man/man3 /opt/gcc-4.6.3/share/man/man7 /opt/gcc-4.6.3/share/man/man1/ppl-config.1 /opt/gcc-4.6.3/share/info /opt/gcc-4.6.3/info /opt/gcc-4.6.3/lib/*.{a,la} /opt/gcc-4.6.3/bin/ppl-config
sudo strip -s /opt/gcc-4.6.3/bin/* /opt/gcc-4.6.3/mips-sgi-irix6.5/bin/* /opt/gcc-4.6.3/libexec/gcc/mips-sgi-irix6.5/4.6.3/* /opt/gcc-4.6.3/libexec/gcc/mips-sgi-irix6.5/4.6.3/install-tools/fixincl
That's all, folks