NAME CC - Sun WorkShop C++ Compiler 5.0 SYNOPSIS CC [-386] [-486] [-a] [-B(dynamic|static)] [-c] [-cg(89|92)] [-compat[=(4|5)]] [+d] [-Dname[=def]] [-d(y|n)] [-dalign] [-dryrun] [-E] [+e(0|1)] [-fast] [-features=a] [-flags] [-fnonstd] [-fns[=(yes|no)]] [-fprecision=p] [-fround=r] [-fsimple[=n]] [-fstore] [-ftrap=t] [-G] [-g] [-g0] [-H] [-h name] [-help] [-i] [-I dir] [-inline=rlst] [-instances=i] [-keeptmp] [-KPIC] [-Kpic] [-Ldir] [-llib] [-libmieee] [-libmil] [-library=lib] [-migration] [-misalign] [-mt] [-native] [-noex] [-nofstore] [-nolib] [-nolibmil] [-noqueue] [-norunpath] [-O[n]] [-o file] [+p] [-P] [-p] [-pen- tium] [-pg] [-PIC] [-pic] [-pta] [-ptidir] [-pto] [-ptrdir] [-ptv] [(-Qoption|-qoption) phase option [(-Qproduce|-qproduce) type [-qp] [-Rpath] [-readme] [-S] [-s] [-sb] [-sbfast] [-staticlib=lib] [-temp=dir] [-template=w] [-time] [-Uname] [-unroll=n] [-V] [-v] [-vdelx] [-verbose=v] [+w] [+w2] [-w] [-xa] [-xar] [-xarch=a] [-xcache=c] [-xcg(89|92)] [-xchip=c] [-xcode=v] [-xF] [-xhelp=(flags|readme)] [-xild(off|on)] [-xinline=rlst] [-xlibmieee] [-xlic_lib=lib] [-xlicinfo] [-Xm] [-xM] [-xM1] [-xMerge] [-xnolib] [-xnolibmil] [-xnolibmopt] [-xO[n]] [-xpg] [-xprefetch[=(yes|no)]] [-xprofile=p] [-xregs=r] [-xs] [-xsb] [-xsbfast] [-xspace] [-xtarget=t] [-xtime] [-xunroll=n] [-xwe] [-ztext] [file] ... Release 5.0 This release supports standard C++ and SPARC v9. Be sure to read the C++ README file by using the command: CC -xhelp=readme DESCRIPTION CC converts C++ and assembly source files to object files, and links object files and libraries into executable pro- grams. Programs containing C++ objects must be linked with CC. CC takes arguments ending in .c, .C, .cc, .cxx, .cpp, or .i to be C++ source programs. The .i files are presumed to be preprocessed files. Arguments ending in .s are presumed to be assembly source files Arguments ending in .o are presumed to be object files. Files whose names do not end with the above suffixes are treated as object programs or libraries and are handed over to the link editor. Unless -c, -S, -E, or -P is specified, these programs and libraries, together with the results of any specified compilations or assemblies, are linked in the order given to produce an output file named a.out. You can specify a name for the executable by using the -o option. If a single file is compiled and linked all at once, the intermediate files are deleted. The Incremental Link Editor (iilldd) is sometimes used in place of linker lldd for incremental linking. See -xildon and -xild- off for more information. Before you use the CC command, insert the name of the direc- tory in which you have chosen to install the C++ compilation system at the beginning of your search path. For instruc- tions on setting your search path, see the csh(1) or the sh(1) man page. COMPILING FOR 64-BIT SOLARIS 7: This version of the compiler can produce 64-bit object binaries on 32-bit or 64-bit Solaris 7 SPARC Platform Edi- tion. The resulting executable will run only on 64-bit SPARC or UltraSPARC processors under Solaris 7 with the 64- bit kernel. Compilation, linking, and execution of 64-bit objects can only take place in a Solaris 7 environment. Compiling for 64-bit Solaris 7 is indicated by the -xarch=v9 and -xarch=v9a options. Note that one of these options must be specified even if -xtarget or -fast are also specified. In such a case, the -xarch=v9 or -xarch=v9a option must appear AFTER any -xtarget or other option that sets For example: -xtarget=ultra -xarch=v9 Note that -xtarget=ultra and -xtarget=ultra2 imply -xarch=v8 and do not automatically signal -xarch=v9 or -xarch=v9a. When building shared dynamic libraries with -xarch=v9 or v9a on 64-bit Solaris 7, the -Kpic or -KPIC option MUST ALSO be specified. See also the new -xcode=abs32|abs64|pic13|pic32 option for specifying code address forms. 64-bit Solaris 7 not only enables 64-bit integer and pointer data, but also support for large files and large arrays. For more details, see the README file: <install directory> /SUNWspro/READMEs/64bit_Compilers (where <install-directory> is usually /opt in a standard install. ) For general information on 64-bit Solaris for software developers, see the "Solaris 7 64-bit Developer's Guide" in AnswerBook2. OPTIONS For a complete description of the C++ compiler options, including examples, see the C++ User's Guide. CC accepts the following options: -386 (x86) Use -xtarget=386. -486 (x86) Use -xtarget=486. -a Use -xa. See also the tcov(1) man page. -Bbinding Specifies whether library bindings for linking are dynamic (shared) or static (nonshared). The values for binding are static and dynamic. -Bdynamic is the default. You can use the -B option to toggle several times on a command-line. For more information on the -Bbinding option, see the ld(1) man page and the Solaris documentation. -Bdynamic-Directs the link editor to look for liblib.so files. Use this option if you want shared library bindings for linking. If the liblib.so files are not found, it looks for liblib.a files. -Bstatic - Directs the link editor to look only for files named lliibblib..aa. The .a suffix indicates that the file is static, that is, nonshared. Use this option if you want nonshared library bindings for linking. This option and its arguments are passed to the linker, ld. If you compile and link in separate steps, and use -Bbinding on the command line, you must use it in the link step as well. -c Directs the CC driver to suppress linking with ld and produces 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. For example: o If you enter CC -c x.cc, the object file, x.o, is generated. o If you enter CC -c x.cc -o y.o, the object file, y.o, is generated. See also -o filename. -cg(89|92) Use -xcg(89|92). See also -xtarget=native. -compat[=(4|5)] Sets the compiler to be compatible with 4.0.1, 4.1, and 4.2 compilers; or with full 5.0. This option controls the preprocessor __cplusplus macro. The C++ compiler has two principal modes. One accepts the semantics and language defined by the Annotated C++ Reference Manual (ARM) and used in the 4.2 compiler (the compatibility mode, -com- pat=4). The other accepts constructs according to the ANSI/ISO standard (standards mode, -compat=5). These two modes are incompatible with each other because the ANSI/ISO standard forces significant, incompatible changes in name mangling, vtable lay- out, and other ABI details. These two modes are differentiated by the -compat option as shown in the following values. Value Meaning -compat=4 Compile for compatibility with C++ 4.0.1, C++ 4.1, and C++ 4.2 (Sets __cplusplus macro to 1.) -compat=5 Compile with full C++ 5.0 features. (Sets __cplusplus macro to 199711L.) Defaults: If the -compat option is not specified, -compat=5 is assumed. If only -compat is specified, -com- pat=4 is assumed. Interactions: The -xarch=v9 option and the -compat[=4] option are not supported when used together. +d Prevents the compiler from expanding C++ inline functions. This option is turned on when you specify -g, the debugging option. The debugging option, -g0, does not turn on +d. See -g0. Warning: For large programs that rely heavily on inline functions, the amount of additional code generated may be substantial. -Dname[=def] Defines a macro symbol name to the preprocessor. Doing so is equivalent to including a #define directive at the beginning of the source. If you do not use =def, name is defined as 1. You can use multiple -D options. The following values are predefined: SPARC and x86: __BUILTIN_VA_ARG_INCR __cplusplus __DATE__ __FILE__ __LINE__ __STDC__ __SVR4 __SUNPRO_CC = 0x500 __SUNPRO_CC_COMPAT = 4 or 5 __sun sun __TIME__ __`uname -s`_`uname -r` (replacing invalid charac- ters with underscores, for example: -D__SunOS_5_3, -D__SunOS_5_4) __unix unix _WCHAR_T __ARRAYNEW if the "array" forms of operators new and delete are enabled (see "- features=[no%]arraynew") _BOOL if type bool is enabled (see "- features=[no%]bool") SPARC only: __sparc sparc (32-bit compilation modes only) SPARC V9 only: __sparcv9 (64-bit compilation modes only) x86 only: __i386 i386 Defaults: If you do not use [=def], name is defined as 1. Warnings: If +p is used, sun, unix, sparc and i386 are not defined. -d(y|n) Allows or disallows dynamic libraries for the entire executable. -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. Warning: If you compile and link in separate steps, and use -dn|dy in the compile command, you must use -dn|dy in the link step as well. -dalign (SPARC) Generates double-word load and store instructions whenever possible for improved per- formance. This option assumes that all double- typed data are double-word-aligned. If you com- pile one unit with -dalign, compile all units of a program with -dalign, or you might get unexpected results. -dryrun Displays what options the driver has passed to the compiler. This option directs the driver CC to show, but not execute, the commands constructed by the compilation driver. -E 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++ com- piler when templates are used. +e(0|1) Controls virtual table generation. Invalid and ignored in compat=5 mode. Values: o +e0 suppresses the generation of virtual tables, and creates external references to those that are needed. o +e1 creates virtual tables for all defined classes with virtual functions. -fast Selects a combination of compilation options for optimum execution speed. This option provides near maximum performance for most applications by expanding the following compilation options: -dalign (SPARC only) -fns (SPARC) -fsimple (SPARC only) -ftrap=%none (SPARC, x86) -xlibmil (SPARC, x86) -nofstore (x86 only) -xO4 (SPARC, x86) -xlibmopt (SPARC, x86 only) -xtarget=native (SPARC, x86) Interactions: If you combine -fast with other compilation options, the -dalign option applies; see the description for -dalign. The code generation option, the optimization level, and use of inline template files can be overridden by subsequent flags. For example, although the optimization level set by -fast is -xO4, if you specify -fast -xO3, the optimization level becomes -xO3. The optimization level that you specify will override a previously set optimi- zation level. Warnings: Do not use this option for programs that depend on IEEE standard floating-point exception handling; different numerical results, premature program termination, or unexpected SIGFPE signals might occur. Note-The criteria for the -fast option vary with the Sun C, C++, FORTRAN 77, and Pascal compilers. Please see the appropriate documentation for the specifics. The -fast option includes -fns -ftrap=%none; that is, this option turns off all trapping. In previ- ous SPARC releases, the -fast macro option included -fnonstd, now it does not. See the Numerical Computation Guide, ieee_sun(3m). -features=a Enables/disables various C++ language features. The following flags are valid for both -compat=4 and -compat=5 unless otherwise specified. Value Meaning [no%]altspell [Do not] Recognize alternative token spellings (for example, "and" for "&&"). [no%]anachronisms [Do not] Allow anachronistic con- structs. [no%]arraynew (-compat=4 only) [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. For details on the use of this flag with -compat=5, see the Migration Guide. [no%]bool [Do not] Allow the bool type and literals. When enabled, the macro _BOOL = 1. When disabled, the macro is not defined. [no%]conststrings [Do not] Put literal strings in Read-Only memory. [no%]except [Do not] Allow C++ exceptions. [no%]explicit [Do not] Recognize the keyword explicit. [no%]export [Do not] Recognize the keyword export. [no%]iddollar [Do not] Allow a $ as a non-initial identifier character. [no%]localfor [Do not] Use new local-scope rules for the for statement. [no%]mutable [Do not] Recognize the keyword mut- able. [no%]namespace (-compat=4 only) [Do not] Recognize keywords namespace, using. [no%]rtti (-compat=4 only) [Do not] Allow runtime type identification (RTTI). Defaults: If -features is not specified, the fol- lowing is assumed for -compat=4: -features=%none, anachronisms, except, longlong, transitions. If -features is not specified, the following is assumed for -compat=5: -features=%all,no%iddollar. -flags Displays a brief description of each compiler flag. Also displayed are: phone numbers to call to obtain additional information on Sun products and for technical support. (This option is the same as -help.) -fnonstd (x86) Causes nonstandard initialization of floating-point arithmetic hardware. In addition, this 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 ter- minates with a memory dump (unless you limit the core dump size to 0). Default: If -fnonstd is not specified, IEEE 754 floating-point arithmetic exceptions do not abort the program, and underflows are gradual. See the Numerical Computation Guide for more information. -fns[=(no|yes)] (SPARC) Selects SPARC non-standard floating-point mode. Default: Without this flag, the nonstandard float- ing point mode is not enabled automatically. Stan- dard IEEE 754 floating-point computation takes place, that is, underflows are gradual. This flag causes the nonstandard floating-point mode to be enabled when a program begins execu- tion. On some SPARC platforms, 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 platforms that do not support gra- dual underflow and subnormal numbers in hardware, use of this option can significantly improve the performance of some programs. Optional use of =yes or =no provides a way of tog- gling the -fns flag following some other macro flag that includes -fns, such as -fast. -fns is the same as -fns=yes. -fns=yes selects non-standard floating point. -fns=no selects standard floating point. Warnings: When nonstandard mode is enabled, floating-point arithmetic may produce results that do not conform to the requirements of the IEEE 754 standard. This option is effective only on SPARC platforms and only if used when compiling the main program. On x86 systems, the option is ignored. If you compile one routine with -fns, then compile all routines of the program with the -fns option; otherwise you can get unexpected results. -fprecision=p (x86) Sets floating-point rounding precision mode. p must be one of: single, double, extended. The -fprecision flag 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, sub- tract, multiply, divide, and square root) are rounded. The following table shows the meanings of the values of p: Value Meaning single Rounds to an IEEE single-precision value double Rounds to an IEEE double-precision value extended Rounds to the maximum precision avail- able When p is single or double, this flag causes the rounding precision mode to be set to single or double precision, respectively, when a program begins execution. When p is extended or the -fpre- cision flag is not used, the rounding precision mode remains as 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 pre- cision 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. The nominal precision of the float type is single. The nominal precision of the long double type is extended. Defaults: When the -fprecision flag is not specified, the rounding precision mode defaults to extended. Warnings: This option is effective only on x86 devices and only if used when compiling the main program. On SPARC devices, this option is ignored. -fround=r Sets the IEEE rounding mode in effect at startup. r must be one of: nearest, tozero, negative, positive. Value Meaning nearest Rounds towards the nearest number and breaking ties to even numbers. tozero Round-to-zero. negative Round-to-negative-infinity. positive Round-to-positive-infinity. Default: When the -fround option is not speci- fied, the rounding mode defaults to -fround=nearest. This option sets the IEEE 754 rounding mode that: o Can be used by the compiler in evaluating con- stant expressions. o Is established at runtime during the program initialization. function, The meanings are the same as those for the ieee_flags which may be used to change the mode at runtime. If you compile one routine with -fround=r , com- pile all routines of the program with the same -fround=r option; otherwise, you can get unex- pected results. This option is effective only if used when compiling the main program. -fsimple[=n] Selects floating-point optimization preferences. If n is present, it must be 0, 1 or 2. The following table shows the -fsimple values: Value Meaning 0 Permits no simplifying assumptions. Preserves strict IEEE 754 conformance. 1 Allows conservative simplification. The resulting code does not strictly conform to IEEE 754, but numeric results of most pro- grams are unchanged. With -fsimple=1 , the optimizer can assume the following: IEEE 754 default rounding/trapping modes do not change after process initializa- tion Computation producing no visible result other than potential floating point exceptions might be deleted Computation with infinities or NaNs as operands needs to propagate NaNs to their results; e.g., x*0 might be replaced by 0 Computations do not depend on sign of zero With -fsimple=1, the optimizer is not allowed to optimize completely without regard to roundoff or exceptions. In particular, a floating point computation cannot be replaced by one that produces different results with rounding modes held constant at runtime. -fast implies -fsimple=1. 2 Permits aggressive floating point optimiza- tion that may cause many programs to produce different numeric results due to changes in rounding. For example, permits the optimizer to replace all computations of x/y in a given loop with x*z, where x/y is guaranteed to be evaluated at least once in the loop, z=1/y , and the values of y and z are known to have constant values during execution of the loop. Defaults: If -fsimple is not designated, the compiler uses -fsimple=0. If -fsimple is designated but no value is given for n, the compiler uses -fsimple=1. Interactions: -fast implies -fsimple=1. Warnings: This option can break IEEE 754 conformance. -fstore (x86) Forces precision of floating-point expres- sions. 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 - when that expression or function is assigned to a variable, or when that expression is cast to a shorter floating-point type rather than leaving the value in a register. To turn off this option, use the -nofstore option. Warnings: Due to roundoffs and truncation, the results may be different from those that are generated from the register values. -ftrap=t Sets the IEEE trapping mode in effect at startup. This option sets the IEEE 754 trapping modes that are established at program initialization, but does not install a SIGFPE handler. You can use ieee_handler to simultaneously enable traps and install a SIGFPE handler. When more than one value is used, the list is processed sequentially from left to right. t is a comma-separated list that consists of one or more of the following: Value 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 meanings of the %all or common value and 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. Defaults: If -ftrap is not specified, the -ftrap=%none value is assumed. (Traps will not be enabled automati- cally.) Examples: When one or more terms is given, the list is pro- cessed sequentially from left to right, thus -ftrap=%all, no%inexact means to set all traps except inexact. Interactions: The mode may be changed at runtime with ieee_handler(3). Warnings: 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. Use the -ftrap=inexact trap with caution, as it will result in the trap being issued whenever a floating-point value cannot be represented exactly. For example, the following statement may generate this condition: x = 1.0 / 3.0; This option is effective only if used when compil- ing the main program. -G Instructs the linker to build a dynamic shared library instead of an executable file; see the ld(1) man page and the C++ Library Reference. All source files specified in the command-line are compiled with -Kpic by default. When building a shared library that uses tem- plates, it is necessary in most cases to include in the shared library those template functions that are instantiated in the template database. Using this option automatically adds those tem- plates to the shared library as needed. The following options are passed to ld if -c is not specified: o -dy o -G -g Instructs both the compiler and the linker to prepare the file or program for debugging. The tasks include: o Producing more detailed information, known as stabs, in the symbol table of the object files and the executable o Producing some "helper functions," which the Debugger can call to implement some of its features o Disabling the inline generation of functions; that is, using this option implies the +d option o Disabling certain levels of optimization. Interactions: You can use this option along with -O for the optimization level that you desire. If you use this option with -xO, you will get limited debugging information. This option makes -xildon the default incremen- tal linker option in order to speed up the compile-edit-debug cycle. See the description for -xildon and -xildoff. This option invokes ild in place of ld unless any of the following are true: o The -G option is present o The -xildoff option is present o Any source files are named on the command line. See also the explanations for -g0 and +d, as well as the ld(1) man page. The Debugging a Program with Sun WorkShop guide pro- vides details about dbx stabs and "lazy stabs." -g0 Instructs the compiler to prepare the file or pro- gram for debugging, but not to disable inlining. This option is the same as -g, except that +d is disabled. See also the description for the +d option. -H On the standard error output (stderr), prints, one per line, the path name of each #include file con- tained in the current compilation. -hname Assigns the name name to the generated shared dynamic library. This is a loader option, passed to ld. In gen- eral, 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 needed shared library files. When the runtime linker links the library into an execut- able 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. This command- line is an example: % CC -G -o libx.so.1 -h libx.so.1 a.o b.o c.o -help Use -flags. -i Tells the linker, ld(1), to ignore any LD_LIBRARY_PATH setting. -Ipathname 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 this order: 1. For includes in the form #include (where quo- tation marks are used), the directory containing the source. 2. For includes in the form <foo.h> (where angle brackets are used), the directory containing the source file is not searched. 3. In the directories named with -I options, if any. 4. In the directories for compiler-provided C++ header files: /opt/SUNWspro/SC5.0/include/CC for compat=5 or CC4 for compat=4; the actual path depends on where the compiler was installed. 5. In the directories for compiler-provided ANSI C header files: /opt/SUNWspro/SC5.0/include/CC for compat=5 or CC4 for compat=4; the actual path depends on where the compiler was installed. 6. In /usr/include Note- If -ptipath is not used, the compiler looks for template files in -Ipathname. It is recommended that you use -Ipathname instead of -ptipath. -inline=rlst Use -xinline=rlst. -instances=a Controls the placement and linkage of template instances. The following table shows the meanings of the values of a: Value Meaning extern Places all needed instances into the template repository and gives them glo- bal linkage. (If an instance in the repository is out of date, it will be 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 glo- bal 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. Default: If instances is not specified, -instances=extern is assumed. Warnings: 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. The static and semiexplicit values may produce invalid results. See the C++ User's Guide. -keeptmp Retains the temporary files that are created dur- ing compilation. Along with -verbose=diags, this option is useful for debugging. -KPIC (SPARC) Same as -xcode=pic32. (x86) Same as -Kpic. -Kpic (SPARC) Same as -xcode=pic13. (x86) Produces position-independent code. Use this option to compile source files when building a shared library. Each reference to a global datum is generated as a dereference of a pointer in the global offset table. Each function call is gen- erated in pc-relative addressing mode through a procedure linkage table. -Ldir Adds dir to the list of directories to be searched for libraries. This option is passed to ld. The directory, dir, is searched before compiler-provided directories. -llib Add library liblib.a or liblib.so to 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 can 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 names. -libmieee Use -xlibmieee. -libmil Use -xlibmil. -library=l Incorporates specified CC-provided libraries into compilation and linking. If this option is specified, the proper -I paths are set during compilation. The proper -L, -Y P, -R paths, and -l options are set during linking. Values: l is a comma-separated list of library specifiers. The following table shows the meanings of the values for l: For -compat=4: Value Meaning [no%]rwtools7 [Do not] Use Tools.h++ v7 [no%]rwtools7_dbg [Do not] Use debug-enabled Tools.h++ v7 [no%]complex [Do not] Use libcomplex, complex arith- metic [no%]libC [Do not] Use libC, C++ support [no%]gc [Do not] Use libgc, garbage collection [no%]gc_dbg [Do not] Use debug-enabled libgc, gar- bage collection %all Use all libraries, in the order rwtools7, complex, gc, libC %none Use none of the above For -compat=5: Value Meaning [no%]rwtools7 [Do not] Use Tools.h++ v7 [no%]rwtools7_dbg [Do not] Use debug-enabled Tools.h++ v7 [no%]iostream [Do not] Use libiostream, the classic iostreams library. (If using this value, do not use Cstd) [no%]Cstd [Do not] Use libCstd, C++ standard library (If using this value, do not use iostream) [no%]Crun [Do not] Use libCrun, C++ runtime library [no%]gc [Do not] Use libgc, garbage collection. [no%]gc_dbg [Do not] Use debug-enabled libgc, gar- bage collection. %all Use all libraries, in the order %none,rwtools7,Cstd, %none Use none of the above Defaults: For -compat=4, if -library is not specified, -library=%none, libC For -compat=5, if -library is not specified, -library=%none,Cstd,Crun Examples: To link without any C++ libraries, use CC -library=%none To use the older classic iostreams facility rather than the newer standard C++ library, use CC -library=iostream,no%Cstd To use RogueWave tools.h++ v7 libraries, use CC -library=rwtools7 Interactions: Only one rwtools library can be used at a time. Only one of iostream or Cstd may be used. Libraries are linked in the order listed above. Programs linking neither libC nor Crun might not use all features of the C++ language. The specified libraries are linked after user- specified libraries, and before system support libraries. Warnings: The set of libraries is not stable and might change from release to release. See also: -I,-l,-R, C++ Library Reference, Tools.h++User'sGuide, Tools.h++ Class Library Reference , C++ Standard Reference Library -migration Displays a pointer to the C++ Migration Guide, which contains information about incompatibilities between versions 4.0.1, 4.1, and 4.2 of the com- piler and the 5.0 compiler. NOTE - This option might cease to exist in the next release. -misalign (SPARC) Permits misaligned data, which would oth- erwise generate an error, in memory. 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 peformance when you run the program. If possible, do not link aligned and misaligned parts of the program. -mt Compile and link 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. This flag is required if the application or libraries are multithreaded. Warnings: To ensure proper library linking order, use this option, rather than -lthread. See also: -xnolib. -native Use -xtarget=native. -noex Use -features=no%except. -nofstore (x86) Disables forced precision of 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 that expression or func- tion is assigned to a variable, or is cast to a shorter floating-point type. See also -fstore. -nolib Use -xnolib. -nolibmil Use -xnolibmil. -noqueue Disables license queueing. If no license is available, this option returns without queueing your request and without compiling. A nonzero status is returned for testing makefiles. -norunpath Does not build the 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, who need not work with that nonstandard location. Interactions: 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 run time to specify the loca- tion of the shared libraries. This will allow the runtime linker to find the shared libraries. -O Same as -xO2 -xO[level] Use -xO[level]. -o filename Sets the name of the output file (with the suffix, .o) or the executable file to filename. Warning: filename must have the appropriate suf- fix for the type of file to be produced by the compilation (see FILES). It cannot be the same file as the source file, since the CC driver does not overwrite the source file. +p Use -features=no%anachronisms. -P Only preprocesses source: does not compile. (Out- puts a file with a .i suffix.) This option does not include preprocessor-type line number information in the output. -p Prepares the object code to collect data for pro- filing with prof. This option invokes a runtime recording mechanism that produces a mon.out file at normal termination. You can also perform this task with the Analyzer. Refer to the analyzer(1) man page. -pentium (x86) Use -xtarget=pentium. -pg Use -xpg. -PIC Use -KPIC. -pic Use -Kpic. -pta Use -template=wholeclass. -ptipath Specifies an additional search directory for tem- plate source. This option is an alternative to the normal search path set by -Ipathname. If the -ptipath flag is used, the compiler looks for template definition files on this path and ignores the -Ipathname flag. Using -Ipathname flag instead of -ptipath produces less confusion. -pto Use -instances=static. -ptrpath Specifies the directory of the template reposi- tory. The template repository cache files are stored in path/SunWS_cache. The template repository confi- guration files are stored in path/SunWS_config. You cannot use multiple -ptr options. Examples: -ptr/tmp/Foo specifies the repository subdirectories /tmp/Foo/SunWS_cache and /tmp/Foo/SunWS_config. Interactions: The subdirectory names can be changed with the environmental variables SUNWS_CACHE or SUNWS_CONFIG . Warnings: If you use -ptr to compile, you must also use -ptr to link. -ptv Use -verbose=template. -Qoption phase option Passes the option, to the compilation phase. To pass more than one option, specify them in order as a comma-separated list. The following table shows the possible values for prog: SPARC Architecture x86 Architecture ccfe ccfe iropt cg386 cg codegen CClink CClink ld ld Examples: In the following command-line, when ld is invoked by the CC driver, -Qoption passes the option, -i to ld: % CC -Qoption ld -i test.c -qoption phase option Use -Qoption. -qp Same as -p. -Qproduce sourcetype Causes the CC driver to produce source code of the type sourcetype. Source code types are shown in the following table: Value Meaning .i Preprocessed C++ source from ccfe .o Object file from cg, the code gen- erator .s Assembler source from cg -qproduce sourcetype Use -Qproduce. -Rpathname Builds dynamic library search paths into the exe- cutable file. Multiple instances of -Rpathname are concatenated, with each pathname separated by a colon. Without this option specified, the compiler passes one of the following default search paths to the linker: /opt/SUNWspro/lib (for standard installs) <install_path>/lib (for non-standard installs into <install_path> If both the LD_RUN_PATH and the -R option are specified, then the path from -R is scanned, and the path from LD_RUN_PATH is ignored. This option is passed to ld. -readme Displays the contents of the README file. The README file is paged by the command specified by the environment variable, PAGER. If PAGER is not set, the default paging command is more. -S Compiles and generates only assembly code. This option causes the CC driver to compile the program and output an assembly source file, but not assem- ble the program. The assembly source file is named with a .s suffix. -s Strip the symbol table from the executable file. This option removes all symbol information from output executable files. This option is passed to ld. -sb Use -xsb. -sbfast Use -xsbfast. -staticlib=l Indicates which C++ libraries are to be linked statically. Values: The following table shows the meanings of the values of l. Value Meaning [no%]library See -library for the specific libraries. %all Link all libraries specified in the -library option statically. %none Link no libraries statically. Default: If -staticlib is not specified, -staticlib=%none is assumed. Interactions: For C++ libraries selected explicitly with the -library option or implicitly through its defaults, libraries specified with -staticlib are linked statically. If a library specified with -staticlib is not selected with -library or its defaults, it is not linked. Examples: CC -staticlib=Crun links libCrun statically because Crun is a default value for -library. However, CC -library=no%Cstd -staticlib=Cstd will not link Crun at all because Crun is not in the specified -library set. Warnings: This set of libraries is not stable and might change from release to release. -temp=dir Defines directory for temporary files. This option sets the name of the directory for the temporary files, generated during the compilation process, to be dir. See also -keeptmp. -template=w Enables/disables various template options. The following table shows the meaning of the value of w: Value Meaning [no%]wholeclass Directs the compiler [not] to instan- tiate a whole template class, rather than only those functions that are used. This option creates a .o file for each member of a class. You must reference at least one member of the class; otherwise, the compiler does not instantiate any members for the class. -time Use -xtime. -Uname Deletes command-line definition of preprocessor symbol name. This option affects only -D options on the command line, including those implicitly placed there by the CC driver. It has no effect on other predefined macros or on macro definitions in source files. The -U option is: o Equivalent to putting #undef on the first line of the first file seen by the compiler. o The inverse of the -D option. You can specify multiple -U options on the command-line. Warnings: This option is order-sensitive if used with the -D option, and is processed after all -D options are processed. -unroll=n Same as -xunroll=n. -V Same as -verbose=version. -v Same as -verbose=diags. -vdelx This is an obsolete flag that will be removed in future releases. This flag is available only for -compat=4. Don't use this flag unless you have bought some software from a third-party vendor and the vendor recommends using this flag. For expressions using delete[], this option gen- erates 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 an addi- tional third argument: the address of the des- tructor for the class. This third argument is not used by the function but is provided to be used by third-party vendors. Default: The compiler generates a call to _vector_delete_ for expressions using delete[]. -verbose=v Controls compiler verbosity. v is a comma- separated list consisting of one or more of the following: [no%]template, [no%]diags, [no%]version, %all, %none. You can specify more than one option, for example, -verbose=template,diags The following table shows the meanings of the values of v: Value Meaning [no%]template [Do not] Turn on the verbose mode, some- times called the verify mode. The ver- bose mode displays each phase of instan- tiation as it occurs during compilation. Use this option if you are new to tem- plates. [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. +w Prints extra warnings where necessary. Generates additional warnings about all question- able constructs that are: o Nonportable o Likely to be mistakes o Inefficient Default: If +w is not specified, the compiler warns about constructs that are almost certainly problems. +w2 Prints even more warnings. -w Suppresses warning messages. This option causes the compiler not to print warn- ing messages. Some warnings, particularly anachronistic ones, cannot be suppressed. -xa Generates code for profiling. If set at compiler time, the TCOVDIR environment variable specifies the directory where the cover- age (.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. See -xprofile=tcov for information on the new style of profiling, the tcov (1) man page, and Profiling Tools for more details. Interactions: The -xprofile=tcov and the -a options are compati- ble 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 -a. You cannot compile a sin- gle file with both options. -xa is incompatible with -g. Warnings: If you compile and link in separate steps, and you compile with -xa, then be sure to link with -xa, or you might get unexpected results. -xar Creates archive libraries. When building a C++ archive that uses templates, it is necessary in most cases to include in the archive those template functions which are instan- tiated in the template database. Using this option automatically adds those templates to the archive as needed. Example: CC -xar -o libmain.a a.o b.o c.o archives the template functions contained in the library and object files. Warnings: 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. -xarch=a Specifies the target architecture set. Although this option can be used alone, it is part of the expansion of the -xtarget option. Its pri- mary use is to override a value supplied by the - xtarget option. This option limits the instructions generated to those of the specified architecture, and allows the specified set of instructions. It does not guarantee an instruction is used; however, under optimization, it is usually used. Values: On SPARC platforms, must be one of: generic, v7, v8a, v8, v8plus, v8plusa, v9, v9a. On x86 devices, a must be one of: generic, 386, 486, pentium, pentium_pro. SPARC architectures v7, v8a, and v8 are all binary compatible. v8plus and v8plusa are binary compati- ble with each other and they are forward, but not backward, compatible. For any particular choice, the generated execut- able can run much more slowly on earlier architec- tures. The following table shows the -xarch values: Value Meaning generic Gets good performance on most SPARC architectures, major degradation on none. This is the default. With each new release, this best instruction set will be adjusted, if appropriate. v7 Limits instruction set to v7 architec- ture. This option uses the best instruction set for good performance on the v7 architecture, but without the quad- precision floating-point instructions. This is equivalent to using the best instruction set for good performance on the v8 architecture, but without the following instructions: The quad-precision floating-point instructions The integer mul and div instruc- tions The fsmuld instruction Examples: SPARCstation 1, SPARCstation 2 v8 Limits instruction set to v8 architec- ture. This option uses the best instruction set for good performance on the v8 architecture, but without quad- precision, floating-point instructions. Examples: SPARCstation 10 v8a Limits instruction set to the v8a ver- sion of the v8 architecture. By definition, v8a means the v8 archi- tecture but without: The quad-precision floating-point instructions The fsmuld instruction This option uses the best instruction set for good performance on the V8a architecture. Example: Any machine based on MicroSPARC 1. v8plus Limits instruction set to the V8plus version of the V9 architecture. By definition, V8plus means the V9 architecture, but: Without the quad-precision floating-point instructions Limited to the 32-bit subset defined by the v8plus specification This option uses the best instruction set for good performance on the v8plus chip architecture. In v8plus, a system with the 64-bit registers of v9 runs in 32-bit addressing mode, but the upper 32 bits of the i and l registers must not affect program results. This choice does not include the VIS instructions. Example: any machine based on UltraSPARC Use of this option also causes the .o file to be marked as a v8plus binary. Such files will not run on a v7 or v8 machine. v8plusa Limits instruction set to the v8plusa architecture variation. By definition, v8plusa means the v8plus architecure plus: The UltraSPARC-specific instruc- tions The VIS instructions This option uses the best instruction set for good performance on the UltraSPARC TM architecture, but limited to the 32-bit subset defined by the v8plus specification. Example: Any machine based on UltraSPARC Use of this option also causes the .o file to be marked as a Sun-specific v8plus binary. Such files will not run on a v7 or v8 machine. v9 Limits instruction set to the SPARC-V9 architecture. The resulting .o object files are in 64-bit ELF format and can only be linked with other object files in the same format. The resulting exe- cutable can only be run on a 64-bit SPARC processor running 64-bit Solaris 7 software with the 64-bit kernel. Compil- ing with this option uses the best instruction set for good performance on the V9 SPARC architecture, but without the use of quad-precision floating-point instructions. (Available only on 64-bit Solaris 7 software.) v9a Limits instruction set to the SPARC-V9 architecture, adding the Visual Instruc- tion Set (VIS) and extensions specific to UltraSPARC processors. The resulting .o object files are in 64-bit ELF for- mat, and can only be linked with other object files in the same format. The resulting executable can only be run on a 64-bit SPARC processor running 64-bit Solaris 7 software with the 64-bit ker- nel. Compiling with this option uses the best instruction set for good perfor- mance on the V9 UltraSPARC architecture, but without the use of quad-precision floating-point instructions. (Available only on 64-bit Solaris 7 software.) For x86 Platforms: o generic and 386 are equivalent in this release. o 486 , pentium , or pentium_pro directs the compiler to issue instructions for the corresponding Intel chip. Interactions: The -xarch=v9 option and the -compat[=4] options are not supported when used together. Warnings: If this option is used with optimiza- tion, the appropriate choice can provide good performance of the executable on the specified architecture. An inap- propriate choice, however, might result in serious degradation of performance. -xcache=c (SPARC) Defines the cache properties for use by the optimizer. This option specifies the cache properties that the optimizer can use. It does not guarantee that any particular cache property is used. Note - Although this option can be used alone, it is part of the expansion of the -xtarget option; its primary use is to override a value supplied by the -xtarget option. c must be one of the following: o generic o s1/l1/a1 o s1/l1/a1:s2/l2/a2 o s1/l1/a1:s2/l2/a2:s3/l3/a3 That is, -xcache={generic | s1/l1/a1[:s2/l2/a2[:s3/l3/a3]]}, where the 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 For example, i=1 designates level 1 cache properties, s1/l1/a1. The following table shows the -xcache values: Value Meaning generic Defines the cache properties for good performance on most SPARC pro- cessors. This is the default value which directs the compiler to use cache properties for good performance on most SPARC processors, without major performance degradation on any of them. s1/l1/a1 Defines level 1 cache properties. s1/l1/a1:s2/l2/a2 Defines levels 1 and 2 cache pro- perties. s1/l1/a1:s2/l2/a2:s3/l3/a3 Defines levels 1, 2, and 3 cache properties. Example: -xcache=16/32/4:1024/32/1 specifies the following: Level 1 cache has: Level 2 cache has: 16K bytes 1024K bytes 32-byte line size 32-byte line size 4-way associativity Direct mapping -xcg[89|92] (SPARC) Compiles for generic SPARC or SPARC V8 architecture. This option specifies the code generator for floating-point hardware on SPARC platforms released in 1989 or 1992. Use the fpversion com- mand to determine which floating-point hardware you have. If you compile one procedure of a pro- gram with this option, it does not mean that you must compile all the procedures of the program in the same way. -xcg89 generates code to run on generic SPARC architecture. -xcg89 is a macro for -xtarget=ss2 and expands to: -xarch=v7 -xchip=old -xcache=64/32/1. -xcg92 generates code to run on SPARC V8 architec- ture. -xcg92 is a macro for -xtarget=ss1000 and expands to: -xarch=v8 -xchip=super -xcache=16/64/4:1024/64/1. -xchip=c Specifies the target processor for use by the optimizer. c must be one of the following: On SPARC platforms: generic, old, super, super2, micro, micro2, hyper, hyper2, powerup, ultra, ultra2, ultra2i On x86 platforms: 386, 486, pentium, pentium_pro. Although this option can be used alone, it is part of the expansion of the -xtarget option; its pri- mary use is to override a value supplied by the -xtarget option. This option specifies timing properties by speci- fying the target processor. This option affects: o The ordering of instructions, that is, scheduling o The way the compiler uses branches o The instructions to use in cases where semant- ically equivalent alternatives are available. The -xchip values for SPARC: Value Meaning generic Uses timing properties for good perfor- mance on most SPARC processors. This is the default value that directs the compiler to use the best timing pro- perties for good performance on most SPARC processors, without major perfor- mance degradation on any of them. old Uses timing properties of pre-SuperSPARC TM processors. super Uses timing properties of the SuperSPARC chip. super2 Uses timing properties of the SuperSPARC II chip. micro Uses timing properties of the MicroSPARC TM chip. micro2 Uses timing properties of the MicroSPARC II chip. hyper Uses timing properties of the HyperSPARC TM chip. hyper2 Uses timing properties of the HyperSPARC II chip. powerup Uses timing properties of the Weitek PowerUp chip. ultra Uses timing properties of the UltraSPARC I chip. ultra2 Uses timing properties of the UltraSPARC II chip. ultra2i Uses timing properties of the UltraSPARC IIi chip. The following table shows the -xchip values for x86: The -xchip values for x86: Value Meaning generic Uses timing properties for good perfor- mance on most x86 processors. 386 Uses timing properties of the Intel 386 chip. 486 Uses timing properties of the Intel 486 chip. pentium Uses timing properties of the Intel Pen- tium chip. pentium_pro Uses timing properties of the Intel Pen- tium Pro chip. -xcode=a (SPARC) Specifies code address space. The follow- ing table shows the -xcode values: Value Meaning abs32 Generate 32-bit absolute addresses. Code + data + bss size is limited to 2**32 bytes. abs44 Generate 44-bit absolute addresses. Code + data + bss size is limited to 2**44 bytes. Available only on 64-bit architectures: -xarch=(v9|v9a) abs64 Generate 64-bit absolute addresses. Available only on 64-bit architectures: -xarch=(v9|v9a) pic13 Generate position-independent code (small model). Equivalent to -Kpic. Permits references to at most 2**11 unique external symbols on 32-bit archi- tectures, 2**10 on 64-bit. pic32 Generate position-independent code (large model). Equivalent to -KPIC. Permits references to at most 2**30 unique external symbols on 32-bit archi- tectures, 2**29 on 64-bit. Defaults: The default is -xcode=abs32 for SPARC V8 and V7. The default is -xcode=abs64 for SPARC and UltraSPARC V9 (with -xcg[89|92]. Interactions: When building shared dynamic libraries using -xarch=v9 or v9a on 64-bit Solaris 7 software, the -xcode=pic13 or pic32 (or -pic or -PIC ) option MUST be specified. -xF With -features=no%except, enables reordering of functions by the linker. If you compile with the -xF option, and then run the Analyzer, you generate a map file that shows an optimized order for the functions. The subse- quent 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 may not improve the overall performance of the application. Note- The -xF option will work only if you also specify -features=no%except The analyzer(1), debugger(1), and ld(1) man pages provide further details on this option. -xhelp=flags Same as -help. Displays list of compiler options. -xhelp=readme Same as -readme. Displays contents of online readme file. -xildoff 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 Turns on the Incremental Linker. This option is assumed if you use the -g option and not -G, and do not name any source file on the command line. Override this default by using the -xildoff option. -xinline=rlst Inlines specified routines. This option requests that the optimizer inline the user-written routines named in the rlst list - a comma-separated list of functions and subroutines. Inlining is an optimization technique whereby the compiler effectively replaces a function call with the actual subprogram code. Inlining often pro- vides the optimizer more opportunities to produce efficient code. Note - This option does not affect C++ inline functions and is not related to the +d option. The following restrictions apply - no warning is issued: o Optimization must be greater than -xO3. o The compiler determines if actual inlining is advantageous or safe. o The source for the routine must be in the file being compiled. Examples: % cat example.cc static int twice (int i) { return 2*1; } int main() { return twice( 3 ); } % CC -compat=4 -O example.cc % nm -C a.out | grep twice [37] | 68068| 8|FUNC |LOCL |0 |7 |twice(int) [__0FFtwicei] % CC -compat=4 -O -xinline=__0FFtwicei example.cc Interactions: o 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. o Adding the -xinline has no effect for optimi- zation levels below -xO3. At -xO4, the optim- izer 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 per- formance if they are inlined. If you force inlining of a function with -xinline, you might actually diminish performance. -xlibmieee Causes libm to return IEEE 754 values for math routines in exceptional cases. The default behavior of libm is XPG-compliant. -xlibmil Inlines selected library routines for optimiza- tion. 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. Note- This option does not affect C++ inline func- tions. -xlibmopt Uses a library of optimized math routines. This option uses a math routine library optimized for performance, and usually generates faster code. The results may be slightly different from those produced by the normal math library. If so, they usually differ in the last bit. The order on the command line for this library option is not significant. This option is implied by the -fast option. See also the descriptions for -fast and -xnolibmopt. -xlic_lib=l Links with the Sun-supplied, licensed libraries specified in l. -xlicinfo Shows license server information. This option returns the license-server name and the user ID for each user who has a license checked out. When you use this option, the com- piler is not invoked, and a license is not checked out. Generally, with this option, no compilation is done, and a license is not checked out. If a con- flicting option is used, then the latest one on the command line takes precedence, and a warning is issued. Examples: Do not compile; report license information. demo% CC -c -xlicinfo any.cc Compile; do not report license information. demo% CC -xlicinfo -c any.cc -Xm Use -features=iddollar. -xM Outputs makefile dependency information. Example: When you compile the following code #include <stdio.h> int main() (void) printf ("hello"); with this option: % CC -xM hello.c The output shows the dependencies: hello.o: hello.c hello.o: /opt/SunWSpro/SC5.0/include/CC/stdio.h hello.o: /usr/include/stdio.h See make(1) for details about makefiles and dependencies. -xM1 Generates dependency information, but excludes /usr/include. This is the same as -xM, except that this option does not report dependencies for the /usr/include header files. When you compile the same code provided with the -xM option, the output is: hello.o: hello.c -xMerge 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. -xnolib Disables linking with default system libraries. Normally, the C++ compiler links with several sys- tem libraries to support C++ programs. With this option, the -llib options to link the default sys- tem support libraries are not passed to ld. Normally, the compiler links with the following libraries in the following order: For -compat=4: -lm -lC -lw -lthread -lcx -lc (Use -lthread when -mt is specified; do not use -lthread when -mt is not specified.) For -compat=5: -lm -lCrun -lw -lthread -lcx -lc (Use -lthread when -mt is specified; do not use -lthread when -mt is not specified.) You must pass all -l options explicitly. The order of the -l options is significant. The -lm,-lw, and -lcx options must appear before -lc. Examples: For minimal compilation to meet the C application binary interface, that is, a C++ program with only C support required, use: CC -library=%none -xnolib test.cc -lc To link libm statically, into a single-threaded application on SPARC V8 platforms, use CC -xnolib -Bstatic -lm -Bdynamic -lw To link libm and libw statically, and link others dynamically: CC -xnolib -Bstatic -lm -lw -Bdynamic Interactions: 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. Warnings: The set of system support libraries is not stable and might change from release to release. -lcx is not present in 64-bit compilation mode. -xnolibmil Cancels -xlibmil on command line. Use this option with -fast to override linking with the optimized math library. -xnolibmopt Does not use the math routine library. Use this option after the -fast option on the command-line, as in: CC -fast -xnolibmopt ... -xOlevel Specifies optimization level. 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 may be sig- nificantly improved when compiled with an optimi- zation level than without optimization. Use of -xO (which implies -xO2) or -fast (which implies -xO4) is recommended for most programs. Generally, the higher the level of optimization with which a program is compiled, the better run- time performance obtained. However, higher optimi- zation levels may result in increased compilation time and larger executable files. There are five levels that you can use with -xO. The following sections describe how they differ for SPARC platforms, for x86, and for all plat- forms. Values: On SPARC Platforms: If the optimizer runs out of memory, it attempts to proceed over again at a lower level of optimi- zation, resuming compilation of subsequent rou- tines at the original level. -xO-This 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 if you are running out of swap space. -xO2 -Does basic local and global optimization, which includes: o Induction-variable elimination o Local and global common subexpression elimina- tion o Algebraic simplification o Copy propagation o Constant propagation o Loop-invariant optimization o Register allocation o Basic block merging o Tail recursion elimination o Dead-code elimination o Tail-call elimination o Complex-expression expansion This level does not optimize references or defini- tions for external or indirect variables. In gen- eral, this level results in minimum code size. -xO3-In addition to optimizations performed at the -xO2 level, also optimizes references and defini- tions for external variables. This level does not trace the effects of pointer assignments. When compiling either device drivers that are not prop- erly 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 con- tained in the same file in addition to performing -xO3 optimizations. This automatic inlining usu- ally improves execution speed, but sometimes makes it worse. In general, this level results in increased code size. -xO5-Does the highest level of optimization, suit- able only for the small fraction of a program that uses the largest fraction of computer time. 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. On x86 Platforms: -xO1-Preloads arguments from memory; causes cross jumping (tail merging), as well as the single pass of the default optimization. -xO2-Schedules both high- and low-level instruc- tions, and performs improved spill analysis, loop memory-reference elimination, register lifetime analysis, enhanced register allocation, global common subexpression elimination, and optimiza- tions done by level 1. -xO3-Performs loop strength reduction, inlining, as well as optimization done by level 2. -xO4-Performs architecture-specific optimization, as well as optimization done by level 3. -xO5-Generates the highest level of optimization. Uses optimization algorithms that take more compi- lation time or that do not have as high a cer- tainty of improving execution time. On SPARC and x86 Platforms: In general, program execution speed depends on level of optimization. The higher the level of optimization, the faster the speed. In a few cases, -xO2 may perform better than the others, and -xO3 may outperform -xO4. Try compil- ing 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, and resumes subse- quent procedures at the original level specified in the -xO option. If you optimize at -xO3 or -xO4 with very large procedures, such as thousands of lines of code in a single procedure, the optimizer might require an unreasonably large amount of memory. In such cases, performance of the machine might 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, on a machine with 32 megabytes, to limit virtual memory to 16 mega- bytes, the command: % limit datasize 16M, This command causes the optimizer to recover if it reaches 16 megabytes of data space. This limit cannot be greater than the total avail- able swap space of the machine, and the limit should be small enough to permit normal use of the machine while a large compilation is in progress. The best setting of data size depends on the degree of optimization requested, the amount of real memory, and virtual memory available. o To find the actual swap space, type: swap -1 o To find the actual real memory, type: dmesg | grep mem Interactions: o Debugging with -g does not supress -xO[level], but -xO[level] limits -g in certain ways. o The -xO3and-xO4 options reduce the utility of debugging so that you cannot display variables from dbx, but you can still use dbx where command to get a symbolic traceback. o Adding the -xinline has no effect for optimiza- tion levels below -xO3. At -xO4, the optimizer decides which functions should be inlined, and does so without the -xinline option being speci- fied. 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 dimin- ish performance. See also: -fast, -xprofile=p, csh(1) man page -xpg 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. Warnings: If you compile and link separately, and you compile with -xpg, then be sure to link with -xpg. You can also perform this task with the Analyzer. Refer to the analyzer(1) man page. -xprefetch[=(yes| (SPARC) Uses prefetch instructions on UltraSPARC II processors. With -xprefetch=yes, the compiler is free to insert prefetch instructions into the code it gen- erates. This may result in a performance improve- ment on UltraSPARC II processors. Defaults: If the -xprefetch option is not specified, the default is -xprefetch=no. Specifying -xprefetch alone is equivalent to -xprefetch=yes. -xprofile=p Collects or optimizes with runtime profiling data. p must be collect[:name], use[:name], or tcov. 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 a level of optimization is specified. If compilation and linking are performed in separate steps, the same -xprofile option must appear on the compile as well as the link step. Values: 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 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 sub- directory 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. This name is optional. If name is not specified, a.out is assumed to be the name of the executable. The program is optimized by using the execu- tion frequency data previously generated and saved in the feedback files written by a pre- vious 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 for tcov. It has simi- lar functionality to the -xa option, but correctly collects data for programs that have source code in header files or make use of C++ templates. See also -xa for informa- tion on the old style of prfiling, the tcov(1) man page, and the Performance Profil- ing Tools manual 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 can- not 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, the TCOVDIR environ- ment variable has no effect at compile-time. However, its value is used at program run- time. See tcov(1) and the Performance Pro- filing Tools manual for more details. The -xprofile=tcov option is incompatible with -g. -xregs=r Specify register usage (SPARC Only). Specify usage of registers in generated code. r is a comma-separated list of one or more of the following: [no%]appl, [no%]float. Example: -xregs=appl,no%float The -xregs values are for specific -xarch values): appl Allow using registers g2, g3, and g4. (v8, v8a) Allow using registers g2, g3, g4, and g5. (v8plus, v8plusa) Allow using registers g2, g3. (v9, v9a) no%appl Do not use appl registers. float Allow using floating-point registers as specified in the SPARC ABI. no%float Do not use floating-point registers. The default is: -xregs=appl,float. -xs Allows debugging by dbx without object ( .o) files. This option disables Auto-Read for dbx. Use this option in case you cannot keep the .o files around. This option passes -s 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 distributed in the .o files, so that dbx loads the symbol table information only if and when 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 files in order to use dbx. Without -xs , if you move the executables, then you must move both the source files and the object ( .o ) files in order to use dbx. -xsafe=mem (SPARC) Allows no memory-based traps occur. This option grants permission to use the specula- tive load instruction on V9 machines. It is only effective when used with -x05 optimization, and -xarch=v8plus, v8plusa, v9, or v9a is specified. Warnings: You should only use this option 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 han- dle exceptional conditions, this assertion is not safe. -xsb Produces information for the WorkShop source code browser. This option causes the CC driver to generate extra symbol table information in the SunWS_cache sub- directory for the source browser. See also: -xsbfast -xsbfast Produces only source browser information, no com- pilation. 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 -xspace (SPARC) Does not allow optimizations that increase code size. -xtarget=t Specifies the target system for instruction set and optimization. t must be one of: native, gen- eric, sytem-name The -xtarget option 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. The -xtarget values on SPARC platforms: Value Meaning native 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 run- ning. 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 speci- fied system. You select a system name from C++ User's Guide Table 3-15 that lists the mnemonic encodings of the actual system name and numbers. Note: The -compat and the -xtarget=v9 options are not supported when used together. Compiling for 64-bit Solaris 7 software on SPARC or UltraSPARC V9 platforms is indicated by the -xarch=v9|v9a flag. Setting -xtarget=ultra|ultra2 is not necessary or sufficient. If -xtarget is specified, the -xarch=v9|v9a option must appear after -xtarget, as in: -xtarget=ultra -xarch=v9 otherwise, the -xtarget setting will revert the -xarch value to v8. For x86 platforms, -xtarget accepts the following values: o native or generic o 386 (Directs the compiler to generate code for the best performance on the Intel 80386 microprocessor.) o 486 (Directs the compiler to generate code for the best performance on the Intel 80486 microprocessor.) o pentium (Directs (Directs the compiler to generate code for the best performance on the Pentium or Pentium Pro microprocessor.) This option is a macro. Each specific value for -xtarget expands into a specific set of values for the -xarch, -xchip, and -xcache options. Refer to Table 3-15 in the C++ User's Guide for the expanded values. Valid system names on SPARC are: sun4/15, sun4/20, sun4/25, sun4/30, sun4/40, sun4/50, sun4/60, sun4/65, sun4/75, sun4/110, sun4/150, sun4/260, sun4/280, sun4/330, sun4/370, sun4/390, sun4/470, sun4/490, sun4/630, sun4/670, sun4/690, sselc, ssipc, ssipx, sslc, sslt, sslx, sslx2, ssslc, ss1, ss1plus, ss2, ss2p, ss4, ss5, ssvyger, ss10, ss10/hs11, ss10/hs12, ss10/hs14, ss10/20, ss10/hs21, ss10/hs22, ss10/30, ss10/40, ss10/41, ss10/50, ss10/51, ss10/61, ss10/71, ss10/402, ss10/412, ss10/512, ss10/514, ss10/612, ss10/712, ss20/hs11, ss20/hs12, ss20/hs14, ss20/hs21, ss20/hs22, ss20/51, ss20/61, ss20/71, ss20/502, ss20/512, ss20/514, ss20/612, ss20/712, ss600/41, ss600/51, ss600/61, ss600/120, ss600/140, ss600/412, ss600/512, ss600/514, ss600/612, ss1000, sc2000, cs6400, solb5, solb6, ultra, ultra2, ultra2i, ultra1/140, ultra1/170, ultra1/200, ultra2/1170, ultra2/1200, ultra2/1300, ultra2/2170, ultra2/2200, ultra2/2300, entr2, entr2/1170, entr2/2170, entr2/1200, entr2/2200, entr150, entr3000, entr4000, entr5000, entr6000. Compiling for 64-bit Solaris 7 on SPARC or UltraSPARC V9 is indicated by the -xarch=v9 or -xarch=v9a flag. 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=ultra2 ... -xarch=v9 otherwise the -xtarget setting will revert the -xarch value to v8. On x86, -xtarget accepts: o generic or native o 386 (Directs the compiler to generate code for the best performance on the Intel 80386 microprocessor.) o 486 (Directs the compiler to generate code for the best performance on the Intel 80486 microprocessor.) o pentium or pentium_pro (Directs the compiler to generate code for the best performance on the Pentium or Pentium Pro microprocessor.) -xtime Causes the CC driver to report execution times for the various compilation passes. -xunroll=n 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 not to unroll loops. When n is an integer greater than 1, -xunroll=n causes the compiler to unroll loops n times. -xwe Converts all warnings to errors by returning non- zero exit status. -ztext Forces a fatal error if any relocations remain against non-writable, allocatable sections. This option is passed to the linker. NOTES The C++ compiler includes the static library, libC.a. How- ever, the corresponding bundled shared library, libC.so.5, is out of sync with the C++ 5.0 compiler on Solaris OS ver- sions 2.5.1, 2.6 and Solaris 7. For the compiler to work correctly with the shared library on Solaris versions 2.5.1, 2.6 or Solaris 7, you must install the appropriate OS patch; see the README. Type CC -readme for details. FILES file.a Static library file.C Input file file.cc Input file file.cpp Input file file.cxx Input file file.o Object file file.so Dynamic (shared) library a.out Linked output SEE ALSO analyzer(1), as(1), c++filt(1), cc(1), csh(1), dbx(1), debugger(1), gprof(1), ild(1), ld(1), more(1), nm(1), prof(1), tcov(1) C++ User's Guide, C++ Programming Guide, C++ Migration Guide, C++ Library Reference The C++ Programming Language, Third Edition, Bjarne Stroustrup, Addison-Wesley 1997 The C Programming Language, B. W. Kernighan and D. M. Ritchie, Prentice-Hall 1988 Solaris Linker and Libraries Guide International Standard (ISO/IEC FDIS 14882), Programming Languages - C++
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |