Click "show" to see how to compile GCC 4.7.1 (soon to be outdated)
There was already a thread on Nekochan about compiling 4.6.3 on IRIX, there's also a Chinese webpage that details installing 4.7.1.
Since Nekochan is down, I figured I should make a thread on how to do it here. Also, there are a things I came across that none of those aforementioned guides mentioned. Also, we're going to be compiling this assuming it's going to be packaged for IRISWare.
Prerequisites
neko texinfo, neko m4, neko perl, neko tar, neko wget and at least gcc 4.3.x (all available in Nekoware)
A decently fast machine (took 16+ hours to compile on my 2x 250 MHz Octane)
CFLAGS and CXXFLAGS<
IRISWare requires the -O2 flag.
PATH stuff
Obviously make sure the GCC version you're going to be compiling with is in your PATH.
Also, make sure to set LD_LIBRARY_PATH properly, e.g. if you're compiling with 4.3.x and using csh:
Code:
setenv LD_LIBRARY_PATH /usr/nekoware/gcc-4.3/lib:/usr/nekoware/gcc-4.3/lib32
<B>
Getting stuff</B>
I'd recommend making a folder called gccbuild or something like that in /var/tmp. After making it, cd there.
Next, open up your favorite editor and save this, chmod +x it, and run it to download everything you need.
Code:
wget ftp://ftp.gmplib.org/pub/gmp-5.0.5/gmp-5.0.5.tar.bz2
wget ftp://ftp.gnu.org/gnu/binutils/binutils-2.23.1.tar.bz2
wget ftp://ftp.gnu.org/gnu/mpfr/mpfr-3.1.1.tar.bz2
wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.1.tar.gz
wget http://www.bugseng.com/products/ppl/download/ftp/releases/0.11/ppl-0.11.tar.gz
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-ppl-0.15.11.tar.gz
wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.7.1/gcc-4.7.1.tar.bz2
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
rm *.tar.bz2 *.tar.gz
Building
Unless otherwise stated, to build each project, cd into the directory, run the configure line I've provided, and then make by the use of
Code:
gmake -j[amount of CPUs +1]
. For example, on my Octane I used
. I've heard it's a good rule of thumb to use one more CPU than you have as it makes sure they stay fed. This most definitely applies to modern systems, and it won't really hurt here. Also, it is a good idea to run
Code:
gmake -j[amount of CPUs +1] check
after compiling PPL, CLooG-PPL, and binutils, but it is not absolutely necessary if you are willing to live on the edge and go without these checks.
Patches
libgomp must be patched in order to correctly detect the number of CPUs.
Create /opt/local/patches/gcc47-libgomp.patch with this inside:
Code:
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. */
<B>
Configure lines</B>
<B>
After each is done building, you should run gmake install</B>
gmp
Code:
./configure --disable-shared --enable-static --prefix=/opt/local/gcc47 --enable-cxx CPPFLAGS=-fexceptions
<B>
IMPORTANT NOTE:</B>
You may experience an error during compilation due to a lack of uint_least32_t for C++ on IRIX. If so, gmake clean then configure again with this command then try building:
Code:
./configure --disable-shared --enable-static --prefix=/opt/local/gcc47 --enable-cxx CPPFLAGS=-fexceptions ac_cv_type_uint_least32_t=no
mpfr
Code:
./configure --disable-shared --enable-static --prefix=/opt/local/gcc47 --with-gmp=/opt/local/gcc47
mpc
Code:
./configure --disable-shared --enable-static --prefix=/opt/local/gcc47 --with-gmp=/opt/local/gcc47 --with-mpfr=/opt/local/gcc47
ppl
Code:
./configure --disable-shared --enable-static --prefix=/opt/local/gcc47 --with-gmp-prefix=/opt/local/gcc47 --without-java --disable-watchdog --disable-ppl_lcdd --disable-ppl_lpsol --disable-ppl_pips CPPFLAGS=-fexceptions
IMPORTANT NOTE: We don't have getopt_long.
Before compiling:
* delete D["HAVE_GETOPT_H"]=" 1" line in config.status
* edit config.h + src/ppl.hh.dist to change lines w/ HAVE_GETOPT_H to comments
If you get an error regarding a missing warnings.pm, set the PERL5LIB environment variable to the nekoware perl5 lib folder. Example for csh:
Code:
setenv PERL5LIB /usr/nekoware/lib/perl5/5.8.9
cloog-ppl
Code:
./configure --disable-shared --enable-static --prefix=/opt/local/gcc47 --with-gmp=/opt/local/gcc47 --with-ppl=/opt/local/gcc47
IMPORTANT NOTE:
If the configure line for binutils/gcc is too long, save it in a file first then run it with
.
binutils
Configure & build binutils in a separate directory:
Code:
<i>
</i>cd .. && mkdir bu-objs && cd bu-objs
../binutils-2.23.1/configure --prefix=/opt/local/gcc47 --with-gmp=/opt/local/gcc47 --with-mpfr=/opt/local/gcc47 --with-mpc=/opt/local/gcc47 --with-ppl=/opt/local/gcc47 --with-cloog=/opt/local/gcc47 --with-host-libstdcxx=/usr/nekoware/gcc-4.3/lib32/libstdc++.a --disable-libssp --disable-nls --disable-lto --disable-ld --disable-gold --disable-werror --without-docdir
gcc
Also configured & built gcc in a separate directory
Code:
cd ../gcc-4.7.1 && patch < /opt/local/patches/gcc47-libgomp.patch
cd .. && mkdir gcc-objs && cd gcc-objs
../gcc-4.7.1/configure --prefix=/opt/local/gcc47 --with-gmp=/opt/local/gcc47 --with-mpfr=/opt/local/gcc47 --with-mpc=/opt/local/gcc47 --with-cloog=/opt/local/gcc47 --with-ppl=/opt/local/gcc47 --with-as=/opt/local/gcc47/bin/as --with-gnu-as --without-gnu-ld --with-ld=/usr/bin/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-obsolete --enable-checking=release --enable-languages=c,c++ --with-arch=mips4 --with-abi=n32
IMPORTANT NOTE: There is an issue that rears its head when working with gcc compilation in IRIX which seems to be undocumented in the previous guides. The default IRIX environment space is only 20K, that that is too small for one of the commands gmake install needs to run to install gcc. You can remedy this by running
Code:
systune ncargs 65536
, which gives you 64K of argument/environment space.
Post-build cleanup
You can free up some space after the build by running
Code:
rm -r /opt/local/gcc47/share/doc /opt/local/gcc47/share/aclocal /opt/local/gcc47/share/man/man3 /opt/local/gcc47/share/man/man7 /opt/local/gcc47/share/man/man1/ppl-config.1 /opt/local/gcc47/share/info /opt/local/gcc47/lib/*.{a,la} /opt/local/gcc47/bin/ppl-config /opt/local/gcc47/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}
strip -s /opt/local/gcc47/bin/* /opt/local/gcc47/mips-sgi-irix6.5/bin/* /opt/local/gcc47/libexec/gcc/mips-sgi-irix6.5/4.7.1/* /opt/local/gcc47/libexec/gcc/mips-sgi-irix6.5/4.7.1/install-tools/fixincl /opt/local/gcc47/libexec/gcc/mips-sgi-irix6.5/4.7.1/plugin/gengtype
<B>
Checking</B>
It is a good idea to run some gcc testsuites. Be warned, though, that these can take quite a long time.
Code:
gmake check-gcc-c
gmake check-target-libgomp
gmake check-gcc-c++
gmake check-target-libstdc++-v3