C++ User's Guide HomeContentsPreviousNextIndex


Chapter 3

C++ Compiler Options

This chapter details the command-line options for the CC compiler running under Solaris 2.6, Solaris 7, and Solaris 8. The features described apply to all platforms except as noted; features unique to one platform are identified as SPARC or IA. See Multiplatform Release" in the preface for more information.

The following table shows examples of typical option syntax formats.

TABLE 3-1   Option Syntax Format Examples
Syntax Format Example
option -E
-optionvalue -Ipathname
-option=value -xunroll=4
-option value -o filename


The typographical conventions in TABLE P-1 are used in this section of the manual to describe individual options.

Parentheses, braces, brackets, pipe characters, and ellipses are metacharacters used in the descriptions of the options and are not part of the options themselves.

Some general guidelines for options are:

Source files, object files, and libraries are compiled and linked in the order in which they appear on the command line.

3.1 Options Summarized by Function

In this section, the compiler options are grouped by function to provide a quick reference.

3.1.1 Code Generation Options

The following code generation options are listed in alphabetical order.

TABLE 3-2   Code Generation Options  
Action Option
Sets the major release compatibility mode of the compiler. -compat
Does not expand C++ inline functions. +d
Controls virtual table generation. +e(0|1)
Compiles for use with the debugger. -g
Produces position-independent code. -KPIC
Produces position-independent code. -Kpic
Compiles and links for multithreaded code. -mt
Specifies the code address space. -xcode=a
Merges the data segment with the text segment. -xMerge
Linker option. -z arg


3.1.2 Debugging Options

The following debugging options are listed in alphabetical order.

TABLE 3-3   Debugging Options  
Action Option
Does not expand C++ inline functions. +d
Shows options passed by the driver to the compiler, but does not compile. -dryrun
Runs only the preprocessor on the C++ source files and sends result to stdout. Does not compile. -E
Compiles for use with the debugger. -g
Compiles for debugging, but doesn't disable inlining. -g0
Prints path names of included files. -H
Retains temporary files created during compilation. -keeptmp
Explains where to get information about migrating from earlier compilers. -migration
Only preprocesses source; outputs to .i file. -P
Passes an option directly to a compilation phase. -Qoption
Displays the content of the online README file. -readme
Strips the symbol table out of the executable file. -s
Defines directory for temporary files. -temp=dir
Controls compiler verbosity. -verbose=vlst
Displays a summary list of compiler options. -xhelp=flags
Turns off the Incremental Linker. -xildoff
Turns on the Incremental Linker. -xildon
Allows debugging with dbx without object (.o) files. -xs
Produces table information for the WorkShop source code browser. -xsb
Produces only source browser information, no compilation. -xsbfast


3.1.3 Floating-Point Options

The following floating-point options are listed in alphabetical order.

TABLE 3-4   Floating-Point Options  
Action Option
Disables or enables the SPARC nonstandard floating-point mode. -fns[=(no|yes)]
IA: Sets floating-point precision mode. -fprecision=p
Sets IEEE rounding mode in effect at startup. -fround=r
Sets floating-point optimization preferences. -fsimple=n
IA: Forces precision of floating-point expressions. -fstore
Sets IEEE trapping mode in effect at startup. -ftrap=tlst
IA: Disables forced precision of expression. -nofstore
Causes libm to return IEEE 754 values for math routines in exceptional cases. -xlibmieee


3.1.4 Language Options

The following language options are listed in alphabetical order.

TABLE 3-5   Language Options
Action Option
Sets the major release compatibility mode of the compiler. -compat
Enables or disables various C++ language features. -features=alst


3.1.5 Library Options

The following library linking options are listed in alphabetical order.

TABLE 3-6   Library Options  
Action Option
Requests symbolic, dynamic, or static library linking. -Bbinding
Allows or disallows dynamic libraries for the entire executable. -d(y|n)
Builds a dynamic shared library instead of an executable file. -G
Assigns a name to the generated dynamic shared library. -hname
Tells ld(1) to ignore any LD_LIBRARY_PATH setting. -i
Adds dir to the list of directories to be searched for libraries. -Ldir
Adds liblib.a or liblib.so to the linker's library search list. -llib
Forces inclusion of specific libraries and associated files into compilation and linking. -library=llst
Compiles and links for multithreaded code. -mt
Does not build path for libraries into executable. -norunpath
Builds dynamic library search paths into the executable file. -Rplst
Indicates which C++ libraries are to be linked statically. -staticlib=llst
Creates archive libraries. -xar
Causes libm to return IEEE 754 values for math routines in exceptional cases. -xlibmieee
Inlines selected libm library routines for optimization. -xlibmil
Uses library of optimized math routines. -xlibmopt
SPARC: Links in the Sun Performance LibraryTM. -xlic_lib=sunperflib
Disables linking with default system libraries. -xnolib
Cancels -xlibmil on the command line. -xnolibmil
Does not use the math routine library. -xnolibmopt
Forces fatal error if relocations remain against non-writable, allocatable sections. -ztext


3.1.6 Licensing Options

The following licensing options are listed in alphabetical order.

TABLE 3-7   Licensing Options
Action Option
Disables license queueing. -noqueue
SPARC: Links in the Sun Performance Library. -xlic_lib=sunperf
Shows license server information. -xlicinfo


3.1.7 Obsolete Options

The following options are obsolete or will become obsolete.

TABLE 3-8   Obsolete Options
Action Option
Ignored by the compiler. A future release of the compiler may reuse this option using a different behavior. -ptr
Obsolete option that will be removed in future release. -vdelx


3.1.8 Output Options

The following output options are listed in alphabetical order.

TABLE 3-9   Output Options  
Action Option
Compiles only; produces object (.o) files, but suppresses linking. -c
Shows options passed by the driver to the compiler, but does not compile. -dryrun
Runs only the preprocessor on the C++ source files and sends result to stdout. Does not compile. -E
Builds a dynamic shared library instead of an executable file. -G
Prints path names of included files. -H
Explains where to get information about migrating from earlier compilers. -migration
Sets name of the output or executable file to filename. -o filename
Only preprocesses source; outputs to .i file. -P
Causes the CC driver to produce output of the type sourcetype. -Qproduce sourcetype
Strips the symbol table out of the executable file. -s
Controls compiler verbosity. -verbose=vlst
Prints extra warnings where necessary. +w
Suppresses warning messages. -w
Displays a summary list of compiler options -xhelp=flags
Displays the contents of the online README file. -xhelp=readme
Outputs makefile dependency information. -xM
Generates dependency information, but excludes /usr/include. -xM1
Produces table information for the WorkShop source code browser. -xsb
Produces only source browser information, no compilation. -xsbfast
Reports execution time for each compilation phase. -xtime
Converts all warnings to errors by returning non-zero exit status. -xwe
Linker option. -z arg


3.1.9 Performance Options

The following performance options are listed in alphabetical order.

TABLE 3-10   Performance Options  
Action Option
Selects a combination of compilation options for optimum execution speed. -fast
Strips the symbol table out of the executable. -s
Specifies target architecture instruction set. -xarch=isa
SPARC: Defines target cache properties for the optimizer. -xcache=c
Compiles for generic SPARC architecture. -xcg89
Compiles for SPARC V8 architecture. -xcg92
Specifies target processor chip. -xchip=c
Enables linker reordering of functions. -xF
Inlines selected libm library routines for optimization. -xlibmil
Uses a library of optimized math routines. -xlibmopt
Cancels -xlibmil on the command line. -xnolibmil
Does not use the math routine library. -xnolibmopt
Specifies optimization level to level. -xOlevel
SPARC: Controls scratch register use. -xregs=rlst
SPARC: Allows no memory-based traps. -xsafe=mem
SPARC: Does not allow optimizations that increase code size. -xspace
Specifies a target instruction set and optimization system. -xtarget=t
Enables unrolling of loops where possible. -xunroll=n


3.1.10 Preprocessor Options

The following preprocessor options are listed in alphabetical order.

TABLE 3-11   Preprocessor Options  
Action Option
Defines symbol name to the preprocessor. -Dname[=def]
Runs only the preprocessor on the C++ source files and sends result to stdout. Does not compile. -E
Only preprocesses source; outputs to .i file. -P
Deletes initial definition of preprocessor symbol name. -Uname
Outputs makefile dependency information. -xM
Generates dependency information, but excludes /usr/include. -xM1


3.1.11 Profiling Options

The following profiling options are listed in alphabetical order.

TABLE 3-12   Profiling Options  
Action Option
Prepares the object code to collect data for profiling using prof. -p
Generates code for profiling. -xa
Compiles for profiling with the gprof profiler. -xpg
Collects or optimizes using runtime profiling data. -xprofile=tcov


3.1.12 Reference Options

The following options provide a quick reference to compiler information.

TABLE 3-13   Reference Options
Action Option
Explains where to get information about migrating from earlier compilers. -migration
Displays a summary list of compiler options. -xhelp=flags
Displays the contents of the online README file. -xhelp=readme


3.1.13 Source Options

The following source options are listed in alphabetical order.

TABLE 3-14   Source Options
Action Option
Adds pathname to the include file search path. -Ipathname
Outputs makefile dependency information. -xM
Generates dependency information, but excludes /usr/include. -xM1


3.1.14 Template Options

The following template options are listed in alphabetical order.

TABLE 3-15   Template Options
Action Option
Controls the placement and linkage of template instances. -instances=a
Specifies an additional search directory for the template source. -ptipath
Enables or disables various template options. -template=wlst


3.1.15 Thread Options

The following thread options are listed in alphabetical order.

TABLE 3-16   Thread Options
Action Option
Compiles and links for multithreaded code. -mt
SPARC: Allows no memory-based traps. -xsafe=mem


3.1.16 How Option Information Is Organized

To help you find information, compiler option descriptions are separated into the following subsections. If the option is one that is replaced by or identical to some other option, see the description of the other option for full details.

TABLE 3-17   Option Subsections  
Subsection Contents
Option Definition A short definition immediately follows each option. (There is no heading for this category.)
Values If the option has one or more values, this section defines each value.
Defaults If the option has a primary or secondary default value, it is stated here.
The primary default is the option value in effect if the option is not specified. For example, if -compat is not specified, the default is -compat=5.
The secondary default is the option in effect if the option is specified, but no value is given. For example, if -compat is specified without a value, the default is -compat=4.
Expansions If the option has a macro expansion, it is shown in this section.
Examples If an example is needed to illustrate the option, it is given here.
Interactions If the option interacts with other options, the relationship is discussed here.
Warnings If there are cautions regarding use of the option, they are noted here, as are actions that might cause unexpected behavior.
See also This section contains references to further information in other options or documents.
"Replace with" "Same as" If an option has become obsolete and has been replaced by another option, the replacement option is noted here. Options described this way may not be supported in future releases.
If there are two options with the same general meaning and purpose, the preferred option is referenced here. For example, "Same as -xO" indicates that -xO is the preferred option.


3.2 Option Reference

3.2.1 -386

IA: Same as -xtarget=386. This option is provided for backward compatibility only.

3.2.2 -486

IA: Same as -xtarget=486. This option is provided for backward compatibility only.

3.2.3 -a

Same as -xa.

3.2.4 -Bbinding

Specifies whether a library binding for linking is symbolic, dynamic (shared), or static (nonshared).

