PowerAda ada

From OC Systems Wiki!
Jump to: navigation, search


ada - compile a program


ada [Options] [FileName...]


The ada command runs the compiler. Control the actions of the compiler by using this command with the appropriate command-line options as described in the following sections.

A more in-depth description of the compiler and library may be found in Chapter 3, "Basic PowerAda Concepts". A quick introduction is provided in Chapter 2, "Getting Started". A graphical interface for specifying compiler options and invoking the compiler is provided by the powerada Build Menu. Automatic program building and updating capabilities are provided from the command line by abuild


These descriptions include information about how the options interact with each other, and any restrictions on their use.

The following rules govern how you can specify compiler options on the command line. Most rules also apply when specifying options to other PowerAda commands.

  • Some options consist of single-letter flags, like -a. Others consist of a flag followed by a parameter, like -o Name. Separate parameters from their flags with one or more spaces.
  • Specify multiple single-letter flags either separately or together with no intervening blanks. For example, these commands are equivalent:
   ada -a -k -l -p -u FileName
   ada -akl -pu FileName
  • Case is significant; for instance -l is different from -L.
  • Options can be specified in any order.
  • The file names can appear anywhere on the command line. The files are compiled one at a time in the order they appear (left to right) on the command line.

The following options are applied only after the last Ada source file on the command line has been processed: -b, -e, -i, -m, -o, -r, and a number of -q options. The -u option applies only once for a single invocation of ada. All other options are applied to each file as it is compiled. Options -a and -l produce a result for each file.

Options for Compiler Output

Prints the compiler banner and version notice, then display progress messages to standard output during compilation. By default, nothing is displayed to standard output; diagnostic messages are written to standard error.
-o Name
Specifies the name for the executable output file. The default name is a.out. This option is only valid with the -b or -m options.
Create one or more files (with the suffix .lst) containing a source listing and a list of all syntax and semantic errors the compiler finds in the Ada source code.
One output file is created for each Ada source file specified on the command line (or on standard input if -I is used). The Ada source lines are preceded by line numbers to make it easier to locate specific places within the source files. Any errors the compiler finds are printed below the line where the error was found.
Writes assembler code to output files that have a suffix of .s.
One output file is created for each Ada source file specified on the command line (or on standard input if -I is used). Note that the resulting files contain a concatenation of all assembler code produced for the contents of the corresponding Ada file, together with information to map source lines to assembler statements, and so may not be in a correct format for the AIX or Linux assembler. This occurs most often in the case of main unit compilations, where the main elaboration code and the main program code are concatenated into the same file.
The generated assembler code is most useful in locating problems, verifying how the compiler is optimizing certain constructs, or determining how the compiler represents particular data types in memory.
Performs both high-level and low-level code optimizations, including inline expansion; these are described in Chapter 9, "Optimization".
The debugger can work with code compiled at this level of optimization, but values and lines other than those at entry and exit to a subprogram will likely be inaccurate due to reorganization done during optimization.
Produces code that records subprogram call counts at run time by calling the AIX system profiling routines. This flag is not valid on Linux.
In order to generate profiling information, the executable program must be bound with this option (i.e., specify -p along with -b or -m).
Stores the text from the specified file as comments inside the object module.
Each source file can be compiled with one or more -qcomment options, and the final object file when the program is linked contains the -qcomment comments from all the source files.

For example, you might add a standard copyright header to an object file by using a command such as the following:ada -qcomment=copyright.txt test.ada

Options for Linking

-b UnitName
Binds and links an executable with UnitName as the main unit.
With this option you can omit the Ada source file names on the command line. Omitting source file names causes the compiler to invoke the linkage editor to produce an executable file; all compilation units must already be compiled. If you do specify Ada source files, they will be compiled first, then UnitName will be linked as the main unit.
UnitName must be a subprogram compilation unit in the working sublibrary, but it need not be in any of the source files when you specify both a unit name and source file names.
Compiles the Ada source files specified on the command line, then bind and link the last unit of the last file as a main program. This option is mutually exclusive with the -b option.
Permits the link step to complete successfully and generate an object module without necessarily resolving all symbols. By default, a linked object module is not produced unless all symbols are resolved.
The resulting file is named a.out unless you also specify the -o Name option, in which case the object module is Name. This file contains all the object code needed from the Ada sublibraries, so it can be further linked without the sublibraries.
Use this option only if you are very familiar with linking operations under AIX or Linux. You can use it to create an object module that can be linked with several different versions of other object modules, perhaps during development and testing of non-Ada interface packages.
Using -e creates a file Ada.Link that shows the ld command that was used to create the object module. You can execute the commands in Ada.Link to link your program. If you want to do a full link, remove the -r option from the ld command. The Ada.Link file will contain the names of all the required files for your link step. This option is valid only when the -m or -b options are also specified.
Note that after using the -e compiler option, the next use of the compiler or one of the other PowerAda commands may change the sublibrary and remove files needed by the command in Ada.Link.
If you just want to get the link script, use the -qlink_script option.
-i FileName
Includes the object module or archive file named by FileName in the linking of the main program. You can use this option to specify any object modules that you need to link with your Ada program.
By default, the compiler determines which object modules will be in the executable file based on the contents of the program library.
For a complete description, see "Compiling Ada Programs that Include Non-Ada Subprograms" in Chapter 7.
You can also use -i to specify any string you want passed as an argument to the linker, ld, including options. If the linker argument begins with a dash, it should follow the compiler's -i flag without any intervening blanks or tabs so it is not interpreted as a compiler option.
Links the generated executable such that profiling information is collected.
In order to generate profiling information, the executable program must be bound with this option (i.e., specify -p along with -b or -m). See the entry for -p under "Options for Linking". This will record how much time was spent in each subprogram.
Running a profiled program produces a file called gmon.out. Use the AIX gprof command to produce a profile report from this file and your program. This command is described in the AIX Commands Reference for the RISC System/6000. This option is not valid on Linux.
Specifies that the Ada code is to be "pre-bound" into a single partially linked object module. This option is used to specify that only a partially linked (non-executable) object module should be created for the Ada main and the units it imports. =

See "Linking Ada Into Non-Ada Programs" in Chapter 7.

Specifies that the Ada code is to be bound into a single shared library. This option is used when Ada code is to be linked and used in other programs that are not written in Ada. See "Linking Ada Into Non-Ada Programs" in Chapter 7.
Specifies that the Ada and AIX or Linux thread libraries are to be bound into the program. The Ada and AIX or Linux thread libraries are automatically included in any program that contains Ada tasks which will execute in separate AIX or Linux threads. This option is used in binding programs that do not contain any Ada tasks executing in separate AIX or Linux threads, but utilize the AIX or Linux thread subprograms directly, or (on AIX 4.2) call a function ending in _r and so require the libc_r.a shared library.
-x Name
Name designates an existing version of the program being linked. The ld command is performed by identifying those Ada object modules that have changed since Name was linked, and creating the new program by linking it against the existing one rather than against each of the individual libraries. This is much faster than a full link.
Note: -x should not be used to re-link after non-Ada modules have been changed unless those modules are explicitly listed on the bind command line.

Options for Libraries

-L Library
Specifies the name for a library list file or the root sublibrary (within a project). This determines the library where the compiler searches for compilation units and dependency information. If this option is not specified, ada first looks for the library list file alib.list in the current directory. If this is not found, and the current directory is within a project, it determines the library from the root sublibrary adalib in the current directory.
Prevents the compiler from attempting to get a write-lock on the working sublibrary before compiling. This effect may be achieved permanently for a given sublibrary by removing the sublibrary write-lock called adalockfile in the current sublibrary directory.
Warning: This flag be used with caution, since it may disrupt users who are reading the sublibrary, and may corrupt the sublibrary file permanently of processes are attempting to write to it simultaneously
Does not store symbolic debugging information in the working sublibrary. This information makes it possible for the debugger and other debugging tools to associate abstractions like line numbers and variable names with locations within a running program. By default, debugging information is saved in the working sublibrary; this option ensures that only information necessary to perform further compilations is saved.
Note: the addition of debugging information may increase the size of a sublibrary by as much as two and a half times. However, this information is necessary to use any PowerAda library-based debugging and development tools (e.g., powerada).
Deletes (proprietary) source from the sublibrary after a compile, rather than saving it. Normally, source is saved in the sublibrary for use by aprojbuild, powerada, adbg, and other tools, and may be extracted with the aextract tool.
Note: the elimination of source from the sublibrary may decrease its size by as much as 30% (much more than the total space occupied by the source files themselves).

Options for Other Compiler Features

Requests help for the command. If specified, all other options and parameters (except possibly erroneous ones) are ignored.
Directs the compiler to read a list of file names from standard input instead of taking a file name as a command-line parameter.
If you do not pipe or redirect standard input, the compiler will pause and wait for you to type in the names of the files. Press Enter after each file name, and type the end-of-file character (usually Ctrl-D) when you have entered all the file names.
The working sublibrary is updated after each successful compilation. If one or more files fail to compile, -I continues despite the errors.
You can put comments in the lines the compiler reads from standard input by using Ada comment syntax. The compiler ignores text on a line from a double hyphen (--) to the end of that line.
Suppresses most run-time checks for all conditions, as if pragma SUPPRESS were applied.
Use of -S means that when error conditions such as constraint violation, most elaboration checks, or numeric overflow occur at run time, the Ada program will not detect them and so will not raise the appropriate exceptions. The program may run faster because the checking is not performed; however you must take special care that no error conditions occur, otherwise your program will continue to run but may produce incorrect results.
-q arch={ com | pwr | pwr2 | ppc }
Specifies the architecture on which the program will be run. The options are interpreted as follows:
  • com- Produce an object that contains instructions that will run on all the POWER and PowerPC hardware platforms.
  • pwr - Produce an object that contains instructions that will run on the POWER hardware platform.
  • pwr2 - Produce an object that contains instructions that will run on the POWER2 hardware platform.
  • ppc - Produce an object that contains instructions that will run on any of the 32-bit PowerPC hardware platforms.
The default is -q arch=com. These options are only valid on AIX.
-q crt=FilePathName
-q crt_r=FilePathName
Specifies an alternative to /usr/lib/crt0.o (or /usr/lib/crt0_r.o, respectively) to use when linking the Ada load module. This is only valid with -m or -b. A common use for this option is when C++ object modules are to be included in the Ada program. For example, IBM CSet++ requires /usr/lpp/xlC/lib/crt0.o.
Requests that floating point checks be generated as if the attribute MACHINE_OVERFLOWS were true for all floating point types, instead of the default of FALSE. Note that this applies to the point of the check, not to the point of the type declaration.
-q import=ail_file
Specifies an Ada Imports List (.ail) file which describes separately compiled and dynamically linked shared libraries. See Shared Ada Libraries.
-q instances={defer | inline}
When set to defer, generic instance bodies are deferred to separate subunits, and are compiled as needed. When set to inline, generic instance bodies are generated inline.
The default is -q instances=inline.
-q reinstantiate={ yes | no }
When set to yes, outdated instance subunits are reinstantiated, and are brought upto date automatically when a bind is attempted on a main unit. When set to no, outdated instance subunits are not automatically recompiled when a bind is attempted, and will cause the bind to fail.
The default is -q reinstantiate=no.
-q link_script_name=FilePathName
saves the script that executes the 'ld' command in the file designated by FilePathName. This is useful if one is getting errors at link-time, or one wants to do a special kind of link.
-q listobjs=FileName
Writes a list of object file names used in the bind step to the file FileName. If FileName is not specified, then a default file with the name <executable output file>.objs will be used (e.g. for a.out, the list file would be named a.out.objs).
-q name_after_code
Places an ASCII string containing the link name of the subprogram after the for each subprogram for low-level debugging purposes.
-q noautoinit
This option may only be used with -s, and indicates that the resulting shared library should not be automatically initialized at load time. This is applied by ashared when producing a .ail file, since it is assumed that the ail file will tell the main program how to initialize the shared library in the proper elaboration order. See Shared Ada Libraries.
-q stack_limit={ MaximumSize | environment_variable }
Specifies the maximum size for the main program stack, in bytes, to a maximum of 256_000_000. By default, no limit is imposed by the Ada runtime. If the value specified is environment_variable, the value of the environment variable Ada_stack_limit is used (if defined). Note that in all cases, the limit cannot exceed the limit imposed by AIX or Linux for the process.
-q task_stack={ DefaultSize | environment_variable }
Specifies the default stack size for tasks, in bytes. By default, task stacks are at least 32M bytes in size. If the value specified is environment_variable, the value of the environment variable Ada_task_stack will be used (if defined) upon program startup. Note that this option does not affect the stack size for tasks whose storage size is explicitly provided in a pragma STORAGE_SIZE for the corresponding task type.
Allows the compiled unit to "with" a private child package to which it normally does not have visibility. This is intended solely to allow the library subprogram representing a linkable partition to include such private child units. See Chapter 7, "Linking Ada Into Non-Ada Programs".
-q xlCbind
uses /bin/xlC or /bin/xlC_r instead of /bin/ld to do the bind step in order to support generating and linking in the necessary C++ initialization code when C++ object modules are included. Note: this is not a full solution to linking such programs together--contact OC Systems for further assistance.


Source files to be compiled.


The ada command will return a return of zero if the compilation is successful, and a non-zero code if an error occurs during compilation. The possible values returned by the ada command are:

0, 1, 2, 3, 4, 13, 18, 99

Refer to Return Codes for Commands at the start of this appendix for details about the meaning of these return codes.

If more than one error occurs while compiling more than one file, the return of the ada command reflects exactly one of those errors, but which one is unspecified.


$POWERADA/bin/ada - the compiler driver program
$POWERADA/tools/bin/Adaentry - the actual compiler program
$POWERADA/tools/lib/messages.catalog - error message database
$POWERADA/lib/libada -        the Ada system (runtime) sublibrary on AIX
$POWERADA/lib/libada -  the Ada system (runtime) sublibrary on Linux
$POWERADA/lib/libada_r.a, $POWERADA/adarte/lib/libada_r.a - the shared Ada runtime library for AIX


This must be defined and indicate the powerada/ada95 directory in the PowerAda installation. For Linux, this indicates the powerada/linux directory in the PowerAda installation,
Names a baselines file identifying aliases for baseline projects.
forces the compiler to interpret pragma Export as it was in previous versions.
when this is defined, it toggles the default values of -qinstances and -qreinstantiate.
shows a stack traceback when an unhandled exception is raised within a task other than the environment task.
see -qstack_limit=environment_variable option above.
see -qtask_stack=environment_variable option above.


Typical sessions might be:

ada package_1.ada   # library unit in package_1.ada

ada package_2.ada   # library unit in package_2.ada

ada main_unit.ada   # main unit compiled (procedure
                    # my_program)

ada -b my_program   # binds and links with "my_program"
                    # as main and produces "a.out"


ada package_1.ada
ada package_2.ada
ada -m main_unit.ada


abuild, alibinit, aprojbuild, areport, ashared, powerada.