g77 for your Intel Mac


Condition: You have a MacOS X 10.4 and higher system on Intel and you want g77 to run on it

These patches were updated 2 Oct. 2009 (to g77 version grh-6). The compiler built using the previous patches would sometimes fail to compile programs unless some optimization was invoked (-O0 or higher). The present patch set repairs that problem, and also yields smaller executables for debug compiles (-g) when COMMON is extensively used. For further information, see the ChangeLog in the patch file.

The build also works on Power PC systems prior to 10.6. With the 10.6 release, MacOS became Intel-only, and PPC support was dropped.

  1. Download the 3.4.3 version of gcc from GNU ftp.gnu.org/gnu/gcc/gcc-3.4.3/gcc-3.4.3.tar.gz or one of the many mirror sites. The exact version is important; versions newer than 3.4.3 will not work -- they have all been tried by the author.
  2. Download the patches to a file, such as /tmp/gcc-3.4.3.diffs.
  3. Unpack the gcc tarball. A good place is /usr/local/src:
    
        cd /usr/local/src; tar xfz gcc-3.4.3.tar.gz
        
  4. Patch the source code:
    
        cd /usr/local/src; patch -p0 < /tmp/gcc-3.4.3.diffs
        
  5. Make a directory for the compiler build, change to it, and configure:
    
        mkdir /usr/local/src/gcc-3.4.3-darwin
        cd /usr/local/src/gcc-3.4.3-darwin
        ../gcc-3.4.3/configure --enable-languages=f77 --disable-shared
        
    This will configure GCC to build only an f77/g77 compiler.
  6. Build:
    
        make STAGE1_CFLAGS='-m32 -D_FORTIFY_SOURCE=0' \
             BOOT_CFLAGS='-m32 -D_FORTIFY_SOURCE=0' \
    	 CFLAGS='-O -fno-common -m32 -D_FORTIFY_SOURCE=0' \
    	 LIBCFLAGS='-g -O2 -fno-common -m32 -D_FORTIFY_SOURCE=0' \
    	 LIBCXXFLAGS='-g -O2 -m32 -fno-implicit-templates -D_FORTIFY_SOURCE=0' \
    	 bootstrap
        
    This will build the compilers and will take about 15 minutes. If all looks ok, install them:
    
        make install
        
    This will leave g77 in /usr/local/bin. Make sure that is in your search path. You should be able to say,
    
        g77 -v
        ...
        gcc version 3.4.3 (grh-6)