You can use the -B option to toggle several times on a command line. This option is passed to the linker, ld.


Note – On the Solaris 7 and Solaris 8 platforms, not all libraries are available as static libraries.

Values

binding must be one of the following:

Value of binding Meaning
dynamic
Directs the link editor to look for liblib.so (shared) files, and if they are not found, to look for liblib.a (static, nonshared) files. Use this option if you want shared library bindings for linking.
static
Directs the link editor to look only for liblib.a (static, nonshared) files. Use this option if you want nonshared library bindings for linking.
symbolic See the ld(1) man page.


(No space is allowed between -B and the binding value.)

Defaults

If -B is not specified, -Bdynamic is assumed.

Interactions

To link the C++ default libraries statically, use the -staticlib option.

The -Bstatic and -Bdynamic options affect the linking of the libraries that are provided by default. To ensure that the default libraries are linked dynamically, the last use of -B should be -Bdynamic.

Examples

The following compiler command links libfoo.a even if libfoo.so exists; all other libraries are linked dynamically:

example% CC a.o -Bstatic -lfoo -Bdynamic

Warnings

If you compile and link in separate steps and are using the -Bbinding option, you must include the option in the link step.

When building a shared library in compatibility mode (-compat[=4]), do not use -Bsymbolic if the library has exceptions in it. Exceptions that should be caught might be missed.

See also

-nolib, -staticlib, ld(1), Section 5.5 "Statically Linking Standard Libraries"," Linker and Libraries Guide

3.2.5 -c

Compile only; produce object .o files, but suppress linking.

This option directs the CC driver to suppress linking with ld and produce a .o file for each source file. If you specify only one source file on the command line, then you can explicitly name the object file with the -o option.

Examples

If you enter CC -c x.cc, the x.o object file is generated.

If you enter CC -c x.cc -o y.o, the y.o object file is generated.

Warnings

When the compiler produces object code for an input file (.c, .i), the compiler always produces a .o file in the working directory. If you suppress the linking step, the .o files are not removed.

See also

-o filename

3.2.6 -cg[89|92]

Same as -xcg[89|92].

3.2.7 -compat[=(4|5)]

Sets the major release compatibility mode of the compiler. This option controls the __SUNPRO_CC_COMPAT and __cplusplus macros.

The C++ compiler has two principal modes. The compatibility mode accepts ARM semantics and language defined by the 4.2 compiler. The standard mode accepts constructs according to the ANSI/ISO standard. These two modes are incompatible with each other because the ANSI/ISO standard forces significant, incompatible changes in name mangling, vtable layout, and other ABI details. These two modes are differentiated by the -compat option as shown in the following values.

Values

The -compat option can have the following values.

Value Meaning
-compat=4 (Compatibility mode) Set language and binary compatibility to that of the 4.0.1, 4.1, and 4.2 compilers. Set the __cplusplus preprocessor macro to 1 and the __SUNPRO_CC_COMPAT preprocessor macro to 4.
-compat=5 (Standard mode) Set language and binary compatibility to ANSI/ISO standard mode. Set the __cplusplus preprocessor macro to 199711L and the __SUNPRO_CC_COMPAT preprocessor macro to 5.


Defaults

If the -compat option is not specified, -compat=5 is assumed.

If only -compat is specified, -compat=4 is assumed.

Regardless of the -compat setting, __SUNPRO_CC is set to 0x510.

Interactions

Use of -compat[=4] with -xarch=v9, -xarch=v9a, or -xarch=v9b is not supported.

See also

C++ Migration Guide

3.2.8 +d

Does not expand C++ inline functions.

Interactions

This option is automatically turned on when you specify -g, the debugging option.

The -g0 debugging option does not turn on +d.

See also

-g0, -g

3.2.9 -Dname[=def]

Defines the macro symbol name to the preprocessor.

Using this option is equivalent to including a #define directive at the beginning of the source. You can use multiple -D options.

Values

The following tables show the predefined macros. You can use these values in such preprocessor conditionals as #ifdef.

TABLE 3-18   SPARC and IA Predefined Symbols  
Name Note
__ARRAYNEW __ARRAYNEW is defined if the "array" forms of operators new and delete are enabled. See -features=[no%]arraynew for more information.
_BOOL _BOOL is defined if type bool is enabled. See -features=[no%]bool for more information.
__BUILTIN_VA_ARG_INCR For the __builtin_alloca, __builtin_va_alist, and __builtin_va_arg_incr keywords in varargs.h, stdarg.h, and sys/varargs.h.
__cplusplus
__DATE__
__FILE__
__LINE__
__STDC__
__sun
sun See Interactions.
__SUNPRO_CC=0x510 The value of __SUNPRO_CC indicates the release number of the compiler
__SUNPRO_CC_COMPAT=(4|5) See Section 3.2.7 -compat[=(4|5)]
__SVR4
__TIME__
__'uname -s'_'uname -r' Where uname -s is the output of uname -s and uname -r is the output of uname -r with the invalid characters, such as periods (.), replaced by underscores, as in -D__SunOS_5_7 and -D__SunOS_5_8.
__unix
unix See Interactions.


TABLE 3-19   UNIX Predefined Symbols
Name Note
_WCHAR_T


TABLE 3-20   SPARC Predefined Symbols
Name Note
__sparc 32-bit compilation modes only
sparc See Interactions.


TABLE 3-21   SPARC v9 Predefined Symbols
Name Note
__sparcv9 64-bit compilation modes only


TABLE 3-22   IA Predefined Symbols
Name Note
__i386
i386 See Interactions.


Defaults

If you do not use =def, name is defined as 1.

Interactions

If +p is used, sun, unix, sparc, and i386 are not defined.

See also

-U

3.2.10 -d(y|n)

Allows or disallows dynamic libraries for the entire executable.

This option is passed to ld.

This option can appear only once on the command line.

Values

Value Meaning
-dy Specifies dynamic linking in the link editor.
-dn Specifies static linking in the link editor.


Defaults

If no -d option is specified, -dy is assumed.

See also

ld(1), Linker and Libraries Guide

3.2.11 -dalign

SPARC: Generates double-word load and store instructions whenever possible for improved performance.

This option assumes that all double type data are double-word aligned.

Warnings

If you compile one program unit with -dalign, compile all units of a program with -dalign, or you might get unexpected results.

3.2.12 -dryrun

Shows commands built by driver, but does not compile.

This option directs the driver CC to show, but not execute, the subcommands constructed by the compilation driver.

3.2.13 -E

Runs the preprocessor on source files; does not compile.

Directs the CC driver to run only the preprocessor on C++ source files, and to send the result to stdout (standard output). No compilation is done; no .o files are generated.

This option causes preprocessor-type line number information to be included in the output.

Examples

This option is useful for determining the changes made by the preprocessor. For example, the following program, foo.cc, generates the output shown in CODE EXAMPLE 3-2

CODE EXAMPLE 3-1   foo.cc
#if __cplusplus < 199711L
int power(int, int);
#else
template <> int power(int, int);
#endif
 
int main () {
  int x;
  x=power(2, 10);
}

.

CODE EXAMPLE 3-2   Output of foo.cc Using -E Option
example% CC -E foo.cc
#4 "foo.cc"
template < > int power ( int , int ) ; 
 
 
int main ( ) { 
int x ; 
x = power ( 2 , 10 ) ; 
} 

Warnings

Output from this option is not supported as input to the C++ compiler when templates are used.

See also

-P

3.2.14 +e(0|1)

Controls virtual table generation in compatibility mode (-compat[=4]). Invalid and ignored when in standard mode (the default mode).

Values

The +e option can have the following values.

Value Meaning
0 Suppresses the generation of virtual tables and creates external references to those that are needed.
1 Creates virtual tables for all defined classes with virtual functions.


Interactions

When you compile with this option, also use the -features=no%except option. Otherwise, the compiler generates virtual tables for internal types used in exception handling.

See also

C++ Migration Guide

3.2.15 -fast

Optimizes for speed of execution using a selection of options.

This option is a macro that selects a combination of compilation options for optimum execution speed on the machine upon which the code is compiled.

Expansions

This option provides near maximum performance for many applications by expanding to the following compilation options.

TABLE 3-23   -fast Expansion
Option SPARC IA
-dalign X -
-fns X -
-fsimple=2 X -
-ftrap=%none X X
-nofstore - X
-xlibmil X X
-xlibmopt X X
-xO5 X X
-xtarget=native X X


Interactions

The -fast macro expands into compilation options that may affect other specified options. For example, in the following command, the expansion of the -fast macro includes -xtarget=native which reverts -xarch to one of the 32-bit architecture options.

Incorrect:

example% CC -xarch=v9 -fast test.cc

Correct:

example% CC -fast -xarch=v9 test.cc

See the description for each option to determine possible interactions.

The code generation option, optimization level, and use of inline template files can be overridden by subsequent options (see examples). The optimization level that you specify overrides a previously set optimization level.

The -fast option includes -fns -ftrap=%none; that is, this option turns off all trapping.

Examples

The following compiler command results in an optimization level of -xO3.

example% CC -fast -xO3

The following compiler command results in an optimization level of -xO5.

example% CC -xO3 -fast

Warnings

Code that is compiled with the -fast option is not portable. For example, using the following command on an UltraSPARC-III system generates a binary that will not execute on an UltraSPARC-II system.

example% CC -fast test.cc

Do not use this option for programs that depend on IEEE standard floating-point arithmetic; different numerical results, premature program termination, or unexpected SIGFPE signals can occur.

In previous SPARC releases, the -fast macro expanded to -fsimple=1. Now it expands to -fsimple=2.

In previous releases, the -fast macro expanded to -xO4. Now it expands to -xO5.


Note – In previous SPARC releases, the -fast macro option included -fnonstd; now it does not. Nonstandard floating-point mode is not initialized by -fast. See the Numerical Computation Guide, ieee_sun(3M).

See also

-dalign, -fns, -fsimple, -ftrap=%none, -libmil, -nofstore, -xO5, -xlibmopt, -xtarget=native

3.2.16 -features=a[,...a]

Enables/disables various C++ language features named in a comma-separated list.

Values

In both compatibility mode (-compat[=4]) and standard mode (the default mode), a can have the following values.

TABLE 3-24   -features Options for Compatibility Mode and Standard Mode  
Value of a Meaning
%all All the -features options that are valid for the specified mode.
[no%]altspell [Do not] Recognize alternative token spellings (for example, "and" for "&&").
[no%]anachronisms [Do not] Allow anachronistic constructs. When disabled (that is, -features=no%anachronisms), no anachronistic constructs are allowed.
[no%]bool [Do not] Allow the bool type and literals. When enabled, the macro _BOOL=1. When not enabled, the macro is not defined.
[no%]conststrings [Do not] Put literal strings in read-only memory.
[no%]except [Do not] Allow C++ exceptions. When C++ exceptions are disabled (that is, -features=no%except), a throw-specification on a function is accepted but ignored; the compiler does not generate exception code. Note that the keywords try, throw, and catch are always reserved.
[no%]export [Do not] Recognize the keyword export.
[no%]iddollar [Do not] Allow a $ as a non-initial identifier character.
[no%]localfor [Do not] Use new local-scope rules for the for statement.
[no%]mutable [Do not] Recognize the keyword mutable.
%none Turn off all the features that can be turned off for the specified mode.


