Oracle® Solaris Studio 12.4: C User's Guide

Exit Print View

Updated: March 2015
 
 

C Compiler Options Reference

This chapter describes the C compiler options in alphabetical order. See Appendix A, Compiler Options Grouped by Functionality for options grouped by functionality. For example, Table A–1 lists all the optimization and performance options.

The C compiler recognizes by default some of the constructs of the 2011 ISO/IEC C standard. The supported features are detailed in Appendix C, Features of C11. Use the -std command if you want to limit the compiler to a previous version of ISO/IEC C standard.

B.1 Option Syntax

The syntax of the cc command is:

% cc [options] filenames [libraries]...

where:

  • options represents one or more of the options described in Table A–14.

  • filenames represents one or more files used in building the executable program

    The C compiler accepts a list of C source files and object files contained in the list of files specified by filenames. The resulting executable code is placed in a.out, unless the -o option is used. In this case, the code is placed in the file named by the -o option.

    Use the C compiler to compile and link any combination of the following:

    • C source files, with a .c suffix

    • Inline template files, with a .il suffix (only when specified with .c files)

    • C preprocessed source files, with a .i suffix

    • Object-code files, with .o suffixes

    • Assembler source files, with .s suffixes

      After linking, the C compiler places the linked files, now in executable code, into a file named a.out, or into the file specified by the -o option. When the compiler produces object code for each .i or .c input file, it always creates an object (.o) file in the current working directory.

    libraries represents any of a number of standard or user-provided libraries containing functions, macros, and definitions of constants.

Use the option -YP, dir to change the default directories used for finding libraries. dir is a colon-separated path list. The default library search order can be seen by using the -### or -xdryrun option and examining the -Y option of the ld invocation.

cc uses getopt to parse command-line options. Options are treated as a single letter or a single letter followed by an argument. See thegetopt(3c) man page.

B.2 cc Options

This section describes the cc options, arranged alphabetically. These descriptions are also available 0n the cc(1) man page. Use the cc -flags option for a one-line summary of these descriptions.

Options noted as being unique to one or more platforms are accepted without error and ignored on all other platforms.

B.2.1 -#

Enables verbose mode, showing how command options expand. Shows each component as it is invoked.

B.2.2 -###

Shows each component as it would be invoked, but does not actually execute it. Also shows how command options would expand.

B.2.3 –Aname[(tokens)]

Associates name as a predicate with the specified tokens as if by a #assert preprocessing directive. Preassertions:

  • system(unix)

  • machine(sparc) (SPARC)

  • machine(i386) (x86)

  • cpu(sparc) (SPARC)

  • cpu(i386) (x86)

These preassertions are not valid in -pedantic mode.

-A followed only by a dash (-) causes all predefined macros (other than those that begin with __) and predefined assertions to be ignored.

B.2.4 -ansi

Equivalent to -std=c89.

B.2.5 -B[static|dynamic]

Specifies whether bindings of libraries for linking are static or dynamic, indicating whether libraries are non-shared or shared, respectively.

–Bdynamic causes the link editor to look for files named libx.so and then for files named libx.a when given the -lx option.

–Bstatic causes the link editor to look only for files named libx.a. This option may be specified multiple times on the command line as a toggle. This option and its argument are passed to ld(1).


Note -  Many system libraries, such as libc, are only available as dynamic libraries in the Oracle Solaris 64-bit compilation environment. Therefore, do not use -Bstatic as the last toggle on the command line.

This option and its argument are passed to the linker.

B.2.6 -C

Prevents the C preprocessor from removing comments, except those on the preprocessing directive lines.

B.2.7 -c

Directs the C compiler to suppress linking with ld(1) and to produce a .o file for each source file. You can explicitly name a single object file using the-o option. When the compiler produces object code for each .i or .c input file, it always creates an object (.o) file in the current working directory. If you suppress the linking step, you also suppress the removal of the object files.

B.2.8 -Dname[(arg[,arg])][=expansion]

Define a macro with optional arguments as if the macro is defined by a #define preprocessing directive. If no =expansion is specified, the compiler assumes 1.

See the cc(1) man page for a list of compiler predefined macros.

B.2.9 -d[y|n]

-dy specifies dynamic linking, which is the default, in the link editor.

-dn specifies static linking in the link editor.

This option and its arguments are passed to ld(1).


Note -  This option causes fatal errors if you use it in combination with dynamic libraries. Most system libraries are only available as dynamic libraries.

B.2.10 -dalign

(SPARC) Obsolete. You should not use this option. Use -xmemalign=8s instead. See -xmemalign=ab for more information. For a complete list of obsolete options, see Obsolete Options. This option is silently ignored on x86 platforms.

B.2.11 -E

Runs the source file through the preprocessor only and sends the output to stdout. The preprocessor is built directly into the compiler, except in -Xs mode, where /usr/ccs/lib/cpp is invoked. Includes the preprocessor line numbering information. See also the description of the -P option.

B.2.12 -errfmt[=[no%]error]

Use this option if you want to prefix the string “error:” to the beginning of error messages so they are more easily distinguishable from warning messages. The prefix is also attached to warnings that are converted to errors by -errwarn.

Table B-1  -errfmt Flags
Flag
Meaning
error
Add the prefix “error:” to all error messages.
no%error
Do not add the prefix “error:” to any error messages.

If you do not specify this option, the compiler sets it to -errfmt=no%error. If you specify –errfmt but do not supply a value, the compiler sets it to -errfmt=error.

B.2.13 -errhdr[=h]

Limits the warnings from header files to the group of header files indicated by the flags in the following table:

Table B-2  —errhdr option
Value
Meaning
%all
Check all header files used.
%none
Do not check header files.
%user
Checks all used user header files, that is, all header files except those in /usr/include and its subdirectories, as well as those supplied by the compiler. This is the default.

B.2.14 -erroff[=t]

This command suppresses C compiler warning messages and has no effect on error messages. This option applies to all warning messages regardless of whether they have been designated by -errwarn to cause a non-zero exit status.

t is a comma-separated list that consists of one or more of the following: tag, no%tag, %all, %none. Order is important; for example, %all,no%tag suppresses all warning messages except tag. The following table lists the -erroff values.

Table B-3  -erroff Flags
Flag
Meaning
tag
Suppresses the warning message specified by tag. You can display the tag for a message by using the -errtags=yes option.
no%tag
Enables the warning message specified by tag.
%all
Suppresses all warning messages.
%none
Enables all warning messages (default).

The default is -erroff=%none. Specifying -erroff is equivalent to specifying -erroff=%all.

Only warning messages from the C compiler front-end that display a tag when the -errtags option is used can be suppressed with the -erroff option. You can achieve finer control over error message suppression. See error_messages.

B.2.15 -errshort[=i]

Use this option to control how much detail is in the error message produced by the compiler when it discovers a type mismatch. This option is particularly useful when the compiler discovers a type mismatch that involves a large aggregate.

i can be one of the values listed in the following table.

Table B-4  -errshort Flags
Flag
Meaning
short
Error messages are printed in short form with no expansion of types. Aggregate members are not expanded, neither are function argument and return types.
full
Error messages are printed in full verbose form showing the full expansion of the mismatched types.
tags
Error messages are printed with tag names for types which have tag names. If there is no tag name, the type is shown in expanded form.

If you do not specify -errshort, the compiler sets the option to -errshort=full. If you specify -errshort but do not provide a value, the compiler sets the option to -errshort=tags.

This option does not accumulate. It accepts the last value specified on the command line.

B.2.16 -errtags[=a]

Displays the message tag for each warning message of the C compiler front-end that can be suppressed with the -erroff option or made a fatal error with the -errwarn option. Messages from the C compiler driver and other components of the C compilation system do not have error tags, and cannot be suppressed with -erroff and made fatal with -errwarn.

a can be either yes or no. The default is -errtags=no. Specifying -errtags is equivalent to specifying -errtags=yes.

B.2.17 -errwarn[=t]

Use the -errwarn option to cause the C compiler to exit with a failure status for the given warning messages.

t is a comma-separated list that consists of one or more of the following: tag, no%tag, %all, %none. Order is important; for example %all,no%tag causes cc to exit with a fatal status if any warning except tag is issued.

The warning messages generated by the C compiler change from release to release as the compiler error checking improves and features are added. Code that compiles using -errwarn=%all without error might not compile without error in the next release of the compiler.

Only warning messages from the C compiler front-end that display a tag when the -errtags option is used can be specified with the -errwarn option to cause the C compiler to exit with a failure status.

The following table details the -errwarn values:

Table B-5  -errwarn Flags
Flag
Meaning
tag
Cause cc to exit with a fatal status if the message specified by tag is issued as a warning message. Has no effect if tag is not issued.
no%tag
Prevent cc from exiting with a fatal status if the message specified by tag is issued only as a warning message. Has no effect if the message specified by tag is not issued. Use this option to revert a warning message that was previously specified by this option with tag or %all from causing cc to exit with a fatal status when issued as a warning message.
%all
Cause the compiler to exit with a fatal status if any warning messages are issued. %all can be followed by no%tag to exempt specific warning messages from this behavior.
%none
Prevents any warning message from causing the compiler to exit with a fatal status should any warning message be issued.

The default is -errwarn=%none. Specifying -errwarn alone is equivalent to -errwarn=%all.

B.2.18 -fast

This option is a macro that can be effectively used as a starting point for tuning an executable for maximum runtime performance. The -fast option macro can change from one release of the compiler to the next and expands to options that are target platform specific. Use the -# option or -xdryrun to examine the expansion of -fast, and incorporate the appropriate options of -fast into the ongoing process of tuning the executable.

The expansion of -fast includes the -xlibmopt option, which enables the compiler to use a library of optimized math routines. For more information, see -xlibmopt.

The -fast option impacts the value of errno. See Preserving the Value of errno for more information.

Modules that are compiled with -fast must also be linked with -fast. For a complete list of all compiler options that must be specified at both compile time and at link time, see Compile-Time and Link-Time Options.

The –fast option is unsuitable for programs intended to run on a different target than the compilation machine. In such cases, follow -fast with the appropriate -xtarget option. For example:

cc -fast -xtarget=generic ...

For C modules that depend on exception handling specified by SUID, follow -fast by -xnolibmil:

% cc -fast -xnolibmil

With -xlibmil, exceptions cannot be noted by setting errno or calling matherr(3m).

The –fast option is unsuitable for programs that require strict conformance to the IEEE 754 Standard.

The following table lists the set of options selected by -fast across platforms.

Table B-6  -fast Expansion Flags
Option
SPARC
x86
-fma=fused
X
X
-fns
X
X
-fsimple=2
X
X
-fsingle
X
X
-nofstore
-
X
-xalias_level=basic
X
X
-xbuiltin=%all
X
X
-xlibmil
X
X
-xlibmopt
X
X
-xmemalign=8s
X
-
-xO5
X
X
-xregs=frameptr
-
X
-xtarget=native
X
X

Note -  Some optimizations make certain assumptions about program behavior. If the program does not conform to these assumptions, the application might fail or produce incorrect results. Refer to the description of the individual options to determine whether your program is suitable for compilation with -fast.

The optimizations performed by these options might alter the behavior of programs from that defined by the ISO C and IEEE standards. See the description of the specific option for details.

The -fast flag acts like a macro expansion on the command line. Therefore, you can override the optimization level and code generation option aspects by following -fast with the desired optimization level or code generation option. Compiling with the -fast -xO4 pair is like compiling with the -xO2 -xO4 pair. The latter specification takes precedence.

On x86, the -fast option includes -xregs=frameptr. See the discussion of this option for details, especially when compiling mixed C, Fortran, and C++ source codes.

Do not use this option for programs that depend on IEEE standard exception handling; you can get different numerical results, premature program termination, or unexpected SIGFPE signals.

To see the actual expansion of —fast on a running platform, use the following command:

% cc -fast -xdryrun |& grep ###

B.2.19 -fd

Reports K&R-style function definitions and declarations.

B.2.20 -features=[v]

The following table lists acceptable values for v.

Table B-7  The -features Flags
Value
Meaning
[no%]conststrings
Enables the placement of string literals in read-only memory. The default is –features=conststrings which places string literals into the read-only data section. Note that compiling a program that attempts to write to the memory location of a string literal will now cause a segmentation fault when compiled with this option. no% prefix disables this suboption.
[no%]extensions
Allows/disallows zero-sized struct/union declarations and void functions with return statements returning a value to work.
extinl
Generates extern inline functions as global functions. This is the default, which conforms to the 1999 C standard.
no%extinl
Generates extern inline functions as static functions. Compile new codes with -features=no%extinl to obtain the same treatment of extern inline functions as provided by older versions of the C and C++ compilers.
[no%]typeof
Enables/disables recognition of the typeof operator. The typeof operator returns the type of its argument (either an expression or a type). It is specified syntactically like the sizeof operator, but it behaves semantically like a type defined with typedef.
Accordingly, it can be used anywhere a typedef can be used. For example, it can be used in a declaration, a cast, or inside of a sizeof or typeof. The default is -features=typeof.
The no% prefix disables this feature.
%none
The -features=%none option is deprecated and should be replaced by -features=no% followed by the suboption..

Old C and C++ objects (created with Solaris Studio compilers prior to this release) can be linked with new C and C++ objects with no change of behavior for the old objects. To get standard conforming behavior, you must recompile old code with the current compiler.

B.2.20.1 —features=typeof Examples

          typeof(int) i;/* declares variable "i" to be type int*/
          typeof(i+10) j;/* declares variable "j" to be type int,
                            the type of the expression */

          i = sizeof(typeof(j)); /* sizeof returns the size of
                          the type associated with variable "j" */

          int a[10];
          typeof(a) b;/* declares variable "b" to be array of
                         size 10 */

The typeof operator can be especially useful in macro definitions, where arguments may be of arbitrary type. For example:

                    #define SWAP(a,b)
                { typeof(a) temp; temp = a; a = b; b = temp; }

B.2.21 -flags

Prints a brief summary of each available compiler option.

B.2.22 -flteval[={any|2}]

(x86) Use this option to control how floating-point expressions are evaluated.

Table B-8  -flteval Flags
Flag
Meaning
2
Floating-point expressions are evaluated as long double.
any
Floating point-expressions are evaluated depending on the combination of the types of the variables and constants that make up an expression.

If you do not specify -flteval, the compiler sets it to -flteval=any. If you do specify -flteval but do not provide a value, the compiler sets it to -flteval=2.

-flteval=2 is only usable with -xarch=sse, pentium_pro, ssea, or pentium_proa. -flteval=2 is also not compatible in combination with options -fprecision or -nofstore.

See also Precision of Floating Point Evaluators.

B.2.23 –fma[={none|fused}]

Enables automatic generation of floating-point fused multiply-add instructions. –fma=none disables generation of these instructions. –fma=fused allows the compiler to attempt to find opportunities to improve the performance of the code by using floating-point fused multiply-add instructions.

The default is –fma=none.

The minimum architecture requirement is –xarch=sparcfmaf on SPARC and -xarch=avx2 on x86 to generate fused multiply-add instructions. The compiler marks the binary program if fused multiply-add instructions are generated in order to prevent the program from executing on platforms that do not support fused multiply-add instructions. When the minimum architecture is not used, then -fma=fused has no effect.

Fused multiply-add instructions eliminate the intermediate rounding step between the multiply and add. Consequently, programs may produce different results when compiled with –fma=fused, although precision will tend to increase rather than decrease.

B.2.24 -fnonstd

This option is a macro for -fns and -ftrap=common.

B.2.25 -fns[={no|yes}]

On SPARC platforms, this option enables nonstandard floating-point mode.

For x86 platforms, this option selects SSE flush-to-zero mode and, where available, denormals-are-zero mode, which causes subnormal results to be flushed to zero, and, where available, this option also causes subnormal operands to be treated as zero. This option has no effect on traditional x86 floating-point operations that do not utilize the SSE or SSE2 instruction set.

The default is -fns=no, standard floating-point mode. -fns is the same as -fns=yes.

Optional use of =yes or =no provides a way of toggling the -fns flag following some other macro flag that includes -fns, such as -fast.

On some SPARC systems, the nonstandard floating point mode disables “gradual underflow,” causing tiny results to be flushed to zero rather than producing subnormal numbers. It also causes subnormal operands to be replaced silently by zero. On those SPARC systems that do not support gradual underflow and subnormal numbers in hardware, use of this option can significantly improve the performance of some programs.

When nonstandard mode is enabled, floating point arithmetic may produce results that do not conform to the requirements of the IEEE 754 standard. See the Numerical Computation Guide for more information.

On SPARC systems, this option is effective only if used when compiling the main program.

B.2.26 -fopenmp

Same as -xopenmp=parallel.

B.2.27 -fPIC

Equivalent to -KPIC

B.2.28 -fpic

Equivalent to -Kpic

B.2.29 -fprecision=p

(x86) -fprecision= {single, double, extended}

Initializes the rounding-precision mode bits in the Floating-point Control Word to single (24 bits), double (53 bits), or extended (64 bits), respectively. The default floating-point rounding-precision mode is extended.

Note that on x86, only the precision, not exponent, range is affected by the setting of floating-point rounding precision mode.

This option is effective only on x86 systems and only if used when compiling the main program, but is ignored if compiling for 64–bit (-m64) or SSE2–enabled (-xarch=sse2) processors. It is also ignored on SPARC systems.

B.2.30 -fround=r

Sets the IEEE 754 rounding mode that is established at runtime during the program initialization.

r must be one of: nearest, tozero, negative, positive.

The default is -fround=nearest.

The meanings are the same as those for the ieee_flags subroutine.

When r is tozero, negative, or positive, this flag sets the rounding direction mode to round-to-zero, round-to-negative-infinity, or round-to-positive-infinity respectively when a program begins execution. When r is nearest or the -fround flag is not used, the rounding direction mode is not altered from its initial value (round-to-nearest by default).

This option is effective only if used when compiling the main program.

B.2.31 -fsimple[=n]

Enables the optimizer to make simplifying assumptions concerning floating-point arithmetic.

The compiler defaults to -fsimple=0. Specifying -fsimple, is equivalent to -fsimple=1.

If n is present, it must be 0, 1, or 2.

Table B-9  -fsimple Flags
Value
Meaning
-fsimple=0
Permits no simplifying assumptions. Preserve strict IEEE 754 conformance.
-fsimple=1
Allows conservative simplifications. The resulting code does not strictly conform to IEEE 754.
With -fsimple=1, the optimizer can assume the following:
  • IEEE 754 default rounding/trapping modes do not change after process initialization.

  • Computations producing no visible result other than potential floating-point exceptions may be deleted.

  • Computations with Infinity or NaNs as operands need not propagate NaNs to their results. For example, x*0 may be replaced by 0.

  • Computations do not depend on sign of zero.

    With -fsimple=1, the optimizer is not allowed to optimize completely without regard to roundoff or exceptions. In particular, a floating-point computation cannot be replaced by one that produces different results with rounding modes held constant at runtime.

-fsimple=2
Includes all the functionality of –fsimple=1 and also enables use of SIMD instructions to compute reductions when -xvector=simd is in effect.
The compiler attempts aggressive floating-point optimizations that might cause many programs to produce different numeric results due to changes in rounding. For example, -fsimple=2 permits the optimizer to replace all computations of x/y in a given loop with x*z, where x/y is guaranteed to be evaluated at least once in the loop, z=1/y, and the values of y and z are known to have constant values during execution of the loop.

Even with -fsimple=2, the optimizer is not permitted to introduce a floating-point exception in a program that otherwise produces none.

See Techniques for Optimizing Applications: High Performance Computing by Rajat Garg and Ilya Sharapov for a more detailed explanation of how optimization can affect precision.

B.2.32 -fsingle

(-Xt and -Xs modes only) By default -Xs and -Xt follow the K&R C rules for float expressions, by promoting them to double and evaluating them in double precision. Use -fsingle when specifying -Xs or -Xt to cause the compiler to evaluate float expressions as single precision.

B.2.33 -fstore

(x86) Causes the compiler to convert the value of a floating-point expression or function to the type on the left-hand side of an assignment, when that expression or function is assigned to a variable, or when the expression is cast to a shorter floating-point type, rather than leaving the value in a register. Due to rounding and truncation, the results might be different from those that are generated from the register value. This is the default mode.

Use the -nofstore flag to disable this option.

B.2.34 -ftrap=t[,t...]

Sets the IEEE trapping mode in effect at startup but does not install a SIGFPE handler. You can use ieee_handler(3M) or fex_set_handling(3M) to simultaneously enable traps and install a SIGFPE handler. If you specify more than one value, the list is processed sequentially from left to right.

t can be one of the values listed in the following table.

Table B-10  -ftrap Flags
Flag
Meaning
[no%]division
Trap on division by zero.
[no%]inexact
Trap on inexact result.
[no%]invalid
Trap on invalid operation.
[no%]overflow
Trap on overflow.
[no%]underflow
Trap on underflow.
%all
Trap on all of the above.
%none
Trap on none of the above.
common
Trap on invalid, division by zero, and overflow.

Note that the no% prefix is used only to modify the meaning of the %all and common values, and must be used with one of these values, as shown in the example. The no% prefix does not explicitly cause a particular trap to be disabled.

If you do not specify –ftrap, the compiler assumes –ftrap=%none.

Example: –ftrap=%all,no%inexact sets all traps except inexact.

If you compile one routine with -ftrap=t, you should compile all routines of the program with the same option to avoid unexpected results.

Use the -ftrap=inexact trap with caution. Use of –ftrap=inexact results in the trap being issued whenever a floating-point value cannot be represented exactly. For example, the following statement generates this condition:

x = 1.0 / 3.0;

This option is effective only if used when compiling the main program. Be cautious when using this option. To enable the IEEE traps, use -ftrap=common.

B.2.35 -G

Produces a shared object rather than a dynamically linked executable. This option is passed to ld(1), and cannot be used with the -dn option.

When you use the -G option, the compiler does not pass any default -l options to ld. If you want the shared library to have a dependency on another shared library, you must pass the necessary -l option on the command line.

If you are creating a shared object by specifying -G along with other compiler options that must be specified at both compile time and link time, make sure that those same options are also specified when you link with the resulting shared object.

When you create a shared object, all the 64–bit SPARC object files that are compiled with -m64 must also be compiled with an explicit -xcode value as documented in -xcode[=v].

B.2.36 -g

See -g[n].

B.2.37 -g[n]

Produces additional symbol table information for debugging with dbx(1) and the Performance Analyzer, analyzer(1).

If you specify -g, and the optimization level is -xO3 or lower, the compiler provides best-effort symbolic information with almost full optimization. Tail-call optimization and back-end inlining are disabled.

If you specify -g and the optimization level is -xO4, the compiler provides best-effort symbolic information with full optimization.

Compile with the -g option to use the full capabilities of the Performance Analyzer. While some performance analysis features do not require -g, you must compile with -g to view annotated source, some function level information, and compiler commentary messages. See the analyzer(1) man page and the Performance Analyzer manual for more information.

The commentary messages that are generated with -g describe the optimizations and transformations that the compiler made while compiling your program. Use the er_src(1) command to display the messages, which are interleaved with the source code.


Note -  If you compile and link your program in separate steps, then including the —g option in one step and excluding it from the other step will not affect the correctness of the program, but it will affect the ability to debug the program. Any module that is not compiled with —g, but is linked with —g will not be prepared properly for debugging. Note that compiling the module that contains the function main with the —g option is usually necessary for debugging.

