Saturday, 9 July 2011

Building gprbuild-gpl-2011

The way to build Ada code with GNAT used to be to use gnatmake. This still works, but there's a new kid on the block: gprbuild.

gnatmake is part of GCC, but gprbuild is a separate item. AdaCore don't maintain a publicly-visible SVN repository, so the way to get the latest source (if you're not a supported AdaCore customer) is to visit the Libre web site.

gprbuild is very configurable, but it's far easier to use if it's built in the context of your compiler. The binary that comes with GNAT GPL is fine for use with that compiler, but not so hot with a different one.

At the moment I use GCC 4.6.0 on Mac OS X Snow Leopard, with Fortran as well as the C, C++ and Ada that GNAT GPL 2011 supports. I have the compiler installed at /opt/gcc-4.6.0-x86_64. To configure gprbuild, I go to the source directory (say, ~/tmp/gprbuild-2011-src) and configure:

   PATH=/opt/gcc-4.6.0-x86_64/bin:$PATH ./configure \
   --prefix=/opt/gcc-4.6.0-x86_64 \

You'll see that this installs the new gprbuild in the same place as the compiler. This is by far the easiest way to deal with multiple compilers; each gprbuild (or xmlada, or ...) lives with its own compiler, and you don't risk getting mixed up with incompatible binaries.

The make resulted in several compilation errors; one was a simple warning-treated-as-error, the others were because GCC 4.6.0 doesn't understand SPARK. Here's a patch; after applying it (use patch -p1), gprbuild built and installed fine.

No comments:

Post a Comment