C User's Guide |
cc
Compiler OptionsThis chapter describes the C compiler options and is organized into the following sections:
If you are porting a K&R C program to ANSI/ISO C, make special note of the section on compatibility flags, -X[a|c|s|t]. Using them makes the transition to ANSI/ISO C easier. Also refer to the discussion on the transition in Transitioning to ANSI/ISO C.
Option Syntax
The syntax of the
cc
command is:
%
cc
[
options]
filenames[
libraries]...
- options represents one or more of the options described in The cc Options
- filenames represents one or more files used in building the executable program
cc
accepts a list of C source files and object files contained in the list of files specified by filenames. The resulting executable code is placed ina.out
, unless the-o
option is used. In this case, the code is placed in the file named by the-o
option.- Use
cc
to compile and link any combination of the following:
- C source files, with a
.c
suffix- Inline template files, with a
.il
suffix (only when specified with.c
files)- C preprocessed source files, with a
.i
suffix- Object-code files, with
.o
suffixes- Assembler source files, with
.s
suffixes- libraries represents any of a number of standard or user-provided libraries containing functions, macros, and definitions of constants.
See option
-Y
P, dir to change the default directories used for finding libraries. dir is a colon-separated path list. The default library search order forcc
is:
cc
usesgetopt
to parse command-line options. Options are treated as a single letter or a single letter followed by an argument. Seegetopt
(3c).Options Summary
In this section, the compiler options are grouped by function to provide an easy reference. The details are in the sections of the following pages. The following table summarizes the cc compiler options by functionality. Some flags serve more than one purpose and appear more than once.
The
cc
OptionsThis section describes the
cc
options, arranged alphabetically. These descriptions are also available in the man page,cc
(1). Use thecc
-flags
option for a one-line summary of these descriptions.Options noted as being unique to one or more platforms are accepted without error and ignored on all other platforms. For an explanation of the typographic notations used with the options and arguments, refer to Typographic Conventions.
-#
Turns on verbose mode, showing each component as it is invoked.
-###
Shows each component as it would be invoked, but does not actually execute it.
-A
name[(
tokens)]
Associates name as a predicate with the specified tokens as if by a
#assert
preprocessing directive. Preassertions:
system
(unix
)machine(sparc)
(SPARC)machine(i386)
(x86)cpu(sparc)
(SPARC)cpu(i386)
(x86)These preassertions are not valid in
-Xc
mode.
-B[static|dynamic]
Specifies whether bindings of libraries for linking are
static
ordynamic
, indicating whether libraries are non-shared or shared, respectively.
-Bdynamic
causes the link editor to look for files namedlib
x.so
and then for files namedlib
x.a
when given the-l
x option.
-Bstatic
causes the link editor to look only for files namedlib
x.a
. This option may be specified multiple times on the command line as a toggle. This option and its argument are passed told
.
Note Many system libraries, such aslibc
, are only available as dynamic libraries in the Solaris 64-bit compilation environment. Therefore, do not use-Bstatic
as the last toggle on the command line.
-C
Prevents the C preprocessor from removing comments, except those on the preprocessing directive lines.
-c
Directs
cc
to suppress linking withld
(1) and to produce a.o
file for each source file. You can explicitly name a single object file using the-o
option. When the compiler produces object code for each.i
or.c
input file, it always creates an object (.o) file in the current working directory. If you suppress the linking step, you also suppress the removal of the object files.
-D
name[=
tokens]
Associates name with the specified tokens as if by a
#define
preprocessing directive. If no=
tokens is specified, the token1
is supplied.Predefinitions (not valid in
-Xc
mode):
sun
unix
sparc
(SPARC)i386
(x86)The following predefinitions are valid in all modes.
__sparcv9
(-Xarch=v9
,v9a
)
__sun __unix __SUNPRO_C=0x510__`uname -s`_`uname -r` (
example:__SunOS_5_7
)__sparc
(SPARC)__i386
(x86)__BUILTIN_VA_ARG_INCR
__SVR4
The following is predefined in
-Xa
and-Xt
modes only:__RESTRICT
The compiler also predefines the object-like macro
__PRAGMA_REDEFINE_EXTNAME,
to indicate the pragma will be recognized.
-d[y|n]
-dy
specifies dynamic linking, which is the default, in the link editor.
-dn
specifies static linking in the link editor.This option and its arguments are passed to
ld
(1).
Note Many system libraries are only available as dynamic libraries in the Solaris 7 64-bit compilation environment. As a result, this option causes fatal errors if you use it in combination with-Xarch=v9
.
-dalign
-dalign
is equivalent to-xmemalign=8s
. See -xmemalign=ab.
-E
Runs the source file through the preprocessor only and sends the output to
stdout
. The preprocessor is built directly into the compiler, except in-Xs
mode
, where/usr/ccs/lib/cpp
is invoked. Includes the preprocessor line numbering information. See also the-P
option.
-erroff=
t
Suppresses
cc
warning messages. Has no effect on error messages.t is a comma-separated list that consists of one or more of the following: tag,
no%
tag,%all
,%none
. Order is important; for example,%all,no%
tag suppresses all warning messages except tag. The following table lists the-erroff
values:
The default is
-erroff=%none
. Specifying-erroff
is equivalent to specifying-erroff=%all
.You can achieve finer control over error message suppression. See #pragma error_messages (on|off|default,tag... tag).
-errtags=
a
Displays the message tag for each warning message.
a can be either
yes
orno
. The default is-errtags=no
. Specifying-errtags
is equivalent to specifying-errtags=yes
.
-errwarn=
t
If the indicated warning message is issued, cc exits with a failure status. t is a comma-separated list that consists of one or more of the following: tag,
no%
tag,%all
,%none
. Order is important; for example%all,no%
tag causescc
to exit with a fatal status if any warning except tag is issued. The following table list the-errwarn
values:
The default is
-errwarn=%none
. If you specify-errwarn
alone, it is equivalent to-errwarn=%all
.
-fast
Selects the optimum combination of compilation options for speed. This should provide close to the maximum performance for most realistic applications. Modules compiled with
-fast
must also be linked with-fast
.The
-fast
option is unsuitable for programs intended to run on a different target than the compilation machine. In such cases, follow-fast
with the appropriate xtarget option. For example:
cc -fast -xtarget=ultra ...
For C modules that depend on exception handling specified by SVID, follow
-fast
by-xnolibmil
:
% cc -fast -xnolibmil
With
-xlibmil
, exceptions cannot be noted by settingerrno
or callingmatherr
(3m).The
-fast
option is unsuitable for programs that require strict conformance to the IEEE 754 Standard.The following table lists the set of options selected by
-fast
across platforms.
-dalign
X - -fns
X X -fsimple=2
X - -ftrap=%none
X X -xlibmil
X X -xtarget=native
X X -nofstore
- X -xO5
X X -fsingle
X X
-fast
acts like a macro expansion on the command line. Therefore, you can override the optimization level and code generation option aspects by following-fast
with the desired optimization level or code generation option. Compiling with the-fast -xO4
pair is like compiling with the-xO2 -xO4
pair. The latter specification takes precedence.In previous releases, the
-fast
macro option included-fnonstd
; now it includes-fns
instead.You can usually improve performance for most programs with this option.
Do not use this option for programs that depend on IEEE standard exception handling; you can get different numerical results, premature program termination, or unexpected
SIGFPE
signals.
-fd
Reports K&R-style function definitions and declarations.
-flags
Prints a brief summary of each available compiler option.
-fnonstd
Causes nonstandard initialization of floating-point arithmetic hardware. In addition, the
-fnonstd
option causes hardware traps to be enabled for floating-point overflow, division by zero, and invalid operations exceptions. These are converted intoSIGFPE
signals; if the program has noSIGFPE
handler, it terminates with a memory dump.By default, IEEE 754 floating-point arithmetic is nonstop, and underflows are gradual. (See Nonstandard Floating Point for a further explanation.)
(SPARC) Synonym for
-fns -ftrap=common
.
-fns[={no,yes}]
(SPARC) Turns on the SPARC nonstandard floating-point mode.
The default is
-fns=no
, the SPARC standard floating-point mode.-fns
is the same as-fns=yes
.Optional use of
=yes
or=no
provides a way of toggling the-fns
flag following some other macro flag that includes-fns
, such as-fast
. This flag enables the nonstandard floating point mode when a program begins execution. By default, the non-standard floating point mode will not be enabled automatically.On some SPARC systems, the nonstandard floating point mode disables "gradual underflow," causing tiny results to be flushed to zero rather than producing subnormal numbers. It also causes subnormal operands to be replaced silently by zero. On those SPARC systems that do not support gradual underflow and subnormal numbers in hardware, use of this option can significantly improve the performance of some programs.
When nonstandard mode is enabled, floating point arithmetic may produce results that do not conform to the requirements of the IEEE 754 standard. See the Numerical Computation Guide for more information.
This option is effective only on SPARC systems and only if used when compiling the main program. On x86 systems, the option is ignored.
-fprecision=
p(x86)
-fprecision={single,
double,
extended}
Initializes the rounding-precision mode bits in the Floating-point Control Word to single (24 bits), double (53 bits), or extended (64 bits), respectively. The default floating-point rounding-precision mode is extended.
Note that on Intel, only the precision, not exponent, range is affected by the setting of floating-point rounding precision mode.
-fround=
r
Sets the IEEE 754 rounding mode that is established at runtime during the program initialization.
r must be one of:
nearest
,tozero
,negative
,positive
.The default is
-fround=nearest
.The meanings are the same as those for the
ieee_flags
subroutine.When r is
tozero
,negative
, orpositive
, this flag sets the rounding direction mode to round-to-zero, round-to-negative-infinity, or round-to-positive-infinity respectively when a program begins execution. When r isnearest
or the-fround
flag is not used, the rounding direction mode is not altered from its initial value (round-to-nearest by default).This option is effective only if used when compiling the main program.
-fsimple[=
n]
Allows the optimizer to make simplifying assumptions concerning floating-point arithmetic.
If n is present, it must be
0
,1
, or2
. The defaults are:
- With no
-fsimple
[=n], the compiler uses-fsimple=0
- With only
-fsimple
, no=
n, the compiler uses-fsimple=1
-fsimple=0
Permits no simplifying assumptions. Preserve strict IEEE 754 conformance.
-fsimple=1
Allows conservative simplifications. The resulting code does not strictly conform to IEEE 754, but numeric results of most programs are unchanged.
With
-fsimple=1
, the optimizer can assume the following:
- IEEE 754 default rounding/trapping modes do not change after process initialization.
- Computations producing no visible result other than potential floating point exceptions may be deleted.
- Computations with Infinity or NaNs as operands need not propagate NaNs to their results; for example,
x*0
may be replaced by0
.- Computations do not depend on sign of zero.
With
-fsimple=1
, the optimizer is not allowed to optimize completely without regard to roundoff or exceptions. In particular, a floating-point computation cannot be replaced by one that produces different results with rounding modes held constant at runtime. The-fast
macroflag includes-fsimple=1
.
-fsimple=2
Permits aggressive floating point optimizations that may cause many programs to produce different numeric results due to changes in rounding. For example,
-fsimple=2
permits the optimizer to replace all computations ofx/y
in a given loop withx*z
, wherex/y
is guaranteed to be evaluated at least once in the loop,z=1/y
, and the values ofy
andz
are known to have constant values during execution of the loop.Even with
-fsimple=2
, the optimizer is not permitted to introduce a floating point exception in a program that otherwise produces none.
-fsingle
(
-Xt
and-Xs
modes only) Causes the compiler to evaluatefloat
expressions as single precision rather than double precision. This option has no effect if the compiler is used in either-Xa
or-Xc
modes, asfloat
expressions are already evaluated as single precision.
-fstore
(x86) Causes the compiler to convert the value of a floating-point expression or function to the type on the left-hand side of an assignment, when that expression or function is assigned to a variable, or when the expression is cast to a shorter floating-point type, rather than leaving the value in a register. Due to rounding and truncation, the results may be different from those that are generated from the register value. This is the default mode.
To turn off this option, use the
-nofstore
option.
-ftrap=
t
Sets the IEEE 754 trapping mode in effect at startup.
t is a comma-separated list that consists of one or more of the following:
%all
,%none
,common
, [no%
]invalid
, [no%
]overflow
, [no%
]underflow
, [no%
]division
, [no%
]inexact
.This option sets the IEEE 754 trapping modes that are established at program initialization. Processing is left-to-right. The
common
exceptions, by definition, are invalid, division by zero, and overflow.Example:
-ftrap=%all,no%inexact
means set all traps, exceptinexact
.The meanings are the same as for the
ieee_flags
subroutine, except that:
%all
turns on all the trapping modes.%none
, the default, turns off all trapping modes.- A
no%
prefix turns off that specific trapping mode.If you compile one routine with
-ftrap=
t, compile all routines of the program with the same-ftrap=
t option; otherwise, you can get unexpected results.
-G
Passes the option to the link editor to produce a shared object rather than a dynamically linked executable. This option is passed to
ld
(1), and cannot be used with the-dn
option.
-g
Produces additional symbol table information for the debugger.
This option invokes the incremental linker; see -xildoff and -xildon. Invoke
ild
instead ofld
unless you are using the-G
or-xildoff
options, or you are naming source files on the command line.If you issue
-g
, and the optimization level is-xO3
or lower, the compiler provides best-effort symbolic information with almost full optimization. Tail-call optimization and back-end inlining are disabled.If you issue
-g
and the optimization level is-xO4
, the compiler provides best-effort symbolic information with full optimization.
-H
Prints to standard error, one per line, the path name of each file included during the current compilation. The display is indented so as to show which files are included by other files.
Here, the program
sample.c
includes the files,stdio.h
andmath.h
;math.h
includes the file,floatingpoint.h
, which itself includes functions that usesys/ieeefp.h
:
%
cc -H sample.c
/usr/include/stdio.h
/usr/include/math.h
/usr/include/floatingpoint.h
/usr/include/sys/ieeefp.h
-h
nameAssigns a name to a shared dynamic library as a way to have different versions of a library. In general, the name after
-h
should be the same as the file name given after the-o
option. The space between-h
and name is optional.The linker assigns the specified name to the library and records the name in the library file as the intrinsic name of the library. If there is no
-h
name option, then no intrinsic name is recorded in the library file.When the runtime linker loads the library into an executable file, it copies the intrinsic name from the library file into the executable, into a list of needed shared library files. Every executable has such a list. If there is no intrinsic name of a shared library, then the linker copies the path of the shared library file instead.
-I
dir
Adds dir to the list of directories that are searched for
#include
files with relative file names, that is, those not beginning with a/
(slash). See Include Files for a discussion of the search order used to find the include files.
-i
Passes the option to the linker to ignore any
LD_LIBRARY_PATH
orLD_LIBRARY_PATH_64
setting.
-KPIC
-KPIC
is equivalent to-xcode=pic32
, see -xcode=v.(x86)
-KPIC
is identical to-Kpic
.
-Kpic
-Kpic
is equivalent to-xcode=pic13
, see -xcode=v.
-keeptmp
Retains temporary files created during compilation instead of deleting them automatically.
-L
dir
Adds dir to the list of directories searched for libraries by
ld
(1). This option and its arguments are passed told
.
-l
name
Links with object library
lib
name.so
, orlib
name.a.
The order of libraries in the command-line is important, as symbols are resolved from left to right.This option must follow the sourcefile arguments.
-mc
Removes duplicate strings from the
.comment
section of the object file. When you use the-mc
flag,mcs
-c
is invoked.
-misalign
(SPARC)
-misalign
is equivalent to-xmemalign=1i
. See -xmemalign=ab.
-misalign2
(SPARC)
-misalign2
is equivalent to-xmemalign=2i
. See -xmemalign=ab.
-mr
Removes all strings from the
.comment
section. When you use this flag,mcs
-d -a
is invoked.
-mr
,string
Removes all strings from the
.comment
section and inserts string in that section of the object file. If string contains embedded blanks, it must be enclosed in quotation marks. A null string results in an empty.comment
section. This option is passed as-d
astring tomcs
.
-mt
Macro option that expands to
-D_REENTRANT
-lthread
. If you are doing your own multithread coding, you must use this option in the compile and link steps. To obtain faster execution, this option requires a multiprocessor system. On a single-processor system, the resulting executable usually runs more slowly with this option.
-native
This option is a synonym for
-xtarget=native
.
-nofstore
(x86) Does not convert the value of a floating-point expression or function to the type on the left-hand side of an assignment, when that expression or function is assigned to a variable or is cast to a shorter floating-point type; rather, it leaves the value in a register. See also -fstore.
-noqueue
Instructs the compiler not to queue this compile request if a license is not available. Under normal circumstances, if no license is available, the compiler waits until one becomes available. With this option, the compiler returns immediately.
-O
-o
filenameNames the output file filename (as opposed to the default,
a.out)
. filename cannot be the same as sourcefile, sincecc
does not overwrite the source file. This option and its arguments are passed told
(1).
-P
Runs the source file through the C preprocessor only. It then puts the output in a file with a
.i
suffix. Unlike-E
, this option does not include preprocessor-type line number information in the output. See also the-E
option.
-p
Prepares the object code to collect data for profiling with
prof
(1). This option invokes a runtime recording mechanism that produces amon.out
file at normal termination.
-Q[y|n]
Emits or does not emit identification information to the output file.
-Qy
is the default.If
-Qy
is used, identification information about each invoked compilation tool is added to the.comment
section of output files, which is accessible withmcs
. This option can be useful for software administration.
-Q
n suppresses this information.
-qp
-R
dir[:
dir]
Passes a colon-separated list of directories used to specify library search directories to the runtime linker. If present and not null, it is recorded in the output object file and passed to the runtime linker.
If both
LD_RUN_PATH
and the-R
option are specified, the-R
option takes precedence.
-S
Directs
cc
to produce an assembly source file but not to assemble the program.
-s
Removes all symbolic debugging information from the output object file. This option cannot be specified with
-g
.
-U
name
Removes any initial definition of the preprocessor symbol name. This option is the inverse of the
-D
option. You can give multiple-U
options.
-V
Directs
cc
to print the name and version ID of each component as the compiler executes.
-v
Directs the compiler to perform stricter semantic checks and to enable other
lint
-like checks. For example, the code:
#include <stdio.h>main(void){printf("Hello World.\n");}
compiles and executes without problem. With
-v
, it still compiles; however, the compiler displays this warning:
"hello.c", line 5: warning: function has no return statement: main
-v
does not give all the warnings thatlint
(1) does. Try running the above example throughlint
.
-W
c,
argPasses the argument arg to a specified component c. Each argument must be separated from the preceding only by a comma. All
-W
arguments are passed after the regular command-line arguments. A comma can be part of an argument by escaping it by an immediately preceding\
(backslash) character.See Components of the C Compilation System for a list of components. c can be one of the following:
a
Assembler ( fbe
); (gas
)c
C code generator ( cg
) (SPARC)d
cc driver1 h
Intermediate code translator ( ir2hf
)(Intel)i
Inter-procedure analysis ( ube_ipa
)(Intel)l
Link editor ( ld
)m
mcs p
Preprocessor ( cpp
)u
C code generator ( ube
) (Intel)0
Compiler ( acomp
) (ssbd
, SPARC)2
Optimizer ( iropt
) (SPARC)
1 You cannot use -Wd
to pass the cc options listed in this chapter to the C compiler.
-w
Suppresses compiler warning messages.
This option overrides the
error_messages
pragma.
-X[a|c|s|t]
The
See K&R Sun C Incompatibilities with Sun ANSI/ISO C for a discussion of differences between ANSI/ISO C and K&R C.-X
(note uppercaseX
) options specify varying degrees of compliance to the ANSI/ISO C standard.-Xa
is the default mode.
-Xa
(
a
= ANSI) This is the default compiler mode. ANSI C plus K&R C compatibility extensions, with semantic changes required by ANSI C. Where K&R C and ANSI C specify different semantics for the same construct, the compiler uses the ANSI C interpretation. If the-Xa
option is used in conjunction with the-xtransition
option, the compiler issues warning about the conflict. The predefined macro _ _STDC_ _ has a value of0
with the-Xa
option.
-Xc
(
c
= conformance) Issues errors and warnings for programs that use non-ANSI/ISO C constructs. This option is strictly conformant ANSI/ISO C, without K&R C compatibility extensions. The predefined macro _ _STDC_ _ has a value of1
with the -Xa option.
-Xs
(
s
= K&R C) Attempts to warn about all language constructs that have differing behavior between ANSI/ISO C and K&R C. The compiler language includes all features compatible with K&R C. This option invokescpp
for preprocessing._ _STDC_ _
is not defined in this mode. For more information regarding the effects of compiling with the-Xs
option, see The Difference Between Sun C and ANSI/ISO C As Set By -Xs.
-Xt
(
t
= transition) This option uses ANSI/ISO C plus K&R C compatibility extensions without semantic changes required by ANSI/ISO C. Where K&R C and ANSI/ISO C specify different semantics for the same construct, the compiler uses the K&R C interpretation. If you use the -Xt option in conjunction with the -xtransition option, the compiler issues warnings about the conflict. The predefined macro _ _STDC_ _ has a value of0
with the -Xa option.
-x386
(x86) Optimizes for the 80386 processor.
-x486
(x86) Optimizes for the 80486 processor.
-xa
Inserts code to count how many times each basic block is executed. This option is the old style of basic block profiling for
tcov
. See -xprofile=p for information on the new style of profiling and thetcov
(1) man page for more details. See also Analyzing Program Performance With Sun Workshop.
-xa
invokes a runtime recording mechanism that creates a.d
file for every.c
file at normal termination. The.d
file accumulates execution data for the corresponding source file. tcov(1) can then be run on the source file to generate statistics about the program. Since this option entails some optimization, it is incompatible with-g
.If set at compile-time, the
TCOVDIR
environment variable specifies the directory where the.d
files are located. If this variable is not set, the.d
files remain in the same directory as the.c
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 which have been compiled with-xprofile=tcov
, and others with-xa
. You cannot compile a single file with both options.
-xarch=
isaSpecify instruction set architecture (ISA).
Architectures that are accepted by
-xarch
keyword isa are shown in TABLE 2-4:
TABLE 2-4 -xarch
ISA KeywordsSPARC generic
,native
,v7
,v8a
,v8
,v8plus
,v8plusa
,v8plusb
,v9
,v9a
,v9b
x86 generic
,386
,pentium_pro
Note that although
-xarch
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:
% cc -xtarget=ultra2 -xarch=v8plusb ...
overrides the
-xarch=v8
set by-xtarget=ultra2
If you use this option with optimization, the appropriate choice can provide good performance of the executable on the specified architecture. An inappropriate choice results in a binary program that is not executable on the intended target platform.
SPARC Only
The following table details the performance of an executable that is compiled with a given
-xarch
option and then executed by various SPARC processors. The purpose of this table is to help you identify the best-xarch
option for your executable given a particular target machine. Start by identifying the range of machines that are of interest to you and then consider the cost of maintaining multiple binaries versus the benefit of extracting the last iota of performance from newer machines.
- N reflects Nominal performance. The program executes and takes full advantage of the processor's instruction set.
- S reflects Satisfactory performance. The program executes but may not exploit all available processor instructions.
- PD reflects Performance Degradation. The program executes, but depending on the instructions used, may experience slight to significant performance degradation. The degradation occurs when instructions that are not implemented by the processor are emulated by the kernel.
- NE means Not Executable. The program will not execute because the kernel does not emulate the instructions that are not implemented by the processor.
If you are going to compile your executable with the
v8plus
orv8plusa
instruction set, consider compiling your executable withv9
orv9a
instead. Thev8plus
andv8plusa
options were provided so that programs could take advantage of some SPARC V9 and UltraSPARC features prior to the availability of Solaris 7 with its support for 64-bit programs. Programs compiled with thev8plus
orv8plusa
option are not portable to SPARC V8 or older machines. Such programs can be re-compiled withv9
orv9a
, respectively, to take full advantage of all the features of SPARC V9 and UltraSPARC. The V8+ Technical Specification white paper, part number 802-7447-10, is available through your Sun representative and explains the limitations ofv8plus
andv8plusa
.
- SPARC instruction set architectures V7, V8, and V8a are all binary compatible.
- Object binary files (.o) compiled with
v8plus
andv8plusa
can be linked and can execute together, but only on a SPARC V8plusa compatible platform.- Object binary files (.o) compiled with
v8plus
,v8plusa
, andv8plusb
can be linked and can execute together, but only on a SPARC V8plusb compatible platform.-xarch
valuesv9
,v9a
, andv9b
are only available on UltraSPARC 64-bit Solaris environments.- Object binary files (.o) compiled with
v9
andv9a
can be linked and can execute together, but will run only on a SPARC V9a compatible platform.- Object binary files (.o) compiled with
v9
,v9a
, andv9b
can be linked and can execute together, but will run only on a SPARC V9b compatible platform.For any particular choice, the generated executable may run much more slowly on earlier architectures. Also, although quad-precision (
REAL*16
andlong
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.The following table gives details for each of the
-xarch
keywords on SPARC platforms.
x86 Only
-xautopar
(SPARC) Turns on automatic parallelization for multiple processors. Does dependence analysis (analyze loops for inter-iteration data dependence) and loop restructuring. If optimization is not at
-xO3
or higher, optimization is raised to-xO3
and a warning is emitted.Avoid
-xautopar
if you do your own thread management.The Sun Workshop includes the license required to use multiprocessor C. To get faster execution, this option requires a multiple processor system. On a single-processor system, the resulting binary usually runs slower.
To determine how many processors you have, use the
psrinfo
command:
%
psrinfo
0 on-line since 01/12/95 10:41:541 on-line since 01/12/95 10:41:543 on-line since 01/12/95 10:41:544 on-line since 01/12/95 10:41:54
To request a number of processors, set the
PARALLEL
environment variable. The default is 1.
- Do not request more processors than are available.
- If
N
is the number of processors on the machine, then for a one-user, multiprocessor system, tryPARALLEL
=N-1
.If you use
-xautopar
and compile and link in one step, then linking automatically includes the microtasking library and the threads-safe C runtime library. If you use-xautopar
and compile and link in separate steps, then you must also link with-xautopar
.
-xCC
Accepts the C++-style comments. In particular,
//
can be used to indicate the start of a comment.
-xcache=
cDefines the cache properties for use by the optimizer. c must be one of the following:
generic (SPARC,
x86)
- s1
/
l1/
a1- s1
/
l1/
a1:
s2/
l2/
a2- s1
/
l1/
a1:
s2/
l2/
a2:
s3/
l3/
a3The si
/
li/
ai are defined as follows:
si The size of the data cache at level i, in kilobytes li The line size of the data cache at level i, in bytes ai The associativity of the data cache at level i
Although this option can be used alone, it is part of the expansion of the
-xtarget
option; its primary use is to override a value supplied by the-xtarget
option.This option specifies the cache properties that the optimizer can use. It does not guarantee that any particular cache property is used. The following table lists the
-xcache
values.
Example:
-xcache=16/32/4:1024/32/1
specifies the following:
Level 1 cache has: 16K bytes 32 bytes line size 4-way associativity Level 2 cache has: 1024K bytes 32 bytes line size Direct mapping associativity
-xcg[89|92]
-xcg89
is a macro for:-xarch=v7 -xchip=old -xcache=64/32/1
.
-xcg92
is a macro for:-xarch=v8 -xchip=super
-xchar_byte_order=
oProduce an integer constant by placing the characters of a multi-character character-constant in the specified byte order. You can substitute one of the following values for o:
low
: place the characters of a multi-character character-constant in low-to-high byte order.high
: place the characters of a multi-character character-constant in high-to-low byte order.default
: place the characters of a multi-character character-constant in an order determined by the compilation mode -X[a|c|s|t]. For more information, see Character Constants.
-xchip=
cSpecifies the target processor for use by the optimizer.
c must be one of the following:
generic
,old
,super
,super2
,micro
,micro2
,hyper
,hyper2
,powerup
,ultra, ultra2, ultra2i, 386,486, pentium, pentium_pro
,603
,604
.Although this option can be used alone, it is part of the expansion of the
-xtarget
option; its primary use is to override a value supplied by the-xtarget
option.This option specifies timing properties by specifying the target processor.
- 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
-xcode=
v
(SPARC) Specify code address space. v must be one of:
The default is
-xcode=abs32
for SPARC V7 and V8, and-xcode=abs64
for SPARC and UltraSPARC V9 (with-xarch=v9|v9a
).When building shared dynamic libraries with
-xarch=v9
orv9a
on 64-bit Solaris 7, you must specify-xcode=pic13
or-xcode=pic32
.There are two nominal performance costs with
-xcode=pic13
and-xcode=pic32
:
- A routine compiled with either
-xcode=pic13
or-xcode=pic32
executes a few extra instructions upon entry to set a register to point at a table (_GLOBAL_OFFSET_TABLE_
) used for accessing a shared library's global or static variables.- Each access to a global or static variable involves an extra indirect memory reference through
_GLOBAL_OFFSET_TABLE_
. If the compile is done with-xcode=pic32
, there are two additional instructions per global and static memory reference.When considering the above costs, remember that the use of
-xcode=pic13
and-xcode=pic32
can significantly reduce system memory requirements, due to the effect of library code sharing. Every page of code in a shared library compiled-xcode=pic13
or-xcode=pic32
can be shared by every process that uses the library. If a page of code in a shared library contains even a single non-pic
(that is, absolute) memory reference, the page becomes nonsharable, and a copy of the page must be created each time a program using the library is executed.The easiest way to tell whether or not a .o file has been compiled with
-xcode=pic13
or-xcode=pic32
is with thenm
command:
%nm
file.o | grep _GLOBAL_OFFSET_TABLE_
U _GLOBAL_OFFSET_TABLE_
A
.o
file containing position-independent code contains an unresolved external reference to _GLOBAL_OFFSET_TABLE_
, as indicated by the letterU
.To determine whether to use
-xcode=pic13
or-xcode=pic32
, usenm
to identify the number of distinct global and static variables used or defined in the library. If the size of_GLOBAL_OFFSET_TABLE_
is under 8,192 bytes, you can use-Kpic
. Otherwise, you must use-xcode=pic32
.
-xcrossfile=[
n]
(SPARC) Enables optimization and inlining across source files. If specified, n can be
0
or1
.Normally the scope of the compiler's analysis is limited to each separate file on the command line. For example,
-xO4
's automatic inlining is limited to subprograms defined and referenced within the same source file.With -xcrossfile, the compiler analyzes all the files named on the command line as if they had been concatenated into a single source file.
-xcrossfile
is only effective when used with-xO4
or-xO5
.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.
The default is
-xcrossfile=0
, and no cross-file optimizations are performed.-xcrossfile
is equivalent to-xcrossfile=1
.
-xdepend
(SPARC) Analyzes loops for inter-iteration data dependencies and does loop restructuring. Loop restructuring includes loop interchange, loop fusion, scalar replacement, and elimination of "dead" array assignments. If optimization is not at
-xO3
or higher, optimization is raised to-xO3
and a warning is issued.Dependency analysis is also included with
-xautopar
or-xparallel
. The dependency analysis is done at compile time.Dependency analysis may help on single-processor systems. However, if you try
-xdepend
on single-processor systems, you should not use either-xautopar
or-xexplicitpar
. If either of them is on, then the-xdepend
optimization is done for multiple-processor systems.
-xe
Performs only syntax and semantic checking on the source file, but does not produce any object or executable code.
-xexplicitpar
(SPARC) Generates parallelized code based on specification of
#pragma
MP
directives. You do the dependency analysis: analyze and specify loops for inter-iteration data dependencies. The software parallelizes the specified loops. If optimization is not at-xO3
or higher, optimization is raised to-xO3
and a warning is issued. Avoid-xexplicitpar
if you do your own thread management.The Sun Workshop includes the license required to use multiprocessor C. To get faster code, this option requires a multiprocessor system. On a single-processor system, the generated code usually runs slower.
If you identify a loop for parallelization, and the loop has dependencies, you can get incorrect results, possibly different ones with each run, and with no warnings. Do not apply an explicit parallel pragma to a reduction loop. The explicit parallelization is done, but the reduction aspect of the loop is not done, and the results can be incorrect.
In summary, to parallelize explicitly:
- Analyze the loops to find those that are safe to parallelize.
- Insert
#pragma MP
to parallelize a loop. See the Explicit Parallelization and Pragmas" for more information.- Use the
-xexplicitpar
option.An example of inserting a parallel pragma immediately before the loop is:
#pragma MP taskloopfor (j=0; j<1000; j++){...}
If you use
-xexplicitpar
and compile and link in one step, then linking automatically includes the microtasking library and the threads-safe C runtime library. If you use-xexplicitpar
and compile and link in separate steps, then you must also link with-xexplicitpar
.
-xF
Enables performance analysis of the executable using the Analyzer. (See the
analyzer
(1) man pages.) Produces code that can be reordered at the function level. Each function in the file is placed in a separate section; for example, functionsfoo()
andbar()
are placed in the sections.text%foo
and.text%bar
, respectively. Function ordering in the executable can be controlled by using-xF
in conjunction with the-M
option told
(seeld
(1)). This option also causes the assembler to generate some debugging information in the object file, necessary for data collection.
-xhelp=
fDisplays on-line help information.
f must be one of:
flags
,readme
, orerrors
.
-xhelp=flags
displays a summary of the compiler options.
-xhelp=readme
displays theREADME
file.
-xhelp=errors
displays the Error and Warning Messages file.
-xildoff
Turns off the incremental linker and forces the use of
ld
. This option is the default if you do not use the-g
option, or you do use the-G
option, or any source files are present on the command line. Override this default by using the-xildon
option.
-xildon
Turns on the incremental linker and forces the use of
ild
in incremental mode. This option is the default if you use the-g
option, and you do not use the-G
option, and there are no source files present on the command line. Override this default by using the-xildoff
option.
-xinline=[{%auto,
func_name,no%
func_name}[,{%auto,
func_name,no%
func_name}]...]
Tries to inline only those functions specified in the list. The list is comprised of either a comma-separated list of functions names, or a comma separated list of
no%
func_ name values, or the value%auto
. If you issueno%
func_ name, the compiler is not to inline the named function. If you issue%auto
, the compiler is to attempt to automatically inline all functions in the source files.If you are compiling with
-xO3
, you can use-xinline
to increase optimization by inlining some or all functions. The-xO3
level of optimization does not include inlining.If you are compiling with
-xO4
,-xinline
can decrease optimization by restricting inlining to only those routines in the list. With-xO4
, the compiler normally tries to inline all references to functions defined in the source file. When you specify-xinline=
but do not name any functions or%auto
, this indicates that none of the routines in the source file are to be inlined.A function is not inlined if any of the following conditions apply (no warning is issued):
- Optimization is less than
-xO3
.- The routine cannot be found.
- Inlining the routine does not look practicable to the optimizer.
- The source for the routine is not in the file being compiled (however, see
-xcrossfile
).
-xlibmieee
Forces IEEE 754 style return values for math routines in exceptional cases. In such cases, no exception message is printed, and you should not rely on
errno
.
-xlibmil
Inlines some library routines for faster execution. This option selects the appropriate assembly language inline templates for the floating-point option and platform for your system.
-xlic_lib=sunperf
(SPARC) Links in the Sun-supplied performance libraries.
-xlicinfo
Returns information about the licensing system. In particular, this option returns the name of the license server and the IDs of users who have checked out licenses. This option does not request compilation or check out a license.
-xloopinfo
(SPARC) Shows which loops are parallelized and which are not. Gives a short reason for not parallelizing a loop. The
-xloopinfo
option is valid only if-xautopar
, or-xparallel
, or-xexplicitpar
is specified; otherwise, the compiler issues a warning.The Sun WorkShop includes the license required to use multiprocessor C options. To get faster code, this option requires a multiprocessor system. On a single-processor system, the generated code usually runs slower.
-xM
Runs only the preprocessor on the named C programs, requesting that it generate makefile dependencies and send the result to the standard output (see
make
(1) for details about makefiles and dependencies).For example:
#include <unistd.h>void main(void){}generates this output:
-xM1
Collects dependencies like
-xM
, but excludes/usr/include
files. For example:
more hello.c
#include<stdio.h>main(){(void)printf("hello\n");}cc -xM hello.c
hello.o: hello.chello.o: /usr/include/stdio.h
Compiling with
-xM1
does not report header file dependencies:
cc -xM1 hello.c
hello.o: hello.c
-xMerge
Merges data segments into text segments. Data initialized in the object file produced by this compilation is read-only and (unless linked with
ld
-N
) is shared between processes.
-xmaxopt
=off,
1,
2,
3,
4,
5
This command limits the level of
pragma
opt
to the level specified. The default value is-xmaxopt=off
which causespragma
opt
to be ignored. If you specify-xmaxopt
without supplying an argument, that is the equivalent of specifying-xmaxopt=5
.
-xmemalign=
abSpecify maximum assumed memory alignment and behavior of misaligned data accesses. There must be a value for both a (alignment) and b (behavior). a specifies the maximum assumed memory alignment and b specifies the behavior for misaligned memory accesses. The following table lists the alignment and behavior values for
-xmemalign
.For memory accesses where the alignment is determinable at compile time, the compiler will generate the appropriate load/store instruction sequence for that alignment of data.
For memory accesses where the alignment cannot be determined at compile time, the compiler must assume an alignment to generate the needed load/store sequence.
The -xmemalign flag allows the user to specify the maximum memory alignment of data to be assumed by the compiler in these indeterminable situations. It also specifies the error behavior to be followed at run time when a misaligned memory access does take place.
Here are the default values for
-xmemalign
. The following default values only apply when no-xmemalign
flag is present:
-xmemalgin=4s
when-xarch
has the valuegeneric
,v7
,v8
,v8a
,v8plus
,v8plusa
, ILP32.-xmemalign=8s
when -xarch has the valuev9
,v9a
.Here is the default when
-xmemalign
flag is present but no value is given:
-xmemalign=1i
for all-xarch
values.The following table shows how you can use -xmemalign to handle different alignment situations.
-xnolib
Does not link any libraries by default; that is, no
-l
options are passed told
. Normally, thecc
driver passes-lc
told
.When you use
-xnolib
, you have to pass all the-l
options yourself. For example:
%
cc test.c -xnolib -Bstatic -lm -Bdynamic -lc
links
libm
statically and the other libraries dynamically.
-xnolibmil
Does not inline math library routines. Use it after the
-fast
option. For example:
%
cc -fast -xnolibmil....
-xO[1|2|3|4|5]
Optimizes the object code; note the upper-case letter O. When
-xO
is used with the-g
option, a limited amount of debugging is available. For more information, see "Debugging Optimized Code" in Chapter 1 of Debugging a Program With dbx.The levels (
1
,2
,3
,4
, or5
) you can use with-xO
differ according to the platform you are using.SPARC
-xO1
Does basic local optimization (peephole).
-xO2
Does basic local and global optimization. This is induction variable elimination, local and global common subexpression elimination, algebraic simplification, copy propagation, constant propagation, loop-invariant optimization, register allocation, basic block merging, tail recursion elimination, dead code elimination, tail call elimination, and complex expression expansion.
The
-xO2
level does not assign global, external, or indirect references or definitions to registers. It treats these references and definitions as if they were declaredvolatile
. In general, the-xO2
level results in minimum code size.-xO3
Performs like
-xO2
, but also optimizes references or definitions for external variables. Loop unrolling and software pipelining are also performed. This level does not trace the effects of pointer assignments. When compiling either device drivers, or programs that modify external variables from within signal handlers, you may need to use thevolatile
type qualifier to protect the object from optimization. In general, the-xO3
level results in increased code size.-xO4
Performs like
-xO3
, but also automatically inlines functions contained in the same file; this usually improves execution speed. If you want to control which functions are inlined, see -xinline=[{%auto,func_name,no%func_name}[,{%auto,func_name,no%func_name}]...].This level traces the effects of pointer assignments, and usually results in increased code size.
-xO5
Attempts to generate the highest level of optimization. Uses optimization algorithms that take more compilation time or that do not have as high a certainty of improving execution time. Optimization at this level is more likely to improve performance if it is done with profile feedback. See -xprofile=p.
x86
-xO1
Preloads arguments from memory, 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, and elimination of global common subexpressions.
-xO3
Performs loop strength reduction, induction variable elimination, as well as the optimization done by level
2
.-xO4
Performs loop unrolling, avoids creating stack frames when possible, and automatically inlines functions contained in the same file, as well as the optimization done by levels
2
and3
. Note that this optimization level can cause stack traces fromadb
anddbx
to be incorrect.-xO5
Generates the highest level of optimization. Uses optimization algorithms that take more compilation time or that do not have as high a certainty of improving execution time. Some of these include generating local calling convention entry points for exported functions, further optimizing spill code and adding analysis to improve instruction scheduling.
If the optimizer runs out of memory, it tries to recover by retrying the current procedure at a lower level of optimization and resumes subsequent procedures at the original level specified in the command-line option.
If you optimize at
-xO3
or-xO4
with very large procedures (thousands of lines of code in the same procedure), the optimizer may require a large amount of virtual memory. In such cases, machine performance may degrade.
-xP
Prints prototypes for all K&R C functions defined in this module.
f(){}main(argc,argv)int argc;char *argv[];{}
produces this output:
int f(void);int main(int, char **);
-xparallel
(SPARC) Parallelizes loops both automatically by the compiler and explicitly specified by the programmer. The
-xparallel
option is a macro, and is equivalent to specifying all three of-xautopar
,-xdepend
, and-xexplicitpar
. With explicit parallelization of loops, there is a risk of producing incorrect results. If optimization is not at-xO3
or higher, optimization is raised to-xO3
and a warning is issued.Avoid
-xparallel
if you do your own thread management.The Sun WorkShop includes the license required to use the multiprocessor C options. To get faster code, this option requires a multiprocessor system. On a single-processor system, the generated code usually runs slower.
If you compile and link in one step,
-xparallel
links with the microtasking library and the threads-safe C runtime library. If you compile and link in separate steps, and you compile with-xparallel
, then link with-xparallel
-xpentium
(x86) Optimizes for the Pentium processor.
-xpg
Prepares the object code to collect data for profiling with
gprof
(1). It invokes a runtime recording mechanism that produces agmon.out
file at normal termination.
-xprefetch=[
val],
val
(SPARC) Enable prefetch instructions on those architectures that support prefetch, such as UltraSPARC II. (
-xarch=v8plus
,v9plusa
,v9
, orv9a
)Explicit prefetching should only be used under special circumstances that are supported by measurements.
val must be one of the following:
If you do not specify
-xprefetch
, the default is-xprefetch=no%auto,explicit
. If you specify-xprefetch
without a value, that is equivalent to-xprefetch=auto,explicit
.The
sun_prefetch.h
header file provides the macros that you can use to specify explicit prefetch instructions. The prefetches are approximately at the place in the executable that corresponds to where the macros appear.
-xprofile=
pCollects data for a profile or uses a profile to optimize.
(SPARC) p must be
collect
[:name],use
[:name], ortcov
.This option causes execution frequency data to be collected and saved during execution, then the data can be used in subsequent runs to improve performance. This option is only valid when you specify a level of optimization.
collect
[:
name]Collects and saves execution frequency data 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 name is not specified,
a.out
is assumed to be the name of the executable.At runtime a program compiled with
-xprofile=collect:
name will create the subdirectory name.profile
to hold the runtime feedback information. Data is written to the filefeedback
in this subdirectory. If you run the program several times, the execution frequency data accumulates in thefeedback
file; that is, output from prior runs is not lost.
use
[:
name]Uses execution frequency data to optimize strategically.
As with
collect:
name, the name is optional and may be used to specify the name of the program.The program is optimized by using the execution frequency data previously generated and saved in the
feedback
files written by a previous execution of the program compiled with-xprofile=collect
.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 "new" style
tcov
.The
-xprofile=tcov
option is the new style of basic block profiling fortcov
. It has similar functionality to the-xa
option, but correctly collects data for programs that have source code in header files. See -xa for information on the old style of profiling, thetcov
(1) man page, and Analyzing Program Performance With Sun WorkShop for more details.Code instrumentation is performed similarly 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
, the data file is stored in/foo/bar/myprog.profile/myprog.tcovd
.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 with-xa
. You cannot compile a single file with both options.When running
tcov
, you must pass it the-x
option to make it use the new style of data. If not,tcov
uses the old.d
files, if any, by default for data, and produces unexpected output.Unlike the
-xa
option, theTCOVDIR
environment variable has no effect at compile-time. However, its value is used at program runtime. Seetcov
(1) and Analyzing Program Performance With Sun WorkShop for more details.
Note tcov
's code coverage report can be unreliable if there is inlining of routines due to-xO4
or-xinline
.
-xreduction
(SPARC) Turns on reduction recognition during automatic parallelization.
-xreduction
must be specified with-xautopar
, or-xparallel
.Parallelization options require a WorkShop license.
When reduction recognition is enabled, the compiler parallelizes reductions such as dot products, maximum and minimum finding. These reductions yield different roundoffs than obtained by unparallelized code.
-xregs=
r(SPARC) Specifies the usage of registers for the generated code.
r is a comma-separated list that consists of one or more of the following: [
no%
]appl
, [no%
]float
.Example:
-xregs=appl,no%float
TABLE 2-12 The -xregs
Valuesappl
Allows the use of the following registers:g2, g3, g4 (v8a, v8, v8plus, v8plusa, v8plusb) g2, g3 (v9, v9a, v9b) For more information on SPARC instruction sets, see -xarch=isa. 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 some old library programs written in assembly code. no%appl
Does not use the appl
registers.float
Allows using the floating-point registers as specified in the SPARC ABI. You can use these registers even if the program contains no floating-point code. no%float
Does not use the floating-point registers.
With this option, a source program cannot contain any floating-point code.
The default is
-xregs=appl,float
.
-xrestrict=
f(SPARC) Treats pointer-valued function parameters as restricted pointers. f is a comma-separated list that consists of one or more function parameters,
%all
, or%none
.If a function list is specified with this option, pointer parameters in the specified functions are treated as restricted; if
-xrestrict=%all
is specified, all pointer parameters in the entire C file are treated as restricted. Refer to _Restrict Keyword, for more information.This command-line option can be used on its own, but it is best used with optimization. For example, the command:
%
cc -xO3 -xrestrict=%all prog.c
treats all pointer parameters in the file
%prog.c
as restricted pointers. The command:cc -xO3 -xrestrict=agc prog.c
treats all pointer parameters in the function
agc
in the fileprog.c
as restricted pointers.The default is
%none
; specifying-xrestrict
is equivalent to specifying-xrestrict=%all
.
-xs
Disables Auto-Read for
dbx
. Use this option in case you cannot keep the.o
files around. It 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 anddbx
initializes more slowly.Auto-Read is the newer and default way of loading symbol tables. With Auto-Read, the information is distributed in the
.o
files, so thatdbx
loads the symbol table information only if and when it is needed. Hence, the linker links faster, anddbx
initializes faster.With
-xs
, if you move the executables to another directory, then to usedbx
, you can ignore the object (.o
) files.Without
-xs
, if you move the executables, you must move both the source files and the object (.o
) files, or set the path with thedbx
pathmap
oruse
command.
-xsafe=mem
(SPARC) Allows the compiler to assume no memory-based traps occur.
This option grants permission to use the speculative load instruction on V9 machines. It is only effective when you specify
-xO5
optimization and-xarch=v8plus|v8plusa|v9|v9a
.
-xsb
Generates extra symbol table information for the Source Browser. This option is not valid with the
-Xs
mode of the compiler.
-xsbfast
Creates the database for the Source Browser. Does not compile source into an object file. This option is not valid with the
-Xs
mode of the compiler.
-xsfpconst
Represents unsuffixed floating-point constants as single precision, instead of the default mode of double precision. Not valid with
-Xc
.
-xspace
Does no optimizations or parallelization of loops that increase code size.
Example: The compiler will not unroll loops or parallelize loops if it increases code size.
-xstrconst
Inserts string literals into the read-only data section of the text segment instead of the default data segment.
-xtarget=
tSpecifies the target system for instruction set and optimization.
The value of t must be one of the following:
native
,generic
, system-name (SPARC, x86).The
-fast
macro option includes-xtarget=native
in its expansion.The
-xtarget
option is a macro that permits a quick and easy specification of the-xarch
,-xchip
, and-xcache
combinations that occur on real systems. The only meaning of-xtarget
is in its expansion.
TABLE 2-13 The -xtarget
Valuesnative
Gets the best performance on the host system.
The compiler generates code for the best performance on 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.system-name
Gets the best performance for the specified system.
You select a system name from TABLE 2-14 that lists the mnemonic encodings of the actual system name and numbers.
The performance of some programs may benefit by providing the compiler with an accurate description of the target computer hardware. When program performance is critical, the proper specification of the target hardware could be very important. 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.
Each specific value for
-xtarget
expands into a specific set of values for the-xarch
,-xchip
, and-xcache
options. See TABLE 2-14 for the values. For example:
-xtarget=sun4/15
is equivalent to:-xarch=v8a -xchip=micro
-xcache=2/16/1
generic
ornative
386
(equivalent to -386
option) or486
(equivalent to -486
option)pentium
(equivalent to -pentium
option) orpentium_pro
-xtemp=
dirSets the directory for temporary files used by
cc
to dir. No space is allowed within this option string. Without this option, temporary files go into/tmp
.-xtemp
has precedence over theTMPDIR
environment variable.
-xtime
Reports the time and resources used by each compilation component.
-xtransition
Issues warnings for the differences between K&R C and Sun ANSI/ISO C. The
-xtransition
option issues warnings in conjunction with the-Xa
and-Xt
options. You can eliminate all warning messages about differing behavior through appropriate coding. The following warnings no longer appear unless the-xtransition
option is used:
\a is ANSI C "alert" character
\x is ANSI C hex escape
bad octal digit
base type is really
type tag: namecomment is replaced by
"##"comment does not concatenate tokens
declaration introduces new type in ANSI C:
type tagmacro replacement within a character constant
macro replacement within a string literal
no macro replacement within a character constant
no macro replacement within a string literal
operand treated as unsigned
trigraph sequence replaced
ANSI C treats constant as unsigned:
operatorsemantics of
operatorchange in ANSI C; use explicit cast
-xunroll=
nSuggests to the optimizer to unroll loops n times. n is a positive integer. When n is 1, it is a command, and the compiler unrolls no loops. When n is greater than 1, the
-xunroll=
n merely suggests to the compiler that it unroll loops n times.
-xvector[={yes|no}
Enable automatic generation of calls to the vector library functions.
-xvector=yes
permits the compiler to transform math library calls within loops into single calls to the equivalent vector math routines when such transformations are possible. Such transformations could result in a performance improvement for loops with large loop counts.If you do not issue
-xvector
, the default is-xvector=no
. If you specify-xvector
but do not supply a value, the default is-xvector=yes
.If you use
-xvector
on the command line without previously specifying-xdepend
,-xvector
triggers-xdepend
. The-xvector
option also raises the optimization level to -x03 if optimization is not specified or optimization is set lower than-x03
.The compiler includes the
libmvec
libraries in the load step. If you compile and link with separate commands, be sure to use-xvector
in the linkingcc
command.
-xvpara
(SPARC) Warns about loops that have
#pragma
MP
directives specified when the loop may not be properly specified for parallelization. For example, when the optimizer detects data dependencies between loop iterations, it issues a warning.The Sun WorkShop includes the license required to use multiprocessor C options.
Use
-xvpara
with the-xexplicitpar
option or the-xparallel
option and the#pragma MP
. See Explicit Parallelization and Pragmas for more information.
-Y
c,
dirSpecifies a new directory dir for the location of component c. c can consist of any of the characters representing components that are listed under the
-W
option.If the location of a component is specified, then the new path name for the tool is dir/tool. If more than one
-Y
option is applied to any one item, then the last occurrence holds.
-YA,
dirChanges the default directory searched for components.
-YI,
dirChanges the default directory searched for
include
files.
-YP,
dirChanges the default directory for finding library files.
-YS,
dirChanges the default directory for startup object files.
-Zll
(SPARC) Creates the program database for
lock_lint
, but does not actually compile. Refer to thelock_lint
(1) man page for more details.
-Zlp
(SPARC) Prepares object files for the loop profiler,
looptool
. Thelooptool
(1) utility can then be run to generate loop statistics about the program. Use this option with-xdepend
; if-xdepend
is not explicitly or implicitly specified, turns on-xdepend
and issues a warning. If optimization is not at-xO3
or higher, optimization is raised to-xO3
and a warning is issued. Generally, this option is used with one of the loop parallelization options:-xexplicitpar
,-xautopar
, or-xparallel
.The Sun WorkShop includes the license required to use the MPC options. To get faster code, this option requires a multiprocessor system. On a single-processor system, the generated code usually runs slower.
If you compile and link in separate steps, and you compile with
-Zlp
, then be sure to link with-Zlp
.If you compile one subprogram with
-Zlp
, you need not compile all subprograms of that program with-Zlp
. However, you get loop information only for the files compiled with-Zlp
, and no indication that the program includes other files.Options Passed to the Linker
cc
recognizes-a
,-e
,-r
,-t
,-u
, and-z
and passes these options and their arguments told
.cc
passes any unrecognized options told
with a warning.
Sun Microsystems, Inc. Copyright information. All rights reserved. Feedback |
Library | Contents | Previous | Next | Index |