Build GCC 4.7.1 on IRIX

From Nekochan
Jump to: navigation, search

Disk space required: about 4 GB
Estimated build time: about 2 hours on a 16-processor Origin 3400
Estimated time to run the testsuite: about 17.5 hours (single-threaded)

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>. Also, don't forget to replace every instance of /usr/nekoware/gcc-4.7 with the directory you wish to install GCC into.

You will need GCC 4.3.2 from Nekoware, or something newer to build this; GCC 3.x won't do. To run the testsuite, you will need dejagnu and expect from Nekoware.


0. Make a build directory:

cd /var/tmp && mkdir build-gcc && cd build-gcc

You can delete this directory after installation is complete.


1. Download prerequisites:

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.23.1.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.7.1/gcc-4.7.1.tar.bz2


2. Extract packages:

This will take a while, make yourself some coffee :)

tar jxf gmp-5.0.5.tar.bz2 && tar jxf binutils-2.23.1.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.7.1.tar.bz2

You can now delete the archives to save disk space:

rm *.tar.bz2 *.tar.gz


3. Build gmp:

cd gmp-5.0.5
./configure --disable-shared --enable-static --prefix=/usr/nekoware/gcc-4.7 --enable-cxx CPPFLAGS=-fexceptions
gmake -j16
gmake -j16 check
sudo gmake install
gmake clean


4. Build mpfr:

cd ../mpfr-3.1.1
./configure --disable-shared --enable-static --prefix=/usr/nekoware/gcc-4.7 --with-gmp=/usr/nekoware/gcc-4.7
gmake -j16
gmake -j16 check
sudo gmake install
gmake clean


5. Build mpc:

cd ../mpc-1.0.1
./configure --disable-shared --enable-static --prefix=/usr/nekoware/gcc-4.7 --with-gmp=/usr/nekoware/gcc-4.7 --with-mpfr=/usr/nekoware/gcc-4.7
gmake -j16
gmake -j16 check
sudo gmake install
gmake clean


6. Build PPL:

cd ../ppl-0.11
./configure --disable-shared --enable-static --prefix=/usr/nekoware/gcc-4.7 --with-gmp-prefix=/usr/nekoware/gcc-4.7 --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.

gmake -j16
sudo gmake install
sudo gmake clean


7. Build CLooG-PPL:

cd ../cloog-ppl-0.15.11
./configure --disable-shared --enable-static --prefix=/usr/nekoware/gcc-4.7 --with-gmp=/usr/nekoware/gcc-4.7 --with-ppl=/usr/nekoware/gcc-4.7
gmake -j16
sudo gmake install
gmake clean


8. Build binutils:

cd .. && mkdir bu-objs && cd bu-objs
../binutils-2.23.1/configure --prefix=/usr/nekoware/gcc-4.7 --with-gmp=/usr/nekoware/gcc-4.7 --with-mpfr=/usr/nekoware/gcc-4.7 --with-mpc=/usr/nekoware/gcc-4.7 --with-ppl=/usr/nekoware/gcc-4.7 --with-cloog=/usr/nekoware/gcc-4.7 --with-host-libstdcxx=/opt/gcc-4.7.1/lib32/libstdc++.a --disable-libssp --disable-nls --disable-lto --disable-ld --disable-gold --disable-werror --without-docdir
gmake -j16
sudo gmake install
sudo rm /usr/nekoware/gcc-4.7/bin/strip /usr/nekoware/gcc-4.7/mips-sgi-irix6.5/bin/strip /usr/nekoware/gcc-4.7/share/man/man1/strip.1
gmake clean

Note: in the above configure options you need to provide the full path to libstdc++.a of the gcc you are using to compile this binutils package (I used a previously-compiled version of gcc 4.7.1 I had installed under /opt/gcc-4.7.1). For example, if you're using gcc-4.3 from Nekoware, use /usr/nekoware/gcc-4.3/lib32/libstdc++.a instead of /opt/gcc-4.7.1/lib32/libstdc++.a.


9. Build gcc:

First we have to patch libgomp (used by OpenMP code) to properly detect the number of processors on IRIX:

cd ../gcc-4.7.1 && patch < /usr/nekoware/patches/gcc47-libgomp.patch

