g77 on MacOS X

Before you begin, you need to have Apple's developer tools installed. If you just want to use my precompiled gcc-with-g77 package, get an RPM package from here. If you want to build g77 for yourself, follow the instruction below.

g77 Building Procedure (gcc-3.3 based)

gcc-3.3 that comes with Apple's standard DevTools does not include "g77". However, its source tree does include one. This makes g77 support much easier than before. Nevertheless, the source code that Apple used to build the gcc-3.3 compiler suite for 10.3 has some problem: g77 built from it fails to compile a trivial single line fortran code like

$ cat test.F

      end
$ g77 test.F
/var/tmp//ccr9QDpP.s:23:section difference relocatable subtraction expression, "LC0" minus "L00000000001$pb" using a symbol at the end of section will not produce an assembly time constant
/var/tmp//ccr9QDpP.s:23:use a symbol with a constant value created with an assignment instead of the expression, L_const_sym = LC0 - L00000000001$pb
/var/tmp//ccr9QDpP.s:22:section difference relocatable subtraction expression, "LC0" minus "L00000000001$pb" using a symbol at the end of section will not produce an assembly time constant
/var/tmp//ccr9QDpP.s:22:use a symbol with a constant value created with an assignment instead of the expression, L_const_sym = LC0 - L00000000001$pb


I had to back port a patch (see gcc/varasum.c Revision 1.324.2.6) to fix this problem. In addtion, fortran open statement for a dirct access file does not assume UNFORMATTED if not specified. To fix this default behavior I had to apply yet another patch (see libf2c/libI77/open.c Revision 1.20.14.1).

$ tar -zxvf gcc-1495.tar.gz
$ cd gcc-1495
$ patch -p1 -s < <somewhere>/gcc-1495-varasm.patch
$ patch -p1 -s < <somewhere>/gcc-1495-open.patch
$ export SRCROOT=`pwd`

$ vi build_gcc
.....
ENABLE_LANGUAGES="c++,c,objc,objc++,f77"
.....
$ make HOSTS=ppc TARGETS=ppc install >& install.log &
$ tail -f install.log
......
^C (control + C to get out of tail)

Then build libg2c.a
$ cd obj/ppc
$ mkdir libf2c
$ cd libf2c
$ CFLAGS='-no-cpp-precomp' $SRCROOT/libf2c/configure --srcdir=$SRCROOT/libf2c --host=ppc --target=ppc
$ make >& make.log &
$ tail -f install.log
......
^C (control +C to get out of tail)


What follows is only a packaging issue, useless for most people:^)

$ cp -p .libs/libg2c.a libfrtbegin.a ../../../dst/usr/lib/gcc/darwin/3.3/
$ cp g2c.h ../../../dst/usr/include/gcc/darwin/3.3/
$ ln -s gcc/darwin/default/g2c.h ../../../dst/usr/include/.
$ ln -s gcc/darwin/default/libg2c.a ../../../dst/usr/lib/libg2c.a
$ cd ../../cc-ppc-on-ppc/
$ cp g77 ../../dst/usr/bin/g77-3.3
$ cp f771 ../../dst/usr/libexec/gcc/darwin/ppc/3.3/
$ cd ../../dst
$ pushd usr/bin
$ ln -s g++-3.3 g++
$ ln -s gcc-3.3 gcc
$ ln -s g77-3.3 g77
$ ln -s g++ c++
$ ln -s gcc cc
$ ln -s g77 f77
$ cd ../include
$ pushd gcc/darwin/

$ ln -s 3.3 default
$ popd
$ for i in gcc/darwin/default/*.h; do ln -s $i .; done
$ rm ppc_intrinsics.h
$ cd ../lib
$ pushd gcc/darwin
$ ln -s 3.3 default
$ popd
$ for i in gcc/darwin/default/lib*.a; do ln -s $i .; done
$ rm libcc_noc++.a libgcc_static.a libstdc++_ZeroLink.a
$ cd ../libexec
$ pushd gcc/darwin/ppc
$ ln -s 3.3 default
$ popd
$ cd ../..
$ su
# chown -R root:wheel usr

# gnutar -zcvf <somewhere>/gcc-with-g77-1495-2b.tar.gz usr/
#exit

How to Install a Precompiled Binary Package

A binary package is available as an RPM which can be installed as

# rpm -Uvh gcc-with-g77-1495-2b.ppc.rpm
# rpm -Uvh gcc-with-g77-symlinks-1495-2b.ppc.rpm


The last "symlinks" packages makes gcc-3.3 based compilers as default compilers to be referred to as gcc, g++, and g77.
 

REMARKS



Back to Keisuke Fujii's HEP on X Page
keisuke.fujii@kek.jp January 13, 2004