Go to main content
Oracle® Developer Studio 12.6: C++ User's Guide

Exit Print View

Updated: July 2017
 
 

3.4 Options Summarized by Function

In this section, the compiler options are grouped by function to provide a quick reference. For a detailed description of each option, refer to C++ Compiler Options.

The options apply to all platforms except as noted; features that are unique to the Oracle Solaris OS on SPARC-based systems are identified as (SPARC), and the features that are unique to the Oracle Solaris OS on x86-based systems are identified as (x86).

3.4.1 Code Generation Options

Table 4  Code Generation Options
Option
Action
-compat
Sets the e compatibility mode of the compiler.
-g
Compiles for use with the debugger.
-KPIC
Produces position-independent code.
-Kpic
Produces position-independent code.
-mt
Compiles and links for multithreaded code.
-xaddr32
Restricts code to a 32–bit address space (x86/x64)
-xarch
Specifies the target architecture.
-xcode=a
(SPARC) Specifies the code address space.
-xlinker
Specify linker options.
-xMerge
(SPARC) Merges the data segment with the text segment.
-xtarget
Specifies the target system.
-xmodel
Modifies the form of 64-bit objects for the x86 platforms
+w
Identifies code that might have unintended consequences.
+w2
Emits all the warnings emitted by +w plus warnings about technical violations that are probably harmless but that might reduce the maximum portability of your program.
-xregs
The compiler can generate faster code if it has more registers available for temporary storage (scratch registers). This option makes available additional scratch registers that might not always be appropriate.
-xsegment_align
Cause the driver to include a special mapfile on the link line.
-z arg
Linker option.

3.4.2 Compile-Time Performance Options

Table 5  Compile-Time Performance Options
Option
Action
-fsemantic-interposition
-fno-semantic-interposition
Control optimizations that impact interposing on global library functions.
-instlib
Inhibits the generation of template instances that are already present in the designated library.
-m32|-m64
Specifies the data type model for the compiled binary object.
-xinstrument
Compiles and instruments your program for analysis by the Thread Analyzer.
-xjobs
Sets the number of processes the compiler can create to complete its work.
-xpch
Might reduce compile time for applications whose source files share a common set of include files.
-xpchstop
Specifies the last include file to be considered in creating a precompiled header file with -xpch.
-xprofile_ircache
(SPARC) Reuses compilation data saved during -xprofile=collect.
-xprofile_pathmap
(SPARC) Support for multiple programs or shared libraries in a single profile directory.

3.4.3 Compile-Time and Link-Time Options

The following table lists the options that must be specified both at link-time and at compile-time.

Table 6  Compile-Time and Link-Time Options
Option
Action
–fast
Selects the optimum combination of compilation options for speed of executable code.
-fopenmp
Equivalent to -xopenmp=parallel.
–m32|–m64
Specifies the data type model for the compiled binary object.
–mt
Macro option that expands to –D_REENTRANT –lthread.
-std
Specify C++ language version and compatibility mode.
–xarch
Specifies the instruction set architecture.
–xautopar
Turns on automatic parallelization for multiple processors.
–xhwcprof
Enables compiler support for hardware counter-based profiling.
–xipo
Performs whole-program optimizations by invoking an interprocedural analysis component.
-xipo_build
Reduce compile time by avoiding optimizations during the initial pass through the compiler, optimizing only at link time.
-xlinker
Specify linker options
–xlinkopt
Performs link-time optimizations on relocatable object files.
–xmemalign
(SPARC) Specifies the maximum assumed memory alignment and behavior of misaligned data accesses.
–xopenmp
Supports the OpenMP interface for explicit parallelization including a set of source code directives, runtime library routines, and environment variables
–xpagesize
Sets the preferred page size for the stack and the heap.
–xpagesize_heap
Sets the preferred page size for the heap.
–xpagesize_stack
Sets the preferred page size for the stack.
-xpatchpadding
Reserve an area of memory before the start of each function.
–xpg
Prepares the object code to collect data for profiling with gprof(1).
–xprofile
Collects data for a profile or uses a profile to optimize.
-xs
(Oracle Solaris) Link debug information from object files into executable.
–xvector=lib
Enables automatic generation of calls to the vector library functions.

3.4.4 Debugging Options

