- or a + sign.
Any number of options can be interspersed anywhere in the aCC
command and they are typically separated by blanks.
-mt Command Line Option Syntax |
The new -mt option enables multi-threading capability without the need to set any other flags, such as -l and -D. aC++ examines your environment and automatically selects and sets the appropriate flags. There are four possible sets of flags depending on your operating system and which libstd you use.
Option matrix for -mt:
| |
---------+--------------------------------+
old-lib | -D_REENTRANT |
libstd | -DRW_MULTI_THREAD |
1.2.1 | -DRWSTD_MULTI_THREAD |
(-AP) | -D_THREAD_SAFE |
& | -D_POSIX_C_SOURCE=199506L |
librwtool| -D_HPUX_SOURCE * |
7.0.x | -lpthread |
---------+--------------------------------|
new-lib | -D_REENTRANT |
(-AA) | -D_RW_MULTI_THREAD |
| -D_RWSTD_MULTI_THREAD |
libstd | -D_POSIX_C_SOURCE=199506L |
2.2.1 | -D_HPUX_SOURCE * |
| -lpthread |
---------+--------------------------------+
* required if -D_POSIX_C_SOURCE used
Macros used to compile multi-thread source code:
+O[no]autopar Command Line Option Syntax |
+O[no]autopar
+Oparallel
option, +Oautopar
causes the compiler to parallelize loops that are safe to parallelize.
When used with +Oparallel, +Onoautopar causes
the compiler not to parallelize any loops.
A loop is safe to parallelize if it has an iteration count that can be determined at runtime before loop invocation; it must contain no loop-carried dependences, procedure calls, or I/O operations. A loop-carried dependence exists when one iteration of a loop assigns a value to an address that is referenced or assigned on another iteration.
+Oautopar is the default for all optimization levels but is useful only at levels 3 and 4.
+O[no]dynsel Command Line Option Syntax |
+O[no]dynsel
+Oparallel,
the +Odynsel option
enables workload-based dynamic selection of parallelizable loops.
+Odynsel causes the compiler to generate either a
parallel or a serial version of the loop.
The loop's workload is compared to parallelization overhead,
and the parallel version is run only if it is profitable to do so.
The +Onodynsel option disables dynamic selection
and tells the compiler that it is profitable
to parallelize all parallelizable loops.
If a loop's iteration count is known at compile time, this optimization is performed at compile time. If a loop's iteration count is not known until runtime, the optimization is performed at runtime.
The default is +Odynsel if +Oparallel is enabled
at optimization level(s) 3 and 4.
+O[no]loop_block Command Line Option Syntax |
+O[no]loop_block
+O[no]loop_block option enables [disables] blocking
of eligible loops for improved cache performance.
The default is +Onoloop_block at optimization level(s) 3 and 4.
+O[no]loop_unroll_jam Command Line Option Syntax |
+O[no]loop_unroll_jam
+O[no]loop_unroll_jam option enables [disables]
loop unrolling and jamming.
Loop unrolling and jamming increase register exploitation.
The default is +Onoloop_unroll_jam
at optimization level(s) 3 and 4.
+O[no]report[=report_type] Command Line Option Syntax |
+O[no]report[=report_type]
This option causes the compiler to display various optimization reports. The value of report_type determines which report is displayed, as described below:
+Oreport=loop produces the Loop Report which gives
information on optimizations performed on loops and calls.
+Oreport (without = report_type) also
produces the Loop Report.
+Oreport=private produces the Loop Report and the
Privatization Table, which provides information on loop
variables that are privatized by the compiler.
+Oreport=all produces all reports.
The +Onoreport option does not accept any of
the report_type values.
The +Oreport[=report_type] option is active only
at optimization levels 3 and above.
The default is +Onoreport.
-c Command Line Option Syntax |
-c
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.
aCC -c sub.C prog.C
Compiles sub.C and prog.C and puts the relocatable object code in the
files sub.o and prog.o, respectively.
+DDdata_model Command Line Option Syntax |
+DDdata_modeldata_model can be one of the following:
| ILP32 Data Model | LP64 Data Model |
|---|---|
| The size of an int, long, or pointer data type is 32-bits. | 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 _ILP32 is defined. |
The preprocessor predefined macro,
__LP64__
is defined. Also __LP64__ and _LP64.
|
aCC +DD64 app.CThe following example generates code for the 32-bit data model.
aCC app.C
+DSmodel Command Line Option Syntax |
+DSmodelmodel can be either of four values. The default is blended.
Object code with scheduling tuned for a particular model will execute on other HP 9000 systems, although possibly less efficiently.
When you use the +DS option depends on your particular circumstances.
+DS option. The compiler
generates code tuned for your system.
+DSmodel with either the model number of the target system or
the processor name of the target system.
-S Command Line Option Syntax |
-S
.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).
aCC -S prog.C
Compiles prog.C to assembly code rather than to object code, and puts the
assembly code in the file prog.s.
The following -B options are recognized by aCC 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.
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.
-Bdefault Command Line Option Syntax |
-Bdefault
-Bdefault=symbol[,symbol...]
The named symbols are assigned the default export class.
-Bdefault:filename
The file indicated by filename contains a list of symbols, separated by spaces or newlines. These symbols are assigned the default export class.
-Bextern Command Line Option Syntax |
-Bextern
-Bextern=symbol[,symbol...]
The named symbols, or all symbols if no list is provided, are assigned the default export class.
-Bextern:filename
The file indicated by 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 Syntax |
-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. 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. 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.
-Bhidden=symbol[,symbol...] The named symbols, or all symbols if no symbols are specified, are assigned the hidden export class.
-Bhidden:filename
The file indicated by filename is expected to contain a list of symbols, separated by spaces or newlines. These symbols are assigned the hidden export class.
-Bprotected Command Line Option Syntax |
-Bprotected
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, -Bhidden implies -Wl,-archive_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.
-Bprotected_data
Marks only data symbols as having the protected export class.
-Bprotected_def
Same as -Bprotected but only locally defined (non-tentative) symbols are assigned the protected export class.
-Bprotected:filename
The file indicated by filename is expected to contain a list of symbols, separated by spaces or newlines. These symbols are assigned the protected export class.
-Bprotected=symbol[,symbol...] The named symbols, or all symbols if no symbols are specified, are assigned the protected export class.
-Bsymbolic Command Line Option Syntax |
-Bsymbolic
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 aC++ 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.
The following table lists the sizes and alignments of HP aC++ 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 | 80 in floating register. 128 in memory. |
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-, or 8-byte |
| union | *** | 1-, 2-, 4-, or 8-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.
+d Command Line Option Syntax |
+d
This option is useful when you are debugging your code because you cannot set breakpoints at inline functions. This option defeats inlining thereby allowing you to set breakpoints at functions specified as inline.
-g Command Line Option Syntax |
-g
-g 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.
-g0 Command Line Option Syntax |
-g0
To suppress expansion of inline functions use the +d option.
-g1 Command Line Option Syntax |
-g1
-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.
-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, on the other hand, 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, with neither the -g, the -g0, nor the -g1 option) 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.
Use -g0 when either of the following is true:
NOTE: If you compile part of an application with -g or -g1 and part with debug off, (that is, with neither the -g, the -g0, nor the -g1 option) 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.
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.
A problem occurs if all functions are inline;
in this case, no debug information is generated.
+[no]objdebug Command Line Option Syntax |
+[no]objdebug
CAUTION: With +objdebug, the object files or archive libraries must not be removed.
+objdebug is the default at link time and at compile time.
If +noobjdebug is used at link time (not the default), 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.
Use +[no]objdebug with the -g, -g0, or -g1 option.
+p Command Line Option Syntax |
+p
Ordinarily, the compiler gives warnings about anachronistic constructs. Using
the +p option, the compiler gives errors for anachronistic constructs.
aCC +p file.CCompiles
file.C and gives errors for all anachronistic constructs rather
than just giving warnings.
-w Command Line Option Syntax |
-w
By default, HP aC++ reports all errors and warnings.
aCC -w file.CCompiles
file.C and reports errors but does not report any warnings.
+w Command Line Option Syntax |
+w
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.CCompiles
file.C and warns about both questionable constructs and
constructs almost certainly problematic.
+W args Command Line Option Syntax |
+W arg1[,arg2,..argn]
aCC +W600 app.C
+We args Command Line Option Syntax |
+We arg1[,arg2,..argn]
aCC +We 600,829 app.C
+noeh Command Line Option Syntax |
+noeh
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.
Code compiled with and without +noeh can be mixed freely.
aCC +noeh progex.CCompiles and links
progex.C, which does not use exception handling.
-ext Command Line Option Syntax |
-ext
-ext, you are enabling the following HP aC++
extensions to the C++ standard:
| HP aC++ Extentions |
|---|
Enable 64-bit integer data type support for:
Use this option to declare 64-bit integer literals and for input and output of 64-bit integers. |
Enable #assert and
#unassert
preprocessor directives allowing
you to set a predicate name or predicate name and token to be tested with a
#if directive.
|
Note, when using -ext, specify it at both compile and link time.
aCC -ext foo.C
Compiles foo.C which contains a long long declaration.
#include <iostream.h>void main(){ long long ll = 1; cout << ll << endl; }
+Ofenvaccess Command Line Option Syntax |
+Ofenvaccess
-fpeval Command Line Option Syntax |
-fpeval=precision
-fpwidetypes Command Line Option Syntax |
-[no]fpwidetypes
+FP Command Line Option Syntax |
+FP[flags]
Specifies how the runtime environment for floating point operations should be initialized at program startup and used at link time. The default is that all trapping behaviors are disabled. The following flags are supported. 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. To dynamically change these settings at run-time, see fesettrapenable(3M).
+O[no]libmerrno Command Line Option Syntax |
+O{no}libmerrno
#include files.
-Idirectory Command Line Option Syntax |
-I directory
directory is the HP-UX directory where HP aC++ looks for header files.
#include files during preprocessing.
During the link phase, 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:
#include.
-I option.
For #include files that are enclosed in angle brackets (< >), the
preprocessor searches in the following order:
-I option.
(The current directory is not searched when angle brackets (< >)
are used with #include.)
aCC -I include file.C
This example directs HP aC++ to search in the directory
include for #include files.
-I- Command Line Option Syntax |
[-Idirs] -I- [-Idirs][-Idirs] indicates an optional list of -Idirectory specifications in which a directory name cannot begin with a hyphen (-) character.
Specifying -I- serves a dual purpose, as follows:
(" ")
file names in a #include directive to the following order:
-I option.
The preprocessor does not search the directory of the including file.
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 succeed the -I- option.
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.
aCC -Idir1 -Idir2 -c a.CWith 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.CCAUTION: 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 -I- command 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.CIf 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 by a.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.
+help Command Line Option Syntax |
+help
If +help is used on any command line, the compiler displays the online programmer's guide with the default web browser and then processes any other arguments.
If $DISPLAY is set, the default web browser is displayed.
If the display variable is not set, a message so indicates.
Set your $DISPLAY variable as follows:
export DISPLAY=YourDisplayAddress (ksh/sh shell notation) setenv DISPLAY YourDisplayAddress (csh shell notation)
export BROWSER=AlternateBrowserLocation
To invoke the online guide:
aCC +help
+inline_level [i]num Command Line Option Syntax |
+inline_level [i]num
This option controls how C++ inlining hints influence HP aC++. Such inlining happens in addition to explicitly inlined functions. By default, this option is off.
Specifying i causes implicit inlining of small functions.
Specify num as 0, 1, 2, or 3. Refer to the tables below.
Note that +d and
+inline_level 0 turn off all
inlining, including implicit inlining.
| num | Meaning |
|---|---|
| 0 | No inlining is done (same effect as the +d option). |
| 1 | Only small functions are inlined. |
| 2 | Only large functions are not inlined. |
| 3 | Inlining hints are respected in all cases, except when the called function is recursive or when it has a variable number of arguments. |
The default level depends on +Oopt as shown in the following table:
| opt | num |
|---|---|
| 0 | 1 |
| 1 | 1 |
| 2 | 2 |
| 3 | 2 |
| 4 | 2 |
NOTE: This option controls functions declared with the inline keyword or within the class declaration and is effective at all optimization levels.
The options +O[no]inline and +Oinlinebudget control the high level optimizer that recognizes other opportunities in the same source file (+O3) or amongst all source files (+O4).
aCC +inline_level3 app.C
-b Command Line Option Syntax |
-b
aCC -b utils.o -o utils.so
Links utils.o
and creates the shared library utils.so.
-dynamic Command Line Option Syntax |
-dynamic
-exec Command Line Option Syntax |
-exec
-lname Command Line Option Syntax |
-lnameThe name parameter forms part of the name of the library the linker searchs when looking for routines called by your program.
/usr/lib/lib/hpux32/name.so
/usr/lib/lib/hpux32/name.a
/opt/langtools/lib/hpux32lib/name.so
/opt/langtools/lib/hpux64lib/name.a
.so) or the archive
library (.a) depends on the value of the
-a linker option or the
-minshared compiler option.
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. For details refer to the description of ld
in the HP-UX Reference Manual or the ld(1) man page if it is installed
on your system. (If you see the message "Man page could not be formatted,"
ensure the man page is installed.)
aCC file.o -lnumeric
This example directs the linker to link file.o and (by default)
search the library /usr/lib/hpux32/libnumeric.so.
-Ldirectory Command Line Option Syntax |
-LdirectoryThe directory parameter is the HP-UX directory where you want the linker to search for libraries your program uses before searching the default directories.
See the -l option for default search path.
The -L option must precede any -lname
option entry on the command line; otherwise -L is ignored.
This option is passed directly to the linker.
aCC -L/project/libs prog.C -lmylib1 -lmylib2
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).
-minshared Command Line Option Syntax |
-minshared
+nostl Command Line Option Syntax |
+nostl
+nostl suppresses linking of all default -Idirectory and -Ldirectory paths and some of the -lname libraries (-lstd and -lstream). Use the -v option to see the effect of +nostl.
CAUTION: Complete understanding of the linking process and the behavior of the actual (third party) libraries linked with the application is essential for avoiding link or run-time failures.
In addition, you can use the -Wl,args compiler option to specify any linker option on the compiler command line. For more information on linker options, see the ld(1) man page or the HP-UX Reference Manual.
CAUTION: You must use the aCC command to link your HP aC++ programs and libraries. This ensures that all libraries and other files needed by the linker are available.
-n Command Line Option Syntax |
-n
ld in the
HP-UX Reference Manual or the ld(1) man page if it is installed
on your system. (If you see the message "Man page could not be formatted,"
ensure the man page is installed.)
-N Command Line Option Syntax |
-N
Unsharable executable files generated with the -N option cannot
be executed with exec.
ld description in the
HP-UX Reference Manual or the ld(1) man page if it is installed
on your system. (If you see the message "Man page could not be formatted,"
ensure the man page is installed.)
-q Command Line Option Syntax |
-q
ld in the
HP-UX Reference Manual or the ld(1) man page if it is installed
on your system. (If you see the message "Man page could not be formatted,"
ensure the man page is installed.)
-Q Command Line Option Syntax |
-Q
-s Command Line Option Syntax |
-s
Specifying this option prevents using a symbolic debugger on the resulting program.
ld in the HP-UX Reference Manual or
the ld(1) man page if it is installed on your system.
(If you see the message "Man page could not be formatted," ensure the man page
is installed.)
-o Command Line Option Syntax |
-o outfile
The outfile parameter is the name of the file containing the
output of the compilation.
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 Syntax |
-.suffixThe 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.
.c file.
aCC -E -.i prog.C
Preprocesses the C++ code in prog.C and puts the resulting code
in the file prog.i.
-Y Command Line Option Syntax |
-Y
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.
hpnls, lang, and environ in the
HP-UX Reference Manual for a description of the NLS model.
-z Command Line Option Syntax |
-z
Fatal errors result if null pointers are dereferenced.
If you attempt to dereference a null pointer, a SIGSEGV
error occurs at run time.
aCC -z file.CCompiles
file.C and generates code to disallow dereferencing of null
pointers.
To use optimization, first specify the appropriate basic optimization level
(+O1, +O2, +O3, or +O4)
on the aCC command line followed by one or more
finer or more precise options when necessary.
For an introduction with examples, refer to
Optimizing HP aC++ Programs.
Categories of options are listed below.
-O Command Line Option Syntax |
-O
aCC -O prog.CCompiles
prog.C and optimizes at level 2.
+O0 Command Line Option Syntax |
+O0
aCC +O0 prog.CCompiles
prog.C and optimizes at level 0.
+O1 Command Line Option Syntax |
+O1
aCC +O1 prog.CCompiles
prog.C and optimizes at level 1.
+O2 Command Line Option Syntax |
+O2
aCC +O2 prog.CCompiles
prog.C and optimizes at level 2.
+O3 Command Line Option Syntax |
+O3
aCC +O3 prog.CCompiles
prog.C and optimizes at level 3.
+O4 Command Line Option Syntax |
+O4
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.
If you run out of memory when compiling at +O4 optimization, there
are several things you can do:
+O4 only those
modules that need to be compiled at optimization level 4, and compile
the remaining modules at a lower level.
maxdsiz process parameter from 64 MB to 128 MB.
This procedure provides the process with additional data space.
Refer to the System Administration Tasks manual, Chapter 11,
"Reconfiguring the HP-UX Kernel." See Appendix A for full
descriptions of the different process parameters, including
maxdsiz.
For a complete discussion of swap space, refer to How HP-UX Works: Concepts for the System Administrator.
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. Therefore, 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. The compiler will issue an error message and terminate when an incompatible intermediate file is generated.
aCC +O4 prog.CCompiles
prog.C and optimizes at level 4.
+ES[no]lit Command Line Option Syntax |
+ES[no]lit
In A.03.15, A.01.23, and prior compiler versions, only floating-point constant
values were placed in read-only memory. Other constants and literals
were placed in read-write memory.
This behavior remains available by specifying the +ESnolit
option when compiling.
As +ESlit allows the placement of string literals into
read-only memory, all users of an application share this data.
Whereas, each user is allocated a private copy of
the data stored in read-write memory. By moving additional
data from read-write storage to read-only storage,
overall system memory requirements can be reduced and run-time speed improved.
In addition, the compiler may also group identical strings, further reducing
memory usage.
NOTE:
When +ESlit is in effect, you should not attempt to modify
string literals, because all string literals are placed in read-only memory.
Particularly, the following C library functions should be used with care,
since they can alter the contents of a string literal
that is specified as the receiving string.
extern char *strncat(char *, const char *, size_t); extern void *memmove(void *, const void *, size_t); extern char *strcpy(char *, const char *); extern char *strncpy(char *, const char *, size_t); extern char *strcat(char *, const char *); extern char *strtok(char *, const char *);Following is an example of code that attempts to modify read-only memory. A compile-time error is generated unless a cast is done, in which case there is no message. At runtime, a SIGBUS signal is generated.
int main()
{
static const char *p = "Now is the time";
char *q;
// .....
q = (char*)p; // cast to q
// OR
// q = const_cast(p); // const cast to q
*q = 'd'; // Very bad! Application core dump
// .....
}
+O[no]all Command Line Option Syntax |
+O[no]all
+Oall to obtain the best possible performance.
This option should be used with stable, well-structured code. These optimizations give you the fastest code, but are riskier than the default optimizations.
You can use +Oall at optimization levels 2, 3, and 4.
The default is +Onoall.
aCC +Oall prog.CCompiles
prog.C and optimizes for best performance.
aCC -O +Oall prog.CCompiles
prog.C and optimizes at level 2 with aggressive optimizations
and unrestricted compile time.
+Oall option without +O2, +O3, or +O4 combines the following options:
+O[no]aggressive Command Line Option Syntax |
+O[no]aggressive
The +Oaggressive option enables aggressive optimizations.
The +Onoaggressive option disables aggressive optimizations.
Aggressive optimizations can result in significant performance improvement, but can change program behavior. They can:
Use +Oaggressive with optimization levels 2, 3, or 4.
By default, aggressive optimizations are turned off.
aCC +O2 +Oaggressive sourcefile.Cor:
aCC +O3 +Oaggressive sourcefile.Cor:
aCC +O4 +Oaggressive sourcefile.C
+Oaggressive option invokes the following advanced optimization
options:
+O[no]conservative Command Line Option Syntax |
+O[no]conservative
+Oconservative option causes the optimizer to make conservative
assumptions about application code and enable only
conservative optimizations, a subset of basic optimizations.
Use +Oconservative at optimization levels 2, 3, or 4 when your source code
is unstructured or you are unfamiliar with the source code being optimized.
The default is +Onoconservative.
+Oconservative option as follows:
aCC +O2 +Oconservative sourcefile.Cor:
aCC +O3 +Oconservative sourcefile.Cor:
aCC +O4 +Oconservative sourcefile.C
+O[no]limit Command Line Option Syntax |
+O[no]limit
+Olimit option suppresses optimizations that significantly
increase compile-time or that consume a lot of memory.
The +Onolimit option enables optimizations regardless of their effect
on compile time or memory consumption.
Use +Onolimit with optimization levels 2, 3, or 4.
The default is +Olimit.
+Onolimit as follows:
aCC +O2 +Onolimit sourcefile.Cor:
aCC +O3 +Onolimit sourcefile.Cor:
aCC +O4 +Onolimit sourcefile.C
+O[no]size Command Line Option Syntax |
+O[no]size
+Osize option suppresses
those few optimizations that significantly increase code size.
The +Onosize option enables code-expanding optimizations.
Use +Osize at optimization levels 2, 3, or 4. The default is +Onosize.
+Osize as follows:
aCC +O2 +Osize sourcefile.Cor:
aCC +O3 +Osize sourcefile.Cor:
aCC +O4 +Osize sourcefile.C
Advanced optimization options provide additional control for special situations.
+O[no]cross_region_addressing Command Line Option Syntax |
+O[no]cross_region_addressing
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.
+O[no]dataprefetch Command Line Option Syntax |
+O[no]dataprefetch
+Odataprefetch is enabled, the optimizer inserts instructions within
innermost loops to explicitly prefetch data from memory into the data cache.
Data prefetch instructions are inserted only for data structures referenced
within innermost loops using simple loop varying addresses (that is,
in a simple arithmetic progression).
Use this option for applications that have high data cache miss overhead.
You can use +Odataprefetch at optimization levels 2, 3, and 4.
The default is +Onodataprefetch.
+Odataprefetch=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
Enable 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
Disable generation of data prefetch instructions.
This is the default at optimization levels +O1
and below.
+O[no]extern Command Line Option Syntax |
+O[no]extern
NOTE: Use of +Onoextern creates code that cannot be included in a shared library. Use +Onoextern only to build executables.
Only internal symbols (defined in the load module) can be optimized. If +Onoextern is specified, the compiler assumes that no symbols are external to the load module being compiled, and any symbol can be optimized. If +Oextern is specified, the compiler assumes that all symbols are external to the load module being compiled and thus cannot be optimized; this is the default.
Use +O[no]extern at optimization levels 0, 1, 2, 3, or 4.
The default is +Oextern with no name list.
This option is deprecated and its use is not recommended.
+O[no]fltacc Command Line Option Syntax |
+O[no]fltacc
+Onofltacc also generates Fused Multiply-Add (FMA)
instructions, as does compiling your program at
optimization level 2 or higher. 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 specify neither option at optimization level 2 or higher, the
optimizer generates FMA instructions but does
not perform any expression-reordering optimizations.
Specifying +Ofltacc
insures the same result as in unoptimized code (+O0).
+Onofltacc option allows 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 under +Onofltacc are
adequately similar to those obtained without the optimization.
For applications
in which roundoff error has been carefully studied, and the order of
computation carefully crafted to control error, +Onofltacc
may be unsatisfactory.
To insure the same result as in unoptimized code, use +Ofltacc.
Use +Onofltacc at optimization levels 2, 3, or 4.
The default is to leave this option unspecified.
+Onofltacc allows the compiler to substitute 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 Syntax |
+Ofrequently_called=function1[,function2...]
+Ofrequently_called:filename
+O[no]initcheck Command Line Option Syntax |
+O[no]initcheck
+Oinitcheck), the optimizer initializes to zero any local,
scalar, non-static variables that are uninitialized with respect to at least
one path leading to a use of the variable.
+Onoinitcheck), the optimizer does not initialize uninitialized
variables, but issues warning messages when it discovers them.
Use +Oinitcheck to look for program variables that may not be
initialized.
Use +Oinitcheck at any optimization level and +Onoinitcheck at
optimization levels 2, 3, or 4.
+O[no]inline Command Line Option Syntax |
+O[no]inline
+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 3 or 4.
The default is +Onoinline at optimization levels 1 and 2 and
+Oinline at levels 3 and 4.
+O[no]inline=function1{,function2...]
Enable [disable] optimizer inlining for the named functions.
+O[no]inline=filename
The file indicated by filename should contain a list of function names,
separated by commas or newlines. Optimization is enabled [disabled]
for the named functions.
+Oinlinebudget Command Line Option Syntax |
+Oinlinebudget=n
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:
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, however, that 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 3 or higher.
The default is +Oinlinebudget=100.
See also the
+O[no]inline option.
+Olevel=name1[,name2,...,nameN] Command Line Option Syntax |
+Olevel=name1[,name2,...,nameN]
This option works as does the OPT_LEVEL pragma. The option 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, it is best to use either this option or the OPT_LEVEL pragma rather than both.
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.
aCC +O3 +O1=myfunc1,myfunc2 funcs.c main.cThe 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]looptransform Command Line Option Syntax |
+O[no]looptransform
The +O[no]looptransform option enables [disables] transformation of
eligible loops for improved cache performance. The most important
transformation is the reordering of nested loops to make the inner loop
unit stride, resulting in fewer cache misses.
The default is +Olooptransform at optimization levels 3 and 4.
You cannot use the option at levels 0-2.
+O[no]moveflops Command Line Option Syntax |
+O[no]moveflops
+Omoveflops option allows moving conditional floating-point
instructions out of loops. The behavior of floating-point error handling may
be altered by this option.
This option also allows you to enable or disable replacing integer divide by a floating-point multiply. This may cause SIGFPE if IEEE inexact is enabled (+FPI).
+Onomoveflops if floating-point traps are enabled and you do not
want the behavior of floating-point errors to be altered by the relocation
of floating-point instructions.
Use +Onomoveflops at optimization levels 2, 3, and 4.
The default is +Omoveflops.
This option is deprecated and its use is not recommended.
+opts Command Line Option Syntax |
+opts filename
+O[no]parminit Command Line Option Syntax |
+O[no]parminit
+O[no]parmsoverlap Command Line Option Syntax |
+O[no]parmsoverlap
+Oparmsoverlap option optimizes with the assumption that the actual
arguments of function calls overlap in memory.
Use +Onoparmsoverlap if C++ programs have been literally translated
from FORTRAN programs.
Use +Onoparmsoverlap at optimization levels 2, 3, and 4.
The default is +Oparmsoverlap.
+O[no]procelim Command Line Option Syntax |
+O[no]procelim
Used when linking an executable file, +Oprocelim removes functions not
referenced by the application.
Used when building a shared library, +Oprocelim removes
functions not exported and not referenced from within the shared library.
This may be especially useful when functions have been inlined.
Note that any function having symbolic debug information associated with it is not removed.
The default is +Onoprocelim unless -g is used.
Use +O[no]procelim at any optimization level.
+O[no]promote_indirect_calls Command Line Option Syntax |
+O[no]promote_indirect_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 +Onopromote_indirect_calls.
+Orarely_called Command Line Option Syntax |
+Orarely_called=function1[,function2...]
+Orarely_called:filename
+O[no]recovery Command Line Option Syntax |
+O[no]recovery
+Oshortdata Command Line Option Syntax |
+Oshortdata[=size]
+Ostore_ordering Command Line Option Syntax |
+O[no]store_ordering
Profile-based optimization is a set of performance-improving code transformations based on the run-time characteristics of your application.
+dfname Command Line Option Syntax |
+dfname
The profile database by default is named flow.data. This file stores
profile information for one or more executables.
Use +df when the flow.data file has been renamed or is in a different
directory than where you are linking.
You can also use the FLOW_DATA environment variable to specify a different
path and file name for the profile database file. The +dfname
command line option takes precedence over the FLOW_DATA environment
variable.
NOTE:
The +dfname option cannot be used to redirect the
instrumentation output (with the +I option). It is only compatible
with the +P option.
aCC +P +dfpbo.data prog.o -o myapp
Relinks the object file prog.o, optimizes using the run-time
profile data in the file pbo.data, and
puts the executable code in the file myapp.
+Oprofile Command Line Option Syntax |
+Oprofile=[use|collect]
+Oprofile=collect is equivalent to +I.
+Oprofile=use[filename] causes the compiler to look for a profile database file. Overrides the FLOW_DATA environment variable.
After compiling and linking with +Oprofile, run the resultant program
using representative input data to collect execution profile data.
Finally, relink with the +P option
to perform profile-based optimization.
Profile data is stored in flow.data by default. See the
+dfname option for information on
controlling the name and location of this data file.
The +Oprofile option is incompatible with the
-G,
+P,
and -S options.
And it is incompatible with
-g0 and
-g1
if used to compile.
aCC +Oprofile -O -c prog.C aCC +Oprofile -O -o prog.pbo prog.o
Compiles prog.C with optimization, prepares the object code for data
collection, and creates the executable file prog.pbo. Running prog.pbo
collects run-time information in the file flow.data in preparation for
optimization with +P.
+I Command Line Option Syntax |
+I
After compiling and linking with +I, run the resultant program
using representative input data to collect execution profile data.
Finally, relink with the +P option
to perform profile-based optimization.
Profile data is stored in flow.data by default. See the
+dfname option for information on
controlling the name and location of this data file.
The +I option is incompatible with the
-G,
+P,
and -S options.
And it is incompatible with
-g0 and
-g1
if used to compile.
aCC +I -O -c prog.C aCC +I -O -o prog.pbo prog.o
Compiles prog.C with optimization, prepares the object code for data
collection, and creates the executable file prog.pbo. Running prog.pbo
collects run-time information in the file flow.data in preparation for
optimization with +P.
+P Command Line Option Syntax |
+P
The +P option does not affect the default optimization level, or the
optimization level specified by the +O1,
+O2, +O3, or
+O4 options.
NOTE:
Source files that are compiled with the
+I option
do not need to be recompiled with +P
in order to use profile-based optimization. You only need to relink
the object files with the +P option after running the
instrumented version of the program.
The +P option is incompatible with the
+I
and -S options.
And it is incompatible
-g0
and -g1
if used to compile.
aCC +P -o myapp prog.o
Relinks the object file prog.o and optimizes using the run-time profile
data.
+O[no]info Command Line Option Syntax |
+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 levels 0-4.
The default is +Onoinfo at levels 0-4.
-fast Command Line Option Syntax |
-fast
NOTE: Do not use this option for programs that depend on IEEE standard floating-point denormalized numbers. Otherwise, different numerical results may occur.
+uc Command Line Option Syntax |
+uc
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.
stdout.
.i file.
.suffix.
-Dname Command Line Option Syntax |
-Dname[=def]
name is the symbol name that is defined for the preprocessor.
def is the definition of the symbol name (name).
#define.
If no definition (def) is given, the name is defined as "1".
aCC -DDEBUGFLAG file.C
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
...
}