In standard mode (the default mode), a can have the following additional values.

TABLE 3-25   -features Options for Standard Mode Only
Value of a Meaning
[no%]strictdestrorder [Do not] Follow the requirements specified by the C++ standard regarding the order of the destruction of objects with static storage duration.


In compatibility mode (-compat[=4]), a can have the following additional values.

TABLE 3-26   -features Options for Compatibility Mode Only 
Value of a Meaning
[no%]arraynew [Do not] Recognize array forms of operator new and operator delete (for example, operator new [ ] (void*)). When enabled, the macro __ARRAYNEW=1. When not enabled, the macro is not defined.
[no%]explicit [Do not] Recognize the keyword explicit.
[no%]namespace [Do not] Recognize the keywords namespace and using.
[no%]rtti [Do not] Allow runtime type information (RTTI). RTTI must be enabled to use the dynamic_cast<> and typeid operators. For more information see "Runtime Type Identification" in the C++ Programming Guide.



Note – The [no%]castop setting is allowed for compatibility with makefiles written for the C++ 4.2 compiler, but has no affect on the 5.0 and Sun WorkShop 6 C++ compilers. The new style casts (const_cast, dynamic_cast, reinterpret_cast, and static_cast) are always recognized and cannot be disabled.

Defaults

If -features is not specified, the following is assumed:

See also

C++ Migration Guide

3.2.17 -flags

Same as -xhelp=flags.

3.2.18 -fnonstd

IA: Causes nonstandard initialization of floating-point hardware.

In addition, the -fnonstd option causes hardware traps to be enabled for floating-point overflow, division by zero, and invalid operations exceptions. These results are converted into SIGFPE signals; if the program has no SIGFPE handler, it terminates with a memory dump (unless you limit the core dump size to 0).

Defaults

If -fnonstd is not specified, IEEE 754 floating-point arithmetic exceptions do not abort the program, and underflows are gradual.

See also

-fns, -ftrap=common, Numerical Computation Guide.

3.2.19 -fns[=(yes|no)]

SPARC: Enables/disables the SPARC nonstandard floating-point mode.

-fns=yes (or -fns) causes the nonstandard floating point mode to be enabled when a program begins execution.

This option provides a way of toggling the use of nonstandard or standard floating-point mode following some other macro option that includes -fns, such as -fast. (See "Examples.")

On some SPARC devices, the nonstandard floating-point mode disables "gradual underflow," causing tiny results to be flushed to zero rather than to produce subnormal numbers. It also causes subnormal operands to be silently replaced by zero.

On those SPARC devices that do not support gradual underflow and subnormal numbers in hardware, -fns=yes (or -fns) can significantly improve the performance of some programs.

Values

The -fns option can have the following values.

Value Meaning
yes Selects nonstandard floating-point mode
no Selects standard floating-point mode


Defaults

If -fns is not specified, the nonstandard floating point mode is not enabled automatically. Standard IEEE 754 floating-point computation takes place--that is, underflows are gradual.

If only -fns is specified, -fns=yes is assumed.

Examples

In the following example, -fast expands to several options, one of which is -fns=yes which selects nonstandard floating-point mode. The subsequent -fns=no option overrides the initial setting and selects floating-point mode.

example% CC foo.cc -fast -fns=no

Warnings

When nonstandard mode is enabled, floating-point arithmetic can produce results that do not conform to the requirements of the IEEE 754 standard.

If you compile one routine with the -fns option, then compile all routines of the program with the -fns option; otherwise, you might get unexpected results.

This option is effective only on SPARC devices, and only if used when compiling the main program. On IA devices, the option is ignored.

Use of the -fns=yes (or -fns) option might generate the following message if your program experiences a floating-point error normally managed by the IEEE floating-point trap handlers:

See also

Numerical Computation Guide, ieee_sun(3M)

3.2.20 -fprecision=p

IA: Sets the non-default floating-point precision mode.

The -fprecision option sets the rounding precision mode bits in the Floating Point Control Word. These bits control the precision to which the results of basic arithmetic operations (add, subtract, multiply, divide, and square root) are rounded.

Values

p must be one of the following values.

Value of p Meaning
single Rounds to an IEEE single-precision value.
double Rounds to an IEEE double-precision value.
extended Rounds to the maximum precision available.


If p is single or double, this option causes the rounding precision mode to be set to single or double precision, respectively, when a program begins execution. If p is extended or the -fprecision option is not used, the rounding precision mode remains at the extended precision.

The single precision rounding mode causes results to be rounded to 24 significant bits, and double precision rounding mode causes results to be rounded to 53 significant bits. In the default extended precision mode, results are rounded to 64 significant bits. This mode controls only the precision to which results in registers are rounded, and it does not affect the range. All results in register are rounded using the full range of the extended double format. Results that are stored in memory are rounded to both the range and precision of the destination format, however.

The nominal precision of the float type is single. The nominal precision of the long double type is extended.

Defaults

When the -fprecision option is not specified, the rounding precision mode defaults to extended.

Warnings

This option is effective only on IA devices and only if used when compiling the main program. On SPARC devices, this option is ignored.

3.2.21 -fround=r

Sets the IEEE rounding mode in effect at startup.

This option sets the IEEE 754 rounding mode that:

The meanings are the same as those for the ieee_flags subroutine, which can be used to change the mode at runtime.

Values

r must be one of the following values.

Value of r Meaning
nearest Rounds towards the nearest number and breaks ties to even numbers.
tozero Rounds to zero.
negative Rounds to negative infinity.
positive Rounds to positive infinity.


Defaults

When the -fround option is not specified, the rounding mode defaults to -fround=nearest.

Warnings

If you compile one routine with -fround=r, compile all routines of the program with the same -fround=r option; otherwise, you might get unexpected results.

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

3.2.22 -fsimple[=n]

Selects floating-point optimization preferences.

This option allows the optimizer to make simplifying assumptions concerning floating-point arithmetic.

Values

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

