The following section alphabetically lists all the C++ compiler options and indicates any platform restrictions.
x86: Use -xtarget=386. This option is provided for backward compatibility only.
x86: Use -xtarget=486. This option is provided for backward compatibility only.
Use -xa.
Allows dynamic or requires static library linking.
This option specifies whether the linker should look for dynamic (shared) libraries or for static (archive) libraries. You can use the -B option to toggle several times on a command line. This option is passed to the linker, ld.
On the Solaris 7 platform, not all libraries available as static libraries.
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. |
(No space is allowed between -B and dynamic or static.)
If -B is not specified, -Bdynamic is assumed.
To link the C++ default libraries statically, use the -staticlib option.
This option affects the linking of libraries provided by default. To ensure that default libraries are linked dynamically, the last use of -B should be -Bdynamic.
The following compiler command links libfoo.a even if libfoo.so exists; all other libraries are linked dynamically:
demo% CC a.o -Bstatic -lfoo -Bdynamic
-nolib, -staticlib, ld(1), "Statically Linking Standard Libraries", Linker and Libraries Guide
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.
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.
-o filename
Use -xcg[89|92].
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.
-compat=4 |
(Compatibility mode) Set language and binary compatibility to that of the 4.0.1, 4.1, and 4.2 compilers. |
-compat=5 |
(Standard mode) Set language and binary compatibility to that of the 5.0 compiler. |
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 0x500.
This option controls the preprocessor __SUNPRO_CC_COMPAT=(4|5) macro.
The -xarch=v9 and the -compat[=4] options are not supported when used together.
C++ Migration Guide
Does not expand C++ inline functions.
This option is automatically turned on when you specify -g, the debugging option.
The -g0 debugging option does not turn on +d.
For large programs that rely heavily on inline functions, the amount of additional code generated can be substantial.
-g0, -g
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.
The following values are predefined for SPARC and x86:
__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_ _
_ _TIME_ _
__sun
The following values are predefined for sun
_ _SUNPRO_CC=0x500 (The value of _ _SUNPRO_CC indicates the release number of the compiler)
_ _SUNPRO_CC_COMPAT=(4|5)
_ _SVR4
_ _'uname -s'_'uname -r'(Where uname is the output of uname -s with invalid characters replaced by underscores, as in -D__SunOS_5_3; -D__SunOS_5_4)
_ _unix
The following values are predefined for UNIX
_WCHAR_T
The following values are predefined for SPARC only:
_ _sparc (32-bit compilation modes only)
The following values are predefined for SPARC v9 only:
_ _sparcv9 (64-bit compilation modes only)
The following values are predefined for x86 only:
_ _i386
You can use these values in such preprocessor conditionals as #ifdef.
If you do not use =def, name is defined as 1.
-U
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.
-dy
-dn |
Specifies dynamic linking in the link editor.
Specifies static linking in the link editor. |
If no -d option is specified, -dy is assumed.
ld(1), Linker and Libraries Guide
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.
If you compile one program unit with -dalign, compile all units of a program with -dalign, or you might get unexpected results.
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.
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.
Output from this option is not supported as input to the C++ compiler when templates are used.
-P
Controls virtual table generation when -compat=4. Invalid and ignored when -compat=5.
+e0
+e1 |
Suppresses the generation of virtual tables and creates external references to those that are needed.
Creates virtual tables for all defined classes with virtual functions. |
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.
C++ Migration Guide
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.
The criteria for the -fast option vary with the C, C++, FORTRAN 77, and Pascal compilers. See the appropriate compiler documentation for specifics.
This option provides near maximum performance for many applications by expanding to the following compilation options:
Option |
SPARC |
x86 |
|
---|---|---|---|
-dalign |
X |
- |
|
-fns |
X |
- |
|
-fsimple |
X |
- |
|
-ftrap=%none |
X |
X |
|
-nofstore |
- |
X |
|
-xlibmil |
X |
X |
|
-xlibmopt |
X |
X |
|
-xO4 |
X |
X |
|
-xtarget=native |
X |
X |
|
The -fast option expands into options that may affect options that are specified after -fast.
The code generation option, optimization level, and use of inline template files can be overridden by subsequent options. 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.
The following compiler command results in an optimization level of -xO3:
demo% CC -fast -xO3
The following compiler command results in an optimization level of -xO4:
demo% CC -xO3 -fast
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 option included -fnonstd; now it does not. Nonstandard floating-point mode is not initialized by -fast. See the Numerical Computation Guide, ieee_sun(3M).
-dalign, -fns, -fsimple, -ftrap=%none, -libmil, -nofstore, -xO4, -xlibmopt, -xtarget=native
Enables/disables various C++ language features named in a comma-separated list.
For compat=4 only, a can be one of the following values:
Value of a |
Meaning |
---|---|
[no%]namespace |
[Do not] Recognize the keywords namespace and using. |
[no%]rtti |
[Do not] Allow runtime type information (RTTI). |
For compat=4 and compat=5, a can be one of the following values:
Value of a |
Meaning |
---|---|
[no%]altspell
[no%]arraynew
[no%]anachronisms
[no%]bool
[no%]conststrings
[no%]except
[no%]explicit
[no%]export
[no%]iddollar
[no%]localfor
[no%]mutable |
[Do not] Recognize alternative token spellings (for example, "and" for "&&").
[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.
[Do not] Allow anachronistic constructs.
[Do not] Allow the bool type and literals.
[Do not] Put literal strings in read-only memory.
[Do not] Allow C++ exceptions.
[Do not] Recognize the keyword explicit.
[Do not] Recognize the keyword export.
[Do not] Allow a $ as a non-initial identifier character.
[Do not] Use new local-scope rules for the for statement.
[Do not] Recognize the keyword mutable. |
[no%]castop is allowed for compatibility with makefiles written for the C++ 4.2 compiler, but has no affect on the 5.0 compiler. The new style casts (const_cast, dynamic_cast, reinterpret_cast, and static_cast) are always recognized and cannot be disabled.
When -features=arraynew is enabled, the macro _ARRAYNEW=1 is defined; when disabled, the macro is not defined.
When -features=bool is enabled, the macro _BOOL=1 is defined; when disabled, the macro is not defined.
When -features=no%anachronisms is enabled, no anachronistic constructs are allowed.
When -features=except is disabled, a throw-specification on a function is accepted but ignored. The keywords try, throw, and catch are always reserved.
If -features is not specified, the following is assumed:
Compatibility mode (compat=4 or compat):
-features=%none,anachronisms,no%conststrings,except
Standard mode (compat=5 or no compat option specified):
-features=%all,conststrings,no%iddollar
C++ Migration Guide
Same as -help.
The -flags option displays a brief description of each compiler option.
-help, -readme, -migration.
x86: 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).
If -fnonstd is not specified, IEEE 754 floating-point arithmetic exceptions do not abort the program, and underflows are gradual.
-fns, -ftrap=common, Numerical Computation Guide.
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.
yes
no |
Selects nonstandard floating-point mode
Selects standard floating-point mode |
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.
To use the -fns option following some other macro option that includes -fns, such as -fast:
demo% CC foo.cc -fast -fns=no
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 x86 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:
Note: Nonstandard floating-point mode enabled See the Numerical Computation Guide, ieee_sun(3M)
Numerical Computation Guide
x86: 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.
p must be one of the following:
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.
When the -fprecision option is not specified, the rounding precision mode defaults to extended.
This option is effective only on x86 devices and only if used when compiling the main program. On SPARC devices, this option is ignored.
Sets the IEEE rounding mode in effect at start-up.
This option sets the IEEE 754 rounding mode that:
Can be used by the compiler in evaluating constant expressions
Is established at runtime during the program initialization
The meanings are the same as those for the ieee_flags subroutine, which can be used to change the mode at runtime.
r must be one of the following:
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. |
When the -fround option is not specified, the rounding mode defaults to -fround=nearest.
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.
Selects floating-point optimization preferences.
This option allows the optimizer to make simplifying assumptions concerning floating-point arithmetic.
If n is present, it must be 0, 1, or 2.
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.
-fast implies -fsimple=1.
This option can break IEEE 754 conformance.
-fast
x86: Forces precision of floating-point expressions.
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:
The expression or function is assigned to a variable.
The expression is cast to a shorter floating-point type.
To turn off this option, use the -nofstore option.
Due to roundoffs and truncation, the results can be different from those that are generated from the register values.
-nofstore
Sets the IEEE trapping mode in effect at start-up.
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.
t is a comma-separated list that consists of one or more of the following:
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 wish to enable the IEEE traps, -ftrap=common is the recommended setting.
If -ftrap is not specified, the -ftrap=%none value is assumed. (Traps are not enabled automatically.)
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.
The mode can be changed at runtime with ieee_handler(3M).
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.
ieee_handler(3M) man page
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.
The following options are passed to ld if -c (the compile-only option) is not specified:
-dy
-G
-R
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++.
-dy, -Kpic, -xcode=pic13, -xildoff, -ztext, ld(1) man page, C++ Library Reference.
Instructs both the compiler and the linker to prepare the file or program for debugging.
The tasks include:
Producing detailed information, known as stabs, in the symbol table of the object files and the executable
Producing some "helper functions," which the debugger can call to implement some of its features
Disabling the inline generation of functions
Disabling certain levels of optimization
You can use this option with -xO to get the optimization level that you desire.
If you use this option with -xO, you will get limited debugging information.
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:
The -G option is present
The -xildoff option is present
Any source files are named on the command line
+d, -g0, -xildoff, -xildon, -xs, ld(1) man page, Debugging a Program With dbx (for details about stabs)
Compiles and links for debugging, but doesn't disable inlining.
This option is the same as -g, except that +d is disabled.
+d, -g, -xildon, Debugging a Program With dbx
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.
Displays a summary list of compiler options.
This option displays a brief description of each compiler option.
-flags, -readme, C++ Migration Guide
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.
demo% CC -G -o libx.so.1 -h libx.so.1 a.o b.o c.o
Tells the linker, ld, to ignore any LD_LIBRARY_PATH setting.
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:
For includes of the form #include "foo.h" (where quotation marks are used), the directory containing the source file is searched
For includes of the form #include <foo.h> (where angle brackets are used), the directory containing the source file is not searched
The directories named with -I options, if any
The standard directory for C++ header files at the following default directory: /opt/SUNWspro/SC5.0/include/CC
Special-purpose files: /opt/SUNWspro/SC5.0/include/cc
In /usr/include
If -ptipath is not used, the compiler looks for template files in -Ipathname.
Use -Ipathname instead of -ptipath.
Use -xinline=rlst.
Controls the placement and linkage of template instances.
a must be one of the following:
Value of a |
Meaning |
---|---|
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.) |
explicit |
Places explicitly instantiated instances into the current object file and gives them global linkage. Does not generate any other needed instances. |
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. |
If -instances is not specified, -instances=extern is assumed.
For all values other than extern, the template definitions must be included (directly or indirectly) within the current compilation unit. The compiler silently skips the instantiation if the definition is not available.
Chapter 4, Compiling Templates
Retains temporary files created during compilation.
Along with -verbose=diags, this option is useful for debugging.
-v, -verbose
SPARC: Same as -xcode=pic32.
x86: Same as -Kpic.
SPARC: Same as -xcode=pic13.
x86: 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.
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.
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.
It is always safer to put -lx after the list of sources and objects to insure that libraries are searched in the correct order.
-Ldir, C++ Library Reference, and Tools.h++ Class Library Reference
Use -xlibmieee.
Use -xlibmil.
Incorporates specified CC-provided libraries into compilation and linking.
For -compat=4, l must be one of the following:
Value of l |
Meaning |
---|---|
[no%]rwtools7 |
[Do not] Use Tools.h++ v 7 |
[no%]rwtools7_dbg |
[Do not] Use debug-enabled Tools.h++ v 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 |
The same as %none, rwtools7, complex, gc, libC |
%none |
Use no C++ libraries |
For -compat=5, l must be one of the following:
Value of l |
Meaning |
---|---|
[no%]rwtools7 |
[Do not] Use Tools.h++ v 7 |
[no%]rwtools7_dbg |
[Do not] Use debug-enabled Tools.h++ v 7 |
[no%]iostream |
[Do not] Use libiostream, the classic iostreams library |
[no%]Cstd |
[Do not] Use libCstd, the C++ standard library |
[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 |
Same as %none, rwtools7, gc,iostream, Cstd,Crun |
%none |
Use no C++ libraries, except for libCrun |
For -compat=4, if -library is not specified, -library=%none,libC.The libC library always is included unless specifically excluded using -library=%none or -library=no%libC.
For -compat=5, if -library is not specified, -library=%none,Cstd,Crun.The libCstd library always is included unless specifically excluded using -library=%none or -library=no%Cstd. The libCrun library always is included unless specifically excluded using -library=no%Crun.
To link in standard mode without any C++ libraries (except libCrun), use:
demo% CC -library=%none
To include the Rogue Wave tools.h++ v7 and iostream libraries in standard mode:
demo% CC -library=rwtools7,iostream
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 system support libraries.
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.
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.
The set of libraries is not stable and might change from release to release.
-I, -l, -R, -staticlib, -xnolib, "Using make With iostreams", C++ Library Reference, Tools.h++ User's Guide, Tools.h++ Class Library Reference, Standard C++ Library Reference
Explains where to get information about migrating source code to C++ 5.0.
C++ Migration Guide: C++ 4.2 to C++ 5.0 contains information about incompatibilities between versions 4.0.1, 4.1, and 4.2 of the compiler and the 5.0 compiler.
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; }
Very conservative loads and stores must be used for the data, that is, one byte at a time. Using this option can cause significant degradation in performance when you run the program.
If possible, do not link aligned and misaligned parts of the program.
Compiles and links for multithreaded code.
This option compiles source files with -D_REENTRANT and augments the set of support libraries to include -lthread in the required order.
To ensure proper library linking order, use this option, rather than -lthread, to link with libthread.
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.
demo% CC -c -mt myprog.cc demo% CC -mt myprog.o
-xnolib, Multithreaded Programming Guide, Linker and Libraries Guide, C++ Library Reference
Use -xtarget=native.
Use -features=no%except.
x86: Disables forced precision of an expression.
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:
The expression or function is assigned to a variable.
The expression or function is cast to a shorter floating-point type.
-fstore
Use -xnolib.
Use -xnolibmil.
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.
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 don't have to work with that nonstandard location.
If you use any shared libraries under the compiler installed area (default location /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.
Same as -xO2.
Use -xOlevel.
Sets the name of the output file or the executable file to filename.
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.
Disallows preprocessor asserts.
If +p is not present, preprocessor asserts are allowed.
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.
-E
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.
-xpg, analyzer(1) man page.
x86: Replace with -xtarget=pentium.
Use -xpg.
Use -KPIC.
Use -Kpic.
Use -template=wholeclass.
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.
-Ipathname
Use -instances=static.
Specifies the directory of the template repository.
The template repository is contained within the SunWS_config or SunWS_cache subdirectory of the given directory. The template repository cache files are stored in directory/SunWS_cache. The template repository configuration files are stored in directory/SunWS_config.
You cannot use multiple -ptr options.
-ptr/tmp/Foo specifies the repository subdirectories /tmp/Foo/SunWS_cache and /tmp/Foo/SunWS_config.
The subdirectory names can be changed with the environment variables SUNWS_CACHE_NAME and SUNWS_CONFIG_NAME.
If you compile and link in separate steps, and use -ptr to compile, you must also use -ptr to link.
Use -verbose=template.
Passes option to the compilation phase.
To pass multiple options, specify them in order as a comma-separated list.
phase must have one of the following values:
SPARC Architecture
ccfe iropt cg CClink ld |
x86 Architecture
ccfe cg386 codegen CClink ld |
In the following command line, when ld is invoked by the CC driver, -Qoption passes the -i and -m options to ld:
demo% CC -Qoption ld -i,-m test.c
Use -Qoption.
Same as -p.
Causes the CC driver to produce output of the type sourcetype.
Sourcetype suffixes are defined below.
Suffix
.i
.o
.s |
Meaning
Preprocessed C++ source from ccfe
Object file from cg, the code generator
Assembler source from cg |
Use -Qproduce.
Builds dynamic library search paths into the executable file.
Multiple instances of -Rpathname are concatenated, with each pathname separated by a colon.
This option is passed to ld.
If the -R option is not present, the library search path that is 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 or v9a |
install_dir/SUNWspro/lib/v9 |
All other values |
install_dir/SUNWspro/lib |
With a standard install, install-path is /opt.
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.
-norunpath, Linker and Libraries Guide
Displays the content of the 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.
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.
Strips the symbol table from the executable file.
This option removes all symbol information from output executable files. This option is passed to ld.
Replace with -xsb.
Use -xsbfast.
Indicates which C++ libraries are to be linked statically.
l must be one of the following:
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. |
If -staticlib is not specified, -staticlib=%none is assumed.
The following command line links libCrun statically because Crun is a default value for -library:
demo% CC -staticlib=Crun
However, the following command line does not link libgc because libgc is not linked unless explicitly specified with the -library option:
demo% CC -staticlib=gc
To link libgc statically, use the following command:
demo% CC -library=gc -staticlib=gc
If you select C++ libraries explicitly with the -library option or implicitly through its defaults, you must also specify -staticlib to link these libraries statically. If a you specify a library with -staticlib but have not selected it with -library or its defaults, the library is not linked. Refer to the examples.
In the Solaris 7 operating environment, some C++ libraries are not available as static libraries.
This set of libraries is not stable and might change from release to release.
-library, "Statically Linking Standard Libraries"
Defines directory for temporary files.
This option sets the name of the directory for temporary files, generated during the compilation process, to dir.
-keeptmp
Enables/disables various template options.
w must be wholeclass or no%wholeclass.
[no%]wholeclass
|
Does [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. |
Use -xtime.
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.
This option is order-sensitive if used with the -D option, and is processed after all -D options are processed.
Same as -xunroll=n.
Same as -verbose=version.
Same as -verbose=diags.
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.
The compiler generates a call to _vector_delete_ for expressions using delete[].
This is an obsolete option that will be removed in future releases. This option is available only for -compat=4. Don't use this option unless you have bought some software from a third-party vendor and the vendor recommends using this option.
Controls compiler verbosity.
v must be one of the following values.
Value of v |
Meaning |
---|---|
[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. Use this option if you are new to templates.
|
[no%]diags
|
[Do not] Print the command line for each compilation pass.
|
[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 |
Invokes none of the above. |
You can specify more than one option, for example, -verbose=template,diags.
If -verbose is not specified, -verbose=%none is assumed.
Prints extra warnings where necessary.
This option generates additional warnings about questionable constructs that are:
Nonportable
Likely to be mistakes
Inefficient
If +w is not specified, the compiler warns about constructs that are almost certainly problems.
-w, +w2
Prints even more warnings.
+w
Suppresses warning messages.
This option causes the compiler not to print warning messages. However, some warnings, particularly warnings regarding serious anachronisms cannot be suppressed.
+w
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.
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 others that have been compiled with -xa. You cannot compile a single file with both options.
-xa is incompatible with -g.
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.
-xprofile=tcov, tcov(1) man page, Analyzing Program Performance With Sun WorkShop
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.
The following command line archives the template functions contained in the library and object files.
demo% CC -xar -o libmain.a a.o b.o c.o
Do not add .o files from the template data base 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.
Chapter 6
Specifies the target architecture instruction set.
Although this option can be used alone, its primary use is to override a value supplied by the -xtarget option.
This option limits the instructions generated to those appropriate to the specified architecture, and it allows the specified set of instructions. The option does not guarantee an instruction will be used; however, under optimization, it is usually used.
a must be one of the following:
Platform |
Value of a |
---|---|
SPARC |
generic, v7, v8a, v8, v8plus, v8plusa, v9, v9a |
x86 |
generic, 386, 486, pentium, pentium_pro |
SPARC architectures v7, v8a, and v8 are all binary compatible. v8plus and v8plusa are binary compatible with each other, and they are forward, but not backward, compatible.
For any particular choice, the generated executable might run much more slowly on earlier architectures.
generic and 386 are equivalent in this release.
486, pentium, or pentium_pro directs the compiler to issue instructions for the Intel PentiumPro chip.
If -xarch=a is not specified, -xarch=generic is assumed.
The -xarch=v9 option and the -compat[=4] options are not supported when used together.
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.
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.
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.
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:
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.
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.
-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 |
-xtarget=t
SPARC: Compiles for generic SPARC or SPARC V8 architecture.
This option specifies the code generator for floating-point hardware in SPARC devices released in 1989 or 1992. Use the fpversion command to determine which floating-point hardware you have. If you compile one procedure of a program with this option, it does not mean that you must compile all the procedures of that program in the same way.
-xg89 generates code to run on generic SPARC architecture.
-xg92 generates code to run on SPARC V8 architecture.
The option -xcg89 is a macro for -xtarget=ss2, which is equivalent to -xarch=v7 -xchip=old -xcache=64/32/1.
The option -xcg92 is a macro for -xtarget=ss1000, which is equivalent to
-xarch=v8 -xchip=super -xcache=16/64/4:1024/64/1.
If you compile and link in separate steps and you compile with -xcg89 or -xcg92, be sure to link with the same option, or you might get unexpected results.
Specifies target processor for use by the optimizer.
The -xchip option specifies timing properties by specifying the target processor. This option affects:
The ordering of instructions--that is, scheduling
The way the compiler uses branches
The instructions to use in cases where semantically equivalent alternatives are available
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.
The following table lists the valid values for c.
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(TM) 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(TM) 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 |
x86 |
generic |
Using timing properties of most x86 processors |
x86 |
386 |
Using timing properties of the Intel 386 chip |
x86 |
486 |
Using timing properties of the Intel 486 chip |
x86 |
pentium |
Using timing properties of the Intel Pentium chip |
x86 |
pentium_pro |
Using timing properties of the Intel Pentium Pro chip
|
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 them.
SPARC: Specifies the code address space.
a must be one of the following:
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) |
abs64
|
SPARC: Generates 64-bit absolute addresses, which are slow, but have full range. Available only on 64-bit architectures: -xarch=(v9|v9a) |
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. |
For SPARC V8 and V7 processors, the default is -xcode=abs32.
For SPARC and UltraSPARC processors (with -xarch=(v9|v9a)), the default is -xcode=abs64.
When building shared dynamic libraries with -xarch=v9 or -xarch=v9a using 64-bit Solaris 7 software, the -xcode=pic13 or -xcode=pic32 (or -pic or -PIC) option must be specified.
Enables reordering of functions by the linker.
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.
The -xF option is only supported with -features=no%except (-noex).
analyzer(1), debugger(1), ld(1) man pages
Same as -help. Displays list of compiler options.
Same as -readme. Displays contents of online readme file.
Turns off the incremental linker.
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.
-xildon, ild(1) man page, ld(1) man page, Incremental Link Editor Guide
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.
-xildoff, ild(1) man page, ld(1) man page, Incremental Link Editor Guide
Inlines specified routines.
This option does not affect C++ inline functions and is not related to the +d option.
This option instructs the optimizer to inline the user-written functions and subroutines specified in a comma-separated list. Inlining is an optimization technique whereby the compiler effectively replaces a function call with the actual subprogram code itself. Inlining often provides the optimizer more opportunities to produce efficient code.
The following restrictions apply--no warning is issued:
The compiler determines if actual inlining is advantageous or safe.
The source for the routine must be in the file being compiled.
demo% cat example.cc static int twice ( int i ) { return 2*i; } int main() {return twice( 3 ); } demo% CC -compat=4 -O example.cc demo% nm -C a.out | grep twice[37] | 68068| 8|FUNC |LOCL |0 |7 |twice(int) [__0FFtwicei] demo% CC -compat=4 -O -xinline=__0FFtwicei example.cc
If a function specified in the list is not declared as extern "C", the function name should be mangled. You can use the nm command on the executable file to find the mangled function names. For functions declared as extern "C", the names are not mangled by the compiler.
The -xinline option has no effect for optimization levels below -xO3. At -xO4, the optimizer decides which functions should be inlined, and does so without the -xinline option being specified. At -xO4, the compiler also attempts to determine which functions will improve performance if they are inlined. If you force inlining of a function with -xinline, you might actually diminish performance.
nm(1), +d
Causes libm to return IEEE 754 values for math routines in exceptional cases.
The default behavior of libm is XPG-compliant.
Numerical Computation Guide
Inlines selected libm library routines for optimization.
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.
Numerical Computation Guide
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.
This option is implied by the -fast option.
-fast, -xnolibmopt
Links with the Sun-supplied, licensed library specified by l.
This option, like -l, should appear at the end of the command line, after source or object files.
To link with the Sun(TM) Performance Library(TM):
demo% CC program.cc -xlic_lib=sunperf
performance_library README
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.
Do not compile; report license information:
CC -c -xlicinfo any.cc
Compile; do not report license information:
CC -xlicinfo -c any.cc
Use -features=iddollar.
Outputs makefile dependency information.
When you compile the following code, hello.c,
#include <cstdio> using std::printf; int main () { printf ("Hello World!\n"); }
with this option:
demo% CC -xM hello.c
the output shows the dependencies:
hello.o : hello.c hello.o : /opt/SUNWspro/SC5.0/include/CC/cstdio hello.o : /usr/include/sys/va_list.h
make(1) (for details about makefiles and dependencies)
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.
When you compile the code sample shown for the -xM option:
% CC -xM1 hello.c
the output is:
hello.o: hello.c
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.
ld(1) man page
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 following libraries in the following order:
For compat=4:
-lC -lC_mtstubs -lm -lw -lcx -lc
For compat=5:
-lCstd -lCrun -lC_mtstubs -lm -lw -lcx -lc
The order of the -l options is significant. The -lm, -lw,and -lcx options must appear before -lc.
If the -mt compiler option is specified, then -lthread is passed instead of -lC_mtstubs.
For minimal compilation to meet the C application binary interface (that is, a C++ program with only C support required) use:
demo% CC -xnolib test.cc -lc
To link libm statically into a single-threaded application on SPARC V8 architecure, use:
demo% CC -xnolib -Bstatic -lm -Bdynamic -lC_mtstubs -lw -lcx -lc
To link libm and libw statically, and link others dynamically:
demo% CC -xnolib -Bstatic -lm -lw -Bdynamic -lcx -lc
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.
This set of libraries is not stable and might change from release to release.
-lcx is not present in 64-bit compilation modes.
-library, -staticlib, -l
Cancels -xlibmil on the command line.
Use this option with -fast to override linking with the optimized math library.
Does not use the math routine library.
Use this option after the -fast option on the command line, as in:
demo% CC -fast -xnolibmopt
Specifies optimization level. In general, program execution speed depends on level of optimization. The higher the level of optimization, the faster the speed.
If -xO[level] 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 -O (which implies -xO2) 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 -xO option.
There are five levels that you can use with -xO. The following sections describe how they operate on the SPARC platform and the x86 platform.
On the SPARC Platform:
-xO is equivalent to -xO2.
-xO1 does only the minimum amount of optimization (peephole), which is postpass, assembly-level optimization. Do not use -xO1 unless using -xO2 or -xO3 results in excessive compilation time, or you are running out of swap space.
-xO2 does basic local and global optimization, which includes:
Induction-variable elimination
Local and global common-subexpression elimination
Algebraic simplification
Copy propagation
Constant propagation
Loop-invariant optimization
Register allocation
Basic block merging
Tail recursion elimination
Dead-code elimination
Tail-call elimination
Complicated expression expansion
This level does not optimize references or definitions for external or indirect variables. In general, this level results in minimum code size.
-xO3, in addition to optimizations performed at the -xO2 level, also optimizes references and definitions for external variables. This level does not trace the effects of pointer assignments. When compiling either device drivers that are not properly protected by volatile or programs that modify external variables from within signal handlers, use -xO2. In general, -xO3 results in increased code size. If you are running out of swap space, use -xO2.
-xO4 does automatic inlining of functions contained in the same file in addition to performing -xO3 optimizations. This automatic inlining usually improves execution speed but sometimes makes it worse. In general, this level results in increased code size.
-xO5 generates the highest level of optimization. It is suitable only for the small fraction of a program that uses the largest fraction of computer time. This level uses optimization algorithms that take more compilation time or that do not have as high a certainty of improving execution time. Optimization at this level is more likely to improve performance if it is done with profile feedback. See "-xprofile=p".
On the x86 Platform:
-xO1 preloads arguments from memory and causes cross jumping (tail merging), as well as the single pass of the default optimization.
-xO2 schedules both high- and low-level instructions and performs improved spill analysis, loop memory-reference elimination, register lifetime analysis, enhanced register allocation, global common subexpression elimination, as well as the optimization done by level 1.
-xO3 performs loop strength reduction and inlining, as well as the optimization done by level 2.
-xO4 performs architecture-specific optimization, as well as the optimization done by level 3.
-xO5 generates the highest level of optimization. It uses optimization algorithms that take more compilation time or that do not have as high a certainty of improving execution time.
Debugging with -g does not suppress -xO[level], but -xO[level] limits -g in certain ways.
The -xO3 and -xO4 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.
The -xinline option has no effect for optimization levels below -xO3. At -xO4, the optimizer decides which functions should be inlined, and does so without the -xinline option being specified. At -xO4, the compiler also attempts to determine which functions will improve performance if they are inlined. If you force inlining of a function with -xinline, you might actually diminish performance.
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:
demo% 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
-fast, -xprofile=p, csh(1) man page
Compiles for profiling with the gprof profiler.
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.
If you compile and link separately, and you compile with -xpg, be sure to link with -xpg.
-xprofile=p, analyzer(1) man page
SPARC: Uses prefetch instructions on UltraSPARC II processors.
With -xprefetch=yes, the compiler is free to insert prefetch instructions into the code it generates. This can result in a performance improvement on UltraSPARC II processors.
If the -xprefetch option is not specified, the default is -xprefetch=no.
Specifying -xprefetch alone is equivalent to -xprefetch=yes.
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.
p must be one of the following:
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. This name is optional. If not specified, a.out is assumed to be the name of the executable.
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 don't, 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.
|
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.
-xprofile=tcov is incompatible with -g.
If compilation and linking are performed in separate steps, the same -xprofile option must appear in the compile as well as the link step.
-xa, tcov(1) man page, Analyzing Program Performance With Sun WorkShop
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.
r must be one of the following (meaning depends upon the -xarch setting):
Value of r |
Meaning |
---|---|
[no%]appl
|
[Does not] Allows use of registers g2, g3, and g4 (v8, v8a) [Does not] Allows use of registers g2, g3, g4, and g5 (v8plus, v8plusa) [Does not] Allows use of registers g2, g3 (v9, v9a)
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] Allows 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. |
If -xregs is not specified, -xregs=appl,float is assumed.
To compile an application program using all available scratch registers, use:
-xregs=appl,float
To compile non-floating-point code sensitive to context switch, use:
-xregs=no%appl,no%float
SPARC V7/V8 ABI, SPARC V9 ABI
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 around. 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.
SPARC: Allows no memory-based traps to occur.
This option grants permission to use the speculative load instruction on V9 machines.
This option is only effective if used with -xO5 optimization when -xarch=v8plus, v8plusa, v9, or v9a is specified.
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.
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.
-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.
-xsb
SPARC: Does not allow optimizations that increase code size.
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.
t must be one of the following:
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 the table in the following section. |
For the x86 platform, -xtarget accepts the following values:
native or generic
386-Directs the compiler to generate code for the best performance on the Intel 80386 microprocessor.
486-Directs the compiler to generate code for the best performance on the Intel 80486 microprocessor.
pentium-Directs the compiler to generate code for the best performance on the Pentium or Pentium Pro microprocessor.
pentium_pro-Directs the compiler to generate code for the best performance on the Pentium Pro microprocessor.
-xtarget |
-xarch |
-xchip |
-xcache |
---|---|---|---|
cs6400 |
v8 |
super |
16/32/4:2048/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 |
entr150 |
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 |
ss1plus |
v7 |
old |
64/16/1 |
ss2 |
v7 |
old |
64/32/1 |
ss2p |
v7 |
powerup |
64/32/1 |
ss4 |
v8a |
micro2 |
8/16/1 |
ss4/85 |
v8a |
micro2 |
8/16/1 |
ss4/110 |
v8a |
micro2 |
8/16/1 |
ss5 |
v8a |
micro2 |
8/16/1 |
ss5/85 |
v8a |
micro2 |
8/16/1 |
ss5/110 |
v8a |
micro2 |
8/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/41 |
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/61 |
v8 |
super |
16/32/4:1024/32/1 |
ss10/71 |
v8 |
super2 |
16/32/4:1024/32/1 |
ss10/402 |
v8 |
super |
16/32/4 |
ss10/412 |
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/612 |
v8 |
super |
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 |
ss20 |
v8 |
super |
16/32/4:1024/32/1 |
ss20/50 |
v8 |
super |
16/32/4 |
ss20/51 |
v8 |
super |
16/32/4:1024/32/1 |
ss20/61 |
v8 |
super |
16/32/4:1024/32/1 |
ss20/71 |
v8 |
super2 |
16/32/4:1024/32/1 |
ss20/151 |
v8 |
hyper |
512/64/1 |
ss20/152 |
v8 |
hyper |
512/64/1 |
ss20/502 |
v8 |
super |
16/32/4 |
ss20/514 |
v8 |
super |
16/32/4:1024/32/1 |
ss20/612 |
v8 |
super |
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 |
ss600/41 |
v8 |
super |
16/32/4:1024/32/1 |
ss600/51 |
v8 |
super |
16/32/4:1024/32/1 |
ss600/61 |
v8 |
super |
16/32/4:1024/32/1 |
ss600/120 |
v7 |
old |
64/32/1 |
ss600/140 |
v7 |
old |
64/32/1 |
ss600/412 |
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/612 |
v8 |
super |
16/32/4:1024/32/1 |
ss1000 |
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 |
ssvygr |
v8a |
micro2 |
8/16/1 |
sun4/15 |
v8a |
micro |
2/16/1 |
sun4/20 |
v7 |
old |
64/16/1 |
sun4/25 |
v7 |
old |
64/32/1 |
sun4/30 |
v8a |
micro |
2/16/1 |
sun4/40 |
v7 |
old |
64/16/1 |
sun4/50 |
v7 |
old |
64/32/1 |
sun4/60 |
v7 |
old |
64/16/1 |
sun4/65 |
v7 |
old |
64/16/1 |
sun4/75 |
v7 |
old |
64/32/1 |
sun4/110 |
v7 |
old |
2/16/1 |
sun4/150 |
v7 |
old |
2/16/1 |
sun4/260 |
v7 |
old |
128/16/1 |
sun4/280 |
v7 |
old |
128/16/1 |
sun4/330 |
v7 |
old |
128/16/1 |
sun4/370 |
v7 |
old |
128/16/1 |
sun4/390 |
v7 |
old |
128/16/1 |
sun4/470 |
v7 |
old |
128/32/1 |
sun4/490 |
v7 |
old |
128/32/1 |
sun4/630 |
v7 |
old |
64/32/1 |
sun4/670 |
v7 |
old |
64/32/1 |
sun4/690 |
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 |
ultra1/2170 |
v8 |
ultra |
16/32/1:512/64/1 |
ultra1/2200 |
v8 |
ultra |
16/32/1:1024/64/1 |
ultra1/2300 |
v8 |
ultra2 |
16/32/1:2048/64/1 |
ultra2i |
v8 |
ultra2i |
16/32/1:512/64/1 |
For SPARC devices, -xtarget accepts the following expansion values:
On both SPARC and x86 devices, if -xtarget is not specified, -xtarget=generic is assumed.
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.
-xtarget=sun4/15 means -xarch=v8a -xchip=micro -xcache=2/16/1
Compiling for 64-bit Solaris 7 on SPARC or UltraSPARC V9 devices is indicated by the -xarch=v9|v9a option. Setting -xtarget=ultra or ultra2 is not necessary or sufficient. If -xtarget is specified, the -xarch=v9 or v9a option must appear after the -xtarget, as in:
-xtarget=ultra -xarch=v9
Otherwise, the -xtarget setting reverts the -xarch value to v8.
Causes the CC driver to report execution time for the various compilation passes.
Enables unrolling of loops where possible.
This option specifies whether or not the compiler optimizes (unrolls) loops.
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.
Converts all warnings to errors by returning nonzero exit status.
Forces a fatal error if any relocations remain against nonwritable, allocatable sections.
This option is passed to the linker.