Table 7  Debugging Options
Option
Action
-###
Equivalent to -dryrun
+d
Does not expand C++ inline functions.
-dryrun
Shows shows all commands that the driver would issue to all components of the compilation.
-E
Runs only the preprocessor on the C++ source files and sends the result to stdout. Does not compile.
-g
Compiles for use with the debugger.
-g0
Compiles for debugging but does not disable inlining.
-H
Prints path names of included files.
-keeptmp
Retains temporary files created during compilation.
-P
Only preprocesses source; outputs to .i file.
-preserve_argvalues
(x86) Save copies of register-based function arguments in the stack.
-Qoption
Passes an option directly to a compilation phase.
-s
Strips the symbol table out of the executable file, thus preventing the ability to debug code.
-temp
Defines the directory for temporary files.
-verbose
Controls compiler verbosity.
-xanalyze
Produce a static analysis of the source code that can be viewed using the Code Analyzer.
-xcheck
Adds a runtime check for stack overflow.
-xcompress
Control compression of the debug section.
-xcompress_format
Specify format of compression of the debug section.
-xdebuginfo
Compiles for use with the debugger, specifying how much debug detail to emit.
-xdumpmacros
Prints information about macros such as definition, location defined and undefined, and locations used.
-xe
Only checks for syntax and semantic errors.
-xglobalize
Control globalization of file static variables but not functions.
-xhelp=flags
Displays a summary list of compiler options.
-xkeep_unref
Keep definitions of unreferenced functions and variables.
-xpatchpadding
Reserve an area of memory before the start of each function.
-xprevise
Produce a static analysis of the source code that can be viewed using the Code Analyzer.
-xport64
Warns against common problems during a port from a 32-bit architecture to a 64-bit architecture.
-xs
(Oracle Solaris) Link debug information from object files into executable.

3.4.5 Floating-Point Options

Table 8  Floating-Point Options
Option
Action
-fma
Enables automatic generation of floating-point fused multiply-add instructions.
-fns[={no|yes}]
(SPARC) Disables or enables the SPARC nonstandard floating-point mode.
-fprecision=p
x86: Sets floating-point precision mode.
-fround=r
Sets IEEE rounding mode in effect at startup.
-fsimple=n
Sets floating-point optimization preferences.
-fstore
x86: Forces precision of floating-point expressions.
-ftrap=tlst
Sets the IEEE trapping mode in effect at startup.
-nofstore
x86: Disables forced precision of expression.
-xlibmieee
Causes libm to return IEEE 754 values for math routines in exceptional cases.

3.4.6 Language Options

Table 9  Language Options
Option
Action
-compat
Sets the major release compatibility mode of the compiler.
-features=alst
Enables or disables various compilers or C++ language features.
-std
Specify C++ language version.
-xchar
Eases the migration of code from systems where the char type is defined as unsigned.
-xldscope
Controls the default linker scope of variable and function definitions to create faster and safer shared libraries.
-xthreadvar
(SPARC) Changes the default thread-local storage access mode.
-xtrigraphs
Enables recognition of trigraph sequences.
-xustr
Enables recognition of string literals composed of sixteen-bit characters.

3.4.7 Library Options

Table 10  Library Options
Option
Action
-Bbinding
Requests symbolic, dynamic, or static library linking.
-d{y|n}
Allows or disallows dynamic libraries for the entire executable.
-G
Builds a dynamic shared library instead of an executable file.
Does not link any libraries by default.
-hname
Assigns an internal name to the generated dynamic shared library.
-i
Tells ld(1) to ignore any LD_LIBRARY_PATH setting.
-Ldir
Adds dir to the list of directories to be searched for libraries.
-llib
Adds liblib.a or liblib.so to the linker’s library search list.
-library=llst
Forces inclusion of specific libraries and associated files into compilation and linking.
-mt
Compiles and links for multithreaded code.
-norunpath
Does not build the path for libraries into the executable file.
-Rplst
Builds dynamic library search paths into the executable file.
-shared
Passes the -G option to the link editor to produce a shared object rather than a dynamically linked executable. Links default system libraries.
-staticlib=llst
Indicates which C++ libraries are to be linked statically.
-xar
Creates archive libraries.
-xbuiltin[=opt]
Enables or disables better optimization of standard library calls
-xlang=l[,l]
Includes the appropriate runtime libraries and ensures the proper runtime environment for the specified language.
-xlibmieee
Causes libm to return IEEE 754 values for math routines in exceptional cases.
-xlibmil
Inlines selected libm library routines for optimization.
-xlibmopt
Selects library of optimized math routines .
-xnolibmil
Cancels– xlibmil on the command line.

