Next: , Previous: Compiling Programs, Up: Compiling Using gcc


3.2 Switches for gcc

The gcc command accepts switches that control the compilation process. These switches are fully described in this section. First we briefly list all the switches, in alphabetical order, then we describe the switches in more detail in functionally grouped sections.

-b target
Compile your program to run on target, which is the name of a system configuration. You must have a GNAT cross-compiler built if target is not the same as your host system.
-Bdir
Load compiler executables (for example, gnat1, the Ada compiler) from dir instead of the default location. Only use this switch when multiple versions of the GNAT compiler are available. See the gcc manual page for further details. You would normally use the -b or -V switch instead.
-c
Compile. Always use this switch when compiling Ada programs.

Note: for some other languages when using gcc, notably in the case of C and C++, it is possible to use use gcc without a -c switch to compile and link in one step. In the case of GNAT, you cannot use this approach, because the binder must be run and gcc cannot be used to run the GNAT binder.

-fno-inline
Suppresses all back-end inlining, even if other optimization or inlining switches are set. This includes suppression of inlining that results from the use of the pragma Inline_Always. See also -gnatn and -gnatN.
-fstack-check
Activates stack checking. See Stack Overflow Checking, for details of the use of this option.
-g
Generate debugging information. This information is stored in the object file and copied from there to the final executable file by the linker, where it can be read by the debugger. You must use the -g switch if you plan on using the debugger.
-gnat83
Enforce Ada 83 restrictions.
-gnata
Assertions enabled. Pragma Assert and pragma Debug to be activated.
-gnatA
Avoid processing gnat.adc. If a gnat.adc file is present, it will be ignored.
-gnatb
Generate brief messages to stderr even if verbose mode set.
-gnatc
Check syntax and semantics only (no code generation attempted).
-gnatd
Specify debug options for the compiler. The string of characters after the -gnatd specify the specific debug options. The possible characters are 0-9, a-z, A-Z, optionally preceded by a dot. See compiler source file debug.adb for details of the implemented debug options. Certain debug options are relevant to applications programmers, and these are documented at appropriate points in this users guide.
-gnatD
Output expanded source files for source level debugging. This switch also suppress generation of cross-reference information (see -gnatx).
-gnatec=path
Specify a configuration pragma file (the equal sign is optional) (see The Configuration Pragmas Files).
-gnateDsymbol[=value]
Defines a symbol, associated with value, for preprocessing. (see Integrated Preprocessing)
-gnatef
Display full source path name in brief error messages.
-gnatem=path
Specify a mapping file (the equal sign is optional) (see Units to Sources Mapping Files).
-gnatep=file
Specify a preprocessing data file (the equal sign is optional) (see Integrated Preprocessing).
-gnatE
Full dynamic elaboration checks.
-gnatf
Full errors. Multiple errors per line, all undefined references, do not attempt to suppress cascaded errors.
-gnatF
Externals names are folded to all uppercase.
-gnatg
Internal GNAT implementation mode. This should not be used for applications programs, it is intended only for use by the compiler and its run-time library. For documentation, see the GNAT sources. Note that -gnatg implies -gnatwu so that warnings are generated on unreferenced entities, and all warnings are treated as errors.
-gnatG
List generated expanded code in source form.
-gnath
Output usage information. The output is written to stdout.
-gnatic
Identifier character set (c=1/2/3/4/8/9/p/f/n/w).
-gnatk=n
Limit file names to n (1-999) characters (k = krunch).
-gnatl
Output full source listing with embedded error messages.
-gnatL
Use the longjmp/setjmp method for exception handling
-gnatm=n
Limit number of detected error or warning messages to n where n is in the range 1..999_999. The default setting if no switch is given is 9999. Compilation is terminated if this limit is exceeded.
-gnatn
Activate inlining for subprograms for which pragma inline is specified. This inlining is performed by the GCC back-end.
-gnatN
Activate front end inlining for subprograms for which pragma Inline is specified. This inlining is performed by the front end and will be visible in the -gnatG output. In some cases, this has proved more effective than the back end inlining resulting from the use of -gnatn. Note that -gnatN automatically implies -gnatn so it is not necessary to specify both options. There are a few cases that the back-end inlining catches that cannot be dealt with in the front-end.
-gnato
Enable numeric overflow checking (which is not normally enabled by default). Not that division by zero is a separate check that is not controlled by this switch (division by zero checking is on by default).
-gnatp
Suppress all checks.
-gnatP
Enable polling. This is required on some systems (notably Windows NT) to obtain asynchronous abort and asynchronous transfer of control capability. See the description of pragma Polling in the GNAT Reference Manual for full details.
-gnatq
Don't quit; try semantics, even if parse errors.
-gnatQ
Don't quit; generate ALI and tree files even if illegalities.
-gnatR[0/1/2/3[s]]
Output representation information for declared types and objects.
-gnats
Syntax check only.
-gnatS
Print package Standard.
-gnatt
Generate tree output file.
-gnatTnnn
All compiler tables start at nnn times usual starting size.
-gnatu
List units for this compilation.
-gnatU
Tag all error messages with the unique string “error:”
-gnatv
Verbose mode. Full error output with source lines to stdout.
-gnatV
Control level of validity checking. See separate section describing this feature.
-gnatwxxx
Warning mode where xxx is a string of option letters that denotes the exact warnings that are enabled or disabled. (see Warning Message Control)
-gnatWe
Wide character encoding method (e=n/h/u/s/e/8).
-gnatx
Suppress generation of cross-reference information.
-gnaty
Enable built-in style checks. (see Style Checking)
-gnatzm
Distribution stub generation and compilation (m=r/c for receiver/caller stubs).
-gnatZ
Use the zero cost method for exception handling
-Idir
Direct GNAT to search the dir directory for source files needed by the current compilation (see Search Paths and the Run-Time Library (RTL)).
-I-
Except for the source file named in the command line, do not look for source files in the directory containing the source file named in the command line (see Search Paths and the Run-Time Library (RTL)).
-mbig-switch
This standard gcc switch causes the compiler to use larger offsets in its jump table representation for case statements. This may result in less efficient code, but is sometimes necessary (for example on HP-UX targets) in order to compile large and/or nested case statements.
-o file
This switch is used in gcc to redirect the generated object file and its associated ALI file. Beware of this switch with GNAT, because it may cause the object file and ALI file to have different names which in turn may confuse the binder and the linker.
-nostdinc
Inhibit the search of the default location for the GNAT Run Time Library (RTL) source files.
-nostdlib
Inhibit the search of the default location for the GNAT Run Time Library (RTL) ALI files.
-O[n]
n controls the optimization level.
n = 0
No optimization, the default setting if no -O appears
n = 1
Normal optimization, the default if you specify -O without an operand.
n = 2
Extensive optimization
n = 3
Extensive optimization with automatic inlining of subprograms not specified by pragma Inline. This applies only to inlining within a unit. For details on control of inlining see See Subprogram Inlining Control.

-pass-exit-codes
Catch exit codes from the compiler and use the most meaningful as exit status.
--RTS=rts-path
Specifies the default location of the runtime library. Same meaning as the equivalent gnatmake flag (see Switches for gnatmake).
-S
Used in place of -c to cause the assembler source file to be generated, using .s as the extension, instead of the object file. This may be useful if you need to examine the generated assembly code.
-v
Show commands generated by the gcc driver. Normally used only for debugging purposes or if you need to be sure what version of the compiler you are executing.
-V ver
Execute ver version of the compiler. This is the gcc version, not the GNAT version.

You may combine a sequence of GNAT switches into a single switch. For example, the combined switch

     -gnatofi3

is equivalent to specifying the following sequence of switches:

     -gnato -gnatf -gnati3

The following restrictions apply to the combination of switches in this manner: