Go to the first, previous, next, last section, table of contents.


GCC Command Options

When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an intermediate stage. For example, the `-c' option says not to run the linker. Then the output consists of object files output by the assembler.

Other options are passed on to one stage of processing. Some options control the preprocessor and others the compiler itself. Yet other options control the assembler and linker; most of these are not documented here, since you rarely need to use any of them.

Most of the command line options that you can use with GCC are useful for C programs; when an option is only useful with another language (usually C++), the explanation says so explicitly. If the description for a particular option does not mention a source language, you can use that option with all supported languages.

See section Compiling C++ Programs, for a summary of special options for compiling C++ programs.

The gcc program accepts options and file names as operands. Many options have multi-letter names; therefore multiple single-letter options may not be grouped: `-dr' is very different from `-d -r'.

You can mix options and other arguments. For the most part, the order you use doesn't matter. Order does matter when you use several options of the same kind; for example, if you specify `-L' more than once, the directories are searched in the order specified.

Many options have long names starting with `-f' or with `-W'---for example, `-fforce-mem', `-fstrength-reduce', `-Wformat' and so on. Most of these have both positive and negative forms; the negative form of `-ffoo' would be `-fno-foo'. This manual documents only one of these two forms, whichever one is not the default.

Option Summary

Here is a summary of all the options, grouped by type. Explanations are in the following sections.

Overall Options
See section Options Controlling the Kind of Output.
C Language Options
See section Options Controlling C Dialect.
C++ Language Options
See section Options Controlling C++ Dialect.
Language Independent Options
See section Options to Control Diagnostic Messages Formatting.
Warning Options
See section Options to Request or Suppress Warnings.
C-only Warning Options
Debugging Options
See section Options for Debugging Your Program or GCC.
-a  -ax  -dletters  -fdump-unnumbered -fdump-translation-unit-file
-fpretend-float -fprofile-arcs  -ftest-coverage
-g  -glevel  -gcoff  -gdwarf  -gdwarf-1  -gdwarf-1+  -gdwarf-2
-ggdb  -gstabs  -gstabs+  -gxcoff  -gxcoff+
-p  -pg  -print-file-name=library  -print-libgcc-file-name
-print-prog-name=program  -print-search-dirs  -Q
-save-temps  -time
Optimization Options
See section Options That Control Optimization.
-falign-functions=n  -falign-jumps=n
-falign-labels=n  -falign-loops=n 
-fbranch-probabilities  -fcaller-saves
-fcse-follow-jumps  -fcse-skip-blocks  -fdata-sections  -fdce
-fdelayed-branch  -fdelete-null-pointer-checks
-fexpensive-optimizations  -ffast-math  -ffloat-store
-fforce-addr  -fforce-mem  -ffunction-sections  -fgcse 
-finline-functions  -finline-limit=n  -fkeep-inline-functions
-fkeep-static-consts  -fmove-all-movables
-fno-default-inline  -fno-defer-pop
-fno-function-cse  -fno-inline  -fno-math-errno  -fno-peephole
-fomit-frame-pointer  -foptimize-register-move
-foptimize-sibling-calls  -freduce-all-givs
-fregmove  -frename-registers
-frerun-cse-after-loop  -frerun-loop-opt
-fschedule-insns  -fschedule-insns2
-fsingle-precision-constant  -fssa
-fstrength-reduce  -fstrict-aliasing  -fthread-jumps  -ftrapv
-funroll-all-loops  -funroll-loops 
-O  -O0  -O1  -O2  -O3  -Os
Preprocessor Options
See section Options Controlling the Preprocessor.
Assembler Option
See section Passing Options to the Assembler.
Linker Options
See section Options for Linking.
Directory Options
See section Options for Directory Search.
Target Options
See section Specifying Target Machine and Compiler Version.
Machine Dependent Options
See section Hardware Models and Configurations.
MIPS Options
-mabicalls  -mcpu=cpu type
-membedded-data  -muninit-const-in-rodata
-membedded-pic  -mfp32  -mfp64  -mgas  -mgp32  -mgp64
-mgpopt  -mhalf-pic  -mhard-float  -mint64  -mips1
-mips2  -mips3 -mips4 -mlong64  -mlong32 -mlong-calls  -mmemcpy
-mmips-as  -mmips-tfile  -mno-abicalls
-mno-embedded-data  -mno-uninit-const-in-rodata  -mno-embedded-pic
-mno-gpopt  -mno-long-calls
-mno-memcpy  -mno-mips-tfile  -mno-rnames  -mno-stats
-mrnames  -msoft-float
-m4650  -msingle-float  -mmad
-mstats  -EL  -EB  -G num  -nocpp
-mabi=32 -mabi=n32 -mabi=64 -mabi=eabi
-mfix7000 -mno-crt0

i386 Options
-mcpu=cpu type -march=cpu type
-mintel-syntax -mieee-fp  -mno-fancy-math-387
-mno-fp-ret-in-387  -msoft-float  -msvr3-shlib
-mno-wide-multiply  -mrtd  -malign-double
-mreg-alloc=list  -mregparm=num
-malign-jumps=num  -malign-loops=num
-malign-functions=num -mpreferred-stack-boundary=num
-mthreads -mno-align-stringops -minline-all-stringops
-mpush-args -maccumulate-outgoing-args

Code Generation Options
See section Options for Code Generation Conventions.
-fcall-saved-reg  -fcall-used-reg
-fexceptions  -funwind-tables  -ffixed-reg
-finhibit-size-directive  -finstrument-functions
-fcheck-memory-usage  -fprefix-function-name
-fno-common  -fno-ident  -fno-gnu-linker
-fpcc-struct-return  -fpic  -fPIC
-freg-struct-return  -fshared-data  -fshort-enums
-fshort-double  -fvolatile  -fvolatile-global -fvolatile-static
-fverbose-asm  -fpack-struct  -fstack-check
-fstack-limit-register=reg  -fstack-limit-symbol=sym
-fargument-alias  -fargument-noalias
-fargument-noalias-global
-fleading-underscore

Options for Debugging Your Program or GCC

GCC has various special options that are used for debugging either your program or GCC:

-g
Produce debugging information in the operating system's native format (stabs, COFF, XCOFF, or DWARF). GDB can work with this debugging information. On most systems that use stabs format, `-g' enables use of extra debugging information that only GDB can use; this extra information makes debugging work better in GDB but will probably make other debuggers crash or refuse to read the program. If you want to control for certain whether to generate the extra information, use `-gstabs+', `-gstabs', `-gxcoff+', `-gxcoff', `-gdwarf-1+', or `-gdwarf-1' (see below). Unlike most other C compilers, GCC allows you to use `-g' with `-O'. The shortcuts taken by optimized code may occasionally produce surprising results: some variables you declared may not exist at all; flow of control may briefly move where you did not expect it; some statements may not be executed because they compute constant results or their values were already at hand; some statements may execute in different places because they were moved out of loops. Nevertheless it proves possible to debug optimized output. This makes it reasonable to use the optimizer for programs that might have bugs. The following options are useful when GCC is generated with the capability for more than one debugging format.
-ggdb
Produce debugging information for use by GDB. This means to use the most expressive format available (DWARF 2, stabs, or the native format if neither of those are supported), including GDB extensions if at all possible.
-gstabs
Produce debugging information in stabs format (if that is supported), without GDB extensions. This is the format used by DBX on most BSD systems. On MIPS, Alpha and System V Release 4 systems this option produces stabs debugging output which is not understood by DBX or SDB. On System V Release 4 systems this option requires the GNU assembler.
-gstabs+
Produce debugging information in stabs format (if that is supported), using GNU extensions understood only by the GNU debugger (GDB). The use of these extensions is likely to make other debuggers crash or refuse to read the program.
-gcoff
Produce debugging information in COFF format (if that is supported). This is the format used by SDB on most System V systems prior to System V Release 4.
-gxcoff
Produce debugging information in XCOFF format (if that is supported). This is the format used by the DBX debugger on IBM RS/6000 systems.
-gxcoff+
Produce debugging information in XCOFF format (if that is supported), using GNU extensions understood only by the GNU debugger (GDB). The use of these extensions is likely to make other debuggers crash or refuse to read the program, and may cause assemblers other than the GNU assembler (GAS) to fail with an error.
-gdwarf
Produce debugging information in DWARF version 1 format (if that is supported). This is the format used by SDB on most System V Release 4 systems.
-gdwarf+
Produce debugging information in DWARF version 1 format (if that is supported), using GNU extensions understood only by the GNU debugger (GDB). The use of these extensions is likely to make other debuggers crash or refuse to read the program.
-gdwarf-2
Produce debugging information in DWARF version 2 format (if that is supported). This is the format used by DBX on IRIX 6.
-glevel
-ggdblevel
-gstabslevel
-gcofflevel
-gxcofflevel
-gdwarflevel
-gdwarf-2level
Request debugging information and also use level to specify how much information. The default level is 2. Level 1 produces minimal information, enough for making backtraces in parts of the program that you don't plan to debug. This includes descriptions of functions and external variables, but no information about local variables and no line numbers. Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use `-g3'.
-p
Generate extra code to write profile information suitable for the analysis program prof. You must use this option when compiling the source files you want data about, and you must also use it when linking.
-pg
Generate extra code to write profile information suitable for the analysis program gprof. You must use this option when compiling the source files you want data about, and you must also use it when linking.
-a
Generate extra code to write profile information for basic blocks, which will record the number of times each basic block is executed, the basic block start address, and the function name containing the basic block. If `-g' is used, the line number and filename of the start of the basic block will also be recorded. If not overridden by the machine description, the default action is to append to the text file `bb.out'. This data could be analyzed by a program like tcov. Note, however, that the format of the data is not what tcov expects. Eventually GNU gprof should be extended to process this data.
-Q
Makes the compiler print out each function name as it is compiled, and print some statistics about each pass when it finishes.
-ax
Generate extra code to profile basic blocks. Your executable will produce output that is a superset of that produced when `-a' is used. Additional output is the source and target address of the basic blocks where a jump takes place, the number of times a jump is executed, and (optionally) the complete sequence of basic blocks being executed. The output is appended to file `bb.out'. You can examine different profiling aspects without recompilation. Your executable will read a list of function names from file `bb.in'. Profiling starts when a function on the list is entered and stops when that invocation is exited. To exclude a function from profiling, prefix its name with `-'. If a function name is not unique, you can disambiguate it by writing it in the form `/path/filename.d:functionname'. Your executable will write the available paths and filenames in file `bb.out'. Several function names have a special meaning:
__bb_jumps__
Write source, target and frequency of jumps to file `bb.out'.
__bb_hidecall__
Exclude function calls from frequency count.
__bb_showret__
Include function returns in frequency count.
__bb_trace__
Write the sequence of basic blocks executed to file `bbtrace.gz'. The file will be compressed using the program `gzip', which must exist in your PATH. On systems without the `popen' function, the file will be named `bbtrace' and will not be compressed. Profiling for even a few seconds on these systems will produce a very large file. Note: __bb_hidecall__ and __bb_showret__ will not affect the sequence written to `bbtrace.gz'.
Here's a short example using different profiling parameters in file `bb.in'. Assume function foo consists of basic blocks 1 and 2 and is called twice from block 3 of function main. After the calls, block 3 transfers control to block 4 of main. With __bb_trace__ and main contained in file `bb.in', the following sequence of blocks is written to file `bbtrace.gz': 0 3 1 2 1 2 4. The return from block 2 to block 3 is not shown, because the return is to a point inside the block and not to the top. The block address 0 always indicates, that control is transferred to the trace from somewhere outside the observed functions. With `-foo' added to `bb.in', the blocks of function foo are removed from the trace, so only 0 3 4 remains. With __bb_jumps__ and main contained in file `bb.in', jump frequencies will be written to file `bb.out'. The frequencies are obtained by constructing a trace of blocks and incrementing a counter for every neighbouring pair of blocks in the trace. The trace 0 3 1 2 1 2 4 displays the following frequencies:
Jump from block 0x0 to block 0x3 executed 1 time(s)
Jump from block 0x3 to block 0x1 executed 1 time(s)
Jump from block 0x1 to block 0x2 executed 2 time(s)
Jump from block 0x2 to block 0x1 executed 1 time(s)
Jump from block 0x2 to block 0x4 executed 1 time(s)
With __bb_hidecall__, control transfer due to call instructions is removed from the trace, that is the trace is cut into three parts: 0 3 4, 0 1 2 and 0 1 2. With __bb_showret__, control transfer due to return instructions is added to the trace. The trace becomes: 0 3 1 2 3 1 2 3 4. Note, that this trace is not the same, as the sequence written to `bbtrace.gz'. It is solely used for counting jump frequencies.
-fprofile-arcs
Instrument arcs during compilation. For each function of your program, GCC creates a program flow graph, then finds a spanning tree for the graph. Only arcs that are not on the spanning tree have to be instrumented: the compiler adds code to count the number of times that these arcs are executed. When an arc is the only exit or only entrance to a block, the instrumentation code can be added to the block; otherwise, a new basic block must be created to hold the instrumentation code. Since not every arc in the program must be instrumented, programs compiled with this option run faster than programs compiled with `-a', which adds instrumentation code to every basic block in the program. The tradeoff: since gcov does not have execution counts for all branches, it must start with the execution counts for the instrumented branches, and then iterate over the program flow graph until the entire graph has been solved. Hence, gcov runs a little more slowly than a program which uses information from `-a'. `-fprofile-arcs' also makes it possible to estimate branch probabilities, and to calculate basic block execution counts. In general, basic block execution counts do not give enough information to estimate all branch probabilities. When the compiled program exits, it saves the arc execution counts to a file called `sourcename.da'. Use the compiler option `-fbranch-probabilities' (see section Options That Control Optimization) when recompiling, to optimize using estimated branch probabilities.
-ftest-coverage
Create data files for the gcov code-coverage utility (see section gcov: a Test Coverage Program). The data file names begin with the name of your source file:
sourcename.bb
A mapping from basic blocks to line numbers, which gcov uses to associate basic block execution counts with line numbers.
sourcename.bbg
A list of all arcs in the program flow graph. This allows gcov to reconstruct the program flow graph, so that it can compute all basic block and arc execution counts from the information in the sourcename.da file (this last file is the output from `-fprofile-arcs').
-dletters
Says to make debugging dumps during compilation at times specified by letters. This is used for debugging the compiler. The file names for most of the dumps are made by appending a pass number and a word to the source file name (e.g. `foo.c.00.rtl' or `foo.c.01.sibling'). Here are the possible letters for use in letters, and their meanings:
`A'
Annotate the assembler output with miscellaneous debugging information.
`b'
Dump after computing branch probabilities, to `file.11.bp'.
`B'
Dump after block reordering, to `file.26.bbro'.
`c'
Dump after instruction combination, to the file `file.14.combine'.
`C'
Dump after the first if conversion, to the file `file.15.ce'.
`d'
Dump after delayed branch scheduling, to `file.29.dbr'.
`D'
Dump all macro definitions, at the end of preprocessing, in addition to normal output.
`e'
Dump after SSA optimizations, to `file.05.ssa' and `file.06.ussa'.
`E'
Dump after the second if conversion, to `file.24.ce2'.
`f'
Dump after life analysis, to `file.13.life'.
`F'
Dump after purging ADDRESSOF codes, to `file.04.addressof'.
`g'
Dump after global register allocation, to `file.19.greg'.
`o'
Dump after post-reload CSE and other optimizations, to `file.20.postreload'.
`G'
Dump after GCSE, to `file.08.gcse'.
`i'
Dump after sibling call optimizations, to `file.01.sibling'.
`j'
Dump after the first jump optimization, to `file.02.jump'.
`J'
Dump after the last jump optimization, to `file.27.jump2'.
`k'
Dump after conversion from registers to stack, to `file.29.stack'.
`l'
Dump after local register allocation, to `file.18.lreg'.
`L'
Dump after loop optimization, to `file.09.loop'.
`M'
Dump after performing the machine dependent reorganisation pass, to `file.28.mach'.
`n'
Dump after register renumbering, to `file.23.rnreg'.
`N'
Dump after the register move pass, to `file.16.regmove'.
`r'
Dump after RTL generation, to `file.00.rtl'.
`R'
Dump after the second instruction scheduling pass, to `file.25.sched2'.
`s'
Dump after CSE (including the jump optimization that sometimes follows CSE), to `file.03.cse'.
`S'
Dump after the first instruction scheduling pass, to `file.17.sched'.
`t'
Dump after the second CSE pass (including the jump optimization that sometimes follows CSE), to `file.10.cse2'.
`w'
Dump after the second flow pass, to `file.21.flow2'.
`X'
Dump after dead code elimination, to `file.06.dce'.
`z'
Dump after the peephole pass, to `file.22.peephole2'.
`a'
Produce all the dumps listed above.
`m'
Print statistics on memory usage, at the end of the run, to standard error.
`p'
Annotate the assembler output with a comment indicating which pattern and alternative was used. The length of each instruction is also printed.
`P'
Dump the RTL in the assembler output as a comment before each instruction. Also turns on `-dp' annotation.
`v'
For each of the other indicated dump files (except for `file.00.rtl'), dump a representation of the control flow graph suitable for viewing with VCG to `file.pass.vcg'.
`x'
Just generate RTL for a function instead of compiling it. Usually used with `r'.
`y'
Dump debugging information during parsing, to standard error.
-fdump-unnumbered
When doing debugging dumps (see -d option above), suppress instruction numbers and line number note output. This makes it more feasible to use diff on debugging dumps for compiler invocations with different options, in particular with and without -g.
-fdump-translation-unit-file (C and C++ only)
Dump a representation of the tree structure for the entire translation unit to file.
-fpretend-float
When running a cross-compiler, pretend that the target machine uses the same floating point format as the host machine. This causes incorrect output of the actual floating constants, but the actual instruction sequence will probably be the same as GCC would make when running on the target machine.
-save-temps
Store the usual "temporary" intermediate files permanently; place them in the current directory and name them based on the source file. Thus, compiling `foo.c' with `-c -save-temps' would produce files `foo.i' and `foo.s', as well as `foo.o'. This creates a preprocessed `foo.i' output file even though the compiler now normally uses an integrated preprocessor.
-time
Report the CPU time taken by each subprocess in the compilation sequence. For C source files, this is the compiler proper and assembler (plus the linker if linking is done). The output looks like this:
# cc1 0.12 0.01
# as 0.00 0.01
The first number on each line is the "user time," that is time spent executing the program itself. The second number is "system time," time spent executing operating system routines on behalf of the program. Both numbers are in seconds.
-print-file-name=library
Print the full absolute name of the library file library that would be used when linking--and don't do anything else. With this option, GCC does not compile or link anything; it just prints the file name.
-print-prog-name=program
Like `-print-file-name', but searches for a program such as `cpp'.
-print-libgcc-file-name
Same as `-print-file-name=libgcc.a'. This is useful when you use `-nostdlib' or `-nodefaultlibs' but you do want to link with `libgcc.a'. You can do
gcc -nostdlib files... `gcc -print-libgcc-file-name`
-print-search-dirs
Print the name of the configured installation directory and a list of program and library directories gcc will search--and don't do anything else. This is useful when gcc prints the error message `installation problem, cannot exec cpp: No such file or directory'. To resolve this you either need to put `cpp' and the other compiler components where gcc expects to find them, or you can set the environment variable GCC_EXEC_PREFIX to the directory where you installed them. Don't forget the trailing '/'. See section Environment Variables Affecting GCC.

Options That Control Optimization

These options control various sorts of optimizations:

-O
-O1
Optimize. Optimizing compilation takes somewhat more time, and a lot more memory for a large function. Without `-O', the compiler's goal is to reduce the cost of compilation and to make debugging produce the expected results. Statements are independent: if you stop the program with a breakpoint between statements, you can then assign a new value to any variable or change the program counter to any other statement in the function and get exactly the results you would expect from the source code. Without `-O', the compiler only allocates variables declared register in registers. The resulting compiled code is a little worse than produced by PCC without `-O'. With `-O', the compiler tries to reduce code size and execution time. When you specify `-O', the compiler turns on `-fthread-jumps' and `-fdefer-pop' on all machines. The compiler turns on `-fdelayed-branch' on machines that have delay slots, and `-fomit-frame-pointer' on machines that can support debugging even without a frame pointer. On some machines the compiler also turns on other flags.
-O2
Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. The compiler does not perform loop unrolling or function inlining when you specify `-O2'. As compared to `-O', this option increases both compilation time and the performance of the generated code. `-O2' turns on all optional optimizations except for loop unrolling, function inlining, and register renaming. It also turns on the `-fforce-mem' option on all machines and frame pointer elimination on machines where doing so does not interfere with debugging.
-O3
Optimize yet more. `-O3' turns on all optimizations specified by `-O2' and also turns on the `-finline-functions' and `-frename-registers' options.
-O0
Do not optimize.
-Os
Optimize for size. `-Os' enables all `-O2' optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size. If you use multiple `-O' options, with or without level numbers, the last such option is the one that is effective.

Options of the form `-fflag' specify machine-independent flags. Most flags have both positive and negative forms; the negative form of `-ffoo' would be `-fno-foo'. In the table below, only one of the forms is listed--the one which is not the default. You can figure out the other form by either removing `no-' or adding it.

-ffloat-store
Do not store floating point variables in registers, and inhibit other options that might change whether a floating point value is taken from a register or memory. This option prevents undesirable excess precision on machines such as the 68000 where the floating registers (of the 68881) keep more precision than a double is supposed to have. Similarly for the x86 architecture. For most programs, the excess precision does only good, but a few programs rely on the precise definition of IEEE floating point. Use `-ffloat-store' for such programs, after modifying them to store all pertinent intermediate computations into variables.
-fno-default-inline
Do not make member functions inline by default merely because they are defined inside the class scope (C++ only). Otherwise, when you specify `-O', member functions defined inside class scope are compiled inline by default; i.e., you don't need to add `inline' in front of the member function name.
-fno-defer-pop
Always pop the arguments to each function call as soon as that function returns. For machines which must pop arguments after a function call, the compiler normally lets arguments accumulate on the stack for several function calls and pops them all at once.
-fforce-mem
Force memory operands to be copied into registers before doing arithmetic on them. This produces better code by making all memory references potential common subexpressions. When they are not common subexpressions, instruction combination should eliminate the separate register-load. The `-O2' option turns on this option.
-fforce-addr
Force memory address constants to be copied into registers before doing arithmetic on them. This may produce better code just as `-fforce-mem' may.
-fomit-frame-pointer
Don't keep the frame pointer in a register for functions that don't need one. This avoids the instructions to save, set up and restore frame pointers; it also makes an extra register available in many functions. It also makes debugging impossible on some machines. On some machines, such as the Vax, this flag has no effect, because the standard calling sequence automatically handles the frame pointer and nothing is saved by pretending it doesn't exist. The machine-description macro FRAME_POINTER_REQUIRED controls whether a target machine supports this flag. See section Register Usage.
-foptimize-sibling-calls
Optimize sibling and tail recursive calls.
-ftrapv
This option generates traps for signed overflow on addition, subtraction, multiplication operations.
-fno-inline
Don't pay attention to the inline keyword. Normally this option is used to keep the compiler from expanding any functions inline. Note that if you are not optimizing, no functions can be expanded inline.
-finline-functions
Integrate all simple functions into their callers. The compiler heuristically decides which functions are simple enough to be worth integrating in this way. If all calls to a given function are integrated, and the function is declared static, then the function is normally not output as assembler code in its own right.
-finline-limit=n
By default, gcc limits the size of functions that can be inlined. This flag allows the control of this limit for functions that are explicitly marked as inline (ie marked with the inline keyword or defined within the class definition in c++). n is the size of functions that can be inlined in number of pseudo instructions (not counting parameter handling). The default value of n is 10000. Increasing this value can result in more inlined code at the cost of compilation time and memory consumption. Decreasing usually makes the compilation faster and less code will be inlined (which presumably means slower programs). This option is particularly useful for programs that use inlining heavily such as those based on recursive templates with c++. Note: pseudo instruction represents, in this particular context, an abstract measurement of function's size. In no way, it represents a count of assembly instructions and as such its exact meaning might change from one release to an another.
-fkeep-inline-functions
Even if all calls to a given function are integrated, and the function is declared static, nevertheless output a separate run-time callable version of the function. This switch does not affect extern inline functions.
-fkeep-static-consts
Emit variables declared static const when optimization isn't turned on, even if the variables aren't referenced. GCC enables this option by default. If you want to force the compiler to check if the variable was referenced, regardless of whether or not optimization is turned on, use the `-fno-keep-static-consts' option.
-fno-function-cse
Do not put function addresses in registers; make each instruction that calls a constant function contain the function's address explicitly. This option results in less efficient code, but some strange hacks that alter the assembler output may be confused by the optimizations performed when this option is not used.
-ffast-math
This option allows GCC to violate some ISO or IEEE rules and/or specifications in the interest of optimizing code for speed. For example, it allows the compiler to assume arguments to the sqrt function are non-negative numbers and that no floating-point values are NaNs. This option should never be turned on by any `-O' option since it can result in incorrect output for programs which depend on an exact implementation of IEEE or ISO rules/specifications for math functions.
-fno-math-errno
Do not set ERRNO after calling math functions that are executed with a single instruction, e.g., sqrt. A program that relies on IEEE exceptions for math error handling may want to use this flag for speed while maintaining IEEE arithmetic compatibility. The default is `-fmath-errno'. The `-ffast-math' option sets `-fno-math-errno'.

The following options control specific optimizations. The `-O2' option turns on all of these optimizations except `-funroll-loops' and `-funroll-all-loops'. On most machines, the `-O' option turns on the `-fthread-jumps' and `-fdelayed-branch' options, but specific machines may handle it differently.

You can use the following flags in the rare cases when "fine-tuning" of optimizations to be performed is desired.

-fstrength-reduce
Perform the optimizations of loop strength reduction and elimination of iteration variables.
-fthread-jumps
Perform optimizations where we check to see if a jump branches to a location where another comparison subsumed by the first is found. If so, the first branch is redirected to either the destination of the second branch or a point immediately following it, depending on whether the condition is known to be true or false.
-fcse-follow-jumps
In common subexpression elimination, scan through jump instructions when the target of the jump is not reached by any other path. For example, when CSE encounters an if statement with an else clause, CSE will follow the jump when the condition tested is false.
-fcse-skip-blocks
This is similar to `-fcse-follow-jumps', but causes CSE to follow jumps which conditionally skip over blocks. When CSE encounters a simple if statement with no else clause, `-fcse-skip-blocks' causes CSE to follow the jump around the body of the if.
-frerun-cse-after-loop
Re-run common subexpression elimination after loop optimizations has been performed.
-frerun-loop-opt
Run the loop optimizer twice.
-fgcse
Perform a global common subexpression elimination pass. This pass also performs global constant and copy propagation.
-fdelete-null-pointer-checks
Use global dataflow analysis to identify and eliminate useless null pointer checks. Programs which rely on NULL pointer dereferences not halting the program may not work properly with this option. Use -fno-delete-null-pointer-checks to disable this optimizing for programs which depend on that behavior.
-fexpensive-optimizations
Perform a number of minor optimizations that are relatively expensive.
-foptimize-register-move
-fregmove
Attempt to reassign register numbers in move instructions and as operands of other simple instructions in order to maximize the amount of register tying. This is especially helpful on machines with two-operand instructions. GCC enables this optimization by default with `-O2' or higher. Note -fregmove and -foptimize-register-move are the same optimization.
-fdelayed-branch
If supported for the target machine, attempt to reorder instructions to exploit instruction slots available after delayed branch instructions.
-fschedule-insns
If supported for the target machine, attempt to reorder instructions to eliminate execution stalls due to required data being unavailable. This helps machines that have slow floating point or memory load instructions by allowing other instructions to be issued until the result of the load or floating point instruction is required.
-fschedule-insns2
Similar to `-fschedule-insns', but requests an additional pass of instruction scheduling after register allocation has been done. This is especially useful on machines with a relatively small number of registers and where memory load instructions take more than one cycle.
-ffunction-sections
-fdata-sections
Place each function or data item into its own section in the output file if the target supports arbitrary sections. The name of the function or the name of the data item determines the section's name in the output file. Use these options on systems where the linker can perform optimizations to improve locality of reference in the instruction space. HPPA processors running HP-UX and Sparc processors running Solaris 2 have linkers with such optimizations. Other systems using the ELF object format as well as AIX may have these optimizations in the future. Only use these options when there are significant benefits from doing so. When you specify these options, the assembler and linker will create larger object and executable files and will also be slower. You will not be able to use gprof on all systems if you specify this option and you may have problems with debugging if you specify both this option and `-g'.
-fcaller-saves
Enable values to be allocated in registers that will be clobbered by function calls, by emitting extra instructions to save and restore the registers around such calls. Such allocation is done only when it seems to result in better code than would otherwise be produced. This option is always enabled by default on certain machines, usually those which have no call-preserved registers to use instead. For all machines, optimization level 2 and higher enables this flag by default.
-funroll-loops
Perform the optimization of loop unrolling. This is only done for loops whose number of iterations can be determined at compile time or run time. `-funroll-loops' implies both `-fstrength-reduce' and `-frerun-cse-after-loop'.
-funroll-all-loops
Perform the optimization of loop unrolling. This is done for all loops and usually makes programs run more slowly. `-funroll-all-loops' implies `-fstrength-reduce' as well as `-frerun-cse-after-loop'.
-fmove-all-movables
Forces all invariant computations in loops to be moved outside the loop.
-freduce-all-givs
Forces all general-induction variables in loops to be strength-reduced. Note: When compiling programs written in Fortran, `-fmove-all-movables' and `-freduce-all-givs' are enabled by default when you use the optimizer. These options may generate better or worse code; results are highly dependent on the structure of loops within the source code. These two options are intended to be removed someday, once they have helped determine the efficacy of various approaches to improving loop optimizations. Please let us (gcc@gcc.gnu.org and fortran@gnu.org) know how use of these options affects the performance of your production code. We're very interested in code that runs slower when these options are enabled.
-fno-peephole
Disable any machine-specific peephole optimizations.
-fbranch-probabilities
After running a program compiled with `-fprofile-arcs' (see section Options for Debugging Your Program or GCC), you can compile it a second time using `-fbranch-probabilities', to improve optimizations based on guessing the path a branch might take. With `-fbranch-probabilities', GCC puts a `REG_EXEC_COUNT' note on the first instruction of each basic block, and a `REG_BR_PROB' note on each `JUMP_INSN' and `CALL_INSN'. These can be used to improve optimization. Currently, they are only used in one place: in `reorg.c', instead of guessing which path a branch is mostly to take, the `REG_BR_PROB' values are used to exactly determine which path is taken more often.
-fstrict-aliasing
Allows the compiler to assume the strictest aliasing rules applicable to the language being compiled. For C (and C++), this activates optimizations based on the type of expressions. In particular, an object of one type is assumed never to reside at the same address as an object of a different type, unless the types are almost the same. For example, an unsigned int can alias an int, but not a void* or a double. A character type may alias any other type. Pay special attention to code like this:
union a_union { 
  int i;
  double d;
};

int f() {
  a_union t;
  t.d = 3.0;
  return t.i;
}
The practice of reading from a different union member than the one most recently written to (called "type-punning") is common. Even with `-fstrict-aliasing', type-punning is allowed, provided the memory is accessed through the union type. So, the code above will work as expected. However, this code might not:
int f() { 
  a_union t;
  int* ip;
  t.d = 3.0;
  ip = &t.i;
  return *ip;
}
Every language that wishes to perform language-specific alias analysis should define a function that computes, given an tree node, an alias set for the node. Nodes in different alias sets are not allowed to alias. For an example, see the C front-end function c_get_alias_set.
-falign-functions
-falign-functions=n
Align the start of functions to the next power-of-two greater than n, skipping up to n bytes. For instance, `-falign-functions=32' aligns functions to the next 32-byte boundary, but `-falign-functions=24' would align to the next 32-byte boundary only if this can be done by skipping 23 bytes or less. `-fno-align-functions' and `-falign-functions=1' are equivalent and mean that functions will not be aligned. Some assemblers only support this flag when n is a power of two; in that case, it is rounded up. If n is not specified, use a machine-dependent default.
-falign-labels
-falign-labels=n
Align all branch targets to a power-of-two boundary, skipping up to n bytes like `-falign-functions'. This option can easily make code slower, because it must insert dummy operations for when the branch target is reached in the usual flow of the code. If `-falign-loops' or `-falign-jumps' are applicable and are greater than this value, then their values are used instead. If n is not specified, use a machine-dependent default which is very likely to be `1', meaning no alignment.
-falign-loops
-falign-loops=n
Align loops to a power-of-two boundary, skipping up to n bytes like `-falign-functions'. The hope is that the loop will be executed many times, which will make up for any execution of the dummy operations. If n is not specified, use a machine-dependent default.
-falign-jumps
-falign-jumps=n
Align branch targets to a power-of-two boundary, for branch targets where the targets can only be reached by jumping, skipping up to n bytes like `-falign-functions'. In this case, no dummy operations need be executed. If n is not specified, use a machine-dependent default.
-fssa
Perform optimizations in static single assignment form. Each function's flow graph is translated into SSA form, optimizations are performed, and the flow graph is translated back from SSA form. User's should not specify this option, since it is not yet ready for production use.
-fdce
Perform dead-code elimination in SSA form. Requires `-fssa'. Like `-fssa', this is an experimental feature.
-fsingle-precision-constant
Treat floating point constant as single precision constant instead of implicitly converting it to double precision constant.
-frename-registers
Attempt to avoid false dependancies in scheduled code by making use of registers left over after register allocation. This optimization will most benefit processors with lots of registers. It can, however, make debugging impossible, since variables will no longer stay in a "home register".

Hardware Models and Configurations

Earlier we discussed the standard option `-b' which chooses among different installed compilers for completely different target machines, such as Vax vs. 68000 vs. 80386.

In addition, each of these target machine types can have its own special options, starting with `-m', to choose among various hardware models or configurations--for example, 68010 vs 68020, floating coprocessor or none. A single installed version of the compiler can compile for any model or configuration, according to the options specified.

Some configurations of the compiler also support additional special options, usually for compatibility with other compilers on the same platform.

These options are defined by the macro TARGET_SWITCHES in the machine description. The default for the options is also defined by that macro, which enables you to change the defaults.

MIPS Options

These `-m' options are defined for the MIPS family of computers:

-mcpu=cpu type
Assume the defaults for the machine type cpu type when scheduling instructions. The choices for cpu type are `r2000', `r3000', `r3900', `r4000', `r4100', `r4300', `r4400', `r4600', `r4650', `r5000', `r6000', `r8000', and `orion'. Additionally, the `r2000', `r3000', `r4000', `r5000', and `r6000' can be abbreviated as `r2k' (or `r2K'), `r3k', etc. While picking a specific cpu type will schedule things appropriately for that particular chip, the compiler will not generate any code that does not meet level 1 of the MIPS ISA (instruction set architecture) without a `-mipsX' or `-mabi' switch being used.
-mips1
Issue instructions from level 1 of the MIPS ISA. This is the default. `r3000' is the default cpu type at this ISA level.
-mips2
Issue instructions from level 2 of the MIPS ISA (branch likely, square root instructions). `r6000' is the default cpu type at this ISA level.
-mips3
Issue instructions from level 3 of the MIPS ISA (64 bit instructions). `r4000' is the default cpu type at this ISA level.
-mips4
Issue instructions from level 4 of the MIPS ISA (conditional move, prefetch, enhanced FPU instructions). `r8000' is the default cpu type at this ISA level.
-mfp32
Assume that 32 32-bit floating point registers are available. This is the default.
-mfp64
Assume that 32 64-bit floating point registers are available. This is the default when the `-mips3' option is used.
-mgp32
Assume that 32 32-bit general purpose registers are available. This is the default.
-mgp64
Assume that 32 64-bit general purpose registers are available. This is the default when the `-mips3' option is used.
-mint64
Force int and long types to be 64 bits wide. See `-mlong32' for an explanation of the default, and the width of pointers.
-mlong64
Force long types to be 64 bits wide. See `-mlong32' for an explanation of the default, and the width of pointers.
-mlong32
Force long, int, and pointer types to be 32 bits wide. If none of `-mlong32', `-mlong64', or `-mint64' are set, the size of ints, longs, and pointers depends on the ABI and ISA chosen. For `-mabi=32', and `-mabi=n32', ints and longs are 32 bits wide. For `-mabi=64', ints are 32 bits, and longs are 64 bits wide. For `-mabi=eabi' and either `-mips1' or `-mips2', ints and longs are 32 bits wide. For `-mabi=eabi' and higher ISAs, ints are 32 bits, and longs are 64 bits wide. The width of pointer types is the smaller of the width of longs or the width of general purpose registers (which in turn depends on the ISA).
-mabi=32
-mabi=o64
-mabi=n32
-mabi=64
-mabi=eabi
Generate code for the indicated ABI. The default instruction level is `-mips1' for `32', `-mips3' for `n32', and `-mips4' otherwise. Conversely, with `-mips1' or `-mips2', the default ABI is `32'; otherwise, the default ABI is `64'.
-mmips-as
Generate code for the MIPS assembler, and invoke `mips-tfile' to add normal debug information. This is the default for all platforms except for the OSF/1 reference platform, using the OSF/rose object format. If the either of the `-gstabs' or `-gstabs+' switches are used, the `mips-tfile' program will encapsulate the stabs within MIPS ECOFF.
-mgas
Generate code for the GNU assembler. This is the default on the OSF/1 reference platform, using the OSF/rose object format. Also, this is the default if the configure option `--with-gnu-as' is used.
-msplit-addresses
-mno-split-addresses
Generate code to load the high and low parts of address constants separately. This allows gcc to optimize away redundant loads of the high order bits of addresses. This optimization requires GNU as and GNU ld. This optimization is enabled by default for some embedded targets where GNU as and GNU ld are standard.
-mrnames
-mno-rnames
The `-mrnames' switch says to output code using the MIPS software names for the registers, instead of the hardware names (ie, a0 instead of $4). The only known assembler that supports this option is the Algorithmics assembler.
-mgpopt
-mno-gpopt
The `-mgpopt' switch says to write all of the data declarations before the instructions in the text section, this allows the MIPS assembler to generate one word memory references instead of using two words for short global or static data items. This is on by default if optimization is selected.
-mstats
-mno-stats
For each non-inline function processed, the `-mstats' switch causes the compiler to emit one line to the standard error file to print statistics about the program (number of registers saved, stack size, etc.).
-mmemcpy
-mno-memcpy
The `-mmemcpy' switch makes all block moves call the appropriate string function (`memcpy' or `bcopy') instead of possibly generating inline code.
-mmips-tfile
-mno-mips-tfile
The `-mno-mips-tfile' switch causes the compiler not postprocess the object file with the `mips-tfile' program, after the MIPS assembler has generated it to add debug support. If `mips-tfile' is not run, then no local variables will be available to the debugger. In addition, `stage2' and `stage3' objects will have the temporary file names passed to the assembler embedded in the object file, which means the objects will not compare the same. The `-mno-mips-tfile' switch should only be used when there are bugs in the `mips-tfile' program that prevents compilation.
-msoft-float
Generate output containing library calls for floating point. Warning: the requisite libraries are not part of GCC. Normally the facilities of the machine's usual C compiler are used, but this can't be done directly in cross-compilation. You must make your own arrangements to provide suitable library functions for cross-compilation.
-mhard-float
Generate output containing floating point instructions. This is the default if you use the unmodified sources.
-mabicalls
-mno-abicalls
Emit (or do not emit) the pseudo operations `.abicalls', `.cpload', and `.cprestore' that some System V.4 ports use for position independent code.
-mlong-calls
-mno-long-calls
Do all calls with the `JALR' instruction, which requires loading up a function's address into a register before the call. You need to use this switch, if you call outside of the current 512 megabyte segment to functions that are not through pointers.
-mhalf-pic
-mno-half-pic
Put pointers to extern references into the data section and load them up, rather than put the references in the text section.
-membedded-pic
-mno-embedded-pic
Generate PIC code suitable for some embedded systems. All calls are made using PC relative address, and all data is addressed using the $gp register. No more than 65536 bytes of global data may be used. This requires GNU as and GNU ld which do most of the work. This currently only works on targets which use ECOFF; it does not work with ELF.
-membedded-data
-mno-embedded-data
Allocate variables to the read-only data section first if possible, then next in the small data section if possible, otherwise in data. This gives slightly slower code than the default, but reduces the amount of RAM required when executing, and thus may be preferred for some embedded systems.
-muninit-const-in-rodata
-mno-uninit-const-in-rodata
When used together with -membedded-data, it will always store uninitialized const variables in the read-only data section.
-msingle-float
-mdouble-float
The `-msingle-float' switch tells gcc to assume that the floating point coprocessor only supports single precision operations, as on the `r4650' chip. The `-mdouble-float' switch permits gcc to use double precision operations. This is the default.
-mmad
-mno-mad
Permit use of the `mad', `madu' and `mul' instructions, as on the `r4650' chip.
-m4650
Turns on `-msingle-float', `-mmad', and, at least for now, `-mcpu=r4650'.
-mips16
-mno-mips16
Enable 16-bit instructions.
-mentry
Use the entry and exit pseudo ops. This option can only be used with `-mips16'.
-EL
Compile code for the processor in little endian mode. The requisite libraries are assumed to exist.
-EB
Compile code for the processor in big endian mode. The requisite libraries are assumed to exist.
-G num
Put global and static items less than or equal to num bytes into the small data or bss sections instead of the normal data or bss section. This allows the assembler to emit one word memory reference instructions based on the global pointer (gp or $28), instead of the normal two words used. By default, num is 8 when the MIPS assembler is used, and 0 when the GNU assembler is used. The `-G num' switch is also passed to the assembler and linker. All modules should be compiled with the same `-G num' value.
-nocpp
Tell the MIPS assembler to not run its preprocessor over user assembler files (with a `.s' suffix) when assembling them.
-mfix7000
Pass an option to gas which will cause nops to be inserted if the read of the destination register of an mfhi or mflo instruction occurs in the following two instructions.
-no-crt0
Do not include the default crt0.

These options are defined by the macro TARGET_SWITCHES in the machine description. The default for the options is also defined by that macro, which enables you to change the defaults.

Intel 386 Options

These `-m' options are defined for the i386 family of computers:

-mcpu=cpu type
Assume the defaults for the machine type cpu type when scheduling instructions. The choices for cpu type are:
`i386' `i486' `i586' `i686'
`pentium' `pentiumpro' `k6' `athlon'
While picking a specific cpu type will schedule things appropriately for that particular chip, the compiler will not generate any code that does not run on the i386 without the `-march=cpu type' option being used. `i586' is equivalent to `pentium' and `i686' is equivalent to `pentiumpro'. `k6' is the AMD chip as opposed to the Intel ones.
-march=cpu type
Generate instructions for the machine type cpu type. The choices for cpu type are the same as for `-mcpu'. Moreover, specifying `-march=cpu type' implies `-mcpu=cpu type'.
-m386
-m486
-mpentium
-mpentiumpro
Synonyms for -mcpu=i386, -mcpu=i486, -mcpu=pentium, and -mcpu=pentiumpro respectively. These synonyms are deprecated.
-mintel-syntax
Emit assembly using Intel syntax opcodes instead of AT&T syntax.
-mieee-fp
-mno-ieee-fp
Control whether or not the compiler uses IEEE floating point comparisons. These handle correctly the case where the result of a comparison is unordered.
-msoft-float
Generate output containing library calls for floating point. Warning: the requisite libraries are not part of GCC. Normally the facilities of the machine's usual C compiler are used, but this can't be done directly in cross-compilation. You must make your own arrangements to provide suitable library functions for cross-compilation. On machines where a function returns floating point results in the 80387 register stack, some floating point opcodes may be emitted even if `-msoft-float' is used.
-mno-fp-ret-in-387
Do not use the FPU registers for return values of functions. The usual calling convention has functions return values of types float and double in an FPU register, even if there is no FPU. The idea is that the operating system should emulate an FPU. The option `-mno-fp-ret-in-387' causes such values to be returned in ordinary CPU registers instead.
-mno-fancy-math-387
Some 387 emulators do not support the sin, cos and sqrt instructions for the 387. Specify this option to avoid generating those instructions. This option is the default on FreeBSD. As of revision 2.6.1, these instructions are not generated unless you also use the `-ffast-math' switch.
-malign-double
-mno-align-double
Control whether GCC aligns double, long double, and long long variables on a two word boundary or a one word boundary. Aligning double variables on a two word boundary will produce code that runs somewhat faster on a `Pentium' at the expense of more memory. Warning: if you use the `-malign-double' switch, structures containing the above types will be aligned differently than the published application binary interface specifications for the 386.
-msvr3-shlib
-mno-svr3-shlib
Control whether GCC places uninitialized locals into bss or data. `-msvr3-shlib' places these locals into bss. These options are meaningful only on System V Release 3.
-mno-wide-multiply
-mwide-multiply
Control whether GCC uses the mul and imul that produce 64 bit results in eax:edx from 32 bit operands to do long long multiplies and 32-bit division by constants.
-mrtd
Use a different function-calling convention, in which functions that take a fixed number of arguments return with the ret num instruction, which pops their arguments while returning. This saves one instruction in the caller since there is no need to pop the arguments there. You can specify that an individual function is called with this calling sequence with the function attribute `stdcall'. You can also override the `-mrtd' option by using the function attribute `cdecl'. See section Declaring Attributes of Functions. Warning: this calling convention is incompatible with the one normally used on Unix, so you cannot use it if you need to call libraries compiled with the Unix compiler. Also, you must provide function prototypes for all functions that take variable numbers of arguments (including printf); otherwise incorrect code will be generated for calls to those functions. In addition, seriously incorrect code will result if you call a function with too many arguments. (Normally, extra arguments are harmlessly ignored.)
-mreg-alloc=regs
Control the default allocation order of integer registers. The string regs is a series of letters specifying a register. The supported letters are: a allocate EAX; b allocate EBX; c allocate ECX; d allocate EDX; S allocate ESI; D allocate EDI; B allocate EBP.
-mregparm=num
Control how many registers are used to pass integer arguments. By default, no registers are used to pass arguments, and at most 3 registers can be used. You can control this behavior for a specific function by using the function attribute `regparm'. See section Declaring Attributes of Functions. Warning: if you use this switch, and num is nonzero, then you must build all modules with the same value, including any libraries. This includes the system libraries and startup modules.
-malign-loops=num
Align loops to a 2 raised to a num byte boundary. If `-malign-loops' is not specified, the default is 2 unless gas 2.8 (or later) is being used in which case the default is to align the loop on a 16 byte boundary if it is less than 8 bytes away.
-malign-jumps=num
Align instructions that are only jumped to to a 2 raised to a num byte boundary. If `-malign-jumps' is not specified, the default is 2 if optimizing for a 386, and 4 if optimizing for a 486 unless gas 2.8 (or later) is being used in which case the default is to align the instruction on a 16 byte boundary if it is less than 8 bytes away.
-malign-functions=num
Align the start of functions to a 2 raised to num byte boundary. If `-malign-functions' is not specified, the default is 2 if optimizing for a 386, and 4 if optimizing for a 486.
-mpreferred-stack-boundary=num
Attempt to keep the stack boundary aligned to a 2 raised to num byte boundary. If `-mpreferred-stack-boundary' is not specified, the default is 4 (16 bytes or 128 bits). The stack is required to be aligned on a 4 byte boundary. On Pentium and PentiumPro, double and long double values should be aligned to an 8 byte boundary (see `-malign-double') or suffer significant run time performance penalties. On Pentium III, the Streaming SIMD Extension (SSE) data type __m128 suffers similar penalties if it is not 16 byte aligned. To ensure proper alignment of this values on the stack, the stack boundary must be as aligned as that required by any value stored on the stack. Further, every function must be generated such that it keeps the stack aligned. Thus calling a function compiled with a higher preferred stack boundary from a function compiled with a lower preferred stack boundary will most likely misalign the stack. It is recommended that libraries that use callbacks always use the default setting. This extra alignment does consume extra stack space. Code that is sensitive to stack space usage, such as embedded systems and operating system kernels, may want to reduce the preferred alignment to `-mpreferred-stack-boundary=2'.
-mpush-args
Use PUSH operations to store outgoing parameters. This method is shorter and usually equally fast as method using SUB/MOV operations and is enabled by default. In some cases disabling it may improve performance because of improved scheduling and reduced dependencies.
-maccumulate-outgoing-args
If enabled, the maximum amount of space required for outgoing arguments will be computed in the function prologue. This in faster on most modern CPUs because of reduced dependencies, improved scheduling and reduced stack usage when preferred stack boundary is not equal to 2. The drawback is a notable increase in code size. This switch implies -mno-push-args.
-mthreads
Support thread-safe exception handling on `Mingw32'. Code that relies on thread-safe exception handling must compile and link all code with the `-mthreads' option. When compiling, `-mthreads' defines `-D_MT'; when linking, it links in a special thread helper library `-lmingwthrd' which cleans up per thread exception handling data.
-mno-align-stringops
Do not align destination of inlined string operations. This switch reduces code size and improves performance in case the destination is already aligned, but gcc don't know about it.
-minline-all-stringops
By default GCC inlines string operations only when destination is known to be aligned at least to 4 byte boundary. This enables more inlining, increase code size, but may improve performance of code that depends on fast memcpy, strlen and memset for short lengths.