3.4.8 Obsolete Options


Note -  The following options are either currently obsolete and so no longer accepted by the compiler, or are likely to be removed in a future release.
Table 11  Obsolete Options
Option
Action
-features=[%all|%none]
Obsolete sub-options %all and %none.
-library=%all
Obsolete sub-option that is likely to be removed in a future release.
-migration
This option is no longer recognized.
-xanalyze
Obsolete, use -previse instead.
-xarch=pentium_pro
Obsolete. Use -xarch=generic instead.
-xarch=sse
Obsolete. Use -xarch=generic instead.
-xarch=v7,v8,v8a
Obsolete.
-xchip=amdfam10
Obsolete.
-xchip=pentium
Obsolete. Use -xchip=generic instead.
-xchip=pentium_pro
Obsolete. Use -xchip=generic instead.
-xchip=pentium3
Obsolete. Use -xchip=generic instead.
-xchip=T3
Obsolete.
-xchip=ultraT1
Obsolete.
-xchip=ultraT2
Obsolete.
-xchip=ultraT2plus
Obsolete.
-xchip=sparc64vi
Obsolete.
-xchip=sparc64vii
Obsolete.
-xnolibmopt
Use -xlibmopt=%none instead.
-xnativeconnect
Obsolete, there is no alternative option.
-xpentium
Obsolete. Use -xchip=generic instead.
-xprefetch=yes
Use -xprefetch=auto,explicit instead.
-xprefetch=no
Use -xprefetch=no%auto,no%explicit instead.
-xtarget=T3
Obsolete.
-xtarget=pentium
Obsolete. Use -xtarget=generic instead.
-xtarget=pentium_pro
Obsolete. Use -xtarget=generic instead.
-xtarget=pentium3
Obsolete. Use -xtarget=generic instead.
-xtarget=ultraT1
Obsolete.
-xtarget=ultraT2
Obsolete.
-xtarget=ultraT2plus
Obsolete.
-xtarget=ultraT3
Obsolete.
-xtarget=sparc64vi
Obsolete.
-xtarget=sparc64vii
Obsolete.
–xvector=yes
Use –xvector=lib instead.
–xvector=no
Use –xvector=none instead.

3.4.9 Output Options

Table 12  Output Options
Option
Action
-c
Compiles only; produces object (.o) files, but suppresses linking.
-dryrun
Shows all the command lines that would be issued by the driver, but does not run any of them.
-E
Runs only the preprocessor on the C++ source files and sends the result to stdout. Does not compile.
-erroff
Suppresses compiler warning messages.
-errtags
Displays the message tag for each warning message.
-errwarn
If the indicated warning message is issued, compiler exits with a failure status.
-filt
Suppresses the filtering that the compiler applies to linker error messages.
–G
Builds a dynamic shared library instead of an executable file.
Does not link any libraries by default.
–H
Prints the path names of included files.
–o filename
Sets name of the output or executable file to filename.
–P
Only preprocesses source; outputs to .i file.
–Qproduce sourcetype
Causes the CC driver to produce output of the type sourcetype.
–s
Strips the symbol table out of the executable file.
-shared
Passes the -G option to the link editor to produce a shared object rather than a dynamically linked executable. Links default system libraries.
–verbose=vlst
Controls compiler verbosity.
+w
Prints extra warnings where necessary.
+w2
Prints still more warnings where appropriate.
–w
Suppresses warning messages.
-xdumpmacros
Prints information about macros such as definition, location defined and undefined, and locations used.
-xe
Performs only syntax and semantic checking on the source file but does not produce any object or executable code.
–xhelp=flags
Displays a summary list of compiler options
–xM
Outputs makefile dependency information.
–xM1
Generates dependency information, but excludes /usr/include
–xtime
Reports execution time for each compilation phase.
–xwe
Converts all warnings to errors.
-z arg
Linker option.

3.4.10 Run-Time Performance Options

