Build environmentI'm building on a 15" Macbook Pro with a 2.4 GHz Intel Core 2 Duo processor and 4 GB of RAM, running Mac OS X Lion 10.7.2 with Xcode 4.2. FSF GCC Ada requires a working GNAT compiler. I started with GNAT GPL 2011, which I installed at /opt/gnat-gpl-2011, so I adjust my PATH to make this compiler the default choice:
$ PATH=/opt/gnat-gpl-2011/bin:$PATHNote, this is OK if you're building GCC later than 4.6 (in which the build of gnatbind uses a flag which is deprecated in 4.6 but not supported in GNAT GPL 2011). Otherwise, you'll need a GCC 4.5- or 4.6-based compiler. Fortunately, there's one available at Dropbox or Sourceforge (it also includes C++, Fortran, AUnit, GNATcoll, and XML/Ada - but who's counting!)
GCC in a Distributed Version Control System?Normally you'd use a source release, from one of the GCC mirror sites. However, this time round I'm going to be working from the GCC repository. This is a Subversion repository (note, SVN is migrating to Apache), which is a centralised VCS. I would feel much safer keeping local changes in a VCS than having patches scattered around, so I'd like to use a DVCS if possible. There is a mirror supported by Git (see here); there's also a Mercurial mirror, but it's not been updated for almost a year. I'm not sure what I have against Git; perhaps it's just that the name is (deliberately?) offensive. Anyway, it seems to me (I may well be mistaken!) that there may be issues tracking the official SVN revision numbers. So I'll stay with SVN for now, checking out the trunk into gcc-trunk-svn/:
svn checkout svn://gcc.gnu.org/svn/gcc/trunk gcc-trunk-svnTo update the tree later on, don't just svn update; instead, from gcc-trunk-svn/,
$ contrib/gcc_updatewhich updates timestamps.
Support librariesGCC depends on several support libraries. The minimum set is
- GNU Multiple Precision Library (GMP) version 4.3.2 (or later)
- MPFR Library version 2.4.2 (or later)
- MPC Library version 0.8.1 (or later)
$ ln -s ~/tmp/gcc-support/gmp-5.0.2 gmp $ ln -s ~/tmp/gcc-support/mpfr-3.0.1 mpfr $ ln -s ~/tmp/gcc-support/mpc-0.9 mpc(you may of course find later versions).
BuildingI use a build directory, ~/tmp/gcc-build/:
$ mkdir ~/tmp/gcc-build $ cd ~/tmp/gcc-build/and configure:
$ ../gcc-trunk-svn/configure \ CC='gcc -D_FORTIFY_SOURCE=0' \ --prefix=/opt/gcc-4.7-180524 \ --disable-multilib \ --enable-languages=c,ada \ --build=x86_64-apple-darwin11The CC='gcc -D_FORTIFY_SOURCE=0' is because of a problem with Lion and GCC. The --prefix=/opt/gcc-4.7-180524 is to keep different versions of compilers separate (the 180524 was the SVN revision I'd updated to). Nothing so infuriating as accidentally overwriting your only compiler with a non-doing version! Then,
$ make... which succeeded after 38 minutes.
TestingYou need to install Dejagnu, and put its runtest on your path. I have dejagnu-1.4.4 installed in /opt/gnu, so I say
$ PATH=/opt/gnu/bin:$PATHFrom previous experience, it can take a very long time indeed to run the full test suite, even locking up the machine to the point of needing a power cycle. So it can make sense to run the individual test suites.
$ make check-ada === acats Summary === # of expected passes 2321 # of unexpected failures 0 === gnat Summary === # of expected passes 940 # of expected failures 11 # of unsupported tests 4It's also possible to make check-gmp, make check-mpfr, make check-mpc, make check-c.
$ sudo make install... and now all you need to do is to put /opt/gcc-4.7-180524/bin at the front of your PATH, and you're using the new compiler. If you're into multiple-precision arithmetic, you might want to install the support libraries:
$ (cd gmp; sudo make install) $ (cd mpfr; sudo make install) $ (cd mpc; sudo make install)Update 5.xi.11: Explained "180524". Corrected the final Path setting.
Update 21.i.12: Added backslash in the last line but 1 of the configure command.