Loading...
 

GCC on IRIX

Some versions of GCC are available and working for IRIX. Officially, support for GCC was removed in 2011 for the 4.8.x releases as per GCC's support policy. All mainline working versions are prior to this.

Compiling

This section will cover compiling various GCC versions IRIX 6.5.22 or later.

5.4.0

Library Versions Used:

  • gmp-6.20
  • isl-0.18
  • mpc-1.1.0
  • mpfr-4.0.2


Recommended GCC version: 4.7.4

GCC configure command:

./configure --prefix=/opt/local/gcc5/ --libdir=/opt/local/gcc5/lib32 --disable-silent-rules --disable-nls --disable-multilib --enable-obsolete --enable-languages=c,c++ --disable-bootstrap --enable-shared --enable-static --enable-threads=posix --enable-tls=no --enable-lto --with-gmp=/usr/nekoware/ --with-gmp-lib=/usr/nekoware/lib32 --with-system-zlib LD=/opt/local/gcc-4.7.4/bin/ld AS=/opt/local/gcc-4.7.4/bin/as CC=/opt/local/gcc-4.7.4/bin/gcc CXX=/opt/local/gcc-4.7.4/bin/g++ CFLAGS=-O2 -mips4 CXXFLAGS=-O2 -mips4 CPPFLAGS='-I/usr/nekoware/include -I/usr/include' LDFLAGS='-L/usr/nekoware/lib32'


Then run gmake -j<nCPU+1> to build

Testsuite requires autogen, guile etc.

Notes: Ensure there's at least 3G of memory to build this. If not, initialize some swap.

http://irix.cc/gcc5-mipsiv-irix.tar.gz - Prepatched GCC code.

4.7.3

Prerequisites:

  • texinfo
  • m4
  • bsdtar (from libarchive) or gtar
  • gcc 4.3.x or newer.


This guide assumes the /opt/local prefix.

First, set the kernel's argument space:

systune ncargs 65536


Check the LD_LIBRARY_PATH to ensure GCC libs are in PATH.

Make a directory in /var/tmp for the build. Then run:

ftp ftp://ftp.gmplib.org/pub/gmp-5.1.3/gmp-5.1.3.tar.bz2
ftp ftp://ftp.gnu.org/gnu/binutils/binutils-2.23.2.tar.bz2
ftp ftp://ftp.gnu.org/gnu/mpfr/mpfr-3.1.2.tar.bz2
ftp ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.1.tar.gz
ftp ftp://ftp.gnu.org/gnu/gcc/gcc-4.7.3/gcc-4.7.3.tar.bz2
tar jxf gmp-5.1.3.tar.bz2 && tar jxf binutils-2.23.2.tar.bz2 && tar jxf mpfr-3.1.2.tar.bz2 && tar zxf mpc-1.0.1.tar.gz && tar jxf gcc-4.7.3.tar.bz2
rm *.tar.bz2 *.tar.gz

libgomp must be patched. Create /opt/local/patches/gcc473-libgomp.patch with this inside:

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.  */

dwarf2cfi.c must be patched in order to prevent an error during the GCC build. Create /opt/local/patches/gcc473-dwarf2cfi.patch

--- dwarf2cfi.c    2012-01-10 00:28:55.000000000 -0800
+++ dwarf2cfi_patch.c    2018-07-20 14:42:17.251616220 -0700
@@ -1240,6 +1240,10 @@

   add_cfi_restore (regno);
   update_row_reg_save (cur_row, regno, NULL);
+  if (REG_P (INCOMING_RETURN_ADDR_RTX)
+    && regno == dwf_regno (INCOMING_RETURN_ADDR_RTX)
+    && regno != DWARF_FRAME_RETURN_COLUMN)
+    reg_save (DWARF_FRAME_RETURN_COLUMN, regno, 0);
}

/* A subroutine of dwarf2out_frame_debug, process a REG_CFA_WINDOW_SAVE.


Now begin building the various components.

GNU MP:

./configure --prefix=/opt/local/gcc473 --enable-cxx CPPFLAGS=-fexceptions ac_cv_type_uint_least32_t=no
gmake
gmake install


MPFR:

./configure --prefix=/opt/local/gcc473 --with-gmp-include=/opt/local/gcc473/include --with-gmp-lib=/opt/local/gcc473/lib
gmake
gmake install


MPCL:

./configure --prefix=/opt/local/gcc473 --with-gmp-include=/opt/local/gcc473/include --with-gmp-lib=/opt/local/gcc473/lib --with-mpfr-include=/opt/local/gcc473/include --with-mpfr-lib=/opt/local/gcc473/lib
gmake
gmake install


Now binutils:

cd .. && mkdir bu-objs && cd bu-objs

../binutils-2.23.2/configure --prefix=/opt/local/gcc473 --enable-obsolete --with-gmp-include=/opt/local/gcc473/include --with-gmp-lib=/opt/local/gcc473/lib --with-mpfr-include=/opt/local/gcc473/include --with-mpfr-lib=/opt/local/gcc473/lib --with-mpc-include=/opt/local/gcc473/lib --with-mpc-lib=/opt/local/gcc473/lib --without-ppl --without-cloog --without-isl --disable-werror
gmake
gmake install


Now GCC:

cd ../gcc-4.7.1 && patch < /opt/local/patches/gcc473-libgomp.patch && cd gcc && patch < /opt/local/patches/gcc473-dwarf2cfi.patch

cd /var/tmp/gccbuild && mkdir gcc-objs && cd gcc-objs

../gcc-4.7.3/configure --prefix=/opt/local/gcc473 --enable-obsolete --with-as=/opt/local/gcc473/bin/as --with-gnu-as --with-gmp-include=/opt/local/gcc473/include --with-gmp-lib=/opt/local/gcc473/lib --with-mpfr-include=/opt/local/gcc473/include --with-mpfr-lib=/opt/local/gcc473/lib --with-mpc-include=/opt/local/gcc473/include --with-mpc-lib=/opt/local/gcc473/lib --enable-languages=c,c++ --without-ppl --without-cloog --without-isl --without-gnu-ld --with-ld=/usr/bin/ld --with-abi=n32
gmake
gmake install


To run the testsuites:

gmake check-gcc-c
gmake check-target-libgomp
gmake check-gcc-c++
gmake check-target-libstdc++-v3


Larbob's tests yielded:

=== gcc Summary ===

  1. of expected passes 75096
  2. of unexpected failures 24
  3. of expected failures 112
  4. of unsupported tests 1236
/var/tmp/gccbuild/gcc-objs/gcc/xgcc version 4.7.3 (GCC)

Known Bugs

This section serves to categorize unresolved bugs in IRIX with GCC and provide help for developers looking to use GCC instead of MIPSPro. Developers are welcomed to share patches for these bugs, but IRIX Network does not host, aggregate or fork GCC code as the GCC project has made it clear that they will not upstream support or accept patches for older GCC versions. With this in mind, it's not advisable to try pursuing reinstatement of IRIX support upstream.

Structure Sizing

The gcc compiler does not correctly pass/return structures that are smaller than 16 bytes and which are not 8 bytes. gcc is consistent with itself, but not consistent with the MIPSpro C compiler, so the only failures that can happen are when mixing code compiled with the two compilers. Recent releases of libgcc have special wrapper procedures that contain the known instances of these functions in libc. Note that this may not be true for all ABIs; this may vary between gcc versions.

Pthread Resolution

GCC 4.7.x versions on IRIX do not resolve pthreads correctly. This can sometimes by fixed by forcing the flag of -lpthread, but this does not always work. This appears to be related to IRIX's pthreads implementation not matching GCC's expectations.

Bootstrap Failures

A bug exists in binutils 2.20 with GCC 4.5.0 on IRIX, and was closed as "won't fix" https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43533

Another exists for a bootstrap failure with IRIX's "native ld" https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24334

GNU Go

Go never worked under IRIX with GCC due to too many "testsuite failures" https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51874