Table 13  Run-Time Performance Options
Option
Action
–fast
Selects a combination of compilation options for optimum execution speed for some programs.
-fma
Enables automatic generation of floating-point fused multiply-add instructions.
-g
Instructs both the compiler and the linker to prepare the program for performance analysis (and for debugging).
-s
Strips the symbol table out of the executable.
-m32|-m64
Specifies the data type model for the compiled binary object.
-xalias_level
Enables the compiler to perform type-based alias analysis and optimizations.
-xarch=isa
Specifies target architecture instruction set.
-xbuiltin[=opt]
Enables or disables better optimization of standard library calls
-xcache=c
(SPARC) Defines target cache properties for the optimizer.
-xchip=c
Specifies target processor chip.
-xdebuginfo
Instructs both the compiler and the linker to prepare the program for performance analysis (and for debugging).
-xF
Enables linker reordering of functions and variables.
-xinline=flst
Specifies which user-written routines can be inlined by the optimizer
-xinline_param
Manually change the heuristics used by the compiler for deciding when to inline a function call.
-xinline_report
Generate a report written to standard output on the inlining of functions by the compiler.
-xipo
Performs interprocedural optimizations.
-xipo_build
Reduce compile time by avoiding optimizations during the initial pass through the compiler, optimizing only at link time.
-xlibmil
Inlines selected libm library routines for optimization.
-xlibmopt
Selects library of optimized math routines.
-xlinkopt
Performs link-time optimization on the resulting executable or dynamic library in addition to any optimizations in the object files.
-xmemalign=ab
(SPARC) Specifies maximum assumed memory alignment and behavior of misaligned data accesses.
-xnolibmil
Cancels –xlibmil on the command line.
-xOlevel
Specifies optimization level to level.
-xpagesize
Sets the preferred page size for the stack and the heap.
-xpagesize_heap
Sets the preferred page size for the heap.
-xpagesize_stack
Sets the preferred page size for the stack.
-xprefetch[=lst]
Enables prefetch instructions on architectures that support prefetch.
-xprefetch_level
Control the aggressiveness of automatic insertion of prefetch instructions as set by -xprefetch=auto
-xprofile
Collects or optimizes using runtime profiling data.
-xregs=rlst
Controls scratch register use.
-xsafe=mem
(SPARC) Allows no memory-based traps.
-xsegment_align
Cause the driver to include a special mapfile on the link line.
-xspace
(SPARC) Does not allow optimizations that increase code size.
-xtarget=t
Specifies a target instruction set and optimization system.
-xthreadvar
Changes the default thread-local storage access mode.
-xthroughput
Specify that the application will be run in situations where many processes are simultaneously running on the system.
-xunboundsym
Specify whether the program contains references to dynamically bound symbols.
-xunroll=n
Enables unrolling of loops where possible.
-xvis
(SPARC) Enables compiler recognition of the assembly-language templates defined in the VIS instruction set

3.4.11 Preprocessor Options

Table 14  Preprocessor Options
Option
Action
-Dname[=def]
Defines symbol name to the preprocessor.
-E
Runs only the preprocessor on the C++ source files and sends the result to stdout. Includes information about the source of the preprocessed lines. Does not compile.
-H
Prints the path names of included files.
-P
Only preprocesses source; outputs to .i file.
-Uname
Deletes initial definition of preprocessor symbol name.
-xM
Outputs makefile dependency information.
-xM1
Generates dependency information but excludes /usr/include.

3.4.12 Profiling Options

Table 15  Profiling Options
Option
Action
-p
Prepares the object code to collect data for profiling using prof.
-xpg
Compiles for profiling with the gprof profiler.
-xprofile
Collects or optimizes using runtime profiling data.

3.4.13 Reference Options

Table 16  Reference Options
Option
Action
-xhelp=flags
Displays a summary list of compiler options.

3.4.14 Source Options

Table 17  Source Options
Option
Action
-H
Prints the path names of included files.
-Ipathname
Adds pathname to the include file search path.
-I-
Changes the include-file search rules
-xM
Outputs makefile dependency information.
-xM1
Generates dependency information but excludes /usr/include.

3.4.15 Template Options

Table 18  Template Options
Option
Action
-instances=a
Controls the placement and linkage of template instances.
-template=wlst
Enables or disables various template options.

3.4.16 Thread Options

Table 19  Thread Options
Option
Action
-mt
Compiles and links for multithreaded code.
-xsafe=mem
(SPARC) Allows no memory-based traps.
-xthreadvar
(SPARC) Changes the default thread-local storage access mode.