CC(1)
NAME
CC − C++ compilation system
SYNOPSIS
CC [ −386 ] [ −486 ] [ −a ] [ −Bbinding ]
[ −bsdmalloc ] [ −c ] [ −cg [89 92] ] [ +d ]
[ −Dname [=def ]] [ −dalign ] [ −dryrun ] [+ e 0|+ e 1]
[ −E ] [ −fast ] [ −flags ] [ −fnonstd ] [ −fsimple ]
[ −fstore ] [ −G ] [ −g ] [ −g0 ] [ −H ] [ −hname ]
[ −help ] [ −Ipathname ] [ −inline=rlst ] [ −keeptmp ]
[ −KPIC ] [ −Kpic ] [ −Ldir ] [ −llib ] [ −libmieee ]
[ −libmil ] [ −migration ] [ −misalign ] [ −mt ]
[ −native ] [ −nocx ] [ −noex ] [ −nofstore ]
[ −nolib ] [ −nolibmil ] [ −noqueue ] [ −norunpath ]
[ −Olevel ] [ −o outputfile ] [ +p ] [ −P ] [ −p ]
[ −pentium ] [ −pg ] [ −PIC ] [ −pic ] [ −pta ]
[ −ptipath ] [ −pto ] [ −ptr database-path ]
[ −ptv ] [ −Qdir | −qdir directory ]
[ −Qoption | −qoption prog opt ] [ −qp ]
[ −Qpath | −qpath pathname ]
[ −Qproduce | −qproduce sourcetype ] [ −R ] [ −R path ]
[ −readme ] [ −S ] [ −s ] [ −sb ] [ −sbfast ]
[ −temp=directory ] [ −time ] [ −Uname ] [ −u name ]
[ −unroll=n ] [ −V ] [ −v ] [ + w ] [ −w ]
[ −Xm ] [ −xa ] [ −xar ] [ −xcg [89 92] ] [ −xF ]
[ −xinline ] [ −xlibmiee ] [ −xlibmil ] [ −xlibmopt ]
[ −xlicinfo ] [ −xM ] [ −xM1 ] [ −xMerge ] [ −xnolib ]
[ −xnolibmopt ] [ −xOlevel ] [ −xpg ] [ −xs ] [ −xsb ]
[ −xsbfast ] [ −xtime ] [ −xunroll=n ] [ −Ztha ] sourcefile ...
DESCRIPTION
CC (capital CC ) uses the following components to compile C++ source code to object code.
ccfe Preprocessing and compilation.
cg (SPARC only) SPARC code generation.
cg386 (Intel only) Prepare intermediate code for code generation.
codegen (Intel only) Intel code optimizations and generation.
iropt (SPARC only) Optimizes for execution time. This step is optional. Optimization options invoke this step.
tdb_link Template instantiation, and invokes the linker.
ld Link editing.
cdlink (SPARC/Solaris 1.x only) Post-link operations to handle static constructors and destructors.
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. Both .s and .o files are also accepted by the CC command. The .s files are treated as assembly source files that may be assembled and link edited; .o files are treated as object files that may be link edited.
Files whose names do not end with the above suffix are treated as object programs or libraries and are handed over to the link editor. Unless -c, -S, -E, -P, or -Qproduce 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 (unless you specify -keeptmp).
Before you use the CC command, insert the name of the directory in which you have chosen to install the C++ compilation system at the beginning of your search path. This is usually done in the .cshrc file, in a line with set path = at the start; or in the .profile file, in a line with PATH= at the start.
Before you use the man command for CC man pages, insert the name of the directory in which you have chosen to install the C++ compiler at the beginning of your man path. This is usually done in the .cshrc file, in a line with setenv MANPATH at the start; or in the .profile file, in a line with export MANPATH= at the start.
OPTIONS
For a complete description of the C++ compiler options, including examples, see the C++ User’s Guide.
CC interprets the following options:
-386 (Intel only) Generate code for best performance on the Intel 80386 microprocessor.
-486 (Intel only) Generate code for best performance on the Intel 80486 microprocessor.
-a Prepare object code for coverage analysis using tcov(1).
-Bbinding Specifies library bindings. Specifies whether bindings for linking are dynamic (shared) or static (nonshared). Default is dynamic. Can be used as a toggle. -B and argument are passed to ld.
-Bdynamic—Causes link editor to first look for files named liblib.so and then, if not found, to look for files named liblib.a when given the −llib option. This is the default.
-Bstatic—Causes the link editor to look only for files named liblib.a.
-bsdmalloc (Solaris 1.x only) Faster malloc. Use the faster malloc from the library libbsdmalloc.a. This malloc is faster, but uses more memory.
-c Supress linking with ld(1) and produce a .o file for each source file. A single object file can be named explicitly using the -o option.
-cg[89 92] (SPARC only)
-cg89— Generate code to run on the SPARC architecture. This is the default -cg option. Uses a subset of the SPARC V8 instruction set. When optimizing, the instructions are scheduled to run well on a generic SPARC machine.
-cg92— Generate code to run on the SPARC V8 instruction set; in particular, the following instructions may be generated in-line: smul, smulcc, sdiv, sdivcc, umul, umulcc, udiv, udivcc, and fsmuld. When optimizing is turned on, the instructions are scheduled to run well on a SuperSPARC machine. Code compiled with -cg92 will run, but possibly more slowly, on pre-SPARC V8 machines; this practice is strongly discouraged.
+d Do not expand in-line functions. Used for debugging in-line functions. Is automatically selected when you specify the debugging (-g) option.
-Dname[=def]
Define a symbol name to the compiler equivalent to a #define directive in the source. If no def is given, name is defined as ‘1’. You can give multiple -D options on the command line. The following values are predefined: __BUILTIN_VA_ARG_INCR,
__i386 (Intel only),
__sparc (SPARC only),
__sun,
__SUNPRO_CC=0x401,
__SVR4 (Solaris 2.x only),
__unix,
sparc,
sun,
unix.
-dalign (SPARC only) Generate double load and store instructions whenever possible for improved performance. With -dalign, you may not get ANSI standard alignment. When you use this option, you trade portability for speed. If you compile one module with -dalign you must compile all modules with -dalign.
-dryrun Show, but do not execute, the commands constructed by the compilation driver.
+e[0|1] Controls when virtual tables are emitted for classes with virtual function. Only useful when attempting to control the placement of virtual tables in situations where objects with virtual functions are shared between processes. +e0 suppresses the generation of virtual tables, creating external references to those needed. +e1 forces the creation of virtual tables for all defined classes with virtual functions. Compilations using +e1 should usually also use -noex, or the compiler will generate virtual tables for internal types used in exception handling.
-E Run only the preprocessor on C++ source files and send output to stdout (standard output).
-fast Select optimum compilation options for speed. Should provide close to the maximum performance for most realistic applications. A convenience option; it chooses the fastest code generation option available on the compile-time hardware and: o The optimization level -02
o A set of inline expansion templates
o The -fnonstd floating-point option
o The −fsimple option
o The −dalign option (SPARC only)
o The −xlibmopt option (SPARC only). For x86 the −fast option turns off the −fstore option. If you combine -fast with other options, the last option applies. 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.
-flags Display all available flags.
-fnonstd Cause non-standard initialization of floating-point arithmetic hardware. By default, IEEE 754 floating-point arithmetic is nonstop and underflows are gradual. The -fnonstd option enables hardware traps to be enabled for floating-point overflow, division by zero, and invalid operation exceptions. These are converted into SIGFPE signals, and if the program has no SIGFPE handler, it will terminate with a memory dump. See ieee_handler(3m).
-fsimple Allow optimizer to use mathematically equivalent expressions.
-fstore (Intel only) Force the compiler to store floating-point values in memory, rather than leaving them in floating-point registers. This is the default option. See -nofstore.
-G Build a shared library. All object files specified in this command line should be compiled with -pic.
-g Produce additional symbol table information for dbx(1) and debugger(1). Implies +d (inline functions can also be debugged).
-g0 Same as -g , except this option does not imply +d (inline functions cannot be debugged). Increases compilation speed compared to the -g option, and may result in smaller object files.
-H Print to stderr (standard error) the path name of each file included during the current compilation.
-hname (Solaris 2.x only) Assign a name to a shared dynamic library. The name after -h should match the outputfile in the -o option. This option is passed to ld.
-help Display helpful information about CC.
-Ipathname Add pathname to the list of directories in which to search for #include files with relative filenames (not beginning with slash /).
-inline=rlst (SPARC only) Used by iropt for user-written routines. rlst is a comma-separated list of functions to be inlined. If compiling with -O3, -inline=rlst can increase optimization by inlining some routines. The -O3 option alone does not inline any routines. If compiling with -O4, -inline=rlst can decrease optimization by restricting inlining to only those routines in the list. With -O4, iropt normally tries to inline all user-written functions. A routine is not inlined if any of the following apply (no warning): - Optimization is less than -O3.
- The routine cannot be found.
- Inlining the routine does not look profitable or safe to iropt.
- The source for the routine is not in the file being compiled. If the function names specified in the list are not declared as extern “C” the list should contain mangled names. You may use nm(1) on the executable to find the mangled names. For functions declared as extern “C” , the names are not mangled by the compiler.
-keeptmp Keep all temporary files created during compilation.
-KPIC Same as -PIC.
-Kpic Same as -pic.
-Ldir Add dir to the search path for directories that contain object-library routines (for linking using ld(1) ).
-llib Link with object library liblib.a or liblib.so (for ld(1)). This option must follow the sourcefile.
-libmieee Cause libm to return values in the spirit of IEEE 754. The default behavior of libm is to be SVID-compliant on Solaris 2.x, and IEEE-compliant on Solaris 1.x.
-libmil Select the best inline templates for the floating-point option and operating system release available on this system.
-migration Display contents of the migration guide: Moving from C++ 3.0.1 to C++ 4.0.1. This option provides important information about incompatibilities between the cfront-based compiler (C++ 3.0.1) and the current compiler. The contents of the file are paged through the command specified by the environment variable PAGER. If this environment variable is not set, the default paging command is more(1).
-misalign (SPARC only) Generate code to allow loading and storage of misaligned data.
-mt (Solaris 2.x only) Compile and link for multithread coding. Pass -D_REENTRANT to the preprocessor and -lthread to ld. Passes -lsunmath_mt -lm -lC -lw -lthread -lc to ld instead of -lsunmath -lm -lC -lC_mtstubs -lw -lc.
-native Use appropriate code generator options for the compile-time hardware.
-nocx (Solaris 1.x only) Do not link with -lcx. Makes the output executable file smaller by not linking with -lcx. This may somewhat compromise the run-time performance and accuracy of binary-decimal base conversions. Also disables the recognition of the long long type during compilation, and passes -D_NO_LONGLONG to the preprocessor. If one or more object files are compiled without -nocx, and they contain the use of long long, then you may not pass -nocx to the compiler driver at link-time.
-noex Do not generate code supporting C++ exceptions.
-nofstore (Intel only) Do not force expressions to target precision on assignment.
-nolib Do not link any libraries by default, (no -l options are passed to ld); you must pass all -l options yourself. This option can be used to statically link some system libraries. The CC driver links in several libraries by default by passing the following -l options to ld: (Solaris 2.x) -lsunmath, -lm, -lC, -lC_mtstubs, -lw, and -lc. (Solaris 1.x) -lsunmath, -lm, -lC, -lansi, -lcx, and -lc. If you use -nolib, you will have to pass these options yourself.
-nolibmil Reset -fast so that it does not include inline templates. Use this after the -fast option: CC -fast -nolibmil ...
-noqueue If no license is available, the compiler returns without queueing your request and without doing your compile. A nonzero status is returned for testing make files.
-norunpath (Solaris 2.x only) No runpath in executable. If an executable file uses shared libraries, the compiler normally builds in a path that tells the runtime linker where to find those shared libraries. The compiler does this by setting the environment variable LD_RUN_PATH before invoking ld. The path depends on the directory where you installed the compiler. The -norunpath option prevents that path from being built into the executable. This option is helpful if you have installed the compiler in some nonstandard location, and you ship an executable file to your customers, but you do not want to make the customers deal with that nonstandard location.
-O[level] Optimize for execution time. -O with the level omitted is equivalent to O2. level can have a value in range 1-4.
For SPARC
O1— Do only the minimum amount of optimization (peephole). This is postpass assembly-level optimization. Do not use O1 unless O2 and O3 result in excessive compilation time, or result in running out of swap space.
O2— Do 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 O2 level does not optimize references or definitions for external or indirect variables. Do not use O2 unless O3 results in excessive compilation time, or running out of swap space. In general, the O2 level results in minimum code size.
O3— In addition to what -O2 does, this also optimizes references and definitions for external variables. The O3 level does not trace the effects of pointer assignments. Do not use O3 when compiling either device drivers, or programs that modify external variables from within signal handlers. In general, the O3 level results in increased code size.
O4— In addition to what O3 does, this also does automatic inlining of functions contained in the same file; this usually improves execution speed, but occasionally makes it worse. In general, the O4 level results in increased code size. For Intel
O1— Preload arguments from memory; cross jumping (tail merging), and the single pass of the default optimization.
O2— Schedule high- and low-level instructions, perform improved spill analysis, loop memory-reference elimination, register lifetime analysis, enhanced register allocation, global common subexpression elimination, and optimizations done by O1.
O3— Loop strength reduction, inlining, and optimizations done by O2.
O4— Architecture-specific optimizations and optimizations done by O3. For All Platforms
For most programs: O4 is faster than O3 is faster than O2 is faster than O1 . But in a few cases O2 might beat the others, and O3 might beat O4 . You can try compiling with each level to see if you have one of these rare cases.
If the optimizer runs out of memory, it tries to recover by retrying the current procedure at a lower level of optimization and resumes subsequent procedures at the original level specified in the command-line option.
If you optimize at O3 or O4 with very large procedures (thousands of lines of code in a single procedure), the optimizer may require an unreasonably large amount of memory. In such cases, performance of the machine may be degraded. You can prevent this in the C shell by limiting the amount of virtual memory available to a single process. To do this, use the limit command (see csh(1)).
-o outputfile Name the output file outputfile. The outputfile must have the appropriate suffix for the type of file to be produced by the compilation (see FILES). The outputfile cannot be the same as sourcefile (the compiler will not overwrite the source file).
+p Do not allow anachronistic constructs. Ordinarily, the translator warns about anachronistic constructs; under +p (for “pure”), the translator will not compile code containing anachronistic constructs.
-P Run source file through preprocessor only. Put output in a file with a .i suffix. Do not include line number information in output.
-p Prepare the object code to collect data for profiling with prof(1). Invoke a run-time recording mechanism that produces a mon.out file (at normal termination).
-pentium (Intel only) Generate code for best performance on the Intel Pentium microprocessor.
-pg Prepare the object code to collect data for profiling with gprof(1). Invokes a run-time recording mechanism that produces a gmon.out file (at normal termination).
-PIC Like -pic, but allows the global offset table to span the range of 32-bit addresses in those rare cases where there are too many global data objects for -pic.
-pic Produce position-independent code. Each reference to a global datum is generated as a dereference of a pointer in the global offset table. Each function call is generated in pc-relative addressing mode through a procedure linkage table. The size of the global offset table is limited to 8K on SPARC processors. For larger tables, see -PIC.
-pta Instantiate a whole template class rather than only those functions which are used. This creates a .o file for each member of a class. This option is provided for compatibility only.
-ptipath Add path to the template source path. The template source path specifies a list of directories to search for template source files. If you don’t specify -pti, the -I option path is used instead (for backward compatibility with cfront).
-pto One file mode. Causes generated templates to be instantiated in the compilation unit, rather than in the template database. This forces generated templates to be static. This option is provided for compatibility only.
-ptrdatabase-path
Specify location of the template database, Templates.DB. database-path is the path of the directory which holds Templates.DB. You can use -ptr more than once on the command line to handle multiple databases. The first -ptr entry specifies your working template database; this is the only writeable directory. If you omit -ptr, a database Templates.DB will be created in your current working directory.
-ptv Verbose output. Displays templates that are being instantiated.
-Qdir | -qdir directory
Look for compiler components in directory.
-Qoption | -qoption prog opt
Pass the option opt to the program prog. The option must be appropriate to that program and may begin with a minus sign. Multiple options can be supplied to prog can be supplied as a comma separated list.
-qp Prepare object code to collect data for profiling with prof(1). Invokes runtime recording mechanism that produces a mon.out file at normal termination. Same as the -p option.
-Qpath | -qpath pathname
Insert directory pathname into the compilation search path. pathname will be searched first for versions of the compilation programs, such as ld(1). This path will also be searched first for certain relocatable object files that are implicitly referenced by the compiler driver, for example ∗crt∗.o and bb_link.o.
-Qproduce | -qproduce sourcetype
Perform partial compilation and stops when a file of type sourcetype is generated. sourcetype is one of the following: .i, .o, or, .s.
-R (Solaris 1.x only) Merge the data segment with the text segment for the assembler.
-R path (Solaris 2.x only) A colon-separated list of directories used to specify library search directories to the run-time linker. Multiple instances of -R are concatenated, with each path separated by a colon. If both the environmental variable 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. A space is required between R and path.
-readme Display contents of the C++ README file. This file contains important information about the compiler. The contents of the file are paged through the command specified by the environment variable PAGER. If this environment variable is not set, the default paging command is more(1).
-S Do not assemble the program, but produce an assembly source file with a .s suffix.
-s Remove all symbol information from output executable files.
-sb Generate extra symbol table information for the SourceBrowser.
-sbfast Run only the ccfe phase to generate the Source Browser database.
-temp=directory
Specify the directory for temporary files.
-time Report execution times for the various compilation passes.
-Uname Remove any initial definition of the ccfe symbol name.
-u name Enter name as undefined symbol. This option is passed to ld.
-unroll=n Suggests to the compiler to unroll loops n times. n is a positive integer. If n is 1, the compiler does not unroll loops.
-V Print name and version ID of each pass of compiler.
-v Verbose. Print name of each pass of the compiler.
+w Generate additional warning messages. Warns about constructs that may be mistakes, nonportable, or inefficient. Without the +w option, the compiler issues warnings only about constructs that are almost certainly errors.
-w Do not print warnings.
-Xm Allow the character $ in identifier names (except as the first character).
-xa Same as -a.
-xar Used to create archive libraries. This option invokes the ar command. Ensures automatic instantiation of template instances used in the archive library. When this option is used, -o library-archive-name should be present in the command line.
-xcg[89 92] Same as -cg[89 92].
-xF (Solaris 2.x only) Enable performance analysis of the executable using the Analyzer and Debugger.
-xinline Same as -inline.
-xlibmiee Same as -libmiee.
-xlibmil Same as -libmil.
−xlibmopt (SPARC only) Use a library of selected math routines optimized for performance. This usually generates faster code. It may produce slightly different results; if so, they usually differ in the last bit.
-xlicinfo Get license server information.
-xM Generate makefile dependencies and send results to standard output (see make(1) for details about makefiles and dependencies).
-xM1 Same as -xM, except -xM1 does not report dependencies for /usr/include header files.
-xMerge Merge the data segment with the text segment. The data in the object file thus produced is read-only. The data is shared between processes, unless you link with ld -N.
-xnolib Same as -nolib.
−xnolibmopt
(SPARC only) Reset −fast so that it does not use the library of selected math routines optimized for performance. Use this after the −fast option. CC −fast −xnolibmopt ...
-xO Same as -O.
-xpg Same as -pg.
-xs (Solaris 2.x only) Place symbol table information in executable. Passes the -s option to the assembler. Use this only in cases where stabs must remain in the .stab section of the executable, and not in the default of .stab.excl. This older method of implementing symbol tables causes the loader to link more slowly and dbx (1) to initialize more slowly.
-xsb Same as -sb.
-xsbfast Same as -sbfast.
-xtime Same as -time.
-xunroll=n Same as -unroll.
-Ztha (Solaris 2.x/SPARC only) Prepare code for use with the Thread Analyzer, the performance analysis tool for multithreaded code.
NOTES
The C++ compiler includes a static version of the libC.a library. On SunOS 5.x, the corresponding shared library, libC.so.5 , is not bundled with either Solaris 2.2 or Solaris 2.3. Users of Solaris 2.2 or Solaris 2.3 need to apply OS Patch 101242 to install libC.so.5 on their system if they want to link libC dynamically. Type CC -readme for details. On SunOS 4.x, the shared library, libC.so.50, is included with the compiler.
FILES
file.[Cc] input file
file.cc input file
file.cxx input file
file.cpp input file
file.o object file
a.out linked output
<path>/bin/ccfe the C++ front end
/usr/lib/libc.a standard C library
<path>/lib/libC.a standard C++ library
<path>/lib/libtask.a C++ co-routine library
<path>/lib/libcomplex.a C++ complex library
<path>/include/CC standard directory for C++ #include files on Solaris 2.x
<path>/include/CC_411,CC_412,CC_413
standard directory for C++ #include files on Solaris 1.x
The <path> statement shown above must be replaced by the correct path at your installation site. If you are using Solaris 2.x, <path> is usually /opt/SUNWspro/SC3.0.1. If you are using Solaris 1.x, <path> is usually /usr/lang/SC3.0.1.
SEE ALSO
as(1), c++filt(1), cc(1), csh(1), dbx(1), debugger(1), eprof(1), gprof(1), ld(1), more(1), nm(1), prof(1), tcov(1).
Bjarne Stroustrup, The C++ Programming Language, Addison-Wesley 1991.
B. W. Kernighan and D. M. Ritchie, The C Programming Language, Prentice-Hall 1988.
C++ Language System Product Reference Manual , C++ User’s Guide.
SunOS 3.0.1 — Last change: 12 July 1994