-g is implemented as a macro that expands to various other, more primitive, options. See -xdebuginfo for the details of the expansions.

-g

Produce standard debugging information.

-gnone

Do not produce any debugging information. This is the default.

-g1

Produce file and line number as well as simple parameter information that is considered crucial during post-mortem debugging.

-g2

Same as -g.

-g3

Produce additional debugging information, which currently consists only of macro definition information. This added information can result in an increase in the size of the debug information in the resulting .o and executable when compared to using only -g.

For more information about debugging, see the Debugging a Program With dbx manual.

B.2.38 -H

Prints to standard error, one per line, the path name of each file included during the current compilation. The display is indented to show which files are included by other files.

In the following example, the program sample.c includes the files stdio.h and math.h. math.h includes the file floatingpoint.h, which itself includes functions that use sys/ieeefp.h.

% cc -H sample.c
    /usr/include/stdio.h
    /usr/include/math.h
        /usr/include/floatingpoint.h
            /usr/include/sys/ieeefp.h

B.2.39 -h name

Assigns a name to a shared dynamic library as a way to have different versions of a library. name should be the same as the file name provided with the -o option. The space between -h and name is optional.

The linker assigns the specified name to the library and records the name in the library file as the intrinsic name of the library. If there is no -hname option, then no intrinsic name is recorded in the library file.

When the runtime linker loads the library into an executable file, it copies the intrinsic name from the library file into the executable's, list of needed shared library files. Every executable has such a list. If no intrinsic name of a shared library is provided, the linker copies the path of the shared library file instead.

B.2.40 -I[-|dir]

-I dir adds dir to the list of directories that are searched for #include files with relative file names prior to /usr/include, that is, those directory paths not beginning with a / (slash).

Directories for multiple -I options are searched in the order specified.

For more information on the search pattern of the compiler, see Using the -I- Option to Change the Search Algorithm.

B.2.41 -i

Passes the option to the linker to ignore any LD_LIBRARY_PATH or LD_LIBRARY_PATH_64 setting.

B.2.42 –include filename

This option causes the compiler to treat filename as if it appears in the first line of a primary source file as a #include preprocessor directive. Consider the source file t.c:

main()
{
   ...
}

If you compile t.c with the command cc -include t.h t.c, the compilation proceeds as if the source file contains the following:

#include "t.h"
main()
{
   ...
}

The compiler first searches for filename is the current working directory rather than the directory containing the main source file, as is the case when a file is explicitly included. For example, the following directory structure contains two header files with the same name, but at different locations:

foo/
   t.c
   t.h
   bar/
     u.c
     t.h

If your working directory is foo/bar and you compile with the command cc ../t.c -include t.h, the compiler includes t.h from foo/bar, not foo/ as would be the case with a #include directive from within the source file t.c.

If the compiler cannot find the file specified with –include in the current working directory, it searches the normal directory paths for the file. If you specify multiple –include options, the files are included in the order in which they appear on the command line.

B.2.43 -KPIC

(SPARC) Obsolete. You should not use this option. Use -xcode=pic32 instead.

For more information, see -xcode[=v]. For a complete list of obsolete options, see Obsolete Options.

(x86) -KPIC is identical to -Kpic.

B.2.44 -Kpic

(SPARC) Obsolete. You should not use this option. Use -xcode=pic13 instead. For more information, see -xcode[=v]. For a complete list of obsolete options, see Obsolete Options.

(x86) Produces position-independent code. Use this option to compile source files when building a shared library. Each reference to a global datum is generated as a dereference of a pointer in the global offset table. Each function call is generated in pc-relative addressing mode through a procedure linkage table.

B.2.45 -keeptmp

Retains temporary files created during compilation instead of deleting them automatically.

B.2.46 -Ldir

Adds dir to the list of directories searched for libraries by ld(1). This option and its arguments are passed to ld(1).


Note -  Never specify the compiler installation area (/usr/include, /lib, or /usr/lib) as search directories.

B.2.47 -lname

Links with object library libname.so, or libname.a. The order of libraries in the command is important, as symbols are resolved from left to right.

This option must follow the sourcefile arguments.

B.2.48 -library=sunperf

Link with the Oracle Solaris Studio performance libraries.

B.2.49 –m32|–m64

Specifies the memory model for the compiled binary object.

Use –m32 to create 32-bit executables and shared libraries. Use –m64 to create 64-bit executables and shared libraries.

The ILP32 memory model (32-bit int, long, pointer data types) is the default on all Oracle Solaris platforms and on Linux platforms that are not 64-bit enabled. The LP64 memory model (64-bit long, pointer data types) is the default on Linux platforms that are 64-bit enabled. –m64 is permitted only on platforms that are enabled for the LP64 model.

Object files or libraries compiled with –m32 cannot be linked with object files or libraries compiled with–m64.

Modules that are compiled with –m32 |–m64 must also be linked with –m32 |–m64. For a complete list of compiler options that must be specified at both compile time and at link time, see Compile-Time and Link-Time Options

When compiling applications with large amounts of static data using –m64 on x86/x64 platforms, –xmodel=medium may also be required. Be aware that some Linux platforms do not support the medium model.

Note that in previous compiler releases, the memory model, ILP32 or LP64, was implied by the choice of the instruction set with –xarch. Starting with the Oracle Solaris Studio 12 compilers, this default is no longer the case. On most platforms, just adding –m64 to the command line is sufficient to create 64-bit objects.

On Oracle Solaris, –m32 is the default. On Linux systems supporting 64-bit programs, –m64 –xarch=sse2 is the default.

See also the description of –xarch.

B.2.50 -mc

Removes duplicate strings from the .comment section of the object file. When you use the -mc flag, mcs -c is invoked.

B.2.51 -misalign

(SPARC) Obsolete. You should not use this option. Use the -xmemalign=1i option instead. For more information, see -xmemalign=ab. For a complete list of obsolete options, see Obsolete Options.

B.2.52 -misalign2

(SPARC) Obsolete. You should not use this option. Use the –xmemalign=2i option instead. For more information, see -xmemalign=ab. For a complete list of obsolete options, see Obsolete Options.

B.2.53 -mr[,string]

-mr removes all strings from the .comment section. When you use this flag, mcs -d -a is invoked.

-mr,string removes all strings from the .comment section and inserts string in that section of the object file. If string contains embedded blanks, it must be enclosed in quotation marks. A null string results in an empty .comment section. This option is passed as -d -astring to mcs.

B.2.54 -mt[={yes|no}]

Use this option to compile and link multithreaded code using the Oracle Solaris threads or POSIX threads API. The –mt=yes option assures that libraries are linked in the appropriate order.

This option passes -D_REENTRANT to the preprocessor.

To use Oracle Solaris threads, include the thread.h header file and compile with the —mt=yes option. To use POSIX threads on Oracle Solaris platforms, include the pthread.h header file and compile with the —mt=yes option.

On Linux platforms, only the POSIX threads API is available. (libthread is not available on Linux platforms.) Consequently, —mt=yes on Linux platforms adds —lpthread instead of —lthread. To use POSIX threads on Linux platforms, compile with —mt.

Note that when compiling with —G, neither —lthread nor —lpthread are automatically included by —mt=yes. You will need to explicitly list these libraries when building a shared library.

The -xopenmp option and the -xautopar option include -mt=yes automatically.

If you compile with –mt=yes and link in a separate step, you must use the -mt=yes option in the link step as well as the compile step. If you compile and link one translation unit with –mt=yes, you must compile and link all units of the program with –mt=yes

-mt=yes is the default behavior of the compiler. If this behavior is not desired, compile with -mt=no.

The option —mt is equivalent to —mt=yes.

See also -xnolib, and the Oracle Solaris Multithreaded Programming Guide, and Linker and Libraries Guide

B.2.55 -native

This option is a synonym for -xtarget=native.

B.2.56 -nofstore

(x86) Does not convert the value of a floating-point expression or function to the type on the left-hand side of an assignment when that expression or function is assigned to a variable or is cast to a shorter floating-point type. Instead, it leaves the value in a register. See also -fstore.

B.2.57 -O

Use default optimization level -xO3. The -O macro expands to -xO3.

The -xO3 optimization level yields higher runtime performance. However, this may be inappropriate for programs that rely on all variables being automatically considered volatile. Typical programs that might have this assumption are device drivers and older multithreaded applications that implement their own synchronization primitives. The workaround is to compile with -xO2 instead of -O.

B.2.58 -o filename

Names the output file filename, instead of the default a.out. filename cannot be the same as the input source file since the compiler will not overwrite a source file.

filename must have an appropriate suffix. When used with —c, filename specifies the target .o object file; with —G it specifies the target .so library file. This option and its argument are passed to the linker, ld.

B.2.59 -P

Runs the source file through the C preprocessor only. It then puts the output in a file with a .i suffix. Unlike -E, this option does not include preprocessor-type line number information in the output. See also the -E option.

B.2.60 -p

The option is now obsolete. Use -xpg instead.

B.2.61 –pedantic{=[yes|no]}

Strict conformance with errors/warnings for non-ANSI constructs. The -std flag can be used to specify which ANSI standard is in effect. The -Xc, -Xa, -Xt, -Xs, and -xc99 flags cannot be specified with the -pedantic flag. Doing so will result in an error being issued by the compiler.

When -pedantic is not specified, the default is -pedantic=no.

-pedantic is equivalent to -pedantic=yes.

B.2.62 –preserve_argvalues[=simple|none|complete]

(x86) Saves copies of register-based function arguments in the stack.

When none is specified or if the -preserve_argvalues option is not specified on the command line, the compiler behaves as usual.

When simple is specified, up to six integer arguments are saved.

When complete is specified, the values of all function arguments in the stack trace are visible to the user in the proper order.

The values are not updated during the function lifetime on assignments to formal parameters.

B.2.63 –Qoption phase option[,option..]

Passes option to the compilation phase.

To pass multiple options, specify them in order as a comma-separated list. Options that are passed to components with -Qoption might be reordered. Options that the driver recognizes are kept in the correct order. Do not use -Qoption for options that the driver already recognizes.

phase can be one of the values in the following list.

acomp

Compiler

cg

Code generator (SPARC)

cpp

Preprocessor

driver

cc driver

fbe

Assembler

ipo

Interprocedural optimizer

iropt

Optimizer

ld

Link editor (ld)

mcs

mcs — manipulate comment section of object file when —mc or —mr specified.

postopt

Postoptimizer

ssbd

Compiler phase for lock_lint

ube

Code generator (x86)

See also —Wc,arg, which provides equivalent functionality. —Qoption is provided for compatibility with other compilers.

B.2.64 -Q[y|n]

Determines whether to emit identification information to the output file. -Qy is the default.

If -Qy is used, identification information about each invoked compilation tool is added to the .comment section of output files, which is accessible with mcs. This option can be useful for software administration.

-Qn suppresses this information.

B.2.65 -qp

Same as -p.

B.2.66 -Rdir[:dir]

Passes a colon-separated list of directories used to specify library search directories to the runtime linker. If present and not null, the directory list is recorded in the output object file and passed to the runtime linker.

If both LD_RUN_PATH and the -R option are specified, the -R option takes precedence.

B.2.67 -S

Directs cc to produce an assembly source file but not to assemble or link the program. The assembler-language output is written to corresponding files suffixed .s.

B.2.68 -s

Removes all symbolic debugging information from the output object file. This option cannot be specified with -g.

Passed to ld(1).

B.2.69 -staticlib=[no%]sunperf

When used with -library=sunperf, -staticlib=sunperf will link statically with the Sun performance libraries. By default and when -library=no%sunperf is specified, -library=sunperf results in dynamic linking of the Sun performance libraries.

For compatibility with CC, %all and %none are also accepted values for -staticlib, where %all is equivalent to sunperf and %none is equivalent to no%sunperf.

B.2.70 –std=value

C language standard selection flag.

value is defined as one of the following:

c89

C source language accepted is that defined by the ISO C90 standard.

c99

C source language accepted is that defined by the ISO C99 standard.

c11

C source language accepted is that defined by the ISO C11 standard.

The first default is c11, implying acceptance of the C source language as defined by ANSI C11 with extensions. There is no second default. Instead, specification of -std without a value will generate an error.

When any of the flags -Xc, -Xa, -Xt, or -xtransition are specified, the -std first default is not in effect and the compiler defaults to -xc99=all,no_lib. When -Xs is specified, the first default is not in effect and the compiler defaults to -xc99=none. When -xc99 is specified, the -std first default is not in effect and the compiler is as specified by -xc99.

The -Xc, -Xa, -Xt, -Xs, and -xc99 flags cannot be used if the -std flag has been specified. Doing so will result in an error being issued by the compiler.

If you compile and link in separate steps you must use the same values for -std flag in both steps.

B.2.71 –temp=path

Defines the directory for temporary files.

This option sets the path name of the directory for storing the temporary files which are generated during the compilation process. The compiler gives precedence to the value set by –temp over the value of TMPDIR.

B.2.71.1 See Also

–keeptmp

B.2.72 -traceback[={%none|common|signals_list}]

Issues a stack trace if a severe error occurs in execution.

The -traceback option causes the executable to issue a stack trace to stderr, dump core, and exit if certain signals are generated by the program. If multiple threads generate a signal, a stack trace will only be produced for the first one.

To use traceback, add the -traceback option to the compiler command line when linking. The option is also accepted at compile time but is ignored unless an executable binary is generated. Using -traceback with -G to create a shared library is an error.

Table B-11  -traceback Options
Option
Meaning
common
Specifies that a stack trace should be issued if any of a set of common signals occurs: sigill, sigfpe, sigbus, sigsegv, or sigabrt.
signals_list
Specifies a comma-separated list of names of signals that should generate a stack trace, in lower case. The following signals that cause the generation of a core file can be caught: sigquit, sigill, sigtrap, sigabrt, sigemt, sigfpe, sigbus, sigsegv, sigsys, sigxcpu, sigxfsz.
Any of these signals can be preceded with no% to disable catching the signal.
For example: -traceback=sigsegv,sigfpe will produce a stack trace and core dump if either sigsegv or sigfpe occurs.
%none or none
Disables traceback.

If the option is not specified, the default is -traceback=%none

-traceback alone, without a = sign, implies -traceback=common

If you don't want the core dump, set the coredumpsize limit to zero as follows:

% limit coredumpsize 0            

The -traceback option has no effect on runtime performance.

B.2.73 -Uname

Undefines the preprocessor symbol name. This option removes any initial definition of the preprocessor symbol name created by -D on the same command line, including the ones placed there by the command-line driver.

-U has no effect on any preprocessor directives in source files. You can give multiple -U options on the command line.

If the same name is specified for both -D and -U on the command line, name is undefined, regardless of the order in which the options appear. In the following example, -U undefines __sun:

cc -U__sun text.c

Preprocessor statements of the following form in test.c will not take effect because __sun is undefined.

#ifdef(__sun)

See -Dname[(arg[,arg])][=expansion] for a list of predefined symbols.

B.2.74 -V

Directs cc to print the name and version ID of each component as the compiler executes.

B.2.75 -v

Directs the compiler to perform stricter semantic checks and to enable other lint-like checks. For example, the following code compiles and executes without problem.

#include <stdio.h>
main(void)
{
     printf("Hello World.\n");
}

With the -v option it still compiles. However, the compiler displays this warning:

"hello.c", line 5: warning: function has no return statement:
 main

-v does not give all the warnings that lint(1) does. You can see the difference by running the above example through lint.

B.2.76 -Wc,arg

Passes the argument arg to a specified component c. See Table 1–1 for a list of components.

Arguments must be separated from the preceding only by a comma. All -W arguments are passed after the rest of the command-line arguments. To include a comma as part of an argument, use the escape character \ (backslash) immediately before the comma. All -W arguments are passed after the regular command-line arguments.

For example, -Wa,-o,objfile passes -o and objfile to the assembler in that order. Also, -Wl,-I,name causes the linking phase to override the default name of the dynamic linker, /usr/lib/ld.so.1.

The order in which the arguments are passed to a tool with respect to the other specified command line options might change an subsequent compiler releases.

The possible values for c are listed in the following table

Table B-12  -W Flags
Flag
Meaning
a
Assembler: (fbe); (gas)
c
C code generator: (cg) (SPARC) ;
d
cc driver
l
Link editor (ld)
m
mcs
O (Capital o)
Interprocedural optimizer
o (Lowercase o)
Postoptimizer
p
Preprocessor (cpp)
u
C code generator (ube) (x86)
0 (Zero)
Compiler (acomp)
2
Optimizer: (iropt)

Note that you cannot use -Wd to pass cc options to the c compiler.

B.2.77 -w

Suppresses compiler warning messages.

This option overrides the error_messages pragma.

B.2.78 -X[c|a|t|s]

(Obsolete) The -Xs option will be removed in a future release. It is recommended that C code that requires -Xs to build and compile correctly be migrated to conform with at least the C99 dialect of the ISO C standard, that is, compilable with -std=c99.

The -Xc, -Xa, -Xt, and -Xs flags cannot be used if the -std or -xlang flag has been specified.

When not using the -std flag, the -X (note uppercase X) options specify varying degrees of compliance to the 1990 and 1999 ISO C standard. The value of -xc99 affects which version of the ISO C standard the -X option applies. The -xc99 option defaults to -xc99=all which supports the 1999 ISO/IEC C standard. -xc99=none supports the 1990 ISO/IEC C standard. See D.1 for a discussion of supported 1999 ISO/IEC features. See Appendix H for a discussion of differences between ISO/IEC C and K&R C.

The default mode of the compiler is -std=c11 without the -pedantic flag. If the -xc99 flag has been specified or is in effect, then -Xa is the default mode of the compiler .

-Xc

(c = conformance) Issues errors and warnings for programs that use non-ISO C constructs. This option is strictly conformant ISO C without K&R C compatibility extensions. The predefined macro __STDC__ has a value of 1 with the–Xc option.

–Xa

ISO C plus K&R C compatibility extensions with semantic changes required by ISO C. Where K&R C and ISO C specify different semantics for the same construct, the compiler uses the ISO C interpretation. If the -Xa option is used in conjunction with the -xtransition option, the compiler issues warnings about the different semantics. The predefined macro __STDC__has a value of –0 with the–Xa option.

-Xt

(t = transition) This option uses ISO C plus K&R C compatibility extensions without semantic changes required by ISO C. Where K&R C and ISO C specify different semantics for the same construct, the compiler uses the K&R C interpretation. If you use the -Xt option in conjunction with the -xtransition option, the compiler issues warnings about the different semantics. The predefined macro __STDC__ has a value of 0 with the -Xt option.

-Xs

(s = K&R C) Attempts to warn about all language constructs that have differing behavior between ISO C and K&R C. The compiler language includes all features compatible with K&R C. This option invokes cpp for preprocessing. __STDC__ is not defined in this mode.

B.2.79 -x386

(x86) Obsolete. You should not use this option. Use -xchip=generic instead. For a complete list of obsolete options, see Obsolete Options.

B.2.80 -x486

(x86) Obsolete. You should not use this option. Use -xchip=generic instead. For a complete list of obsolete options, see Obsolete Options.

B.2.81 -Xlinker arg

Pass arg to linker ld(1). Equivalent to —z arg

B.2.82 -xaddr32[=yes|no]

(Solaris x86/x64 only) The -xaddr32=yes compilation flag restricts the resulting executable or shared object to a 32-bit address space.

An executable that is compiled in this manner results in the creation of a process that is restricted to a 32-bit address space.

When -xaddr32=no is specified a usual 64 bit binary is produced.

If the -xaddr32 option is not specified, -xaddr32=no is assumed.

If only -xaddr32 is specified -xaddr32=yes is assumed.

This option is only applicable to -m64 compilations and only on Oracle Solaris platforms supporting SF1_SUNW_ADDR32 software capability. Because Linux kernels do not support address space limitation, this option is not available on Linux.

When linking, if a single object file was compiled with -xaddr32=yes, the whole output file is assumed to be compiled with -xaddr32=yes.

A shared object that is restricted to a 32-bit address space must be loaded by a process that executes within a restricted 32-bit mode address space.

For more information refer to the SF1_SUNW_ADDR32 software capabilities definition, described in the Linker and Libraries Guide.

B.2.83 -xalias_level[=l]

The compiler uses the -xalias_level option to determine what assumptions it can make in order to perform optimizations using type-based alias-analysis. This option places the indicated alias level into effect for the translation units being compiled.

If you do not specify the -xalias_level command, the compiler assumes -xalias_level=any. If you specify -xalias_level without a value, the default is -xalias_level=layout.

The -xalias_level option requires optimization level -xO3 or above. If optimization is set lower, a warning is issued and the -xalias_level option is ignored.

Remember that if you issue the -xalias_level option but you fail to adhere to all of the assumptions and restrictions about aliasing described for any of the alias levels, the behavior of your program is undefined.

Replace l with one of the terms in the following table.

Table B-13  Levels of Alias-Disambiguation
Flag
Meaning
any
The compiler assumes that all memory references can alias at this level. There is no type-based alias analysis at the level of -xalias_level=any.
basic
If you use the -xalias_level=basic option, the compiler assumes that memory references that involve different C basic types do not alias each other. The compiler also assumes that references to all other types can alias each other as well as any C basic type. The compiler assumes that references using char * can alias any other type.
For example, at the -xalias_level=basic level, the compiler assumes that a pointer variable of type int * is not going to access a float object. Therefore the compiler can safely perform optimizations that assume a pointer of type float * will not alias the same memory that is referenced with a pointer of type int *.
weak
If you use the -xalias_level=weak option, the compiler assumes that any structure pointer can point to any structure type.
Any structure or union type that contains a reference to any type that is either referenced in an expression in the source being compiled or is referenced from outside the source being compiled must be declared prior to the expression in the source being compiled.
You can satisfy this restriction by including all the header files of a program that contain types that reference any of the types of the objects referenced in any expression of the source being compiled.
At the level of -xalias_level=weak, the compiler assumes that memory references that involve different C basic types do not alias each other. The compiler assumes that references using char * alias memory references that involve any other type.
layout
If you use the -xalias_level=layout option, the compiler assumes that memory references that involve types with the same sequence of types in memory can alias each other.
The compiler assumes that two references with types that do not look the same in memory do not alias each other. The compiler assumes that any two memory accesses through different struct types alias if the initial members of the structures look the same in memory. However, at this level, you should not use a pointer to a struct to access some field of a dissimilar struct object that is beyond any of the common initial sequence of members that look the same in memory between the two structs. The compiler assumes that such references do not alias each other.
At the level of -xalias_level=layout the compiler assumes that memory references that involve different C basic types do not alias each other. The compiler assumes that references using char * can alias memory references involving any other type.
strict
If you use the -xalias_level=strict option, the compiler assumes that memory references, that involve types such as structs or unions, that are the same when tags are removed, can alias each other. Conversely, the compiler assumes that memory references involving types that are not the same even after tags are removed do not alias each other.
However, any structure or union type that contains a reference to any type that is part of any object referenced in an expression in the source being compiled, or is referenced from outside the source being compiled, must be declared prior to the expression in the source being compiled.
You can satisfy this restriction by including all the header files of a program that contain types that reference any of the types of the objects referenced in any expression of the source being compiled. At the level of -xalias_level=strict the compiler assumes that memory references that involve different C basic types do not alias each other. The compiler assumes that references using char * can alias any other type.
std
If you use the -xalias_level=std option, the compiler assumes that types and tags need to be the same to alias, however, references using char * can alias any other type. This rule is the same as the restrictions on the dereferencing of pointers that are found in the 1999 ISO C standard. Programs that properly use this rule will be very portable and should see good performance gains under optimization.
strong
If you use the -xalias_level=strong option, the same restrictions apply as at the std level, but additionally, the compiler assumes that pointers of type char * are used only to access an object of type char. Also, the compiler assumes that there are no interior pointers. An interior pointer is defined as a pointer that points to a member of a struct.

B.2.84 -xanalyze={code|%none}

(Obsolete) This option will be removed in a future release. Use -xprevise instead.

Produce a static analysis of the source code that can be viewed using the Oracle Solaris Studio Code Analyzer.

When compiling with —xanalyze=code and linking in a separate step, include —xanalyze=code also on the link step.

The default is —xanalyze=%none.

On Linux, -xanalyze=code needs to be specified along with -xannotate.

See the Oracle Solaris Studio Code Analyzer documentation for more information.

B.2.85 –xannotate[=yes|no]

Create binaries that can later be used by the optimization and observability tools binopt(1), code-analyzer(1), discover(1), collect(1), and uncover(1).

The default on Oracle Solaris is -xannotate=yes. The default on Linux is -xannotate=no. Specifying -xannotate without a value is equivalent to -xannotate=yes.

For optimal use of the optimization and observability tools, -xannotate=yes must be in effect at both compile and link time. Compile and link with -xannotate=no to produce slightly smaller binaries and libraries when optimization and observability tools will not be used.

B.2.86 –xarch=isa

Specifies the target instruction set architecture (ISA).

This option limits the code generated by the compiler to the instructions of the specified instruction set architecture. This option does not guarantee use of any target–specific instructions. However, use of this option could affect the portability of a binary program.


Note -  Use the –m64 or –m32 option to specify the intended memory model, LP64 (64-bits) or ILP32 (32-bits) respectively. The –xarch option no longer indicates the memory model, except for compatibility with previous releases, as indicated below.

If you compile and link in separate steps, make sure you specify the same value for -xarch in both steps.

When specifying the _asm statement, or compiling with .il inline templates files that use architecture-specific instructions, it might be necessary to specify an appropriate -xarch value to avoid compilation errors.

B.2.86.1 -xarch Flags for SPARC and x86

The following table lists the -xarch keywords common to both SPARC and x86 platforms.

Table B-14  Flags Common to SPARC and x86 Platforms
Flag
Meaning
generic
Uses the instruction set common to most processors. This is the default.
generic64
Compile for good performance on most 64-bit platforms.This option is equivalent to –m64 –xarch=generic and is provided for compatibility with earlier releases.
native
Compile for good performance on this system. The compiler chooses the appropriate setting for the current system processor it is running on.
native64
Compile for good performance on this system. This option is equivalent to –m64 –xarch=native and is provided for compatibility with earlier releases.

B.2.86.2 -xarch Flags for SPARC

The following table describes the -xarch keywords on SPARC platforms.

Table B-15  -xarch Flags for SPARC Platforms
Flag
Meaning
sparc
Compile for the SPARC-V9 ISA, but without the Visual Instruction Set (VIS), and without other implementation-specific ISA extensions. This option enables the compiler to generate code for good performance on the V9 ISA.
sparcvis
Compile for SPARC-V9 plus the Visual Instruction Set (VIS) version 1.0, and with UltraSPARC extensions. This option enables the compiler to generate code for good performance on the UltraSPARC architecture.
sparcvis2
Enables the compiler to generate object code for the UltraSPARC architecture, plus the Visual Instruction Set (VIS) version 2.0, and with UltraSPARC III extensions.
sparcvis3
Compile for the SPARC VIS version 3 of the SPARC-V9 ISA. Enables the compiler to use instructions from the SPARC-V9 instruction set, plus the UltraSPARC extensions, including the Visual Instruction Set (VIS) version 1.0, the UltraSPARC-III extensions, including the Visual Instruction Set (VIS) version 2.0, the fused multiply-add instructions, and the Visual Instruction Set (VIS) version 3.0
sparcfmaf
Enables the compiler to use instructions from the SPARC-V9 instruction set, plus the UltraSPARC extensions, including the Visual Instruction Set (VIS) version 1.0, the UltraSPARC-III extensions, including the Visual Instruction Set (VIS) version 2.0, and the SPARC64 VI extensions for floating-point multiply-add.
You must use –xarch=sparcfmaf in conjunction with fma=fused and some optimization level to get the compiler to attempt to find opportunities to use the multiply-add instructions automatically.
sparcace
Compile for the sparcace version of the SPARC-V9 ISA. Enables the compiler to use instructions from the SPARC-V9 instruction set, plus the UltraSPARC extensions, including the Visual Instruction Set (VIS) version 1.0, the UltraSPARC-III extensions, including the Visual Instruction Set (VIS) version 2.0, the SPARC64 VI extensions for floating-point multiply-add, the SPARC64 VII extensions for integer multiply-add, and the SPARC64 X extensions for ACE floating-point.
sparcaceplus
Compile for the sparcaceplus version of the SPARC-V9 ISA. Enables the compiler to use instructions from the SPARC-V9 instruction set, plus the UltraSPARC extensions, including the Visual Instruction Set (VIS) version 1.0, the UltraSPARC-III extensions, including the Visual Instruction Set (VIS) version 2.0, the SPARC64 VI extensions for floating-point multiply-add, the SPARC64 VII extensions for integer multiply-add, the SPARC64 X extensions for SPARCACE floating-point, and the SPARC64 X+ extensions for SPARCACE floating-point.
sparcima
Compile for the sparcima version of the SPARC-V9 ISA. Enables the compiler to use instructions from the SPARC-V9 instruction set, plus the UltraSPARC extensions, including the Visual Instruction Set (VIS) version 1.0, the UltraSPARC-III extensions, including the Visual Instruction Set (VIS) version 2.0, the SPARC64 VI extensions for floating-point multiply-add, and the SPARC64 VII extensions for integer multiply-add.
sparc4
Compile for the SPARC4 version of the SPARC-V9 ISA. Enables the compiler to use instructions from the SPARC-V9 instruction set, plus the extensions, which includes VIS 1.0, the UltraSPARC-III extensions, which includes VIS2.0, the fused floating-point multiply-add instructions, VIS 3.0, and SPARC4 instructions.
sparc4b
Compile for the SPARC4B version of the SPARC-V9 ISA. Enables the compiler to use instructions from the SPARC-V9 instruction set, plus the UltraSPARC extensions, which includes VIS 1.0, the UltraSPARC-III extensions, which includes VIS2.0, the SPARC64 VI extensions for floating-point multiply-add, the SPARC64 VII extensions for integer multiply-add, and the PAUSE and CBCOND instructions from the SPARC T4 extensions.
sparc4c
Compile for the SPARC4C version of the SPARC-V9 ISA. Enables the compiler to use instructions from the SPARC-V9 instruction set, plus the UltraSPARC extensions, which includes VIS 1.0, the UltraSPARC-III extensions, which includes VIS2.0, the SPARC64 VI extensions for floating-point multiply-add, the SPARC64 VII extensions for integer multiply-add, the VIS3B subset of the VIS 3.0 instructions a subset of the SPARC T3 extensions, called the VIS3B subset of VIS 3.0, and the PAUSE and CBCOND instructions from the SPARC T4 extensions.
sparc5
Compile for the SPARC5 version of the SPARC-V9 ISA. Enables the compiler to use instructions from the SPARC-V9 instruction set, plus the extensions, which includes VIS 1.0, the Ultra SPARC-III extensions, which includes VIS2.0, the fused floating-point multiply-add instructions, VIS 3.0, SPARC4, and SPARC5 instructions.
v9
Is equivalent to –m64 –xarch=sparc. Legacy makefiles and scripts that use –xarch=v9 to obtain the 64-bit memory model need only use –m64.
v9a
Is equivalent to –m64 –xarch=sparcvis and is provided for compatibility with earlier releases.
v9b
Is equivalent to –m64 –xarch=sparcvis2 and is provided for compatibility with earlier releases.

Also note the following:

  • Object binary files (.o) compiled with generic, sparc, sparcvis2, sparcvis3, sparcfmaf, sparcima can be linked and can execute together but can only run on a processor supporting all the instruction sets linked.

  • For any particular choice, the generated executable might not run or might run much more slowly on legacy architectures. Also, because quad-precision (long double) floating-point instructions are not implemented in any of these instruction set architectures, the compiler does not use these instructions in the code it generates.

B.2.86.3 -xarch Flags for x86

The following table lists the -xarch flags on x86 platforms.

Table B-16  The -xarch Flags on x86
Flag
Meaning
amd64
(Solaris only) Is equivalent to –m64 –xarch=sse2. Legacy makefiles and scripts that use –xarch=amd64 to obtain the 64-bit memory model need only use –m64.
amd64a
(Solaris only) Is equivalent to –m64 –xarch=sse2a
pentium_pro
Limits the instruction set to the 32–bit Pentium Pro architecture.
pentium_proa
Adds the AMD extensions (3DNow!, 3DNow! extensions, and MMX extensions) to the 32-bit pentium_pro architecture.
sse
Adds the SSE instruction set to the pentium_pro architecture.
ssea
Adds the AMD extensions (3DNow!, 3DNow! extensions, and MMX extensions) to the 32-bit SSE architecture.
sse2
Adds the SSE2 instruction set to the pentium_pro architecture.
sse2a
Adds the AMD extensions (3DNow!, 3DNow! extensions, and MMX extensions) to the 32-bit SSE2 architecture.
sse3
Adds the SSE3 instruction set to SSE2 instruction set.
sse3a
Adds the AMD extended instructions including 3DNow! to the SSE3 instruction set.
ssse3
Supplements the pentium_pro, SSE, SSE2, and SSE3 instruction sets with the SSSE3 instruction set.
sse4_1
Supplements the pentium_pro, SSE, SSE2, SSE3, and SSSE3 instruction sets with the SSE4.1 instruction set.
sse4_2
Supplements the pentium_pro, SSE, SSE2, SSE3,SSSE3, and SSE4.1 instruction sets with the SSE4.2 instruction set.
amdsse4a
Uses the AMD SSE4a Instruction set.
aes
Uses Intel Advanced Encryption Standard instruction set.
avx
Uses Intel Advanced Vector Extensions instruction set.
avx_i
Uses Intel Advanced Vector Extensions instruction set with the RDRND, FSGSBASE and F16C instruction sets.
avx2
Uses Intel Advanced Vector Extensions 2 instruction set.

If any part of a program is compiled or linked on an x86 platform with —m64, then all parts of the program must be compiled with one of these options as well. For details on the various Intel instruction set architectures (SSE, SSE2, SSE3, SSSE3, and so on) refer to the Intel 64 and IA-32 Architectures Software Developer Manuals at http://www.intel.com.

See also Special x86 Notes and Binary Compatibility Verification.

B.2.86.4 Interactions

Although this option can be used alone, it is part of the expansion of the -xtarget option and may be used to override the –xarch value that is set by a specific -xtarget option. For example, -xtarget=ultra2 expands to -xarch=sparcvis -xchip=ultra2 -xcache=16/32/1:512/64/1. In the following command -xarch=generic overrides the -xarch=sparcvis that is set by the expansion of -xtarget=ultra2.

example% cc -xtarget=ultra2 -xarch=generic foo.c

B.2.86.5 Warnings

If you use this option with optimization, the appropriate choice can provide good performance of the executable on the specified architecture. An inappropriate choice, however, might result in serious degradation of performance or in a binary program that is not executable on the intended target platform.

If you compile and link in separate steps, make sure you specify the same value for -xarch in both steps.

B.2.87 -xautopar


Note -  This option does not enable OpenMP parallelization directives.

Enables automatic parallelization of loops. Does dependence analysis (analyze loops for inter-iteration data dependence) and loop restructuring. If optimization is not at -xO3 or higher, optimization is raised to -xO3 and a warning is issued.

Avoid-xautopar if you do your own thread management.

To achieve faster execution, this option requires a system with multiple hardware threads. Use the OMP_NUM_THREADS or PARALLEL environment variable to specify the number of threads you want to use. Refer to the OpenMP API User's Guide for information about these environment variables and their default values.

For best performance, the number of threads used to execute a parallel region should not exceed the number of hardware threads (or virtual processors) available on the machine. On Oracle Solaris systems, this number can be determined by using the psrinfo(1M) command. On Linux systems, this number can be determined by inspecting the file /proc/cpuinfo.

If you use-xautopar and compile and link in one step, then linking automatically includes the microtasking library (libmtsk.so) and the threads-safe C runtime library. If you use-xautopar and compile and link in separate steps, then you must also link with -xautopar. For a complete list of all compiler options that must be specified at both compile time and at link time, see Table A–2.

B.2.88 -xbinopt={prepare|off}

(SPARC) This option is now obsolete and will be removed in a future release of the compiler. See -xannotate[=yes|no]

Instructs the compiler to prepare the binary for later optimizations, transformations and analysis. This option may be used for building executables or shared objects. This option must be used with optimization level -xO1 or higher to be effective. There is a modest increase in size of the binary when built with this option.

If you compile in separate steps, -xbinopt must appear on both compile and link steps:

example% cc -c -xO1 -xbinopt=prepare a.c b.c
example% cc -o myprog -xbinopt=prepare a.o

If some source code is not available for compilation, this option may still be used to compile the remainder of the code. It should then be used in the link step that creates the final binary. In such a situation, only the code compiled with this option can be optimized, transformed or analyzed.

Compiling with -xbinopt=prepare and -g increases the size of the executable by including debugging information. The default is -xbinopt=off.

For more information, see the binopt(1) man page.

B.2.89 -xbuiltin[=(%all|%default|%none)]

Use the -xbuiltinoption to improve the optimization of code that calls standard library functions. Many standard library functions, such as the ones defined in math.h and stdio.h, are commonly used by various programs. The -xbuiltin option enables the compiler to substitute intrinsic functions or inline system functions where profitable for performance. See the er_src(1) man page for an explanation of how to read compiler commentary in object files to determine the functions for which the compiler actually makes a substitution.

Note that these substitutions can cause the setting of errno to become unreliable. If your program depends on the value of errno, avoid this option. See also Preserving the Value of errno.

-xbuiltin=%default only inlines functions that do not set errno. The value of errno is always correct at any optimization level, and can be checked reliably. With -xbuiltin=%default at -xO3 or lower, the compiler will determine which calls are profitable to inline, and not inline others. The -xbuiltin=%none option turns off all substitutions of library functions.

If you do not specify -xbuiltin, the default is -xbuiltin=%default when compiling with an optimization level -xO1 and higher, and -xbuiltin=%none at -xO0. If you specify -xbuiltin without an argument, the default is -xbuiltin=%all and the compiler substitutes intrinsics or inlines standard library functions much more aggressively.

If you compile with -fast, then -xbuiltin is set to %all.


Note -  -xbuiltin only inlines global functions defined in system header files, and not static functions defined by the user.

B.2.90 -xCC

When you specify -std=c89 and -xCC, the compiler accepts the C++-style comments. In particular, // can be used to indicate the start of a comment.

B.2.91 -xc99[=o]

The -xc99 option controls compiler recognition of the implemented features from the C99 standard (ISO/IEC 9899:1999, Programming Language - C).

The following table lists accepted values for o. Multiple values can be separated by commas.

Table B-17  -xc99 Flags
Flag
Meaning
lib
Enable the 1999 C standard library semantics of routines that appeared in both the 1990 and 1999 C standard. no_lib disables recognition of these semantics.
all
Turn on recognition of supported C99 language features and enable the 1999 C standard library semantics of routines that appear in both the 1990 and 1999 C standard.
none
Turn off recognition of C99 language features, and do not enable the 1999 C standard library semantics of routines that appeared in both the 1990 and 1999 C standard.

If you do not specify -xc99, the compiler defaults to -xc99=all,no_lib. If you specify -xc99 without any values, the option is set to-xc99=all.

The -xc99 flag cannot be used if the -std or -xlang flag has been specified.

B.2.92 -xcache[=c]

Defines cache properties for use by the optimizer . This option does not guarantee that any particular cache property is used.


Note -  Although this option can be used alone, it is part of the expansion of the –xtarget option; its primary use is to override a value supplied by the –xtarget option.

An optional property, [/ti], sets the number of threads that can share the cache. If you do not specify a value for t, the default is 1.

c must be one of the following:

  • generic

  • native

  • s1/l1/a1[/t1]

  • s1/l1/a1[/t1]:s2/l2/a2[/t2]

  • s1/l1/a1[/t1]:s2/l2/a2[/t2]:s3/l3/a3[/t3]

The s/l/a/t properties are defined as follows:

si

The size of the data cache at level i, in kilobytes

li

The line size of the data cache at level i, in bytes

ai

The associativity of the data cache at level i

ti

The number of hardware threads sharing the cache at level i

The following table lists the-xcache values.

Table B-18  -xcache Flags
Flag
Meaning
generic
This is the default value. It directs the compiler to use cache properties for good performance on most x86 and SPARC processors without major performance degradation on any of them.
With each new release, these best timing properties will be adjusted, if appropriate.
native
Set the parameters for the best performance on the host environment.
s1/l1/a1[/t1]
Define level 1 cache properties.
s1/l1/a1[/t1]:s2/l2/a2[/t2]
Define levels 1 and 2 cache properties.
s1/l1/a1[/t1]:s2/l2/a2[/t2]:s3/l3/a3[/t3]
Define levels 1, 2, and 3 cache properties.

Example:-xcache=16/32/4:1024/32/1 specifies the following:

  • Level 1 cache with:

    • 16K bytes

    • 32 bytes line size

    • Four–way associativity

  • Level 2 cache with:

    • 1024 bytes

    • 32 bytes line size

    • Direct mapping associativity

B.2.93 –xcg[89|92]

(SPARC) Obsolete. You should not use this option. Compiling with this option generates code that runs slower on current SPARC platforms. Use -O instead and take advantage of compiler defaults for -xarch, -xchip, and -xcache.

B.2.94 -xchar[=o]

The option is provided solely for the purpose of easing the migration of code from systems where the char type is defined as unsigned. Unless you are migrating from such a system, do not use this option. Only code that relies on the sign of a char type needs to be rewritten to explicitly specify signed or unsigned.

The following table lists the accepted values for o:

Table B-19  -xchar Flags
Flag
Meaning
signed
Treat character constants and variables declared as char as signed. This option affects the behavior of compiled code, but note the behavior of library routines.
s
Equivalent to signed
unsigned
Treat character constants and variables declared as char as unsigned. This option affects the behavior of compiled code, but not the behavior of library routines.
u
Equivalent to unsigned.

If you do not specify -xchar, the compiler assumes -xchar=s.

If you specify -xchar but do not specify a value, the compiler assumes -xchar=s.

The -xchar option changes the range of values for the type char only for code compiled with -xchar. This option does not change the range of values for type char in any system routine or header file. In particular, the value of CHAR_MAX and CHAR_MIN, as defined by limits.h, do not change when this option is specified. Therefore, CHAR_MAX and CHAR_MIN no longer represent the range of values encodable in a plain char.

If you use -xchar, be particularly careful when you compare a char against a predefined system macro because the value in the macro may be signed. This situation is most common for any routine that returns an error code that is accessed through a macro. Error codes are typically negative values so when you compare a char against the value from such a macro, the result is always false. A negative number can never be equal to any value of an unsigned type.

Do not use -xchar to compile routines for any interface exported through a library. The ABIs for all target platforms of Oracle Solaris Studio specify type char as signed, and system libraries behave accordingly. The effect of making char unsigned has not been extensively tested with system libraries. Instead of using this option, modify your code so that it does not depend on whether type char is signed or unsigned. The sign of type char varies among compilers and operating systems.

B.2.95 -xchar_byte_order[=o]

Produce an integer constant by placing the characters of a multicharacter character-constant in the specified byte order. Use one of the following values for o:

  • low: Places the characters of a multicharacter character-constant in low-to-high byte order.

  • high: Places the characters of a multicharacter character-constant in high-to-low byte order.

  • default: Places the characters of a multicharacter character-constant in an order determined by the compilation mode (-Xv). For more information, see Character Constants and -X[c|a|t|s].

B.2.96 -xcheck[=o[,o]]

Adds runtime checks for stack overflow and initializes local variables.

The following table lists values for o.

Table B-20  -xcheck Flags
Flag
Meaning
%none
Perform none of the -xcheck checks.
%all
Perform all of the -xcheck checks.
stkovf[action]
Generate code to detect stack overflow errors at runtime, optionally specifying an action to be taken when a stack overflow error is detected.
A stack overflow error occurs when a thread's stack pointer is set beyond the thread's allocated stack bounds. The error may not be detected if the new top of stack address is writable.
A stack overflow error is detected if a memory access violation occurs as a direct result of the error, raising an associated signal (usually SIGSEGV). The signal thus raised is said to be associated with the error.
If -xcheck=stkovf[action] is specified, the compiler generates code to detect stack overflow errors in cases involving stack frames larger than the system page size. The code includes a library call to force a memory access violation instead of setting the stack pointer to an invalid but potentially mapped address (see _stack_grow(3C)).
The optional action, if specified, must be either :detect or :diagnose.
If action is :detect, a detected stack overflow error is handled by executing the signal handler normally associated with the error.
If action is :diagnose, a detected stack overflow error is handled by catching the associated signal and calling stack_violation(3C) to diagnose the error. This is the default behavior if no action is specified.
If a memory access violation is diagnosed as a stack overflow error, the following message is printed to stderr:
ERROR: stack overflow detected: pc=<inst_addr>, sp=<sp_addr>
where <inst_addr> is the address of the instruction where the error was detected, and <sp_addr> is the value of the stack pointer at the time that the error was detected. After checking for stack overflow and printing the above message if appropriate, control passes to the signal handler normally associated with the error.
-xcheck=stkovf:detect adds a stack bounds check on entry to routines with stack frames larger than system page size (see _stack_grow(3C)). The relative cost of the additional bounds check should be negligible in most applications.
-xcheck=stkovf:diagnose adds a system call to thread creation (see sigaltstack(2)). The relative cost of the additional system call depends on how frequently the application creates and destroys new threads.
-xcheck=stkovf is supported only on Oracle Solaris. The C runtime library on Linux does not support stack overflow detection.
no%stkovf
Disable stack-overflow checking.
init_local
Initialize local variables.
no%init_local
Do not initialize local variables.

If you do not specify -xcheck, the compiler defaults to-xcheck=%none. If you specify -xcheck without any arguments, the compiler defaults to-xcheck=%all.

The -xcheck option does not accumulate on the command line. The compiler sets the flag in accordance with the last occurrence of the command. Thus, to enable both stack overflow diagnosis an local variable initialization, use the following option:

cc -xcheck=stkovf:diagnose,init_local ...

B.2.96.1 Initialization Values for -xcheck=init_local

With -xcheck=init_local, the compiler initializes local variables declared without an initializer to a predefined value as shown in the following table. (Note that these values might change and should not be relied upon.)

Basic Types
Table B-21  init_local Initialization for Basic Types
Type
Initialization Value
char, _Bool
0x85
short
0x8001
int, long, enum     (-m32)
0xff80002b
long    (-m64)
0xfff00031ff800033
long long
0xfff00031ff800033
pointer
0x00000001 (-m32)
0x0000000000000001 (-m64)
float, float _Imaginary
0xff800001
float _Complex
0xff80000fff800011
double
SPARC: 0xfff00003ff800005
x86: 0xfff00005ff800003
double _Imaginary
0xfff00013ff800015
long double, long double _Imaginary
SPARC: 0xffff0007ff800009 / 0xfff0000bff80000d
x86: 12 bytes (-m32): 0x80000009ff800005 / 0x0000ffff
x86: 16 bytes (-m64): 0x80000009ff800005 / 0x0000ffff00000000
double _Complex
0xfff00013ff800015 / 0xfff00017ff800019
long double _Complex
SPARC: 0xffff001bff80001d / 0xfff0001fff800021 / 0xffff0023ff800025 / 0xfff00027ff800029
x86: 12 bytes (-m32): 0x7fffb01bff80001d / 0x00007fff / 0x7fffb023ff800025 / 0x00007fff
x86: 16 bytes (-m64): 0x00007fff00080000 / 0x1b1d1f2100000000 / 0x00007fff00080000 / 0x2927252300000000

Local variables declared for use with the computed goto, which are simple void * pointers, will be initialized according to the description for pointers in the table.

The following local variable types are never initialized: const qualified, register, label numbers for computed gotos, local labels.

Initializing Structs, Unions, and Arrays

Fields in a struct that are basic types are initialized as described in the table, as is the first declared pointer or float field in a union, to maximize the likelihood that an uninitialized reference generates a visible error.

Array elements are also initialized as described in the table.

Nested struct, union, and array fields are initialized as described in the table except for the following cases: a struct containing bit-fields, a union without a pointer or float field, or an array of types that cannot be fully initialized. These exceptions will be initialized with the value used for local variables of type double.

B.2.97 -xchip[=c]

Specifies the target processor for use by the optimizer.

Although this option can be used alone, it is part of the expansion of the-xtarget option. Its primary use is to override a value supplied by the-xtarget option.

This option specifies timing properties by specifying the target processor. Some effects are:

  • The ordering of instructions, that is, scheduling

  • The way the compiler uses branches

  • The instructions to use in cases where semantically equivalent alternatives are available

The following table lists the -xchip values for c for SPARC platforms:

Table B-22  SPARC -xchip Flags
Flag
Meaning
generic
Use timing properties for good performance on most SPARC architectures.
This is the default value. It directs the compiler to use the best timing properties for good performance on most processors, without major performance degradation on any of them.
native
Sets the parameters for the best performance on the host environment.
sparc64vi
Optimize for the SPARC64 VI processor.
sparc64vii
Optimize for the SPARC64 VII processor.
sparc64viiplus
Optimize for the SPARC64 VII+ processor.
sparc64x
Optimize for the SPARC64 X processor.
sparc64xplus
Optimize for the SPARC64 X+ processor.
ultra
Uses timing properties of the UltraSPARC processors.
ultra2
Uses timing properties of the UltraSPARC II processors.
ultra2e
Uses timing properties of the UltraSPARC IIe processors.
ultra2i
Uses timing properties of the UltraSPARC IIi processors.
ultra3
Uses timing properties of the UltraSPARC III processors.
ultra3cu
Uses timing properties of the UltraSPARC III Cu processors.
ultra3i
Uses the timing properties of the UltraSPARC IIIi processors.
ultra4
Uses timing properties of the UltraSPARC IV processors.
ultra4plus
Uses the timing properties of the UltraSPARC IVplus processor.
ultraT1
Uses the timing properties of the UltraSPARC T1 processor.
ultraT2
Uses the timing properties of the UltraSPARC T2 processor.
ultraT2plus
Uses the timing properties of the UltraSPARC T2+ processor.
T3
Uses the timing properties of the SPARC T3 processor.
T4
Uses the timing properties of the SPARC T4 processor.
T5
Uses the timing properties of the SPARC T5 processor.
T7
Uses the timing properties of the SPARC T7 processor.
M5
Uses the timing properties of the SPARC M5 processor.
M6
Uses the timing properties of the SPARC M6 processor.
M7
Uses the timing properties of the SPARC M7 processor.

Note -  The following SPARC -xchip values are obsolete and may be removed in a future release: ultra, ultra2, ultra2e, ultra2i, ultra3, ultra3cu, ultra3i, ultra4, and ultra4plus.

The following table lists the -xchip values for the x86 platforms:

Table B-23  x86 -xchip Flags
Flag
Meaning
generic
Use timing properties for good performance on most x86 architectures.
This is the default value. It directs the compiler to use the best timing properties for good performance on most processors without major performance degradation on any of them.
native
Set the parameters for the best performance on the host environment.
core2
Optimize for the Intel Core2 processor.
nehalem
Optimize for the Intel Nehalem processor.
opteron
Optimize for the AMD Opteron processor.
penryn
Optimize for the Intel Penryn processor.
pentium
Uses timing properties of the x86 Pentium architecture
pentium_pro
Uses timing properties of the x86 Pentium Pro architecture
pentium3
Uses the timing properties of the x86 Pentium 3 architecture.
pentium4
Uses the timing properties of the x86 Pentium 4 architecture.
amdfam10
Optimize for the AMD AMDFAM10 processor.
sandybridge
Intel Sandy Bridge processor
ivybridge
Intel Ivy Bridge processor
haswell
Intel Haswell processor
westmere
Intel Westmere processor

B.2.98 -xcode[=v]

(SPARC) Specify code address space.


Note -  Build shared objects by specifying -xcode=pic13 or -xcode=pic32. While you can build workable shared objects with -m64 -xcode=abs64 they will be inefficient. Shared objects built with -m64, -xcode=abs32, or -m64, -xcode=abs44 will not work.

The following table lists the values for v.

Table B-24  The -xcode Flags
Value
Meaning
abs32
This is the default on 32-bit architectures. Generates 32-bit absolute addresses. Code + data + BSS size is limited to 2**32 bytes.
abs44
This is the default on 64-bit architectures. Generates 44-bit absolute addresses. Code + data + BSS size is limited to 2**44 bytes. Available only on 64–bit architectures.
abs64
Generates 64-bit absolute addresses. Available only on 64-bit architectures.
pic13
Generates position-independent code for use in shared libraries (small model). Equivalent to -Kpic. Permits references to at most 2**11 unique external symbols on 32-bit architectures, 2**10 on 64-bit architectures.
pic32
Generates position-independent code for use in shared libraries (large model). Equivalent to -KPIC. Permits references to at most 2**30 unique external symbols on 32-bit architectures, 2**29 on 64-bit architectures.

The default is -xcode=abs32 for 32–bit architectures. The default for 64–bit architectures is-xcode=abs44.

When building shared dynamic libraries, the default -xcode values of abs44 and abs32 will not work with 64–bit architectures. Specify -xcode=pic13 or -xcode=pic32 instead. Two nominal performance costs with -xcode=pic13 and -xcode=pic32 on SPARC are:.

  • A routine compiled with either -xcode=pic13 or -xcode=pic32 executes a few extra instructions upon entry to set a register to point at a table (_GLOBAL_OFFSET_TABLE_) used for accessing a shared library’s global or static variables.

  • Each access to a global or static variable involves an extra indirect memory reference through _GLOBAL_OFFSET_TABLE_. If the compilation includes -xcode=pic32, there are two additional instructions per global and static memory reference.

When considering these costs, remember that the use of -xcode=pic13 and -xcode=pic32 can significantly reduce system memory requirements due to the effect of library code sharing. Every page of code in a shared library compiled -xcode=pic13 or -xcode=pic32 can be shared by every process that uses the library. If a page of code in a shared library contains even a single non-pic (that is, absolute) memory reference, the page becomes nonsharable, and a copy of the page must be created each time a program using the library is executed.

The easiest way to tell whether a .o file has been compiled with -xcode=pic13 or -xcode=pic32 is by using the nm command:

% nm file.o | grep _GLOBAL_OFFSET_TABLE_ U _GLOBAL_OFFSET_TABLE_

A .o file containing position-independent code contains an unresolved external reference to _GLOBAL_OFFSET_TABLE_, as indicated by the letter U.

To determine whether to use -xcode=pic13 or -xcode=pic32, check the size of the Global Offset Table (GOT) by using elfdump -c looking for the section header sh_name: .got. The sh_size value is the size of the GOT. If the GOT is less than 8,192 bytes, specify -xcode=pic13. Otherwise specify -xcode=pic32.See the elfdump(1) man page for more information.

Follow these guidelines to determine how you should use -xcode:

  • If you are building an executable, do not use -xcode=pic13 or -xcode=pic32.

  • If you are building an archive library only for linking into executables, do not use -xcode=pic13 or -xcode=pic32.

  • If you are building a shared library, start with -xcode=pic13 and, once the GOT size exceeds 8,192 bytes, use -xcode=pic32.

  • If you are building an archive library for linking into shared libraries, use -xcode=pic32.

B.2.99 -xcrossfile

Obsolete, do not use. Use –xipo instead. -xcrossfile is an alias for —xipo=1.

B.2.100 -xcsi

Allows the C compiler to accept source code written in locales that do not conform to the ISO C source character code requirements. These locales include ja_JP.PCK.

The compiler translation phases required to handle such locales may result in significantly longer compilation times. You should only use this option when you compile source files that contain source characters from one of these locales.

The compiler does not recognize source code written in locales that do not conform to the ISO C source character code requirements unless you specify -xcsi.

B.2.101 -xdebugformat=[stabs|dwarf]

Specify -xdebugformat=dwarf if you maintain software which reads debugging information in the DWARF format. This option causes the compiler to generate debugging information by using the DWARF standard format and is the default.

Table B-25  The -xdebugformat Flags
Value
Meaning
stabs
-xdebugformat=stabs generates debugging information using the STABS standard format.
dwarf
-xdebugformat=dwarf generates debugging information using the DWARF standard format (default).

If you do not specify -xdebugformat, the compiler assumes -xdebugformat=dwarf. This option requires an argument.

This option affects the format of the data that is recorded with the -g option. Some small amount of debugging information is recorded even without -g, and the format of that information is also controlled with this option. Therefore, -xdebugformat has an effect even when -g is not used.

The dbx and Performance Analyzer software understand both STABS and DWARF format so using this option does not have any effect on the functionality of either tool.

See the dumpstabs(1) and dwarfdump(1) man pages for more information.

B.2.102 -xdebuginfo=a[,a...]

Control how much debugging and observability information is emitted.

The term tagtype refers to tagged types: structs, unions, enums, and classes.

The following list contains the possible values for suboptions a. The prefix no% applied to a suboption disables that suboption. The default is -xdebuginfo=%none. Specifying -xdebuginfo without a suboption is forbidden.

%none

No debugging information is generated. This is the default.

[no%]line

Emit line number and file information.

[no%]param

Emit location list info for parameters. Emit full type information for scalar values (for example, int, char *) and type names but not full definitions of tagtypes.

[no%]variable

Emit location list information for lexically global and local variables, including file and function statics but excluding class statics and externs. Emit full type information for scalar values such as int and char * and type names but not full definitions of tagtypes.

[no%]decl

Emit information for function and variable declarations, member functions, and static data members in class declarations.

[no%]tagtype

Emit full type definitions of tagtypes referenced from param and variable datasets, as well as template definitions.

[no%]macro

Emit macro information.

[no%]codetag

Emit DWARF codetags (also known as Stabs N_PATCH). This is information regarding bitfields, structure copy, and spills used by RTC and discover.

[no%]hwcpro

Generate information critical to hardware counter profiling. This information includes ldst_map, a mapping from ld/st instructions to the symbol table entry being referenced, and branch_target table of branch-target addresses used to verify that backtracking did not cross a branch-target. See -xhwcprof for more information.


Note -  ldst_map requires the presence of tagtype information. The driver will issue an error if this requirement is not met.

These are macros which expand to combinations of -xdebuginfo and other options as follows:

-g = -g2

-gnone =
        -xdebuginfo=%none
        -xglobalize=no
        -xpatchpadding=fix
        -xkeep_unref=no%funcs,no%vars

-g1 =
        -xdebuginfo=line,param,codetag
        -xglobalize=no
        -xpatchpadding=fix
        -xkeep_unref=no%funcs,no%vars

-g2 =
        -xdebuginfo=line,param,decl,variable,tagtype,codetag
        -xglobalize=yes
        -xpatchpadding=fix
        -xkeep_unref=funcs,vars

-g3 =

        -xdebuginfo=line,param,decl,variable,tagtype,codetag,macro
        -xglobalize=yes
        -xpatchpadding=fix
        -xkeep_unref=funcs,vars

B.2.103 -xdepend=[yes|no]

Analyzes loops for interiteration data dependencies and does loop restructuring, including loop interchange, loop fusion, and scalar replacement.

-xdepend defaults to -xdepend=on for all optimization levels -xO3 and above. Specifying an explicit setting of -xdepend overrides any default setting.

Specifying -xdepend without an argument is equivalent to -xdepend=yes.

Dependency analysis can help on single-processor systems. However, if you use -xdepend on single-processor systems, you should not also specify -xautopar because the -xdepend optimization will be done for a multiprocessor system.

B.2.104 -xdryrun

This option is a macro for -###.

B.2.105 -xdumpmacros[=value[,value...]]

Use this option when you want to see how macros are behaving in your program. This option provides information such as macro defines, undefines, and instances of usage. It prints output to the standard error (stderr), based on the order in which macros are processed. The -xdumpmacros option is in effect through the end of the file or until it is overridden by the dumpmacros or end_dumpmacros pragma. See dumpmacros.

The following table lists the valid arguments for value. The prefix no% disables the associated value.

Table B-26  -xdumpmacros Values
Value
Meaning
[no%]defs
Print all macro defines.
[no%]undefs
Print all macro undefines.
[no%]use
Print information about macros used.
[no%]loc
Print location (path name and line number) also for defs, undefs, and use.
[no%]conds
Print use information for macros used in conditional directives.
[no%]sys
Print all macros defines, undefines, and use information for macros in system header files.
%all
Sets the option to -xdumpmacros=defs,undefs,use,loc,conds,sys. A good way to use this argument is in conjunction with the [no%] form of the other arguments. For example, -xdumpmacros=%all,no%sys would exclude system header macros from the output but still provide information for all other macros.
%none
Do not print any macro information.

The option values accumulate, so specifying -xdumpmacros=sys -xdumpmacros=undefs has the same effect as -xdumpmacros=undefs,sys.


Note -  The sub-options loc, conds, and sys are qualifiers for defs, undefs and use options. By themselves, loc, conds, and sys have no effect. For example, -xdumpmacros=loc,conds,sys has no effect.

Specifying -xdumpmacros without any arguments defaults to -xdumpmacros=defs,undefs,sys. The default when not specifying -xdumpmacros is -xdumpmacros=%none.

If you use the option -xdumpmacros=use,no%loc, the name of each macro that is used is printed only once. However, if you want more detail, use the option -xdumpmacros=use,loc so the location and macro name is printed every time a macro is used.

Consider the following file t.c:

example% cat t.c
#ifdef FOO
#undef FOO
#define COMPUTE(a, b) a+b
#else
#define COMPUTE(a,b) a-b
#endif
int n = COMPUTE(5,2);
int j = COMPUTE(7,1);
#if COMPUTE(8,3) + NN + MM
int k = 0;
#endif

The following examples show the output for file t.c based on the defs, undefs, sys, and loc arguments.

example% cc -c -xdumpmacros -DFOO t.c
#define __SunOS_5_9 1
#define __SUNPRO_C 0x512
#define unix 1
#define sun 1
#define sparc 1
#define __sparc 1
#define __unix 1
#define __sun 1
#define __BUILTIN_VA_ARG_INCR 1
#define __SVR4 1
#define __SUNPRO_CC_COMPAT 5
#define __SUN_PREFETCH 1
#define FOO 1
#undef FOO
#define COMPUTE(a, b) a + b

example% cc -c -xdumpmacros=defs,undefs,loc -DFOO -UBAR t.c
command line: #define __SunOS_5_9 1
command line: #define __SUNPRO_C 0x512
command line: #define unix 1
command line: #define sun 1
command line: #define sparc 1
command line: #define __sparc 1
command line: #define __unix 1
command line: #define __sun 1
command line: #define __BUILTIN_VA_ARG_INCR 1
command line: #define __SVR4 1
command line: #define __SUN_PREFETCH 1
command line: #define FOO 1
command line: #undef BAR
t.c, line 2: #undef FOO
t.c, line 3: #define COMPUTE(a, b) a + b

The following examples show how the use, loc, and conds arguments report macro behavior in file t.c:

example% cc -c -xdumpmacros=use t.c
used macro COMPUTE

example% cc -c -xdumpmacros=use,loc t.c
t.c, line 7: used macro COMPUTE
t.c, line 8: used macro COMPUTE

example% cc -c -xdumpmacros=use,conds t.c
used macro FOO
used macro COMPUTE
used macro NN
used macro MM

example% cc -c -xdumpmacros=use,conds,loc t.c
t.c, line 1: used macro FOO
t.c, line 7: used macro COMPUTE
t.c, line 8: used macro COMPUTE
t.c, line 9: used macro COMPUTE
t.c, line 9: used macro NN
t.c, line 9: used macro MM

Consider the file y.c:

example% cat y.c
#define X 1
#define Y X
#define Z Y
int a = Z;

The following example shows the output from -xdumpmacros=use,loc based on the macros in y.c:

example% cc -c -xdumpmacros=use,loc y.c
y.c, line 4: used macro Z
y.c, line 4: used macro Y
y.c, line 4: used macro X

Pragma dumpmacros/end_dumpmacros overrides the scope of the -xdumpmacros command-line option.

B.2.106 -xe

Performs syntax and semantic checking on the source file but does not produce any object or executable code.

B.2.107 –xF[=v[,v...]]

Enables optimal reordering of functions and variables by the linker.

This option instructs the compiler to place functions or data variables into separate section fragments, which enables the linker, using directions in a mapfile specified by the linker’s -M option, to reorder these sections to optimize program performance. This optimization is most effective when page-fault time constitutes a significant fraction of program runtime.

Reordering of variables can help solve the following problems that negatively affect runtime performance:

  • Cache and page contention caused by unrelated variables that are near each other in memory.

  • Unnecessarily large work-set size as a result of related variables that are not near each other in memory.

  • Unnecessarily large work-set size as a result of unused copies of weak variables that decrease the effective data density.

Reordering variables and functions for optimal performance requires the following operations:

  1. Compiling and linking with -xF.

  2. Following the instructions about generating mapfiles for functions or for data in the Oracle Solaris Studio Performance Analyzer manual and Oracle Solaris Linker and Libraries Guide.

  3. Relinking with the new mapfile by using the linker’s -M option.

  4. Re-executing under the Analyzer to verify improvement.

B.2.107.1 Values

The following table lists the values for v.

Table B-27  –xF Values
Value
Meaning
func
Fragment functions into separate sections.
gbldata
Fragment global data (variables with external linkage) into separate sections.
lcldata
Fragment local data (variables with internal linkage) into separate sections.
%all
Fragment functions, global data, and local data.
%none
Fragment nothing.

Precede the values (other than %all and %none) with no% to disable the suboption. For example no%func.

If you do not specify -xF, the default is -xF=%none. If you specify -xF without any arguments, the default is -xF=%none,func.

Using -xF=lcldata inhibits some address calculation optimizations, so you should use this flag only when it is experimentally justified.

See the analyzer(1), and ld(1) man pages.

B.2.108 -xglobalize[={yes|no}]

Control globalization of file static variables but not functions.

Globalization is a technique needed by fix and continue and interprocedural optimization whereby file static symbols are promoted to global while a prefix is added to the name to keep identically named symbols distinct.

The default is -xglobalize=no. Specifying -xglobalize is equivalent to specifying -xglobalize=yes.

B.2.108.1 Interactions

See -xpatchpadding.

-xipo requires globalization as well and will override -xglobalize.

B.2.109 -xhelp=flags

Displays online help information.

-xhelp=flags displays a summary of the compiler options.

B.2.110 -xhwcprof

(SPARC) Enables compiler support for hardware counter-based profiling.

When -xhwcprof is enabled, the compiler generates information that helps tools associate profiled load and store instructions with the data-types and structure members (in conjunction with symbolic information produced with -g to which they refer. It associates profile data with the data space of the target rather than the instruction space. It provides insight into behavior that is not easily obtained from only instruction profiling.

You can compile a specified set of object files with -xhwcprof. However, -xhwcprof is most useful when applied to all object files in the application, identifying and correlating all memory references distributed in the application’s object files.

If you are compiling and linking in separate steps, use -xhwcprof at link time as well. Future extensions to -xhwcprof might require its use at link time. For a complete list of all compiler options that must be specified at both compile time and at link time, see Table A–2.

An instance of -xhwcprof=enable or -xhwcprof=disable overrides all previous instances of -xhwcprof in the same command line.

-xhwcprof is disabled by default. Specifying -xhwcprof without any arguments is the equivalent to -xhwcprof=enable.

-xhwcprof requires that optimization be enabled and that the debug data format be set to DWARF (-xdebugformat=dwarf), which is the default with current Oracle Solaris Studio compilers. The occurrence of -xhwcprof and -xdebugformat=stabs on the same command line is not permitted.

-xhwcprof uses -xdebuginfo to automatically enable the minimum amount of debugging information it needs, so -g is not required.

The combination of -xhwcprof and -g increases compiler temporary file storage requirements by more than the sum of the increases due to -xhwcprof and -g specified alone.

-xhwcprof is implemented as a macro that expands to various other, more primitive, options as follows:

-xhwcprof
        -xdebuginfo=hwcprof,tagtype,line
-xhwcprof=enable
        -xdebuginfo=hwcprof,tagtype,line
-xhwcprof=disable
        -xdebuginfo=no%hwcprof,no%tagtype,no%line

The following command compiles example.c and specifies support for hardware counter profiling and symbolic analysis of data types and structure members using DWARF symbols:

example% cc -c -O -xhwcprof -g -xdebugformat=dwarf example.c

For more information on hardware counter-based profiling, see the Oracle Solaris Studio Performance Analyzer manual.

B.2.111 -xinline=list

The format of the list for -xinline is as follows: [{%auto,func_name,no%func_name}[,{%auto,func_name,no%func_name}]...]

-xinline tries to inline only those functions specified in the optional list. The list is either empty, or contains a comma-separated list of func_name, no%func_name, or %auto, where func_name is a function name. -xinline only has an effect at –xO3 or higher.

Table B-28  -xinline Flags
Flag
Meaning
%auto
Specifies that the compiler is to attempt to automatically inline all functions in the source file. %auto takes effect only at -xO4 or higher optimization levels. %auto is silently ignored at -xO3 or lower optimization levels.
func_name
Specifies that the compiler is to attempt to inline the named function.
no%func_name
Specifies that the compiler is not to inline the named function.

The list of values accumulates from left to right. For a specification of -xinline=%auto,no%foo the compiler attempts to inline all functions except foo. For a specification of -xinline=%bar,%myfunc,no%bar the compiler only tries to inline myfunc.

When you compile with optimization set at -xO4 or above, the compiler normally tries to inline all references to functions defined in the source file. You can restrict the set of functions the compiler attempts to inline by specifying the -xinline option. Specifying only -xinline= without naming any functions or %auto indicates that none of the routines in the source files are to be inlined. If you specify func_name and no%func_name without specifying %auto, the compiler only attempts to inline those functions specified in the list. If %auto is specified in the list of values with the -xinline option at optimization level set at -xO4 or above, the compiler attempts to inline all functions that are not explicitly excluded by no%func_name.

A function is not inlined if any of the following conditions apply. No warning is issued.

  • Optimization is less than -xO3.

  • The routine cannot be found.

  • Inlining the routine does not look practicable to the optimizer.

  • The source for the routine is not in the file being compiled (however, see -xipo).

If you specify multiple -xinline options on the command line, they do not accumulate. The last -xinline on the command line specifies the functions that the compiler attempts to inline.

See also -xldscope.

B.2.112 –xinline_param=a[,a[,a]...]

Use this option to manually change the heuristics used by the compiler for deciding when to inline a function call.

This option only has an effect at -O3 or higher. The following sub-options have an effect only at -O4 or higher when automatic inlining is on.

In the following sub-options n must be a positive integer; a can be one of the following:

Table B-29  -xinline_param Sub-options
Sub-option
Meaning
default
Set the values of all the sub-options to their default values.
max_inst_hard[:n]
Automatic inlining only considers functions smaller than n pseudo instructions (counted in compiler's internal representation) as possible inline candidates.
Under no circumstances will a function larger than this be considered for inlining.
max_inst_soft[:n]
Set inlined function's size limit to n pseudo instructions (counted in compiler's internal representation).
Functions of greater size than this may sometimes be inlined.
When interacting with max_inst_hard, the value of max_inst_soft should be equal to or smaller than the value of max_inst_hard, i.e, max_inst_soft <= max_inst_hard.
In general, the compiler's automatic inliner only inlines calls whose called function's size is smaller than the value of max_inst_soft. In some cases a function may be inlined when its size is larger than the value of max_inst_soft but smaller than that of max_inst_hard. An example of this would be if the parameters passed into a function were constants.
When deciding whether to change the value of max_inst_hard or max_inst_soft for inlining one specific call site to a function, use -xinline_report=2 to report detailed inlining message and follow the suggestion in the inlining message.
max_function_inst[:n]
Allow functions to increase due to automatic inlining by up to n pseudo instructions (counted in compiler's internal representation).
max_growth[:n]
The automatic inliner is allowed to increase the size of the program by up to n% where the size is measured in pseudo instructions.
min_counter[:n]
The minimum call site frequency counter as measured by profiling feedback (-xprofile) in order to consider a function for automatic inlining.
This option is valid only when the application is compiled with profiling feedback (-xprofile=use).
level[:n]
Use this suboption to control the degree of automatic inlining that is applied. The compiler will inline more functions with higher settings for -xinline_param=level.
n must be one of 1, 2, or 3.
The default value of n is 2 when this option is not specified, or when the options is specified without :n.
Specify the level of automatic inline:
level:1 basic inlining level:2 medium inlining (default) level:3 aggressive inlining
The level decides the specified values for the combination of the following inlining parameters:
max_growth + max_function_inst + max_inst + max_inst_call
When level = 1, all the parameters are half the values of the default.
When level = 2, all the parameters are the default value.
When level = 3, all the parameters are double the values of the default.
max_recursive_depth[:n]
When a function calls itself either directly or indirectly, it is said to be making a recursive call.
This suboption allows a recursive call to be automatically inlined up to n levels.
max_recursive_inst[:n]
Specifies the maximum number of pseudo instructions (counted in compiler's internal representation) the caller of a recursive function can grow to by performing automatic recursive inlining.
When interactions between max_recursive_inst and max_recursive_depth occur, recursive function calls will be inlined until either the max_recursive_depth number of recursive calls, or until the size of the function being inlined into exceeds max_recursive_inst. The settings of these two parameters control the degree of inlining of small recursive functions.

If -xinline_param=default is specified, the compiler will set all the values of the subopitons to the default values.

If the option is not specified, the default is -xinline_param=default.

The list of values and options accumulate from left to right. So for a specification of -xinline_param=max_inst_hard:30,..,max_inst_hard:50, the value max_inst_hard:50 will be passed to the compiler.

If multiple -xinline_param options are specified on the command line, the list of sub-options likewise accumulate from left to right. For example, the effect of

 -xinline_param=max_inst_hard:50,min_counter:70 ...
   -xinline_param=max_growth:100,max_inst_hard:100

will be the same as that of

-xinline_param=max_inst_hard:100,min_counter:70,max_growth:100

B.2.113 –xinline_report[=n]

This option generates a report written to standard output on the inlining of functions by the compiler. The type of report depends on the value of n, which must be 0, 1, or 2.

0

No report is generated.

1

A summary report of default values of inlining parameters is generated.

2

A detailed report of inlining messages is generated, showing which callsites are inlined and which are not, with a short reason for not inlining a callsite. In some cases, this report will include suggested values for -xinline_param that can be used to inline a callsite that is not inlined.

When -xinline_report is not specified, the default value for n is 0. When -xinline_report is specified without =n, the default value is 1.

When -xlinkopt is present, the inlining messages about the callsites that are not inlined might not be accurate.

B.2.114 –xinstrument=[no%]datarace

Specify this option to compile and instrument your program for analysis by the Thread Analyzer. For more information on the Thread Analyzer, see the tha(1) man page for details.

You can then use the Performance Analyzer to run the instrumented program with collect –r races to create a data-race-detection experiment. If you run the instrumented code stand-alone, it runs more slowly.

You can specify –xinstrument=no%datarace to turn off preparation of source code for the thread analyzer. This is the default.

You must specify –xinstrument= with an argument.

If you compile and link in separate steps, you must specify –xinstrument=datarace in both the compilation and linking steps.

This option defines the preprocessor token __THA_NOTIFY. You can specify #ifdef __THA_NOTIFY to guard calls to libtha(3) routines.

This option also sets –g.

B.2.115 -xipo[=a]

Replace a with 0, 1, or 2. -xipo without any arguments is equivalent -xipo=1. -xipo=0 is the default setting and disables -xipo. With -xipo=1, the compiler performs inlining across all source files.

With -xipo=2, the compiler performs interprocedural aliasing analysis as well as optimizations of memory allocation and layout to improve cache performance.

The compiler performs partial-program optimizations by invoking an interprocedural analysis component. It performs optimizations across all object files in the link step, and is not limited to just the source files of the compile command. However, whole-program optimizations performed with -xipo do not include assembly (.s) source files.

You must specify -xipo both at compile time and at link time. For a complete list of all compiler options that must be specified at both compile time and at link time, see Table A–2.

The -xipo option generates significantly larger object files due to the additional information needed to perform optimizations across files. However, this additional information does not become part of the final executable binary file. Any increase in the size of the executable program is due to the additional optimizations performed. The object files created in the compilation steps have additional analysis information compiled within them to permit crossfile optimizations to take place at the link step.

If you have .o files compiled with the –xipo option from different compiler versions, mixing these files can result in failure with an error message about "IR version mismatch". When using the –xipo option, all the files should be compiled with the same version of the compiler.

-xipo is particularly useful when compiling and linking large multifile applications. Object files compiled with this flag have analysis information compiled within them that enables interprocedural analysis across source and precompiled program files.

Analysis and optimization is limited to the object files compiled with -xipo, and does not extend to object files or libraries.

-xipo is multiphased, so you need to specify -xipo for each step if you compile and link in separate steps.

Other important information about -xipo:

  • It requires an optimization level of at least -xO4.

  • Objects that are compiled without -xipo can be linked freely with objects that are compiled with -xipo.

B.2.115.1 -xipo Examples

In this example, compilation and linking occur in a single step:

cc -xipo -xO4 -o prog part1.c part2.c part3.c

The optimizer performs crossfile inlining across all three source files. This process is done in the final link step, so the compilation of the source files need not all take place in a single compilation. It could take place over a number of separate compilations, each specifying -xipo.

In this example, compilation and linking occur in separate steps:

cc -xipo -xO4 -c part1.c part2.c
cc -xipo -xO4 -c part3.c
cc -xipo -xO4 -o prog part1.o part2.o part3.o

A restriction is that libraries, even if compiled with -xipo, do not participate in crossfile interprocedural analysis, as shown in the following example:

cc -xipo -xO4 one.c two.c three.c
ar -r mylib.a one.o two.o three.o
...
cc -xipo -xO4 -o myprog main.c four.c mylib.a

In this example, interprocedural optimizations are performed between one.c, two.c and three.c, and between main.c and four.c, but not between main.c or four.c and the routines on mylib.a. (The first compilation might generate warnings about undefined symbols, but the interprocedural optimizations are performed because it is a compile and link step.)

B.2.115.2 When Not To Use -xipo=2 Interprocedural Analysis

The compiler tries to perform whole-program analysis and optimizations as it works with the set of object files in the link step. The compiler makes the following two assumptions for any function (or subroutine) foo() defined in this set of object files:

  • foo() is not called explicitly by another routine that is defined outside this set of object files at runtime.

  • The calls to foo() from any routine in the set of object files are not interposed upon by a different version of foo() defined outside this set of object files.

Do not compile with either -xipo=1 or -xipo=2 if assumption 2 is not true.

As an example, consider interposing on the function malloc() with your own version and compiling with -xipo=2. Consequently, all the functions in any library that reference malloc() that are linked with your code have to be compiled with -xipo=2 also and their object files need to participate in the link step. Because this process might not be possible for system libraries, do not compile your version of malloc() with -xipo=2.

As another example, suppose that you build a shared library with two external calls, foo() and bar() inside two different source files. Furthermore, suppose that bar() calls foo(). If foo() could be interposed at runtime, then do not compile the source file for foo() or for bar() with -xipo=1 or -xipo=2. Otherwise, foo() could be inlined into bar(), which could cause incorrect results.

B.2.116 -xipo_archive=[a]

The -xipo_archive option enables the compiler to optimize object files that are passed to the linker with object files that were compiled with -xipo and that reside in the archive library (.a) before producing an executable. Any object files contained in the library that were optimized during the compilation are replaced with their optimized version.

The following table lists the values for a.

Table B-30  -xipo_archive Flags
Value
Meaning
writeback
The compiler optimizes object files passed to the linker with object files compiled with -xipo that reside in the archive library (.a) before producing an executable. Any object files contained in the library that were optimized during the compilation are replaced with an optimized version.
For parallel links that use a common set of archive libraries, each link should create its own copy of archive libraries to be optimized before linking.
readonly
The compiler optimizes object files passed to the linker with object files compiled with -xipo that reside in the archive library (.a) before producing an executable.
The option –xipo_archive=readonly enables cross-module inlining and interprocedural data flow analysis of object files in an archive library specified at link time. However, it does not enable cross-module optimization of the archive library's code except for code that has been inserted into other modules by cross-module inlining.
To apply cross-module optimization to code within an archive library, –xipo_archive=writeback is required. Note that this option modifies the contents of the archive library from which the code was extracted.
none
This is the default. There is no processing of archive files. The compiler does not apply cross-module inlining or other cross-module optimizations to object files compiled using –xipo and extracted from an archive library at link time. To do that, both –xipo and either –xipo_archive=readonly or –xipo_archive=writeback must be specified at link time.

If you do not specify a setting for -xipo_archive, the compiler sets it to -xipo_archive=none.

You must specify –xipo_archive= with a value.

B.2.117 -xipo_build=[yes|no]

Building -xipo without -xipo_build involves two passes through the compiler—once when producing the object files, and then again later at link time when performing the cross file optimization. Setting -xipo_build reduces compile time by avoiding optimizations during the initial pass and optimizing only at link time. Optimization is not needed for the object files, as with -xipo it will be performed at link time. If unoptimized object files built with -xipo_build are linked without including -xipo to perform optimization, the application will fail to link with an unresolved symbol error.

B.2.117.1 -xipo_build Examples

The following example performs a fast build of .o files, followed by crossfile optimization at link time:

% cc -O -xipo -xipo_build -o code1.o -c code1.c
% cc -O -xipo -xipo_build -o code2.o -c code2.c
% cc -O -xipo -o a.out code1.o code2.o

The -xipo_build will turn off -O when creating the .o files, to build these quickly. Full -O optimization will be performed at link time as part of -xipo crossfile optimization.

The following example links without using -xipo.

% cc -O -o a.out code1.o code2.o

If either code1.o or code2.o were generated with -xipo_build, the result will be a link-time failure indicating the symbol __unoptimized_object_file is unresolved.

When building .o files separately, the default behavior is -xipo_build=no. However, when the executable or library is built in a single pass from source files, -xipo_build will be implicitly enabled. For example:

% cc -fast -xipo a.c b.c c.c

will implicitly enable -xipo_build=yes for the first passes that generate a.o, b.o, and c.o. Include the option -xipo_build=no to disable this behavior.

B.2.118 -xivdep[=p]

Disable or set interpretation of #pragma ivdep pragmas (ignore vector dependencies).

The ivdep pragmas tell a compiler to ignore some or all loop-carried dependences on array references that it finds in a loop for purposes of optimization. This enables a compiler to perform various loop optimizations such as microvectorization, distribution, software pipelining, and so on., which would not be otherwise possible. It is used in cases where the user knows either that the dependences do not matter or that they never occur in practice.

The interpretation of #pragma ivdep directives depend upon the value of the —xivdep option.

The following list gives the values for p and their meaning.

loop

ignore assumed loop-carried vector dependences

loop_any

ignore all loop-carried vector dependences

back

ignore assumed backward loop-carried vector dependences

back_any

ignore all backward loop-carried vector dependences

none

do not ignore any dependences (disables ivdep pragmas)

These interpretations are provided for compatibility with other vendor's interpretations of the ivdep pragma.

B.2.119 -xjobs{=n|auto}

Compile with multiple processes. If this flag is not specified, the default behavior is -xjobs=auto.

Specify the -xjobs option to set how many processes the compiler creates to complete its work. This option can reduce the build time on a multi-cpu machine. Currently, -xjobs works only with the -xipo option. When you specify -xjobs=n, the interprocedural optimizer uses n as the maximum number of code generator instances it can invoke to compile different files.

Generally, a safe value for n is 1.5 multiplied by the number of available processors. Using a value that is many times the number of available processors can degrade performance because of context switching overheads among spawned jobs. Also, using a very high number can exhaust the limits of system resources such as swap space.

When -xjobs=auto is specified, the compiler will automatically choose the appropriate number of parallel jobs.

You must always specify -xjobs with a value. Otherwise, an error diagnostic is issued and compilation aborts.

If -xjobs is not specified, the default behavior is -xjobs=auto. This can be overridden by adding -xjobs=n to the command line. Multiple instances of -xjobs on the command line override each other until the right-most instance is reached.

B.2.119.1 -xjobs Examples

The following example links with up to three parallel processes for -xipo:

% cc -xipo -xO4 -xjobs=3 t1.o t2.o t3.o

The following example links serially with a single process for -xipo:

% cc -xipo -xO4 -xjobs=1 t1.o t2.o t3.o

The following example links in parallel, with the compiler choosing the number of jobs for -xipo:

% cc -xipo -xO4  t1.o t2.o t3.o

Note that this is exactly the same behavior as when explicitly specifying -xjobs=auto:

% cc -xipo -xO4 -xjobs=auto t1.o t2.o t3.o

B.2.120 -xkeep_unref[={[no%]funcs,[no%]vars}]

Keep definitions of unreferenced functions and variables. The no% prefix allows the compiler to potentially remove the definitions.

The default is no%funcs,no%vars. Specifying -xkeep_unref is equivalent to specifying -xkeep_unref=funcs,vars, meaning that -keep_unref keeps everything.

B.2.121 -xkeepframe[=[%all,%none,name,no%name]]

Prohibit stack related optimizations for the named functions (name).

%all

Prohibit stack related optimizations for all the code.

%none

Allow stack related optimizations for all the code.

This option is accumulative and can appear multiple times on the command line. For example, —xkeepframe=%all —xkeepframe=no%func1 indicates that the stack frame should be kept for all functions except func1. Also, —xkeepframe overrides —xregs=frameptr. For example, —xkeepframe=%all —xregs=frameptr indicates that the stack should be kept for all functions, but the optimizations for —xregs=frameptr would be ignored.

If not specified on the command line, the compiler assumes -xkeepframe=%none as the default. If specified but without a value, the compiler assumes -xkeepframe=%all

B.2.122 -xlang=language

The -xlang flag can be used to override the default libc behavior as specified by the -std flag. language must be one of the following:

c89

Specify runtime library behavior of libc to be in conformance with the C90 standard.

c99

Specify runtime library behavior of libc be in conformance with the C99 standard.

c11

Equivalent to c99. The runtime library behavior of libc for c99 and c11 are identical.

When -xlang is not specified, the default value is c99 when -std=c99 has been specified and c11 when -std=c11 has been specified. Otherwise the default value is c89.

The -Xc, -Xa, -Xt, -Xs, and -xc99 flags cannot be used if -xlang has been specified. Doing so will result in an error being issued by the compiler.

If you compile and link in separate steps you must use the same values for -xlang in both steps.

To determine which driver to use for mixed-language linking , use the following language hierarchy:

C++

Use the CC command. See the C++ Uder's Guide for details.

Fortran 95 (or Fortran 90)

Use the f95 command. See the Fortran User's Guide for details.

Fortran 77

Use f95 -xlang=f77. See the Fortran User's Guide for details.

C

Use the cc command.

B.2.123 -xldscope={v}

Specify the -xldscope option to change the default linker scoping for the definition of extern symbols. Changing the default can result in faster and safer shared libraries because the implementation is better hidden.

v must be one of the following:

Table B-31  -xldscope Flags
Flag
Meaning
global
Global linker scoping is the least restrictive linker scoping. All references to the symbol bind to the definition in the first dynamic module that defines the symbol. This linker scoping is the current linker scoping for extern symbols.
symbolic
Symbolic linker scoping is more restrictive than global linker scoping. All references to the symbol from within the dynamic module being linked bind to the symbol defined within the module. Outside of the module, the symbol appears as though it were global. This linker scoping corresponds to the linker option -Bsymbolic. See theld(1) man page for more information about the linker.
hidden
Hidden linker scoping is more restrictive than symbolic and global linker scoping. All references within a dynamic module bind to a definition within that module. The symbol will not be visible outside of the module.

If you do not specify -xldscope, the compiler assumes -xldscope=global. The compiler issues an error if you specify -xldscope without an argument. Multiple instances of this option on the command line override each other until the rightmost instance is reached.

If you intend to allow a client to override a function in a library, you must be sure that the function is not generated inline during the library build. The compiler inlines a function in the following situations:

  • You specify the function name with -xinline.

  • You compile at -xO4 or higher, in which case inlining can happen automatically.

  • You use the inline specifier.

  • You use the inline pragma.

  • You use cross-file optimization.

For example, suppose library ABC has a default allocator function that can be used by library clients, and is also used internally in the library:

void* ABC_allocator(size_t size) { return malloc(size); }

If you build the library at -xO4 or higher, the compiler inlines calls to ABC_allocator that occur in library components. If a library user attempts to replace ABC_allocator with a customized version, the replacement will not occur in library components that called ABC_allocator. The final program will include different versions of the function.

Library functions declared with the __hidden or __symbolic specifiers can be generated inline when building the library. These functions are not supposed to be overridden by users. For more information, see Linker Scoping Specifiers.

Library functions declared with the __global specifier should not be declared inline, and should be protected from inlining by use of the -xinline compiler option.

See also -xinline, -xO, -xipo, #pragma inline.

B.2.124 -xlibmieee

Forces IEEE 754 style return values for math routines in exceptional cases. In such cases, no exception message is printed, and you should not rely on errno.

B.2.125 -xlibmil

Inlines some library routines for faster execution. This option selects the appropriate assembly language inline templates for the floating-point option and platform for your system.

-xlibmil inlines a function regardless of any specification of the function as part of the -xinline flag.

However, these substitutions can cause the setting of errno to become unreliable. If your program depends on the value of errno, avoid this option. See also Preserving the Value of errno.

B.2.126 -xlibmopt

Enables the compiler to use a library of optimized math routines. You must use default rounding mode by specifying -fround=nearest when you use this option.

The math routine library is optimized for performance and usually generates faster code. The results may be slightly different from those produced by the normal math library. If so, they usually differ in the last bit.

Note that these substitutions can cause the setting of errno to become unreliable. If your program depends on the value of errno, avoid this option. For more information, see Preserving the Value of errno.

The order on the command line for this library option is not significant.

This option is set by the -fast option.

See also -fast and -xnolibmopt.

B.2.127 -xlic_lib=sunperf

(Obsolete) Use -library=sunperf to link with the Sun Performance Library.

B.2.128 -xlicinfo

This option is silently ignored by the compiler.

B.2.129 -xlinkopt[=level]

Instructs the compiler to perform link-time optimizations on relocatable object files. These optimizations are performed at link time by analyzing the object binary code. The object files are not rewritten but the resulting executable code might differ from the original object codes.

You must use -xlinkopt on at least some of the compilation commands for -xlinkopt to be useful at link time. The optimizer can still perform some limited optimizations on object binaries that are not compiled with -xlinkopt.

-xlinkopt optimizes code coming from static libraries that appear on the compiler command line, but does not optimize code coming from shared (dynamic) libraries that appear on the command line. You can also use -xlinkopt when you build shared libraries (compiling with -G ).

level sets the level of optimizations performed, and must be 0, 1, or 2. The optimization levels are listed in the following table:

Table B-32  -xlinkopt Flags
Flag
Meaning
0
The post-optimizer is disabled. (This is the default.)
1
Perform optimizations based on control flow analysis, including instruction cache coloring and branch optimizations, at link time.
2
Perform additional data flow analysis, including dead-code elimination and address computation simplification, at link time.

If you compile in separate steps, -xlinkopt must appear on both compile and link steps.

example% cc -c -xlinkopt a.c b.c
example% cc -o myprog -xlinkopt=2 a.o

For a complete list of all compiler options that must be specified at both compile time and at link time, see Table A–2.

Note that the level parameter is only used when the compiler is linking. In the example, the post- optimization level used is 2 even though the object binaries were compiled with an implied level of 1.

Specifying -xlinkopt without a level parameter implies -xlinkopt=1.

The -xlinkopt option requires profile feedback (-xprofile) in order to optimize the program. Profiling reveals the most- and least-used parts of the code, which enables the optimizer to focus its effort accordingly. Link-time optimization is particularly important with large applications where optimal placement of code can substantially reduce instruction cache misses. Additionally, -xlinkopt is most effective when used to compile the whole program. Use this option as follows:

example% cc -o progt -xO5 -xprofile=collect:prog file.c
example% progt
example% cc -o prog -xO5 -xprofile=use:prog -xlinkopt file.c

For details about using profile feedback, see –xprofile=p.

Do not use the -zcombreloc linker option when you compile with -xlinkopt.

Note that compiling with this option increases link time slightly. Object file sizes also increase, but the size of the executable remains the same. Compiling with -xlinkopt and -g increases the size of the executable by including debugging information.

B.2.130 -xloopinfo

Shows which loops are parallelized. Provides a brief reason for not parallelizing a loop. The -xloopinfo option is valid only if -xautopar is specified; otherwise, the compiler issues a warning.

To achieve faster execution, this option requires a multiprocessor system. On a single-processor system, the generated code usually runs slower.

B.2.131 -xM

Runs only the C preprocessor on the named C programs, requesting that the preprocessor generate makefile dependencies and send the result to the standard output. See the make(1) man page for details about make files and dependencies.

For example:

#include <unistd.h>
void main(void)
{}

generates this output:

e.o: e.c
e.o: /usr/include/unistd.h
e.o: /usr/include/sys/types.h
e.o: /usr/include/sys/machtypes.h
e.o: /usr/include/sys/select.h
e.o: /usr/include/sys/time.h
e.o: /usr/include/sys/types.h
e.o: /usr/include/sys/time.h
e.o: /usr/include/sys/unistd.h

If you specify -xM and -xMF, the compiler appends all makefile dependency information to the file specified with -xMF.

B.2.132 -xM1

Generates makefile dependencies like -xM, but excludes /usr/include files. For example:

more hello.c
#include<stdio.h>
main()
{
    (void)printf(“hello\n”);
}
cc– xM hello.c
hello.o: hello.c
hello.o: /usr/include/stdio.h

Compiling with -xM1 does not report header file dependencies:

cc– xM1 hello.c
hello.o: hello.c

-xM1 is not available under -Xs mode.

If you specify -xM1 and -xMF, the compiler appends all makefile dependency information to the file specified with -xMF.

B.2.133 -xMD

Generates makefile dependencies like -xM but compilation continues. -xMD generates an output file for the makefile-dependency information derived from the -o output filename, if specified, or the input source filename, replacing (or adding) the filename suffix with .d. If you specify -xMD and -xMF, the preprocessor writes all makefile dependency information to the file specified with -xMF. Compiling with -xMD -xMF or -xMD -o filename with more than one source file is not allowed and generates an error. The dependency file is overwritten if it already exists.

B.2.134 -xMF filename

Use this option to specify a file for the makefile-dependency output. You cannot specify individual filenames for multiple input files with -xMF on one command line. Compiling with -xMD -xMF or -xMMD -xMF with more than one source file is not allowed and generates an error. The dependency file is overwritten if it already exists.

This option cannot be used with -xM or -xM1.

B.2.135 -xMMD

Use this option to generate makefile dependencies excluding system header files. This option provides the same functionality as -xM1, but compilation continues. -xMMD generates an output file for the makefile-dependency information derived from the -o output filename, if specified, or the input source filename, replacing (or adding) the filename suffix with .d . If you specify -xMF, the compiler uses the filename you provide instead. Compiling with -xMMD -xMF or -xMMD -o filename with more than one source file is not allowed and generates an error. The dependency file is overwritten if it already exists.

B.2.136 -xMerge

Merges data segments into text segments. Data initialized in the object file produced by this compilation is read-only and (unless linked with ld -N) is shared between processes.

The three options -xMerge -ztext -xprofile=collect should not be used together. While -xMerge forces statically initialized data into read-only storage, -ztext prohibits position-dependent symbol relocations in read-only storage, and -xprofile=collect generates statically initialized, position-dependent symbol relocations in writable storage.

B.2.137 -xmaxopt[=v]

This option limits the level of pragma opt to the level specified. v is one of off, 1, 2, 3, 4, 5. The default value is -xmaxopt=off which causes pragma opt to be ignored. Specifying -xmaxopt without supplying an argument is the equivalent of specifying -xmaxopt=5.

If you specify both -xO and -xmaxopt, the optimization level set with -xO must not exceed the -xmaxopt value.

B.2.138 -xmemalign=ab

(SPARC) Use the -xmemalign option to control the assumptions that the compiler makes about the alignment of data. By controlling the code generated for potentially misaligned memory accesses and by controlling program behavior in the event of a misaligned access, you can more easily port your code to the SPARC platform.

Specify the maximum assumed memory alignment and behavior of misaligned data accesses. You must provide a value for both a (alignment) and b (behavior). a specifies the maximum assumed memory alignment and b specifies the behavior for misaligned memory accesses. The following table lists the alignment and behavior values for -xmemalign.

Table B-33  The -xmemalign Alignment and Behavior Flags
a
b
1
Assume at most 1 byte alignment.
i
Interpret access and continue execution.
2
Assume at most 2 byte alignment.
s
Raise signal SIGBUS.
4
Assume at most 4 byte alignment.
f
For 64–bit SPARC (-m64) only:
Raise signal SIGBUS for alignments less or equal to 4. Otherwise, interpret access and continue execution. For 32–bit programs, the f flag is equivalent to i.
8
Assume at most 8 byte alignment.
16
Assume at most 16 byte alignment

You must specify -xmemalign whenever you want to link to an object file that was compiled with the value of b set to either i or f. For a complete list of all compiler options that must be specified at both compile time and at link time, see Table A–2.

For memory accesses where the alignment is determinable at compile time, the compiler generates the appropriate load/store instruction sequence for that alignment of data.

For memory accesses where the alignment cannot be determined at compile time, the compiler must assume an alignment to generate the needed load/store sequence. The -xmemalign option enables you to specify the maximum memory alignment of data to be assumed by the compiler in these situations. It also specifies the error behavior to be followed at run time when a misaligned memory access does take place.

If actual data alignment at runtime is less than the specified alignment, the misaligned access attempt (a memory read or write) generates a trap. The two possible responses to the trap are

  • The OS converts the trap to a SIGBUS signal. If the program does not catch the signal, the program stops. Even if the program catches the signal, the misaligned access attempt will not have succeeded.

  • The OS handles the trap by interpreting the misaligned access and returning control to the program as if the access had succeeded normally.

The following default values apply only when no -xmemalign option is present:

  • -xmemalgin=8i for all 32–bit platforms (-m32).

  • -xmemalign=8s for all 64–bit platforms (-m64).

The default when -xmemalign option is present but no value is given is -xmemalign=1i for all platforms.

The following table describes how you can use -xmemalign to handle different alignment situations.

Table B-34  Examples of -xmemalign
Command
Situation
-xmemalign=1s
There are many misaligned accesses so trap handling is too slow.
-xmemalign=8i
There are occasional, intentional, misaligned accesses in code that is otherwise correct.
-xmemalign=8s
There should be no misaligned accesses in the program.
-xmemalign=2s
You want to check for possible odd-byte accesses.
-xmemalign=2i
You want to check for possible odd-byte access and you want the program to work.

B.2.139 -xmodel=[a]

(x86) The -xmodel option enables the compiler to modify the form of 64-bit objects for Oracle Solaris x86 platforms and should only be specified for the compilation of such objects.

This option is valid only when –m64 is also specified on 64–bit enabled x64 processors.

The following table lists the values for a.

Table B-35  -xmodel Flags
Value
Meaning
small
This option generates code for the small model in which the virtual address of code executed is known at link time and all symbols are known to be located in the virtual addresses in the range from 0 to 2^31 - 2^24 - 1.
kernel
Generates code for the kernel model in which all symbols are defined to be in the range from 2^64 - 2^31 to 2^64 - 2^24.
medium
Generates code for the medium model in which no assumptions are made about the range of symbolic references to data sections. Size and address of the text section have the same limits as the small code model. Applications with large amounts of static data might require –xmodel=medium when compiling with –m64.

This option is not cumulative so the compiler sets the model value according to the rightmost instance of -xmodel on the command line.

If you do not specify -xmodel, the compiler assumes -xmodel=small. Specifying -xmodel without an argument is an error.

You do not have to compile all translation units with this option. You can compile select files as long as you ensure the object you are accessing is within reach.

Be aware that not all Linux systems support the medium model.

B.2.140 -xnolib

Does not link any libraries by default; that is, no -l options are passed to ld(1). Normally, the cc driver passes -lc to ld.

When you use -xnolib, you have to pass all the -l options yourself.

B.2.141 -xnolibmil

Does not inline math library routines. Use this option after the –fast option for example:

% cc– fast– xnolibmil....

B.2.142 -xnolibmopt

Prevents the use of an optimized math library by the compiler by disabling any previously specified -xlibmopt option. For example, use this option after -fast, which enables -xlibmopt.

% cc -fast -xnolibmopt ...

B.2.143 –xnorunpath

Do not build a runtime search path for shared libraries into the executable.

This option is recommended for building executables that will be shipped to customers who might have a different path for the shared libraries that are used by the program.

B.2.144 -xO[1|2|3|4|5]

Sets the compiler optimization level. Note the uppercase letter O followed by the digit 1, 2, 3, 4, or 5. Generally, the higher the level of optimization, the better the runtime performance. However, higher optimization levels can result in longer compilation time and larger executable files.

In a few cases, -xO2 might perform better than the others, and -xO3 might outperform -xO4.

If the optimizer runs out of memory, it tries to recover by retrying the current procedure at a lower level of optimization and resumes subsequent procedures at the original level specified in the command-line option.

The default is no optimization, which is only possible if you do not specify an optimization level. If you specify an optimization level, you cannot disable optimization.

If you are trying to avoid setting an optimization level, be sure not to specify any option that implies an optimization level. For example, -fast is a macro option that sets optimization at -xO5. All other options that imply an optimization level issue a warning message that optimization has been set. The only way to compile without any optimization is to delete all options from the command line or makefile that specify an optimization level.

If you use -g and the optimization level is -xO3 or lower, the compiler provides best-effort symbolic information with almost full optimization. Tail-call optimization and back-end inlining are disabled.

If you use -g and the optimization level is -xO4 or higher, the compiler provides best-effort symbolic information with full optimization.

Debugging with -g does not suppress -xOn, but -xOn limits -g in certain ways. For example, the optimization options reduce the utility of debugging so that you cannot display variables from dbx, but you can still use the dbx where command to get a symbolic traceback. For more information, see “Debugging Optimized Code” in Chapter 1 of Debugging a Program With dbx.

If you specify both -xO and -xmaxopt, the optimization level set with -xO must not exceed the -xmaxopt value.

If you optimize at -xO3 or -xO4 with very large procedures (thousands of lines of code in the same procedure), the optimizer may require a large amount of virtual memory. In such cases, machine performance might degrade.

B.2.144.1 SPARC Optimizations

The following table lists the optimization levels on SPARC platforms.

Table B-36  -xO Flags on SPARC Platforms
Value
Meaning
-xO1
Does basic local optimization (peephole).
-xO2
Does basic local and global optimization. This is induction variable elimination, local and global common subexpression elimination, algebraic simplification, copy propagation, constant propagation, loop-invariant optimization, register allocation, basic block merging, tail recursion elimination, dead code elimination, tail call elimination, and complex expression expansion.
The -xO2 level does not assign global, external, or indirect references or definitions to registers. It treats these references and definitions as if they were declared volatile. In general, the -xO2 level results in minimum code size.
-xO3
Performs like -xO2, but also optimizes references or definitions for external variables. Loop unrolling and software pipelining are also performed. This level does not trace the effects of pointer assignments. When compiling either device drivers or programs that modify external variables from within signal handlers, you might need to use the volatile type qualifier to protect the object from optimization. The -xO3 level usually results in increased code size.
-xO4
Performs like -xO3, but also automatically inlines functions contained in the same file; this usually improves execution speed. To control which functions are inlined, see -xinline=list.
This level traces the effects of pointer assignments, and usually results in increased code size.
-xO5
Attempts to generate the highest level of optimization. Uses optimization algorithms that take more compilation time or that do not have as high a certainty of improving execution time. Optimization at this level is more likely to improve performance if it is done with profile feedback. For more information, see –xprofile=p.

B.2.144.2 x86 Optimization Levels

The following table lists the optimization levels on x86 platforms.

Table B-37  -xO Flags on x86 Platforms
Value
Meaning
-xO1
Preloads arguments from memory, cross-jumping (tail-merging), as well as single pass default optimizations.
-xO2
Schedules both high-level and low-level instructions and performs improved spill analysis, loop memory-reference elimination, register lifetime analysis, enhanced register allocation, and elimination of global common subexpressions.
-xO3
Performs loop strength reduction and induction variable elimination, as well as the optimization done by level 2.
-xO4
Performs automatic inlining of functions contained in the same file in addition to performing -xO3 optimizations. This automatic inlining usually improves execution speed but sometimes can make it worse. This level usually results in increased code size.
-xO5
Generates the highest level of optimization. Uses optimization algorithms that take more compilation time or that do not have as high a certainty of improving execution time. Some of these include generating local calling convention entry points for exported functions, further optimizing spill code, and adding analysis to improve instruction scheduling.

For more information about debugging, see the Oracle Solaris Studio: Debugging a Program With dbx manual. For more information on optimization, see the Oracle Solaris Studio Performance Analyzer manual.

See also -xldscope and -xmaxopt.

B.2.145 -xopenmp[={parallel|noopt|none}]

Enable explicit parallelization with OpenMP directives.

The following table details the -xopenmp values:

Table B-38  -xopenmp Flags
Value
Meaning
parallel
Enables recognition of OpenMP pragmas. The optimization level under -xopenmp=parallel is -xO3. The compiler raises the optimization level to-xO3 if necessary and issues a warning.
This flag also defines the preprocessor macro _OPENMP. The _OPENMP macro is defined to have the decimal value yyyymm where yyyy and mm are the year and month designations of the version of the OpenMP API that the implementation supports. Refer to the Oracle Solaris Studio OpenMP API User's Guide for the value of the _OPENMP macro for a particular release.
noopt
Enables recognition of OpenMP pragmas. The compiler does not raise the optimization level if it is lower than -O3.
If you explicitly set the optimization lower than -O3, as in cc -O2 -xopenmp=noopt, the compiler issues an error. If you do not specify an optimization level with -xopenmp=noopt, the OpenMP pragmas are recognized, the program is parallelized accordingly, but no optimization is done.
This flag also defines the preprocessor token _OPENMP.
none
Does not enable recognition of OpenMP pragmas, makes no change to the optimization level of your program, and does not define any preprocessor macros. This is the default when -xopenmp is not specified.

If you specify -xopenmp but do not specify a value, the compiler assumes -xopenmp=parallel. If you do not specify -xopenmp at all, the compiler assumes -xopenmp=none.

If you are debugging an OpenMP program with dbx, compile with -g -xopenmp=noopt so you can breakpoint within parallel regions and display the contents of variables.

The default for -xopenmp might change in a future release. You can avoid warning messages by explicitly specifying an appropriate optimization level.

Use the OMP_NUM_THREADS environment variable to specify the number of threads to use when running an OpenMP program. If OMP_NUM_THREADS is not set, the default number of threads used to execute a parallel region is the number of cores available on the machine, capped at 32. You can specify a different number of threads by setting the OMP_NUM_THREADS environment variable, or by calling the omp_set_num_threads() OpenMP runtime routine, or by using the num_threads clause on the parallel region directive. For best performance, the number of threads used to execute a parallel region should not exceed the number of hardware threads (or virtual processors) available on the machine. On Oracle Solaris systems, this number can be determined by using the psrinfo(1M) command. On Linux systems, this number can be determined by inspecting the file /proc/cpuinfo. See the OpenMP API User's Guide for more information.

Nested parallelism is disabled by default. To enable nested parallelism, you must set the OMP_NESTED environment variable to TRUE. See the OpenMP API User's Guide for details.

If you compile and link in separate steps, specify -xopenmp in both the compilation step and the link step. When used with the link step, the -xopenmp option will link with the OpenMP runtime support library, libmtsk.so.

For up-to-date functionality and performance, make sure that the latest patch of the OpenMP runtime library, libmtsk.so, is installed on the system.

For more information about the OpenMP Fortran 95, C, and C++ application program interface (API) for building multithreaded applications, see the Oracle Solaris Studio OpenMP API User's Guide.

B.2.146 -xP

The compiler performs only syntax and semantic checking on the source file in order to print prototypes for all K&R C functions. This option does not produce any object or executable code. For example, specifying -xP with the following source file,

f()
{
}

main(argc,argv)
int argc;
char *argv[];
{
}

produces this output:

int f(void);
int main(int, char **);

B.2.147 -xpagesize=n

Sets the preferred page size for the stack and the heap.

SPARC: The following values are valid: 4k, 8K, 64K, 512K, 2M, 4M, 32M, 256M, 2G, 16G, or default.

x86: The following values are valid: 4K, 2M. 4M, 1G, or default.

If you do not specify a valid page size, the request is silently ignored at runtime. You must specify a valid page size for the target platform.

Use the pagesize(1) Oracle Solaris command to determine the number of bytes in a page. The operating system offers no guarantee that the page size request will be honored. However, appropriate segment alignment can be used to increase the likelihood of obtaining the requested page size. See the -xsegment_align option on how to set the segment alignment. You can use pmap(2) or meminfo(2) to determine page size of the target platform.

The -xpagesize option has no effect unless you use it at compile time and at link time. For a complete list of all compiler options that must be specified at both compile time and at link time, see Table A–2.

If you specify -xpagesize=default, the Oracle Solaris operating system sets the page size.

Compiling with this option has the same effect as setting the LD_PRELOAD environment variable to mpss.so.1 with the equivalent options, or running the Oracle Solaris command ppgsz(1) with the equivalent options before running the program. See the related Oracle Solaris man pages for details.

This option is a macro for -xpagesize_heap and -xpagesize_stack. These two options accept the same arguments as -xpagesize. You can set both options with the same value by specifying -xpagesize or you can specify them individually with different values.

B.2.148 -xpagesize_heap=n

Set the page size in memory for the heap.

This option accepts the same values as —xpagesize. If you do not specify a valid page size, the request is silently ignored at run-time.

Use the getpagesize(3C) command on the Oracle Solaris operating system to determine the number of bytes in a page. The Oracle Solaris operating system offers no guarantee that the page size request will be honored. You can use pmap(1) or meminfo(2) to determine page size of the target platform.

If you specify -xpagesize_heap=default, the Oracle Solaris operating system sets the page size.

Compiling with this option has the same effect as setting the LD_PRELOAD environment variable to mpss.so.1 with the equivalent options, or running the Oracle Solaris command ppgsz(1) with the equivalent options before running the program. See the related Oracle Solaris man pages for details.

The -xpagesize_heap option has no effect unless you use it at compile time and at link time. For a complete list of all compiler options that must be specified at both compile time and at link time, see Table A–2.

B.2.149 -xpagesize_stack=n

Set the page size in memory for the stack.

This option accepts the same values as —xpagesize. If you do not specify a valid page size, the request is silently ignored at run-time.

Use the getpagesize(3C) command on the Oracle Solaris operating system to determine the number of bytes in a page. The Oracle Solaris operating system offers no guarantee that the page size request will be honored. You can use pmap(1) or meminfo(2) to determine page size of the target platform.

If you specify -xpagesize_stack=default, the Oracle Solaris operating system sets the page size.

Compiling with this option has the same effect as setting the LD_PRELOAD environment variable to mpss.so.1 with the equivalent options, or running the Oracle Solaris command ppgsz(1) with the equivalent options before running the program. See the related Oracle Solaris man pages for details.

The -xpagesize_stack option has no effect unless you use it at compile time and at link time. For a complete list of all compiler options that must be specified at both compile time and at link time, see Table A–2.

B.2.150 -xpatchpadding[={fix|patch|size}]

Reserve an area of memory before the start of each function. If fix is specified, the compiler will reserve the amount of space required by fix and continue. This is the first default. If either patch or no value is specified, the compiler will reserve a platform-specific default value. A value of -xpatchpadding=0 will reserve 0 bytes of space. The maximum value for size on x86 is 127 bytes and on SPARC is 2048 bytes.

B.2.151 -xpch=v

This compiler option activates the precompiled-header feature. v can be auto, autofirst, collect:pch_filename, or use:pch_filename. You can take advantage of this feature through the -xpch and -xpchstop options in combination with the #pragma hdrstop directive.

Use the -xpch option to create a precompiled-header file and improve your compilation time. The precompiled-header file reduces compile time for applications whose source files share a common set of include files containing a large amount of source code. A precompiled header works by collecting information about a sequence of header files from one source file, and then using that information when recompiling that source file, and when compiling other source files that have the same sequence of headers. The information that the compiler collects is stored in a precompiled-header file.

For more information, see:

B.2.151.1 Creating a Precompiled-Header File Automatically

The compiler can generate the precompiled- header file for you automatically in one of two ways. One way is for the compiler to create the precompiled-header file from the first include file it finds in the source file. The other way is for the compiler to select from the set of include files found in the source file starting with the first include file and extending through a well-defined point that determines which include file is the last one. Use one of the flags described in the following table to determine which method the compiler uses to automatically generate a precompiled header.

Table B-39  The –xpch Flags
Flag
Meaning
-xpch=auto
The content of the precompiled-header file is based on the longest viable prefix that the compiler finds in the source file. This flag produces a precompiled-header file that consists of the largest possible number of header files. For more information, see The Viable Prefix
-xpch=autofirst
This flag produces a precompiled-header file that contains only the first header found in the source file.

B.2.151.2 Creating a Precompiled-Header File Manually

To create your precompiled-header file manually, start by first using -xpch, and specifying the collect mode. The compilation command that specifies -xpch=collect must only specify one source file. In the following example, the -xpch option creates a precompiled-header file called myheader.cpch based on the source file a.c.

cc -xpch=collect:myheader a.c

A valid precompiled-header file name always has the suffix .cpch. When you specify pch_filename, you can add the suffix or have the compiler add it for you. For example, if you specify cc -xpch=collect:foo a.c, the precompiled-header file is called foo.cpch.

B.2.151.3 How the Compiler Handles an Existing Precompiled-Header File

If the compiler cannot use the precompiled-header file with -xpch=auto and -xpch=autofirst, it generates a new precompiled-header file. If the compiler cannot use the precompiled-header file with -xpch=use, a warning is issued and the compilation is done using the real headers.

B.2.151.4 Directing the Compiler to Use a Specific Precompiled-Header File

You can also direct the compiler to use a specific precompiled header by specifying -xpch=use:pch_filename. You can specify any number of source files with the same sequence of include files as the source file that was used to create the precompiled-header file. For example, your command in use mode might be: cc -xpch=use:foo.cpch foo.c bar.c foobar.c.

You should only use an existing precompiled-header file if the following items are true. If any of the following is not true, you should re-create the precompiled-header file:

  • The compiler that you are using to access the precompiled-header file is the same as the compiler that created the precompiled-header file. A precompiled-header file created by one version of the compiler might not be usable by another version of the compiler.

  • Except for the -xpch option, the compiler options you specify with -xpch=use must match the options that were specified when the precompiled-header file was created.

  • The set of included headers you specify with -xpch=use is identical to the set of headers that were specified when the precompile header was created.

  • The contents of the included headers that you specify with -xpch=use is identical to the contents of the included headers that were specified when the precompiled header was created.

  • The current directory (that is, the directory in which the compilation is occurring and attempting to use a given precompiled-header file) is the same as the directory in which the precompiled-header file was created.

  • The initial sequence of preprocessing directives, including #include directives, in the file you specified with -xpch=collect are the same as the sequence of preprocessing directives in the files you specify with -xpch=use.

B.2.151.5 The Viable Prefix

In order to share a precompiled-header file across multiple source files, those source files must share a common set of include files as their initial sequence of tokens. A token is a keyword, name or punctuation mark. Comments and code that is excluded by #if directives are not recognized by the compiler as tokens. This initial sequence of tokens is known as the viable prefix. In other words, the viable prefix is the top portion of the source file that is common to all source files. The compiler uses this viable prefix as the basis for creating a precompiled-header file and thereby determining which header files from the source are precompiled.

The viable prefix that the compiler finds during the current compilation must match the viable prefix that it used to create the precompiled-header file. In other words, a viable prefix must be interpreted consistently across all the source files that use the same precompiled-header file.

The viable prefix of a source file can only consist of comments and any of the following preprocessor directives:

#include
#if/ifdef/ifndef/else/elif/endif
#define/undef
#ident (if identical, passed through as is)
#pragma (if identical)

Any of these directives may reference macros. The #else, #elif, and #endif directives must match within the viable prefix. Comments are ignored.

The compiler determines the end point of the viable prefix automatically when you specify -xpch=auto or -xpch=autofirst. It is defined as follows.

  • The first declaration/definition

  • The first #line directive

  • A #pragma hdrstop directive

  • After the named include file if you specify –xpch=auto and –xpchstop

  • The first include file if you specify –xpch=autofirst


    Note -  An end point within a preprocessor conditional compilation statement generates a warning and disables the automatic creation of a precompiled-header file. Also, if you specify both the #pragma hdrstop and the -xpchstop option, then the compiler uses the earlier of the two stop points to terminate the viable prefix.

For -xpch=collect or -xpch=use, the viable prefix ends with a #pragma hdrstop.

Within the viable prefix of each file that shares a precompiled-header file, each corresponding #define and #undef directive must reference the same symbol. In the case of #define, each one must reference the same value. Their order of appearance within each viable prefix must be the same as well. Each corresponding pragma must also be the same and appear in the same order across all the files sharing a precompiled header.

B.2.151.6 Screening a Header File for Problems

A header file is precompilable when it is interpreted consistently across different source files; specifically, when it contains only complete declarations. That is, a declaration in any one file must stand alone as a valid declaration. Incomplete type declarations, such as struct S;, are valid declarations. The complete type declaration can appear in some other file. Consider these example header files:

file a.h
struct S {
#include "x.h" /* not allowed */
};

file b.h
struct T; // ok, complete declaration
struct S {
   int i;
[end of file, continued in another file] /* not allowed*/

A header file that is incorporated into a precompiled-header file must not violate the following constraints. The results of compiling a program that violates any of these constraints is undefined.

  • The header file must not use __DATE__ and __TIME__.

  • The header file must not contain #pragma hdrstop.

A header is also precompilable if it contains variable and function definitions. as well.

B.2.151.7 Precompiled-Header File Cache

When the compiler creates a precompiled-header file automatically, the compiler writes it to the SunWS_cache directory. This directory always resides in the location where the object file is created. Updates to the file are performed under a lock so that it works properly under dmake.

If you need to force the compiler to rebuild automatically generated precompiled-header files, you can clear the precompiled-header file cache-directory with the CCadmin tool. See the CCadmin(1) man page for more information.

B.2.151.8 Caveats

  • Do not specify conflicting -xpch flags on the command line. For example, specifying both -xpch=collect and -xpch=auto, or specifying both -xpch=autofirst with -xpchstop=<include> generates an error.

  • If you specify -xpch=autofirst or you specify -xpch=auto without -xpchstop, any declaration, definition, or #line directive that appears prior to the first include file, or appears prior to the include file that is specified with -xpchstop for -xpch=auto, generates a warning and disables the automatic generation of the precompiled-header file.

  • A #pragma hdrstop before the first include file under -xpch=autofirst or -xpch=auto disables the automatic generation of the precompiled-header file.

B.2.151.9 Precompiled-Header File Dependencies and make Files

The compiler generates dependency information for precompiled-header files when you specify -xpch=collect. You need to create the appropriate rules in your make files to take advantage of these dependencies. Consider this sample make file:

%.o : %.c shared.cpch
         $(CC) -xpch=use:shared -xpchstop=foo.h -c $<
default : a.out

foo.o + shared.cpch : foo.c
         $(CC) -xpch=collect:shared -xpchstop=foo.h foo.c -c

a.out : foo.o bar.o foobar.o
         $(CC) foo.o bar.o foobar.o

clean :
         rm -f *.o shared.cpch .make.state a.out

These make rules, along with the dependencies generated by the compiler, force a manually created precompiled- header file to be re-created if any source file you used with -xpch=collect, or any of the headers that are part of the precompiled-header file, have changed. This constraint prevents the use of an out-of-date precompiled-header file.

You do not have to create any additional make rules in your makefiles for -xpch=auto or -xpch=autofirst.

B.2.152 -xpchstop=[file|<include>]

Use the -xpchstop=file option to specify the last include file of the viable prefix for the precompiled-header file. Using -xpchstop on the command line is equivalent to placing a hdrstop pragma after the first include-directive that references file in each of the source files that you specify with the cc command.

Use -xpchstop=<include> with -xpch-auto to create a precompiled-header file that is based on header files up through and including <include>. This flag overrides the default -xpch=auto behavior of using all header files that are contained in the entire viable prefix.

In the following example, the -xpchstop option specifies that the viable prefix for the precompiled-header file ends with the include of projectheader.h. Therefore, privateheader.h is not a part of the viable prefix.

example% cat a.c
     #include <stdio.h>
     #include <strings.h>
     #include "projectheader.h"
     #include "privateheader.h"
     .
     .
     .
example% cc -xpch=collect:foo.cpch a.c -xpchstop=projectheader.h -c

See also -xpch.

B.2.153 –xpec[={yes|no}]

(Solaris only) Generates a Portable Executable Code (PEC) binary. This option puts the program intermediate representations in the object file and the binary. This binary may be used later for tuning and troubleshooting.

A binary that is built with –xpec is usually five to ten times larger than if it is built without –xpec.

If you do not specify –xpec, the compiler assumes –xpec=no. If you specify –xpec, but do not supply a flag, the compiler assumes –xpec=yes.

B.2.154 -xpentium

(x86) Generates code for the Pentium processor.

B.2.155 -xpg

Prepares the object code to collect data for profiling with gprof(1). It invokes a runtime recording mechanism that produces a gmon.out file at normal termination.


Note -  -xpg does not provide any additional benefit if used with -xprofile. The two options do not prepare or use data provided by the other.

Profiles are generated by using prof(1) or gprof(1) on 64–bit Oracle Solaris platforms or just gprof on 32–bit Oracle Solaris platforms and include approximate user CPU times derived from PC sample data (see pcsample(2)) for routines in the main executable and routines in shared libraries specified as linker arguments when the executable is linked. Other shared libraries (libraries opened after process startup using dlopen(3DL)) are not profiled.

On 32–bit Oracle Solaris systems, profiles generated using prof(1) are limited to routines in the executable. 32–bit shared libraries can be profiled by linking the executable with -xpg and using gprof(1).

On x86 systems, -xpg is incompatible with -xregs=frameptr. These two options should not be used together. Note also that -xregs=frameptr is included in -fast. Compile with -fast -xregs=no%frameptr -xpg when using -fast with -xpg.

Current Oracle Solaris releases do not include system libraries compiled with -p. As a result, profiles collected current Solaris platforms do not include call counts for system library routines.

If you specify -xpg at compile time, you must also specify it at link time. See Compile-Time and Link-Time Options for a complete list of options that must be specified at both compile time and link time.


Note -  Binaries compiled with -xpg for gprof profiling should not be used with binopt(1), as they are incompatible and can result in internal errors.

B.2.156 -xprefetch[=val[,val]]

Enables prefetch instructions on those architectures that support prefetch.

Explicit prefetching should be used only under special circumstances that are supported by measurements.

The following table lists the values of val.

Table B-40  -xprefetch Flags
Flag
Meaning
latx:factor
(SPARC) Adjust the compiler’s assumed prefetch-to-load and prefetch-to-store latencies by the specified factor. You can only combine this flag with -xprefetch=auto. See Prefetch Latency Ratio (SPARC)
[no%]auto
[Disable] Enable automatic generation of prefetch instructions.
[no%]explicit
[Disable] Enable explicit prefetch macros.
yes
Obsolete - do not use. Use -xprefetch=auto,explicit instead.
no
Obsolete - do not use. Use -xprefetch=no%auto,no%explicit instead.

The default is -xprefetch=auto,explicit. This default adversely affects applications that have essentially non-linear memory access patterns. Specify -xprefetch=no%auto,no%explicit to override the default.

The sun_prefetch.h header file provides the macros that you can use to specify explicit prefetch instructions. The prefetches are approximately at the place in the executable that corresponds to where the macros appear.

B.2.156.1 Prefetch Latency Ratio (SPARC)

The prefetch latency is the hardware delay between the execution of a prefetch instruction and the time the data being prefetched is available in the cache.

The factor must be a positive number of the form n.n.

The compiler assumes a prefetch latency value when determining how far apart to place a prefetch instruction and the load or store instruction that uses the prefetched data. The assumed latency between a prefetch and a load might not be the same as the assumed latency between a prefetch and a store.

The compiler tunes the prefetch mechanism for optimal performance across a wide range of machines and applications. This tuning may not always be optimal. For memory-intensive applications, especially applications intended to run on large multiprocessors, you might be able to obtain better performance by increasing the prefetch latency values. To increase the values, use a factor that is greater than 1 (one). A value between .5 and 2.0 will most likely provide the maximum performance.

For applications with data sets that reside entirely within the external cache, you might be able to obtain better performance by decreasing the prefetch latency values. To decrease the values, use a factor that is less than one.

To use the latx:factor suboption, start with a factor value near 1.0 and run performance tests against the application. Increase or decrease the factor, as appropriate, and run the performance tests again. Continue adjusting the factor and running the performance tests until you achieve optimum performance. When you increase or decrease the factor in small steps, you will see no performance difference for a few steps, then a sudden difference, then performance will level off again.

B.2.157 -xprefetch_auto_type=a

The value for a is [no%]indirect_array_access.

Use -xprefetch_auto_type=indirect_array_access to enable the compiler to generate indirect prefetches for the loops indicated by the option -xprefetch_level in the same fashion the prefetches for direct memory accesses are generated.

If you do not specify a setting for -xprefetch_auto_type, the compiler sets it to -xprefetch_auto_type=no%indirect_array_access.

Options such as -xalias_level can affect the aggressiveness of computing the indirect prefetch candidates and therefore the aggressiveness of the automatic indirect prefetch insertion due to better memory alias disambiguation information.

B.2.158 -xprefetch_level=l

Use the -xprefetch_level option to control the aggressiveness of automatic insertion of prefetch instructions as determined with -xprefetch=auto. l must be 1, 2, or 3. The compiler becomes more aggressive, or in other words, introduces more prefetches with each higher level of -xprefetch_level.

The appropriate value for the -xprefetch_level depends on the number of cache misses the application has. Higher -xprefetch_level values have the potential to improve the performance of applications.

This option is effective only when it is compiled with -xprefetch=auto with optimization level 3 or greater, and generate codes for a platform that supports prefetch (v8plus, v8plusa, v9, v9a, v9b, sse2, sse2a, sse3, amdsse4a, sse4_1, sse4_2, aes, avx, avx_i, avx2, generic64, and native64).

-xprefetch_level=1 enables automatic generation of prefetch instructions. -xprefetch_level=2 enables additional generation beyond level 1. -xprefetch_level=3 enables additional generation beyond level 2.

The default is -xprefetch_level=1 when you specify -xprefetch=auto.

B.2.159 -xprevise={yes|no}

Compile with this option to produce a static analysis of the source code that can be viewed using the Code Analyzer.

When compiling with -xprevise=yes and linking in a separate step, include -xprevise=yes also on the link step.

The default is -xprevise=no.

On Linux, -xprevise=yes needs to be specified along with -xannotate.

See the Oracle Solaris Studio Code Analyzer documentation for further information.

B.2.160 –xprofile=p

Collects data for a profile or uses a profile to optimize.

p must be collect[:profdir], use[:profdir], or tcov[:profdir].

This option causes execution frequency data to be collected and saved during execution. The data can be used in subsequent runs to improve performance. Profile collection is safe for multithreaded applications. That is, profiling a program that does its own multitasking ( -mt ) produces accurate results. This option is valid only when you specify -xO2 or greater level of optimization. If compilation and linking are performed in separate steps, the same -xprofile option must appear on the link step as well as the compile step.

collect[:profdir]

Collects and saves execution frequency for later use by the optimizer with -xprofile=use. The compiler generates code to measure statement execution-frequency.

-xMerge, -ztext, and -xprofile=collect should not be used together. While -xMerge forces statically initialized data into read-only storage, -ztext prohibits position-dependent symbol relocations in read-only storage, and -xprofile=collect generates statically initialized, position-dependent symbol relocations in writable storage.

The profile directory name profdir, if specified, is the pathname of the directory where profile data are to be stored when a program or shared library containing the profiled object code is executed. If the profdir pathname is not absolute, it is interpreted relative to the current working directory when the program is compiled with the option -xprofile=use:profdir.

If no profile directory name is specified with —xprofile=collect:prof_dir or —xprofile=tcov:prof_dir, profile data are stored at run time in a directory named program.profile where program is the basename of the profiled process's main program. In this case, the environment variables SUN_PROFDATA and SUN_PROFDATA_DIR can be used to control where the profile data are stored at run time. If set, the profile data are written to the directory given by $SUN_PROFDATA_DIR/$SUN_PROFDATA. If a profile directory name is specified at compilation time, SUN_PROFDATA_DIR and SUN_PROFDATA have no effect at run time. These environment variables similarly control the path and names of the profile data files written by tcov, as described in the tcov(1) man page.

If these environment variables are not set, the profile data is written to the directory profdir.profile in the current directory, where profdir is the name of the executable or the name specified in the -xprofile=collect:profdir flag. -xprofile does not append .profile to profdir if profdir already ends in .profile. If you run the program several times, the execution frequency data accumulates in the profdir.profile directory; that is output from prior executions is not lost.

If you are compiling and linking in separate steps, make sure that any object files compiled with -xprofile=collect are also linked with -xprofile=collect.

The following example collects and uses profile data in the directory myprof.profile located in the same directory where the program is built:

demo: cc -xprofile=collect:myprof.profile -xO5 prog.c -o prog  
demo: ./prog        
demo: cc -xprofile=use:myprof.profile -xO5 prog.c -o prog

The following example collects profile data in the directory /bench/myprof.profile and later uses the collected profile data in a feedback compilation at optimization level -xO5:

demo: cc -xprofile=collect:/bench/myprof.profile
\    -xO5 prog.c -o prog  
...run prog from multiple locations..
demo: cc -xprofile=use:/bench/myprof.profile 
\    -xO5 prog.c -o prog
use[:profdir]

Uses execution frequency data collected from code compiled with —xprofile=collect[:profdir] or —xprofile=tcov[:profdir] to optimize for the work performed when the profiled code was executed. profdir is the pathname of a directory containing profile data collected by running a program that was compiled with —xprofile=collect[:profdir] or —xprofile=tcov[:profdir].

To generate data that can be used by both tcov and —xprofile=use[:profdir], a profile directory must be specified at compilation time, using the option —xprofile=tcov[:profdir]. The same profile directory must be specified in both —xprofile=tcov:profdir and —xprofile=use:profdir. To minimize confusion, specify profdir as an absolute pathname.

The profdir path name is optional. If profdir is not specified, the name of the executable binary is used. a.out is used if -o is not specified. The compiler looks for profdir.profile/feedback, or a.out.profile/feedback when profdir is not specified. For example:

demo: cc -xprofile=collect	-o myexe prog.c 		 
demo: cc -xprofile=use:myexe -xO5 -o myexe	prog.c

The program is optimized by using the execution frequency data previously generated and saved in the feedback files written by a previous execution of the program compiled with -xprofile=collect.

Except for the -xprofile option, the source files and other compiler options must be exactly the same as those used for the compilation that created the compiled program that generated the feedback file. The same version of the compiler must be used for both the collect build and the use build as well.

If compiled with -xprofile=collect:profdir, the same profile directory name profdir must be used in the optimizing compilation: -xprofile=use:profdir.

See also -xprofile_ircache for speeding up compilation between collect and use phases.

tcov[:profdir]

Instrument object files for basic block coverage analysis using tcov(1).

If the optional profdir argument is specified, the compiler will create a profile directory at the specified location. The data stored in the profile directory can be used either by tcov(1) or by the compiler with -xprofile=use:profdir. If the optional profdir path name is omitted, a profile directory will be created when the profiled program is executed. The data stored in the profile directory can be used only by tcov(1). The location of the profile directory can be controlled using environment variables SUN_PROFDATA and SUN_PROFDATA_DIR.

If the location specified by profdir is not an absolute path name, it is interpreted at compilation time relative to the current working directory.

The directory whose location is specified by profdir must be accessible from all machines where the profiled program is to be executed. The profile directory should not be deleted until its contents are no longer needed, because data stored there by the compiler cannot be restored except by recompilation.

Example 1: If object files for one or more programs are compiled with -xprofile=tcov:/test/profdata, a directory named /test/profdata.profile will be created by the compiler and used to store data describing the profiled object files. The same directory will also be used at execution time to store execution data associated with the profiled object files.

Example 2: If a program named myprog is compiled with -xprofile=tcov and executed in the directory /home/joe, the directory /home/joe/myprog.profile will be created at runtime and used to store runtime profile data.

B.2.161 -xprofile_ircache[=path]

(SPARC) Use -xprofile_ircache[=path] with -xprofile=collect|use to improve compilation time during the use phase by reusing compilation data saved from the collect phase.

With large programs, compilation time in the use phase can improve significantly because the intermediate data is saved. Note that the saved data could increase disk space requirements considerably.

When you use -xprofile_ircache[=path], path overrides the location where the cached files are saved. By default, these files are saved in the same directory as the object file. Specifying a path is useful when the collect and use phases happen in two different directories. The following example shows a typical sequence of commands:

example% cc -xO5 -xprofile=collect -xprofile_ircache t1.c t2.c
example% a.out    // run collects feedback data
example% cc -xO5 -xprofile=use -xprofile_ircache t1.c t2.c

B.2.162 -xprofile_pathmap

(SPARC) Use the -xprofile_pathmap=collect_prefix:use_prefix option when you are also specifying the -xprofile=use command. Use -xprofile_pathmap when both of the following are true and the compiler is unable to find profile data for an object file that is compiled with -xprofile=use.

  • You are compiling the object file with -xprofile=use in a directory that is different from the directory in which the object file was previously compiled with -xprofile=collect.

  • Your object files share a common base name in the profile but are distinguished from each other by their location in different directories.

The collect-prefix is the prefix of the UNIX path name of a directory tree in which object files were compiled using -xprofile=collect.

The use-prefix is the prefix of the UNIX pathname of a directory tree in which object files are to be compiled using -xprofile=use.

If you specify multiple instances of -xprofile_pathmap, the compiler processes them in the order of their occurrence. Each use-prefix specified by an instance of -xprofile_pathmap is compared with the object file pathname until either a matching use-prefix is identified or the last specified use-prefix is found not to match the object file path name.

B.2.163 -xreduction

Analyzes loops for reduction in automatic parallelization. This option is valid only if -xautopar is also specified. Otherwise the compiler issues a warning.

When a reduction recognition is enabled, the compiler parallelizes reductions such as dot products and maximum and minimum finding. These reductions yield roundoffs different from those obtained by unparallelized code.

See also the Oracle Solaris Studio OpenMP API User's Guide.

B.2.164 -xregs=r[,r…]

Specifies the usage of registers for the generated code.

r is a comma-separated list that consists of one or more of the following suboptions: appl, float,frameptr.

Prefixing a suboption with no% disables that suboption.

Note that —xregs suboptions are restricted to specific hardware platforms.

Example: -xregs=appl,no%float

Table B-41   -xregs Sub-options
Value
Meaning
appl
(SPARC) Allows the compiler to generate code using the application registers as scratch registers. The application registers are:
g2, g3, g4 (on 32–bit platforms)
g2, g3 (on 64–bit platforms)
You should compile all system software and libraries using -xregs=no%appl. System software (including shared libraries) must preserve these registers’ values for the application. Their use is intended to be controlled by the compilation system and must be consistent throughout the application.
In the SPARC ABI, these registers are described as application registers. Using these registers can improve performance because fewer load and store instructions are needed. However, such use can conflict with some old library programs written in assembly code.
float
(SPARC) Allows the compiler to generate code by using the floating-point registers as scratch registers for integer values. Floating-point values may use these registers regardless of this option. If you want your code to be free of all references to floating point registers, use -xregs=no%float and make sure your code does not use floating-point types in any way.
(x86) Allow the compiler to generate code by using the floating-point registers as scratch registers. Floating-point values may use these registers regardless of this option. To generate binary code free of all references to floating point registers, use -xregs=no%float and make sure your source code does not in any way use floating point types. During code generation the compilers will attempt to diagnose code that results in the use of floating point, simd, or x87 instructions.
frameptr
(x86) Allows the compiler to use the frame-pointer register (%ebp on IA32, %rbp on AMD64) as a general-purpose register.
The default is -xregs=no%frameptr
The C++ compiler ignores -xregs=frameptr unless exceptions are also disabled with —features=no%except. Note that -xregs=frameptr is part of -fast.
With -xregs=framptr the compiler is free to use the frame-pointer register to improve program performance. However, some features of the debugger and performance measurement tools might be limited as a result. Stack tracing, debuggers, and performance analyzers cannot report on functions compiled with —xregs=frameptr
Mixed C, Fortran, and C++ code should not be compiled with —xregs=frameptr if a C++ function, called directly or indirectly from a C or Fortran function, can throw an exception. If compiling such mixed source code with —fast, add —xregs=no%frameptr after the —fast option on the command line.
With more available registers on 64–bit platforms, compiling with —xregs=frameptr has a better chance of improving 32–bit code performance than 64–bit code.
The compiler ignores -xregs=frameptr and issues a warning if you also specify -xpg. Also, —xkeepframe overrides —xregs=frameptr. For example, —xkeepframe=%all —xregs=frameptr indicates that the stack should be kept for all functions, but the optimizations for —xregs=frameptr would be ignored.

The SPARC default is -xregs=appl,float.

The x86 default is -xregs=no%frameptr,float.

On x86 systems, -xpg is incompatible with -xregs=frameptr. These two options should not be used together. Note also that -xregs=frameptr is included in -fast.

You should compile code intended for shared libraries that will link with applications with -xregs=no%appl,float. At the very least, the shared library should explicitly document how it uses the application registers so that applications linking with those libraries are aware of these register assignments.

For example, an application using the registers in some global sense (such as using a register to point to some critical data structure) would need to be aware of how a library with code compiled without -xregs=no%appl is using the application registers in order to safely link with that library.

B.2.165 -xrestrict[=f]

Treats pointer-valued function parameters as restricted pointers. f is %all, %none, or a comma-separated list of one or more function names: {%all|%none|fn[,fn...]}.

If a function list is specified with this option, pointer parameters in the specified functions are treated as restricted. If -xrestrict=%all is specified, all pointer parameters in the entire C file are treated as restricted. Refer to Restricted Pointers for more information.

This command-line option can be used on its own, but it is best used with optimization. For example, the command treats all pointer parameters in the file prog.c as restricted pointers:

%cc -xO3 -xrestrict=%all prog.c

The command treats all pointer parameters in the function agc in the file prog.c as restricted pointers:

%cc -xO3 -xrestrict=agc prog.c

The default is %none. Specifying -xrestrict is equivalent to specifying -xrestrict=%all.

B.2.166 –xs[={yes|no}]

dbx

(Oracle Solaris) Link debug information from object files into executable.

-xs is the same as -xs=yes.

The default for -xdebugformat=dwarf is the same as -xs=yes.

The default for -xdebugformat=stabs is the same as -xs=no.

This option controls the trade-off of executable size versus the need to retain object files in order to debug. For dwarf, use -xs=no to keep the executable small but depend on the object files. For stabs, use -xs or -xs=yes to avoid dependence on the object files at the cost of a larger executable. This option has almost no effect on dbx performance or the runtime per formance of the program.

When the compile command forces linking (that is, -c is not specified) there will be no object file(s) and the debug information must be placed in the executable. In this case, -xs=no (implicit or explicit) will be ignored.

The feature is implemented by having the compiler adjust the section flags and/or section names in the object file that it emits, which then tells the linker what to do for that object file's debug information. It is therefore a compiler option, not a linker option. It is possible to have an executable with some object files compiled -xs=yes and others compiled -xs=no.

Linux compilers accept but ignore -xs. Linux compilers do not accept -xs={yes|no}.

B.2.167 -xsafe=mem

(SPARC) Allows the compiler to assume no memory protection violations occur.

This option grants permission to use non-faulting load instruction on the SPARC V9 architecture.


Note -  Because non-faulting loads do not cause a trap when a fault such as address misalignment or segmentation violation occurs, you should use this option only for programs in which such faults cannot occur. Because few programs incur memory-based traps, you can safely use this option for most programs. Do not use this option for programs that explicitly depend on memory-based traps to handle exceptional conditions.

This option takes effect only when used with optimization level –xO5 and one of the following –xarch values: sparc, sparcvis, sparcvis2, or sparcvis3 for both –m32 and –m64.

B.2.168 -xsegment_align=n

(Oracle Solaris) This option causes the driver to include a special mapfile on the link line. The mapfile aligns the text, data, and bss segments to the value specified by n. When using very large pages, it is important that the heap and stack segments are aligned on an appropriate boundary. If these segments are not aligned, small pages will be used up to the next boundary, which could cause a performance degradation. The mapfile ensures that the segments are aligned on an appropriate boundary.

The n value must be one of the following:

SPARC: The following values are valid: 8K, 64K, 512K, 2M, 4M, 32M, 256M, 1G, and none.

x86: The following values are valid: 4K, 8K, 64K, 512K, 2M, 4M, 32M, 256M, 1G, and none.

The default for both SPARC and x86 is none.

Recommended usage is as follows:

SPARC 32-bit compilation: -xsegment_align=64K
SPARC 64-bit compilation: -xsegment_align=4M

x86 32-bit compilation: -xsegment_align=8K
x86 64-bit compilation: -xsegment_align=4M

The driver will include the appropriate mapfile. For example, if the user specifies -xsegment_align=4M, the driver adds -M install-directory/lib/compilers/mapfiles/map.4M.align to the link line, where install-directory is the installation directory. The aforementioned segments will then be aligned on a 4M boundary.

B.2.169 -xsfpconst

Represents unsuffixed floating-point constants as single precision instead of the default mode of double precision. Not valid with -pedantic.

B.2.170 -xspace

Does no optimizations or parallelization of loops that increase code size.

Example: The compiler will not unroll loops or parallelize loops if it increases code size.

B.2.171 -xstrconst

This option is deprecated and might be removed in a future release. —xstrconst is an alias for —features=conststrings.

B.2.172 -xtarget=t

Specifies the target system for instruction set and optimization.

The value of t must be one of the following: native, generic, native64, generic64, or system-name.

Each specific value for -xtarget expands into a specific set of values for the -xarch, -xchip, and -xcache options. Use the -xdryrun option to determine the expansion of -xtarget=native on a running system.

For example, -xtarget=ultra4 is equivalent to -xchip=ultra4 -xcache=64/32/4:8192/128/2 -xarch=sparcvis2


Note -  The expansion of -xtarget for a specific host platform might not expand to the same -xarch, -xchip, or -xcache settings as -xtarget=native when compiling on that platform.
Table B-42  -xtarget Values for All Platforms
Value
Meaning
native
Equivalent to
—m32 —xarch=native —xchip=native —xcache=native
to give best performance on the host 32–bit system.
native64
Equivalent to
—m64 —xarch=native64 —xchip=native64 —xcache=native64
to give best performance on the host 64–bit system.
generic
Equivalent to
—m32 —xarch=generic —xchip=generic —xcache=generic
to give best performance on most 32–bit systems.
generic64
Equivalent to
—m64 —xarch=generic64 —xchip=generic64 —xcache=generic64
to give best performance on most 64–bit systems.
system-name
Gets the best performance for the specified platform.
Select a system name from the following lists for which represents the actual system you are targeting.

The performance of some programs may benefit by providing the compiler with an accurate description of the target computer hardware. When program performance is critical, the proper specification of the target hardware could be very important, especially when running on the newer SPARC processors. However, for most programs and older SPARC processors, the performance gain is negligible and a generic specification is sufficient.

B.2.172.1 –xtarget Values on SPARC Platforms

Compiling for 64-bit Oracle Solaris software on SPARC or UltraSPARC V9 is indicated by the –m64 option. If you specify –xtarget with a flag other than native64 or generic64, you must also specify the –m64 option as follows: –xtarget=ultra... –m64. Otherwise the compiler uses a 32-bit memory model.

Table B-43  -xtarget Expansions on SPARC
-xtarget=
-xarch
-xchip
-xcache
ultra
sparcvis
ultra
16/32/1:512/64/1
ultra1/140
sparcvis
ultra
16/32/1:512/64/1
ultra1/170
sparcvis
ultra
16/32/1:512/64/1
ultra1/200
sparcvis
ultra
16/32/1:512/64/1
ultra2
sparcvis
ultra2
16/32/1:512/64/1
ultra2/1170
sparcvis
ultra
16/32/1:512/64/1
ultra2/1200
sparcvis
ultra
16/32/1:1024/64/1
ultra2/1300
sparcvis
ultra2
16/32/1:2048/64/1
ultra2/2170
sparcvis
ultra
16/32/1:512/64/1
ultra2/2200
sparcvis
ultra
16/32/1:1024/64/1
ultra2/2300
sparcvis
ultra2
16/32/1:2048/64/1
ultra2e
sparcvis
ultra2e
16/32/1:256/64/4
ultra2i
sparcvis
ultra2i
16/32/1:512/64/1
ultra3
sparcvis2
ultra3
64/32/4:8192/512/1
ultra3cu
sparcvis2
ultra3cu
64/32/4:8192/512/2
ultra3i
sparcvis2
ultra3i
64/32/4:1024/64/4
ultra4
sparcvis2
ultra4
64/32/4:8192/128/2
ultra4plus
sparcvis2
ultra4plus
64/32/4:2048/64/4/2:32768/64/4
ultraT1
sparc
ultraT1
8/16/4/4:3072/64/12/32
ultraT2
sparcvis2
ultraT2
8/16/4:4096/64/16
ultraT2plus
sparcvis2
ultraT2plus
8/16/4:4096/64/16
T3
sparcvis3
ultraT3
8/16/4:6144/64/24
T4
sparc4
T4
16/32/4:128/32/8:4096/64/16
sparc64vi
sparcfmaf
sparc64vi
128/64/2:5120/64/10
sparc64vii
sparcima
sparc64vii
64/64/2:5120/256/10
sparc64viiplus
sparcima
sparc64viiplus
64/64/2:11264/256/11
sparc64x
sparcace
sparc64x
64/128/4/2:24576/128/24/32
sparc64xplus
sparcaceplus
sparc64xplus
64/128/4/2:24576/128/24/32
T5
sparc4
T5
16/32/4/8:128/32/8/8:8192/64/16/128
T7
sparc5
T7
16/32/4/8:256/64/8/16:8192/64/8/32
M5
sparc4
M5
16/32/4/8:128/32/8/8:49152/64/12/48
M6
sparc4
M6
16/32/4/8:128/32/8/8:49152/64/12/96
M7
sparc5
M7
16/32/4/8:256/64/8/16:8192/64/8/32

Note -  The following SPARC -xtarget values are obsolete and may be removed in a future release: ultra, ultra1/140, ultra1/170, ultra1/200, ultra2, ultra2e, ultra2i, ultra2/1170, ultra2/1200, ultra2/1300, ultra2/2170, ultra2/2200, ultra2/2300, ultra3, ultra3cu, ultra3i, ultra4, and ultra4plus.

B.2.172.2 –xtarget Values on x86 Platforms

Compiling for 64-bit Oracle Solaris software on 64-bit x86 platforms is indicated by the –m64 option. If you specify –xtarget with a flag other than native64 or generic64, you must also specify the –m64 option as follows:

–xtarget=opteron ... –m64

Otherwise the compiler uses a 32-bit memory model.

Table B-44  -xtarget Expansions on x86
-xtarget=
-xarch
-xchip
-xcache
pentium
386
pentium
generic
pentium_pro
pentium_pro
pentium_pro
generic
pentium3
sse
pentium3
16/32/4:256/32/4
pentium4
sse2
pentium4
8/64/4:256/128/8
opteron
sse2a
opteron
64/64/2:1024/64/16
woodcrest
ssse3
core2
32/64/8:4096/64/16
barcelona
amdsse4a
amdfam10
64/64/2:512/64/16
penryn
sse4_1
penryn
2/64/8:6144/64/24
nehalem
sse4_2
nehalem
32/64/8:256/64/8:8192/64/16
westmere
aes
westmere
32/64/8:256/64/8:30720/64/24
sandybridge
avx
sandybridge
32/64/8/2:256/64/8/2:20480/64/20/16
ivybridge
avx_i
ivybridge
32/64/8/2:256/64/8/2:20480/64/20/16
haswell
avx2
haswell
32/64/8/2:256/64/8/2:20480/64/20/16

B.2.173 -xtemp=path

Equivalent to -temp=path.

B.2.174 -xthreadvar[=o]

Specify -xthreadvar to control the implementation of thread local variables. Use this option in conjunction with the __thread declaration specifier to take advantage of the compiler’s thread-local storage facility. After you declare the thread variables with the __thread specifier, specify -xthreadvar to enable the use of thread-local storage with position dependent code (non-PIC code) in dynamic (shared) libraries. For more information about how to use __thread, see Thread Local Storage Specifier.

o must be dynamic or no%dynamic.

Table B-45  -xthreadvar Flags
Flag
Meaning
[no%]dynamic
Compile variables for dynamic loading.
Access to thread variables is significantly faster when -xthreadvar=no%dynamic but you cannot use the object file within a dynamic library. That is, you can only use the object file in an executable file.

If you do not specify -xthreadvar, the default used by the compiler depends upon whether position-independent code is enabled. If position-independent code is enabled, the option is set to -xthreadvar=dynamic. If position-independent code is disabled, the option is set to -xthreadvar=no%dynamic.

If you specify -xthreadvar but do not specify any values, the option is set to -xthreadvar=dynamic.

If a dynamic library contains non-position-independent code, you must specify -xthreadvar.

The linker cannot support the thread-variable equivalent of non-PIC code in dynamic libraries. Non-PIC thread variables are significantly faster, and therefore should be the default for executables.

See also the descriptions of -xcode, -KPIC, and -Kpic

B.2.175 -xthroughput[={yes|no}]

The -xthroughput option tells the compiler that the application will be run in situations where many processes are simultaneously running on the system

If -xthroughput=yes, the compiler will favor optimizations that slightly reduce performance for a single process while improving the amount of work achieved by all the processes on the system. As an example, the compiler might choose to be less aggressive in prefetching data. Such a choice would reduce the memory bandwidth consumed by the process, and as such the process may run slower, but it would also leave more memory bandwidth to be shared among other processes.

The default is -xthroughput=no.

B.2.176 -xtime

Reports the time and resources used by each compilation component.

B.2.177 -xtransition

Issues warnings for the differences between K&R C and Solaris Studio ISO C.

The -xtransition option issues warnings in conjunction with the -Xa and -Xt options. You can eliminate all warning messages about differing behavior through appropriate coding. The following warnings no longer appear unless you issue the -xtransition option:

  • \a is ISO C “alert” character

  • \x is ISO C hex escape

  • bad octal digit

  • base type is really type tag: name

  • comment is replaced by “##”

  • comment does not concatenate tokens

  • declaration introduces new type in ISO C: type tag

  • macro replacement within a character constant

  • macro replacement within a string literal

  • no macro replacement within a character constant

  • no macro replacement within a string literal

  • operand treated as unsigned

  • trigraph sequence replaced

  • ISO C treats constant as unsigned: operator

  • semantics of operator change in ISO C; use explicit cast

B.2.178 -xtrigraphs[={yes|no}]

The -xtrigraphs option determines whether the compiler recognizes trigraph sequences as defined by the ISO C standard.

By default, the compiler assumes -xtrigraphs=yes and recognizes all trigraph sequences throughout the compilation unit.

If your source code has a literal string containing question marks (?) that the compiler is interpreting as a trigraph sequence, you can use the -xtrigraph=no suboption to disable the recognition of trigraph sequences. The -xtrigraphs=no option disables recognition of all trigraphs throughout the entire compilation unit.

Consider the following example source file named trigraphs_demo.c.

#include <stdio.h>

int main ()
{

  (void) printf("(\?\?) in a string appears as (??)\n");

  return 0;
}

The following examples shows the output if you compile this code with -xtrigraphs=yes.

example% cc -xtrigraphs=yes trigraphs_demo.c
example% a.out
(??) in a string appears as (]

The following example shows the output if you compile this code with -xtrigraphs=no.

example% cc -xtrigraphs=no trigraphs_demo.c
example% a.out
(??) in a string appears as (??)

B.2.179 -xunboundsym={yes|no}

Specify whether the program contains references to dynamically bound symbols.

-xunboundsym=yes means the program contains references dynamically bound symbols.

-xunboundsym=no means the program does not contain references to dynamically bound symbols.

The default is -xunboundsym=no.

B.2.180 -xunroll=n

Suggests to the optimizer to unroll loops n times. n is a positive integer. When n is 1, it requires the compiler not to unroll loops. When n is greater than 1, -xunroll=n suggests that the compiler unroll loops n times where appropriate.

B.2.181 -xustr={ascii_utf16_ushort|no}

Use this option if you need to support an internationalized application that uses ISO10646 UTF-16 string literals. In other words, use this option if your code contains a string literal that you want the compiler to convert to UTF-16 strings in the object file. Without this option, the compiler neither produces nor recognizes 16–bit character string literals. This option enables recognition of the U"ASCII_string" string literals as an array of type unsigned short int. Because such strings are not yet part of any standard, this option enables recognition of non-standard C.

You can turn off compiler recognition of U”ASCII_string” string literals by specifying -xustr=no. The right-most instance of this option on the command line overrides all previous instances.

The default is -xustr=no. If you specify -xustr without an argument, the compiler won’t accept it and instead issues a warning. The default can change if the C or C++ standards define a meaning for the syntax.

You can specify -xustr=ascii_utf16_ushort without also specifying a U"ASCII_string" string literals.

Specifying the flag -xustr=ascii_utf16_ushort results in an error if -std=c11 (including the default) is in effect. One of -Xc, -Xa, -Xt, -Xs, -xc99, -std=c99, -std=c89, or -ansi must also be specified when -xustr=ascii_utf16_ushort is specified.

Not all files have to be compiled with this option.

The following example shows a string literal in quotes that is prepended by U. It also shows a command line that specifies -xustr.

example% cat file.c
const unsigned short *foo = U"foo";
const unsigned short bar[] = U"bar";
const unsigned short *fun() { return foo;}
example% cc -xustr=ascii_utf16_ushort file.c -c

An 8-bit character literal can be prepended with U to form a 16-bit UTF-16 character of type unsigned short. Examples:

const unsigned short x = U'x';    
const unsigned short y = U'\x79';

B.2.182 -xvector[=a]

Enable automatic generation of calls to the vector library functions or the generation of the SIMD (Single Instruction Multiple Data) instructions on x86 processors that support SIMD. You must use default rounding mode by specifying -fround=nearest when you use this option.

The following table lists the values of a. The no% prefix disables the associated suboption.

Table B-46  The -xvector Flags
Value
Meaning
[no%]lib
(Oracle Solaris) Enable the compiler to transform math library calls within loops into single calls to the equivalent vector math routines when such transformations are possible. This could result in a performance improvement for loops with large loop counts. Use no%lib to disable this option.
[no%]simd
(SPARC) For -xarch=sparcace and -xarch=sparcaceplus, directs the compiler to use floating point and integral SIMD instructions to improve the performance of certain loops. Contrary to that of the other SPARC platforms, -xvector=simd is always effective under -xarch=sparcace and -xarch=sparcaceplus with the specification of any -xvector option, except -xvector=none and -xvector=no%simd. In addition -O greater than 3 is required for -xvector=simd, otherwise it is skipped without any warning.
For all other -xarch values, directs the compiler to use the Visual Instruction Set [VIS1, VIS2, ViS3, etc.] SIMD instructions to improve the performance of certain loops. Basically with explicit -xvector=simd option, the compiler will perform loop transformation enabling the generation of special vectorized SIMD instructions to reduce the number of loop iterations. The -xvector=simd option is effective only if -O is greater than 3 and -xarch is sparcvis3 and above. Otherwise -xvector=simd is skipped without any warning.
[no%]simd
(x86) Direct the compiler to use the native x86 SSE SIMD instructions to improve performance of certain loops. Streaming extensions are used on x86 by default at optimization level 3 and above where beneficial. Use no%simd to disable it this option.
The compiler will use SIMD only if streaming extensions exist in the target architecture; that is, if target ISA is at least SSE2. For example, you can specify -xtarget=woodcrest, —xarch=generic64, -xarch=sse2, -xarch=sse3, or -fast on a modern platform to use it. If the target ISA has no streaming extensions, the suboption will have no effect.
%none
Disable this option completely.
yes
This is deprecated, specify -xvector=lib instead.
no
This is deprecated, specify -xvector=%none instead.

The default is -xvector=simd on x86 and -xvector=%none on SPARC platforms. If you specify -xvector without a suboption, the compiler assumes -xvector=simd,lib on x86 Solaris, -xvector=lib on SPARC Solaris, and -xvector=simd on Linux platforms.

The -xvector option requires optimization level -xO3 or greater. Compilation will not proceed if the optimization level is unspecified or lower than -xO3, and a message is issued.


Note -  Compile with -xvector=%none when compiling Oracle Solaris kernel code for x86 platforms.

The compiler includes the libmvec libraries in the load step. If you compile and link in separate steps, use the same -xvector option on both commands.

B.2.183 -xvis

(SPARC) Use the -xvis=[yes|no] command when you are using the vis.h header to generate VIS instructions, or when using assembler inline code (.il) that use VIS instructions. The default is -xvis=no. Specifying -xvis is equivalent to specifying -xvis=yes.

The VIS instruction set is an extension to the SPARC-V9 instruction set. Even though the UltraSPARC processors are 64-bit, there are many cases, especially in multimedia applications, when the data are limited to 8 or 16 bits in size. The VIS instructions can process four 16-bit data with one instruction so they greatly improve the performance of applications that handle new media such as imaging, linear algebra, signal processing, audio, video, and networking.

B.2.184 -xvpara

Issues warnings about potential parallel-programming related problems that might cause incorrect results when using OpenMP. Use with -xopenmp and OpenMP API directives.

The compiler issues warnings when it detects the following situations:

  • Loops are parallelized using MP directives with data dependencies between different loop iterations

  • OpenMP data-sharing attributes clauses are problematic. For example, declaring a variable "shared" whose accesses in an OpenMP parallel region might cause a data race, or declaring a variable "private" whose value in a parallel region is used after the parallel region.

No warnings appear if all parallelization directives are processed without problems.

Example:

cc -xopenmp -vpara any.c

B.2.185 -Yc, dir

Specifies a new directory dir for the location of component c. c can consist of any of the characters representing components that are listed under the -W option.

If the location of a component is specified, then the new path name for the tool is dir/tool. If more than one -Y option is applied to any one item, then the last occurrence holds.

B.2.186 -YA, dir

Specifies a directory dir to search for all compiler components. If a component is not found in dir, the search reverts to the directory where the compiler is installed.

B.2.187 -YI, dir

Changes the default directory that is searched for include files.

B.2.188 -YP, dir

Changes the default directory for finding library files.

B.2.189 -YS, dir

Changes the default directory for startup object files.

B.2.190 -Zll

(SPARC) Creates the program database for lock_lint but does not generate executable code. Refer to the lock_lint(1) man page for more details.

B.3 Options Passed to the Linker

cc recognizes -a, -e, -r, -t, -u, and -z and passes these options and their arguments to ld. cc passes any unrecognized options to ld with a warning. On Oracle Solaris platforms, the -i option and its arguments are also passed to the linker.

B.4 User-Supplied Default Options File

The default compiler options file enables the user to specify a set of default options that are applied to all compiles, unless otherwise overridden. For example, the file could specify that all compiles default at —xO2, or automatically include the file setup.il.

At startup, the compiler searches for a default options file listing default options it should include for all compiles. The environment variable SPRO_DEFAULTS_PATH specifies a colon separated list of directories to search for the defaults file.

If the environment variable is not set, a standard set of defaults is used. If the environment variable is set but is empty, no defaults are used.

The defaults file name must be of the form compiler.defaults, where compiler is one of the following: cc, c89, c99, CC, ftn, or lint. For example, the defaults for the C compiler would be cc.defaults

If a defaults file for the compiler is found in the directories listed in SPRO_DEFAULTS_PATH, the compiler will read the file and process the options prior to processing the options on the command line. The first defaults file found will be used and the search terminated.

System administrators may create system-wide default files in Studio-install-path/lib/compilers/etc/config. If the environment variable is set, the installed defaults file will not be read.

The format of a defaults file is similar to the command line. Each line of the file may contain one or more compiler options separated by white space. Shell expansions, such as wild cards and substitutions, will not be applied to the options in the defaults file.

The value of the SPRO_DEFAULTS_PATH and the fully expanded command line will be displayed in the verbose output produced by options —#, —###, and —dryrun.

Options specified by the user on the command line will usually override options read from the defaults file. For example, if the defaults file specifies compiling with —xO4 and the user specifies —xO2 on the command line, —xO2 will be used.

Some options appearing in the default options file will be appended after the options specified on the command line. These are the preprocessor option —I, linker options —B, —L, —R, and —l, and all file arguments, such as source files, object files, archives, and shared objects.

The following is an example of how a user-supplied default compiler option startup file might be used.

demo% cat /project/defaults/cc.defaults
-I/project/src/hdrs —L/project/libs —llibproj —xvpara
demo% setenv SPRO_DEFAULTS_PATH  /project/defaults
demo% cc —c —I/local/hdrs —L/local/libs —lliblocal tst.c

This command is now equivalent to:

cc -fast —xvpara —c —I/local/hdrs —L/local/libs —lliblocal tst.c \ 
     —I/project/src/hdrs —L/project/libs —llibproj

While the compiler defaults file provides a convenient way to set the defaults for an entire project, it can become the cause of hard to diagnose problems. Set the environment variable SPRO_DEFAULTS_PATH to an absolute path rather than the current directory to avoid such problems.

The interface stability of the default options file is uncommitted. The order of option processing is subject to change in a future release.