[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 multiletter 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.
2.1 Option Summary Brief list of all options, without explanations. 2.2 Options Controlling the Kind of Output Controlling the kind of output: an executable, object files, assembler files, or preprocessed source. 2.3 Compiling C++ Programs Compiling C++ programs. 2.4 Options Controlling C Dialect Controlling the variant of C language compiled. 2.5 Options Controlling C++ Dialect Variations on C++. 2.6 Options to Request or Suppress Warnings How picky should the compiler be? 2.7 Options for Debugging Your Program or GCC Symbol tables, measurements, and debugging dumps. 2.8 Options That Control Optimization How much optimization? 2.9 Options Controlling the Preprocessor Controlling header files and macro definitions. Also, getting dependency information for Make. 2.10 Passing Options to the Assembler Passing options to the assembler. 2.11 Options for Linking Specifying libraries and so on. 2.12 Options for Directory Search Where to find header files and libraries. Where to find the compiler executable files. 2.13 Specifying Target Machine and Compiler Version Running a cross-compiler, or an old version of GCC. 2.14 Hardware Models and Configurations Specifying minor hardware or convention variations, such as 68010 vs 68020. 2.15 Options for Code Generation Conventions Specifying conventions for function calls, data layout and register usage. 2.16 Environment Variables Affecting GCC Env vars that affect GCC. 2.17 Running Protoize Automatically adding or removing function prototypes.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Here is a summary of all the options, grouped by type. Explanations are in the following sections.
-c -S -E -o file -pipe -v --help -x language |
-ansi -flang-isoc9x -fallow-single-precision -fcond-mismatch -fno-asm -fno-builtin -ffreestanding -fhosted -fsigned-bitfields -fsigned-char -funsigned-bitfields -funsigned-char -fwritable-strings -traditional -traditional-cpp -trigraphs |
-fno-access-control -fcheck-new -fconserve-space -fdollars-in-identifiers -fno-elide-constructors -fexternal-templates -ffor-scope -fno-for-scope -fno-gnu-keywords -fguiding-decls -fhandle-signatures -fhonor-std -fhuge-objects -fno-implicit-templates -finit-priority -fno-implement-inlines -fname-mangling-version-n -fno-default-inline -foperator-names -fno-optional-diags -fpermissive -frepo -fstrict-prototype -fsquangle -ftemplate-depth-n -fthis-is-variable -fvtable-thunks -nostdinc++ -Wctor-dtor-privacy -Wno-deprecated -Weffc++ -Wno-non-template-friend -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wno-pmf-conversions -Wreorder -Wsign-promo -Wsynth |
-fsyntax-only -pedantic -pedantic-errors -w -W -Wall -Waggregate-return -Wbad-function-cast -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion -Werror -Wformat -Wid-clash-len -Wimplicit -Wimplicit-int -Wimplicit-function-declaration -Wimport -Werror-implicit-function-declaration -Winline -Wlarger-than-len -Wlong-long -Wmain -Wmissing-declarations -Wmissing-noreturn -Wmissing-prototypes -Wmultichar -Wnested-externs -Wno-import -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wsign-compare -Wstrict-prototypes -Wswitch -Wtraditional -Wtrigraphs -Wundef -Wuninitialized -Wunused -Wwrite-strings -Wunknown-pragmas |
-a -ax -dletters -fdump-unnumbered -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 -save-temps |
-fbranch-probabilities -foptimize-register-moves -fcaller-saves -fcse-follow-jumps -fcse-skip-blocks -fdelayed-branch -fexpensive-optimizations -ffast-math -ffloat-store -fforce-addr -fforce-mem -fdata-sections -ffunction-sections -fgcse -finline-functions -finline-limit-n -fkeep-inline-functions -fno-default-inline -fno-defer-pop -fno-function-cse -fno-inline -fno-peephole -fomit-frame-pointer -fregmove -frerun-cse-after-loop -frerun-loop-opt -fschedule-insns -fschedule-insns2 -fstrength-reduce -fthread-jumps -funroll-all-loops -funroll-loops -fmove-all-movables -freduce-all-givs -fstrict-aliasing -O -O0 -O1 -O2 -O3 -Os |
-Aquestion(answer) -C -dD -dM -dN -Dmacro[=defn] -E -H -idirafter dir -include file -imacros file -iprefix file -iwithprefix dir -iwithprefixbefore dir -isystem dir -isystem-c++ dir -M -MD -MM -MMD -MG -nostdinc -P -trigraphs -undef -Umacro -Wp,option |
-Wa,option |
object-file-name -llibrary -nostartfiles -nodefaultlibs -nostdlib -s -static -shared -symbolic -Wl,option -Xlinker option -u symbol |
-Bprefix -Idir -I- -Ldir -specs=file |
-b machine -V version |
M680x0 Options -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 -m68060 -mcpu32 -m5200 -m68881 -mbitfield -mc68000 -mc68020 -mfpa -mnobitfield -mrtd -mshort -msoft-float -malign-int VAX Options -mg -mgnu -munix SPARC Options -mcpu=cpu type -mtune=cpu type -mcmodel=code model -malign-jumps=num -malign-loops=num -malign-functions=num -m32 -m64 -mapp-regs -mbroken-saverestore -mcypress -mepilogue -mflat -mfpu -mhard-float -mhard-quad-float -mimpure-text -mlive-g0 -mno-app-regs -mno-epilogue -mno-flat -mno-fpu -mno-impure-text -mno-stack-bias -mno-unaligned-doubles -msoft-float -msoft-quad-float -msparclite -mstack-bias -msupersparc -munaligned-doubles -mv8 Convex Options -mc1 -mc2 -mc32 -mc34 -mc38 -margcount -mnoargcount -mlong32 -mlong64 -mvolatile-cache -mvolatile-nocache AMD29K Options -m29000 -m29050 -mbw -mnbw -mdw -mndw -mlarge -mnormal -msmall -mkernel-registers -mno-reuse-arg-regs -mno-stack-check -mno-storem-bug -mreuse-arg-regs -msoft-float -mstack-check -mstorem-bug -muser-registers ARM Options -mapcs-frame -mno-apcs-frame -mapcs-26 -mapcs-32 -mapcs-stack-check -mno-apcs-stack-check -mapcs-float -mno-apcs-float -mapcs-reentrant -mno-apcs-reentrant -msched-prolog -mno-sched-prolog -mlittle-endian -mbig-endian -mwords-little-endian -mshort-load-bytes -mno-short-load-bytes -mshort-load-words -mno-short-load-words -msoft-float -mhard-float -mfpe -mthumb-interwork -mno-thumb-interwork -mcpu= -march= -mfpe= -mstructure-size-boundary= -mbsd -mxopen -mno-symrename -mabort-on-noreturn -mno-sched-prolog Thumb Options -mtpcs-frame -mno-tpcs-frame -mtpcs-leaf-frame -mno-tpcs-leaf-frame -mlittle-endian -mbig-endian -mthumb-interwork -mno-thumb-interwork -mstructure-size-boundary= MN10200 Options -mrelax MN10300 Options -mmult-bug -mno-mult-bug -mrelax M32R/D Options -mcode-model=model type -msdata=sdata type -G num M88K Options -m88000 -m88100 -m88110 -mbig-pic -mcheck-zero-division -mhandle-large-shift -midentify-revision -mno-check-zero-division -mno-ocs-debug-info -mno-ocs-frame-position -mno-optimize-arg-area -mno-serialize-volatile -mno-underscores -mocs-debug-info -mocs-frame-position -moptimize-arg-area -mserialize-volatile -mshort-data-num -msvr3 -msvr4 -mtrap-large-shift -muse-div-instruction -mversion-03.00 -mwarn-passed-structs RS/6000 and PowerPC Options -mcpu=cpu type -mtune=cpu type -mpower -mno-power -mpower2 -mno-power2 -mpowerpc -mno-powerpc -mpowerpc-gpopt -mno-powerpc-gpopt -mpowerpc-gfxopt -mno-powerpc-gfxopt -mnew-mnemonics -mno-new-mnemonics -mfull-toc -mminimal-toc -mno-fop-in-toc -mno-sum-in-toc -maix64 -maix32 -mxl-call -mno-xl-call -mthreads -mpe -msoft-float -mhard-float -mmultiple -mno-multiple -mstring -mno-string -mupdate -mno-update -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align -mstrict-align -mno-strict-align -mrelocatable -mno-relocatable -mrelocatable-lib -mno-relocatable-lib -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian -mcall-aix -mcall-sysv -mprototype -mno-prototype -msim -mmvme -mads -myellowknife -memb -msdata -msdata=opt -G num RT Options -mcall-lib-mul -mfp-arg-in-fpregs -mfp-arg-in-gregs -mfull-fp-blocks -mhc-struct-return -min-line-mul -mminimum-fp-blocks -mnohc-struct-return MIPS Options -mabicalls -mcpu=cpu type -membedded-data -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-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 i386 Options -mcpu=cpu type -march=cpu type -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 HPPA Options -march=architecture type -mbig-switch -mdisable-fpregs -mdisable-indexing -mfast-indirect-calls -mgas -mjump-in-delay -mlong-load-store -mno-big-switch -mno-disable-fpregs -mno-disable-indexing -mno-fast-indirect-calls -mno-gas -mno-jump-in-delay -mno-long-load-store -mno-portable-runtime -mno-soft-float -mno-space -mno-space-regs -msoft-float -mpa-risc-1-0 -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime -mschedule=cpu type -mspace -mspace-regs Intel 960 Options -mcpu type -masm-compat -mclean-linkage -mcode-align -mcomplex-addr -mleaf-procedures -mic-compat -mic2.0-compat -mic3.0-compat -mintel-asm -mno-clean-linkage -mno-code-align -mno-complex-addr -mno-leaf-procedures -mno-old-align -mno-strict-align -mno-tail-call -mnumerics -mold-align -msoft-float -mstrict-align -mtail-call DEC Alpha Options -mfp-regs -mno-fp-regs -mno-soft-float -msoft-float -malpha-as -mgas -mieee -mieee-with-inexact -mieee-conformant -mfp-trap-mode=mode -mfp-rounding-mode=mode -mtrap-precision=mode -mbuild-constants -mcpu=cpu type -mbwx -mno-bwx -mcix -mno-cix -mmax -mno-max -mmemory-latency=time Clipper Options -mc300 -mc400 H8/300 Options -mrelax -mh -ms -mint32 -malign-300 SH Options -m1 -m2 -m3 -m3e -mb -ml -mdalign -mrelax System V Options -Qy -Qn -YP,paths -Ym,dir ARC Options -EB -EL -mmangle-cpu -mcpu=cpu -mtext=text section -mdata=data section -mrodata=readonly data section TMS320C3x/C4x Options -mcpu=cpu -mbig -msmall -mregparm -mmemparm -mfast-fix -mmpyi -mbk -mti -mdp-isr-reload -mrpts=count -mrptb -mdb -mloop-unsigned -mparallel-insns -mparallel-mpy -mpreserve-float V850 Options -mlong-calls -mno-long-calls -mep -mno-ep -mprolog-function -mno-prolog-function -mspace -mtda=n -msda=n -mzda=n -mv850 -mbig-switch NS32K Options -m32032 -m32332 -m32532 -m32081 -m32381 -mmult-add -mnomult-add -msoft-float -mrtd -mnortd -mregparam -mnoregparam -msb -mnosb -mbitfield -mnobitfield -mhimem -mnohimem |
-fcall-saved-reg -fcall-used-reg -fexceptions -ffixed-reg -finhibit-size-directive -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 -fargument-alias -fargument-noalias -fargument-noalias-global -fleading-underscore |
2.2 Options Controlling the Kind of Output Controlling the kind of output: an executable, object files, assembler files, or preprocessed source. 2.4 Options Controlling C Dialect Controlling the variant of C language compiled. 2.5 Options Controlling C++ Dialect Variations on C++. 2.6 Options to Request or Suppress Warnings How picky should the compiler be? 2.7 Options for Debugging Your Program or GCC Symbol tables, measurements, and debugging dumps. 2.8 Options That Control Optimization How much optimization? 2.9 Options Controlling the Preprocessor Controlling header files and macro definitions. Also, getting dependency information for Make. 2.10 Passing Options to the Assembler Passing options to the assembler. 2.11 Options for Linking Specifying libraries and so on. 2.12 Options for Directory Search Where to find header files and libraries. Where to find the compiler executable files. 2.13 Specifying Target Machine and Compiler Version Running a cross-compiler, or an old version of GCC.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Compilation can involve up to four stages: preprocessing, compilation proper, assembly and linking, always in that order. The first three stages apply to an individual source file, and end by producing an object file; linking combines all the object files (those newly compiled, and those specified as input) into an executable file.
For any given input file, the file name suffix determines what kind of compilation is done:
file.c
file.i
file.ii
file.m
file.h
file.cc
file.cxx
file.cpp
file.C
file.s
file.S
other
You can specify the input language explicitly with the `-x' option:
-x language
c objective-c c++ c-header cpp-output c++-cpp-output assembler assembler-with-cpp |
-x none
If you only want some of the stages of compilation, you can use
`-x' (or filename suffixes) to tell gcc
where to start, and
one of the options `-c', `-S', or `-E' to say where
gcc
is to stop. Note that some combinations (for example,
`-x cpp-output -E' instruct gcc
to do nothing at all.
-c
By default, the object file name for a source file is made by replacing the suffix `.c', `.i', `.s', etc., with `.o'.
Unrecognized input files, not requiring compilation or assembly, are ignored.
-S
By default, the assembler file name for a source file is made by replacing the suffix `.c', `.i', etc., with `.s'.
Input files that don't require compilation are ignored.
-E
Input files which don't require preprocessing are ignored.
-o file
Since only one output file can be specified, it does not make sense to use `-o' when compiling more than one input file, unless you are producing an executable file as output.
If `-o' is not specified, the default is to put an executable file in `a.out', the object file for `source.suffix' in `source.o', its assembler file in `source.s', and all preprocessed C source on standard output.
-v
-pipe
--help
gcc
. If the -v
option is also specified
then --help
will also be passed on to the various processes
invoked by gcc
, so that they can display the command line options
they accept. If the -W
option is also specified then command
line options which have no documentation associated with them will also
be displayed.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
C++ source files conventionally use one of the suffixes `.C',
`.cc', `.cpp', `.c++', `.cp', or `.cxx';
preprocessed C++ files use the suffix `.ii'. GCC recognizes
files with these names and compiles them as C++ programs even if you
call the compiler the same way as for compiling C programs (usually with
the name gcc
).
However, C++ programs often require class libraries as well as a
compiler that understands the C++ language--and under some
circumstances, you might want to compile programs from standard input,
or otherwise without a suffix that flags them as C++ programs.
g++
is a program that calls GCC with the default language
set to C++, and automatically specifies linking against the C++
library. On many systems, the script g++
is also
installed with the name c++
.
When you compile C++ programs, you may specify many of the same command-line options that you use for compiling programs in any language; or command-line options meaningful for C and related languages; or options that are meaningful only for C++ programs. See section Options Controlling C Dialect, for explanations of options for languages related to C. See section Options Controlling C++ Dialect, for explanations of options that are meaningful only for C++ programs.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The following options control the dialect of C (or languages derived from C, such as C++ and Objective C) that the compiler accepts:
-ansi
This turns off certain features of GCC that are incompatible with ANSI
C (when compiling C code), or of ANSI standard C++ (when compiling C++ code),
such as the asm
and typeof
keywords, and
predefined macros such as unix
and vax
that identify the
type of system you are using. It also enables the undesirable and
rarely used ANSI trigraph feature. For the C compiler,
it disables recognition of C++ style `//' comments as well as
the inline
keyword. For the C++ compiler,
`-foperator-names' is enabled as well.
The alternate keywords __asm__
, __extension__
,
__inline__
and __typeof__
continue to work despite
`-ansi'. You would not want to use them in an ANSI C program, of
course, but it is useful to put them in header files that might be included
in compilations done with `-ansi'. Alternate predefined macros
such as __unix__
and __vax__
are also available, with or
without `-ansi'.
The `-ansi' option does not cause non-ANSI programs to be rejected gratuitously. For that, `-pedantic' is required in addition to `-ansi'. See section 2.6 Options to Request or Suppress Warnings.
The macro __STRICT_ANSI__
is predefined when the `-ansi'
option is used. Some header files may notice this macro and refrain
from declaring certain functions or defining certain macros that the
ANSI standard doesn't call for; this is to avoid interfering with any
programs that might use these names for other things.
The functions alloca
, abort
, exit
, and
_exit
are not builtin functions when `-ansi' is used.
-flang-isoc9x
restrict
keyword.
Even when this option is not specified, you can still use some C9X
features in so far as they do not conflict with previous C standards.
For example, you may use __restrict__
even when -flang-isoc9x
is not specified.
-fno-asm
asm
, inline
or typeof
as a
keyword, so that code can use these words as identifiers. You can use
the keywords __asm__
, __inline__
and __typeof__
instead. `-ansi' implies `-fno-asm'.
In C++, this switch only affects the typeof
keyword, since
asm
and inline
are standard keywords. You may want to
use the `-fno-gnu-keywords' flag instead, as it also disables the
other, C++-specific, extension keywords such as headof
.
-fno-builtin
abort
,
abs
, alloca
, cos
, exit
, fabs
,
ffs
, labs
, memcmp
, memcpy
, sin
,
sqrt
, strcmp
, strcpy
, and strlen
.
GCC normally generates special code to handle certain builtin functions
more efficiently; for instance, calls to alloca
may become single
instructions that adjust the stack directly, and calls to memcpy
may become inline copy loops. The resulting code is often both smaller
and faster, but since the function calls no longer appear as such, you
cannot set a breakpoint on those calls, nor can you change the behavior
of the functions by linking with a different library.
The `-ansi' option prevents alloca
and ffs
from being
builtin functions, since these functions do not have an ANSI standard
meaning.
-fhosted
Assert that compilation takes place in a hosted environment. This implies
`-fbuiltin'. A hosted environment is one in which the
entire standard library is available, and in which main
has a return
type of int
. Examples are nearly everything except a kernel.
This is equivalent to `-fno-freestanding'.
-ffreestanding
Assert that compilation takes place in a freestanding environment. This
implies `-fno-builtin'. A freestanding environment
is one in which the standard library may not exist, and program startup may
not necessarily be at main
. The most obvious example is an OS kernel.
This is equivalent to `-fno-hosted'.
-trigraphs
-traditional
extern
declarations take effect globally even if they
are written inside of a function definition. This includes implicit
declarations of functions.
typeof
, inline
, signed
, const
and volatile
are not recognized. (You can still use the
alternative keywords such as __typeof__
, __inline__
, and
so on.)
unsigned short
and unsigned char
promote
to unsigned int
.
register
are preserved by
longjmp
. Ordinarily, GNU C follows ANSI C: automatic variables
not declared volatile
may be clobbered.
You may wish to use `-fno-builtin' as well as `-traditional' if your program uses names that are normally GNU C builtin functions for other purposes of its own.
You cannot use `-traditional' if you include any header files that rely on ANSI C features. Some vendors are starting to ship systems with ANSI C header files and you cannot use `-traditional' on such systems to compile files that include any system headers.
The `-traditional' option also enables `-traditional-cpp', which is described next.
-traditional-cpp
__STDC__
is not defined when you use
`-traditional', but __GNUC__
is (since the GNU extensions
which __GNUC__
indicates are not affected by
`-traditional'). If you need to write header files that work
differently depending on whether `-traditional' is in use, by
testing both of these predefined macros you can distinguish four
situations: GNU C, traditional GNU C, other ANSI C compilers, and other
old C compilers. The predefined macro __STDC_VERSION__
is also
not defined when you use `-traditional'. See section `Standard Predefined Macros' in The C Preprocessor,
for more discussion of these and other predefined macros.
-fcond-mismatch
-funsigned-char
char
be unsigned, like unsigned char
.
Each kind of machine has a default for what char
should
be. It is either like unsigned char
by default or like
signed char
by default.
Ideally, a portable program should always use signed char
or
unsigned char
when it depends on the signedness of an object.
But many programs have been written to use plain char
and
expect it to be signed, or expect it to be unsigned, depending on the
machines they were written for. This option, and its inverse, let you
make such a program work with the opposite default.
The type char
is always a distinct type from each of
signed char
or unsigned char
, even though its behavior
is always just like one of those two.
-fsigned-char
char
be signed, like signed char
.
Note that this is equivalent to `-fno-unsigned-char', which is the negative form of `-funsigned-char'. Likewise, the option `-fno-signed-char' is equivalent to `-funsigned-char'.
You may wish to use `-fno-builtin' as well as `-traditional' if your program uses names that are normally GNU C builtin functions for other purposes of its own.
You cannot use `-traditional' if you include any header files that rely on ANSI C features. Some vendors are starting to ship systems with ANSI C header files and you cannot use `-traditional' on such systems to compile files that include any system headers.
-fsigned-bitfields
-funsigned-bitfields
-fno-signed-bitfields
-fno-unsigned-bitfields
signed
or unsigned
. By
default, such a bitfield is signed, because this is consistent: the
basic integer types such as int
are signed types.
However, when `-traditional' is used, bitfields are all unsigned no matter what.
-fwritable-strings
Writing into string constants is a very bad idea; "constants" should be constant.
-fallow-single-precision
Traditional K&R C promotes all floating point operations to double precision, regardless of the sizes of the operands. On the architecture for which you are compiling, single precision may be faster than double precision. If you must use `-traditional', but want to use single precision operations when the operands are single precision, use this option. This option has no effect when compiling with ANSI or GNU C conventions (the default).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section describes the command-line options that are only meaningful
for C++ programs; but you can also use most of the GNU compiler options
regardless of what language your program is in. For example, you
might compile a file firstClass.C
like this:
g++ -g -frepo -O -c firstClass.C |
In this example, only `-frepo' is an option meant only for C++ programs; you can use the other options with any language supported by GCC.
Here is a list of options that are only for compiling C++ programs:
-fno-access-control
-fcheck-new
operator new
is non-null
before attempting to modify the storage allocated. The current Working
Paper requires that operator new
never return a null pointer, so
this check is normally unnecessary.
An alternative to using this option is to specify that your
operator new
does not throw any exceptions; if you declare it
`throw()', g++ will check the return value. See also `new
(nothrow)'.
-fconserve-space
main()
has
completed, you may have an object that is being destroyed twice because
two definitions were merged.
This option is no longer useful on most targets, now that support has been added for putting variables into BSS without making them common.
-fdollars-in-identifiers
-fno-elide-constructors
-fexternal-templates
This option is deprecated.
-falt-external-templates
This option is deprecated.
-ffor-scope
-fno-for-scope
The default if neither flag is given to follow the standard, but to allow and give a warning for old-style code that would otherwise be invalid, or have different behavior.
-fno-gnu-keywords
classof
, headof
, signature
,
sigof
or typeof
as a keyword, so that code can use these
words as identifiers. You can use the keywords __classof__
,
__headof__
, __signature__
, __sigof__
, and
__typeof__
instead. `-ansi' implies
`-fno-gnu-keywords'.
-fguiding-decls
This option implies `-fname-mangling-version-0', and will not work with other name mangling versions. Like all options that change the ABI, all C++ code, including libgcc.a must be built with the same setting of this option.
-fhandle-signatures
signature
and sigof
keywords for specifying
abstract types. The default (`-fno-handle-signatures') is not to
recognize them. See section Type Abstraction using Signatures.
-fhonor-std
namespace std
as a namespace, instead of ignoring
it. For compatibility with earlier versions of g++, the compiler will,
by default, ignore namespace-declarations
,
using-declarations
, using-directives
, and
namespace-names
, if they involve std
.
-fhuge-objects
This flag is not useful when compiling with -fvtable-thunks.
Like all options that change the ABI, all C++ code, including libgcc must be built with the same setting of this option.
-fno-implicit-templates
-fno-implicit-inline-templates
-finit-priority
-fno-implement-inlines
-fname-mangling-version-n
template <class T, class U> void foo(T t); |
Like all options that change the ABI, all C++ code, including libgcc must be built with the same setting of this option.
-foperator-names
and
, bitand
,
bitor
, compl
, not
, or
and xor
as
synonyms for the symbols they refer to. `-ansi' implies
`-foperator-names'.
-fno-optional-diags
-fpermissive
-frepo
-fno-rtti
-fstrict-prototype
foo
can take any combination of arguments, as
in C. `-pedantic' implies `-fstrict-prototype' unless
overridden with `-fno-strict-prototype'.
Specifying this option will also suppress implicit declarations of functions.
This flag no longer affects declarations with C++ linkage.
-fsquangle
-fno-squangle
Like all options that change the ABI, all C++ code, including libgcc.a must be built with the same setting of this option.
-ftemplate-depth-n
-fthis-is-variable
this
. The incorporation of user-defined
free store management into C++ has made assignment to `this' an
anachronism. Therefore, by default it is invalid to assign to
this
within a class member function; that is, GNU C++ treats
`this' in a member function of class X
as a non-lvalue of
type `X *'. However, for backwards compatibility, you can make it
valid with `-fthis-is-variable'.
-fvtable-thunks
This option also enables a heuristic for controlling emission of vtables; if a class has any non-inline virtual functions, the vtable will be emitted in the translation unit containing the first one of those.
Like all options that change the ABI, all C++ code, including libgcc.a must be built with the same setting of this option.
-nostdinc++
In addition, these optimization, warning, and code generation options have meanings only for C++ programs:
-fno-default-inline
-Wctor-dtor-privacy (C++ only)
-Wnon-virtual-dtor (C++ only)
-Wreorder (C++ only)
struct A { int i; int j; A(): j (0), i (1) { } }; |
Here the compiler will warn that the member initializers for `i' and `j' will be rearranged to match the declaration order of the members.
The following `-W...' options are not affected by `-Wall'.
-Weffc++ (C++ only)
-Wno-deprecated (C++ only)
-Wno-non-template-friend (C++ only)
-Wold-style-cast (C++ only)
-Woverloaded-virtual (C++ only)
-Wno-pmf-conversions (C++ only)
-Wsign-promo (C++ only)
-Wsynth (C++ only)
struct A { operator int (); A& operator = (int); }; main () { A a,b; a = b; } |
In this example, g++ will synthesize a default `A& operator = (const A&);', while cfront will use the user-defined `operator ='.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Warnings are diagnostic messages that report constructions which are not inherently erroneous but which are risky or suggest there may have been an error.
You can request many specific warnings with options beginning `-W', for example `-Wimplicit' to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning `-Wno-' to turn off warnings; for example, `-Wno-implicit'. This manual lists only one of the two forms, whichever is not the default.
These options control the amount and kinds of warnings produced by GCC:
-fsyntax-only
-pedantic
Valid ANSI C and ISO C++ programs should compile properly with or without this option (though a rare few will require `-ansi'). However, without this option, certain GNU extensions and traditional C and C++ features are supported as well. With this option, they are rejected.
`-pedantic' does not cause warning messages for use of the
alternate keywords whose names begin and end with `__'. Pedantic
warnings are also disabled in the expression that follows
__extension__
. However, only system header files should use
these escape routes; application programs should avoid them.
See section 4.35 Alternate Keywords.
This option is not intended to be useful; it exists only to satisfy pedants who would otherwise claim that GCC fails to support the ANSI standard.
Some users try to use `-pedantic' to check programs for strict ANSI C conformance. They soon find that it does not do quite what they want: it finds some non-ANSI practices, but not all--only those for which ANSI C requires a diagnostic.
A feature to report any failure to conform to ANSI C might be useful in some instances, but would require considerable additional work and would be quite different from `-pedantic'. We don't have plans to support such a feature in the near future.
-pedantic-errors
-w
-Wno-import
-Wchar-subscripts
char
. This is a common cause
of error, as programmers often forget that this type is signed on some
machines.
-Wcomment
-Wformat
printf
and scanf
, etc., to make sure that
the arguments supplied have types appropriate to the format string
specified.
-Wimplicit-int
-Wimplicit-function-declaration
-Werror-implicit-function-declaration
-Wimplicit
-Wmain
-Wmultichar
-Wparentheses
Also warn about constructions where there may be confusion to which
if
statement an else
branch belongs. Here is an example of
such a case:
{ if (a) if (b) foo (); else bar (); } |
In C, every else
branch belongs to the innermost possible if
statement, which in this example is if (b)
. This is often not
what the programmer expected, as illustrated in the above example by
indentation the programmer chose. When there is the potential for this
confusion, GNU C will issue a warning when this flag is specified.
To eliminate the warning, add explicit braces around the innermost
if
statement so there is no way the else
could belong to
the enclosing if
. The resulting code would look like this:
{ if (a) { if (b) foo (); else bar (); } } |
-Wreturn-type
int
. Also warn about any return
statement with no
return-value in a function whose return-type is not void
.
-Wswitch
switch
statement has an index of enumeral type
and lacks a case
for one or more of the named codes of that
enumeration. (The presence of a default
label prevents this
warning.) case
labels outside the enumeration range also
provoke warnings when this option is used.
-Wtrigraphs
-Wunused
In order to get a warning about an unused function parameter, you must specify both `-W' and `-Wunused'.
To suppress this warning for an expression, simply cast it to void. For unused variables, parameters and labels, use the `unused' attribute (see section 4.29 Specifying Attributes of Variables).
-Wuninitialized
These warnings are possible only in optimizing compilation, because they require data flow information that is computed only when optimizing. If you don't specify `-O', you simply won't get these warnings.
These warnings occur only for variables that are candidates for
register allocation. Therefore, they do not occur for a variable that
is declared volatile
, or whose address is taken, or whose size
is other than 1, 2, 4 or 8 bytes. Also, they do not occur for
structures, unions or arrays, even when they are in registers.
Note that there may be no warning about a variable that is used only to compute a value that itself is never used, because such computations may be deleted by data flow analysis before the warnings are printed.
These warnings are made optional because GCC is not smart enough to see all the reasons why the code might be correct despite appearing to have an error. Here is one example of how this can happen:
{ int x; switch (y) { case 1: x = 1; break; case 2: x = 4; break; case 3: x = 5; } foo (x); } |
If the value of y
is always 1, 2 or 3, then x
is
always initialized, but GCC doesn't know this. Here is
another common case:
{ int save_y; if (change_y) save_y = y, y = new_y; ... if (change_y) y = save_y; } |
This has no bug because save_y
is used only if it is set.
Some spurious warnings can be avoided if you declare all the functions
you use that never return as noreturn
. See section 4.23 Declaring Attributes of Functions.
-Wunknown-pragmas
-Wall
The following `-W...' options are not implied by `-Wall'. Some of them warn about constructions that users generally do not consider questionable, but which occasionally you might wish to check for; others warn about constructions that are necessary or hard to avoid in some cases, and there is no simple way to modify the code to suppress the warning.
-W
longjmp
. These warnings as well are possible only in
optimizing compilation.
The compiler sees only the calls to setjmp
. It cannot know
where longjmp
will be called; in fact, a signal handler could
call it at any point in the code. As a result, you may get a warning
even when there is in fact no problem because longjmp
cannot
in fact be called at the place which would cause a problem.
foo (a) { if (a > 0) return a; } |
static
are not the first things in
a declaration. According to the C Standard, this usage is obsolescent.
x.h
:
struct s { int f, g; }; struct t { struct s h; int i; }; struct t x = { 1, 2, 3 }; |
x.h
would be implicitly initialized to zero:
struct s { int f, g, h; }; struct s x = { 3, 4 }; |
-Wtraditional
switch
statement has an operand of type long
.
static
function declaration follows a static
one.
This construct is not accepted by some traditional C compilers.
-Wundef
-Wshadow
-Wid-clash-len
-Wlarger-than-len
-Wpointer-arith
void
. GNU C assigns these types a size of 1, for
convenience in calculations with void *
pointers and pointers
to functions.
-Wbad-function-cast
int malloc()
is cast to anything *
.
-Wcast-qual
const char *
is cast
to an ordinary char *
.
-Wcast-align
char *
is cast to
an int *
on machines where integers can only be accessed at
two- or four-byte boundaries.
-Wwrite-strings
const char[length]
so that
copying the address of one into a non-const
char *
pointer will get a warning. These warnings will help you find at
compile time code that can try to write into a string constant, but
only if you have been very careful about using const
in
declarations and prototypes. Otherwise, it will just be a nuisance;
this is why we did not make `-Wall' request these warnings.
-Wconversion
Also, warn if a negative integer constant expression is implicitly
converted to an unsigned type. For example, warn about the assignment
x = -1
if x
is unsigned. But do not warn about explicit
casts like (unsigned) -1
.
-Wsign-compare
-Waggregate-return
-Wstrict-prototypes
-Wmissing-prototypes
-Wmissing-declarations
-Wmissing-noreturn
noreturn
.
Note these are only possible candidates, not absolute ones. Care should
be taken to manually verify functions actually do not ever return before
adding the noreturn
attribute, otherwise subtle code generation
bugs could be introduced.
-Wredundant-decls
-Wnested-externs
extern
declaration is encountered within an function.
-Winline
-Wlong-long
-Werror
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
GCC has various special options that are used for debugging either your program or GCC:
-g
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
-gstabs
-gstabs+
-gcoff
-gxcoff
-gxcoff+
-gdwarf
-gdwarf+
-gdwarf-2
-glevel
-ggdblevel
-gstabslevel
-gcofflevel
-gxcofflevel
-gdwarflevel
-gdwarf-2level
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
prof
. You must use this option when compiling
the source files you want data about, and you must also use it when
linking.
-pg
gprof
. You must use this option when compiling
the source files you want data about, and you must also use it when
linking.
-a
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
-ax
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__
__bb_hidecall__
__bb_showret__
__bb_trace__
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
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
gcov
code-coverage utility
(see section gcov
: a GCC Test Coverage Program).
The data file names begin with the name of your source file:
sourcename.bb
gcov
uses to
associate basic block execution counts with line numbers.
sourcename.bbg
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').
-Q
-dletters
-fdump-unnumbered
-fpretend-float
-save-temps
-print-file-name=library
-print-prog-name=program
-print-libgcc-file-name
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
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 2.16 Environment Variables Affecting GCC.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These options control various sorts of optimizations:
-O
-O1
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
`-O2' turns on all optional optimizations except for loop unrolling, function inlining, and strict aliasing optimizations. 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
-O0
-Os
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
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
-fno-defer-pop
-fforce-mem
-fforce-addr
-fomit-frame-pointer
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 17.5 Register Usage.
-fno-inline
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
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
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
static
, nevertheless output a separate run-time
callable version of the function. This switch does not affect
extern inline
functions.
-fkeep-static-consts
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
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
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 ANSI rules/specifications for math functions.
The following options control specific optimizations. The `-O2' option turns on all of these optimizations except `-funroll-loops' `-funroll-all-loops', and `-fstrict-aliasing'. 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
-fthread-jumps
-fcse-follow-jumps
if
statement with an
else
clause, CSE will follow the jump when the condition
tested is false.
-fcse-skip-blocks
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
-frerun-loop-opt
-fgcse
-fexpensive-optimizations
-foptimize-register-moves
-fregmove
Note -fregmove
and -foptimize-register-moves
are the same
optimization.
-fdelayed-branch
-fschedule-insns
-fschedule-insns2
-ffunction-sections
-fdata-sections
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
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
-funroll-all-loops
-fmove-all-movables
-freduce-all-givs
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
-fbranch-probabilities
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
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; } |
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
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These options control the C preprocessor, which is run on each C source file before actual compilation.
If you use the `-E' option, nothing is done except preprocessing. Some of these options make sense only together with `-E' because they cause the preprocessor output to be unsuitable for actual compilation.
-include file
-imacros file
Any `-D' and `-U' options on the command line are always processed before `-imacros file', regardless of the order in which they are written. All the `-include' and `-imacros' options are processed in the order in which they are written.
-idirafter dir
-iprefix prefix
-iwithprefix dir
-iwithprefixbefore dir
-isystem dir
-nostdinc
By using both `-nostdinc' and `-I-', you can limit the include-file search path to only those directories you specify explicitly.
-undef
-E
-C
-P
-M
make
describing the dependencies of each object file. For each source file,
the preprocessor outputs one make
-rule whose target is the object
file name for that source file and whose dependencies are all the
#include
header files it uses. This rule may be a single line or
may be continued with `\'-newline if it is long. The list of rules
is printed on standard output instead of the preprocessed C program.
`-M' implies `-E'.
Another way to specify output of a make
rule is by setting
the environment variable DEPENDENCIES_OUTPUT
(see section 2.16 Environment Variables Affecting GCC).
-MM
-MD
In Mach, you can use the utility md
to merge multiple dependency
files into a single dependency file suitable for using with the `make'
command.
-MMD
-MG
-H
-Aquestion(answer)
-Dmacro
-Dmacro=defn
-Umacro
-dM
-dD
-dN
-trigraphs
-Wp,option
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
You can pass options to the assembler.
-Wa,option
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These options come into play when the compiler links object files into an executable output file. They are meaningless if the compiler is not doing a link step.
object-file-name
-c
-S
-E
-llibrary
It makes a difference where in the command you write this option; the linker searches processes libraries and object files in the order they are specified. Thus, `foo.o -lz bar.o' searches library `z' after file `foo.o' but before `bar.o'. If `bar.o' refers to functions in `z', those functions may not be loaded.
The linker searches a standard list of directories for the library, which is actually a file named `liblibrary.a'. The linker then uses this file as if it had been specified precisely by name.
The directories searched include several standard system directories plus any that you specify with `-L'.
Normally the files found this way are library files--archive files whose members are object files. The linker handles an archive file by scanning through it for members which define symbols that have so far been referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the usual fashion. The only difference between using an `-l' option and specifying a file name is that `-l' surrounds library with `lib' and `.a' and searches several directories.
-lobjc
-nostartfiles
-nostdlib
or -nodefaultlibs
is used.
-nodefaultlibs
-nostartfiles
is used. The compiler may generate calls to memcmp, memset, and memcpy
for System V (and ANSI C) environments or to bcopy and bzero for
BSD environments. These entries are usually resolved by entries in
libc. These entry points should be supplied through some other
mechanism when this option is specified.
-nostdlib
One of the standard libraries bypassed by `-nostdlib' and
`-nodefaultlibs' is `libgcc.a', a library of internal subroutines
that GCC uses to overcome shortcomings of particular machines, or special
needs for some languages.
(See section Interfacing to GCC Output, for more discussion of
`libgcc.a'.)
In most cases, you need `libgcc.a' even when you want to avoid
other standard libraries. In other words, when you specify `-nostdlib'
or `-nodefaultlibs' you should usually specify `-lgcc' as well.
This ensures that you have no unresolved references to internal GCC
library subroutines. (For example, `__main', used to ensure C++
constructors will be called; see section collect2
.)
-s
-static
-shared
-symbolic
-Xlinker option
If you want to pass an option that takes an argument, you must use `-Xlinker' twice, once for the option and once for the argument. For example, to pass `-assert definitions', you must write `-Xlinker -assert -Xlinker definitions'. It does not work to write `-Xlinker "-assert definitions"', because this passes the entire string as a single argument, which is not what the linker expects.
-Wl,option
-u symbol
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These options specify directories to search for header files, for libraries and for parts of the compiler:
-Idir
-I-
If additional directories are specified with `-I' options after the `-I-', these directories are searched for all `#include' directives. (Ordinarily all `-I' directories are used this way.)
In addition, the `-I-' option inhibits the use of the current directory (where the current input file came from) as the first search directory for `#include "file"'. There is no way to override this effect of `-I-'. With `-I.' you can specify searching the directory which was current when the compiler was invoked. That is not exactly the same as what the preprocessor does by default, but it is often satisfactory.
`-I-' does not inhibit the use of the standard system directories for header files. Thus, `-I-' and `-nostdinc' are independent.
-Ldir
-Bprefix
The compiler driver program runs one or more of the subprograms `cpp', `cc1', `as' and `ld'. It tries prefix as a prefix for each program it tries to run, both with and without `machine/version/' (see section 2.13 Specifying Target Machine and Compiler Version).
For each subprogram to be run, the compiler driver first tries the `-B' prefix, if any. If that name is not found, or if `-B' was not specified, the driver tries two standard prefixes, which are `/usr/lib/gcc/' and `/usr/local/lib/gcc-lib/'. If neither of those results in a file name that is found, the unmodified program name is searched for using the directories specified in your `PATH' environment variable.
`-B' prefixes that effectively specify directory names also apply to libraries in the linker, because the compiler translates these options into `-L' options for the linker. They also apply to includes files in the preprocessor, because the compiler translates these options into `-isystem' options for the preprocessor. In this case, the compiler appends `include' to the prefix.
The run-time support file `libgcc.a' can also be searched for using the `-B' prefix, if needed. If it is not found there, the two standard prefixes above are tried, and that is all. The file is left out of the link if it is not found by those means.
Another way to specify a prefix much like the `-B' prefix is to use
the environment variable GCC_EXEC_PREFIX
. See section 2.16 Environment Variables Affecting GCC.
-specs=file
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
By default, GCC compiles code for the same type of machine that you are using. However, it can also be installed as a cross-compiler, to compile for some other type of machine. In fact, several different configurations of GCC, for different target machines, can be installed side by side. Then you specify which one to use with the `-b' option.
In addition, older and newer versions of GCC can be installed side by side. One of them (probably the newest) will be the default, but you may sometimes wish to use another.
-b machine
The value to use for machine is the same as was specified as the machine type when configuring GCC as a cross-compiler. For example, if a cross-compiler was configured with `configure i386v', meaning to compile for an 80386 running System V, then you would specify `-b i386v' to run that cross compiler.
When you do not specify `-b', it normally means to compile for the same type of machine that you are using.
-V version
The default version, when you do not specify `-V', is the last version of GCC that you installed.
The `-b' and `-V' options actually work by controlling part of the file name used for the executable files and libraries used for compilation. A given version of GCC, for a given target machine, is normally kept in the directory `/usr/local/lib/gcc-lib/machine/version'.
Thus, sites can customize the effect of `-b' or `-V' either by changing the names of these directories or adding alternate names (or symbolic links). If in directory `/usr/local/lib/gcc-lib/' the file `80386' is a link to the file `i386v', then `-b 80386' becomes an alias for `-b i386v'.
In one respect, the `-b' or `-V' do not completely change
to a different compiler: the top-level driver program gcc
that you originally invoked continues to run and invoke the other
executables (preprocessor, compiler per se, assembler and linker)
that do the real work. However, since no real work is done in the
driver program, it usually does not matter that the driver program
in use is not the one for the specified target and version.
The only way that the driver program depends on the target machine is in the parsing and handling of special machine-specific options. However, this is controlled by a file which is found, along with the other executables, in the directory for the specified version and target machine. As a result, a single installed driver program adapts to any specified target machine and compiler version.
The driver program executable does control one significant thing, however: the default version and target machine. Therefore, you can install different instances of the driver program, compiled for different targets or versions, under different names.
For example, if the driver for version 2.0 is installed as ogcc
and that for version 2.1 is installed as gcc
, then the command
gcc
will use version 2.1 by default, while ogcc
will use
2.0 by default. However, you can choose either version with either
command with the `-V' option.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These are the `-m' options defined for the 68000 series. The default values for these options depends on which style of 68000 was selected when the compiler was configured; the defaults for the most common choices are given below.
-m68000
-mc68000
Use this option for microcontrollers with a 68000 or EC000 core, including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
-m68020
-mc68020
-m68881
-m68030
-m68040
This option inhibits the use of 68881/68882 instructions that have to be emulated by software on the 68040. Use this option if your 68040 does not have code to emulate those instructions.
-m68060
This option inhibits the use of 68020 and 68881/68882 instructions that have to be emulated by software on the 68060. Use this option if your 68060 does not have code to emulate those instructions.
-mcpu32
Use this option for microcontrollers with a CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334, 68336, 68340, 68341, 68349 and 68360.
-m5200
Use this option for microcontroller with a 5200 core, including the MCF5202, MCF5203, MCF5204 and MCF5202.
-m68020-40
-m68020-60
-mfpa
-msoft-float
-mshort
int
to be 16 bits wide, like short int
.
-mnobitfield
-mbitfield
-mrtd
rtd
instruction, which pops their arguments while returning. This
saves one instruction in the caller since there is no need to pop
the arguments there.
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.)
The rtd
instruction is supported by the 68010, 68020, 68030,
68040, 68060 and CPU32 processors, but not by the 68000 or 5200.
-malign-int
-mno-align-int
int
, long
, long long
,
float
, double
, and long double
variables on a 32-bit
boundary (`-malign-int') or a 16-bit boundary (`-mno-align-int').
Aligning variables on 32-bit boundaries produces code that runs somewhat
faster on processors with 32-bit busses at the expense of more memory.
Warning: if you use the `-malign-int' switch, GCC will align structures containing the above types differently than most published application binary interface specifications for the m68k.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for the Vax:
-munix
aobleq
and so on)
that the Unix assembler for the Vax cannot handle across long
ranges.
-mgnu
-mg
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' switches are supported on the SPARC:
-mno-app-regs
-mapp-regs
To be fully SVR4 ABI compliant at the cost of some performance loss, specify `-mno-app-regs'. You should compile libraries and system software with this option.
-mfpu
-mhard-float
-mno-fpu
-msoft-float
`-msoft-float' changes the calling convention in the output file; therefore, it is only useful if you compile all of a program with this option. In particular, you need to compile `libgcc.a', the library that comes with GCC, with `-msoft-float' in order for this to work.
-mhard-quad-float
-msoft-quad-float
As of this writing, there are no sparc implementations that have hardware support for the quad-word floating point instructions. They all invoke a trap handler for one of these instructions, and then the trap handler emulates the effect of the instruction. Because of the trap handler overhead, this is much slower than calling the ABI library routines. Thus the `-msoft-quad-float' option is the default.
-mno-epilogue
-mepilogue
With `-mno-epilogue', the compiler tries to emit exit code inline at every function exit.
-mno-flat
-mflat
With `-mno-flat' (the default), the compiler emits save/restore instructions (except for leaf functions) and is the normal mode of operation.
-mno-unaligned-doubles
-munaligned-doubles
With `-munaligned-doubles', GCC assumes that doubles have 8 byte alignment only if they are contained in another type, or if they have an absolute address. Otherwise, it assumes they have 4 byte alignment. Specifying this option avoids some rare compatibility problems with code generated by other compilers. It is not the default because it results in a performance loss, especially for floating point code.
-mv8
-msparclite
By default (unless specifically configured for the Fujitsu SPARClite), GCC generates code for the v7 variant of the SPARC architecture.
`-mv8' will give you SPARC v8 code. The only difference from v7 code is that the compiler emits the integer multiply and integer divide instructions which exist in SPARC v8 but not in SPARC v7.
`-msparclite' will give you SPARClite code. This adds the integer
multiply, integer divide step and scan (ffs
) instructions which
exist in SPARClite but not in SPARC v7.
These options are deprecated and will be deleted in a future GCC release. They have been replaced with `-mcpu=xxx'.
-mcypress
-msupersparc
With `-mcypress' (the default), the compiler optimizes code for the Cypress CY7C602 chip, as used in the SparcStation/SparcServer 3xx series. This is also appropriate for the older SparcStation 1, 2, IPX etc.
With `-msupersparc' the compiler optimizes code for the SuperSparc cpu, as used in the SparcStation 10, 1000 and 2000 series. This flag also enables use of the full SPARC v8 instruction set.
These options are deprecated and will be deleted in a future GCC release. They have been replaced with `-mcpu=xxx'.
-mcpu=cpu_type
Default instruction scheduling parameters are used for values that select an architecture and not an implementation. These are `v7', `v8', `sparclite', `sparclet', `v9'.
Here is a list of each supported architecture and their supported implementations.
v7: cypress v8: supersparc, hypersparc sparclite: f930, f934, sparclite86x sparclet: tsc701 v9: ultrasparc |
-mtune=cpu_type
The same values for `-mcpu='cpu_type are used for
`-mtune='
cpu_type, though the only useful values are those that
select a particular cpu implementation: `cypress', `supersparc',
`hypersparc', `f930', `f934', `sparclite86x',
`tsc701', `ultrasparc'.
-malign-loops=num
-malign-jumps=num
-malign-functions=num
These `-m' switches are supported in addition to the above on the SPARCLET processor.
-mlittle-endian
-mlive-g0
%g0
as a normal register.
GCC will continue to clobber it as necessary but will not assume
it always reads as 0.
-mbroken-saverestore
save
and
restore
instructions. Early versions of the SPARCLET processor do
not correctly handle save
and restore
instructions used with
arguments. They correctly handle them used without arguments. A save
instruction used without arguments increments the current window pointer
but does not allocate a new stack frame. It is assumed that the window
overflow trap handler will properly handle this case as will interrupt
handlers.
These `-m' switches are supported in addition to the above on SPARC V9 processors in 64 bit environments.
-mlittle-endian
-m32
-m64
-mcmodel=medlow
-mcmodel=medmid
-mcmodel=medany
-mcmodel=embmedany
-mstack-bias
-mno-stack-bias
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for Convex:
-mc1
__convex__c1__
is defined.
-mc2
__convex_c2__
is defined.
-mc32
__convex_c32__
is defined.
-mc34
__convex_c34__
is defined.
-mc38
__convex_c38__
is defined.
-margcount
-mnoargcount
-mvolatile-cache
-mvolatile-nocache
-mlong32
-mlong64
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for the AMD Am29000:
-mdw
DW
bit is set, i.e., that byte and
halfword operations are directly supported by the hardware. This is the
default.
-mndw
DW
bit is not set.
-mbw
-mnbw
-msmall
call
instruction to be used instead
of a const
, consth
, calli
sequence.
-mnormal
call
instructions only when
calling functions in the same file and calli
instructions
otherwise. This works if each file occupies less than 256 KB but allows
the entire executable to be larger than 256 KB. This is the default.
-mlarge
calli
instructions. Specify this option if you expect
a single file to compile into more than 256 KB of code.
-m29050
-m29000
-mkernel-registers
gr64-gr95
instead of to
registers gr96-gr127
. This option can be used when compiling
kernel code that wants a set of global registers disjoint from that used
by user-mode code.
Note that when this option is used, register names in `-f' flags must use the normal, user-mode, names.
-muser-registers
gr96-gr127
. This is the
default.
-mstack-check
-mno-stack-check
__msp_check
after each stack
adjustment. This is often used for kernel code.
-mstorem-bug
-mno-storem-bug
-mno-reuse-arg-regs
-mreuse-arg-regs
-mno-impure-text
-mimpure-text
-msoft-float
-mno-multm
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for Advanced RISC Machines (ARM) architectures:
-mapcs-frame
-mapcs
-mapcs-26
-mapcs-32
-mapcs-stack-check
-mapcs-float
-mapcs-reentrant
-mthumb-interwork
-mno-sched-prolog
-mhard-float
-msoft-float
`-msoft-float' changes the calling convention in the output file; therefore, it is only useful if you compile all of a program with this option. In particular, you need to compile `libgcc.a', the library that comes with GCC, with `-msoft-float' in order for this to work.
-mlittle-endian
-mbig-endian
-mwords-little-endian
-mshort-load-bytes
-mno-short-load-bytes
-mshort-load-words
-mno-short-load-words
-mbsd
-mxopen
-mno-symrename
-mcpu=<name>
-mtune=<name>
-march=<name>
-mfpe=<number>
-mfp=<number>
-mstructure-size-boundary=<n>
-mabort-on-noreturn
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
-mthumb-interwork
-mtpcs-frame
-mtpcs-leaf-frame
-mlittle-endian
-mbig-endian
-mstructure-size-boundary=<n>
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
-mrelax
This option makes symbolic debugging impossible.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
-mmult-bug
-mno-mult-bug
-mrelax
This option makes symbolic debugging impossible.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for Mitsubishi M32R/D architectures:
-mcode-model=small
ld24
instruction), and assume all subroutines
are reachable with the bl
instruction.
This is the default.
The addressability of a particular object can be set with the
model
attribute.
-mcode-model=medium
seth/add3
instructions to load their addresses), and
assume all subroutines are reachable with the bl
instruction.
-mcode-model=large
seth/add3
instructions to load their addresses), and
assume subroutines may not be reachable with the bl
instruction
(the compiler will generate the much slower seth/add3/jl
instruction sequence).
-msdata=none
section
attribute has been specified).
This is the default.
The small data area consists of sections `.sdata' and `.sbss'.
Objects may be explicitly put in the small data area with the
section
attribute using one of these sections.
-msdata=sdata
-msdata=use
-G num
All modules should be compiled with the same `-G num' value. Compiling with different values of num may or may not work; if it doesn't the linker will give an error message - incorrect code will not be generated.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for Motorola 88k architectures:
-m88000
-m88100
-m88110
-mbig-pic
-midentify-revision
ident
directive in the assembler output recording the
source file name, compiler name and version, timestamp, and compilation
flags used.
-mno-underscores
-mocs-debug-info
-mno-ocs-debug-info
-mocs-frame-position
-mno-ocs-frame-position
-moptimize-arg-area
-mno-optimize-arg-area
-mshort-data-num
r0
,
which allows loading a value using a single instruction (rather than the
usual two). You control which data references are affected by
specifying num with this option. For example, if you specify
`-mshort-data-512', then the data references affected are those
involving displacements of less than 512 bytes.
`-mshort-data-num' is not effective for num greater
than 64k.
-mserialize-volatile
-mno-serialize-volatile
The order of memory references made by the MC88110 processor does not always match the order of the instructions requesting those references. In particular, a load instruction may execute before a preceding store instruction. Such reordering violates sequential consistency of volatile memory references, when there are multiple processors. When consistency must be guaranteed, GNU C generates special instructions, as needed, to force execution in the proper order.
The MC88100 processor does not reorder memory references and so always provides sequential consistency. However, by default, GNU C generates the special instructions to guarantee consistency even when you use `-m88100', so that the code may be run on an MC88110 processor. If you intend to run your code only on the MC88100 processor, you may use `-mno-serialize-volatile'.
The extra code generated to guarantee consistency may affect the performance of your application. If you know that you can safely forgo this guarantee, you may use `-mno-serialize-volatile'.
-msvr4
-msvr3
`-msvr4' is the default for the m88k-motorola-sysv4 and m88k-dg-dgux m88k configurations. `-msvr3' is the default for all other m88k configurations.
-mversion-03.00
-mno-check-zero-division
-mcheck-zero-division
Some models of the MC88100 processor fail to trap upon integer division by zero under certain conditions. By default, when compiling code that might be run on such a processor, GNU C generates code that explicitly checks for zero-valued divisors and traps with exception number 503 when one is detected. Use of mno-check-zero-division suppresses such checking for code generated to run on an MC88100 processor.
GNU C assumes that the MC88110 processor correctly detects all instances of integer division by zero. When `-m88110' is specified, both `-mcheck-zero-division' and `-mno-check-zero-division' are ignored, and no explicit checks for zero-valued divisors are generated.
-muse-div-instruction
On the MC88100 processor the signed integer division instruction div) traps to the operating system on a negative operand. The operating system transparently completes the operation, but at a large cost in execution time. By default, when compiling code that might be run on an MC88100 processor, GNU C emulates signed integer division using the unsigned integer division instruction divu), thereby avoiding the large penalty of a trap to the operating system. Such emulation has its own, smaller, execution cost in both time and space. To the extent that your code's important signed integer division operations are performed on two nonnegative operands, it may be desirable to use the div instruction directly.
On the MC88110 processor the div instruction (also known as the divs instruction) processes negative operands without trapping to the operating system. When `-m88110' is specified, `-muse-div-instruction' is ignored, and the div instruction is used for signed integer division.
Note that the result of dividing INT_MIN by -1 is undefined. In particular, the behavior of such a division with and without `-muse-div-instruction' may differ.
-mtrap-large-shift
-mhandle-large-shift
-mwarn-passed-structs
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for the IBM RS/6000 and PowerPC:
-mpower
-mno-power
-mpower2
-mno-power2
-mpowerpc
-mno-powerpc
-mpowerpc-gpopt
-mno-powerpc-gpopt
-mpowerpc-gfxopt
-mno-powerpc-gfxopt
-mpowerpc64
-mno-powerpc64
Neither architecture is a subset of the other. However there is a large common subset of instructions supported by both. An MQ register is included in processors supporting the POWER architecture.
You use these options to specify which instructions are available on the processor you are using. The default value of these options is determined when configuring GCC. Specifying the `-mcpu=cpu_type' overrides the specification of these options. We recommend you use the `-mcpu=cpu_type' option rather than the options listed above.
The `-mpower' option allows GCC to generate instructions that are found only in the POWER architecture and to use the MQ register. Specifying `-mpower2' implies `-power' and also allows GCC to generate instructions that are present in the POWER2 architecture but not the original POWER architecture.
The `-mpowerpc' option allows GCC to generate instructions that are found only in the 32-bit subset of the PowerPC architecture. Specifying `-mpowerpc-gpopt' implies `-mpowerpc' and also allows GCC to use the optional PowerPC architecture instructions in the General Purpose group, including floating-point square root. Specifying `-mpowerpc-gfxopt' implies `-mpowerpc' and also allows GCC to use the optional PowerPC architecture instructions in the Graphics group, including floating-point select.
The `-mpowerpc64' option allows GCC to generate the additional 64-bit instructions that are found in the full PowerPC64 architecture and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to `-mno-powerpc64'.
If you specify both `-mno-power' and `-mno-powerpc', GCC will use only the instructions in the common subset of both architectures plus some special AIX common-mode calls, and will not use the MQ register. Specifying both `-mpower' and `-mpowerpc' permits GCC to use any instruction from either architecture and to allow use of the MQ register; specify this for the Motorola MPC601.
-mnew-mnemonics
-mold-mnemonics
GCC defaults to the mnemonics appropriate for the architecture in use. Specifying `-mcpu=cpu_type' sometimes overrides the value of these option. Unless you are building a cross-compiler, you should normally not specify either `-mnew-mnemonics' or `-mold-mnemonics', but should instead accept the default.
-mcpu=cpu_type
Specifying any of the following options: `-mcpu=rios1', `-mcpu=rios2', `-mcpu=rsc', `-mcpu=power', or `-mcpu=power2' enables the `-mpower' option and disables the `-mpowerpc' option; `-mcpu=601' enables both the `-mpower' and `-mpowerpc' options. All of `-mcpu=602', `-mcpu=603', `-mcpu=603e', `-mcpu=604', `-mcpu=620', enable the `-mpowerpc' option and disable the `-mpower' option. Exactly similarly, all of `-mcpu=403', `-mcpu=505', `-mcpu=821', `-mcpu=860' and `-mcpu=powerpc' enable the `-mpowerpc' option and disable the `-mpower' option. `-mcpu=common' disables both the `-mpower' and `-mpowerpc' options.
AIX versions 4 or greater selects `-mcpu=common' by default, so that code will operate on all members of the RS/6000 and PowerPC families. In that case, GCC will use only the instructions in the common subset of both architectures plus some special AIX common-mode calls, and will not use the MQ register. GCC assumes a generic processor model for scheduling purposes.
Specifying any of the options `-mcpu=rios1', `-mcpu=rios2', `-mcpu=rsc', `-mcpu=power', or `-mcpu=power2' also disables the `new-mnemonics' option. Specifying `-mcpu=601', `-mcpu=602', `-mcpu=603', `-mcpu=603e', `-mcpu=604', `620', `403', or `-mcpu=powerpc' also enables the `new-mnemonics' option.
Specifying `-mcpu=403', `-mcpu=821', or `-mcpu=860' also enables the `-msoft-float' option.
-mtune=cpu_type
-mfull-toc
-mno-fp-in-toc
-mno-sum-in-toc
-mminimal-toc
If you receive a linker error message that saying you have overflowed the available TOC space, you can reduce the amount of TOC space used with the `-mno-fp-in-toc' and `-mno-sum-in-toc' options. `-mno-fp-in-toc' prevents GCC from putting floating-point constants in the TOC and `-mno-sum-in-toc' forces GCC to generate code to calculate the sum of an address and a constant at run-time instead of putting that sum into the TOC. You may specify one or both of these options. Each causes GCC to produce very slightly slower and larger code at the expense of conserving TOC space.
If you still run out of space in the TOC even when you specify both of these options, specify `-mminimal-toc' instead. This option causes GCC to make only one TOC entry for every file. When you specify this option, GCC will produce code that is slower and larger but which uses extremely little TOC space. You may wish to use this option only on files that contain less frequently executed code.
-maix64
-maix32
long
type, and the infrastructure needed to support them.
Specifying `-maix64' implies `-mpowerpc64' and
`-mpowerpc', while `-maix32' disables the 64-bit ABI and
implies `-mno-powerpc64'. GCC defaults to `-maix32'.
-mxl-call
-mno-xl-call
-mthreads
-mpe
-msoft-float
-mhard-float
-mmultiple
-mno-multiple
-mstring
-mno-string
-mupdate
-mno-update
-mfused-madd
-mno-fused-madd
-mno-bit-align
-mbit-align
For example, by default a structure containing nothing but 8
unsigned
bitfields of length 1 would be aligned to a 4 byte
boundary and have a size of 4 bytes. By using `-mno-bit-align',
the structure would be aligned to a 1 byte boundary and be one byte in
size.
-mno-strict-align
-mstrict-align
-mrelocatable
-mno-relocatable
-mrelocatable-lib
-mno-relocatable-lib
-mno-toc
-mtoc
-mlittle
-mlittle-endian
-mbig
-mbig-endian
-mcall-sysv
-mcall-sysv-eabi
-mcall-sysv-noeabi
-mcall-aix
-mcall-solaris
-mcall-linux
-mprototype
-mno-prototype
-msim
-mmvme
-mads
-myellowknife
-memb
-meabi
-mno-eabi
-meabi
means that the stack is aligned to an 8 byte boundary, a function
__eabi
is called to from main
to set up the eabi
environment, and the `-msdata' option can use both r2
and
r13
to point to two separate small data areas. Selecting
-mno-eabi
means that the stack is aligned to a 16 byte boundary,
do not call an initialization function from main
, and the
`-msdata' option will only use r13
to point to a single
small data area. The `-meabi' option is on by default if you
configured GCC using one of the `powerpc*-*-eabi*' options.
-msdata=eabi
const
global and static data in the `.sdata2' section, which
is pointed to by register r2
. Put small initialized
non-const
global and static data in the `.sdata' section,
which is pointed to by register r13
. Put small uninitialized
global and static data in the `.sbss' section, which is adjacent to
the `.sdata' section. The `-msdata=eabi' option is
incompatible with the `-mrelocatable' option. The
`-msdata=eabi' option also sets the `-memb' option.
-msdata=sysv
r13
. Put small uninitialized global and static data in the
`.sbss' section, which is adjacent to the `.sdata' section.
The `-msdata=sysv' option is incompatible with the
`-mrelocatable' option.
-msdata=default
-msdata
-msdata-data
r13
to address small data however. This is the default behavior unless
other `-msdata' options are used.
-msdata=none
-mno-sdata
-G num
-mregnames
-mno-regnames
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for the IBM RT PC:
-min-line-mul
-mcall-lib-mul
lmul$$
for integer multiples.
-mfull-fp-blocks
-mminimum-fp-blocks
-mfp-arg-in-fpregs
varargs.h
and stdargs.h
will not work with
floating point operands if this option is specified.
-mfp-arg-in-gregs
-mhc-struct-return
-mnohc-struct-return
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for the MIPS family of computers:
-mcpu=cpu type
-mips1
-mips2
-mips3
-mips4
-mfp32
-mfp64
-mgp32
-mgp64
-mint64
-mlong64
-mlong32
If none of `-mlong32', `-mlong64', or `-mint64' are set, the size of ints, longs, and pointers depends on the ABI and ISA choosen. 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
-mmips-as
-mgas
-msplit-addresses
-mno-split-addresses
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
-mgpopt
-mno-gpopt
-mstats
-mno-stats
-mmemcpy
-mno-memcpy
-mmips-tfile
-mno-mips-tfile
-msoft-float
-mhard-float
-mabicalls
-mno-abicalls
-mlong-calls
-mno-long-calls
-mhalf-pic
-mno-half-pic
-membedded-pic
-mno-embedded-pic
-membedded-data
-mno-embedded-data
-msingle-float
-mdouble-float
-mmad
-mno-mad
-m4650
-mips16
-mno-mips16
-mentry
-EL
-EB
-G num
-nocpp
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for the i386 family of computers:
-mcpu=cpu type
`i386' | `i486' | `i586' | `i686' |
`pentium' | `pentiumpro' | `k6' |
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
-m386
-m486
-mpentium
-mpentiumpro
-mieee-fp
-mno-ieee-fp
-msoft-float
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
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
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
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
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
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
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 4.23 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
a
allocate EAX; b
allocate EBX;
c
allocate ECX; d
allocate EDX; S
allocate ESI;
D
allocate EDI; B
allocate EBP.
-mregparm=num
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
-malign-jumps=num
-malign-functions=num
-mpreferred-stack-boundary=num
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 Extention (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'.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for the HPPA family of computers:
-march=architecture type
PA 2.0 support currently requires gas snapshot 19990413 or later. The next release of binutils (current is 2.9.1) will probably contain PA 2.0 support.
-mpa-risc-1-0
-mpa-risc-1-1
-mpa-risc-2-0
-mbig-switch
-mjump-in-delay
-mdisable-fpregs
-mdisable-indexing
-mno-space-regs
Such code is suitable for level 0 PA systems and kernels.
-mfast-indirect-calls
This option will not work in the presense of shared libraries or nested functions.
-mspace
-mlong-load-store
-mportable-runtime
-mgas
-mschedule=cpu type
-mlinker-opt
-msoft-float
`-msoft-float' changes the calling convention in the output file; therefore, it is only useful if you compile all of a program with this option. In particular, you need to compile `libgcc.a', the library that comes with GCC, with `-msoft-float' in order for this to work.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for the Intel 960 implementations:
-mcpu type
-mnumerics
-msoft-float
-mleaf-procedures
-mno-leaf-procedures
bal
instruction as well as call
. This will result in more
efficient code for explicit calls when the bal
instruction can be
substituted by the assembler or linker, but less efficient code in other
cases, such as calls via function pointers, or using a linker that doesn't
support this optimization.
-mtail-call
-mno-tail-call
-mcomplex-addr
-mno-complex-addr
-mcode-align
-mno-code-align
-mic-compat
-mic2.0-compat
-mic3.0-compat
-masm-compat
-mintel-asm
-mstrict-align
-mno-strict-align
-mold-align
-mlong-double-64
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for the DEC Alpha implementations:
-mno-soft-float
-msoft-float
-msoft-float
is specified,
functions in `libgcc1.c' will be used to perform floating-point
operations. Unless they are replaced by routines that emulate the
floating-point operations, or compiled in such a way as to call such
emulations routines, these routines will issue floating-point
operations. If you are compiling for an Alpha without floating-point
operations, you must ensure that the library is built so as not to call
them.
Note that Alpha implementations without floating-point operations are required to have floating-point registers.
-mfp-reg
-mno-fp-regs
-mno-fp-regs
implies -msoft-float
. If the floating-point
register set is not used, floating point operands are passed in integer
registers as if they were integers and floating-point results are passed
in $0 instead of $f0. This is a non-standard calling sequence, so any
function with a floating-point argument or return value called by code
compiled with -mno-fp-regs
must also be compiled with that
option.
A typical use of this option is building a kernel that does not use, and hence need not save and restore, any floating-point registers.
-mieee
_IEEE_FP
is defined
during compilation. The option is a shorthand for: `-D_IEEE_FP
-mfp-trap-mode=su -mtrap-precision=i -mieee-conformant'. The resulting
code is less efficient but is able to correctly support denormalized
numbers and exceptional IEEE values such as not-a-number and plus/minus
infinity. Other Alpha compilers call this option
-ieee_with_no_inexact
.
-mieee-with-inexact
-mfp-trap-mode=trap mode
-mfp-rounding-mode=rounding mode
-mtrap-precision=trap precision
Other Alpha compilers provide the equivalent options called `-scope_safe' and `-resumption_safe'.
-mieee-conformant
-mbuild-constants
Use this option to require GCC to construct all integer constants using code, even if it takes more instructions (the maximum is six).
You would typically use this option to build a shared library dynamic loader. Itself a shared library, it must relocate itself in memory before it can find the variables and constants in its own data segment.
-malpha-as
-mgas
-mbwx
-mno-bwx
-mcix
-mno-cix
-mmax
-mno-max
-mcpu=cpu_type
Supported values for cpu_type are
-mmemory-latency=time
Valid options for time are
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for the Clipper implementations:
-mc300
-mc400
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for the H8/300 implementations:
-mrelax
ld
and the H8/300' in Using ld, for a fuller description.
-mh
-ms
-mint32
int
data 32 bits by default.
-malign-300
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for the SH implementations:
-m1
-m2
-m3
-m3e
-mb
-ml
-mdalign
-mrelax
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These additional options are available on System V Release 4 for compatibility with other compilers on those systems:
-G
-Qy
.ident
assembler directive in the output.
-Qn
.ident
directives to the output file (this is
the default).
-YP,dirs
-Ym,dir
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for TMS320C3x/C4x implementations:
-mcpu=cpu_type
-mbig-memory
-mbig
-msmall-memory
-msmall
-mbk
-mno-bk
-mdb
-mno-db
-mdp-isr-reload
-mparanoid
-mmpyi
-mno-mpyi
-mfast-fix
-mno-fast-fix
-mrptb
-mno-rptb
-mrpts=count
-mno-rpts
-mloop-unsigned
-mno-loop-unsigned
-mti
-mregparm
-mmemparm
-mparallel-insns
-mno-parallel-insns
-mparallel-mpy
-mno-parallel-mpy
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These `-m' options are defined for V850 implementations:
-mlong-calls
-mno-long-calls
-mno-ep
-mep
ep
register, and
use the shorter sld
and sst
instructions. The `-mep'
option is on by default if you optimize.
-mno-prolog-function
-mprolog-function
-mspace
-mtda=n
ep
points to. The tiny data
area can hold up to 256 bytes in total (128 bytes for byte references).
-msda=n
gp
points to. The small data
area can hold up to 64 kilobytes.
-mzda=n
-mv850
-mbig-switch
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These options are defined for ARC implementations:
-EL
-EB
-mmangle-cpu
-mcpu=cpu
-mtext=text section
-mdata=data section
-mrodata=readonly data section
section
attribute.
See section 4.29 Specifying Attributes of Variables.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These are the `-m' options defined for the 32000 series. The default values for these options depends on which style of 32000 was selected when the compiler was configured; the defaults for the most common choices are given below.
-m32032
-m32032
-m32332
-m32332
-m32532
-m32532
-m32081
-m32381
-mmulti-add
polyF
and dotF
. This option is only available if the `-m32381'
option is in effect. Using these instructions requires changes to to
register allocation which generally has a negative impact on
performance. This option should only be enabled when compiling code
particularly likely to make heavy use of multiply-add instructions.
-mnomulti-add
polyF
and dotF
. This is the default on all platforms.
-msoft-float
-mnobitfield
-mbitfield
-mrtd
ret
instruction.
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.)
This option takes its name from the 680x0 rtd
instruction.
-mregparam
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.
-mnoregparam
-msb
-mnosb
-mhimem
-mnohimem
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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
-fpcc-struct-return
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
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
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
double
as for float
.
-fshared-data
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
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
-fno-gnu-linker
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
.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
`-fno-verbose-asm', the default, causes the extra information to be omitted and is useful when comparing two assembler files.
-fvolatile
-fvolatile-global
-fvolatile-static
-fpic
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
Position-independent code requires special support, and therefore works only on certain machines.
-ffixed-reg
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
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
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
-fcheck-memory-usage
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. The
compiler cannot understand what the asm
statement will do, and
therefore cannot generate the appropriate code, so it is rejected.
However, the function attribute no_check_memory_usage
will
disable memory checking within a function, and asm
statements can
be put inside such functions. Inline expansion of a non-checked
function within a checked function is permitted; the inline function's
memory accesses won't be checked, but the rest will.
If you move your asm
statements to non-checked inline functions,
but 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
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); } |
-finstrument-functions
__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
-fargument-alias
-fargument-noalias
-fargument-noalias-global
`-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
Be warned that you should know what you are doing when invoking this option, and that not all targets provide complete support for it.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section describes several environment variables that affect how GCC operates. Some of them work by specifying directories or prefixes to use when searching for various kinds of files. Some are used to specify other aspects of the compilation environment.
Note that you can also specify places to search using options such as `-B', `-I' and `-L' (see section 2.12 Options for Directory Search). These take precedence over places specified using environment variables, which in turn take precedence over those specified by the configuration of GCC. See section 17.1 Controlling the Compilation Driver, `gcc'.
LANG
LC_CTYPE
LC_MESSAGES
LC_ALL
LC_CTYPE
and LC_MESSAGES
if it has been configured to do
so. These locale categories can be set to any value supported by your
installation. A typical value is `en_UK' for English in the United
Kingdom.
The LC_CTYPE
environment variable specifies character
classification. GCC uses it to determine the character boundaries in
a string; this is needed for some multibyte encodings that contain quote
and escape characters that would otherwise be interpreted as a string
end or escape.
The LC_MESSAGES
environment variable specifies the language to
use in diagnostic messages.
If the LC_ALL
environment variable is set, it overrides the value
of LC_CTYPE
and LC_MESSAGES
; otherwise, LC_CTYPE
and LC_MESSAGES
default to the value of the LANG
environment variable. If none of these variables are set, GCC
defaults to traditional C English behavior.
TMPDIR
TMPDIR
is set, it specifies the directory to use for temporary
files. GCC uses temporary files to hold the output of one stage of
compilation which is to be used as input to the next stage: for example,
the output of the preprocessor, which is the input to the compiler
proper.
GCC_EXEC_PREFIX
GCC_EXEC_PREFIX
is set, it specifies a prefix to use in the
names of the subprograms executed by the compiler. No slash is added
when this prefix is combined with the name of a subprogram, but you can
specify a prefix that ends with a slash if you wish.
If GCC cannot find the subprogram using the specified prefix, it tries looking in the usual places for the subprogram.
The default value of GCC_EXEC_PREFIX
is
`prefix/lib/gcc-lib/' where prefix is the value
of prefix
when you ran the `configure' script.
Other prefixes specified with `-B' take precedence over this prefix.
This prefix is also used for finding files such as `crt0.o' that are used for linking.
In addition, the prefix is used in an unusual way in finding the
directories to search for header files. For each of the standard
directories whose name normally begins with `/usr/local/lib/gcc-lib'
(more precisely, with the value of GCC_INCLUDE_DIR
), GCC tries
replacing that beginning with the specified prefix to produce an
alternate directory name. Thus, with `-Bfoo/', GCC will search
`foo/bar' where it would normally search `/usr/local/lib/bar'.
These alternate directories are searched first; the standard directories
come next.
COMPILER_PATH
COMPILER_PATH
is a colon-separated list of
directories, much like PATH
. GCC tries the directories thus
specified when searching for subprograms, if it can't find the
subprograms using GCC_EXEC_PREFIX
.
LIBRARY_PATH
LIBRARY_PATH
is a colon-separated list of
directories, much like PATH
. When configured as a native compiler,
GCC tries the directories thus specified when searching for special
linker files, if it can't find them using GCC_EXEC_PREFIX
. Linking
using GCC also uses these directories when searching for ordinary
libraries for the `-l' option (but directories specified with
`-L' come first).
C_INCLUDE_PATH
CPLUS_INCLUDE_PATH
OBJC_INCLUDE_PATH
PATH
. When GCC searches for header files, it tries the
directories listed in the variable for the language you are using, after
the directories specified with `-I' but before the standard header
file directories.
DEPENDENCIES_OUTPUT
The value of DEPENDENCIES_OUTPUT
can be just a file name, in
which case the Make rules are written to that file, guessing the target
name from the source file name. Or the value can have the form
`file target', in which case the rules are written to
file file using target as the target name.
LANG
LANG
are recognized:
C-JIS
C-SJIS
C-EUCJP
If LANG
is not defined, or if it has some other value, then the
compiler will use mblen and mbtowc as defined by the default locale to
recognize and translate multibyte characters.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The program protoize
is an optional part of GNU C. You can use
it to add prototypes to a program, thus converting the program to ANSI
C in one respect. The companion program unprotoize
does the
reverse: it removes argument types from any prototypes that are found.
When you run these programs, you must specify a set of source files as command line arguments. The conversion programs start out by compiling these files to see what functions they define. The information gathered about a file foo is saved in a file named `foo.X'.
After scanning comes actual conversion. The specified files are all eligible to be converted; any files they include (whether sources or just headers) are eligible as well.
But not all the eligible files are converted. By default,
protoize
and unprotoize
convert only source and header
files in the current directory. You can specify additional directories
whose files should be converted with the `-d directory'
option. You can also specify particular files to exclude with the
`-x file' option. A file is converted if it is eligible, its
directory name matches one of the specified directory names, and its
name within the directory has not been excluded.
Basic conversion with protoize
consists of rewriting most
function definitions and function declarations to specify the types of
the arguments. The only ones not rewritten are those for varargs
functions.
protoize
optionally inserts prototype declarations at the
beginning of the source file, to make them available for any calls that
precede the function's definition. Or it can insert prototype
declarations with block scope in the blocks where undeclared functions
are called.
Basic conversion with unprotoize
consists of rewriting most
function declarations to remove any argument types, and rewriting
function definitions to the old-style pre-ANSI form.
Both conversion programs print a warning for any function declaration or definition that they can't convert. You can suppress these warnings with `-q'.
The output from protoize
or unprotoize
replaces the
original source file. The original file is renamed to a name ending
with `.save'. If the `.save' file already exists, then
the source file is simply discarded.
protoize
and unprotoize
both depend on GCC itself to
scan the program and collect information about the functions it uses.
So neither of these programs will work until GCC is installed.
Here is a table of the options you can use with protoize
and
unprotoize
. Each option works with both programs unless
otherwise stated.
-B directory
protoize
.
-c compilation-options
gcc
to
produce the `.X' files. The special option `-aux-info' is
always passed in addition, to tell gcc
to write a `.X' file.
Note that the compilation options must be given as a single argument to
protoize
or unprotoize
. If you want to specify several
gcc
options, you must quote the entire set of compilation options
to make them a single word in the shell.
There are certain gcc
arguments that you cannot use, because they
would produce the wrong kind of output. These include `-g',
`-O', `-c', `-S', and `-o' If you include these in
the compilation-options, they are ignored.
-C
protoize
.
-g
protoize
.
-i string
protoize
.
unprotoize
converts prototyped function definitions to old-style
function definitions, where the arguments are declared between the
argument list and the initial `{'. By default, unprotoize
uses five spaces as the indentation. If you want to indent with just
one space instead, use `-i " "'.
-k
-l
protoize
with `-l' inserts
a prototype declaration for each function in each block which calls the
function without any declaration. This option applies only to
protoize
.
-n
-N
-p program
-q
-v
gcc
.
If you need special compiler options to compile one of your program's
source files, then you should generate that file's `.X' file
specially, by running gcc
on that source file with the
appropriate options and the option `-aux-info'. Then run
protoize
on the entire set of files. protoize
will use
the existing `.X' file because it is newer than the source file.
For example:
gcc -Dfoo=bar file1.c -aux-info protoize *.c |
You need to include the special files along with the rest in the
protoize
command, even though their `.X' files already
exist, because otherwise they won't get converted.
See section 7.11 Caveats of using protoize
, for more information on how to use
protoize
successfully.
Note most of this information is out of date and superceded by the EGCS install procedures. It is provided for historical reference only.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |