4.2. Compilation

For Ada 83 and Ada 95 the predefined program library is located in a standard place, which is target dependent. The location is /opt/erc32-ada-1.7/lib/gcc-lib/erc-coff/2.8.1/adalib/.

Ada source files are always compiled in the context of a program library. While ERC32 Ada does not have a closed library as some other Ada compilers do, it does generate and use library file information. By default this goes in the current directory. Library files use the .ali (Ada library) suffix. Also ERC32 Ada requires each Ada compilation unit to be in a separate file with the file name the same as the unit name. There must be a file extension which is .ads for a package or subprogram specification and .adb for a body.

Where a source file contains more than one compilation unit, then the program erc-coff-gnatchop may be used to divide the file. This program will write the output files in the current directory, or (more usefully) into a named directory.

For example:


bash$ erc-coff-gnatchop big-file.ada src

4.2.1. Format and Content of User Listings

The compiler accepts several command line options to control the format of listings. By default, no listing is generated at all.

-gnatl

Output full source listing with embedded error messages.

-gnatv

Verbose mode. Full error output with source lines to stdout.

-gnatk

Keep going despite syntax errors.


bash$ erc-coff-gcc -gnatlqv ackermann.adb 
XGC Ada erc32-ada/-1.7/
Copyright 1992-2002 Free Software Foundation, Inc.

Compiling: ackermann.adb (source file time stamp: 2001-04-25 16:57:54)

     1. function Ackermann (m, n : Integer) return Integer is
     2. begin
     3.    if m = 0 then
     4.       return n + 1;
     5.    elsif n = 0 then
     6.       return Ackermann (m - 1, 1);
     7.    else
     8.       return Ackermann (m - 1, Ackermann (m, n - 1));
     9.    end if;
    10. end Ackermann;
    11. 

 11 lines: No errors

The assembler can also generate a listing, as follows:


bash$ erc-coff-gcc -Wa,-a -O -c ackermann.adb 
GAS-ERC  /tmp/cca01513.s                        page 1

   1                            .file  "ackermann.adb"
   2                    gcc2_compiled.:
   3                    __gnu_compiled_ada:
   4                            .text
   5                            .align  4
   6                            .global _ada_ackermann
   7                            .proc   04
   8                    _ada_ackermann:
   9 0000 9DE3BF98              save    %sp,-104,%sp
  10 0004 A0100018              mov     %i0,%l0
lots of output...

The objdump program can also generate a listing by disassembling the object code.


bash$ erc-coff-objdump -d ackermann.o
ackermann.o:     file format coff-erc

Disassembly of section .text:

00000000 <_ada_ackermann>
   0:   9d e3 bf 98     save  %sp, -104, %sp
   4:   a0 10 00 18     mov  %i0, %l0
   8:   80 a3 80 07     cmp  %sp, %g7
   c:   89 d0 20 09     tleu  9
  10:   80 a4 20 00     cmp  %l0, 0
...