Options for Code Generation Conventions

These machine-independent options control the interface conventions used in code generation.

Most of them have both positive and negative forms; the negative form of `-ffoo' would be `-fno-foo'. In the table below, only one of the forms is listed--the one which is not the default. You can figure out the other form by either removing `no-' or adding it.

-fexceptions
Enable exception handling. Generates extra code needed to propagate exceptions. For some targets, this implies GNU CC will generate frame unwind information for all functions, which can produce significant data size overhead, although it does not affect execution. If you do not specify this option, GNU CC will enable it by default for languages like C++ which normally require exception handling, and disable itfor languages like C that do not normally require it. However, you may need to enable this option when compiling C code that needs to interoperate properly with exception handlers written in C++. You may also wish to disable this option if you are compiling older C++ programs that don't use exception handling.
-funwind-tables
Similar to -fexceptions, except that it will just generate any needed static data, but will not affect the generated code in any other way. You will normally not enable this option; instead, a language processor that needs this handling would enable it on your behalf.
-fpcc-struct-return
Return "short" struct and union values in memory like longer ones, rather than in registers. This convention is less efficient, but it has the advantage of allowing intercallability between GCC-compiled files and files compiled with other compilers. The precise convention for returning structures in memory depends on the target configuration macros. Short structures and unions are those whose size and alignment match that of some integer type.
-freg-struct-return
Use the convention that struct and union values are returned in registers when possible. This is more efficient for small structures than `-fpcc-struct-return'. If you specify neither `-fpcc-struct-return' nor its contrary `-freg-struct-return', GCC defaults to whichever convention is standard for the target. If there is no standard convention, GCC defaults to `-fpcc-struct-return', except on targets where GCC is the principal compiler. In those cases, we can choose the standard, and we chose the more efficient register return alternative.
-fshort-enums
Allocate to an enum type only as many bytes as it needs for the declared range of possible values. Specifically, the enum type will be equivalent to the smallest integer type which has enough room.
-fshort-double
Use the same size for double as for float.
-fshared-data
Requests that the data and non-const variables of this compilation be shared data rather than private data. The distinction makes sense only on certain operating systems, where shared data is shared between processes running the same program, while private data exists in one copy per process.
-fno-common
Allocate even uninitialized global variables in the data section of the object file, rather than generating them as common blocks. This has the effect that if the same variable is declared (without extern) in two different compilations, you will get an error when you link them. The only reason this might be useful is if you wish to verify that the program will work on other systems which always work this way.
-fno-ident
Ignore the `#ident' directive.
-fno-gnu-linker
Do not output global initializations (such as C++ constructors and destructors) in the form used by the GNU linker (on systems where the GNU linker is the standard method of handling them). Use this option when you want to use a non-GNU linker, which also requires using the collect2 program to make sure the system linker includes constructors and destructors. (collect2 is included in the GCC distribution.) For systems which must use collect2, the compiler driver gcc is configured to do this automatically.
-finhibit-size-directive
Don't output a .size assembler directive, or anything else that would cause trouble if the function is split in the middle, and the two halves are placed at locations far apart in memory. This option is used when compiling `crtstuff.c'; you should not need to use it for anything else.
-fverbose-asm
Put extra commentary information in the generated assembly code to make it more readable. This option is generally only of use to those who actually need to read the generated assembly code (perhaps while debugging the compiler itself). `-fno-verbose-asm', the default, causes the extra information to be omitted and is useful when comparing two assembler files.
-fvolatile
Consider all memory references through pointers to be volatile.
-fvolatile-global
Consider all memory references to extern and global data items to be volatile. GCC does not consider static data items to be volatile because of this switch.
-fvolatile-static
Consider all memory references to static data to be volatile.
-fpic
Generate position-independent code (PIC) suitable for use in a shared library, if supported for the target machine. Such code accesses all constant addresses through a global offset table (GOT). The dynamic loader resolves the GOT entries when the program starts (the dynamic loader is not part of GCC; it is part of the operating system). If the GOT size for the linked executable exceeds a machine-specific maximum size, you get an error message from the linker indicating that `-fpic' does not work; in that case, recompile with `-fPIC' instead. (These maximums are 16k on the m88k, 8k on the Sparc, and 32k on the m68k and RS/6000. The 386 has no such limit.) Position-independent code requires special support, and therefore works only on certain machines. For the 386, GCC supports PIC for System V but not for the Sun 386i. Code generated for the IBM RS/6000 is always position-independent.
-fPIC
If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding any limit on the size of the global offset table. This option makes a difference on the m68k, m88k, and the Sparc. Position-independent code requires special support, and therefore works only on certain machines.
-ffixed-reg
Treat the register named reg as a fixed register; generated code should never refer to it (except perhaps as a stack pointer, frame pointer or in some other fixed role). reg must be the name of a register. The register names accepted are machine-specific and are defined in the REGISTER_NAMES macro in the machine description macro file. This flag does not have a negative form, because it specifies a three-way choice.
-fcall-used-reg
Treat the register named reg as an allocable register that is clobbered by function calls. It may be allocated for temporaries or variables that do not live across a call. Functions compiled this way will not save and restore the register reg. It is an error to used this flag with the frame pointer or stack pointer. Use of this flag for other registers that have fixed pervasive roles in the machine's execution model will produce disastrous results. This flag does not have a negative form, because it specifies a three-way choice.
-fcall-saved-reg
Treat the register named reg as an allocable register saved by functions. It may be allocated even for temporaries or variables that live across a call. Functions compiled this way will save and restore the register reg if they use it. It is an error to used this flag with the frame pointer or stack pointer. Use of this flag for other registers that have fixed pervasive roles in the machine's execution model will produce disastrous results. A different sort of disaster will result from the use of this flag for a register in which function values may be returned. This flag does not have a negative form, because it specifies a three-way choice.
-fpack-struct
Pack all structure members together without holes. Usually you would not want to use this option, since it makes the code suboptimal, and the offsets of structure members won't agree with system libraries.
-fcheck-memory-usage
Generate extra code to check each memory access. GCC will generate code that is suitable for a detector of bad memory accesses such as `Checker'. Normally, you should compile all, or none, of your code with this option. If you do mix code compiled with and without this option, you must ensure that all code that has side effects and that is called by code compiled with this option is, itself, compiled with this option. If you do not, you might get erroneous messages from the detector. If you use functions from a library that have side-effects (such as read), you might not be able to recompile the library and specify this option. In that case, you can enable the `-fprefix-function-name' option, which requests GCC to encapsulate your code and make other functions look as if they were compiled with `-fcheck-memory-usage'. This is done by calling "stubs", which are provided by the detector. If you cannot find or build stubs for every function you call, you might have to specify `-fcheck-memory-usage' without `-fprefix-function-name'. If you specify this option, you can not use the asm or __asm__ keywords in functions with memory checking enabled. GNU CC cannot understand what the asm statement may do, and therefore cannot generate the appropriate code, so it will reject it. However, if you specify the function attribute no_check_memory_usage (see see section Declaring Attributes of Functions, GNU CC will disable memory checking within a function; you may use asm statements inside such functions. You may have an inline expansion of a non-checked function within a checked function; in that case GNU CC will not generate checks for the inlined function's memory accesses. If you move your asm statements to non-checked inline functions and they do access memory, you can add calls to the support code in your inline function, to indicate any reads, writes, or copies being done. These calls would be similar to those done in the stubs described above.
-fprefix-function-name
Request GCC to add a prefix to the symbols generated for function names. GCC adds a prefix to the names of functions defined as well as functions called. Code compiled with this option and code compiled without the option can't be linked together, unless stubs are used. If you compile the following code with `-fprefix-function-name'
extern void bar (int);
void
foo (int a)
{
  return bar (a + 5);
}
GCC will compile the code as if it was written:
extern void prefix_bar (int);
void
prefix_foo (int a)
{
  return prefix_bar (a + 5);
}
This option is designed to be used with `-fcheck-memory-usage'.
-finstrument-functions
Generate instrumentation calls for entry and exit to functions. Just after function entry and just before function exit, the following profiling functions will be called with the address of the current function and its call site. (On some platforms, __builtin_return_address does not work beyond the current function, so the call site information may not be available to the profiling functions otherwise.)
void __cyg_profile_func_enter (void *this_fn, void *call_site);
void __cyg_profile_func_exit  (void *this_fn, void *call_site);
The first argument is the address of the start of the current function, which may be looked up exactly in the symbol table. This instrumentation is also done for functions expanded inline in other functions. The profiling calls will indicate where, conceptually, the inline function is entered and exited. This means that addressable versions of such functions must be available. If all your uses of a function are expanded inline, this may mean an additional expansion of code size. If you use `extern inline' in your C code, an addressable version of such functions must be provided. (This is normally the case anyways, but if you get lucky and the optimizer always expands the functions inline, you might have gotten away without providing static copies.) A function may be given the attribute no_instrument_function, in which case this instrumentation will not be done. This can be used, for example, for the profiling functions listed above, high-priority interrupt routines, and any functions from which the profiling functions cannot safely be called (perhaps signal handlers, if the profiling routines generate output or allocate memory).
-fstack-check
Generate code to verify that you do not go beyond the boundary of the stack. You should specify this flag if you are running in an environment with multiple threads, but only rarely need to specify it in a single-threaded environment since stack overflow is automatically detected on nearly all systems if there is only one stack. Note that this switch does not actually cause checking to be done; the operating system must do that. The switch causes generation of code to ensure that the operating system sees the stack being extended.
-fstack-limit-register=reg
-fstack-limit-symbol=sym
-fno-stack-limit
Generate code to ensure that the stack does not grow beyond a certain value, either the value of a register or the address of a symbol. If the stack would grow beyond the value, a signal is raised. For most targets, the signal is raised before the stack overruns the boundary, so it is possible to catch the signal without taking special precautions. For instance, if the stack starts at address `0x80000000' and grows downwards you can use the flags `-fstack-limit-symbol=__stack_limit' `-Wl,--defsym,__stack_limit=0x7ffe0000' which will enforce a stack limit of 128K.
-fargument-alias
-fargument-noalias
-fargument-noalias-global
Specify the possible relationships among parameters and between parameters and global data. `-fargument-alias' specifies that arguments (parameters) may alias each other and may alias global storage. `-fargument-noalias' specifies that arguments do not alias each other, but may alias global storage. `-fargument-noalias-global' specifies that arguments do not alias each other and do not alias global storage. Each language will automatically use whatever option is required by the language standard. You should not need to use these options yourself.
-fleading-underscore
This option and its counterpart, -fno-leading-underscore, forcibly change the way C symbols are represented in the object file. One use is to help link with legacy assembly code. Be warned that you should know what you are doing when invoking this option, and that not all targets provide complete support for it.


Go to the first, previous, next, last section, table of contents.