Value of n Meaning
0 Permit no simplifying assumptions. Preserve strict IEEE 754 conformance.
1 Allow conservative simplification. The resulting code does not strictly conform to IEEE 754, but numeric results of most programs are unchanged.
With -fsimple=1, the optimizer can assume the following:

  • IEEE754 default rounding/trapping modes do not change after process initialization.

  • Computation producing no visible result other than potential floating-point exceptions can be deleted.

  • Computation with infinities or NaNs as operands needs to propagate NaNs to their results; that is, x*0 can 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 when rounding modes are held constant at runtime.
  • 2 Permit aggressive floating-point optimization that can cause many programs to produce different numeric results due to changes in rounding. For example, permit 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.


    Defaults

    If -fsimple is not designated, the compiler uses -fsimple=0.

    If -fsimple is designated but no value is given for n, the compiler uses -fsimple=1.

    Interactions

    -fast implies -fsimple=2.

    Warnings

    This option can break IEEE 754 conformance.

    See also

    -fast

    3.2.23 -fstore

    IA: This option causes the compiler to convert the value of a floating-point expression or function to the type on the left side of an assignment rather than leave the value in a register when the following is true:

    To turn off this option, use the -nofstore option.

    Warnings

    Due to roundoffs and truncation, the results can be different from those that are generated from the register values.

    See also

    -nofstore

    3.2.24 -ftrap=t[,...t]

    Sets the IEEE trapping mode in effect at startup.

    This option sets the IEEE 754 trapping modes that are established at program initialization, but does not install a SIGFPE handler. You can use ieee_handler to simultaneously enable traps and install a SIGFPE handler. When more than one value is used, the list is processed sequentially from left to right.

    Values

    t can be one of the following values.

    Value of t Meaning
    [no%]division [Do not] Trap on division by zero.
    [no%]inexact [Do not] Trap on inexact result.
    [no%]invalid [Do not] Trap on invalid operation.
    [no%]overflow [Do not] Trap on overflow.
    [no%]underflow [Do not] 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%] form of the option 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%] form of the option by itself does not explicitly cause a particular trap to be disabled.

    If you want to enable the IEEE traps, -ftrap=common is the recommended setting.

    Defaults

    If -ftrap is not specified, the -ftrap=%none value is assumed. (Traps are not enabled automatically.)

    Examples

    When one or more terms are given, the list is processed sequentially from left to right, thus -ftrap=%all,no%inexact means to set all traps except inexact.

    Interactions

    The mode can be changed at runtime with ieee_handler(3M).

    Warnings

    If you compile one routine with -ftrap=t, compile all routines of the program with the same -ftrap=t option; otherwise, you might get 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. If you wish to enable the IEEE traps, use -ftrap=common.

    See also

    ieee_handler(3M) man page

    3.2.25 -G

    Build a dynamic shared library instead of an executable file.

    All source files specified in the command line are compiled with -Kpic by default.

    When building a shared library that uses templates, it is necessary in most cases to include in the shared library those template functions that are instantiated in the template data base. Using this option automatically adds those templates to the shared library as needed.

    Interactions

    The following options are passed to ld if -c (the compile-only option) is not specified:

    Warnings

    Do not use ld -G to build shared libraries; use CC -G. The CC driver automatically passes several options to ld that are needed for C++.

    See also

    -dy, -Kpic, -xcode=pic13, -xildoff, -ztext, ld(1) man page, C++ Library Reference.

    3.2.26 -g

    Instructs both the compiler and the linker to prepare the file or program for debugging.

    The tasks include:

    Interactions

    If you use this option with -xOlevel, you will get limited debugging information. For more information, see Section 3.2.117 -xOlevel.

    If you use this option 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 this option and the optimization level is -xO4 or higher, the compiler provides best-effort symbolic information with full optimization.

    When you specify this option, the +d option is specified automatically.

    This option makes -xildon the default incremental linker option in order to speed up the compile-edit-debug cycle.

    This option invokes ild in place of ld unless any of the following are true:

    See also

    +d, -g0, -xildoff, -xildon, -xs, ld(1) man page, Debugging a Program With dbx (for details about stabs)

    3.2.27 -g0

    Compiles and links for debugging, but does not disable inlining.

    This option is the same as -g, except that +d is disabled.

    See also

    +d, -g, -xildon, Debugging a Program With dbx

    3.2.28 -H

    Prints path names of included files.

    On the standard error output (stderr), this option prints, one per line, the path name of each #include file contained in the current compilation.

    3.2.29 -help

    Same as -xhelp=flags.

    3.2.30 -hname

    Assigns the name name to the generated dynamic shared library. This is a loader option, passed to ld. In general, the name after -h should be exactly the same as the one after -o. A space between the -h and name is optional.

    The compile-time loader assigns the specified name to the shared dynamic library you are creating. It 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.

    Every executable file has a list of shared library files that are needed. When the runtime linker links the library into an executable file, the linker copies the intrinsic name from the library into that list of needed shared library files. If there is no intrinsic name of a shared library, then the linker copies the path of the shared library file instead.

    Examples

    example% CC -G -o libx.so.1 -h libx.so.1 a.o b.o c.o
    

    3.2.31 -i

    Tells the linker, ld, to ignore any LD_LIBRARY_PATH setting.

    3.2.32 -Ipathname

    Add pathname to the #include file search path.

    This option adds pathname to the list of directories that are searched for #include files with relative file names (those that do not begin with a slash).

    The preprocessor searches for #include files in the following order:

    1. For include statements of the form #include "foo.h" (where quotation marks are used), the directory containing the source file is searched

    2. For include statements of the form #include <foo.h> (where angle brackets are used), the directory containing the source file is not searched

    3. The directories named with -I options, if any

    4. The directories for compiler-provided C++ header files, ANSI C header files, and special-purpose files

    5. The /usr/include directory


      Note – The standard headers are treated differently. For more information, see Section 5.7.4 Standard Header Implementation.

    Interactions

    If -ptipath is not used, the compiler looks for template files in -Ipathname.

    Use -Ipathname instead of -ptipath.

    3.2.33 -instances=a

    Controls the placement and linkage of template instances.

    Values

    a must be one of the following values.

    Value of a Meaning
    explicit Places explicitly instantiated instances into the current object file and gives them global linkage. Does not generate any other needed instances.
    extern Places all needed instances into the template repository and gives them global linkage. (If an instance in the repository is out of date, it is reinstantiated.)
    global Places all needed instances into the current object file and gives them global linkage.
    semiexplicit Places explicitly instantiated instances into the current object file and gives them global linkage. Places all instances needed by the explicit instances into the current object file and gives them static linkage. Does not generate any other needed instances.
    static Places all needed instances into the current object file and gives them static linkage.


    Defaults

    If -instances is not specified, -instances=extern is assumed.

    See also

    Chapter 4

    3.2.34 -keeptmp

    Retains temporary files created during compilation.

    Along with -verbose=diags, this option is useful for debugging.

    See also

    -v, -verbose

    3.2.35 -KPIC

    SPARC: Same as -xcode=pic32.

    IA: Same as -Kpic.

    3.2.36 -Kpic

    SPARC: Same as -xcode=pic13.

    IA: Compiles with 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.

    3.2.37 -Ldir

    Adds dir to list of directories to search for libraries.

    This option is passed to ld. The directory dir is searched before compiler-provided directories.

    3.2.38 -llib

    Adds library liblib.a or liblib.so to the linker's list of search libraries.

    This option is passed to ld. Normal libraries have names such as liblib.a or liblib.so, where the lib and .a or .so parts are required. You should specify the lib part with this option. Put as many libraries as you want on a single command line; they are searched in the order specified with -Ldir.

    Use this option after your object file name.

    Interactions

    It is always safer to put -lx after the list of sources and objects to insure that libraries are searched in the correct order.

    Warnings

    To ensure proper library linking order, you must use -mt, rather than -lthread, to link with libthread.

    If you are using POSIX threads, you must link with the -mt and -lpthread options. The -mt option is necessary because libCrun (standard mode) and libC (compatibility mode) need libthread for a multithreaded application.

    See also

    -Ldir,-mt, C++ Library Reference, and Tools.h++ Class Library Reference

    3.2.39 -libmieee

    Same as -xlibmieee.

    3.2.40 -libmil

    Same as -xlibmil.

    3.2.41 -library=l[,...l]

    Incorporates specified CC-provided libraries into compilation and linking.

    Values

    For compatibility mode (-compat[=4]), l must be one of the following values.

    TABLE 3-27   Compatibility Mode -library Options  
    Value of l Meaning
    [no%]rwtools7 [Do not] Use Tools.h++ version 7.
    [no%]rwtools7_dbg [Do not] Use debug-enabled Tools.h++ version 7.
    [no%]complex [Do not] Use libcomplex for complex arithmetic.
    [no%]libC [Do not] Use libC, the C++ support library.
    [no%]gc [Do not] Use libgc, garbage collection.
    [no%]gc_dbg [Do not] Use debug-enabled libgc, garbage collection.
    %all -library=%all is the same as specifying -library=%none,rwtools7,complex,gc,libC.
    %none Use no C++ libraries.


    For standard mode (the default mode), l must be one of the following:

    TABLE 3-28   Standard Mode -library Options  
    Value of l Meaning
    [no%]rwtools7 [Do not] Use Tools.h++ version 7.
    [no%]rwtools7_dbg [Do not] Use debug-enabled Tools.h++ version 7.
    [no%]iostream [Do not] Use libiostream, the classic iostreams library.
    [no%]Cstd [Do not] Use libCstd, the C++ standard library. [Do not] Include the compiler-provided Cstd header files.
    [no%]Crun [Do not] Use libCrun, the C++ runtime library.
    [no%]gc [Do not] Use libgc, garbage collection.
    [no%]gc_dbg [Do not] Use debug-enabled libgc, garbage collection.
    %all -library=%all is the same as specifying -library=%none,rwtools7,gc,iostream,Cstd,Crun
    %none Use no C++ libraries, except for libCrun.


    Defaults
    Examples

    To link in standard mode without any C++ libraries (except libCrun), use:

    example% CC -library=%none
    

    To include the Rogue Wave tools.h++ version 7 library and the iostream library in standard mode:

    example% CC -library=rwtools7,iostream
    

    Interactions

    If a library is specified with -library, the proper -I paths are set during compilation. The proper -L,-Y P, -R paths and -l options are set during linking.

    Use of the -library option ensures that the -l options for the specified libraries are emitted in the right order. For example, the -l options are passed to ld in the order -lrwtool -liostream for both -library=rwtools7,iostream and -library=iostream,rwtools7.

    The specified libraries are linked before the system support libraries are linked.

    Only one Rogue Wave tools library can be used at a time.

    The Rogue Wave Tools.h++ version 7 library is built with classic iostreams. Therefore, when you include the Rogue Wave tools library in standard mode, you must also include libiostream. For more information, see the C++ Migration Guide.

    If you include both libCstd and libiostream, you must be careful to not use the old and new forms of iostreams (for example, cout and std::cout) within a program to access the same file. Mixing standard iostreams and classic iostreams in the same program is likely to cause problems if the same file is accessed from both classic and standard iostream code.

    Programs linking neither libC nor libCrun might not use all features of the C++ language.

    If -xnolib is specified, -library is ignored.

    Warnings

    The set of libraries is not stable and might change from release to release.

    See also

    -I, -l, -R, -staticlib, -xnolib, Section 2.5.3.3 "Using make With Standard Library Header Files"," C++ Library Reference, Tools.h++ User's Guide, Tools.h++ Class Library Reference, Standard C++ Class Library Reference.

    For information on using the -library=no%cstd option to enable use of your own C++ standard library, see Section 5.7 Replacing the C++ Standard Library.

    3.2.42 -migration

    Explains where to get information about migrating source code that was built for earlier versions of the compiler.

    3.2.43 -misalign

    SPARC: Permits misaligned data, which would otherwise generate an error, in memory. This is shown in the following code:

    char b[100];
    
    int f(int * ar) {
    
    return *(int *) (b +2) + *ar;
    
    }
    

    This option informs the compiler that some data in your program is not properly aligned. Thus, very conservative loads and stores must be used for any data that might be misaligned, that is, one byte at a time. Using this option may cause significant degradation in runtime performance. The amount of degradation is application dependent.

    Interactions

    When using #pragma pack on a SPARC platform to pack denser than the type's default alignment, the -misalign option must be specified for both the compilation and the linking of the application.

    Misaligned data is handled by a trap mechanism that is provided by ld at runtime. If an optimization flag (-x0[1|2|3|4|5] or an equivalent flag) is used with the -misalign option, the additional instructions required for alignment of misaligned data are inserted into the resulting object file and will not generate runtime misalignment traps.

    Warnings

    If possible, do not link aligned and misaligned parts of the program.

    If compilation and linking are performed in separate steps, the -misalign option must appear in both the compile and link commands.

    3.2.44 -mt

    Compiles and links for multithreaded code.

    This option:

    The -mt option is required if the application or libraries are multithreaded.

    Warnings

    To ensure proper library linking order, you must use this option, rather than -lthread, to link with libthread.

    If you are using POSIX threads, you must link with the -mt and -lpthread options. The -mt option is necessary because libCrun (standard mode) and libC (compatibility mode) need libthread for a multithreaded application.

    If you compile and link in separate steps and you compile with -mt, be sure to link with -mt, as shown in the following example, or you might get unexpected results.

    example% CC -c -mt myprog.cc
    
    example% CC -mt myprog.o
    

    See also

    -xnolib, C++ Programming Guide, Multithreaded Programming Guide, Linker and Libraries Guide, C++ Library Reference

    3.2.45 -native

    Same as -xtarget=native.

    3.2.46 -noex

    Same as -features=no%except.

    3.2.47 -nofstore

    IA:

    This option does not force the value of a floating-point expression or function to the type on the left side of an assignment, but leaves the value in a register when either of the following are true:

    See also

    -fstore

    3.2.48 -nolib

    Same as -xnolib.

    3.2.49 -nolibmil

    Same as -xnolibmil.

    3.2.50 -noqueue

    Disables license queueing.

    If no license is available, this option returns without queuing your request and without compiling. A nonzero status is returned for testing makefiles.

    3.2.51 -norunpath

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

    If an executable file uses shared libraries, then the compiler normally builds in a path that points the runtime linker to those shared libraries. To do so, the compiler passes the -R option to ld. The path depends on the directory where you have installed the compiler.

    This option is helpful if you have installed the compiler in some nonstandard location, and you ship an executable file to your customers. Your customers do not have to work with that nonstandard location.

    Interactions

    If you use any shared libraries under the compiler installed area (the default location is /opt/SUNWspro/lib) and you also use -norunpath, then you should either use the -R option at link time or set the environment variable LD_LIBRARY_PATH at runtime to specify the location of the shared libraries. Doing so allows the runtime linker to find the shared libraries.

    3.2.52 -O

    Same as -xO2.

    3.2.53 -Olevel

    Same as -xOlevel.

    3.2.54 -o filename

    Sets the name of the output file or the executable file to filename.

    Interactions

    When the compiler must store template instances, it stores them in the template repository in the output file's directory. For example, the following command writes the object file to ./sub/a.o and writes template instances into the repository contained within ./sub/SunWS_cache.

    example% CC -o sub/a.o a.cc
    

    The compiler reads from the template repositories corresponding to the object files that it reads. For example, the following command reads from ./sub1/SunWS_Cache and ./sub2/SunWS_cache, and, if necessary, writes to ./SunWS_cache.

    example% CC sub1/a.o sub2/b.o
    

    For more information, see Section 4.4 "The Template Repository"."

    Warnings

    The filename must have the appropriate suffix for the type of file to be produced by the compilation. It cannot be the same file as the source file, since the CC driver does not overwrite the source file.

    3.2.55 +p

    Ignore non-standard preprocessor asserts.

    Defaults

    If +p is not present, the compiler recognizes non-standard preprocessor asserts.

    Interactions

    If +p is used, the following macros are not defined:

    3.2.56 -P

    Only preprocesses source; does not compile. (Outputs a file with a .i suffix)

    This option does not include preprocessor-type line number information in the output.

    See also

    -E

    3.2.57 -p

    Prepares object code to collect data for profiling with prof.

    This option invokes a runtime recording mechanism that produces a mon.out file at normal termination.

    See also

    -xpg, -xprofile, analyzer(1) man page, Analyzing Program Performance With Sun WorkShop.

    3.2.58 -pentium

    IA: Replace with -xtarget=pentium.

    3.2.59 -pg

    Same as -xpg.

    3.2.60 -PIC

    SPARC: Same as -xcode=pic32.

    IA: Same as -Kpic.

    3.2.61 -pic

    SPARC: Same as -xcode=pic13.

    IA: Same as -Kpic.

    3.2.62 -pta

    Same as -template=wholeclass.

    3.2.63 -ptipath

    Specifies an additional search directory for template source.

    This option is an alternative to the normal search path set by -Ipathname. If the -ptipath option is used, the compiler looks for template definition files on this path and ignores the -Ipathname option.

    Using the -Ipathname option instead of -ptipath produces less confusion.

    See also

    -Ipathname

    3.2.64 -pto

    Same as -instances=static.

    3.2.65 -ptr

    This option is obsolete and is ignored by the compiler.

    Warnings

    Even though the -ptr option is ignored, you should remove -ptr from all compilation commands because, in a later release, it may be reused with a different behavior.

    See also

    For information about repository directories, see Section 4.4 "The Template Repository"."

    3.2.66 -ptv

    Same as -verbose=template.

    3.2.67 -Qoption phase option[,...option]

    Passes option to the compilation phase.

    To pass multiple options, specify them in order as a comma-separated list.

    Values

    phase must have one of the following values.

    SPARC IA
    ccfe ccfe
    iropt cg386
    cg codegen
    CClink CClink
    ld ld


    Examples

    In the following command line, when ld is invoked by the CC driver, -Qoption passes the -i and -m options to ld:

    example% CC -Qoption ld -i,-m test.c
    

    Warnings

    Be careful to avoid unintended effects. For example,

    -Qoption ccfe -features=bool,castop
    

    is interpreted as

    -Qoption ccfe -features=bool -Qoption ccfe castop
    

    The correct usage is

    -Qoption ccfe -features=bool,-features=castop
    

    3.2.68 -qoption phase option

    Same as -Qoption.

    3.2.69 -qp

    Same as -p.

    3.2.70 -Qproduce sourcetype

    Causes the CC driver to produce output of the type sourcetype.

    Sourcetype suffixes are defined below.

    Suffix Meaning
    .i Preprocessed C++ source from ccfe
    .o Object file from cg, the code generator
    .s Assembler source from cg


    3.2.71 -qproduce sourcetype

    Same as -Qproduce.

    3.2.72 -Rpathname[:...pathname]

    Builds dynamic library search paths into the executable file.

    You can have more than one pathname, such as -R/path1:/path2.

    This option is passed to ld.

    Defaults

    If the -R option is not present, the library search path that is recorded in the output object and passed to the runtime linker depends upon the target architecture instruction specified by the -xarch option (when -xarch is not present, -xarch=generic is assumed).

    -xarch Value Default Library Search Path
    v9, v9a, or v9b install_directory/SUNWspro/lib/v9
    All other values install_directory/SUNWspro/lib


    In a default installation, install-directory is /opt.

    Interactions

    If the LD_RUN_PATH environment variable is defined and the -R option is specified, then the path from -R is scanned and the path from LD_RUN_PATH is ignored.

    See also

    -norunpath, Linker and Libraries Guide

    3.2.73 -readme

    Same as -xhelp=readme.

    3.2.74 -S

    Compiles and generates only assembly code.

    This option causes the CC driver to compile the program and output an assembly source file, without assembling the program. The assembly source file is named with a .s suffix.

    3.2.75 -s

    Strips the symbol table from the executable file.

    This option removes all symbol information from output executable files. This option is passed to ld.

    3.2.76 -sb

    Replace with -xsb.

    3.2.77 -sbfast

    Same as -xsbfast.

    3.2.78 -staticlib=l[,...l]

    Indicates which C++ libraries specified in the -library option (including its defaults) are to be linked statically.

    Values

    l must be one of the following values.

    Value of l Meaning
    [no%]library See -library for the allowable values for library.
    %all

    All libraries specified in the -library option are linked statically.
    %none
    Link no libraries specified in the -library option, statically.


    Defaults

    If -staticlib is not specified, -staticlib=%none is assumed.

    Examples

    The following command line links libCrun statically because Crun is a default value for -library:

    example% CC -staticlib=Crun (correct)
    

    However, the following command line does not link libgc because libgc is not linked unless explicitly specified with the -library option:

    example% CC -staticlib=gc (incorrect)
    

    To link libgc statically, use the following command:

    example% CC -library=gc -staticlib=gc (correct)
    

    With the following command, the librwtool library is linked dynamically. Because librwtool is not a default library and is not selected using the -library option, -staticlib has no effect:

    example% CC -lrwtool -library=iostream \
    
    -staticlib=rwtools7 (incorrect)
    

    This command links the librwtool library statically:

    example% CC -library=rwtools7,iostream -staticlib=rwtools7 (correct)
    

    Interactions

    The -staticlib option only works for C++ libraries that are selected explicitly with the -library option or that are selected implicitly by default. In compatibility mode (-compat=[4]), libC is selected by default. In standard mode (the default mode), Cstd and Crun are selected by default.

    When using -xarch=v9, -xarch=v9a, or -xarch=v9b, some C++ libraries are not available as static libraries.

    Warnings

    The set of allowable values for library is not stable and might change from release to release.

    See also

    -library, Section 5.5 "Statically Linking Standard Libraries""

    3.2.79 -temp=dir

    Defines directory for temporary files.

    This option sets the name of the directory for temporary files, generated during the compilation process, to dir.

    See also

    -keeptmp

    3.2.80 -template=w[,...w]

    Enables/disables various template options.

    Values

    w must be one of the following values.

    Value of w Meaning
    [no%]wholeclass [Do not] Instantiate a whole template class, rather than only those functions that are used. You must reference at least one member of the class; otherwise, the compiler does not instantiate any members for the class.
    [no%]extdef [Do not] Search for template definitions in separate source files.


    Defaults

    If the -template option is not specified, -template=no%wholeclass,extdef is assumed.

    3.2.81 -time

    Same as -xtime.

    3.2.82 -Uname

    Deletes initial definition of the preprocessor symbol name.

    This option removes any initial definition of the macro symbol name created by -D on the command line including those implicitly placed there by the CC driver. It has no effect on any other predefined macros, nor any macro definitions in source files.

    You can specify multiple -U options on the command line.

    Interactions

    All -U options are processed after any -D options that are present.

    3.2.83 -unroll=n

    Same as -xunroll=n.

    3.2.84 -V

    Same as -verbose=version.

    3.2.85 -v

    Same as -verbose=diags.

    3.2.86 -vdelx

    Compatibility mode only (-compat[=4]):

    For expressions using delete[], this option generates a call to the runtime library function _vector_deletex_ instead of generating a call to _vector_delete_. The function _vector_delete_ takes two arguments: the pointer to be deleted and the size of each array element.

    The function _vector_deletex_ behaves the same as _vector_delete_ except that it takes a third argument: the address of the destructor for the class. This third argument is not used by the function, but is provided to be used by third-party vendors.

    Default

    The compiler generates a call to _vector_delete_ for expressions using delete[].

    Warnings

    This is an obsolete option that will be removed in future releases. Don't use this option unless you have bought some software from a third-party vendor and the vendor recommends using this option.

    3.2.87 -verbose=v[,...v]

    Controls compiler verbosity.

    Values

    v must be one of the following values.

    Value of v Meaning
    [no%]diags [Do not] Print the command line for each compilation pass.
    [no%]template
    [Do not] Turn on the template instantiation verbose mode (sometimes called the "verify" mode). The verbose mode displays each phase of instantiation as it occurs during compilation.
    [no%]version [Do not] Direct the CC driver to print the names and version numbers of the programs it invokes.
    %all Invokes all of the above.
    %none -verbose=%none is the same as -verbose=no%template,no%diags,no%version.


    You can specify more than one option, for example, -verbose=template,diags.

    Defaults

    If -verbose is not specified, -verbose=%none is assumed.

    3.2.88 +w

    Identifies code that might have unintended consequences.

    This option generates additional warnings about questionable constructs that are:

    Defaults

    If +w is not specified, the compiler warns about constructs that are almost certainly problems.

    See also

    -w, +w2

    3.2.89 +w2

    Emits all the warnings emitted by +w plus warnings about technical violations that are probably harmless, but that might reduce the maximum portability of your program.

    Warnings

    Some Solaris and C++ standard header files result in warnings when compiled with +w2.

    See also

    +w

    3.2.90 -w

    Suppresses most warning messages.

    This option causes the compiler not to print warning messages. However, some warnings, particularly warnings regarding serious anachronisms, cannot be suppressed.

    See also

    +w

    3.2.91 -xa

    Generates code for profiling.

    If set at compile time, the TCOVDIR environment variable specifies the directory where the coverage (.d) files are located. If this variable is not set, then the coverage (.d) files remain in the same directory as the source files.

    Use this option only for backward compatibility with old coverage files.

    Interactions

    The -xprofile=tcov option and the -xa option are compatible in a single executable. That is, you can link a program that contains some files that have been compiled with -xprofile=tcov, and others that have been compiled with -xa. You cannot compile a single file with both options.

    The -xa option is incompatible with -g.

    Warnings

    If you compile and link in separate steps and you compile with -xa, be sure to link with -xa, or you might get unexpected results.

    See also

    -xprofile=tcov, tcov(1) man page, Analyzing Program Performance With Sun WorkShop

    3.2.92 -xar

    Creates archive libraries.

    When building a C++ archive that uses templates, it is necessary in most cases to include in the archive those template functions that are instantiated in the template database. Using this option automatically adds those templates to the archive as needed.

    Examples

    The following command line archives the template functions contained in the library and object files.

    example% CC -xar -o libmain.a a.o b.o c.o
    

    Warnings

    Do not add .o files from the template database on the command line.

    Do not use the ar command directly for building archives. Use CC -xar to ensure that template instantiations are automatically included in the archive.

    See also

    Chapter 6

    3.2.93 -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 by allowing only the specified set of instructions. This option does not guarantee use of any target-specific instructions.

    Values

    For SPARC platforms:

    TABLE 3-29 gives the details for each of the -xarch keywords on SPARC platforms.

    TABLE 3-29   -xarch Values for SPARC Platforms  
    Value of isa Meaning
    generic
    
    Compile for good performance on most systems. This is the default. This option uses the best instruction set for good performance on most processors without major performance degradation on any of them. With each new release, the definition of "best" instruction set may be adjusted, if appropriate.
    native
    
    Compile for good performance on this system. This is the default for the -fast option. The compiler chooses the appropriate setting for the current system processor it is running on.
    v7
    
    Compile for the SPARC-V7 ISA. Enables the compiler to generate code for good performance on the V7 ISA. This is equivalent to using the best instruction set for good performance on the V8 ISA, but without integer mul and div instructions, and the fsmuld instruction.
    Examples: SPARCstation 1, SPARCstation 2
    v8a
    
    Compile for the V8a version of the SPARC-V8 ISA. By definition, V8a means the V8 ISA, but without the fsmuld instruction. This option enables the compiler to generate code for good performance on the V8a ISA.
    Example: Any system based on the microSPARC I chip architecture
    v8
    
    Compile for the SPARC-V8 ISA. Enables the compiler to generate code for good performance on the V8 architecture.
    Example: SPARCstation 10
    v8plus
    
    Compile for the V8plus version of the SPARC-V9 ISA. By definition, V8plus means the V9 ISA, but limited to the 32-bit subset defined by the V8plus ISA specification, 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 V8plus ISA.

  • The resulting object code is in SPARC-V8+ ELF32 format and only executes in a Solaris UltraSPARC environment--it does not run on a V7 or V8 processor.


    Example: Any system based on the UltraSPARC chip architecture
  • v8plusa
    
    Compile for the V8plusa version of the SPARC-V9 ISA. By definition, V8plusa means the V8plus architecture, 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, but limited to the 32-bit subset defined by the V8plus specification.

  • The resulting object code is in SPARC-V8+ ELF32 format and only executes in a Solaris UltraSPARC environment--it does not run on a V7 or V8 processor.


    Example: Any system based on the UltraSPARC chip architecture
  • v8plusb
    
    Compile for the V8plusb version of the SPARC-V8plus ISA with UltraSPARC-III extensions. 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.

  • The resulting object code is in SPARC-V8+ ELF32 format and executes only in a Solaris UltraSPARC-III environment.

  • Compiling with this option uses the best instruction set for good performance on the UltraSPARC-III architecture.

  • v9
    
    Compile for the SPARC-V9 ISA. Enables the compiler to generate code for good performance on the V9 SPARC architecture.

  • The resulting .o object files are in ELF64 format and can only be linked with other SPARC-V9 object files in the same format.

  • The resulting executable can only be run on an UltraSPARC processor running a 64-bit enabled Solaris operating environment with the 64-bit kernel.

  • -xarch=v9 is only available when compiling in a 64-bit enabled Solaris environment.

  • v9a
    
    Compile for the SPARC-V9 ISA with UltraSPARC extensions. Adds to the SPARC-V9 ISA the Visual Instruction Set (VIS) and extensions specific to UltraSPARC processors, and enables the compiler to generate code for good performance on the V9 SPARC architecture.

  • The resulting .o object files are in ELF64 format and can only be linked with other SPARC-V9 object files in the same format.

  • The resulting executable can only be run on an UltraSPARC processor running a 64-bit enabled Solaris operating environment with the 64-bit kernel.

  • -xarch=v9a is only available when compiling in a 64-bit enabled Solaris operating environment.

  • v9b
    
    Compile for the SPARC-V9 ISA with UltraSPARC-III extensions. Adds UltraSPARC-III extensions and VIS version 2.0 to the V9a version of the SPARC-V9 ISA. Compiling with this option uses the best instruction set for good performance in a Solaris UltraSPARC-III environment.

  • The resulting object code is in SPARC-V9 ELF64 format and can only be linked with other SPARC-V9 object files in the same format.

  • The resulting executable can only be run on an UltraSPARC-III processor running a 64-bit enabled Solaris operating environment with the 64-bit kernel.

  • -xarch=v9b is only available when compiling in a 64-bit enabled Solaris operating environment.


  • Also note the following:

    For any particular choice, the generated executable may run much more slowly on earlier architectures. Also, although quad-precision (REAL*16 and long double) floating-point instructions are available in many of these instruction set architectures, the compiler does not use these instructions in the code it generates.

    For IA platforms:

    TABLE 3-30 gives the details for each of the -xarch keywords on IA platforms.

    TABLE 3-30   -xarch Values for IA Platforms  
    Value of isa Meaning
    generic
    
    Compile for good performance on most systems. This is the default. This option uses the best instruction set for good performance on most processors without major performance degradation on any of them. With each new release, the definition of "best" instruction set may be adjusted, if appropriate.
    386
    
    generic and 386 are equivalent in this release.
    486
    
    Compile for the Intel PentiumPro chip.
    pentium
    
    486 and pentium are equivalent in this release.
    pentium_pro
    
    486 and pentium_pro are equivalent in this release.


    Defaults

    If -xarch=isa is not specified, -xarch=generic is assumed.

    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=v8 -xchip=ultra2 -xcache=15/32/1:512/64/1. In the following command -xarch=v8plusb overrides the -xarch=v8 that is set by the expansion of -xtarget=ultra2.

    example% CC -xtarget=ultra2 -xarch=v8plusb foo.cc
    

    Use of -compat[=4] with -xarch=v9, -xarch=v9a, or -xarch=v9b is not supported.

    Warnings

    If this option is used 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.

    3.2.94 -xcache=c

    SPARC: Defines cache properties for use by the optimizer.

    This option specifies the cache properties that the optimizer can use. It 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.

    Values

    c must be one of the following values.

    Value of c Meaning
    generic Defines the cache properties for good performance on most SPARC processors
    s1/l1/a1 Defines level 1 cache properties
    s1/l1/a1:s2/l2/a2 Defines level 1 and 2 cache properties
    s1/l1/a1:s2/l2/a2:s3/l3/a3 Defines level 1, 2, and 3 cache properties


    The definitions of the cache properties, si/li/ai, are as follows:

    Property Definition
    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


    For example, i=1 designates level 1 cache properties, s1/l1/a1.

    Defaults

    If -xcache is not specified, the default -xcache=generic is assumed. This value directs the compiler to use cache properties for good performance on most SPARC processors, without major performance degradation on any of them.

    Examples

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

    Level 1 Cache Has Level 2 Cache Has
    16 Kbytes 1024 Kbytes
    32 bytes line size 32 bytes line size
    4-way associativity Direct mapping associativity


    See also

    -xtarget=t

    3.2.95 -xcg89

    Same as -xtarget=ss2.

    Warnings

    If you compile and link in separate steps and you compile with -xcg89, be sure to link with the same option, or you might get unexpected results.

    3.2.96 -xcg92

    Same as -xtarget=ss1000.

    Warnings

    If you compile and link in separate steps and you compile with -xcg92, be sure to link with the same option, or you might get unexpected results.

    3.2.97 -xchip=c

    Specifies target processor for use by the optimizer.

    The -xchip option specifies timing properties by specifying the target processor. This option affects:

    Values

    c must be one of the following values.

    TABLE 3-31   -xchip Options  
    Platform Value of c Optimize for
    SPARC generic

    Using timing properties for good performance on most SPARC processors
    SPARC old
    Using timing properties of processors earlier than the SuperSPARC chip
    SPARC super
    Using timing properties of the SuperSPARC chip
    SPARC super2
    Using timing properties of the SuperSPARC II chip
    SPARC micro
    Using timing properties of the microSPARC chip
    SPARC micro2
    Using timing properties of the microSPARC II chip
    SPARC hyper
    Using timing properties of the hyperSPARC chip
    SPARC hyper2
    Using timing properties of the hyperSPARC II chip
    SPARC powerup
    Using timing properties of the Weitek PowerUp chip
    SPARC ultra
    Using timing properties of the UltraSPARC I chip
    SPARC ultra2
    Using timing properties of the UltraSPARC II chip
    SPARC ultra2i
    Using timing properties of the UltraSPARC IIi chip
    SPARC ultra3
    Using timing properties of the UltraSPARC III chip
    IA generic
    Using timing properties of most IA processors
    IA 386
    Using timing properties of the Intel 386 chip
    IA 486
    Using timing properties of the Intel 486 chip
    IA pentium
    Using timing properties of the Intel Pentium chip
    IA pentium_pro
    Using timing properties of the Intel Pentium Pro chip


    Defaults

    On most SPARC processors, generic is the default value that directs the compiler to use the best timing properties for good performance without major performance degradation on any of the processors.

    3.2.98 -xcode=a

    SPARC: Specifies the code address space.

    Values

    a must be one of the following values.

    TABLE 3-32   -xcode Options  
    Value of a Meaning
    abs32 Generates 32-bit absolute addresses, which are fast, but have limited range. Code + data + bss size is limited to 2**32 bytes.
    abs44 SPARC: Generates 44-bit absolute addresses, which have moderate speed and moderate range. Code + data + bss size is limited to 2**44 bytes. Available only on 64-bit architectures: -xarch=(v9|v9a|v9b)
    abs64
    SPARC: Generates 64-bit absolute addresses, which are slow, but have full range. Available only on 64-bit architectures: -xarch=(v9|v9a|v9b)
    pic13
    Generates position-independent code (small model), which is fast, but has limited range. Equivalent to -Kpic. Permits references to at most 2**11 unique external symbols on 32-bit architectures; 2**10 on 64-bit.
    pic32
    Generates position-independent code (large model), which is slow, but has full range. Equivalent to -KPIC. Permits references to at most 2**30 unique external symbols on 32-bit architectures; 2**29 on 64-bit.


    Defaults

    For SPARC V8 and V7 processors, the default is -xcode=abs32.

    For SPARC and UltraSPARC processors, when you use -xarch=(v9|v9a|v9b), the default is -xcode=abs64.

    3.2.99 -xcrossfile[=n]

    SPARC: Enables optimization and inlining across source files.

    Values

    n must be one of the following values.

    Value of n Meaning
    0 Do not perform cross-file optimizations or cross-file inlining.
    1 Perform optimization and inlining across source files.


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

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

    Defaults

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

    -xcrossfile is the same as-xcrossfile=1.

    Interactions

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

    Warnings

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

    3.2.100 -xF

    If you compile with the -xF option and then run the Analyzer, you can generate a map file that shows an optimized order for the functions. A subsequent link to build the executable file can be directed to use that map by using the linker -Mmapfile option. It places each function from the executable file into a separate section.

    Reordering the subprograms in memory is useful only when the application text page fault time is consuming a large percentage of the application time. Otherwise, reordering might not improve the overall performance of the application.

    Interactions

    The -xF option is only supported with -features=no%except (-noex).

    See also

    analyzer(1), debugger(1), ld(1) man pages

    3.2.101 -xhelp=flags

    Displays a brief description of each compiler option.

    3.2.102 -xhelp=readme

    Displays contents of the online README file.

    The README file is paged by the command specified in the environment variable, PAGER. If PAGER is not set, the default paging command is more.

    3.2.103 -xildoff

    Turns off the incremental linker.

    Defaults

    This option is assumed if you do not use the -g option. It is also assumed if you do use the -G option, or name any source file on the command line. Override this default by using the -xildon option.

    See also

    -xildon, ild(1) man page, ld(1) man page, Incremental Link Editor Guide

    3.2.104 -xildon

    Turns on the incremental linker.

    This option is assumed if you use -g and not -G, and you do not name any source file on the command line. Override this default by using the -xildoff option.

    See also

    -xildoff, ild(1) man page, ld(1) man page, Incremental Link Editor Guide

    3.2.105 -xlibmieee

    Causes libm to return IEEE 754 values for math routines in exceptional cases.

    The default behavior of libm is XPG-compliant.

    See also

    Numerical Computation Guide

    3.2.106 -xlibmil

    Inlines selected libm library routines for optimization.


    Note – This option does not affect C++ inline functions.

    There are inline templates for some of the libm library routines. This option selects those inline templates that produce the fastest executables for the floating-point option and platform currently being used.

    Interactions

    This option is implied by the -fast option.

    See also

    -fast, Numerical Computation Guide

    3.2.107 -xlibmopt

    Uses library of optimized math routines.

    This option uses a math routine library optimized for performance and usually generates faster code. The results might be slightly different from those produced by the normal math library; if so, they usually differ in the last bit.

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

    Interactions

    This option is implied by the -fast option.

    See also

    -fast, -xnolibmopt

    3.2.108 -xlic_lib=sunperf

    SPARC: Links in the Sun Performance LibraryTM.

    This option, like -l, should appear at the end of the command line, after source or object files.

    See also

    performance_library README

    3.2.109 -xlicinfo

    Shows license server information.

    This option returns the license-server name and the user ID for each user who has a license checked out. When you use this option, the compiler is not invoked, and a license is not checked out.

    If a conflicting option is used, the latest one on the command line takes precedence, and a warning is issued.

    Examples

    Do not compile; report license information:

    example% CC -c -xlicinfo any.cc
    

    Compile; do not report license information:

    example% CC -xlicinfo -c any.cc
    

    3.2.110 -Xm

    Same as -features=iddollar.

    3.2.111 -xM

    Outputs makefile dependency information.

    Examples

    The program foo.cc contains the following statement:

    #include "foo.h"
    

    When foo.c is compiled with the -xM, the output includes the following line:

    foo.o : foo.h
    

    See also

    make(1S) (for details about makefiles and dependencies)

    3.2.112 -xM1

    Generates dependency information, but excludes /usr/include.

    This is the same as -xM, except that this option does not report dependencies for the /usr/include header files.

    3.2.113 -xMerge

    SPARC: Merges the data segment with the text segment.

    The data in the object file is read-only and is shared between processes, unless you link with ld -N.

    See also

    ld(1) man page

    3.2.114 -xnolib

    Disables linking with default system libraries.

    Normally (without this option), the C++ compiler links with several system libraries to support C++ programs. With this option, the -llib options to link the default system support libraries are not passed to ld.

    Normally, the compiler links with the system support libraries in the following order:

    The order of the -l options is significant. The -lm, -lw, and -lcx options must appear before -lc.


    Note – If the -mt compiler option is specified, the compiler normally links with -lthread just before it links with -lm.

    To determine which system support libraries will be linked by default, compile with the -dryrun option. For example, the output from the following command:

    example% CC foo.cc -xarch=v9 -dryrun
    

    Includes the following in the output:

    -lCstd -lCrun -lm -lw -lc 
    

    Note that when -xarch=v9 is specified, -lcx is not linked.

    Examples

    For minimal compilation to meet the C application binary interface (that is, a C++ program with only C support required), use:

    example% CC -xnolib test.cc -lc
    

    To link libm statically into a single-threaded application with the generic architecure instruction set, use:

    Interactions

    Some static system libraries, such as libm.a and libc.a, are not available when linking with -xarch=v9, -xarch=v9a or -xarch=v9b.

    If you specify -xnolib, you must manually link all required system support libraries in the given order. You must link the system support libraries last.

    If -xnolib is specified, -library is ignored.

    Warnings

    Many C++ language features require the use of libC (compatibility mode) or libCrun (standard mode).

    This set of system support libraries is not stable and might change from release to release.

    In 64-bit compilation modes, -lcx is not present.

    See also

    -library, -staticlib, -l

    3.2.115 -xnolibmil

    Cancels -xlibmil on the command line.

    Use this option with -fast to override linking with the optimized math library.

    3.2.116 -xnolibmopt

    Does not use the math routine library.

    Examples

    Use this option after the -fast option on the command line, as in this example:

    example% CC -fast -xnolibmopt
    

    3.2.117 -xOlevel

    Specifies optimization level. In general, program execution speed depends on level of optimization. The higher the level of optimization, the faster the speed.

    If -xOlevel is not specified, only a very basic level of optimization (limited to local common subexpression elimination and dead code analysis) is performed. A program's performance might be significantly improved when it is compiled with an optimization level. Use of -xO2 (or the equivalent options -O and -O2) is recommended for most programs.

    Generally, the higher the level of optimization with which a program is compiled, the better the runtime performance. However, higher optimization levels can result in increased compilation time and larger executable files.

    In a few cases, -xO2 might perform better than the others, and -xO3 might outperform -xO4. Try compiling with each level to see if you have one of these rare cases.

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

    There are five levels that you can use with -xO. The following sections describe how they operate on the SPARC platform and the IA platform.

    Values

    On the SPARC Platform:

    On the IA Platform:

    Interactions

    If you use -g or -g0 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 or -g0 and the optimization level is -xO4 or higher, the compiler provides best-effort symbolic information with full optimization.

    Debugging with -g does not suppress -xOlevel, but -xOlevel limits -g in certain ways. For example, the -xOlevel 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 a Program With dbx.

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

    Warnings

    If you optimize at -xO3 or -xO4 with very large procedures (thousands of lines of code in a single procedure), the optimizer might require an unreasonable amount of memory. In such cases, machine performance can be degraded.

    To prevent this degradation from taking place, use the limit command to limit the amount of virtual memory available to a single process (see the csh(1) man page). For example, to limit virtual memory to 16 megabytes:

    example% limit datasize 16M
    

    This command causes the optimizer to try to recover if it reaches 16 megabytes of data space.

    The limit cannot be greater than the total available swap space of the machine, and should be small enough to permit normal use of the machine while a large compilation is in progress.

    The best setting for data size depends on the degree of optimization requested, the amount of real memory, and virtual memory available.

    To find the actual swap space, type: swap -l

    To find the actual real memory, type: dmesg | grep mem

    See also

    -fast, -xcrossfile=n, -xprofile=p, csh(1) man page

    3.2.118 -xpg

    The -xpg option compiles self-profiling code to collect data for profiling with gprof. This option invokes a runtime recording mechanism that produces a gmon.out file when the program normally terminates.

    Warnings

    If you compile and link separately, and you compile with -xpg, be sure to link with -xpg.

    See also

    -xprofile=p, analyzer(1) man page, Analyzing Program Performance With Sun WorkShop.

    3.2.119 -xprefetch[=a[,a]]

    SPARC: Enable prefetch instructions on those architectures that support prefetch, such as UltraSPARC II (-xarch=v8plus, v8plusa, v9plusb, v9, v9a, or v9b)

    a must be one of the following values.

    Value Meaning
    auto Enable automatic generation of prefetch instructions
    no%auto Disable automatic generation of prefetch instructions
    explicit Enable explicit prefetch macros
    no%explicit Disable explicit prefetch macros
    yes -xprefetch=yes is the same as -xprefetch=auto,explicit
    no -xprefetch=no is the same as -xprefetch=no%auto,no%explicit


    Defaults

    If -xprefetch is not specified, -xprefetch=no%auto,explicit is assumed.

    If only -xprefetch is specified, -xprefetch=auto,explicit is assumed.

    The default of no%auto is assumed unless explicitly overridden with the use of -xprefetch without any arguments or with an argument of auto or yes. For example, -xprefetch=explicit is the same as -xprefetch=explicit,no%auto.

    The default of explicit is assumed unless explicitly overridden with an argument of no%explicit or an argument of no. For example, -xprefetch=auto is the same as -xprefetch=auto,explicit.

    Interactions

    The sun_prefetch.h header file provides the macros for specifying explicit prefetch instructions. The prefetches will be approximately at the place in the executable that corresponds to where the macros appear.

    To use the explicit prefetch instructions, you must be on the correct architecture, include sun_prefetch.h, and either exclude -xprefetch from the compiler command or use -xprefetch=explicit or -xprefetch=yes.

    If you call the macros and include the sun_prefetch.h header file, but pass -xprefetch=no%explicit or -xprefetch=no, the explicit prefetches will not appear in your executable.

    With -xprefetch, -xprefetch=auto, and -xprefetch=yes, the compiler is free to insert prefetch instructions into the code it generates. This may result in a performance improvement on architectures that support prefetch.

    Warnings

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

    3.2.120 -xprofile=p

    Collects or optimizes with runtime profiling data.

    This option causes execution frequency data to be collected and saved during the execution. The data can then be used in subsequent runs to improve performance. This option is valid only when a level of optimization is specified.

    Values

    p must be one of the following values.

    TABLE 3-33   -xprofile Options  
    Value of p Meaning
    collect[:name]
    Collects and saves execution frequency for later use by the optimizer with -xprofile=use. The compiler generates code to measure statement execution frequency. The name is the name of the program that is being analyzed. The name is optional and, if not specified, is assumed to be a.out.
    At runtime, a program compiled with -xprofile=collect:name creates the subdirectory name.profile to hold the runtime feedback information. Data is written to the file feedback in this subdirectory. If you run the program several times, the execution frequency data accumulates in the feedback file; that is, output from prior runs is not lost.
    use[:name] Uses execution frequency data to optimize strategically. The name is the name of the executable that is being analyzed. The name is optional and, if not specified, is assumed to be a.out.
    The program is optimized by using the execution frequency data previously generated and saved in feedback files that were written by a previous execution of the program compiled with -xprofile=collect.
    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. If compiled with -xprofile=collect:name, the same program name, name, must appear in the optimizing compilation: -xprofile=use:name.
    tcov
    Basic block coverage analysis using the new style tcov.
    This option is the new style of basic block profiling for tcov. It has similar functionality to the -xa option, but correctly collects data for programs that have source code in header files or make use of C++ templates. Code instrumentation is similar to that of the -xa option, but .d files are no longer generated. Instead, a single file is generated, the name of which is based on the final executable. For example, if the program is run out of /foo/bar/myprog.profile, then the data file is stored in /foo/bar/myprog.profile/myprog.tcovd.
    When running tcov, you must pass it the -x option to force it to use the new style of data. If you do not pass -x, tcov uses the old .d files by default, and produces unexpected output.
    Unlike the -xa option, the TCOVDIR environment variable has no effect at compile time. However, its value is used at program runtime.


    Interactions

    The -xprofile=tcov and the -xa options are compatible in a single executable. That is, you can link a program that contains some files that have been compiled with -xprofile=tcov and other files compiled with -xa. You cannot compile a single file with both options.

    The code coverage report produced by -xprofile=tcov can be unreliable if there is inlining of functions due to use of -xO4.

    Warnings

    If compilation and linking are performed in separate steps, the same -xprofile option must appear in the compile as well as the link step.

    See also

    -xa, tcov(1) man page, Analyzing Program Performance With Sun WorkShop

    3.2.121 -xregs=r[,...r]

    SPARC: Controls scratch register usage.

    The compiler can generate faster code if it has more registers available for temporary storage (scratch registers). This option makes available additional scratch registers that might not always be appropriate.

    Values

    r must be one of the following values. The meaning of each value depends upon the -xarch setting.

    Value of r Meaning
    [no%]appl

    [Does not] Allow use of registers g2, g3, and g4 (v8, v8a) [Does not] Allow use of registers g2, g3, and g4 (v8plus, v8plusa, v8plusb) [Does not] Allow use of registers g2, g3 (v9, v9a, v9b)
    In the SPARC ABI, these registers are described as application registers. Using these registers can increase performance because fewer load and store instructions are needed. However, such use can conflict with programs that use the registers for other purposes.
    [no%]float

    [Does not] Allow use of floating-point registers as specified in the SPARC ABI.
    You can use the floating-point registers even if the program contains no floating point code.
    With the no%float option a source program cannot contain any floating-point code.


    Defaults

    If -xregs is not specified, -xregs=appl,float is assumed.

    Examples

    To compile an application program using all available scratch registers, use -xregs=appl,float.

    To compile non-floating-point code that is sensitive to context switch, use -xregs=no%appl,no%float.

    See also

    SPARC V7/V8 ABI, SPARC V9 ABI

    3.2.122 -xs

    Allows debugging by dbx without object (.o) files.

    This option disables Auto-Read for dbx. Use this option if you cannot keep the .o files. This option passes the -s option to the assembler.

    No Auto-Read is the older way of loading symbol tables. It places all symbol tables for dbx in the executable file. The linker links more slowly, and dbx initializes more slowly.

    Auto-Read is the newer and default way of loading symbol tables. With Auto-Read the information is placed in the .o files, so that dbx loads the symbol table information only if it is needed. Hence the linker links faster, and dbx initializes faster.

    With -xs, if you move executables to another directory, you do not have to move the object (.o) files to use dbx.

    Without -xs, if you move the executables to another directory, you must move both the source files and the object (.o) files to use dbx.

    3.2.123 -xsafe=mem

    SPARC: Allows no memory-based traps to occur.

    This option grants permission to use the speculative load instruction on V9 machines.

    Interactions

    This option is only effective if used with -xO5 optimization when -xarch=v8plus, v8plusa, v8plusb, v9, v9a, or v9b is specified.

    Warnings

    You should use this option only if you can safely assert that no memory-based traps occur in your program. For most programs, this assertion is appropriate and can be safely made. For a program that explicitly forces memory-based traps to handle exceptional conditions, this assertion is not safe.

    3.2.124 -xsb

    Produces information for the Sun WorkShop source browser.

    This option causes the CC driver to generate extra symbol table information in the SunWS_cache subdirectory for the source browser.

    See also

    -xsbfast

    3.2.125 -xsbfast

    Produces only source browser information, no compilation.

    This option runs only the ccfe phase to generate extra symbol table information in the SunWS_cache subdirectory for the source browser. No object file is generated.

    See also

    -xsb

    3.2.126 -xspace

    SPARC: Does not allow optimizations that increase code size.

    3.2.127 -xtarget=t

    Specifies the target platform for instruction set and optimization.

    The performance of some programs can 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. This is especially true 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.

    Values

    For SPARC platforms:

    On SPARC platforms, t must be one of the following values.

    Value of t Meaning
    native
    Gets the best performance on the host system.
    The compiler generates code optimized for the host system. It determines the available architecture, chip, and cache properties of the machine on which the compiler is running.
    generic Gets the best performance for generic architecture, chip, and cache. The compiler expands -xtarget=generic to: -xarch=generic -xchip=generic -xcache=generic
    This is the default value.
    platform-name Gets the best performance for the specified platform.
    Select a SPARC platform name from TABLE 3-34.


    The following table details the -xtarget SPARC platform names and their expansions.

    TABLE 3-34   SPARC Platform Names for -xtarget 
    -xtarget= -xarch -xchip -xcache
    generic generic generic generic
    cs6400 v8 super 16/32/4:2048/64/1
    entr150 v8 ultra 16/32/1:512/64/1
    entr2 v8 ultra 16/32/1:512/64/1
    entr2/1170 v8 ultra 16/32/1:512/64/1
    entr2/1200 v8 ultra 16/32/1:512/64/1
    entr2/2170 v8 ultra 16/32/1:512/64/1
    entr2/2200 v8 ultra 16/32/1:512/64/1
    entr3000 v8 ultra 16/32/1:512/64/1
    entr4000 v8 ultra 16/32/1:512/64/1
    entr5000 v8 ultra 16/32/1:512/64/1
    entr6000 v8 ultra 16/32/1:512/64/1
    sc2000 v8 super 16/32/4:2048/64/1
    solb5 v7 old 128/32/1
    solb6 v8 super 16/32/4:1024/32/1
    ss1 v7 old 64/16/1
    ss10 v8 super 16/32/4
    ss10/20 v8 super 16/32/4
    ss10/30 v8 super 16/32/4
    ss10/40 v8 super 16/32/4
    ss10/402 v8 super 16/32/4
    ss10/41 v8 super 16/32/4:1024/32/1
    ss10/412 v8 super 16/32/4:1024/32/1
    ss10/50 v8 super 16/32/4
    ss10/51 v8 super 16/32/4:1024/32/1
    ss10/512 v8 super 16/32/4:1024/32/1
    ss10/514 v8 super 16/32/4:1024/32/1
    ss10/61 v8 super 16/32/4:1024/32/1
    ss10/612 v8 super 16/32/4:1024/32/1
    ss10/71 v8 super2 16/32/4:1024/32/1
    ss10/712 v8 super2 16/32/4:1024/32/1
    ss10/hs11 v8 hyper 256/64/1
    ss10/hs12 v8 hyper 256/64/1
    ss10/hs14 v8 hyper 256/64/1
    ss10/hs21 v8 hyper 256/64/1
    ss10/hs22 v8 hyper 256/64/1
    ss1000 v8 super 16/32/4:1024/32/1
    ss1plus v7 old 64/16/1
    ss2 v7 old 64/32/1
    ss20 v8 super 16/32/4:1024/32/1
    ss20/151 v8 hyper 512/64/1
    ss20/152 v8 hyper 512/64/1
    ss20/50 v8 super 16/32/4
    ss20/502 v8 super 16/32/4
    ss20/51 v8 super 16/32/4:1024/32/1
    ss20/512 v8 super 16/32/4:1024/32/1
    ss20/514 v8 super 16/32/4:1024/32/1
    ss20/61 v8 super 16/32/4:1024/32/1
    ss20/612 v8 super 16/32/4:1024/32/1
    ss20/71 v8 super2 16/32/4:1024/32/1
    ss20/712 v8 super2 16/32/4:1024/32/1
    ss20/hs11 v8 hyper 256/64/1
    ss20/hs12 v8 hyper 256/64/1
    ss20/hs14 v8 hyper 256/64/1
    ss20/hs21 v8 hyper 256/64/1
    ss20/hs22 v8 hyper 256/64/1
    ss2p v7 powerup 64/32/1
    ss4 v8a micro2 8/16/1
    ss4/110 v8a micro2 8/16/1
    ss4/85 v8a micro2 8/16/1
    ss5 v8a micro2 8/16/1
    ss5/110 v8a micro2 8/16/1
    ss5/85 v8a micro2 8/16/1
    ss600/120 v7 old 64/32/1
    ss600/140 v7 old 64/32/1
    ss600/41 v8 super 16/32/4:1024/32/1
    ss600/412 v8 super 16/32/4:1024/32/1
    ss600/51 v8 super 16/32/4:1024/32/1
    ss600/512 v8 super 16/32/4:1024/32/1
    ss600/514 v8 super 16/32/4:1024/32/1
    ss600/61 v8 super 16/32/4:1024/32/1
    ss600/612 v8 super 16/32/4:1024/32/1
    sselc v7 old 64/32/1
    ssipc v7 old 64/16/1
    ssipx v7 old 64/32/1
    sslc v8a micro 2/16/1
    sslt v7 old 64/32/1
    sslx v8a micro 2/16/1
    sslx2 v8a micro2 8/16/1
    ssslc v7 old 64/16/1
    ssvyger v8a micro2 8/16/1
    sun4/110 v7 old 2/16/1
    sun4/15 v8a micro 2/16/1
    sun4/150 v7 old 2/16/1
    sun4/20 v7 old 64/16/1
    sun4/25 v7 old 64/32/1
    sun4/260 v7 old 128/16/1
    sun4/280 v7 old 128/16/1
    sun4/30 v8a micro 2/16/1
    sun4/330 v7 old 128/16/1
    sun4/370 v7 old 128/16/1
    sun4/390 v7 old 128/16/1
    sun4/40 v7 old 64/16/1
    sun4/470 v7 old 128/32/1
    sun4/490 v7 old 128/32/1
    sun4/50 v7 old 64/32/1
    sun4/60 v7 old 64/16/1
    sun4/630 v7 old 64/32/1
    sun4/65 v7 old 64/16/1
    sun4/670 v7 old 64/32/1
    sun4/690 v7 old 64/32/1
    sun4/75 v7 old 64/32/1
    ultra v8 ultra 16/32/1:512/64/1
    ultra1/140 v8 ultra 16/32/1:512/64/1
    ultra1/170 v8 ultra 16/32/1:512/64/1
    ultra1/200 v8 ultra 16/32/1:512/64/1
    ultra2 v8 ultra2 16/32/1:512/64/1
    ultra2/1170 v8 ultra 16/32/1:512/64/1
    ultra2/1200 v8 ultra 16/32/1:1024/64/1
    ultra2/1300 v8 ultra2 16/32/1:2048/64/1
    ultra2/2170 v8 ultra 16/32/1:512/64/1
    ultra2/2200 v8 ultra 16/32/1:1024/64/1
    ultra2/2300 v8 ultra2 16/32/1:2048/64/1
    ultra2i v8 ultra2i 16/32/1:512/64/1
    ultra3 v8 ultra3 64/32/4:8192/256/1


    For IA platforms:

    On IA platforms, -xtarget accepts the following values:

    Defaults

    On both SPARC and IA devices, if -xtarget is not specified, -xtarget=generic is assumed.

    Expansions

    The -xtarget option is a macro that permits a quick and easy specification of the -xarch, -xchip, and -xcache combinations that occur on commercially purchased platforms. The only meaning of -xtarget is in its expansion.

    Examples

    -xtarget=sun4/15 means -xarch=v8a -xchip=micro -xcache=2/16/1

    Interactions

    Compilation for SPARC V9 architecture indicated by the -xarch=v9|v9a|v9b option. Setting -xtarget=ultra or ultra2 is not necessary or sufficient. If -xtarget is specified, the -xarch=v9, v9a, or v9b option must appear after the -xtarget. For example:

    -xarch=v9 -xtarget=ultra 
    

    expands to the following and reverts the -xarch value to v8.

    -xarch=v9 -xarch=v8 -xchip=ultra -xcache=16/32/1:512/64/1
    

    The correct method is to specify -xarch after -xtarget. For example:

    -xtarget=ultra -xarch=v9
    

    3.2.128 -xtime

    Causes the CC driver to report execution time for the various compilation passes.

    3.2.129 -xunroll=n

    Enables unrolling of loops where possible.

    This option specifies whether or not the compiler optimizes (unrolls) loops.

    Values

    When n is 1, it is a suggestion to the compiler to not unroll loops.

    When n is an integer greater than 1, -unroll=n causes the compiler to unroll loops n times.

    3.2.130 -xvector[=(yes|no)]

    SPARC: Enable automatic calls to the SPARC vector library functions.

    Defaults

    The compiler defaults to -xvector=no. Specifying -xvector by itself defaults to -xvector=yes.

    Warnings

    If you compile and link in separate steps, you must use the same -xvector settings in each step.

    3.2.131 -xwe

    Converts all warnings to errors by returning nonzero exit status.

    3.2.132 -z arg

    Link editor option. For more information, see the ld(1) man page and the Solaris Linker and Libraries Guide.

    3.2.133 -ztext

    Forces a fatal error if any relocations remain against nonwritable, allocatable sections.

    This option is passed to the linker.


    Sun Microsystems, Inc.
    Copyright information. All rights reserved.
    Feedback
    Library   |   Contents   |   Previous   |   Next   |   Index