User`s guide

Compiler Overview [7]
The following examples show how to use the compiler options for various compiler
tasks using the whole-program and separate-module modes.
Whole-program:
c++ -c a.cc -pl prog.pl (parses a.cc)
c++ -c b.cc -pl prog.pl (parses b.cc)
c++ -pl prog.pl -o prog a.o b.o (translates a.o, b.o; links prog)
Or, as a shortcut:
c++ a.cc b.cc -o prog (compiles a.cc, b.cc; links prog, and creates prog.pl)
Separate-module:
c++ -c a.cc (parses and translates a.cc)
c++ -c b.cc (parses and translates b.cc)
c++ -o prog a.o b.o (links prog)
7.3.1 Whole-program Mode
With whole-program compilation, the compiler has access to information about all
functions in the program while optimizing each function. This information provides
the compiler with the context for how the larger program uses each function. For
example, when you use the c++ command to link the files jacobian.cc and
blas.cc, the compiler has access to the entire program during all but the initial
compilation phases, and compiles the program in whole-program mode. To do this,
use the following command:
c++ jacobian.cc blas.cc
The previous command produces the skinny .o files jacobian.o and blas.o,
the executable a.out, and the program library a.out.pl.
Whole-program compilation enables inlining among files. The compiler can inline
functions in blas into call sites in jacobian, and vice versa. The compiler can
also inline functions into jacobian and blas from user-defined libraries linked
with the program. See Creating New Libraries on page 87.
The compiler builds the program library a.out.pl during the compilation phase.
The whole-program compilation mode can be specified while retaining the flexibility
of multiple compilation steps that you typically use for separate-module compilation.
To do this, use the following sequence of commands:
c++ -pl test.pl -c ddot.cc
c++ -pl test.pl -c svd.cc
c++ -pl test.pl -o test svd.o ddot.o
The first two commands perform the initial compilation phase of ddot.cc and
svd.cc using the program library test.pl. The last command specifies the
construction of the test executable using the test.pl program library and the
svd and ddot modules.
S247920 81