|
You can specify command-line options to the aCC command. They allow you
to override the default actions of the compiler. Each option begins
with either a - or a + sign. Any number of options can be interspersed
anywhere in the aCC command and they are typically separated by blanks.
Unless exclusively specified, these options are supported by both, C and C++ compilers.
Default options can be set using option configuration files. Refer to
System Wide Configuration in the
Command Syntax and Environment Variables topic.
This section discusses the following topics:
|
| Command-Line Options Listed Alphabetically |
|
| Options to Control Code Generation |
The following options allow you to control what kind of code the compiler generates:
- -c - compiles one or more source
files without entering the linking phase.
- +DO[osname] - sets the
target operating system for the compiler; intended for enabling
optimizations that are not backward compatible.
- +DDdata_model - generates
object code for either the ILP32 or LP64 data model.
- +DSmodel - performs
instruction scheduling tuned for a particular architecture.
- -S - compiles to assembly
language without linking.
-c Command-Line Option
The -c option is used to compile one or more source files
without entering the linking phase.
When compiled, the compiler produces an object file
(a file ending with .o) for each
source file (a file ending with .c, .C, .s, or .i).
Note that you must eventually link object files before they can be executed.
Example:
aCC -c sub.C prog.C
In this example, the compiler compiles sub.C and prog.C and puts the
relocatable object code in the files sub.o and prog.o respectively.
+DOosname Command-Line Option
This option sets the target operating system for the compiler, and is
intended for enabling optimizations that are not backward compatible.
For instance, the 11.23 compiler introduces new optimized math library
functions that require library support not available in prior operating
systems. +DO option can be used at any level of optimization.
The default value
for osname is the operating system version on which the compiler is invoked.
The syntax for this option is +DOosname, where osname is one of :
Example:
The following example generates code for the HP-UX 11.22 (or later)
operating system. Binary incompatible features introduced in later
OS versions are inhibited.
aCC +DO11.22 +O3 app.C
+DDdata_model Command-Line Option
This option specifies the data model for the compiler.
data_model can be one of the following:
- 32 - This option generates ILP32 code and is the default.
- 64 - This option generates LP64 code.
| ILP32 Data Model |
LP64 Data Model |
- The size of an int, long, or pointer data type is 32 bits.
- The preprocessor predefined macro _ILP32 is defined.
|
- The size of an int data type is 32 bits. The size of a long or
pointer data type is 64 bits.
- The preprocessor predefined macro, __LP64__ is defined. Also __LP64.
|
Examples:
- The following example generates code for the 64-bit data model:
aCC +DD64 app.C
- The following example generates code for the 32-bit data model:
aCC app.C
+DSmodel Command-Line Option
This option performs instruction scheduling for a particular implementation of the Itanium®-based architecture.
model can be one of the following values:
- blended -
Tune to run reasonably well on multiple implementations.
As old implementation become less important and new implementations
are added, the behavior with this value will change accordingly.
- itanium -
Tune for the Itanium® processor.
- itanium2 -
Tune for the Itanium2® processor.
- mckinley - See itanium2.
- montecito - Tune for the Montecito processor.
- native -
Tune for the processor on which the compiler is running.
The default is blended.
Object code with scheduling tuned for a
particular model will execute on other HP-UX Integrity systems, although possibly
less efficiently.
Using +DS to Specify Instruction Scheduling
Instruction scheduling is different on different implementations of
Itanium®-based architectures. You can improve performance on a
particular model or processor of the HP-UX system by requesting that
the compiler use instruction scheduling tuned to that particular model
or processor. Using scheduling for one model or processor does not
prevent your program from executing on another model or processor.
-
If you plan to run your program on the same system where you are
compiling, make sure you have selected the correct model. By default, the
compiler will use the +DS blended option. The compiler
will not automatically generate code tuned for your system.
-
If you plan to run your program on one particular model of the
HP-UX system,
use +DSmodel with
the processor name of the target system.
Compiling in Networked Environments
When compiles are performed using diskless workstations or NFS-mounted
file systems, it is important to note that the default code generation
and scheduling are based on the local host processor. The system model
of the hosts where the source or object files reside do not
affect the default code generation and scheduling.
-S Command-Line Option
This option compiles a program and logs the assembly language output
in a corresponding file with a .s suffix. The -S
option is only for displaying the assembler code. The generated code
is not intended to be used as input to the assembler (as).
Example:
aCC -S prog.C
This command compiles prog.C to assembly code rather than
to object code, and puts the assembly code in the file prog.s.
The -S option creates an assembly file in addition to the object file.
|
|
Data Alignment and Storage |
Default Data Storage and Alignment
This section describes default data storage allocation and alignment for
HP compiler data types. Data storage refers to the size of data types,
such as bool, short, int, float,
and char*.
Data alignment refers to the way the HP compiler aligns data
structures in memory. Data type alignment and storage differences
can cause problems when moving data between systems that have
different alignment and storage schemes. These differences
become apparent when a structure is exchanged between systems
using files or inter-process communication. In addition, misaligned
data addresses can cause bus errors when an attempt is made to
dereference the address.
For additional information on unaligned data access refer
to Handling Unaligned Data
in the Pragmas topic.
The following table lists the sizes and alignments of the HP
compiler data types:
| Data Type |
Size (in bytes) |
Alignment |
| bool |
1 |
1-byte |
| char, unsigned char, signed char |
1 |
1 |
| wchar_t |
4 |
4 |
| short, unsigned short, signed short |
2 |
2 |
| int, unsigned int |
4 |
4 |
| long, unsigned long |
4* |
4* |
| float |
4 |
4 |
| __float80 |
16 |
16 |
| __float128 |
16 |
16 in +DD64. 8 otherwise. |
| double |
8 |
8 |
| long double |
16 |
8** |
| long long, unsigned long long |
8 |
8 |
| enum |
4 |
4 |
| arrays |
size of array element type |
alignment of array element type |
| struct |
*** |
1-, 2-, 4-, 8-, or 16-byte |
| union |
*** |
1-, 2-, 4-, 8-, or 16-byte |
| bit-fields |
size of declared type |
alignment of declared type |
| pointer |
4* |
4* |
| * |
In 64-bit mode, long, unsigned long, and pointer data
types are 8 bytes long and 8-byte aligned.
|
| ** |
In 64-bit mode, long double is 16-byte aligned.
|
| *** |
struct and union alignment is the same as the strictest alignment
of any member. Padding is done to a multiple of the alignment size.
|
|
|
-fshort-enums Command-Line Option
cc -Agcc -Wc, -fshort-enums foo.c
aCC -Ag++ -Wc, -fshort-enums foo.c
This option is used with the -Agcc or -Ag++ options to cause each enum type to be represented using the smallest integer type that is capable of representing all values of the enum type. Because it changes the representation of types, the code generated is NOT binary compatible with code compiled without the option. The primary use of this option is for compatibility with gcc, but it can provide performance improvement to applications that can accept the binary incompatibility.
|
+unum Command-Line Option
+unum
The +u option allows pointers to access non-natively aligned data.
This option alters the
way that the compiler accesses dereferenced data. Use of this option may
reduce the efficiency of generated code. num can be specified as:
1 - Assume single byte alignment. Dereferences are performed with a
series of single-byte loads and stores.
2 - Dereferences are performed with a series of two-byte loads and stores.
4 - Dereferences are performed with a series of four-byte loads and stores.
Example:
aCC +u1 app.C
|
|
|
| Debugging Options |
The following debugging options enable you to use the HP WDB Debugger:
- +d - Disables all inlining of functions
- +expand_types_in_diag - Expands typedefs in diagnostics.
- -g - Generates minimal information for debugging
- -g0 - Generates full information for debugging
- -g1 - Generates minimal information for debugging
- +macro_debug - Controls the emission of macro debug information into the object file.
- +[no]objdebug -
Generates debug information in object files and not in the executable
- +keep - Keeps temporary files and saves
diagnostic information for compiler debugging.
- +pathtrace - Provides a mechanism to record program execution control flow into global and/or local path tables.
- +[no]srcpos -
Controls the generation of source position information.
+d Command-Line Option
This option prevents the expansion of inline functions.
It is useful when you are
debugging your code because you cannot set breakpoints at inline functions.
This option disables inlining thereby allowing you to set breakpoints at
functions specified as inline.
<\p>
Also see:
+O[no]inline Command-line option
+expand_types_in_diag Command-Line Option
The +expand_types_in_diag option expands typedefs
in diagnostics so that both the original and final types are present.
-g Command-Line Option
The -g option causes the compiler to generate minimal
information for the debugger. It uses an algorithm that attempts to
reduce duplication of debug information.
To suppress expansion of inline functions, use the +d option.
Also see:
Difference between -g, -g0 and -g1
When to Use -g, -g0, or -g1
-g, -g1 Algorithm
HP WDB Debugger Documentation
-g0 Command-Line Option
The -g0 option causes the compiler to generate complete
debug information for the debugger.
To suppress expansion of inline functions use the +d option.
-g1 Command-Line Option
Like the -g option, -g1 causes the compiler to
generate minimal information for the debugger. It uses an
algorithm that attempts to reduce duplication of debug information.
To suppress expansion of inline functions use the +d option.
Difference between -g, -g0 and -g1
The -g, -g0, and -g1 options all generate
debug information. The difference is that the -g0 option
emits full debug information about every class referenced in a file,
which can result in some redundant information.
The -g and -g1 options emit a subset of this
debug information, thereby decreasing the size of your object file.
If you compile your entire application with -g or -g1 no
debugger functionality is lost.
Note: If you compile part of an application with -g
or -g1 and part with debug off, (that is, without
-g, -g0, and -g1 options) the resulting executable may
not contain complete debug information. You will still be able to
run the executable, but in the debugger, some classes may
appear to have no members.
When to Use -g, -g0, or -g1
Use -g or -g1 when you are compiling your entire application
with debug on and your application is large, for example,
greater than 1 megabyte.
Use -g0 when either of the following is true:
-
You are compiling only a portion of your application with
debug on, for example, a subset of the files in your application.
-
You are compiling your entire application with debug on
and your application is not very large, for example, less
than 1 megabyte.
-g, -g1 Algorithm
In general, the compiler looks for the first non-inline,
non-pure (non-zero) virtual function in order to emit debug
information for a class. If there are no virtual member functions,
the compiler looks for the first non-inline member function.
If there are no non-inline member functions, debug information
is always generated.
+macro_debug= Command-Line Option
+macro_debug={ref|all|none}
This option controls the emission of macro debug information into the object file.
Set +macro_debug to one of the following required values:
| ref |
Emits debug information only for referenced macros. This is the default for -g, -g1, or -g0. |
| all |
Emits debug information for all macros.
This option can cause a significant increase in object file size. |
| none |
Does not emit any macro debug information. |
One of the -g options (-g, -g0, or -g1) must be used to enable the +macro_debug option.
+[no]objdebug Command-Line Option
This option generates [does not generate] debug information in object files and not in the
executable. The HP WDB debugger then reads the object files to construct debugging
information.
Note: With +objdebug, the object files or archive
libraries must not be removed.
+objdebug is default at link time and at compile time.
If +noobjdebug is used at link time, all debug information
goes into the executable, even if some objects were compiled with
+objdebug.
If +objdebug is used at compile time, extra debug
information is placed into each object file to help the debugger
locate the object file and to quickly find global types and constants.
Usage:
Use +objdebug option to enable faster links
and smaller executable file sizes for large applications, rather
than +noobjdebug where debug information is written
to the executable.
Use +noobjdebug with the -g, -g0, or -g1
option when using +ild.
+keep Command-Line Option
+keep
This option instructs the compiler to keep all temporary files and
generate other information useful in diagnosing compiler failures.
The option will save IELF files, generate a post processed source file
and save state information in an .env file. The state information
contains such things as version strings of various compiler components,
the command line options used, and machine configuration.
+pathtrace Command-Line Option
+pathtrace[=kind]
This option provides a mechanism to record program
execution control flow into global and/or local path tables. The
saved information can be used by the HP WDB debugger to assist with crash path
recovery from the core file, or to assist when debugging the
program by showing the executed branches.
Currently only if, else, switch-case-default, and try-catch
execution paths are recorded in the path table. If there is no
condition statement inside a for, while, or do-while loop, then no
execution path is recorded.
The defined values for kind are:
| local |
Generates a local path table and records basic block-execution information in it at runtime. |
| global |
Generates a global path table and records basic block-execution information in it at runtime.
|
| global_fixed_size |
Generates a fixed-size (65536
items) global path table and records basic block-execution information in it at runtime.
This form differs from +pathtrace=global because the
size of the table cannot be configured at runtime, and
the contents cannot be dumped to a file. The fixed-size
global path table has better runtime performance than
the configurable global path table. The performance
difference varies depending on the optimization level
and how the program is written.
|
| none |
Disables generation of both the global and local path tables.
|
The values can be combined by joining them with a colon. For example:
+pathtrace=global:local
The global_fixed_size and global values are mutually exclusive. If more than one of them are specified on the command line, the last
one takes precedence. The same is true for the none value.
+pathtrace with no values is equivalent to +pathtrace=global_fixed_size:local
The use of this option and the -mt option must be consistent for
all compilation and link steps. That means if -mt is used with
+pathtrace at compile time, it should also be used at link
time; if -mt is not used with +pathtrace at compile time, it should not used at link time. Otherwise, a link-time error can occur.
|
| Warnings and Error Handling |
Use the following options to control how potential errors in your code are detected and handled:
- +p - Disallows all anachronistic constructs
- -w - Suppresses all compiler warning messages, except those explicitly enabled with +Wwargs or a subsequent +w-prefix option.
- +w - Warns about all questionable constructs
- +w64bit -
Enables warnings that help detection of potential problems in
converting 32-bit applications to 64-bit
- +Wargs - Selectively suppresses compiler warnings
- +Wcontext_limit - Limits the number of instantiation contexts output by the compiler for diagnostics involving template instantiations.
- +We - Interprets all warning and future error messages as errors
- +Weargs - Selectively interprets warnings or future errors as errors
- +wlint - Enables several warnings in the compiler that provide lint like functionality
- +Wmacro - Disables specified warning diagnostics in the expansion of a specified macro.
- +wn - Specifies the level of the warnings messages
- +wperfadvice - Enables performance advisory messages.
- +wsecurity - Enables compile-time diagnostics for potential security violations
- +Wv - Displays the description for diagnostic messages
- +Wwargs - Selectively treats compiler remarks or discretionary errors as warnings
You can use the cadvise report feature of the HP Code Advisor tool to help analyze compiler errors and warnings.
+p Command-Line Option
This option disallows all anachronistic constructs.
Ordinarily, the compiler gives warnings about anachronistic constructs.
Using the +p option, the compiler gives errors for
anachronistic constructs.
Example:
aCC +p file.C
This command compiles file.C and gives errors for all
anachronistic constructs rather than just giving warnings.
-w Command-Line Option
This option disables all warnings except those that are explicitly enabled with +Wwargs or a subsequent +w-prefix option. By default, the compiler reports all errors and warnings.
HP recommends against using the -w option. In addition to disabling messages currently output by the compiler, it will also disable any new messages added to the compiler in the future that could identify problem areas in user code. HP recommends using the +Wargs option to disable a message. Although it can often take a long list of +Warg options to disable all desired warnings, this list can be included in an options file and referenced using the +opts option to avoid listing them all directly on the command line.
Example:
aCC -w file.C
This command compiles file.C and reports errors but does
not report any warnings.
+w Command-Line Option
This option warns about all questionable constructs and gives pedantic warnings. +w enables all checks except
for the +wsecurity and +wendian warnings. Those need to be enabled
explicitly if needed.
The default is
to warn only about constructs that are almost certainly problems.
For example, this option warns you when calls to inline functions
cannot be expanded inline.
aCC +w file.C
This command compiles file.C and warns about both
questionable constructs and constructs almost certainly problematic.
Note: This option is equivalent to the +w1 option of legacy HP C.
+w64bit Command-Line Option
Enable warnings that help detection of potential problems in converting 32-bit applications to 64-bit. The +w64bit option applies only to a 64-bit compile (using +DD64). The option is equivalent to the +M2 option.
+Wargs Command-Line Option
+Warg1[,arg2,..argn]
This option selectively suppresses any specified warning messages.
arg1 through argn are valid compiler warning
message numbers.
Example:
aCC +W600 app.C
+Wcontext_limit= Command-Line Option
+Wcontext_limit=num
This option limits the number of instantiation contexts output by the
compiler for diagnostics involving template instantiations. At most num outermost contexts
and num innermost contexts are shown. If there are more than 2 * num relevant contexts, the additional contexts are omitted.
Omitted contexts are replaced by a single line separating the outermost num contexts from the
innermost num contexts, and indicating the number of contexts omitted. The default value for
num is 5. A value of 0 removes the limit.
+We Command-Line Option
This option interprets all warning and future error messages as errors.
See Weargs.
+Weargs Command-Line Option
+Wearg1[,arg2,..,argn]
This option selectively interprets any specified warning or future
error messages as errors. arg1 through argn must
be valid compiler warning message numbers.
Example:
aCC +We600,829 app.C
+wlint Command-Line Option
This option enables several warnings in the compiler that provide lint like functionality.
Checks are made for memory leaks, out-of-scope memory
access, null pointer dereference, and out-of-bounds access. These compile time diagnostics can be very useful in detecting potential problems in the source code. To disable a specific warning introduced by +wlint, a +Wargs option can be used after the +wlint option.
NOTE: The +wlint option is only supported on
Integrity systems.
+Wmacro Command-Line Option
+Wmacro:MACRONAME:d1,d2,...,dn
This option disables warning diagnostics d1,d2,...,dn in the expansion of
macro MACRONAME. If -1 is given as the warning number, then all warnings are suppressed. This option is not applicable to warning numbers greater than 20000. +Wmacro gets higher priority than the other diagnostic-control command-line options that are applicable to the whole source. Diagnostic control pragmas take priority based on where they are placed.
+wn Command-Line Option
This option specifies the level of the warnings messages.
+wn
The value of n can be one of the following:
| 1 |
All warnings are issued. This includes low level warnings
that may not indicate anything wrong with the program. |
| 2 |
Only warnings indicating that code generation might
be affected are issued. This is equivalent to the compiler
default without the -w option. |
| 3 |
No warnings are issued. This is equivalent to
the -w option. This option is the same as -W c and -wn. |
+wperfadvice Command-Line Option
This option enables performance advisory messages.
+wperfadvice[={1|2|3|4}]
The level 1, 2, 3, or 4 controls how verbosely the performance advisory messages are emitted. The higher the level, the more messages generated. Level 1 emits only the most important messages, while level 4 emits all the messages. If the optional level is not specified, it defaults to 2.
+wsecurity Command-Line Option
This option enables compile-time diagnostics for potential security violations.
+wsecurity[={1|2|3|4}] The value 1, 2, 3, or 4 controls how verbosely the security check warnings are emitted. The higher the check level, the more warnings can be generated. Note that this may also generate more false positives. The default level is 2.
This option enables compile time diagnostics for potential security violations.
Warnings are emitted for cases where untrusted (tainted) data may reach
a critical reference point in the program. This is based on cross-module
analysis performed by the compiler. Hence, the +wsecurity option implicitly
enables a limited form of cross module analysis, even if -ipo or +O4 options
are not specified. This may lead to a significant increase in the compile
time compared to a build without the +wsecurity option. Using this option may
result in the compiler invoking optimizations other than those which are part
of the user specified optimization level. If +wsecurity is used in addition
to -ipo or +O4, the generated code is not affected and the compile time
does not increase much.
NOTE: The +wsecurity option is only supported on Integrity systems.
+Wv Command-Line Option
+Wv[d1,d2,...,dn]
This option displays the description for diagnostic message numbers d1 through dn.
Specifying this option causes the compiler to emit the descriptive text
for the specified diagnostics to stderr. This option must not be used
with any other compiler options.
If the description for a diagnostic is not available, the compiler emits
only the diagnostic with a note that the description is not available.
+Wwargs Command-Line Option
+Wwarg1[,arg2,..,argn]
This option selectively treats compiler remarks or discretionary errors as warnings.
arg1 through argn are valid compiler message numbers.
Conflicts between +W, +Ww and +We are resolved
based on their severity. +We is the highest and +W is the lowest.
|
| Exception Handling |
By default, exception handling is in effect. To turn
off exception handling, you must use the following option.
+noeh Command-Line Option
+noeh
This option disables exception handling. By default, exception handling is on.
To turn off exception handling, you must use this option. With exception handling
disabled, the keywords throw and try generate an error. Mixing code compiled with
and without +noeh can have undesired results.
Example:
aCC +noeh progex.C
This command compiles and links progex.C, which does
not use exception handling.
|
| Extensions to the Language |
The following options support extensions to the C++ language:
- -ext - Enables HP value added features.
- +e - Enables HP value added features.
-ext Command-Line Option
-ext
When you specify -ext, you enable the following HP aC++
extensions to the C++ standard:
- Enable 64-bit integer data type support for:
- long long (signed 64-bit integer)
- unsigned long long (unsigned 64-bit integer)
Use this option to declare 64-bit integer literals and for
input and output of 64-bit integers.
-
Enable #assert, #unassert preprocessor directives allowing
you to set a predicate name or predicate name and token to
be tested with a #if directive.
When this option is used with -AC89 or -AC99, it defines
the following macros:
- -D__STDC_EXT__
- -D_HPUX_SOURCE (unless -Aa is used)
Note: When using -ext, specify it at both compile time and link time.
Example:
aCC -ext foo.C
This command compiles foo.C, which contains a long long declaration.
#include <iostream.h>
void main(){
long long ll = 1;
cout << ll << endl;
}
+e Command-Line Option
+e
This option is a synonym of the -ext option.
|
| Floating-Point
Processing Options |
The following command line options are used for floating-point processing:
- +O[no]cxlimitedrange -
Enables[disables] the use of the usual formulas for complex arithmetic.
- +O[no]fenvaccess -
Accesses[does not access] the floating-point environment.
- +FPmode - Specifies runtime environment.
- -fpeval -
Specifies minimum precision for expression evaluation.
- -[no]fpwidetypes -
Enables extended and quad data types.
- +O[no]fltacc - Disables [enables] all
optimizations that cause imprecise floating-point results
- +O[no]libmerrno -
Enables[disables] support for errno in libm functions.
- +Oprefetch_latency -
Applies to loops for which the compiler generates data prefetch instructions.
- +O[no]sumreduction -
Enables sum reduction optimization
+O[no]cxlimitedrange
Command-Line Option
+O[no]cxlimitedrange
The usual mathematical formulas for complex multiply,
divide, and absolute value are problematic because of their
treatment of infinities and because of undue overflow and
underflow.
The +O[no]cxlimitedrange command-line option enables[disables] the
use of the usual formulas for complex arithmetic.
The default is +Onocxlimitedrange.
The CX_LIMITED_RANGE pragma can be used to
inform the implementation that (where the state is on)
the usual mathematical formulas are acceptable.
This option is equivalent to adding the following pragma at the beginning of the source file:
# pragma STDC CX_LIMITED_RANGE
See STDC CX_LIMITED_RANGE Pragma
for more information.
+O[no]fenvaccess Command-Line Option
+O[no]fenvaccess
This option provides a means to inform the compiler when a program
might access the floating-point environment to test flags or run
under non-default modes.
Use of the option +Onofenvaccess allows certain optimizations
that could subvert flag tests and mode changes such as global
common subexpression elimination, code motion, and constant folding.
The default is +Onofenvaccess.
This option is equivalent to adding the following pragma at the
beginning of each source file submitted for compilation:
#pragma STDC FENV_ACCESS ON
See STDC FENV_ACCESS Pragma
for more information.
+FPmode Command-Line Option
+FPmode
This option specifies how the run-time environment for floating-point
operations should be initialized at program startup.
By default, modes are as specified by the IEEE
floating-point standard: all traps disabled, gradual
underflow, and rounding to nearest. See ld(1) for
specific values of mode. To dynamically change these
settings at run time, refer to fenv(5), fesettrapenable(3M),
fesetflushtozero(3M), and fesetround(3M).
The following table has a partial list of some of the mode values. Upper case enables the flag; lower case disables the flag:
| V (v) |
Trap on invalid floating-point operations |
| Z (z) |
Trap on divide by zero |
| O (o) |
Trap on floating-point overflow |
| U (u) |
Trap on floating-point underflow |
| I (i) |
Trap on floating-point operations that produce inexact results. |
| D (d) |
Enable sudden underflow (flush to zero) of denormalized values. |
-fpeval Command-Line Option
-fpeval=precision
This option specifies the minimum precision to use for floating-point
expression evaluation. This option does not effect the
precision of parameters, return types, or assignments.
The defined values for precision are:
| float |
Evaluates floating-point expressions and
constants in their semantic type. |
| double |
Evaluates float operations and constants
using the range and precision of double,
and evaluates all other floating-point
expressions and constants in their
semantic type.
|
| extended |
Utilizes hardware support of these floating-point
registers for optium speed in
floating-point computations. Evaluates
float and double constants and expressions
using the range and precision of the extended
type, and evaluates all other floating-point
expressions in their semantic type. This option
while providing greater precision than double,
does not provide greater speed than double
or float.
|
The default is -fpeval=float.
-[no]fpwidetypes Command-Line Option
-[no]fpwidetypes
This option enables [disables] extended and quad floating-point data
types. Quad is equivalent to long double. This option also
enables __float80 prototypes.
The compiler defines
_FPWIDETYPES when -fpwidetypes is in effect.
The default is -nofpwidetypes.
+O[no]libmerrno Command-Line Option
+O[no]libmerrno
This option enables [disables] support for errno in libm functions.
The default is +Onolibmerrno.
In C-mode, the default is +Olibmerrno with -Aa option.
+Oprefetch_latency Command-Line Option
+Oprefetch_latency=cycles
+Oprefetch_latency applies to loops for which the compiler generates data prefetch
instructions. cycles represents the number of cycles for a data cache miss. For a given loop,
the compiler divides cycles by the estimated loop length to arrive at the number of loop
iterations for which to generate advance prefetches.
cycles must be in the range of 0 to 10000. A value of 0 instructs the compiler to use the
default value, which is 480 cycles for loops containing floating-point accesses and 150 cycles
for loops that do not contain any floating-point accesses.
For tuning purposes, it is recommended that users measure their application’s performance
using a few different prefetch latency settings to determine the optimal value. Some
floating-point codes may benefit by increasing the distance to 960. Parallel applications
frequently benefit from a shorter prefetch distance of 150.
+O[no]sumreduction Command-Line Option
+O[no]sumreduction
This option enables[disables] sum reduction optimization. It allows[does not allow] the compiler
to compute partial sums to allow faster computations.
It is not technically legal to do this in C or C++ because of float
accuracy issues. This option is useful if an application cannot use
+Onofltacc but wants sum reduction to be performed.
When sum reduction optimization is enabled, the compiler may evaluate
intermediate partial sums of float or double precision terms using
(wider) extended precision, which reduces variation in the result
caused by different optimization strategies and generally produces a more
accurate result.
|
| Header
File Options |
The following is a list of header file options:
- -H - Dumps the include file
hierarchy to stderr.
- +hdr_create - Creates a precompiled header file.
- +hdr_use - Inserts the referenced precompiled header file.
- -Idirectory - Adds directory
to the directories to be searched for #include files
- -I- - Overrides the default
-Idirectory search-path.
-H Command-Line Option
cc -H file
The -H option enables HP aC++/HP C to print the order and
hierarchy of included files. The -H option dumps the include
file hierarchy to stderr so that the preprocessed
compiler output indicates the include file nesting.
+hdr_create Command-Line
Option
aCC progname -c +hdr_create headername
This option extracts the header from a program file and saves it as a
precompiled header file.
Example:
aCC ApplicTemplate.C -c +hdr_create ApplicHeader
+hdr_use Command-Line Option
aCC progname +hdr_use headerfile -c
This option adds a precompiled header file to a program when the program is compiled.
Example:
aCC Applic.C +hdr_use AddedHeader
-Idirectory Command-Line
Option
-Idirectory
directory is the HP-UX directory where the compiler
looks for header files.
During the compile phase, this option adds directory to the
directories to be searched for #include files during
preprocessing.
During the link phase, this option adds directory to the
directories to be searched for #include files by the
link-time template processor.
For #include files that are enclosed in double quotes
(" ") within a source file and do not begin with a /, the
preprocessor searches in the following order:
- The directory of the source file containing the #include.
- The directory named in the -I option.
- The standard include directories /opt/aCC/include and
/usr/include.
-I- Command-Line Option
[-Idirs] -I- [-Idirs]
[-Idirs] indicates an optional list of
-Idirectory specifications in
which a directory name cannot begin with a hyphen (-) character.
This option allows you to override the default -Idirectory search path.
This feature is called view-pathing. Specifying -I- serves two purposes:
-
It changes the compiler’s search-path for quote enclosed (" ")
file names in a #include directive to the following order:
- The directory named in the -I option.
- The standard include directories /opt/aCC/include*
and /usr/include.
The preprocessor does not search the directory of the including file.
-
It separates the search-path list for quoted and angle-bracketed include files.
Angle-bracket enclosed file names in a #include
directive are searched for only
in the -I directories specified after -I- on the command-line.
Quoted includes are searched for in the directories that both precede
and follow the -I- option.
The standard aCC include directories
(/usr/include and /opt/aCC/include*)
are always searched last for both types of include files.
Usage:
View-pathing can be particularly valuable for medium to
large sized projects. For example,
imagine that a project comprises two sets of directories.
One set contains development
versions of some of the headers that the programmer currently
modifies. A mirror set contains
the official sources.
Without view-pathing, there is no way to completely replace
the default -Idirectory
search-path with one customized specifically for project development.
With view-pathing, you can designate and separate official directories from development
directories and enforce an unconventional search-path order. For quote enclosed headers, the
preprocessor can include any header files located in development directories and, in the
absence of these, include headers located in the official directories.
If -I- is not specified view-pathing is turned off. This is the default.
Examples:
With view-pathing off, the following example obtains all quoted include
files from dir1 only if
they are not found in the directory of a.C and from dir2
only if they are not found in dir1.
Finally, if necessary, the standard include directories are searched. Angle-bracketed includes
are searched for in dir1, then dir2, followed by the standard include directories.
aCC -Idir1 -Idir2 -c a.C
With view-pathing on, the following example searches for quoted include files in dir1 first
and dir2 next, followed by the standard include directories,
ignoring the directory of a.C.
Angle-bracketed includes are searched for in dir2 first, followed by the standard include
directories.
aCC -Idir1 -I- -Idir2 -c a.C
Note:
Some of the compiler’s header files are included using double quotes. Since the
-I- option redefines the search order of such includes, if any standard headers
are used, it is your responsibility to supply the standard include directories
(/opt/aCC/include* and /usr/include) in the correct order in your -Icommand
line.
For example, when using -I- on the aCC command line, any specified -I
directory containing a quoted include file having the same name as an HP-UX
system header file, may cause the following possible conflict.
In general, if your application includes no header having the same name as an
HP-UX system header, there is no chance of a conflict.
Suppose you are compiling program, a.C, with view-pathing on. a.C includes the
file a.out.h which is a system header in /usr/include:
aCC -IDevelopmentDir -I- -IOfficialDir a.C
If a.C contains:
// This is the file a.C
#include <a.out.h>
// ...
When a.out.h is preprocessed from the /usr/include directory,
it includes other files that are quote included
(like #include "filehdr.h").
Since with view-pathing, quote enclosed headers are not searched for in the
including file’s directory, filehdr.h which is included bya.out.h will not be
searched for in a.out.h’s directory (/usr/include.
Instead, for the above command line, it is first searched for in
DevelopmentDir, then in OfficialDir and if
it is found in neither, it is finally searched
for in the standard include directories
(/opt/aCC/include* and /usr/include) in the
latter of which it will be found.
However, if you have a file named filehdr.h in DevelopmentDir
or OfficialDir, that file (the wrong file) will be found.
|
| Online Help Option |
Use the online help option to view the online helper’s Guide.
+help Command-Line Option
+help
This option invokes the main page (index.htm) of the online help.
If +help is used on any command line, the compiler
displays the online help with the default
web browser and then processes any other arguments.
If $DISPLAY is set, the default web browser is used.
If the display variable is not set, set your $DISPLAY variable
as follows:
export DISPLAY=YourDisplayAddress (ksh/sh shell notation)
setenv DISPLAY YourDisplayAddress (csh shell notation)
Example:
To use a browser other than the default, first set the BROWSER
environment variable to the alternate browser’s location:
export BROWSER=AlternateBrowserLocation
To invoke the online help, use the command:
aCC +help
|
| Inlining Options |
The following options allow you to specify the amount of source code inlining done
by the HP aC++ compiler:
- +d - Disables all inlining of functions
- +inline_level - Allows you to specify
the amount of source code inlining done by the HP aC++ compiler.
- +O[no]inline - Inlines [does not inline] procedure calls
- +Oinlinebudget - Controls the compile time
budget for the inliner
+inline_level num Command-Line Option
+inline_level num
This option controls how C++ inlining hints influence HP aC++.
Such inlining happens in addition to functions explicitly tagged
with the inline keyword. (For C89, use the __inline keyword).
This option controls functions declared with the inline
keyword or within the class declaration and is effective at
all optimization levels.
Specify num as an integral value between 0 and 9. Refer to the tables below.
| num |
Description |
| 0 |
No inlining is done (same effect as the +d option). |
| 1 |
Only functions marked with inline or implied by the language to be
inline are considered for inlining. (This is the default for C++ at +O1). |
| 2 |
More inlining than level 1. This is the default level at optimization levels +O2, +O3, and +O4. |
| 3-8 |
Increasing levels of inliner aggressiveness. |
| 9 |
Attempt to inline all functions other than recursive functions or those with a variable number of arguments. |
The default level depends on +Olevel as shown in the following table:
| level |
num |
| 0 |
1 |
| 1 |
1 |
| 2 |
2 |
| 3 |
2 |
| 4 |
2 |
Note: The options +d and +inline_level 0 turn off all inlining, including implicit inlining.
The options +Oinline and +Oinlinebudget also influence inlining aggressiveness.
Example:
aCC +inline_level 3 app.C
|
| Library Options |
The following library options allow you to create, use, and manipulate libraries:
- +A - Causes the linker to link with archive libraries.
- -b - Creates a shared library.
- -dynamic - Specifies dynamically bound executables.
- -exec - Creates an executable file from an object file.
- -lname - Specifies a library for the linker to search.
- -Ldirectory - Specifies a directory for the linker to search for libraries.
- -minshared - Indicates an executable makes minimal use of shared libraries.
- +nostl - Suppresses searching of default -I and -L directory paths and some -l libraries.
- +Onolibcalls= - Allows you to turn off optimization for listed functions.
+A Command-Line Option
+A
This option causes the linker to link with archive libraries
rather than shared libraries and creates a completely archived
executable.
Example:
aCC +A file.o -lm
This command links file.o and links in
the archived version of the math library, /lib/libm.a, rather
than the shared version, /lib/libm.so. It does not link in
/usr/lib/hpux32/libdld.so.
Note: This option is not available on Integrity systems. See
-minshared for more information.
-b Command-Line Option
-b
This option creates a shared library rather than an executable file.
Example:
aCC -b utils.o -o utils.so
This command links utils.o and creates the
shared library utils.so.
For more information on shared libraries,
refer to Creating and Using Libraries.
-dynamic Command-Line Option
-dynamic
This option produces dynamically bound executables.
The default is -dynamic.
See -minshared Command-Line Option for partially statically bound executables.
-exec Command-Line Option
-exec
This option indicates that any object file created will be used to
create an executable file. Constants with a protected or hidden
export class are placed in the read-only data section. This option also
implies -Bprotected_def. It makes all defined functions and data
(even tentatively defined data) protected by default
(unless otherwise specified by another binding option or pragma).
-lname Command-Line Option
-lname
The name parameter forms part of the name
of a library the linker searches for when looking for routines
called by your program.
This option causes the linker to search one of the following
default libraries, if they exist, in an attempt to resolve
unresolved external references:
- /usr/lib/hpux32/name.so
- /usr/lib/hpux32/name.a
- /opt/langtools/lib/hpux32/name.so
- /opt/langtools/lib/hpux32/name.a
Whether it searches the shared library (.so) or the
archive library (.a) depends on the value of the -a
linker option or the -minshared compiler option.
Example:
aCC file.o -lnumeric
This command directs the linker to link file.o and (by default)
search the library /usr/lib/hpux32/libnumeric.so.
Note:
Because a library is searched when its name is encountered, placement
of a -l is significant. If a file contains an unresolved
external reference, the library containing the definition must be
placed after the file on the command line.
-Ldirectory Command-Line Option
-Ldirectory
The directory parameter is the HP-UX directory where
you want the linker to search for libraries your program uses
before searching the default directories.
This option causes the linker to search for libraries in
directory in addition to using the default search path.
Example:
aCC -L/project/libs prog.C -lmylib1 -lmylib2
This command compiles and links prog.C and
directs the linker to search the directories and /project/libs for
any libraries that prog.C uses (in this case, mylib1 and mylib2).
See the -lname option for default search path.
The -L option affects only those -lname options that are subsequent to it
on the command line. This option is passed directly to the linker.
-minshared Command-Line Option
-minshared
This option indicates that the result of the current compilation
is going into an executable file that will make minimal use
of shared libraries.
This option is equivalent to -exec -Bprotected.
+nostl Command-Line Option
+nostl
By eliminating references to the standard header files
and libraries bundled with HP aC++, this option allows experienced
users full control over the header files and libraries used in compilation
and linking of their applications, without potential complications that
arise in mixing different libraries.
Note:
Complete understanding of the linking process and the behavior
of the actual (third party) libraries linked with the application
is essential to avoid link or runtime failures.
+Onolibcalls= Command-Line Option
+Onolibcalls=function1,function2,...
This option allows you to turn off libcall optimizations
(inlining or replacement) for calls to the listed functions.
This option overrides system header files.
|
| Linker Options |
You can specify the following linker options on the compiler command line:
- -e epsym - Sets the default entry point address for the output file
- -n - The linker marks the output as sharable
- -N - The linker marks the output as unsharable
- -q - The linker marks the output as demand-loadable
- -Q - The linker marks the output as not demand-loadable
- -r - Retains relocation information for subsequent re-linking
- -s - The linker strips the symbol table from the executable file it produces
- -usymbol - Enters symbol as an undefined symbol in ld's symbol table
- +ild - Specifies incremental linking
- +ildrelink - Performs an initial incremental link
- -z - Disallows dereferencing of null pointers at runtime.
- -Z - Allows dereferencing of null pointers at runtime.
-e epsym Command-Line Option
-e epsym
Using this option sets the default entry point address for the output file to be the same as the
symbol epsym. This option only applies to executable files. It does not work if epsym=xec.
-n Command-Line Option
-n
This option causes the program file produced by the linker to be marked as sharable.
-N Command-Line Option
-N
This option causes the program file produced by the linker to be marked as unsharable.
Unsharable executable files generated with the -N option cannot be executed with exec.
-q Command-Line Option
-q
This option causes the output file from the linker to be marked as demand-loadable.
-Q Command-Line Option
-Q
This option causes the program file from the linker to be marked as not demand-loadable.
-r Command-Line Option
-r
Use this option to retain relocation information in the output file for
subsequent relinking.
-s Command-Line Option
-s
Using this option causes the executable program file created by the linker to be
stripped of symbol table information. Specifying this option prevents using a symbolic
debugger on the resulting program.
-usymbol Command-Line Option
-usymbol
Enter symbol as an undefined symbol in ld’s symbol table. The resulting unresolved reference
is useful for linking a program solely from object files in a library. More than one symbol can
be specified, but each must be preceded by -u.
+ild Command-Line Option
+ild
This option specifies incremental linking. If the output file does not exist, or if it was created
without the +ild option, the linker performs an initial incremental link. The output file
produced is suitable for subsequent incremental links. The incremental link option is valid for
both executable and shared library links. It is not valid for relocatable links, options or tools
that strip the output module, and certain optimization options.
+ildrelink Command-Line Option
+ildrelink
This option performs an initial incremental link, regardless of the output load module. In
certain situations during incremental linking (for example, internal padding space is
exhausted), the incremental linker is forced to perform an initial incremental link. The
+ildrelink option allows you to avoid such unexpected initial incremental links by
periodically rebuilding the output file.
|
| Options for Naming the Output File |
The following options allow you to name the compilation output file
something other than the default name:
- -o outfile - Specifies the name of the output file from the compilation.
- -.suffix - Specifies a file name suffix to be used for the output file from the compilation.
-o Command-Line Option
-o outfile
The outfile parameter is the name of the file containing the output of the compilation. This
option causes the output of the compilation to be placed in outfile.
Without this option the default name is a.out. When compiling a single source file with the
-c option, you can use the -o option to specify the name and location of the object file.
-.suffix Command-Line Option
-.suffix
The suffix parameter represents the character or characters to be used as the output file
name suffix. suffix cannot be the same as the original source file name suffix. Using this
option causes the compiler to direct output from the -E option into a file with the
corresponding .suffix instead of into a corresponding .c file.
Example:
aCC -E -.i prog.C
This command preprocesses the code in prog.C and puts the resulting code in the file prog.i.
|
| Native Language Support Option |
The following is an option to enable native language support:
-Y Command-Line Option
-Y
This option enables Native Language Support (NLS) of 8-bit, 16-bit and 4-byte EUC
characters in comments, string literals, and character constants.
The language value (refer to environ(5) for the LANG environment variable) is used to
initialize the correct tables for interpreting comments, string literals, and character
constants. The language value is also used to build the path name to the proper message
catalog.
|
| Runtime Checking |
The following option allows you to check the programs for errors at run time:
The following options control dereferencing of null pointers:
- -z - Disallows dereferencing of null pointers at runtime.
- -Z - Allows dereferencing of null pointers at runtime.
-z Command-Line Option
-z
This option disallows dereferencing of null pointers at runtime.
Fatal errors result if null pointers are dereferenced. If you attempt to dereference a null
pointer, a SIGSEGV error occurs at run time.
Example:
aCC -z file.C
The above command compiles file.C and generates code to disallow dereferencing of null
pointers.
For more information, see signal(2) and signal(5) manpages.
-Z Command-Line Option
-Z
This option allows dereferencing of null pointers at runtime. This is the
default. The value of a dereferenced null pointer is zero.
+check= Command-Line Option
+check=all|none|bounds|globals|malloc|stack|truncate|uninit
The +check=xxx options provide runtime checks to detect many common coding
errors in the user program. These options introduce additional instructions for runtime
checks that may significantly slow down the user program. A failed check will
result in the program aborting at runtime. In most cases, an error message and
a stack trace will be emitted to stderr before program termination. The environment variable RTC_NO_ABORT can be set to 1 to allow the program to continue after a failed runtime
check. This allows the user to get the diagnostics for all the failed checks in a single execution run.
The +check options need to be specified at both compile time and link time since
they may require additional libraries to be linked into the user program. If different
+check options are specified while compiling different source files, all the specified
+check options are needed at link time.
Multiple +check options are interpreted left to right. In case of conflicting
options, the one on the right will override an earlier +check option.
NOTE: The +check option is only supported on Integrity systems.
+check=all
The +check=all option enables almost all runtime checks provided by the compiler except for +check=truncate, which must be explicitly specified to enable it. The +check=all option overrides any +check=xxx options that appear earlier on the command line, and is currently equivalent to the following options:
+check=bounds:array +check=globals +check=malloc
+check=stack:variables +check=uninit -z
The -z option, which is part of +check=all, can be overridden by an
explicit -Z option.
+check=none
The +check=none option turns off all runtime checking options. It disables any +check=xxx
options that appear earlier on the command line.
+check=bounds[:array|pointer|all|none]
The +check=bounds option enables checks for out-of-bounds references to array variables or to buffers through pointer access. The check is performed for each reference to an array element or pointer access. If a check fails, an error message is emitted and the program is aborted.
The +check=bounds option applies only to local and global array variables. It also applies to references to array fields of structs. It does not apply to arrays allocated dynamically using malloc or alloca.
You can specify one of the following +check=bounds suboptions:
- array - Enables check for out-of-bounds references to array variables.
- pointer - Enables check for out-of-bounds references to buffers through pointer access. The buffer could be a heap object, global variable, or local variable. This suboption also checks out-of-bounds access through common libc function calls such as strcpy, strcat, memset, and so on. The check can create significant run-time performance overhead.
- all - Enables out-of-bounds checks for both arrays and pointers. This is equal to +check=bounds:array +check=bounds:pointer.
- none - Disables out-of-bounds checks.
- +check=bounds (with no suboption) - Is equal to +check=bounds:array. This may change in the future to also include +check=bounds:pointer.
When +check=all is specified, it enables +check=bounds:array only. To enable the pointer out-of-bounds check, +check=bounds:pointer must be specified explicitly.
You can combine +check=bounds:[pointer|all] with all other +check options,
except for +check=globals (which would be ignored in this case).
Also see the +check=malloc and the +check=stack options for related runtime checks
for heap and stack objects.
+check=globals
The +check=globals option enables runtime checks to detect corruption of global variables by introducing and checking "guards" between them, at the time of program exit.
Setting environment variable RTC_ROUTINE_LEVEL_CHECK will also enable the check whenever a function compiled with this option returns.
For this purpose, the definition of global is extended to be all variables that have static storage duration, including file or namespace scope variables, function scope static variables, and class (or template class) static data members.
+check=malloc
The +check=malloc option enables memory leak and heap corruption checks at runtime.
It will cause the user program to abort for writes beyond boundaries of heap objects, free or
realloc calls for a pointer that is not a valid heap object and out-of-memory conditions.
Memory leak information is captured and written out to a log file when the program exits.
The name of the logfile is printed out before program termination.
The +check=malloc option works by intercepting all heap allocation and deallocation calls.
This is done by the use of a debug malloc library, librtc.so. The option works for programs
that use the system malloc or for user provided malloc routines in a shared library. The
librtc.so library is also used by the HP WDB debugger to provide heap memory checking
features in the debugger. Please refer to the HP WDB debugger documentation for more
information about heap memory checking. The librtc.so library is shipped as part of the
wdb product. Please install the HP WDB bundled with the compiler or a more recent version
of wdb to get full functionality.
The default behavior of the +check=malloc option can be changed by users providing their own
rtcconfig file. The user specified rtcconfig file can be in the current directory
OR in a directory specified by the GDBRTC_CONFIG environment variable. The default
configuration used by the +check=malloc option is:
check_bounds=1;check_free=1;scramble_block=1;
abort_on_bounds=1;abort_on_bad_free=1;abort_on_nomem=1;
check_leaks=1;min_leak_size=0;check_heap=0;
frame_count=4;output_dir=.;
For a description for the above configuration parameters and the full list of other parameters,
please refer to the HP WDB debugger documentation.
+check=stack[:frame|:variables|:none]
The +check=stack[:frame|:variables|:none] option enables runtime checks to detect
writes outside stack boundaries. Markers are placed before and after the whole stack frame
and around some stack variables. On procedure exit, a check is done to see if any marker has
been overwritten. If any stack check fails, an error message and stack trace is written to
stderr and the program is aborted. The stack checks are not performed for an abnormal exit
from the procedure (for example, using longjmp(), exit(), abort(), or exception handling).
+check=stack:frame
This option enables runtime checks for illegal writes from the current stack frame that overflow
into the previous stack frame.
+check=stack:variables
This option enables runtime checks for illegal writes to the stack just before or after some
variables on the stack. This includes array, struct/class/union and variables whose address is
taken. It also includes the overflow check for the stack frame (+check=stack:frame). In addition
to the above checks, this option causes the whole stack to be initialized to a "poison" value, which
can help detect the use of uninitialized variables on the stack.
+check=stack:none
This option disables all runtime checks for the stack.
+check=stack
The +check=stack option without any qualifiers is equivalent to +check=stack:variables at optimization
levels 0 and 1. It is equivalent to +check=stack:frame for optimization level 2 and above.
+check=truncate[:explicit|:implicit]
The +check=truncate[:explicit|:implicit] option enables runtime checks to detect data loss in assignment when integral values are truncated. Data loss occurs if the truncated bits are not all the same as the left most non-truncated bit for signed type, or not all zero for unsigned type.
Programs might contain intentional truncation at runtime, such as when obtaining a hash value from a pointer or integer. To avoid runtime failures on these truncations, you can explicitly mask off the value:
ch = (int_val & 0xff);
Note that the +check=all option does not imply +check=truncate. To enable +check=truncate, you must explicitly specify it.
+check=truncate:explicit
This option turns on runtime checks for truncation on explicit user casts of integral values, such as (char)int_val.
+check=truncate:implicit
This option turns on runtime checks for truncation on compiler-generated implicit type conversions, such as ch = int_val;.
+check=truncate
This option turns on runtime checks for both explicit cast and implicit conversion truncation.
+check=uninit
The +check=uninit option checks for a use of a stack variable before it is defined.
If such a use is detected, an error message is emitted and the program is aborted. The check is done
by adding an internal flag variable to track the definition and use of user variables.
Also see the +Oinitcheck option to enable compile time warnings for variables that may be used before they are set.
|
| Code Optimizing Options |
Optimization options can be used to improve the execution
speed of programs compiled with the HP compiler.
To use optimization, first specify the appropriate
basic optimization level (+O1, +O2, +O3, or +O4)
on the command line followed by one or more finer
or more precise options when necessary.
For more information and examples, refer to Optimizing HP aC++ Programs.
This section discusses the following topics:
|
| Basic Optimization Level Options |
|
The following options allow you specify the basic level of optimization:
- -O - Specify level 2 optimization
- +O0 - Specify level 0 optimization
- +O1 - Specify level 1 optimization
- +O2 - Specify level 2 optimization
- +O3 - Specify level 3 optimization
- +O4 - Specify level 4 optimization
Compiling files at optimization level 2 ("-O" or "+O2") and
above increases the amount of virtual memory needed by the compiler.
In cases where very large functions or files are compiled at +O2,
or in cases where aggressive (+O3 and above) optimization is used,
ensure that the maxdsiz kernel tunable is set appropriately on
the machine where compilation takes place.
HP recommends a setting of 0x100000000, or 4 GB (the default for
this parameter is 0x100000000, or 4 GB) for maxdsiz_64bit in such
cases. Updating the maxdsiz_64bit tunable will ensure that the
compiler does not run out of virtual memory when compiling large files
or functions.
In addition, maxssiz_64bit should be set to 128 MB for very large or
complex input files. (Normally a maxssiz_64bit setting of 64 MB will
be sufficient.)
HP recommends not reducing the maxfiles setting below the default value of 2048.
See the kctune man page for more information on how to change kernel tunable parameters.
-O Command-Line Option
-O
This option invokes the optimizer to perform level 2 optimization. This option is equivalent to
+O2 option.
Example:
This command compiles prog.C and optimizes at level 2.
aCC -O prog.C
+O0 Command-Line Option
+O0
Use +O0 for fastest compile time or with simple programs. No optimizations are performed.
Example:
The following command compiles prog.C and optimizes at level 0.
aCC +O0 prog.C
+O1 Command-Line Option
+O1
This option performs level 1 optimization only. This includes branch optimization, dead code
elimination, faster register allocation, instruction scheduling, and peephole optimization.
This is the default optimization level.
Example:
This command compiles prog.C and optimizes at level 1.
aCC +O1 prog.C
+O2 Command-Line Option
+O2
This option performs level 2 optimization. This includes level 1 optimizations plus
optimizations performed over entire functions in a single file.
NOTE: Compiling with
this optimization setting may require additional memory resources. Refer to the
memory resource discussion above.
Example:
This command compiles prog.C and optimizes at level 2.
aCC +O2 prog.C
+O3 Command-Line Option
+O3
This option performs level 3 optimization. This includes level 2 optimizations plus full
optimization across all subprograms within a single file.
NOTE: Compiling with
this optimization setting may require additional memory resources. Refer to the
memory resource discussion above.
Example:
This command compiles prog.C and optimizes at level 3.
aCC +O3 prog.C
+O4 Command-Line Option
+O4
This option performs level 4 optimization. This includes level 3 optimizations plus full
optimizations across the entire application program.
When you link a program, the compiler brings all modules that were compiled at optimization
level 4 into virtual memory at the same time. Depending on the size and number of the
modules, compiling at +O4 can consume a large amount of virtual memory. If you are linking
a large program that was compiled with the +O4 option, you may notice a system slow down.
In the worst case, you may see an error indicating that you have run out of memory.
NOTE: Compiling with
this optimization setting may require additional memory resources. Refer to the
memory resource discussion above.
Example:
This command compiles prog.C and optimizes at level 4.
aCC +O4 prog.C
If you run out of memory when compiling at +O4 optimization, you can:
- Compile at +O4 only those modules that need to be compiled at optimization level 4, and
compile the remaining modules at a lower level.
- If you still run out of memory, increase the per-process data-size limit. Use the appropriate system administration tool to increase the maxdsiz_64bit process parameter to more than 4 GB. This procedure provides the process with additional data space.
- If increasing the per-process data size limit does not solve the problem, increase the
system swap space.
Object Files Generated at Optimization Level 4
Object files generated by the compiler
at optimization level 4, called intermediate object files, are intended to be temporary files.
These object files contain an intermediate representation of the user code in a format that is
designed for advanced optimizations. The size of these intermediate object files may typically be 3 to 10 times as large as normal object files.
Hewlett-Packard reserves the right to change
the format of these files without prior notice. There is no guarantee that intermediate object
files will be compatible from one revision of the compiler to the next. Use of intermediate files must be limited to the compiler that created them. For the same reason, intermediate object files should not be
included into archived libraries that might be used by different versions of the compiler.
The compiler will issue
an error message and terminate when an incompatible intermediate file is generated.
|
| Additional Optimizations for Finer Control |
Following are the additional optimizations options for finer control:
-ipo Command-Line Option
This option enables interprocedural optimizations across files. The object file produced using
this option contains intermediate code (IELF file). At link time, ld automatically invokes the
interprocedural optimizer (u2comp), if any of the input object files is an IELF file.
For optimization levels +O0 and +O1, this option is silently ignored.
The -ipo option gets implicitly invoked with the +O4 and +Ofaster options to match
current behavior (+O4 ==> +O3 -ipo).
For -ipo compilations, the back end is parallelized, and the level of
parallelism can be controlled with the environment variable PARALLEL, since
the standard HP-UX make utility is used for the parallelization.
See +O4 for additional information.
+[no]nrv Command-Line Option
+[no]nrv
This option disables or enables the named return value (NRV) optimization. By default
it is enabled.
The NRV optimization eliminates a copy-constructor call by allocating a local object of a
function directly in the caller’s context if that object is always returned by the function.
Example:
struct A{
A(A const&); //copy-constructor
};
A f(A constA x) {
A a(x);
return a; // Will not call the copy constructor if the
} // optimization is enabled.
This optimization will not be performed if the copy-constructor was not declared by the
programmer. Note that although this optimization is allowed by the ISO/ANSI C++ standard,
it may have noticeable side-effects.
Example:
aCC,+nrv_optimization,on app.C
+O[no]failsafe Command-Line Option
+O[no]failsafe
This option enables [disables] failsafe optimization. When a compilation fails at the current
optimization level +Ofailsafe will automatically restart the compilation
at +O2 (for specific
high level optimizer errors +O3 or +O4), +O1, or +O0.
The default is +Ofailsafe.
+O[no]limit Command-Line Option
+O[no]limit
The +Onolimit option enables optimizations regardless of their effect on compile
time or memory consumption.
Without the use of +Onolimit option, the compiler may suppress optimizations that
significantly increase compile time or consume a lot of memory. A warning is emitted by the
compiler whenever this happens for a specific procedure. +Onolimit allows the user
to get full optimization. If possible, the user should split the large procedure into smaller
procedures to get full optimization without excessive compile time overhead.
The +Olimit option disables optimizations that significantly increase compile time or that
consume a lot of memory.
Use +Onolimit at all optimization levels.
Usage:
+O[no]limit=level
The defined values of level are:
| default |
Based on tuning heuristics, the optimizer will spend a reasonable amount of time processing large procedures. This is the default option.
|
| min |
For large procedures, the optimizer will avoid non-linear time optimizations. This option is a synonym for +Olimit.
|
| none |
The optimizer will fully optimize large procedures, possibly resulting in
significantly increased compile time. This option is a synonym for
+Onolimit.
|
Example:
To remove optimization time restrictions at +O2, +O3, or +O4 optimization levels,
use +Onolimit as follows:
aCC <opt level> +Onolimit sourcefile.C
+O[no]ptrs_ansi Command-Line Option
+O[no]ptrs_ansi
+Optrs_ansi is synonymous to +Otype_safety=ansi.
+Onoptrs_ansi is synonymous to +Otype_safety=off.
The default is +Onoptrs_ansi
Note: This option is supported in C-mode only. A warning is displayed in C++ when this option is used.
+O[no]ptrs_strongly_typed Command-Line Option
+O[no]ptrs_strongly_typed
+Optrs_strongly_typed is synonymous to +Otype_safety=strong.
+Onoptrs_strongly_typed is synonymous to +Otype_safety=off.
The default is +Onoptrs_strongly_typed.
Note: This option is supported in C-mode only. A warning is displayed in C++ when this option is used.
+O[no]ptrs_to_globals [=list] Command-Line Option
+O[no]ptrs_to_globals[=list]
This option tells the optimizer whether global variables are accessed [are not accessed]
through pointers. If +Onoptrs_to_globals is specified, it is assumed that statically-allocated data (including file-scoped globals, file-scoped statics, and function-scoped static variables) will not be read or written through pointers. The default is +Optrs_to_globals.
+O[no]size Command-Line Option
+O[no]size
While most optimizations reduce code size, the +Osize option suppresses those few
optimizations that significantly increase code size. The +Onosize option enables
code-expanding optimizations.
Use +Osize at all optimization levels.
The default is +Onosize.
|
| Advanced +O Optimization Options |
The following optimization options provide additional control for special situations:
+O[no]cross_region_addressing Command-Line Option
+O[no]cross_region_addressing
This option enables [disables] the use of cross-region addressing. Cross-region addressing is
required if a pointer, such as an array base, points to a different region than the data being
addressed due to an offset that results in a cross-over into another region. Standard
conforming applications do not require the use of cross-region addressing.
The default is +Onocross_region_addressing.
Note: Using this option may result in reduced runtime performance.
+O[no]datalayout Command-Line Option
+O[no]datalayout
Enables [disables] profile-driven layout of global
and static data items to improve cache memory
utilization. This option is currently enabled if
+Oprofile=use (dynamic profile feedback) is
specified.
The default in the absence of
+Oprofile=use is +Onodatalayout.
+O[no]dataprefetch Command-Line Option
+O[no]dataprefetch=kind
The defined values for kind are:
| direct |
Enable generation of data prefetch instructions for the benefit of direct memory accesses, but not indirect memory accesses.
|
| indirect |
Enables the generation of data prefetch instructions for the benefit of both
direct and indirect memory accesses. This is the default at optimization
levels +O2 and above.
|
| none |
Disables the generation of data prefetch instructions. This is the default at
optimization levels +O1 and below.
|
When +Odataprefetch is enabled, the optimizer inserts instructions to
explicitly prefetch data from memory into the data cache.
The default is +Odataprefetch.
+Odataprefetch is equivalent to +Odataprefetch=indirect. +Onodataprefetch is
equivalent to +Odataprefetch=none.
+O[no]fltacc Command-Line Option
+O[no]fltacc=level
This option disables [enables] floating-point optimizations that can result in numerical
differences. Any option other than +Ofltacc=strict also generates Fused Multiply-Add
(FMA) instructions. FMA instructions can improve performance of floating-point applications.
If you specify neither +Ofltacc nor +Onofltacc,
less optimization is performed than for
+Onofltacc. If you do not specify either option, the optimizer generates FMA instructions but does
not perform any expression-reordering optimizations.
Specifying +Ofltacc insures the same result as in unoptimized code (+O0).
The defined values for level are:
| default |
Allows contractions, such as fused multiply- add (FMA), but disallows any
other floating point optimization that can result in numerical differences. |
| limited |
Like default, but also allows floating point optimizations which may affect
the generation and propagation of infinities, NaNs, and the sign of zero. |
| relaxed |
In addition to the optimizations allowed by limited, permits optimizations,
such as reordering of expressions, even if parenthesized, that may affect
rounding error. This is the same as +Onofltacc. |
| strict |
Disallows any floating point optimization that can result in numerical
differences. This is the same as +Ofltacc. |
All options except +Ofltacc=strict option allow the compiler to make transformations
which are algebraically correct, but which may slightly affect the result of computations due
to the inherent imperfection of computer floating-point arithmetic. For many programs, the
results obtained with these options are adequately similar to those obtained without the
optimization.
For applications in which round-off error has been carefully studied, and the order of
computation carefully crafted to control error, these options may be unsatisfactory. To insure
the same result as in unoptimized code, use +Ofltacc.
Example:
All the options, except +Ofltacc=strict, allow the compiler to replace a division by a multiplication
using the reciprocal. For example, the following code:
for (int j=1;j<5;j++)
a[j] = b[j] / x;
is transformed as follows (note that x is invariant in the loop):
x_inv = 1.0/x;
for (int j=1;j<5;j++)
a[j] = b[j] * x_inv;
Since multiplication is considerably faster than division, the optimized program runs faster.
+Ofrequently_called Command-Line Option
+Ofrequently_called=function1[,function2...]
The named functions are assumed to be frequently called. This option overrides any
information in a profile database.
+Ofrequently_called:filename
The file indicated by filename contains a list of functions, separated by spaces or newlines.
These functions are assumed to be frequently called. This option overrides any information in
a profile database.
+O[no]initcheck Command-Line Option
+O[no]initcheck
The initialization checking feature of the optimizer has three possible states:
When on (+Oinitcheck), the optimizer issues warning messages when it discovers uninitialized variables.
When off (+Onoinitcheck), the optimizer does not issue warning messages .
Use +Oinitcheck at optimization level 2 or above.
If this option is used together with +check=uninit uninitialized variables will remain uninitialized so that the an error
will be reported at run-time and trigger a program abort if the variables are accessed.
+O[no]inline Command-Line Option
+O[no]inline
The +Oinline option indicates that any function can be inlined by the optimizer. +Onoinline
disables inlining of functions by the optimizer. This option does not affect functions inlined at
the source code level.
Use +Onoinline at optimization levels 2, 3 and4.
The default is +Oinline at optimization levels 3 and 4.
Usage:
+O[no]inline=function1{,function2...]
This option enables [disables] optimizer inlining for the named functions.
+O[no]inline:filename
The file, filename, should contain a list of function names, separated by commas
or newlines.
+Oinlinebudget Command-Line Option
+Oinlinebudget=n
The +Oinlinebudget option controls the compile time budget for the inliner. A lower number
causes the inliner to consider fewer candidates for inlining, while a higher number leads it to
consider more candidates. The inlining candidates are ordered in priority order based on the
inliner’s heuristics, so this does not affect the most important candidates.
The +Oinlinebudget option controls the aggressiveness of inlining according to the value you
specify for n, where n is an integer in the range 1 - 1000000 that specifies the level of
aggressiveness, as follows:
| n=100 |
Default compile time budget. |
| n>100 |
Allows the inliner to consider more candidates and increase compile time. |
| n<100 |
Considers fewer candidates to reduce compile time for the inliner. |
The +Onolimit and +Osize options also affect inlining. Specifying the +Onolimit option has
the same effect as specifying +Oinlinebudget=200. The +Osize option has the same effect as
+Oinlinebudget=1.
Note: The +Oinlinebudget option takes precedence over both of these options. This
means that you can override the effect of +Onolimit or +Osize option on
inlining by specifying the +Oinlinebudget option on the same compile line.
Use this option at optimization level 2 or higher.
The default is +Oinlinebudget=100.
+Olit Command-Line Option
+Olit=kind
This option places the data items that do not require load time or runtime initialization in a
read-only data section.
The defined values for kind are:
| all |
All string literals and all const-qualified variables that do not require
load-time or run-time initialization will be placed in a read-only data
section. +Olit=all replaces the deprecated +ESlit option. |
| const |
All string literals appearing in a context where const char * is legal, and
all const-qualified variables that do not require load time or runtime
initialization will be placed in a read-only data section. +Olit=const is
mapped to +Olit=all with a warning, except in C compilations. +Olit=const
replaces the deprecated +ESconstlit option in C. |
| none |
No constants are placed in a read-only data section. +Olit=none replaces
the deprecated +ESnolit option. |
The default is +Olit=all for both HP aC++ and HP C. Note that this represents a change from earlier versions of the HP C compiler, which defaulted to +Olit=const.
Note: If you attempt to modify the constant
or literal, a runtime signal 11 will be generated.
+Ointeger_overflow Command-Line Option
+Ointeger_overflow=kind
To provide the best runtime performance, the compiler makes assumptions that runtime
integer arithmetic expressions that arise in certain contexts do not overflow (produce values
that are too high or too low to represent) both expressions that are present in user code and
expressions that the compiler constructs itself. Note that if an integer arithmetic overflow
assumption is violated, runtime behavior is undefined.
+Ointeger_overflow=moderate is the default for all optimization levels.
This was changed to enable a wider class of applications to be compiled with optimization
and run correctly. Previously, +Ointeger_overflow=moderate was the default
below +O2.
Usage:
+Ointeger_overflow=kind
The defined values of kind are:
| aggressive |
Allows the compiler to make a broad set of assumptions that integer
arithmetic expressions do not overflow. |
| conservative |
Directs the compiler to make fewer assumptions that integer arithmetic expressions do not overflow. |
| moderate |
This is the same as +Ointeger_overflow=aggressive, except that linear function test replacement (LFTR) optimization is not performed. |
+Olevel Command-Line Option
+Olevel=name1[,name2,...,nameN]
This option lowers optimization to the specified level for one or more named functions.
level can be 0, 1, 2, 3, or 4.
The name parameters are names of functions in the module being compiled. Use this option
when one or more functions do not optimize well or properly. This option must be used with a
basic +Olevel or -O option.
Note: Currently only the C++ mangled name of the function is allowed for name.
This option works like the OPT_LEVEL pragma. It overrides the pragma for the
specified functions. As with the pragma, you can only lower the level of optimization; you
cannot raise it above the level specified by a basic +Olevel or -O option.
To avoid confusion, use either this option or the OPT_LEVEL pragma.
You can use this option at optimization levels 1, 2, 3, and 4. The default is to optimize all
functions at the level specified by the basic +Olevel or -O option.
Examples:
- The following command optimizes all functions at level 3, except for the functions
myfunc1 and myfunc2, which it optimizes at level 1.
aCC +O3 +O1=myfunc1,myfunc2 funcs.c main.c
- The following command optimizes all functions at level 2, except for the functions
myfunc1 and myfunc2, which it optimizes at level 0.
aCC -O +O0=myfunc1,myfunc2 funcs.c main.c
+O[no]libcalls Command-Line Option
+O[no]libcalls
This option is deprecated and may not be supported
in future releases. On Integrity
systems, including a system header file will cause the functions declared therein to be
eligible for libcalls transformations, regardless of the state of +O[no]libcalls.
Use +O[no]libcalls at any optimization level.
The default is +Onolibcalls.
See also +Onolibcalls=.
+O[no]loop_block Command-Line Option
+O[no]loop_block
Loop blocking is a combination of strip mining and interchange that
improves data cache locality. It is provided primarily to deal with
nested loops that manipulate arrays that are too large to fit into the
data cache. Under certain circumstances, loop blocking allows reuse of
these arrays by transforming the loops that manipulate them so that
they manipulate strips of the arrays that fit into the cache.
At optimization levels 3 and 4, using +Oloop_block (the
default) allows automatic loop blocking. Specifying +Onoloop_block
disables loop blocking.
+O[no]loop_transform Command-Line Option
+O[no]loop_transform
This option transforms [does not transform] eligible loops for improved cache
and other performance. This option can be used at optimization levels 2, 3 and 4.
The default is +Oloop_transform.
+O[no]loop_unroll Command-Line Option
+O[no]loop_unroll[=unroll_factor]
This option enables [disables] loop unrolling. This optimization
can occur at optimization levels 2, 3, and 4. The
default is +Oloop_unroll, where the optimizer uses
its own heuristics to select an unroll factor for
each loop. The unroll_factor controls code expansion.
Note that this option has no effect on loop unroll-and-jam.
+O[no]loop_unroll_jam Command-Line Option
+O[no]loop_unroll_jam
Loop unroll-and-jam involves partially unrolling one or more loops
higher in the nest than the innermost loop, and fusing ("jamming") the
resulting loops back together. This transformation is primarily
intended to increase register reuse and decrease memory loads and
stores per operation within an iteration of a nested loop.
At optimization levels 3 and 4, the default is +Oloop_unroll_jam, which
allows automatic loop unroll-and-jam. Specifying +Onoloop_unroll_jam
disables loop unroll-and-jam. Note that +Onoloop_unroll has no effect
on loop unroll-and-jam.
+O[no]moveflops Command-Line Option
+O[no]moveflops
The +Onomoveflops option is approximately equivalent to +Ofltacc=strict +Ofenvaccess.
The default is +Omoveflops.
This option is deprecated and may not be supported in future releases.
+O[no]openmp Command-Line Option
+O[no]openmp
The +Oopenmp option causes the OpenMP directives to be honored. This option is effective at
any optimization level. Non OpenMP parallelization directives are ignored with warnings.
+Onoopenmp requests that OpenMP directives be silently ignored. If neither +Oopenmp nor
+Onoopenmp is specified, OpenMP directives will be ignored with warnings.
The OpenMP specification is available at
http://www.openmp.org/specs.
OpenMP programs require the libomp and libcps runtime support libraries to be present on
both the compilation and runtime systems. The compiler driver will automatically include
them when linking.
If you use +Oopenmp in an application you must use -mt with any files that are not compiled with +Oopenmp. Refer to -mt for additional information and
restrictions.
It is recommended that you use the -N option when linking OpenMP programs to avoid
exhausting memory when running with large numbers of threads.
+opts Command-Line Option
+opts filename
The file indicated by filename contains a list of options that are processed
as if they had been specified on the command line at the point of the +opts option.
The options must be delimited by a blank character. You can add comments to the option file by using a "#" character in the first column of a line.
The "#" will cause the entire line to be ignored by the compiler.
Example:
$ aCC -opts GNUOptions foo.c
Where GNUOptions contains:
#This file contains the set of options for programs needing GNU support
-Ag++ -Wc
+O[no]parminit Command-Line Option
+O[no]parminit
This option enables [disables] automatic initialization to non-NaT of unspecified function
parameters at call sites. This is useful in preventing NaT values in parameter registers. The
default is +Onoparminit.
+O[no]parmsoverlap Command-Line Option
+O[no]parmsoverlap
The +Onoparmsoverlap option optimizes with the assumption that on entry to a function each
of that function’s pointer-typed formals points to memory that is accessed only through that
formal or through copies of that formal made within the function.
For example, that memory must not be accessed through a different formal,
and that formal must not point to a global that is accessed by name within
the function or any of its calls.
Use +Onoparmsoverlap if C/C++ programs have been literally translated from FORTRAN programs.
The default is +Oparmsoverlap.
+O[no]procelim Command-Line Option
+O[no]procelim
This option enables [disables] the elimination of functions and sometimes
data that is not referenced by the program. Only symbols with the hidden export
class or static may be eliminated unless you compile with
-ipo.
Use this option when linking an executable file, to remove
functions not referenced by the application. You can also use
this option when building a shared library to remove functions
not exported and not referenced from within the shared library.
This may be especially useful when functions have been inlined.
Any function having symbolic debug information associated with
it is not removed. Unreferenced symbols may be eliminated when compiling with
-ipo.
The default is +Onoprocelim at optimization levels 0 and 1.
At levels 2, 3 and 4, the default is +Oprocelim.
+O[no]promote_indirect_calls Command-Line Option
+O[no]promote_indirect_calls
This option uses profile data from profile-based optimization and other information to
determine the most likely target of indirect calls and promotes them to direct calls. Indirect
calls occur with pointers to functions and virtual calls.
In all cases the optimized code tests to make sure the direct call is being taken and if not,
executes the indirect call. If +Oinline is in effect, the optimizer may also inline the promoted
calls. +Opromote_indirect_calls is only effective with profile-based optimization.
Note: The optimizer tries to determine the most likely target of indirect calls. If the
profile data is incomplete or ambiguous, the optimizer may not select the best
target. If this happens, your code’s performance may decrease.
This option can be used at optimization levels 3 and 4. At +O3, it is only effective if indirect
calls from functions within a file are mostly to target functions within the same file. This is
because +O3 optimizes only within a file whereas, +O4 optimizes across files.
The default is +Opromote_indirect_calls at optimization level 3 and above.
+Onopromote_indirect_calls will be the default at optimization level 2 and below.
+Orarely_called Command-Line Option
+Orarely_called=function1[,function2...]
The named functions are assumed to be rarely called. This option overrides any information
in a profile database.
+Orarely_called:filename
The file indicated by filename contains a list of functions, separated by spaces or newlines.
These functions are assumed to be rarely called. This option overrides any information in a
profile database.
+O[no]recovery Command-Line Option
+O[no]recovery
This option generates [does not generate] recovery code for control speculation. For code that
writes to uncacheable memory that may not be properly identified
as volatile, the +Orecovery option reduces the risk of incorrect behavior.
The default is
+Orecovery.
Note:The program that uses signal handlers to catch signals raised by memory
accesses may not behave correctly under +Onorecovery.
+O[no]signedpointers Command-Line Option
+O[no]signedpointers
The +Osignedpointers option treats pointers in Boolean comparisons (for example, <, <=, >,
>=) as signed quantities. Applications that allocate shared memory and that compare a
pointer to shared memory with a pointer to private memory may run incorrectly if this
optimization is enabled.
The default is +Onosignedpointers.
Note: This option is supported in C-mode only. A warning is displayed in C++
when this option is used.
+Oshortdata Command-Line Option
+Oshortdata[=size]
All objects of size bytes or smaller are placed in the short data area, and references to such
data assume it resides in the short data area. Valid values of size are a decimal number
between 8 and 4,194,304 (4MB).
If no size is specified, all data is placed in the short data area.
The default is +Oshortdata=8.
Note: Using a value that is too big or without the optional
size may give various linker fix up errors if there is more than 4Mb of short
data.
+O[no]store_ordering Command-Line Option
+O[no]store_ordering
This option preserves [does not preserve] the original program order for stores to memory that
is visible to multiple threads. This does not imply strong ordering. The default is
+Onostore_ordering.
+Otype_safety Command-Line Option
+Otype_safety=kind
This option controls type-based aliasing assumptions.
The defined values for kind are:
| off |
The default. Specifies that aliasing can occur freely across types. |
| limited |
Code follows ANSI aliasing rules. Unnamed objects should be treated as if they had an unknown type. |
| ansi |
Code follows ANSI aliasing rules. Unnamed objects should be treated the same as named objects. |
| strong |
Code follows ANSI aliasing rules, except that accesses through lvalues of a
character type are not permitted to touch objects of other types and field
addresses are not to be taken. |
The default is +Otype_safety=off.
+O[no]volatile Command-Line Option
+O[no]volatile
The +Ovolatile option implies that memory references to global variables are volatile and
cannot be removed during optimization. The +Onovolatile option implies that all globals are
not of volatile class. This means that references to global variables can be removed during
optimization.
Use this option to control the volatile semantics for all global variables.
Use +Ovolatile at all optimization levels.
The default is +Onovolatile.
Note: The +Ovolatile option is not recommended. Instead use the C/C++ Standard volatile qualifiers.
+O[no]whole_program_mode Command-Line Option
+O[no]whole_program_mode
The +Owhole_program_mode option enables the assertion that only the files that are compiled
with this option directly reference any global variables and procedures that are defined in
these files. In other words, this option asserts that there are no unseen accesses to the globals.
When this assertion is in effect, the optimizer can hold global variables in registers longer and
delete inlined or cloned global procedures. This option is in effect only at +O4 level of
optimization.
All files compiled with +Owhole_program_mode must also be compiled with +O4. If any of the
files are compiled with +O4 but are not compiled with +Owhole_program_mode, the linker
disables the assertion for all files in the program.
Use this option to increase performance speed, but only when you are certain that only the
files compiled with +Owhole_program_mode directly access any globals that are defined in
these files.
The default is +Onowhole_program_mode which disables the assertion.
|
| Profile-Based Optimization Options |
|
Profile-based optimization is a set of performance-improving code transformations based on
the run-time characteristics of your application.
The following is a list of profile-based optimization options:
- +Oprofile - Prepares the object code for profile-based optimization data collection
+Oprofile Command-Line Option
+Oprofile=collect[:<qualifiers>]
+Oprofile=use[:filename]
This option instructs the compiler to instrument the object code for collecting run-time profile
data. The profiling information can then be used by the linker to perform profile-based
optimization.
+Oprofile=collect instructs the compiler to instrument the object code for collecting runtime profile
data. The profiling information can then be used by the linker to perform profile-based
optimization.
+Oprofile=use[:filename] causes the compiler to look for
a profile database file. If a filename is not specified, the compiler will look for a file named "flow.data" or the file/path
specified in the FLOW_DATA environment variable. If a filename is specified, it overrides the FLOW_DATA environment variable.
After compiling and linking with +Oprofile=collect, run the resultant program using
representative input data to collect execution profile data. Profile data is stored in flow.data by default. The name will be
generated as flow.<suffix> if there is already a flow.data file present in the
current directory. Finally, recompile with the +Oprofile=use option
(passing it the appropriate filename if necessary) to perform profile-based optimization.
Example:
aCC +Oprofile=collect -O -o prog.pbo prog.C
The above command compiles prog.C with optimization, prepares the object code for data
collection, and creates the executable file prog.pbo. Running prog.pbo collects runtime
information in the file flow.data in preparation for optimization with +Oprofile=use.
+Oprofile=collect [:<qualifiers>]
<qualifiers> are a comma-separated list of profile collection qualifiers.
The following table lists the supported profile collection qualifiers:
| arc |
Enable collection of arc counts. |
| dcache |
Enable collection of data cache misses. |
| stride |
Enable collection of stride data. |
| loopiter |
Enable collection of loop iteration counts. |
| all |
Enable collection of all types of profile data. This is equivalent to
+Oprofile=collect:arc,stride,loopiter,dcache. This is the default. |
|
| Displaying Optimization Information |
The following option displays informational messages about the optimization process:
+O[no]info Command-Line Option
+O[no]info
+Oinfo displays informational messages about the optimization process. This option may be
helpful in understanding what optimizations are occurring.
You can use the option at optimization levels 0-4. The default is +Onoinfo at levels 0-4.
|
| Parallel Processing Options |
HP aC++ provides the following optimization options for parallel code:
- -mt - Automatically selects and sets flags for parallelization.
- +O[no]autopar - Parallelizes loops deemed safe and profitable to parallelize.
- +O[no]report - Produces a Loop Report.
- +tls - Specifies thread local storage.
- +wlock - Enables compile-time diagnostic messages for potential
errors in using lock/unlock calls in programs that use pthread library based lock/unlock functions.
-mt Command-Line Option
The -mt option enables multi-threading capability
without the need to set any other flags, such as -l
and -D. HP aC++ examines your environment and
automatically selects and sets the appropriate flags.
For additional information refer to the performance discussion under Threads.
There are three possible sets of flags depending on
your operating system and which libstd you use.
The following table lists the option matrix for -mt.
old-lib
libstd 1.2.1
(-AP)
&
librwtool
7.0.x |
- -D_REENTRANT
- -DRW_MULTI_THREAD
- -DRWSTD_MULTI_THREAD
- -D_THREAD_SAFE
- -D_POSIX_C_SOURCE=199506L
- -D_HPUX_SOURCE *
- -lpthread
|
new-lib (-AA)
libstd
2.2.1
|
- -D_REENTRANT
- -D_RW_MULTI_THREAD
- -D_RWSTD_MULTI_THREAD
- -D_POSIX_C_SOURCE=199506L
- -D_HPUX_SOURCE *
- -lpthread
|
C mode
-Ae/-Aa -AC99 -AC89 |
- -D_REENTRANT
- -D_POSIX_C_SOURCE=199506L
- -D_HPUX_SOURCE *
- -lpthread
|
| * required if -D_POSIX_C_SOURCE is used |
Note: For C++ and C -Ae -D_HPUX_SOURCE is set to be compatible with the default when -mt is not used. For C mode options -AC89, -AC99, and
-Aa -D_HPUX_SOURCE is also set. If you do not want to use -D_HPUX_SOURCE, you can undefine it by using -U. Example: -U_HPUX_SOURCE
Macros Used to Compile Multi-Thread Source Code:
- _REENTRANT: Required by system header files that provide reentrant functions (suffixed by _r).
- RW_MULTI_THREAD/_RW_MULTI_THREAD: Required by Rogue Wave toolsh++ header files and libraries. RW_MULTI_THREAD is used by toolsh++ 7.0.x. _RW_MULTI_THREAD is used by toolsh++ 8.x
- RWSTD_MULTI_THREAD/_RWSTD_MULTI_THREAD: Required by Rogue Wave standard library header files and libraries. RWSTD_MULTI_THREAD is used by libstd 1.2.1. _RWSTD_MULTI_THREAD is used by libstd 2.2.1 when compiling with -AA.
- _POSIX_C_SOURCE=199506L: Required by pthread.
- _HPACC_FIXED_REFCNT_MUTEX: This flag reduces the amount of
space for string mutexes and thereby increases performance when using either -AA
or -AP strings. Instead of having one mutex per string, there will now be a fixed
array of mutexes shared among all strings.
- libpthread: Kernel thread library used on 11.x systems.
Note: Make sure that -mt is used consistently at compile
and link times. Whenever you link with -mt, everything must be compiled with
-mt, even if you do not think your file will be used in a threaded application.
When you incorrectly mix and match with -mt, you
get a runtime abort with the following message:
aCC runtime: Use of "-mt" must be consistent during both compilation and linking.
To find the library or object that is missing -mt, use
/usr/ccs/bin/footprints and look for the following:
-mt [(off) 1]
-mt [on 1]
(Or not present)
The number 1 above is the count of objects with that -mt setting. Not present implies the source was not compiled with a recent compiler that contains this information.
+O[no]autopar Command-Line Option
+O[no]autopar
The +Oautopar option enables automatic parallelization of loops that
are deemed safe and profitable by the loop transformer. This optimization allows applications to exploit otherwise idle resources on multicore or multiprocessor systems by automatically transforming serial loops into multithreaded parallel code.
When the +Oautopar option is used at optimization levels +O3 and above, the compiler automatically parallelizes those loops that are deemed
safe and profitable by the loop transformer.
The default is +Onoautopar, which disables automatic parallelization of loops.
Automatic parallelization can be combined with manual parallelization
through the use of OpenMP directives and the +Oopenmp option. When both
+Oopenmp and +Oautopar are specified, then any existing OpenMP directives take precedence, and the compiler will only consider auto-parallelizing other loops that are not controlled by those directives.
Programs compiled with the +Oautopar option require the libcps, libomp,
and libpthreads runtime support libraries to be present at both compilation
and runtime. When linking with the HP-UX B.11.61 linker
(patch PHSS_36342 or PHSS_36349), compiling with the +Oautopar
option causes them to be automatically included. Older linkers require
those libraries to be specified explicitly or by compiling with +Oopenmp.
At present, +Oautopar is only supported when compiling C or Fortran
files, and not C++. If you use +Oautopar with C or Fortran code in a
mixed-language application that also includes C++ files, you must use
+Oopenmp when compiling and linking the C++ files. Refer to the +Oopenmp documentation for additional information and restrictions.
+O[no]report Command-Line Option
+O[no]report[=report_type]
This option causes the compiler to display [not to display] various optimization reports.
The value of report_type determines which report is displayed, as described in the following table:
| loop |
Produces the Loop Report which gives information on
optimizations performed on loops and calls.
+Oreport is equivalent to +Oreport=loop.
|
| private |
Produces the loop report and privatization table, which provide information
on loop variables that are privatized by the compiler.
|
| all |
Produces all reports.
|
The +Onoreport option does not accept any of the report_type values and turns off all
reporting. The +Oreport[=report_type] option is active only at optimization levels 3 and
above.
The default is +Onoreport.
Note: The +Oinfo option can be use to display additional information on the various
optimizations being performed.
+tls Command-Line Option
+tls=mode
This option specifies whether references to thread local data items are to be performed
according to the mode.
The defined values of mode are:
| static |
This is a more efficient mode in which only thread local data in the program
startup set can be accessed. |
| dynamic |
This is a less efficient mode in which thread local data outside the program
startup set can be accessed as well. This is the default. |
Translation units compiled with different settings of this option may be freely mixed, even
within the same load module.
+wlock Command-Line Option
+wlock
This option enables compile-time diagnostic messages for potential errors in using lock/unlock calls in programs that use pthread library based lock/unlock functions. Warnings are emitted for acquiring an already acquired lock, releasing an already released lock, and unconditionally releasing a lock that has been conditionally acquired.
This diagnostic checking is based on cross-module analysis performed by the compiler.
Therefore, the +wlock option implicitly enables a limited form of cross-module analysis, even if -ipo or +O4 options are not specified. This
can lead to a significant increase in the compile time compared to a
build without the +wlock option. Using this option could result in the
compiler invoking optimizations other than those that are part of the
user-specified optimization level. If +wlock is used in addition to
-ipo or +O4, the generated code is not affected, and the compile time
does not increase much.
NOTE: The +wlock option is only supported on Integrity systems.
|
| Performance Options |
The HP compiler provides a variety of options to help improve build and run-time
performance. These options are:
- -fast - Selects options for optimum execution speed.
- +Ofast - Selects optimization options
for optimum execution speed.
- +Ofaster - Optimizes execution speed
at build time.
- +inline_level [i]num - Controls how
C++ inlining hints influence HP aC++. Also allows implicit inlining of small
functions that are not explicitly tagged with the inline keyword.
- +Ono_return - Hints to the optimizer
that the functions will not return to the calling site.
- +[no]objdebug - Generates debug information
in object files and not in the executable.
- +DSmodel - Performs instruction scheduling
tuned for a particular implementation.
- Optimization Options - Selects the appropriate
options to improve program execution speed.
- +[no]srcpos - Controls the generation of
source position information.
-fast Command-Line Option
-fast
The -fast option selects a combination of optimization options for optimum execution speed
and reasonable build times. See +Ofast for currently chosen options.
This option is a synonym for +Ofast.
+Ofast Command-Line Option
+Ofast
The +Ofast option selects a combination of optimization options for optimum
execution speed and reasonable build times. Currently chosen options are:
- +O2
- +Ofltacc=relaxed
- +Onolimit
- +DSnative
- +FPD
- -Wl,+pi,1M
- -Wl,+pd,1M
- -Wl,+mergeseg
Note: Do not use this option for programs that depend on IEEE standard floating point
denormalized numbers. Otherwise, different numerical results may occur. See +Ofltacc=relaxed.
This option is a synonym for -fast.
+Ofaster Command-Line Option
+Ofaster
This option is equivalent to +Ofast with an increased optimization level. The
definition of +Ofaster may change or it may be deprecated in future releases.
+Ono_return Command-Line Option
+Ono_return=function1 [,function2, ...]
+Ono_return:filename
This option provides a hint to the optimizer that the named functions
never return to the call site. If the +Ono_return:filename form
is used, the file filename contains a list of function names separated
by spaces or newlines. This optimization is available at all optimization levels.
+[no]srcpos Command-Line Option
+[no]srcpos
This option controls the generation of source position information for HP Caliper. The default is +srcpos.
When +srcpos, is in effect, the compiler generates source position information. When
+nosrcpos is in effect, the compiler does not generate this information and the compiler
instructs the linker to discard any of this information found in the object files.
|
| Porting Options |
Use the following options as necessary when
porting your code from other operating environments to HP-UX:
- -fast - Selects options for optimum execution speed.
- +sb - Treats unqualified bitfields as signed.
- +ub - Treats unqualified bitfields as unsigned.
- +uc - Treat an unqualified (plain) char data type as unsigned char.
- +w64bit - Enables warnings that help detection
of potential problems in converting 32-bit applications to 64-bit
- +wendian - Identifies porting issues between big
and little endian.
+sb Command-Line Option
+sb
This option specifies unqualified char, short,
int, long, and long long bit fields as signed.
The default is +sb.
Note: When both +sb and +uc are in effect, +uc will override this for char bit fields.
+ub Command-Line Option
+ub
This option specifies unqualified char, short, int, long,
and long long bit fields as unsigned.
This option has no effect on signedness of enum bitfields or on signedness of non-bitfield char.
The default is +sb.
+uc Command-Line Option
+uc
By default, all unqualified char data types are treated as
signed char. Specifying +uc
causes an unqualified (plain) char data type to be treated as unsigned char. (Overloading and
mangling are unchanged.)
Use this option to help in porting applications from environments where an unqualified
(plain) char type is treated as unsigned char.
Note: Since all unqualified char types in the compilation unit will be affected by this
option (including those headers that define external and system interfaces), it is
necessary to compile the interfaces used in a single program uniformly.
+wendian Command-Line Option
+wendian
This option allows the user to identify areas in their source that might have porting issues when going between little-endian and big-endian.
+wendian will warn of a de-reference which could cause endian
dependent behavior:
char charVal = *(char *) int_ptr;
short shortVal = ((short *) long_ptr)[0];
this warning can be suppressed by adding extra cast:
char charVal = *(char *) (void *)int_ptr; // OK
It warns that the initialization which may be endian dependent,
such as using hex constants to init byte arrays:
char a[4] = { 0x11, 0x22, 0x33, 0x44 };
char b[4] = { 'a', 'b', 'c', 'd'}; // OK
this warning can be suppressed by not using a hex/octal constant:
char a[4] = { 17, 0x22, 0x33, 0x44 }; // OK
It also warns of unions which make assumptions about data layout:
union u1 {
char c[4];
int v;
};
union u2 {
long long ll;
short s[4];
char c[8];
};
this warning can be suppressed by adding a dummy member:
union u1 { // OK
char c[4];
int v;
char dummy;
};
Another type of warning is on the use of IO functions read/write
persistent data from files which may be endian dependent:
read(0, &i, sizeof(i));
fread(&ai[0], sizeof(int), elems_of(ai, int), stdin);
write(1, &i, sizeof(i));
fwrite(&ai[0], sizeof(int), elems_of(ai, int), stdout);
this warning can be suppressed by adding extra cast:
fread((char*)(void*)ai, sizeof(char), 1, stdin); // OK
|
| Preprocessor Options |
The following options are accepted by the preprocessor:
- -C - Prevents the preprocessor from stripping comments.
- -dM - Lists preprocessor-encountered #define directives.
- -Dname - Defines name to the preprocessor
- -E - Runs only the preprocessor and sends output to stdout
- -H - Dumps the include file hierarchy to stderr.
- +m[d] and +make[d] - Output quote enclosed
(" ") make dependency files to stdout or to a .d file
- +M[d] and +Make[d] - Output both quote enclosed and
angle bracket enclosed (< >) make dependency files to
stdout or to a .d file
- -P - Runs only the preprocessor and
sends output to a corresponding .i file
- -.suffix - Sends preprocessed output
to the corresponding output file ending with .suffix
- -Uname - Undefines name in the preprocessor
-C Command-Line Option
-C
Using this option prevents the preprocessor from stripping comments.
-dM Command-Line Option
-dM
When -dM is present, instead of normal preprocessor output the
compiler lists the #define directives it encounters as it preprocesses the file, thus providing a list of all macros that are in effect at the start of the compilation. The -dM option requires that -P or -E also be specified.
A common use of this option is to determine the compiler's predefined macros. For example:
touch foo.c ; cc -E -dM foo.c
-Dname Command-Line Option
-Dname[=def]
name is the symbol name that is defined for the preprocessor. def is
the definition of the symbol name (name).
This option defines a symbol name (name) to the preprocessor, as if defined by the
preprocessing directive #define.
If no definition (def) is given, the name is defined as 1.
Note:
__ia64 and __HP_aCC are defined automatically for
aCC and __HP_cc for cc/c89/c99 or aCC with -Ae.
The following is the list of default -D flags:
-
-AP:
- -D__hpux
- -D__ia64=1
- -D_BIG_ENDIAN=1
- -D__STDCPP__
- -D__HP_aCC=version-string
-
-AA:
- Same as -AP, and also defines -D_HP_NAMESPACE_STD
-
aCC -Ae:
- -D__hpux
- -D__unix
- -D__ia64=1
- -D_BIG_ENDIAN=1
Example:
aCC -DDEBUGFLAG file.C
This example defines the preprocessor symbol DEBUGFLAG and gives it the value 1. Following
is a program that uses this symbol:
#include <iostream.h>
void main(){
int i, j;
#ifdef DEBUGFLAG
int call_count=0;
#endif
...
}
-E Command-Line Option
-E
Using this option runs only the preprocessor on the named C++ files and sends the result to
standard output (stdout).
An exception to this rule when -E is used with either the +m[d], +M[d], +Make[d], or +make[d] option,
only make dependency information is output. Unlike the -P option, the output of -E
contains #line entries indicating the original file and line numbers.
Redirecting Output From This Option:
Use the -.suffix option to redirect the output of this option.
+m[d] and +make[d] Command-Line Options
+m[d]
+make[d]
This option directs a list of the quote enclosed (" ") header
files upon which your source code
depends to stdout. The list is in a format accepted by the make command.
If +md is specified, the list is directed to a .d file.
The .d file name prefix is the same as that of
the object file. The .d file is created in the same directory as the object file.
Use +m[d] when you also specify the -E or the -P option.
When used with the -E option, only
dependency information is generated.
The following table lists examples of the +m[d] option.
| command line specified |
.d file name |
.d file location |
preprocessing output |
|
aCC -c +m a.C
|
none
|
stdout
|
none
|
|
aCC -c -E -.i +md a.C
|
a.d
|
current directory
|
none
|
|
aCC -c -P +md a.C -o b.o
|
b.d
|
current directory
|
a.i
|
|
aCC -c -P +md a.C -o /tmp/c
|
c.d
|
/tmp directory
|
a.i
|
+M[d] and +Make[d] Command-Line Options
+M[d]
+Make[d]
This option directs a list of both the quote enclosed (" ") and angle bracket enclosed (< >)
header files upon which your source code depends to stdout. The list is in a format accepted
by the make command.
If +Md is specified, the list is directed to a .d file. The .d file name prefix is the same as that of
the object file. The .d file is created in the same directory as the object file.
Use +Md when you also specify the -E or the -P option. When used with the -E option, only
dependency information is generated.
The following table lists examples of the +M[d] option.
| command line specified |
.d file name |
.d file location |
preprocessing output |
|
aCC -c +M a.C
|
none
|
stdout
|
none
|
|
aCC -c -E -.i +Md a.C
|
a.d
|
current directory
|
none
|
|
aCC -c -P +Md a.C -o b.o
|
b.d
|
current directory
|
a.i
|
|
aCC -c -P +Md a.C -o /tmp/c
|
c.d
|
/tmp directory
|
a.i
|
-P Command-Line Option
-P
Using this option only preprocesses the files named on the command line without invoking
further phases. It leaves the result in corresponding files with the suffix .i.
For example, the following command preprocesses the file prog.C leaving the output in the
file prog.i. It does not compile the program.
aCC -P prog.C
-Uname Command-Line Option
-Uname
name is the symbol name whose definition is removed from the preprocessor. This option
undefines any name that has initially been defined by the preprocessing stage of compilation.
A name can be a definition set by the compiler. This is displayed when you specify the -v
option. A name can also be a definition you have specified with the -D option on the command
line.
The -D option has lower precedence than the -U option. If the same name is used in both, the
-U option and the -D option, the name is undefined regardless of the order of the options on the
command line.
|
| Profiling Code Options |
HP compilers provide the following options for profiling your code:
- -G - Compile-time and link-time option to support gprof.
- -p - Compile-time and link-time option to support prof.
- +profilebucketsize - Link-time option to support prof and gprof.
Note:
-G Command-Line Option
-G
At compile time, -G produces code that counts the number of times each arc in the call graph
is traversed. At link time, when you are building an executable (but not a shared library) -G
picks up profiled versions of certain system libraries and picks up the gprof support library.
Example:
aCC -G file.C
The above example compiles file.C and creates the executable file a.out instrumented for
use with gprof.
-p Command-Line Option
-p
At compile time, -p produces code that counts the number of times each routine is called. At
link time, when you are building an executable (but not a shared library) -p picks up profiled
versions of certain system libraries and picks up the prof support library.
Example:
aCC -p file.C
The above example compiles file.C and creates the executable file a.out instrumented for
use with prof.
+profilebucketsize Command-Line Option
+profilebucketsize=[16|32]
This is a link-time option to support prof and gprof when building an executable, but not a
shared library. When prof or gprof startup code invokes sprofil, this option specifies the
size in bits of the counters used to record sampled values of the program counter.
The effect of this option can be overridden by setting the environment variable
LD_PROFILEBUCKET_SIZE when running the instrumented program. This environment
variable has no effect when building the instrumented program. Legal values are 16 (the
default), and 32.
|
| Standards Related Options |
The following options related to the ANSI/ISO 9899-1990 Standard for the C Programming
Language and ANSI/ISO International Standard and ISO/IEC 14882 Standard for the C++
programming Language are accepted by the compiler:
- -Aa - Enables the use of standard options
(-Wc, -koenig_lookup,on and -Wc,-ansi_for_scope,on).
- -AA - Enables Rogue Wave Standard C++ Library 2.2.1
and set all standards related options on.
- -Aarm - Enables the Tru64 UNIX C++ Annotated Reference
Manual (ARM) dialect
- -AC89 - Enables ANSI C89 compilation mode
- -AC99 - Enables ANSI C99 compilation mode
- -Ae - Enables ANSI C C89 mode
- -Ag++ - Enables GNU C++ dialect compatibility
- -Agcc - Enables GNU C dialect compatibility
- -AOa and -AOe - Conforms to the ANSI C standard
- -AP - Turns off -AA mode and uses the older C++ runtime libraries
- +legacy_cpp - Selects the old HP C preprocessor
- +strict - Strict ANSI standard without extensions
- +tru64 - causes return types of unprototyped functions to be treated as long, instead of int, matching Tru64 C behavior
- -Wc,-ansi_for_scope,[on|off] - Enable or disable the scoping rules for init-declarations in for statements
- -Wc --guiding_decls - Enables recognition of guiding declarations of template functions
- -Wc,-koenig_lookup,[on|off] - Enable or disable argument-dependent lookup rules (also known as Koenig lookup)
-Aa Command-Line Option
-Aa
This option instructs the compiler to use Koenig lookup and strict ANSI for scope rules. This
option is equivalent to specifying -Wc,-koenig_lookup,on and -Wc,-ansi_for_scope,on.
The default is off. Refer to -Ae option for C-mode description. The standard features
enabled by -Aa are incompatible with earlier C and C++ features.
-AA Command-Line Option
-AA
This option enables use of the 2.0 Standard C++ Library, which
includes the new standard conforming (templatized) iostream library. It conforms to the ISO C++ standard. The default is -AA without
-Wc,-ansi_for_scope.
Usage:
The standard features enabled by -AA are incompatible with the older Rogue Wave Standard
C++ Library 1.2.1 and Tools.h++ 7.0.6. All modules must be consistent in using -AA. Mixing
modules compiled with -AA with ones that are not is not supported.
The -Wc,-koenig_lookup,on and -Wc,-ansi_for_scope,on options are also set.
See Choice of the C++ Runtime (-AA vs -AP) on HP-UX for more information on usage of -AA.
-Aarm Command-Line Option
-Aarm
This option enables the Tru64 UNIX C++ Annotated Reference Manual (ARM)
dialect. This dialect was the default for Tru64 UNIX C++ compilers
through compiler version 5.x. Support of this dialect is intended only
to ease porting of existing Tru64 UNIX applications to HP-UX, and not
for development of new programs.
For more information on the ARM dialect, see The Annotated C++
Reference Manual, 1991, by Ellis and Stroustrup.
-AC89 Command-Line Option
-AC89
This option invokes the compiler in ANSI C89 compilation mode. This option, when specified
with -ext option, invokes a part of ANSI C99 features.
-AC99 Command-Line Option
-AC99
This option invokes the compiler in ANSI C99 compilation mode with its features.
-Ae Command-Line Option
-Ae
Setting the -Ae option invokes aC++ as an ANSI C compiler, with additional support for HP C
language extensions.
This option is a synonym for the -AC89 -ext option.
For C++, if -Ae is anywhere on the command line,
C-mode will be in effect. The options, -AA
and -AP, are ignored with warnings.
If both -Ae and -Aa are present, C-mode will be
in effect and the right most option determines whether extended ANSI (-Ae) or strict ANSI
(-Aa) is in effect. So, to get strict ANSI, both
-Ae and -Aa option are required.
Note:
Some code that is a warning in C may be a fatal error in aC++.
-Ag++ Command-Line Option
-Ag++
This option enables GNU C++ dialect compatibility. Not all GNU features
are available, for instance, the asm mechanism. See also -fshort-enums.
-Agcc Command-Line Option
-Agcc
This option enables GNU C dialect compatibility. Not all GNU features
are available, for instance, the asm mechanism. See also -fshort-enums.
-AOa and -AOe Command-Line Options
-AOa
-AOe
See the corresponding C mode options: -Aa or -Ae option.
In addition to specifying the ANSI C language dialect, allows the optimizer to aggressively
exploit the assumption that the source code conforms to the ANSI programming language C
standard ISO 9899:1990.
At present, the effect is to make +Otype_safety=ansi the default. As new
independently-controllable optimizations are developed that depend on the ANSI C standard,
the flags that enable those optimizations may also become the default under -AOa or -AOe.
-AP Command-Line Option
-AP
This option turns off -AA mode and uses the older C++ runtime libraries.
See Choice of the C++ Runtime (-AA vs -AP) on HP-UX for more information on usage of -AP.
+legacy_cpp Command-Line Option
+legacy_cpp
This option enables the use of the HP-UX 11.20 ANSI C preprocessor.
Note:This option is not ordinarily needed.
+strict Command-Line Option
+strict
This option specifies strict ANSI without extensions. It is only
available in the aCC version 6 (C++6) compiler. It is incompatible
with the -ext/+e language extension options.
+tru64 Command-Line Option
This option causes return types of unprototyped functions to be treated
as long, instead of int, matching Tru64 C behavior.
This can prevent segfaults resulting from pointer truncation in +DD64 mode.
Example:
long * a;
long sub() {
a = malloc(sizeof(long)); /* no prototype! */
*a = 1234; /* segfault if +DD64 and no +tru64 */
return *a;
}
A preferable solution is to provide the appropriate function
prototypes.
Note: This option is applicable to C language only.
-Wc,-ansi_for_scope Command-Line Option
-Wc,-ansi_for_scope,[on|off]
This option enables or disables the standard scoping rules for init-declarations in for
statements; the scope of the declaration then ends with the scope of the loop body. By default,
the option is disabled.
Examples:
- In the following example, if the option is not enabled (the current default), the scope of k
extends to the end of the body of main() and statement (1) is valid (and will return zero). With
the option enabled, k is no longer in scope and (1) is an error.
#include <stdio.h>
int main() {
for (int k = 0; k!=100; ++k) {
printf("%d\n", k);
}
return 100-k; // (1)
}
-
In the following example, with the option disabled, the code is illegal, because it redefines k in (2)
when a previous definition (1) is considered to have occurred in the same scope.
With the option enabled (-Wc,-ansi_for_scope,on), the definition in (1) is no longer in scope
at (2) and thus the definition in (2) is legal.
int main() {
int sum = 0;
for (int k = 0; k!=100; ++k) // (1)
sum += k;
for (int k = 100; k!= 0; ++k) // (2)
sum += k;
}
-Wc,--guiding_decls Command-Line Option
-WC,--guiding_decls
This option enables recognition of “guiding declarations” of template functions. A guiding
declaration is a function declaration that matches an instance of a function template but has no
explicit declaration since its definition derives from the function template itself.
For example:
template <class T> void f(T) { ... }
void f(int);
main () {
f(10);
}
Using -WC,--guiding_decls, f<int>(int) will be called.
Otherwise a non-templated function,
f(int), will be called (and a linker unsat is generated if it is not present).
-Wc,-koenig_lookup,[on|off]
Command-Line Option
-Wc,-koenig_lookup,[on|off]
This option enables or disables standard argument-dependent lookup rules (also known as
Koenig lookup). It causes functions to be looked up in the namespaces and classes associated
with the types of the function-call argument. By default, the option is enabled.
Example:
In the following example, if the option is not enabled, the call in main() does not consider
declaration (1) and selects (2).With the option enabled, both declarations are seen, and in this
case overload resolution will select (1).
namespace N {
struct S {};
void f(S const&, int); // (1)
}
void f(N::S const&, long); // (2)
int main() {
N::S x;
f(x, 1);
}
|
| Subprocesses of the Compiler |
The following options allow you to substitute your own processes in
place of the default HP aC++ subprocesses, or pass options
to HP aC++ subprocesses:
- -tx,name - Substitutes name in place of subprocess x.
- -Wx,args - Passes the option arg to subprocess x of the HP aC++ compiling system.
-tx,name Command-Line Option
-tx,name
This option substitutes or inserts subprocess x, using name.
The parameter, x, is one or more identifiers indicating the subprocess or subprocesses. The
value of x can one or more of the following:
| a |
Assembler (standard suffix is as). |
| c |
Compiler (standard suffix is ecom). |
| C |
See c. |
| f |
Filter tool (standard suffix is c++filt). |
| l |
Linker (standard suffix is ld). |
| p |
Preprocessor (standard suffix is cpp.ansi).
-tp must be used before any -Wp options can be
passed to cpp.ansi. To enable the external
preprocessor, use: -tp,/opt/langtools/lbin/cpp.ansi.
|
| u |
Stand-alone code generator (standard suffix is u2comp). |
| x |
All subprocesses. |
The -tx,name option works in two modes:
- If x is a single identifier, name represents the full path name of the new subprocess.
- If x is a set of identifiers, name represents a prefix to which the standard suffixes are concatenated to construct the full path names of the new subprocesses.
For example, the following command invokes the assembler /users/sjs/myasmb instead of
the default assembler /usr/ccs/bin/as to assemble and link file.s.
aCC -ta,/users/sjs/myasmb file.s
More Examples:
Following are some examples of -t option:
- Substituting for c++filt:
The following example compiles file.C and specifies that /new/bin/c++filt should be
used rather than the default /opt/aCC/bin/c++filt.
aCC -tf,/new/bin/c++filt file.C
- Substituting for ecom:
The following example compiles file.C and specifies that /users/proj/ecom should be
used instead of the default /opt/aCC/lbin/ecom.
aCC -tC,/users/proj/ecom file.C
- Substituting for all Subprocesses:
The following example compiles file.C and specifies that the characters /new/aCC
should be used as a prefix to all the subprocesses of HP aC++ For example,
/new/aCC/ecom runs rather than the default /opt/aCC/lbin/ecom.
aCC -tx,/new/aCC file.C
-Wx,args Command-Line Option
-Wx,arg1[,arg2,..,argn]
This option passes the arguments arg1 through argn to the subprocess x of the compilation.
Each argument, arg1, arg2, through argn takes the form:
-argoption[,argvalue]
where:
- argoption is the name of an option recognized by the subprocess.
- argvalue is a separate argument to argoption, where necessary.
The parameter, x, is one or more identifiers indicating a subprocess or subprocesses. The
value of x can be one or more of the following:
| a |
Assembler (standard suffix is as). |
| c |
Compiler (standard suffix is ecom). |
| C |
See c. |
| f |
Filter tool (standard suffix is c++filt). |
| l |
Linker (standard suffix is ld). |
| p |
Preprocessor (standard suffix is cpp.ansi).
-tp must be used before any -Wp options can be
passed to cpp.ansi. To enable the external
preprocessor, use: -tp,/opt/langtools/lbin/cpp.ansi.
|
| x |
All subprocesses. |
The following example compiles file.C and passes the option -v to the linker.
aCC -Wl,-v file.C
Passing Options to the Linker with -W
The following example links file.o and passes the option -a archive to the linker, indicating
that the archive version of the math library (indicated by -lm) and all other driver supplied
libraries should be used rather than the default shared library.
aCC file.o -Wl,-a,archive -lm
Passing Multiple Options to the Linker with -W
The following example links file.o and passes the options -a, archive, -m, and -v to the
linker.
aCC -Wl,-a,archive,-m,-v file.o -lm
This case is similar to the previous example, with additional options. -m indicates that a load
map should be produced. The -v option requests verbose messages from the linker.
|
| Symbol Binding Options |
The following -B options are recognized by the compiler to specify whether references to global symbols may be resolved to symbols defined in the current load module, or whether
they must be assumed to be potentially resolved to symbols defined in another load module:
- -Bdefault - Symbols are assigned the default export class.
- -Bextern - Inlining of import stubs for calls to default export class symbols.
- -Bhidden - Symbols are assigned the hidden export class.
- -Bhidden_def - Locally defined (non-tentative) symbols, without __declspec(dllexport), are assigned the hidden export class.
- -Bprotected - Symbols are assigned the protected export class.
- -Bprotected_data - Assigns only data symbols the protected export class.
- -Bprotected_def - Symbols, locally defined are assigned the protected export class.
- -Bsymbolic - All symbols assigned the protected export class.
A global symbol is one that is visible by name across translation unit boundaries. A static
symbol is one that is visible by name only within a single translation unit but is not
associated with a particular procedure activation. A locally defined symbol is a global or static
symbol with a definition in the translation unit from which it is being referenced.
-B options can be overridden by subsequent -B options on the command line, and any binding pragmas in the source.
-Bdefault Command-Line Option
-Bdefault
Global symbols are assigned the default export class. These symbols may be imported or
exported outside of the current load module. The compiler accesses tentative and undefined
symbols through the linkage table. Any symbol that is not assigned to another export class
through use of another -B option (or the deprecated +O[no]extern option) will have the
default export class. The -Bdefault option may also be used on a per symbol basis to specify
exceptions to global -Bprotected, -Bhidden, and -Bextern options.
Usage:
-Bdefault=symbol[,symbol...]
The named symbols are assigned the default export class.
-Bdefault:filename
The file, filename, contains a list of symbols, separated by spaces or newlines.
These symbols are assigned the default export class.
-Bextern Command-Line Option
-Bextern
The specified symbols, or all undefined symbols if no list is provided, are assigned to default
export class. Additionally, the compiler will inline the import stub for calls to these symbols.
No compile time binding of these symbols will be done. All references to these symbols will be
through the linkage table, so an unnecessary performance penalty will occur if -Bextern is
applied to a listed symbol that is resolved in the same load module.
Usage:
-Bextern=symbol[,symbol...]
The named symbols, or all symbols if no list is provided, are assigned the default export class.
Use of list form overrides the default binding of locally defined symbols.
-Bextern:filename
The file, filename, is expected to contain a list of symbols, separated by spaces or
newlines. These symbols are assigned the default export class.
-Bhidden Command-Line Option
-Bhidden
The specified symbols, or all symbols if no symbols are specified, are assigned the hidden export class. The hidden export class is similar to the protected export class. In addition, hidden symbols will not be exported outside the current load module. The linker may eliminate them from a shared library, but in an executable, they remain accessible to the debugger unless +Oprocelim is also specified.
When used with no symbol list, -Bhidden implies -Wl,-aarchive_shared, causing the linker
to prefer an archive library over a shared library if one is available. This can be overridden by
following the -Bhidden option with a subsequent -Wl,-a option.
Usage:
-Bhidden=symbol[,symbol...]
The named symbols, or all symbols if no symbols are specified, are assigned the hidden export
class.
-Bhidden:filename
The file, filename, is expected to contain a list of symbols, separated by spaces or
newlines. These symbols are assigned the hidden export class.
-Bhidden_def Command-Line Option
-Bhidden_def
This option is the same as -Bhidden but only locally defined
(non-tentative) symbols, without __declspec(dllexport), are assigned the hidden export class.
-Bprotected Command-Line Option
-Bprotected[=symbol[,symbol...]]
The specified symbols, or all symbols if no symbols are specified, are assigned the protected
export class. That means these symbols will not be preempted by symbols from other load
modules, so the compiler may bypass the linkage table for both code and data references and
bind them to locally defined code and data symbols.
When used with no symbol list, -Bprotected implies -Wl,-aarchive_shared, causing the
linker to prefer an archive library over a shared library, if one is available. This can be
overridden by following the -Bprotected option with a subsequent -Wl,-a option.
Usage:
-Bprotected:filename
The file, filename, contains a list of symbols, separated by spaces or newlines.
These symbols are assigned the protected export class.
-Bprotected_data Command-Line Option
-Bprotected_data
This option marks only data symbols as having the protected export class.
-Bprotected_def Command-Line Option
-Bprotected_def
This option is the same as -Bprotected but only locally defined (non-tentative) symbols are
assigned the protected export class.
-Bsymbolic Command-Line Option
-Bsymbolic
All symbols are assigned the protected export class. This is equivalent to -Bprotected with no
symbol list.
|
| Template Options |
By using a template option on the aCC command line, you can:
- Close a library or set of link units, to satisfy all unsatisfied
instantiations without creating duplicate instantiations.
- Specify what templates to instantiate for a given translation unit.
- Name and use template files in the same way as for the cfront based HP C++ compiler.
- Request verbose information about template processing.
Note:
All template options on an aCC command line apply to every file on the
command line. If you specify more than one incompatible option on a command
line, only the last option takes effect.
Options:
+inst_compiletime Command-Line Option
+inst_compiletime
This option causes the compiler to use the compile time (CTTI) instantiation mechanism to
instantiate templates. This occurs for every template used or explicitly instantiated in this
translation unit and for which a definition exists in the translation unit. This is the default.
Note:
This option is supported in C++ only but silently ignored in C-mode.
+inst_directed Command-Line Option
+inst_directed
This option indicates to the compiler that no templates are to be instantiated (except explicit
instantiations). If you are using only explicit instantiation, specify +inst_directed.
The following example compiles file.C with the resulting object file containing no template
instantiations, except for any explicit instantiations coded in your source file.
aCC +inst_directed prog.C
Note:
This option is supported in C++ only but silently ignored in C-mode.
+inst_implicit_include Command-Line Option
+inst_implicit_include
This option specifies that the compiler use a process similar to that of the cfront source rule
for locating template definition files. For the cfront based HP C++ compiler, if you are using
default instantiation (that is, if you are not using a map file), you must have a template
definition file for each template declaration file, and these must have the same file name
prefix.
This restriction does not apply in HP aC++. Therefore, if your code was written for HP C++
and you wish to follow this rule when compiling with HP aC++, you need to specify the
+inst_implicit_include option.
This option is strongly discouraged and the sources should be modified to conform to the
standard.
Example:
aCC +inst_implicit_include prog.C
If prog.C includes a template declaration file named template.h, the compiler assumes a
template definition file name determined by the +inst_include_suffixes option.
Note: This option is supported in C++ only but silently ignored in C-mode.
+inst_include_suffixes Command-Line Option
+inst_include_suffixes "list"
list is a set of space separated file extensions or suffixes, enclosed in quotes, that template
definition files can have.
This option specifies which file name extensions the compiler uses to locate template
definition files. This option must be used with the +inst_implicit_include option.
The default extensions in order of precedence are:
- .c
- .C
- .cxx
- .CXX
- .cc
- .CC
- .cpp
User specified extensions must begin with a dot and must not exceed four characters in total.
Any extension that does not follow these rules causes a warning and is ignored.
These restrictions do not apply in HP aC++. Therefore, if your code was written for HP C++
and you wish to follow the cfront-based HP C++ template definition file naming conventions
when compiling with HP aC++, you need to specify the +inst_include_suffixes option.
The following example specifies that template definition files can have extensions of .c or .C.
+inst_include_suffixes ".c .C"
The +inst_include_suffixes option is equivalent to the HP C++ -ptS option.
Note: This option is supported in C++ only but silently ignored in C-mode.
+[no]dep_name Command Line Option
+[no]dep_name causes strict dependent name lookup rules to be used in templates.
The default is +nodep_name.
|
| Verbose Compile and Link Information |
Use the following options to obtain additional information about:
- What HP compilers do while compiling or linking your program.
- Which subprocesses would execute for a given command line, without running the compiler.
- The current compiler and linker version numbers.
- Execution time.
Options:
- +dryrun - Requests compiler
subprocess information without running the subprocesses.
- +O[no]info - Requests optimization information.
- +wsecurity - Sets veboseness of security messages.
- +time - Requests execution times.
- -v - Requests verbose information of the compilation process.
- -V - Requests the current compiler and linker version numbers.
+dryrun Command-Line Option
+dryrun
This option generates subprocess information for a given command line without running the
subprocesses. It is useful in the development process to obtain command lines of compiler
subprocesses in order to run the commands manually or to use them with other tools.
Example:
aCC +dryrun app.C
This command line gives the same kind of information as the -v option but without running
the subprocesses.
+O[no]info Command-Line Option
+O[no]info
This option displays informational messages about the optimization process. This option may be helpful in understanding what optimizations are occurring. You can use the option at levels 0-4. The default is +Onoinfo at levels 0-4.
+time Command-Line Option
+time
This option generates timing information for compiler subprocesses. For each subprocess,
estimated time is generated in seconds for user processes, system calls, and total processing
time. This option is useful in the development process, for example, when tuning an
application’s compile-time performance.
Examples:
/opt/aCC/lbin/ctcom -inst compiletime -diags 523 -D __hppa -D __hpux
-D __unix -D __hp9000s800 -D __STDCPP__ -D __hp9000s700 -D _PA_RISC1_1
-I /opt/aCC/include -I /opt/aCC/include/iostream -I /usr -I
/usr/include -I /usr/include -inline_power 0 app.C
file name: app.C
file size: app.o 444 + 16 + 1 = 461
process user sys real
------------------------------------------
process: compiler 0.93 0.13 1.17
------------------------------------------
line numbers: app.C 7
lines/minute: app.C 396
LPATH=/usr/lib:/usr/lib/hpux32/pa1.1 :/usr/lib:/opt/langtools/lib:/usr/lib
/opt/aCC/lbin/ld -o a.out /opt/aCC/lib/crt0.o -u ___exit -u main
-L /opt/aCC/lib /opt/aCC/lib/cpprt0.o app.o -lstd -lstream -lCsup -lm
/usr/lib/hpux32/libcl.a -lc /usr/lib/hpux32/libdld.so >/usr/tmp/AAAa28149 2>&1
file size: a.out 42475 + 1676 + 152 = 44303
process user sys real
------------------------------------------
process: ld 0.35 0.24 0.82
------------------------------------------
total link time(user+sys): 0.59
removing /usr/tmp/AAAa28149
removing app.o
-v Command-Line Option
-v
This option enables verbose mode, sending a step-by-step description of the compilation
process to stderr. This option is especially useful for debugging or for learning the
appropriate commands for processing a C++ file.
Example:
The following command compiles file.C and gives extra information about the process of compiling.
aCC -v file.C
/opt/aCC/lbin/ctcom -inst compiletime -diags 523 -D __hppa -D __hpux
-D __unix -D __hp9000s800 -D __STDCPP__ -D __hp9000s700 -D _PA_RISC1_1
-I /opt/aCC/include -I /opt/aCC/include/iostream -I /usr -I /usr/include
-I /usr/include -inline_power 0 app.C
LPATH=/usr/lib:/usr/lib/hpux32/pa1.1
:/usr/lib:/opt/langtools/lib:/usr/lib
/opt/aCC/lbin/ld -o a.out /opt/aCC/lib/crt0.o -u ___exit -u main
-L /opt/aCC/lib /opt/aCC/lib/cpprt0.o app.o -lstd -lstream -lCsup
-lm /usr/lib/hpux32/libcl.a -lc /usr/lib/hpux32/libdld.so >/usr/tmp/AAAa28149 2>&1
removing /usr/tmp/AAAa28149
-V Command-Line Option
-V
This option displays the version numbers of the current compiler and linker (if the linker is
executed). Use this option whenever you need to know the current compiler and linker version
numbers.
Example:
aCC -V app.C
|
| Concatenating Options |
You can concatenate some options to the aCC command under
a single prefix. The longest substring that matches an option
is used. Only the last option can take an argument. You can concatenate
option arguments with their options if the resulting string
does not match a longer option.
Examples:
Suppose you want to compile my_file.C using the
options -v and -g1. Below are equivalent command lines you could use:
- aCC my_file.C -v -g1
- aCC my_file.C -vg1
- aCC my_file.C -vg1
- aCC -vg1 my_file.C
|