An Ada program consists of a set of source files, and the first step in compiling the program is to generate the corresponding object files. These are generated by compiling a subset of these source files. The files you need to compile are the following:
If a package spec has no body, compile the package spec to produce the object file for the package.
If a package has both a spec and a body, compile the body to produce the object file for the package. The source file for the package spec need not be compiled in this case because there is only one object file, which contains the code for both the spec and body of the package.
For a subprogram, compile the subprogram body to produce the object file for the subprogram. The spec, if one is present, is as usual in a separate file, and need not be compiled.
In the case of subunits, only compile the parent unit. A single object file is generated for the entire subunit tree, which includes all the subunits.
Compile child units completely independently from their parent units (though, of course, the spec of the parent unit must be present).
Compile generic units in the same manner as any other units. The object files in this case are small dummy files that contain at most the flag used for elaboration checking, because XGC Ada always handles generic instantiation using macro expansion. However, it is still necessary to compile generic units, for dependency checking and elaboration purposes.
The preceding rules describe the set of files that must be compiled to generate the object files for a program. Each object file has the same name as the corresponding source file, except that the extension is .o as usual.
You may wish to compile other files for the purpose of checking syntactic and semantic correctness. For example, in the case where a package has a separate spec and body, you would not normally compile the spec. However, it is convenient in practice to compile the spec to make sure it is correct before compiling clients of this spec, because such compilations will fail if there is an error in the spec.
XGC Ada provides the option for compiling such files purely for the purposes of checking correctness; such compilations are not required as part of the process of building a program. To compile a file in this checking mode, use the -gnatc switch.