Sun Studio 12: C++ User's Guide

A.2.117 -xcrossfile[=n]

SPARC: Enables optimization and inlining across source files. -xcrossfile works at compile time and involves only the files that appear on the compilation command. Consider the following command-line example:

example% CC -xcrossfile -xO4 -c
example% CC -xcrossfile -xO4 -c

Cross-module optimizations occur between files and, and between and No optimizations occur between and or

A.2.117.1 Values

n must be one of the following values.

Table A–30 The -xcrossfile Values




Do not perform cross-file optimizations or cross-file inlining. 


Perform optimization and inlining across source files. 

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

With -xcrossfile or -xcrossfile=1, the compiler analyzes all the files named on the command line as if they had been concatenated into a single source file.


If -xcrossfile is not specified, -xcrossfile=0 is assumed and no cross-file optimizations or inlining are performed.

-xcrossfile is the same as -xcrossfile=1.


The -xcrossfile option is effective only when it is used with -xO4 or -xO5.


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 makefiles.

See Also