SGI IRIX Freeware

Notes on building Open Source software on IRIX

This is a draft document to help people build open source software on IRIX. It may be missing some items but having built literally hundreds of packages on IRIX over the years we're pretty confident that most of the pitfalls are covered.

General

IRIX has a very comprehensive Unix API. Not only it is POSIX and POSIX-2 compliant, it is also compliant with XOPEN XPG/4, SVID (SystemV R4), BSD extensions, Unix 95 (Spec 1170) and more.

Software that compiles on other UNIX'es (notably those with a smaller API, like Linux and Free/Open/Net BSD), should, almost with no exceptions, compile and run smoothly on IRIX. But read on...

Still there's way too much software out there that makes non-portable assumptions or is written improperly, which may cause problems.

Here's an item list to save you time porting open source software to IRIX.





  • GNU configure and autoconf

    GNU autoconf generates configure scripts that assume that if a library exists, it should be used. This is incorrect on IRIX, which keeps some old libraries around just for the sake of backward compatibility with very old programs. This alone breaks most of the GNU utilities on IRIX. To prevent this from happening, simply force GNU configure to explicitly ignore 'libsocket', 'libnsl', 'libgen' and 'libsun'. All these interfaces have their up-to-date entries in the standard C library libc.so on IRIX 6.x.

    For example, when calling GNU configure you should use something like:

    	ac_cv_lib_gen_getmntent=no \
    	ac_cv_lib_sun=no \
            ac_cv_lib_sun_getpwnam=no \
    	ac_cv_lib_sun_getmntent=no \
            ac_cv_lib_sun_yp_match=no \
            ac_cv_lib_socket=no \
    	ac_cv_lib_socket_main=no \
    		configure ...
    
    Note that this is just an example. Make sure to look at your config.cache (or equivalent) file after configuration, and inspect it for any suspicious ac_cv_lib... entries that match one of the libraries mentioned above and force them to no (or equivalent).

  • Makefiles

    Some open source programs assume GNU make in their Makefiles. You should probably use GNU make on IRIX too. Compatibility is good. With GNU make supporting parallel makes there's really no reason to use any IRIX specific make like smake, pmake, or make.

    If you don't have GNU make for IRIX you can download it from http://freeware.sgi.com/ and not worry about Makefile portability anymore.

  • ranlib

    This is a historical BSD thing that should have been done transparently by the linker. You don't need to run ranlib in IRIX. If your Makefile calls ranlib either delete this or define it to a no-op.

    	gmake RANLIB=:  ...
    

  • install

    The Berkeley 'install' is incompatible with the SYSV version. Either upgrade to IRIX 6.5 (where the IRIX install has transparent BSD compatibility) or define:

    	gmake INSTALL=bsdinst  ...

  • BSD

    BSD programs that assume a BSD environment should compile on IRIX without change (at least in 95% of cases) by forcing BSD compatibility via CFLAGS, e.g:

    	gmake CFLAGS="-D_BSD_COMPAT ..."

    If you don't want full BSD compatibility, consider using one or more of:

    	-D_BSD_TYPES
    	-D_BSD_TIME
    	-D_BSD_SIGNALS
    
    Important: if your software is more "properly" written and uses POSIX signals (i.e. sigaction instead of signal) then you must not compile with -D_BSD_SIGNALS. Mixing signal models may cause unpredictable problems.

  • System types

    Some programs assume system types, in particular 'off_t', are 32 bit (i.e. that files don't exceed 4GB in size) These programs are making bad assumptions, but this problem can be overcome by compiling in the o32 (cc -32) ABI:

    	gmake CC="cc -32 ..."
    

  • varargs

    Some programs do not comply with the ANSI varargs syntax and conventions (i.e. include <stdarg.h> and use ellipsis in the argument list) Again, if those don't work they may start working by compiling using the o32 ABI:

    	gmake CC="cc -32 ..."
    

  • Catching other problems

    The SGI cc is verbose and pedantic. The problem is that when you get way too many warnings you start ignoring the real ones.

    To make the SGI compiler more like gcc in terms of warnings you may use something like:

    	NOWARN = -woff 1009,1014,1110,1116,1185,1188,1204,1230,1233 \
            	-Wl,-woff,85,-woff,84
    	$(CC) $(NOWARN) ...
    In your Makefiles

  • SGI cc

    While the SGI cc may look too pedantic, it can catch a lot of real source code bugs. Consider compiling with:

    	CC="cc -fullwarn ..."
    

    and really clean your source of type mismatches.

  • Multiple other problems (too many to list here)

    Over the years IRIX got thousands of bug fixes. As expected, problems on IRIX 4.0.x are much more numerous than problems on IRIX 6.5. If you can upgrade, please do. Life is way easier with IRIX 6.5.

  • Build vs. target env

    Virtually all open source packages assume that the building environment is the same as the target environment. In fact every Makefile with a 'make install' that directly installs into system directories probably makes this assumption. IRIX supports a much more elegant model of 'inst'able packages that can be built anywhere and installed anywhere else.

    It would be nice if there was a UNIX-wide standard for this. Red Hat RPM and other Linux installers are getting there, which is great.

    We usually build open source software with an IRIX 6.5 ROOT (i.e. get include files and libraries from a backward compatible 6.5 mounted directory). Assuming this directory is called /6.5_root this can be done by:

    	cc -nostdinc -I. -I/6.5_root/usr/include ...	(compiling)
    	cc -nostdlib -L/6.5_root/usr/lib32 ...		(linking)
    

    The packaging itself is an art form. At SGI we use a specialized 'install' perl script to intercept calls from 'make install'. This install adds the appropriate lines to the 'idb' file instead of actually installing files. Later, this idb file is used by 'gendist' to create the packages. Unfortunately, far too many open source packages call mv, cp, tar, etc. to install, so they bypass this mechanism. We have considered but not yet implemented other solutions, such as trapping system calls or running in a chroot directory. If you find (or implement!) a better solution please let us know.

  • gcc vs. cc

    Code that runs fine when compiled with SGI cc and doesn't run when compiled with gcc might be calling functions compiled with MIPSpro C that get passed or return structs that are smaller than 16 bytes but not 8 bytes long. gcc and SGI cc are incompatible in the way they pass these structs so compiling with gcc and linking with a shared library that was compiled with the SGI cc) can cause these problems. There are very few such library functions, but inet_ntoa, inet_lnaof, inet_netof, inet_makeaddr and semctl are all examples. Work-arounds for these particular routines have been built into libgcc.a, but that is not a general fix. If you find more instances in IRIX libraries please report them. Often a small wrapper procedure that realigns the problematic arguments will avoid the problem.

  • portable types

    Occasionally code that works on other platforms will compile fine on IRIX, but will misbehave when run. These problems can be difficult to track down, but one thing to check for is assumptions about whether char is signed or unsigned. IRIX compilers default to unsigned -- if it matters your code should be explicit!

    Setting up parallel debugging sessions and stepping through the working and non-working code simultaneously to find where they diverge is often helpful.


Additions and contributions to this list will be gratefully accepted.
freeware@sgi.com



Contact Us | Trademarks | Privacy | Using this site means you accept its Terms of Use