This topic discusses how to use IPO from the command line.
Compiling and Linking Using IPO
To enable IPO, you first compile each source file, then link the resulting source files.
First, compile your source files with
[Q]ipocompiler as shown below:
icpc -ipo -c a.cpp b.cpp c.cpp
icl /Qipo /c a.cpp b.cpp c.cpp
The output of the above example command differs according to operating system:
- Linuxand: The commands producemacOS*a.o,b.o, andc.oobject files.
- Windows: The commands producea.obj,b.obj, andc.objobject files.
ccompiler option to stop compilation after generating
.objfiles. The output files contain compiler intermediate representation (IR) corresponding to the compiled source files.
Second, link the resulting files. The following example command will produce an executable named
icpc -o app a.o b.o c.o
icl /Feapp a.obj b.obj c.obj
The command invokes the compiler on the objects containing IR and creates a new list of objects to be linked. Alternately, you can use the
xilink(Windows) tool, with the appropriate linking options.
Combining the Steps
The separate compile and link commands demonstrated above can be combined into a single command, as shown in the following examples:
icpc -ipo -o app a.cpp b.cpp c.cpp
icl /Qipo /Feapp a.cpp b.cpp c.cpp
icl/icpccommand, shown in the examples above, calls
link.exe(Windows only) to link the specified object files and produce the executable application, which is specified by the
icpcallows the compiler to use standard C++ libraries automatically;
iccwill not use the standard C++ libraries automatically.
: Using icc/icpc commands allows the compiler to use libc++ libraries, by default.
You can switch to using the GNU implementation of the standard C++ library using the
The Intel linking tools emulate the behavior of compiling at
If multiple file IPO is applied to a series of object files, no one which are mock object files, no multi-file IPO is performed. The object files are simply linked with the linker.
Capturing Intermediate IPO Output
[Q]ipo-Scompiler options are useful for analyzing the effects of multi-file IPO, or when experimenting with multi-file IPO between modules that do not make up a complete program.
- Use the[Q]ipo-ccompiler option to optimize across files and produce an object file. The option performs optimizations as described for the[Q]ipooption but stops prior to the final link stage, leaving an optimized object file. The default name for this file isipo_out.o(Linuxand) ormacOS*ipo_out.obj(Windows).
- Use the[Q]ipo-Scompiler option to optimize across files and produce an assembly file. The option performs optimizations as described for[Q]ipo, but stops prior to the final link stage, leaving an optimized assembly file. The default name for this file isipo_out.s(Linux) oripo_out.asm(Windows).
For both options, you can use the
/Fe(Windows) option to specify a different name.
These options generate multiple outputs if multi-object IPO is being used. The name of the first file is taken from the value of the
The names of subsequent files are derived from the first file with an appended numeric value to the file name. For example, if the first object file is named
foo.obj(Windows), the second object file will be named
You can use the object file generated with the
[Q]ipo-coption, but you will not get the full benefit of whole program optimizations if you use this option.
The object file created using the
[Q]ipo-coption is a real object file, in contrast to the mock file normally generated using IPO; however, the generated object file is significantly different than the mock object file.