User`s guide
Cray XMT™ Programming Environment User’s Guide
7.1 The Compilation Process
There are two major phases of building a program executable from a number of
source files.
Compilation
The compiler creates object files by invoking subprograms that
translate the source files and optimize functions in the program.
The compiler starts by invoking the front end. When the front end
finishes, the compiler invokes the translator, which is the subprogram
that optimizes and parallelizes code, and generates object files.
Linking The compiler creates an executable program by invoking
subprograms that create links between object files created during
the compilation process and any associated libraries. Links can
be created between two or more object files, in any combination,
including the startup file, any specified object files or compile
results, and user-created or standard libraries.
For a traditional UNIX compiler, you use the cc -c file1.c command to
translate the source file file1.c into an object file, which, by default, is called
file1.o. You then link a set of object files using the cc file1.o file2.o
command. This creates an executable called a.out. Unfortunately, this approach
to compilation decreases the efficiency of the resultant executable program because
each file of functions is first compiled independently and then linked together in a
separate process. Using this approach, information that the compiler uses to optimize
functions during the first compilation is not available during the linking phase
when the object files are combined to form an executable. As a result, the compiler
cannot perform some optimizations between object files that might seem simple to a
programmer.
In response to this problem, the Cray XMT compiler supports a compilation mode
that enables information to be captured from individual modules and used when
compiling multi-module programs. In this mode, each function is compiled in the
context of a complete program, and the compiler may use facts about that context to
optimize the translation of the function. The compiler retains this information so that
when you modify your program's functions in the future, the compiler only needs to
recompile the modified functions, resulting in a shorter recompile time. This mode is
called
whole-program compilation. The Cray XMT compiler also supports a mode
for the traditional UNIX style of compiling called separate-module compilation.
76 S–2479–20