GCC-Ada-5.2.0

Introduction to the GCC Ada compiler

Ada is a modern programming language designed for large, long-lived applications — and embedded systems in particular — where reliability and efficiency are essential. It has a set of unique technical features that make it highly effective for use in large, complex and safety-critical projects.

The compiler and associated tools on this page are known as the GNAT technology, developed by the Adacore company, using the GCC backend. Since parts of the Ada compiler are written in Ada, there is a circular dependency on an Ada compiler. The instructions below first install a binary compiler. You do not need to do that if you already have built GNAT tools.

This package is known to build and work properly using an LFS-7.8 platform.

[Caution]

Caution

Using the instructions on this page will have the effect that the C and C++ compiler and libraries will be reinstalled, overwriting the ones on your system. This may lead to some issues. Please read the notes and caution on the GCC-5.2.0 page.

[Note]

Note

If you want to install other compilers in the GCC collection, do that first, or specify ada in the --enable-languages switch to configure. If you rebuild GCC without enabling ada after running the instructions on this page, the new compiler will not be able to compile ADA anymore.

Package Information

Additional Downloads

[Note]

Note

You will need to install GNAT temporarily to satisfy the circular dependency. You may point your browser to the AdaCore download page, choose your platform and 2015 (64 bit machines) or 2014 (32 bit machines), then select the file to download. Alternatively, direct links to the 64 bit and 32 bit linux versions are given below.

GCC Ada Dependencies

Recommended

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/gcc-ada

Installation of the GNAT binary

Before unpacking and changing into the GCC source directory, first unpack the GNAT tarball, and change to the GNAT directory. Then, install the GNAT binary by running the following command as the root user:

make ins-all prefix=/opt/gnat

The GNAT compiler can be invoked by executing the gcc binary installed in /opt/gnat/bin.

You may now remove the GNAT source directory if desired.

Prepare to compile GCC by placing the GNAT version of gcc at the beginning of the PATH variable by using the following commands:

PATH_HOLD=$PATH &&
export PATH=/opt/gnat/bin:$PATH_HOLD

Doing so has the drawback that the GCC and Binutils executables are taken from the just installed GNAT package, but the versions of those executables are outdated compared to those installed in LFS. This is not important for the GCC compilers, since they recompile themselves during the bootstrap process. On the other hand, the outdated ld and as tools are used all along. In order to use the LFS tools, issue as the root user:

find /opt/gnat -name ld -exec mv -v {} {}.old \;
find /opt/gnat -name as -exec mv -v {} {}.old \;

Installation of GCC Ada

Install GCC Ada by running the following commands:

mkdir ../gcc-build &&
cd    ../gcc-build &&

../gcc-5.2.0/configure          \
    --prefix=/usr               \
    --disable-multilib          \
    --with-system-zlib          \
    --enable-languages=ada &&
make

If you have installed additional packages such as Valgrind and GDB, the GCC part of the testsuite will run more tests than in LFS. Some of those will report FAIL and others XPASS (pass when expected to FAIL). To run the tests, issue:

ulimit -s 32768 &&
make -k check

The tests are very long, and the results may be hard to find in the logs, specially if you use parallel jobs with make. You can get a summary of the tests with:

../gcc-5.2.0/contrib/test_summary

Now, as the root user:

make install &&

mkdir -pv /usr/share/gdb/auto-load/usr/lib              &&
mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib &&

chown -v -R root:root \
    /usr/lib/gcc/*linux-gnu/5.2.0/include{,-fixed} \
    /usr/lib/gcc/*linux-gnu/5.2.0/ada{lib,include}

You should now remove the GNAT installation and perform other cleanups. First, as the root user:

rm -rf /opt/gnat

Then, as a normal user:

export PATH=$PATH_HOLD &&
unset PATH_HOLD

Command Explanations

mkdir ../gcc-build; cd ../gcc-build: The GCC documentation recommends building the package in a dedicated build directory.

--disable-multilib: This parameter ensures that files are created for the specific architecture of your computer.

--with-system-zlib: Uses the system zlib instead of the bundled one. zlib is used for compressing and uncompressing GCC's intermediate language in LTO (Link Time Optimization) object files.

--enable-languages=ada: Instructs the build system to build the Ada tools and compiler. It is unavoidable that the C and C++ compilers be built too.

--with-default-libstdcxx-abi=c++98: Use this switch if you are building GNAT tools using a GCC version prior to 5.1.0, and you do not want to recompile all the libraries written in C++.

ulimit -s 32768: This command prevents several tests from running out of stack space.

make -k check: This command runs the test suite without stopping if any errors are encountered.

../gcc-5.2.0/contrib/test_summary: This command will produce a summary of the test suite results. You can append | grep -A7 Summ to the command to produce an even more condensed version of the summary. You may also wish to redirect the output to a file for review and comparison later on.

chown -v -R root:root /usr/lib/gcc/*linux-gnu/...: If the package is built by a user other than root, the ownership of the installed include and adalib directories (and their contents) will be incorrect. These commands change the ownership to the root user and group.

Contents

Installed Programs: gnat, gnatbind, gnatchop, gnatclean, gnatfind, gnatkr, gnatlink, gnatls, gnatmake, gnatname, gnatprep, gnatxref
Installed Libraries: libgnat.{so,a}, libgnarl.{so,a} in /usr/lib/gcc/<arch-triplet>/5.2.0/adalib
Installed Directories: /usr/lib/gcc/<arch-triplet>/5.2.0/ada{include,lib}

Only the Ada specific files are listed here. Others can be found at ../../../../lfs/view/7.8/chapter06/gcc.html#contents-gcc as they were initially installed during the building of LFS.

Short Descriptions

gnat

is a wrapper that accepts a number of commands and calls the corresponding tool from the list below.

gnatbind

is used to bind compiled objects.

gnatchop

is useful for renaming files to meet the standard Ada default file naming conventions.

gnatclean

is used to remove files associated with a GNAT project.

gnatfind

is intended for locating definition and/or references to specified entities in a GNAT project.

gnatkr

is used to determine the crunched name for a given file, when crunched to a specified maximum length.

gnatlink

is used to link programs and build an executable file.

gnatls

is the compiled unit browser.

gnatmake

is the Ada compiler, which performs compilation, binding and linking.

gnatname

will list the files associated with a GNAT project.

gnatprep

is the GNAT external preprocessor.

gnatxref

is similar to gnatfind, but generates a full report of all cross-references.

Last updated on 2015-09-20 15:38:20 -0700