Sun Studio 12: C User's Guide

B.2.81 -xcrossfile[=n]

Enables optimization and inlining across source files. If specified, n can be 0 or 1.

The default is -xcrossfile=0 which specifies that no crossfile optimizations are performed. -xcrossfile is equivalent to -xcrossfile=1.

Consider the following command-line example:

example% cc -xcrossfile -xO4 -c f1.c f2.c
example% cc -xcrossfile -xO4 -c f3.c f4.c

Cross-module optimizations occur between files f1.c and f2.c, and between f3.c and f4.c. No optimizations occur between f1.c and f3.c or f4.c.

Normally the scope of the compiler’s analysis is limited to each separate file on the command line. For example, -xO4’s automatic inlining is limited to subprograms defined and referenced within the same source file.

With -xcrossfile, the compiler analyzes all the files named on the command line as if they had been concatenated into a single source file. -xcrossfile is only effective when used with -xO4 or -xO5.

However, this option has no effect when you direct the compiler to produce assembly source by specifying the -S option. Assembly (.s) files do not participate in optimizations and inlining across source files.

The files produced from this compilation are interdependent due to possible inlining, and must be used as a unit when they are linked into a program. If any one routine is changed and the files recompiled, they must all be recompiled. As a result, using this option affects the construction of make files.

See also -xldscope.