How to compile G95 with GCC

Instructions for the impatient

G95 now includes code to interface with GCC for code generation. It is, however, noted that the backend interface is still at an early stage. Many features are either missing or only partially completed.

You need to get a copy of the GCC source tree where G95 has been integrated. G95 uses GIMPLE trees, so you will need the tree-ssa-20020619-branch from GCC CVS. This branch can be retrieved via CVS as follows (See http://gcc.gnu.org/ for full details):

$ cvs -d :pserver:anoncvs@subversions.gnu.org:/cvsroot/gcc login

(no password)

$ cvs -z9 -d :pserver:anoncvs@subversions.gnu.org:/cvsroot/gcc co -r tree-ssa-20020619-branch gcc

The above cvs command will create a directory named gcc.

Make sure the timestamps on generated configure files are later than their source files. It may be necessary to touch gcc/configure, gcc/Makefile.in, gcc/libgfor/configure, gcc/libgfor/Makefile.in and gcc/libgfor/configure.h.in. GCC requires autoconf 2.13.

Configure GCC as normal with --enable-languages=c,f95. You will need GMP installed on your system. If configure cannot find GMP, you may need to add CPPFLAGS=-I/usr/local/include and LDFLAGS=-L/usr/local/lib to the configure command.

When using gfortran to link programs, the run-time libraries should automatically be linked. Otherwise, you need to specify -lgfortran and possibly -lm. To compile Fortran 77 source with g95, you need to specify -x f95; otherwise, g77 will be used. This will generate "Fortran compiler not installed on this system" if you did not compile g77.

If you experiences problems during the bootstrap of gcc and g95, then check that you are using up to date CVS checkouts of the tree-ssa branch of GCC. Finally, try a clean build. It is possible to cause the build system to get confused beyond repair, especally with the significant changes recently introducted into the tree-ssa branch.

Any problems/comments/suggestions please let us know, and/or send your comments/suggestions/patches to the mailing list.