The contents of that patch are as follows:

diff -urnp libgomp-orig/config/posix/proc.c libgomp/config/posix/proc.c
*** libgomp-orig/config/posix/proc.c    Sat Dec  8 14:57:52 2012
--- libgomp/config/posix/proc.c Sat Dec  8 14:58:43 2012
***************
*** 38,43 ****
--- 38,48 ----
  #endif
  
  
+ #ifdef __sgi
+ #define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN
+ #endif
+ 
+ 
  /* At startup, determine the default number of threads.  It would seem
     this should be related to the number of cpus online.  */

Now we can configure, build, and install GCC.

cd .. && mkdir gcc-objs && cd gcc-objs

../gcc-4.7.1/configure --prefix=/usr/nekoware/gcc-4.7 --with-gmp=/usr/nekoware/gcc-4.7 --with-mpfr=/usr/nekoware/gcc-4.7 --with-mpc=/usr/nekoware/gcc-4.7 --with-cloog=/usr/nekoware/gcc-4.7 --with-ppl=/usr/nekoware/gcc-4.7 --with-as=/usr/nekoware/gcc-4.7/bin/as --with-gnu-as --without-gnu-ld --with-ld=/usr/bin/ld --with-host-libstdcxx=/opt/gcc-4.7.1/lib32/libstdc++.a --disable-libssp --disable-nls --disable-lto --disable-shared --enable-static --enable-threads=posix --enable-libgomp --enable-obsolete --enable-checking=release --enable-languages=c,c++,fortran,objc,obj-c++ --with-arch=mips4 --with-abi=n32

/usr/bin/time gmake -j16 STAGE1_CFLAGS=-O2
# 6641s
sudo gmake install

Note: in the above configure options you need to provide the full path to libstdc++.a of the gcc you are using to compile this gcc (I used a previously-compiled version of gcc 4.7.1 I had installed under /opt/gcc-4.7.1). For example, if you're using gcc-4.3 from Nekoware, use /usr/nekoware/gcc-4.3/lib32/libstdc++.a instead of /opt/gcc-4.7.1/lib32/libstdc++.a.


Now you can run the testsuite. I've split the tests because some of them take a really long time to complete.

/usr/bin/time gmake check-gcc-c
# 16416s
/usr/bin/time gmake check-target-libgomp
# 3355s
/usr/bin/time gmake check-gcc-c++
# 8798s
/usr/bin/time gmake check-target-libstdc++-v3
# 20585s
/usr/bin/time gmake check-gcc-fortran
# 13322s
/usr/bin/time gmake check-gcc-objc
# 630s
/usr/bin/time gmake check-gcc-obj-c++
# 198s

You may now delete the build directory:

cd ../..
rm -rf build-gcc


10. Free up lots of space:

This reduces the size of the install directory from about 800MB to 198MB.

sudo rm -r /usr/nekoware/gcc-4.7/share/doc /usr/nekoware/gcc-4.7/share/aclocal /usr/nekoware/gcc-4.7/share/man/man3 /usr/nekoware/gcc-4.7/share/man/man7 /usr/nekoware/gcc-4.7/share/man/man1/ppl-config.1 /usr/nekoware/gcc-4.7/share/info /usr/nekoware/gcc-4.7/lib/*.{a,la} /usr/nekoware/gcc-4.7/bin/ppl-config /usr/nekoware/gcc-4.7/include/{ansidecl.h,bfd.h,bfdlink.h,cloog,dis-asm.h,gmp.h,gmpxx.h,mpc.h,mpf2mpfr.h,mpfr.h,ppl.hh,ppl_c.h,symcat.h}

sudo strip -s /usr/nekoware/gcc-4.7/bin/* /usr/nekoware/gcc-4.7/mips-sgi-irix6.5/bin/* /usr/nekoware/gcc-4.7/libexec/gcc/mips-sgi-irix6.5/4.7.1/* /usr/nekoware/gcc-4.7/libexec/gcc/mips-sgi-irix6.5/4.7.1/install-tools/fixincl /usr/nekoware/gcc-4.7/libexec/gcc/mips-sgi-irix6.5/4.7.1/plugin/gengtype