Compiling GCC 2.8.1 on SGI IRIX 6.2, 6.3, and 6.4

This page describes how to compile the GNU C and C++ 2.8.1 compilers (GCC) on the Silicon Graphics (SGI) IRIX 6.x platform. Previous versions of GCC did not support the IRIX 6.x platform; there were tricks available that allowed you to build an IRIX 5.3 compiler version, but there was no native support for the new n32 and 64 binary formats. The new 2.8.1 GCC versions supports IRIX 6.x in native mode.

The instructions on this page can also be used to compile egcs, according to Ian McKellar (thanks Ian!).

Instead of compiling GCC 2.8.1 yourself, you can also get a .tardist from Ariel Faigon's freeware for IRIX site. This package installs directly from the web.

Note: if you have build GCC 2.8.0 according to the instructions on this page, you should definitively upgrade to GCC 2.8.1 and build it according to this new instructions. After joining the gcc2 mailing list, it turned out that I made some mistakes in my compiling instructions.

Mirrors are faster!

Available mirrors for this page: [NL] [US]

The latest version of this page is always available here.

Do you need libg++?

Before you build GCC, you have to decide if you want to compile libg++. Libg++ is considered obsolete and its functionality has been replaced by libstdc++. For compatibility reasons, there is still an up-to-date versions of libg++ available. If you have software that depends on libg++, you have to download and compile it; if not, libstdc++ is sufficient.

What do you need?

What do you get?

You'll get a copy of the world-famous freeware GNU C compiler on your IRIX system. GCC supports C, C++, and Objective C. You can use GCC for various reasons:

GCC supports both the n32 and the 64 ABI. GCC will generate n32 binaries as a default, but you can force it to generate 64 binaries by using the -mabi=64 command line option. The older 32 ABI is not yet supported, but you can generate an 32 compiler by just configuring for irix5.

Step by step instructions

  1. Get the source (sic).
  2. Uncompress the source:
    gzip -dc gcc-2.8.1.tar.gz | tar xvf -
    gzip -dc libstdc++-2.8.1.tar.gz | tar xvf -
  3. Clean up your path. You should not have any reference s to old GCC versions or (worse) GNU assembler and linker in your path. A good path is:
    /usr/sbin /sbin /usr/bsd /usr/bin /bin /usr/bin/X11
    Your mileage may vary.
  4. Go tho the GCC directory and configure GCC:
    cd gcc-2.8.1
    ./configure --enable-threads --prefix=/usr/gnu
    Choose the prefixes you like, read the GNU autoconf documentation for more information.
  5. Compile the stage1 compiler using the native SGI compiler:
    gmake LANGUAGES=c
  6. Install the stage1 compiler:
    gmake stage1
  7. Compile the stage2 compiler using the just installed stage1 compiler:
    gmake CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O"
  8. Install the stage2 compiler:
    gmake stage2
  9. Compile the stage3 compiler using the just installed stage2 compiler:
    gmake CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O"
  10. Check if the compiler is build properly:
    gmake compare
    You should not get any error.
  11. Install GCC:
    gmake install CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O"
    You probably have to be root to do this.
  12. Go to the libstdc++ directory:
    cd ../libstc++-2.8.1
  13. Set the CC and CXX environment variable to the freshly installed GCC (csh style):
    setenv CC /usr/gnu/bin/gcc
    setenv CXX /usr/gnu/bin/gcc
    Or Bourne shell style:
    CC=/usr/gnu/bin/gcc ; export CC
    CXX=/usr/gnu/bin/gcc ; export CXX
  14. Configure libstdc++:
    ./configure --prefix=/usr/gnu
    Again, use the prefixes you like, but use the same prefixes as you used for GCC itself.
  15. Compile libstdc++:
    gmake
  16. Install libstdc++:
    gmake install

That's it, you now have a running copy of GCC 2.8.1 on your system. If you want to install libg++, you'll have to compile and install it now. I don't need it, so I did not compile it. (If you provide me with building instructions, I will include them on this page).

Hints for compiling libg++

To compile libg++, you have to untar the libg++ source in the libstdc++ directory. Now configure and install libstdc++ in the usual way, and libg++ will automatically be configured and installed in the right way. I have not tried this on IRIX machines, but it worked perfectly on a SunOS 4.1.3 machine. Your mileage may vary.

Known bugs (and fixes)

If you're using C++ templates, you can get the following linker warnings when using g++:

ld: WARNING 131: Multiply defined weak symbol:(__tf6f_NODE) in
libfoo.a(bar.o) and
libgnu.a(gnats.o) (2nd definition ignored).

The linker is correct, but there's nothing you can do about it; this is just the way g++ handles templates. If these warnings annoy you, you can switch them off by editing the file /usr/gnu/lib/gcc-lib/mips-sgi-irix6.3/2.8.1/specs: search for the link entry and insert -woff 131 just before -_SYSTYPE_SVR4. In future versions of g++, this warning will be switched off as a default.


If you are using a SGI MipsPRO 7.0 compiler, be sure to set the -32 flag when compiling the stage1 compiler. From Jim Wilson on the egcs mailing list (egcs@cygnus.com):

> 2. Is "cc -n32" support truly buggy, or can we use it?

Every SGI compiler I tried up through 7.0beta had a bug that caused gcc to be miscompiled. 7.0beta had only a single bug, which caused an optimization to be disabled, but did not cause bad code. Hence if using 7.0beta, a stage2/stage3 comparison would fail, but a stage3/stage4 comparison would succeed. The one bug I reported against 7.0beta was fixed in 7.1. All versions prior to 7.0beta have serious bugs that can not be worked around easily.

I never tested any compiler after 7.0beta, by then I had gotten in the habit of always using cc -32 when using the SGI compiler. My suspicion though is that bootstrapping with -n32 would work with 7.1 and later compilers. The 7.1 compilers have probably been out for 2 years or so by now.

Setting the -32 flag for the stage1 compiler can be done by using CFLAGS="-32" in step 5. I have not tried this (using a 7.1 compiler), so your mileage may vary.


You should also read Ariel Faigon's notes on using gcc 2.8.1.

Acknowledgments

Thanks to:


Back to my homepage.

Homepage of the Information and Communication Theory Group.

Ariel's Freeware for IRIX page.


Valid HTML 3.2!

Erik Mouw
Last modified: Fri Fri 4 11:14:22 MET 1998