]> gcc.gnu.org Git - gcc.git/blame - gcc/invoke.texi
typeck.c (complete_type_or_else): Add VALUE arg, for helpful diagnostics.
[gcc.git] / gcc / invoke.texi
CommitLineData
db838bb8 1@c Copyright (C) 1988, 89, 92-98, 1999 Free Software Foundation, Inc.
74291a4b
MM
2@c This is part of the GCC manual.
3@c For copying conditions, see the file gcc.texi.
4
5@node Invoking GCC
6@chapter GNU CC Command Options
7@cindex GNU CC command options
8@cindex command options
9@cindex options, GNU CC command
10
11When you invoke GNU CC, it normally does preprocessing, compilation,
12assembly and linking. The ``overall options'' allow you to stop this
13process at an intermediate stage. For example, the @samp{-c} option
14says not to run the linker. Then the output consists of object files
15output by the assembler.
16
17Other options are passed on to one stage of processing. Some options
18control the preprocessor and others the compiler itself. Yet other
19options control the assembler and linker; most of these are not
20documented here, since you rarely need to use any of them.
21
22@cindex C compilation options
23Most of the command line options that you can use with GNU CC are useful
24for C programs; when an option is only useful with another language
25(usually C++), the explanation says so explicitly. If the description
26for a particular option does not mention a source language, you can use
27that option with all supported languages.
28
29@cindex C++ compilation options
30@xref{Invoking G++,,Compiling C++ Programs}, for a summary of special
31options for compiling C++ programs.
32
33@cindex grouping options
34@cindex options, grouping
35The @code{gcc} program accepts options and file names as operands. Many
36options have multiletter names; therefore multiple single-letter options
37may @emph{not} be grouped: @samp{-dr} is very different from @w{@samp{-d
38-r}}.
39
40@cindex order of options
41@cindex options, order
42You can mix options and other arguments. For the most part, the order
43you use doesn't matter. Order does matter when you use several options
44of the same kind; for example, if you specify @samp{-L} more than once,
45the directories are searched in the order specified.
46
47Many options have long names starting with @samp{-f} or with
48@samp{-W}---for example, @samp{-fforce-mem},
49@samp{-fstrength-reduce}, @samp{-Wformat} and so on. Most of
50these have both positive and negative forms; the negative form of
51@samp{-ffoo} would be @samp{-fno-foo}. This manual documents
52only one of these two forms, whichever one is not the default.
53
54@menu
55* Option Summary:: Brief list of all options, without explanations.
56* Overall Options:: Controlling the kind of output:
57 an executable, object files, assembler files,
58 or preprocessed source.
59* Invoking G++:: Compiling C++ programs.
60* C Dialect Options:: Controlling the variant of C language compiled.
61* C++ Dialect Options:: Variations on C++.
62* Warning Options:: How picky should the compiler be?
63* Debugging Options:: Symbol tables, measurements, and debugging dumps.
64* Optimize Options:: How much optimization?
65* Preprocessor Options:: Controlling header files and macro definitions.
66 Also, getting dependency information for Make.
67* Assembler Options:: Passing options to the assembler.
68* Link Options:: Specifying libraries and so on.
69* Directory Options:: Where to find header files and libraries.
70 Where to find the compiler executable files.
71* Target Options:: Running a cross-compiler, or an old version of GNU CC.
72* Submodel Options:: Specifying minor hardware or convention variations,
73 such as 68010 vs 68020.
74* Code Gen Options:: Specifying conventions for function calls, data layout
75 and register usage.
76* Environment Variables:: Env vars that affect GNU CC.
77* Running Protoize:: Automatically adding or removing function prototypes.
78@end menu
79
80@node Option Summary
81@section Option Summary
82
83Here is a summary of all the options, grouped by type. Explanations are
84in the following sections.
85
86@table @emph
87@item Overall Options
88@xref{Overall Options,,Options Controlling the Kind of Output}.
89@smallexample
844642e6 90-c -S -E -o @var{file} -pipe -v --help -x @var{language}
74291a4b
MM
91@end smallexample
92
93@item C Language Options
94@xref{C Dialect Options,,Options Controlling C Dialect}.
95@smallexample
3932261a 96-ansi -flang-isoc9x -fallow-single-precision -fcond-mismatch -fno-asm
8c81598d 97-fno-builtin -ffreestanding -fhosted -fsigned-bitfields -fsigned-char
74291a4b
MM
98-funsigned-bitfields -funsigned-char -fwritable-strings
99-traditional -traditional-cpp -trigraphs
100@end smallexample
101
102@item C++ Language Options
103@xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
104@smallexample
1dc5fc4b
JM
105-fno-access-control -fcheck-new -fconserve-space -fdollars-in-identifiers
106-fno-elide-constructors -fexternal-templates -ffor-scope
107-fno-for-scope -fno-gnu-keywords -fguiding-decls -fhandle-signatures
108-fhonor-std -fhuge-objects -fno-implicit-templates -finit-priority
109-fno-implement-inlines -fname-mangling-version-@var{n} -fno-default-inline
110-foperator-names -fno-optional-diags -frepo -fstrict-prototype
111-fsquangle -ftemplate-depth-@var{n} -fthis-is-variable -fvtable-thunks
112-nostdinc++
74291a4b
MM
113@end smallexample
114
115@item Warning Options
116@xref{Warning Options,,Options to Request or Suppress Warnings}.
117@smallexample
118-fsyntax-only -pedantic -pedantic-errors
119-w -W -Wall -Waggregate-return -Wbad-function-cast
08c5b6e8 120-Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment
74291a4b 121-Wconversion -Werror -Wformat
e9a25f70 122-Wid-clash-@var{len} -Wimplicit -Wimplicit-int
f5963e61
JL
123-Wimplicit-function-declaration -Wimport
124-Werror-implicit-function-declaration -Winline
795add94 125-Wlarger-than-@var{len} -Wlong-long
0ca3fb0a 126-Wmain -Wmissing-declarations -Wmissing-noreturn
4a870dba 127-Wmissing-prototypes -Wmultichar -Wnested-externs -Wno-import
d67343c9
BK
128-Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual
129-Wparentheses -Wpointer-arith -Wredundant-decls -Wreorder
130-Wreturn-type -Wshadow -Wsign-compare -Wstrict-prototypes
1dc5fc4b 131-Wswitch -Wsynth -Wtraditional
d67343c9 132-Wtrigraphs -Wundef -Wuninitialized -Wunused -Wwrite-strings
71271702 133-Wunknown-pragmas
74291a4b
MM
134@end smallexample
135
136@item Debugging Options
137@xref{Debugging Options,,Options for Debugging Your Program or GCC}.
138@smallexample
b707b450 139-a -ax -d@var{letters} -fdump-unnumbered -fpretend-float
861bb6c1 140-fprofile-arcs -ftest-coverage
8c81598d 141-g -g@var{level} -gcoff -gdwarf -gdwarf-1 -gdwarf-1+ -gdwarf-2
74291a4b
MM
142-ggdb -gstabs -gstabs+ -gxcoff -gxcoff+
143-p -pg -print-file-name=@var{library} -print-libgcc-file-name
144-print-prog-name=@var{program} -print-search-dirs -save-temps
145@end smallexample
146
147@item Optimization Options
148@xref{Optimize Options,,Options that Control Optimization}.
149@smallexample
9ec36da5 150-fbranch-probabilities -foptimize-register-moves
74291a4b
MM
151-fcaller-saves -fcse-follow-jumps -fcse-skip-blocks
152-fdelayed-branch -fexpensive-optimizations
153-ffast-math -ffloat-store -fforce-addr -fforce-mem
7d0756fb
CM
154-fdata-sections -ffunction-sections -fgcse
155-finline-functions -fkeep-inline-functions
156-fno-default-inline -fno-defer-pop -fno-function-cse
8c660648 157-fno-inline -fno-peephole -fomit-frame-pointer -fregmove
6d6d0fa0 158-frerun-cse-after-loop -frerun-loop-opt -fschedule-insns
74291a4b
MM
159-fschedule-insns2 -fstrength-reduce -fthread-jumps
160-funroll-all-loops -funroll-loops
41472af8 161-fmove-all-movables -freduce-all-givs -fstrict-aliasing
c6aded7c 162-O -O0 -O1 -O2 -O3 -Os
74291a4b
MM
163@end smallexample
164
165@item Preprocessor Options
166@xref{Preprocessor Options,,Options Controlling the Preprocessor}.
167@smallexample
168-A@var{question}(@var{answer}) -C -dD -dM -dN
169-D@var{macro}@r{[}=@var{defn}@r{]} -E -H
170-idirafter @var{dir}
171-include @var{file} -imacros @var{file}
172-iprefix @var{file} -iwithprefix @var{dir}
f5a1b0d2 173-iwithprefixbefore @var{dir} -isystem @var{dir} -isystem-c++ @var{dir}
74291a4b
MM
174-M -MD -MM -MMD -MG -nostdinc -P -trigraphs
175-undef -U@var{macro} -Wp,@var{option}
176@end smallexample
177
178@item Assembler Option
179@xref{Assembler Options,,Passing Options to the Assembler}.
180@smallexample
181-Wa,@var{option}
182@end smallexample
183
184@item Linker Options
185@xref{Link Options,,Options for Linking}.
186@smallexample
187@var{object-file-name} -l@var{library}
188-nostartfiles -nodefaultlibs -nostdlib
189-s -static -shared -symbolic
190-Wl,@var{option} -Xlinker @var{option}
191-u @var{symbol}
192@end smallexample
193
194@item Directory Options
195@xref{Directory Options,,Options for Directory Search}.
196@smallexample
8c81598d 197-B@var{prefix} -I@var{dir} -I- -L@var{dir} -specs=@var{file}
74291a4b
MM
198@end smallexample
199
200@item Target Options
201@c I wrote this xref this way to avoid overfull hbox. -- rms
202@xref{Target Options}.
203@smallexample
204-b @var{machine} -V @var{version}
205@end smallexample
206
207@item Machine Dependent Options
208@xref{Submodel Options,,Hardware Models and Configurations}.
209@smallexample
210@emph{M680x0 Options}
8c81598d 211-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040
e5e809f4
JL
212-m68060 -mcpu32 -m5200 -m68881 -mbitfield -mc68000 -mc68020
213-mfpa -mnobitfield -mrtd -mshort -msoft-float
214-malign-int
74291a4b
MM
215
216@emph{VAX Options}
217-mg -mgnu -munix
218
219@emph{SPARC Options}
ded17aad
DE
220-mcpu=@var{cpu type}
221-mtune=@var{cpu type}
222-mcmodel=@var{code model}
6d4312dd
DE
223-malign-jumps=@var{num} -malign-loops=@var{num}
224-malign-functions=@var{num}
ded17aad 225-m32 -m64
74291a4b 226-mapp-regs -mbroken-saverestore -mcypress -mepilogue
ded17aad
DE
227-mflat -mfpu -mhard-float -mhard-quad-float
228-mimpure-text -mlive-g0 -mno-app-regs -mno-epilogue
74291a4b
MM
229-mno-flat -mno-fpu -mno-impure-text
230-mno-stack-bias -mno-unaligned-doubles
231-msoft-float -msoft-quad-float -msparclite -mstack-bias
232-msupersparc -munaligned-doubles -mv8
233
234@emph{Convex Options}
235-mc1 -mc2 -mc32 -mc34 -mc38
236-margcount -mnoargcount
237-mlong32 -mlong64
238-mvolatile-cache -mvolatile-nocache
239
240@emph{AMD29K Options}
241-m29000 -m29050 -mbw -mnbw -mdw -mndw
242-mlarge -mnormal -msmall
243-mkernel-registers -mno-reuse-arg-regs
244-mno-stack-check -mno-storem-bug
245-mreuse-arg-regs -msoft-float -mstack-check
246-mstorem-bug -muser-registers
247
248@emph{ARM Options}
157a620e
NC
249-mapcs-frame -mno-apcs-frame
250-mapcs-26 -mapcs-32
251-mapcs-stack-check -mno-apcs-stack-check
252-mapcs-float -mno-apcs-float
253-mapcs-reentrant -mno-apcs-reentrant
254-msched-prolog -mno-sched-prolog
255-mlittle-endian -mbig-endian -mwords-little-endian
256-mshort-load-bytes -mno-short-load-bytes -mshort-load-words -mno-short-load-words
257-msoft-float -mhard-float -mfpe
258-mthumb-interwork -mno-thumb-interwork
259-mcpu= -march= -mfpe=
260-mstructure-size-boundary=
261-mbsd -mxopen -mno-symrename
f5a1b0d2
NC
262-mabort-on-noreturn
263-mno-sched-prolog
157a620e
NC
264
265@emph{Thumb Options}
266-mtpcs-frame -mno-tpcs-frame
267-mtpcs-leaf-frame -mno-tpcs-leaf-frame
268-mlittle-endian -mbig-endian
269-mthumb-interwork -mno-thumb-interwork
270-mstructure-size-boundary=
74291a4b 271
ecff22ab
JL
272@emph{MN10200 Options}
273-mrelax
274
6d6d0fa0
JL
275@emph{MN10300 Options}
276-mmult-bug
277-mno-mult-bug
ecff22ab 278-mrelax
6d6d0fa0 279
861bb6c1
JL
280@emph{M32R/D Options}
281-mcode-model=@var{model type} -msdata=@var{sdata type}
282-G @var{num}
283
74291a4b
MM
284@emph{M88K Options}
285-m88000 -m88100 -m88110 -mbig-pic
286-mcheck-zero-division -mhandle-large-shift
287-midentify-revision -mno-check-zero-division
288-mno-ocs-debug-info -mno-ocs-frame-position
289-mno-optimize-arg-area -mno-serialize-volatile
290-mno-underscores -mocs-debug-info
291-mocs-frame-position -moptimize-arg-area
292-mserialize-volatile -mshort-data-@var{num} -msvr3
293-msvr4 -mtrap-large-shift -muse-div-instruction
294-mversion-03.00 -mwarn-passed-structs
295
296@emph{RS/6000 and PowerPC Options}
8c81598d
JM
297-mcpu=@var{cpu type}
298-mtune=@var{cpu type}
74291a4b
MM
299-mpower -mno-power -mpower2 -mno-power2
300-mpowerpc -mno-powerpc
301-mpowerpc-gpopt -mno-powerpc-gpopt
302-mpowerpc-gfxopt -mno-powerpc-gfxopt
303-mnew-mnemonics -mno-new-mnemonics
304-mfull-toc -mminimal-toc -mno-fop-in-toc -mno-sum-in-toc
7fe90e7b 305-maix64 -maix32 -mxl-call -mno-xl-call -mthreads -mpe
74291a4b 306-msoft-float -mhard-float -mmultiple -mno-multiple
861bb6c1
JL
307-mstring -mno-string -mupdate -mno-update
308-mfused-madd -mno-fused-madd -mbit-align -mno-bit-align
74291a4b
MM
309-mstrict-align -mno-strict-align -mrelocatable
310-mno-relocatable -mrelocatable-lib -mno-relocatable-lib
2880d0aa 311-mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian
74291a4b 312-mcall-aix -mcall-sysv -mprototype -mno-prototype
2880d0aa
CM
313-msim -mmvme -mads -myellowknife -memb -msdata
314-msdata=@var{opt} -G @var{num}
74291a4b
MM
315
316@emph{RT Options}
317-mcall-lib-mul -mfp-arg-in-fpregs -mfp-arg-in-gregs
318-mfull-fp-blocks -mhc-struct-return -min-line-mul
319-mminimum-fp-blocks -mnohc-struct-return
320
321@emph{MIPS Options}
8c81598d 322-mabicalls -mcpu=@var{cpu type} -membedded-data
74291a4b 323-membedded-pic -mfp32 -mfp64 -mgas -mgp32 -mgp64
8c81598d 324-mgpopt -mhalf-pic -mhard-float -mint64 -mips1
3398f47f 325-mips2 -mips3 -mips4 -mlong64 -mlong-calls -mmemcpy
74291a4b
MM
326-mmips-as -mmips-tfile -mno-abicalls
327-mno-embedded-data -mno-embedded-pic
328-mno-gpopt -mno-long-calls
329-mno-memcpy -mno-mips-tfile -mno-rnames -mno-stats
8c81598d
JM
330-mrnames -msoft-float
331-m4650 -msingle-float -mmad
74291a4b 332-mstats -EL -EB -G @var{num} -nocpp
3398f47f 333-mabi=32 -mabi=n32 -mabi=64 -mabi=eabi
74291a4b
MM
334
335@emph{i386 Options}
a9f3e1a4
JL
336-mcpu=@var{cpu type}
337-march=@var{cpu type}
338-mieee-fp -mno-fancy-math-387
74291a4b 339-mno-fp-ret-in-387 -msoft-float -msvr3-shlib
8c81598d
JM
340-mno-wide-multiply -mrtd -malign-double
341-mreg-alloc=@var{list} -mregparm=@var{num}
342-malign-jumps=@var{num} -malign-loops=@var{num}
74291a4b
MM
343-malign-functions=@var{num}
344
345@emph{HPPA Options}
e5e809f4
JL
346-mbig-switch -mdisable-fpregs -mdisable-indexing
347-mfast-indirect-calls -mgas -mjump-in-delay
348-mlong-load-store -mno-big-switch -mno-disable-fpregs
8c81598d 349-mno-disable-indexing -mno-fast-indirect-calls -mno-gas
e5e809f4
JL
350-mno-jump-in-delay -mno-long-load-store
351-mno-portable-runtime -mno-soft-float -mno-space
352-mno-space-regs -msoft-float -mpa-risc-1-0
353-mpa-risc-1-1 -mportable-runtime
8c81598d 354-mschedule=@var{list} -mspace -mspace-regs
74291a4b
MM
355
356@emph{Intel 960 Options}
357-m@var{cpu type} -masm-compat -mclean-linkage
358-mcode-align -mcomplex-addr -mleaf-procedures
359-mic-compat -mic2.0-compat -mic3.0-compat
360-mintel-asm -mno-clean-linkage -mno-code-align
361-mno-complex-addr -mno-leaf-procedures
362-mno-old-align -mno-strict-align -mno-tail-call
363-mnumerics -mold-align -msoft-float -mstrict-align
364-mtail-call
365
366@emph{DEC Alpha Options}
956d6950
JL
367-mfp-regs -mno-fp-regs -mno-soft-float -msoft-float
368-malpha-as -mgas
8c81598d 369-mieee -mieee-with-inexact -mieee-conformant
956d6950
JL
370-mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode}
371-mtrap-precision=@var{mode} -mbuild-constants
372-mcpu=@var{cpu type}
373-mbwx -mno-bwx -mcix -mno-cix -mmax -mno-max
4f69985c 374-mmemory-latency=@var{time}
74291a4b
MM
375
376@emph{Clipper Options}
8c81598d 377-mc300 -mc400
74291a4b
MM
378
379@emph{H8/300 Options}
dcb9d1f0 380-mrelax -mh -ms -mint32 -malign-300
74291a4b
MM
381
382@emph{SH Options}
3d5a0820 383-m1 -m2 -m3 -m3e -mb -ml -mdalign -mrelax
74291a4b
MM
384
385@emph{System V Options}
386-Qy -Qn -YP,@var{paths} -Ym,@var{dir}
74291a4b 387
56b2d7a7
JL
388@emph{ARC Options}
389-EB -EL
390-mmangle-cpu -mcpu=@var{cpu} -mtext=@var{text section}
391-mdata=@var{data section} -mrodata=@var{readonly data section}
392
f84271d9
JL
393@emph{V850 Options}
394-mlong-calls -mno-long-calls -mep -mno-ep
395-mprolog-function -mno-prolog-function -mspace
396-mtda=@var{n} -msda=@var{n} -mzda=@var{n}
e9a25f70 397-mv850 -mbig-switch
83575957
ID
398
399@emph{NS32K Options}
400-m32032 -m32332 -m32532 -m32081 -m32381 -mmult-add -mnomult-add
401-msoft-float -mrtd -mnortd -mregparam -mnoregparam -msb -mnosb
402-mbitfield -mnobitfield -mhimem -mnohimem
f84271d9
JL
403@end smallexample
404
74291a4b
MM
405@item Code Generation Options
406@xref{Code Gen Options,,Options for Code Generation Conventions}.
407@smallexample
408-fcall-saved-@var{reg} -fcall-used-@var{reg}
f2d76545 409-fexceptions -ffixed-@var{reg} -finhibit-size-directive
861bb6c1 410-fcheck-memory-usage -fprefix-function-name
74291a4b
MM
411-fno-common -fno-ident -fno-gnu-linker
412-fpcc-struct-return -fpic -fPIC
413-freg-struct-return -fshared-data -fshort-enums
ab87f8c8 414-fshort-double -fvolatile -fvolatile-global -fvolatile-static
1dc5fc4b 415-fverbose-asm -fpack-struct -fstack-check
e5eb27e5
JL
416-fargument-alias -fargument-noalias
417-fargument-noalias-global
19283265 418-fleading-underscore
74291a4b
MM
419@end smallexample
420@end table
421
422@menu
423* Overall Options:: Controlling the kind of output:
424 an executable, object files, assembler files,
425 or preprocessed source.
426* C Dialect Options:: Controlling the variant of C language compiled.
427* C++ Dialect Options:: Variations on C++.
428* Warning Options:: How picky should the compiler be?
429* Debugging Options:: Symbol tables, measurements, and debugging dumps.
430* Optimize Options:: How much optimization?
431* Preprocessor Options:: Controlling header files and macro definitions.
432 Also, getting dependency information for Make.
433* Assembler Options:: Passing options to the assembler.
434* Link Options:: Specifying libraries and so on.
435* Directory Options:: Where to find header files and libraries.
436 Where to find the compiler executable files.
437* Target Options:: Running a cross-compiler, or an old version of GNU CC.
438@end menu
439
440@node Overall Options
441@section Options Controlling the Kind of Output
442
443Compilation can involve up to four stages: preprocessing, compilation
444proper, assembly and linking, always in that order. The first three
445stages apply to an individual source file, and end by producing an
446object file; linking combines all the object files (those newly
447compiled, and those specified as input) into an executable file.
448
449@cindex file name suffix
450For any given input file, the file name suffix determines what kind of
451compilation is done:
452
453@table @code
454@item @var{file}.c
455C source code which must be preprocessed.
456
457@item @var{file}.i
458C source code which should not be preprocessed.
459
460@item @var{file}.ii
461C++ source code which should not be preprocessed.
462
463@item @var{file}.m
464Objective-C source code. Note that you must link with the library
465@file{libobjc.a} to make an Objective-C program work.
466
467@item @var{file}.h
468C header file (not to be compiled or linked).
469
470@item @var{file}.cc
471@itemx @var{file}.cxx
472@itemx @var{file}.cpp
473@itemx @var{file}.C
474C++ source code which must be preprocessed. Note that in @samp{.cxx},
475the last two letters must both be literally @samp{x}. Likewise,
476@samp{.C} refers to a literal capital C.
477
478@item @var{file}.s
479Assembler code.
480
481@item @var{file}.S
482Assembler code which must be preprocessed.
483
484@item @var{other}
485An object file to be fed straight into linking.
486Any file name with no recognized suffix is treated this way.
487@end table
488
489You can specify the input language explicitly with the @samp{-x} option:
490
491@table @code
492@item -x @var{language}
493Specify explicitly the @var{language} for the following input files
494(rather than letting the compiler choose a default based on the file
495name suffix). This option applies to all following input files until
496the next @samp{-x} option. Possible values for @var{language} are:
497@example
498c objective-c c++
499c-header cpp-output c++-cpp-output
500assembler assembler-with-cpp
501@end example
502
503@item -x none
504Turn off any specification of a language, so that subsequent files are
505handled according to their file name suffixes (as they are if @samp{-x}
506has not been used at all).
507@end table
508
509If you only want some of the stages of compilation, you can use
510@samp{-x} (or filename suffixes) to tell @code{gcc} where to start, and
511one of the options @samp{-c}, @samp{-S}, or @samp{-E} to say where
512@code{gcc} is to stop. Note that some combinations (for example,
513@samp{-x cpp-output -E} instruct @code{gcc} to do nothing at all.
514
515@table @code
516@item -c
517Compile or assemble the source files, but do not link. The linking
518stage simply is not done. The ultimate output is in the form of an
519object file for each source file.
520
521By default, the object file name for a source file is made by replacing
522the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
523
524Unrecognized input files, not requiring compilation or assembly, are
525ignored.
526
527@item -S
528Stop after the stage of compilation proper; do not assemble. The output
529is in the form of an assembler code file for each non-assembler input
530file specified.
531
532By default, the assembler file name for a source file is made by
533replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
534
535Input files that don't require compilation are ignored.
536
537@item -E
538Stop after the preprocessing stage; do not run the compiler proper. The
539output is in the form of preprocessed source code, which is sent to the
540standard output.
541
542Input files which don't require preprocessing are ignored.
543
544@cindex output file option
545@item -o @var{file}
546Place output in file @var{file}. This applies regardless to whatever
547sort of output is being produced, whether it be an executable file,
548an object file, an assembler file or preprocessed C code.
549
550Since only one output file can be specified, it does not make sense to
551use @samp{-o} when compiling more than one input file, unless you are
552producing an executable file as output.
553
554If @samp{-o} is not specified, the default is to put an executable file
555in @file{a.out}, the object file for @file{@var{source}.@var{suffix}} in
556@file{@var{source}.o}, its assembler file in @file{@var{source}.s}, and
557all preprocessed C source on standard output.@refill
558
559@item -v
560Print (on standard error output) the commands executed to run the stages
561of compilation. Also print the version number of the compiler driver
562program and of the preprocessor and the compiler proper.
563
564@item -pipe
565Use pipes rather than temporary files for communication between the
566various stages of compilation. This fails to work on some systems where
567the assembler is unable to read from a pipe; but the GNU assembler has
568no trouble.
844642e6
NC
569
570@item --help
571Print (on the standard output) a description of the command line options
572understood by @code{gcc}. If the @code{-v} option is also specified
573then @code{--help} will also be passed on to the various processes
574invoked by @code{gcc}, so that they can display the command line options
575they accept. If the @code{-W} option is also specified then command
576line options which have no documentation associated with them will also
577be displayed.
74291a4b
MM
578@end table
579
580@node Invoking G++
581@section Compiling C++ Programs
582
583@cindex suffixes for C++ source
584@cindex C++ source file suffixes
585C++ source files conventionally use one of the suffixes @samp{.C},
586@samp{.cc}, @samp{cpp}, or @samp{.cxx}; preprocessed C++ files use the
587suffix @samp{.ii}. GNU CC recognizes files with these names and
588compiles them as C++ programs even if you call the compiler the same way
589as for compiling C programs (usually with the name @code{gcc}).
590
591@findex g++
592@findex c++
593However, C++ programs often require class libraries as well as a
594compiler that understands the C++ language---and under some
595circumstances, you might want to compile programs from standard input,
596or otherwise without a suffix that flags them as C++ programs.
597@code{g++} is a program that calls GNU CC with the default language
e5e809f4
JL
598set to C++, and automatically specifies linking against the C++
599library.
74291a4b
MM
600@cindex @code{g++ 1.@var{xx}}
601@cindex @code{g++}, separate compiler
602@cindex @code{g++} older version
603@footnote{Prior to release 2 of the compiler,
604there was a separate @code{g++} compiler. That version was based on GNU
605CC, but not integrated with it. Versions of @code{g++} with a
606@samp{1.@var{xx}} version number---for example, @code{g++} version 1.37
607or 1.42---are much less reliable than the versions integrated with GCC
6082. Moreover, combining G++ @samp{1.@var{xx}} with a version 2 GCC will
609simply not work.} On many systems, the script @code{g++} is also
610installed with the name @code{c++}.
611
612@cindex invoking @code{g++}
613When you compile C++ programs, you may specify many of the same
614command-line options that you use for compiling programs in any
615language; or command-line options meaningful for C and related
616languages; or options that are meaningful only for C++ programs.
617@xref{C Dialect Options,,Options Controlling C Dialect}, for
618explanations of options for languages related to C.
619@xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
620explanations of options that are meaningful only for C++ programs.
621
622@node C Dialect Options
623@section Options Controlling C Dialect
624@cindex dialect options
625@cindex language dialect options
626@cindex options, dialect
627
628The following options control the dialect of C (or languages derived
629from C, such as C++ and Objective C) that the compiler accepts:
630
631@table @code
632@cindex ANSI support
633@item -ansi
634Support all ANSI standard C programs.
635
636This turns off certain features of GNU C that are incompatible with ANSI
637C, such as the @code{asm}, @code{inline} and @code{typeof} keywords, and
638predefined macros such as @code{unix} and @code{vax} that identify the
639type of system you are using. It also enables the undesirable and
861bb6c1
JL
640rarely used ANSI trigraph feature, and it disables recognition of C++
641style @samp{//} comments.
74291a4b
MM
642
643The alternate keywords @code{__asm__}, @code{__extension__},
644@code{__inline__} and @code{__typeof__} continue to work despite
645@samp{-ansi}. You would not want to use them in an ANSI C program, of
646course, but it is useful to put them in header files that might be included
647in compilations done with @samp{-ansi}. Alternate predefined macros
648such as @code{__unix__} and @code{__vax__} are also available, with or
649without @samp{-ansi}.
650
651The @samp{-ansi} option does not cause non-ANSI programs to be
652rejected gratuitously. For that, @samp{-pedantic} is required in
653addition to @samp{-ansi}. @xref{Warning Options}.
654
655The macro @code{__STRICT_ANSI__} is predefined when the @samp{-ansi}
656option is used. Some header files may notice this macro and refrain
657from declaring certain functions or defining certain macros that the
658ANSI standard doesn't call for; this is to avoid interfering with any
659programs that might use these names for other things.
660
661The functions @code{alloca}, @code{abort}, @code{exit}, and
662@code{_exit} are not builtin functions when @samp{-ansi} is used.
663
3932261a
MM
664@item -flang-isoc9x
665Enable support for features found in the C9X standard. In particular,
666enable support for the C9X @code{restrict} keyword.
667
668Even when this option is not specified, you can still use some C9X
669features in so far as they do not conflict with previous C standards.
670For example, you may use @code{__restrict__} even when -flang-isoc9x
671is not specified.
672
74291a4b
MM
673@item -fno-asm
674Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
675keyword, so that code can use these words as identifiers. You can use
676the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
677instead. @samp{-ansi} implies @samp{-fno-asm}.
678
679In C++, this switch only affects the @code{typeof} keyword, since
680@code{asm} and @code{inline} are standard keywords. You may want to
681use the @samp{-fno-gnu-keywords} flag instead, as it also disables the
682other, C++-specific, extension keywords such as @code{headof}.
683
684@item -fno-builtin
685@cindex builtin functions
686@findex abort
687@findex abs
688@findex alloca
689@findex cos
690@findex exit
691@findex fabs
692@findex ffs
693@findex labs
694@findex memcmp
695@findex memcpy
696@findex sin
697@findex sqrt
698@findex strcmp
699@findex strcpy
700@findex strlen
ab87f8c8 701Don't recognize builtin functions that do not begin with @samp{__builtin_}
e69fd6e5 702as prefix. Currently, the functions affected include @code{abort},
74291a4b
MM
703@code{abs}, @code{alloca}, @code{cos}, @code{exit}, @code{fabs},
704@code{ffs}, @code{labs}, @code{memcmp}, @code{memcpy}, @code{sin},
705@code{sqrt}, @code{strcmp}, @code{strcpy}, and @code{strlen}.
706
707GCC normally generates special code to handle certain builtin functions
708more efficiently; for instance, calls to @code{alloca} may become single
709instructions that adjust the stack directly, and calls to @code{memcpy}
710may become inline copy loops. The resulting code is often both smaller
711and faster, but since the function calls no longer appear as such, you
712cannot set a breakpoint on those calls, nor can you change the behavior
713of the functions by linking with a different library.
714
715The @samp{-ansi} option prevents @code{alloca} and @code{ffs} from being
716builtin functions, since these functions do not have an ANSI standard
717meaning.
718
861bb6c1
JL
719@item -fhosted
720@cindex hosted environment
721
722Assert that compilation takes place in a hosted environment. This implies
723@samp{-fbuiltin}. A hosted environment is one in which the
724entire standard library is available, and in which @code{main} has a return
725type of @code{int}. Examples are nearly everything except a kernel.
726This is equivalent to @samp{-fno-freestanding}.
727
728@item -ffreestanding
729@cindex hosted environment
730
731Assert that compilation takes place in a freestanding environment. This
732implies @samp{-fno-builtin}. A freestanding environment
733is one in which the standard library may not exist, and program startup may
734not necessarily be at @code{main}. The most obvious example is an OS kernel.
735This is equivalent to @samp{-fno-hosted}.
736
74291a4b
MM
737@item -trigraphs
738Support ANSI C trigraphs. You don't want to know about this
739brain-damage. The @samp{-ansi} option implies @samp{-trigraphs}.
740
741@cindex traditional C language
742@cindex C language, traditional
743@item -traditional
744Attempt to support some aspects of traditional C compilers.
745Specifically:
746
747@itemize @bullet
748@item
749All @code{extern} declarations take effect globally even if they
750are written inside of a function definition. This includes implicit
751declarations of functions.
752
753@item
754The newer keywords @code{typeof}, @code{inline}, @code{signed}, @code{const}
755and @code{volatile} are not recognized. (You can still use the
756alternative keywords such as @code{__typeof__}, @code{__inline__}, and
757so on.)
758
759@item
760Comparisons between pointers and integers are always allowed.
761
762@item
763Integer types @code{unsigned short} and @code{unsigned char} promote
764to @code{unsigned int}.
765
766@item
767Out-of-range floating point literals are not an error.
768
769@item
770Certain constructs which ANSI regards as a single invalid preprocessing
771number, such as @samp{0xe-0xd}, are treated as expressions instead.
772
773@item
774String ``constants'' are not necessarily constant; they are stored in
775writable space, and identical looking constants are allocated
776separately. (This is the same as the effect of
777@samp{-fwritable-strings}.)
778
779@cindex @code{longjmp} and automatic variables
780@item
781All automatic variables not declared @code{register} are preserved by
782@code{longjmp}. Ordinarily, GNU C follows ANSI C: automatic variables
783not declared @code{volatile} may be clobbered.
784
785@item
786@kindex \x
787@kindex \a
788@cindex escape sequences, traditional
789The character escape sequences @samp{\x} and @samp{\a} evaluate as the
790literal characters @samp{x} and @samp{a} respectively. Without
791@w{@samp{-traditional}}, @samp{\x} is a prefix for the hexadecimal
792representation of a character, and @samp{\a} produces a bell.
ad299d9b 793@end itemize
74291a4b 794
74291a4b
MM
795You may wish to use @samp{-fno-builtin} as well as @samp{-traditional}
796if your program uses names that are normally GNU C builtin functions for
797other purposes of its own.
798
799You cannot use @samp{-traditional} if you include any header files that
800rely on ANSI C features. Some vendors are starting to ship systems with
801ANSI C header files and you cannot use @samp{-traditional} on such
802systems to compile files that include any system headers.
803
e5e809f4
JL
804The @samp{-traditional} option also enables @samp{-traditional-cpp},
805which is described next.
74291a4b
MM
806
807@item -traditional-cpp
808Attempt to support some aspects of traditional C preprocessors.
809Specifically:
810
811@itemize @bullet
812@item
813Comments convert to nothing at all, rather than to a space. This allows
814traditional token concatenation.
815
816@item
817In a preprocessing directive, the @samp{#} symbol must appear as the first
818character of a line.
819
820@item
821Macro arguments are recognized within string constants in a macro
822definition (and their values are stringified, though without additional
823quote marks, when they appear in such a context). The preprocessor
824always considers a string constant to end at a newline.
825
826@item
827@cindex detecting @w{@samp{-traditional}}
828The predefined macro @code{__STDC__} is not defined when you use
829@samp{-traditional}, but @code{__GNUC__} is (since the GNU extensions
830which @code{__GNUC__} indicates are not affected by
831@samp{-traditional}). If you need to write header files that work
832differently depending on whether @samp{-traditional} is in use, by
833testing both of these predefined macros you can distinguish four
834situations: GNU C, traditional GNU C, other ANSI C compilers, and other
835old C compilers. The predefined macro @code{__STDC_VERSION__} is also
836not defined when you use @samp{-traditional}. @xref{Standard
837Predefined,,Standard Predefined Macros,cpp.info,The C Preprocessor},
838for more discussion of these and other predefined macros.
839
840@item
841@cindex string constants vs newline
842@cindex newline vs string constants
843The preprocessor considers a string constant to end at a newline (unless
844the newline is escaped with @samp{\}). (Without @w{@samp{-traditional}},
845string constants can contain the newline character as typed.)
846@end itemize
847
848@item -fcond-mismatch
849Allow conditional expressions with mismatched types in the second and
850third arguments. The value of such an expression is void.
851
852@item -funsigned-char
853Let the type @code{char} be unsigned, like @code{unsigned char}.
854
855Each kind of machine has a default for what @code{char} should
856be. It is either like @code{unsigned char} by default or like
857@code{signed char} by default.
858
859Ideally, a portable program should always use @code{signed char} or
860@code{unsigned char} when it depends on the signedness of an object.
861But many programs have been written to use plain @code{char} and
862expect it to be signed, or expect it to be unsigned, depending on the
863machines they were written for. This option, and its inverse, let you
864make such a program work with the opposite default.
865
866The type @code{char} is always a distinct type from each of
867@code{signed char} or @code{unsigned char}, even though its behavior
868is always just like one of those two.
869
870@item -fsigned-char
871Let the type @code{char} be signed, like @code{signed char}.
872
873Note that this is equivalent to @samp{-fno-unsigned-char}, which is
874the negative form of @samp{-funsigned-char}. Likewise, the option
875@samp{-fno-signed-char} is equivalent to @samp{-funsigned-char}.
876
877You may wish to use @samp{-fno-builtin} as well as @samp{-traditional}
878if your program uses names that are normally GNU C builtin functions for
879other purposes of its own.
880
881You cannot use @samp{-traditional} if you include any header files that
882rely on ANSI C features. Some vendors are starting to ship systems with
883ANSI C header files and you cannot use @samp{-traditional} on such
884systems to compile files that include any system headers.
885
886@item -fsigned-bitfields
887@itemx -funsigned-bitfields
888@itemx -fno-signed-bitfields
889@itemx -fno-unsigned-bitfields
890These options control whether a bitfield is signed or unsigned, when the
891declaration does not use either @code{signed} or @code{unsigned}. By
892default, such a bitfield is signed, because this is consistent: the
893basic integer types such as @code{int} are signed types.
894
895However, when @samp{-traditional} is used, bitfields are all unsigned
896no matter what.
897
898@item -fwritable-strings
899Store string constants in the writable data segment and don't uniquize
900them. This is for compatibility with old programs which assume they can
901write into string constants. The option @samp{-traditional} also has
902this effect.
903
904Writing into string constants is a very bad idea; ``constants'' should
905be constant.
906
907@item -fallow-single-precision
908Do not promote single precision math operations to double precision,
909even when compiling with @samp{-traditional}.
910
911Traditional K&R C promotes all floating point operations to double
912precision, regardless of the sizes of the operands. On the
913architecture for which you are compiling, single precision may be faster
914than double precision. If you must use @samp{-traditional}, but want
915to use single precision operations when the operands are single
916precision, use this option. This option has no effect when compiling
917with ANSI or GNU C conventions (the default).
918
919@end table
920
921@node C++ Dialect Options
922@section Options Controlling C++ Dialect
923
924@cindex compiler options, C++
925@cindex C++ options, command line
926@cindex options, C++
927This section describes the command-line options that are only meaningful
928for C++ programs; but you can also use most of the GNU compiler options
929regardless of what language your program is in. For example, you
930might compile a file @code{firstClass.C} like this:
931
932@example
1dc5fc4b 933g++ -g -frepo -O -c firstClass.C
74291a4b
MM
934@end example
935
936@noindent
1dc5fc4b 937In this example, only @samp{-frepo} is an option meant
74291a4b
MM
938only for C++ programs; you can use the other options with any
939language supported by GNU CC.
940
941Here is a list of options that are @emph{only} for compiling C++ programs:
942
943@table @code
944@item -fno-access-control
945Turn off all access checking. This switch is mainly useful for working
946around bugs in the access control code.
947
74291a4b
MM
948@item -fcheck-new
949Check that the pointer returned by @code{operator new} is non-null
950before attempting to modify the storage allocated. The current Working
951Paper requires that @code{operator new} never return a null pointer, so
952this check is normally unnecessary.
953
1dc5fc4b
JM
954An alternative to using this option is to specify that your
955@code{operator new} does not throw any exceptions; if you declare it
956@samp{throw()}, g++ will check the return value. See also @samp{new
957(nothrow)}.
958
74291a4b
MM
959@item -fconserve-space
960Put uninitialized or runtime-initialized global variables into the
961common segment, as C does. This saves space in the executable at the
962cost of not diagnosing duplicate definitions. If you compile with this
963flag and your program mysteriously crashes after @code{main()} has
964completed, you may have an object that is being destroyed twice because
965two definitions were merged.
966
1dc5fc4b
JM
967This option is no longer useful on most targets, now that support has
968been added for putting variables into BSS without making them common.
969
74291a4b
MM
970@item -fdollars-in-identifiers
971Accept @samp{$} in identifiers. You can also explicitly prohibit use of
eb795509
RK
972@samp{$} with the option @samp{-fno-dollars-in-identifiers}. (GNU C allows
973@samp{$} by default on most target systems, but there are a few exceptions.)
74291a4b
MM
974Traditional C allowed the character @samp{$} to form part of
975identifiers. However, ANSI C and C++ forbid @samp{$} in identifiers.
976
1dc5fc4b
JM
977@item -fno-elide-constructors
978The C++ standard allows an implementation to omit creating a temporary
979which is only used to initialize another object of the same type.
980Specifying this option disables that optimization, and forces g++ to
981call the copy constructor in all cases.
74291a4b
MM
982
983@item -fexternal-templates
984Cause template instantiations to obey @samp{#pragma interface} and
985@samp{implementation}; template instances are emitted or not according
986to the location of the template definition. @xref{Template
987Instantiation}, for more information.
988
37f6b6bf
MM
989This option is deprecated.
990
74291a4b
MM
991@item -falt-external-templates
992Similar to -fexternal-templates, but template instances are emitted or
993not according to the place where they are first instantiated.
994@xref{Template Instantiation}, for more information.
995
37f6b6bf
MM
996This option is deprecated.
997
74291a4b 998@item -ffor-scope
8c81598d 999@itemx -fno-for-scope
74291a4b
MM
1000If -ffor-scope is specified, the scope of variables declared in
1001a @i{for-init-statement} is limited to the @samp{for} loop itself,
1002as specified by the draft C++ standard.
1003If -fno-for-scope is specified, the scope of variables declared in
1004a @i{for-init-statement} extends to the end of the enclosing scope,
1005as was the case in old versions of gcc, and other (traditional)
1006implementations of C++.
1007
1008The default if neither flag is given to follow the standard,
1009but to allow and give a warning for old-style code that would
1010otherwise be invalid, or have different behavior.
1011
1012@item -fno-gnu-keywords
1013Do not recognize @code{classof}, @code{headof}, @code{signature},
1014@code{sigof} or @code{typeof} as a keyword, so that code can use these
1015words as identifiers. You can use the keywords @code{__classof__},
1016@code{__headof__}, @code{__signature__}, @code{__sigof__}, and
1017@code{__typeof__} instead. @samp{-ansi} implies
1018@samp{-fno-gnu-keywords}.
1019
37f6b6bf
MM
1020@item -fguiding-decls
1021Treat a function declaration with the same type as a potential function
1022template instantiation as though it declares that instantiation, not a
1023normal function. If a definition is given for the function later in the
1024translation unit (or another translation unit if the target supports
1025weak symbols), that definition will be used; otherwise the template will
1026be instantiated. This behavior reflects the C++ language prior to
1027September 1996, when guiding declarations were removed.
1028
1029This option implies @samp{-fname-mangling-version-0}, and will not work
1dc5fc4b
JM
1030with other name mangling versions. Like all options that change the
1031ABI, all C++ code, @emph{including libgcc.a} must be built with the same
1032setting of this option.
74291a4b
MM
1033
1034@item -fhandle-signatures
1035Recognize the @code{signature} and @code{sigof} keywords for specifying
1036abstract types. The default (@samp{-fno-handle-signatures}) is not to
1037recognize them. @xref{C++ Signatures, Type Abstraction using
1038Signatures}.
1039
95c81fb8
ML
1040@item -fhonor-std
1041Treat the @code{namespace std} as a namespace, instead of ignoring
1042it. For compatibility with earlier versions of g++, the compiler will,
1043by default, ignore @code{namespace-declarations},
1044@code{using-declarations}, @code{using-directives}, and
1045@code{namespace-names}, if they involve @code{std}.
1046
74291a4b
MM
1047@item -fhuge-objects
1048Support virtual function calls for objects that exceed the size
1049representable by a @samp{short int}. Users should not use this flag by
1dc5fc4b 1050default; if you need to use it, the compiler will tell you so.
74291a4b
MM
1051
1052This flag is not useful when compiling with -fvtable-thunks.
1053
1dc5fc4b
JM
1054Like all options that change the ABI, all C++ code, @emph{including
1055libgcc} must be built with the same setting of this option.
1056
1057@item -fno-implicit-templates
1058Never emit code for templates which are instantiated implicitly (i.e. by
1059use); only emit code for explicit instantiations. @xref{Template
1060Instantiation}, for more information.
1061
2ce3c6c6
JM
1062@item -finit-priority
1063Support @samp{__attribute__ ((init_priority (n)))} for controlling the
1064order of initialization of file-scope objects. On ELF targets, this
1065requires GNU ld 2.10 or later.
1066
74291a4b
MM
1067@item -fno-implement-inlines
1068To save space, do not emit out-of-line copies of inline functions
1069controlled by @samp{#pragma implementation}. This will cause linker
1070errors if these functions are not inlined everywhere they are called.
1071
37f6b6bf
MM
1072@item -fname-mangling-version-@var{n}
1073Control the way in which names are mangled. Version 0 is compatible
1074with versions of g++ before 2.8. Version 1 is the default. Version 1
1075will allow correct mangling of function templates. For example,
1076version 0 mangling does not mangle foo<int, double> and foo<int, char>
1077given this declaration:
1078
1079@example
1080template <class T, class U> void foo(T t);
1081@end example
1082
74291a4b
MM
1083@item -foperator-names
1084Recognize the operator name keywords @code{and}, @code{bitand},
1085@code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
1086synonyms for the symbols they refer to. @samp{-ansi} implies
1087@samp{-foperator-names}.
1088
4f8b4fd9
JM
1089@item -fno-optional-diags
1090Disable diagnostics that the standard says a compiler does not need to
1091issue. Currently, this means the diagnostic for a name having multiple
1092meanings within a class.
1093
8c7707b0
JM
1094@item -fpermissive
1095Downgrade messages about nonconformant code from errors to warnings. By
1096default, g++ effectively sets @samp{-pedantic-errors} without
1097@samp{-pedantic}; this option reverses that. This behavior and this
1098option are superceded by @samp{-pedantic}, which works as it does for GNU C.
1099
8c81598d
JM
1100@item -frepo
1101Enable automatic template instantiation. This option also implies
1102@samp{-fno-implicit-templates}. @xref{Template Instantiation}, for more
1103information.
1104
8c7707b0
JM
1105@item -fno-rtti
1106Disable generation of the information used by C++ runtime type
1107identification features (@samp{dynamic_cast} and @samp{typeid}). If you
1108don't use those parts of the language (or exception handling, which uses
1109@samp{dynamic_cast} internally), you can save some space by using this
1110flag.
1111
1dc5fc4b
JM
1112@item -fstrict-prototype
1113Within an @samp{extern "C"} linkage specification, treat a function
1114declaration with no arguments, such as @samp{int foo ();}, as declaring
1115the function to take no arguments. Normally, such a declaration means
1116that the function @code{foo} can take any combination of arguments, as
1117in C. @samp{-pedantic} implies @samp{-fstrict-prototype} unless
1118overridden with @samp{-fno-strict-prototype}.
1119
1120Specifying this option will also suppress implicit declarations of
1121functions.
1122
1123This flag no longer affects declarations with C++ linkage.
1124
53f23613 1125@item -fsquangle
bd762873 1126@itemx -fno-squangle
53f23613
BK
1127@samp{-fsquangle} will enable a compressed form of name mangling for
1128identifiers. In particular, it helps to shorten very long names by recognizing
1129types and class names which occur more than once, replacing them with special
1130short ID codes. This option also requires any C++ libraries being used to
1131be compiled with this option as well. The compiler has this disabled (the
1132equivalent of @samp{-fno-squangle}) by default.
1133
1dc5fc4b
JM
1134Like all options that change the ABI, all C++ code, @emph{including
1135libgcc.a} must be built with the same setting of this option.
1136
1137@item -ftemplate-depth-@var{n}
1138Set the maximum instantiation depth for template classes to @var{n}.
1139A limit on the template instantiation depth is needed to detect
1140endless recursions during template class instantiation. ANSI/ISO C++
1141conforming programs must not rely on a maximum depth greater than 17.
1142
74291a4b
MM
1143@item -fthis-is-variable
1144Permit assignment to @code{this}. The incorporation of user-defined
1145free store management into C++ has made assignment to @samp{this} an
1146anachronism. Therefore, by default it is invalid to assign to
1147@code{this} within a class member function; that is, GNU C++ treats
1148@samp{this} in a member function of class @code{X} as a non-lvalue of
1149type @samp{X *}. However, for backwards compatibility, you can make it
1150valid with @samp{-fthis-is-variable}.
1151
1152@item -fvtable-thunks
1153Use @samp{thunks} to implement the virtual function dispatch table
1154(@samp{vtable}). The traditional (cfront-style) approach to
1155implementing vtables was to store a pointer to the function and two
1156offsets for adjusting the @samp{this} pointer at the call site. Newer
1157implementations store a single pointer to a @samp{thunk} function which
1158does any necessary adjustment and then calls the target function.
1159
f5a1b0d2
NC
1160This option also enables a heuristic for controlling emission of
1161vtables; if a class has any non-inline virtual functions, the vtable
1162will be emitted in the translation unit containing the first one of
1163those.
1164
1dc5fc4b
JM
1165Like all options that change the ABI, all C++ code, @emph{including
1166libgcc.a} must be built with the same setting of this option.
861bb6c1 1167
74291a4b
MM
1168@item -nostdinc++
1169Do not search for header files in the standard directories specific to
1170C++, but do still search the other standard directories. (This option
e5e809f4 1171is used when building the C++ library.)
74291a4b
MM
1172@end table
1173
1174In addition, these optimization, warning, and code generation options
1175have meanings only for C++ programs:
1176
1177@table @code
1178@item -fno-default-inline
1179Do not assume @samp{inline} for functions defined inside a class scope.
1dc5fc4b
JM
1180@xref{Optimize Options,,Options That Control Optimization}. Note that these
1181functions will have linkage like inline functions; they just won't be
1182inlined by default.
74291a4b 1183
d67343c9
BK
1184@item -Wno-non-template-friend
1185@xref{Warning Options,,Options to Request or Suppress Warnings}.
d770d3b3
JM
1186@item -Wold-style-cast
1187@itemx -Woverloaded-virtual
74291a4b
MM
1188Warnings that apply only to C++ programs. @xref{Warning
1189Options,,Options to Request or Suppress Warnings}.
1190
861bb6c1
JL
1191@item -Weffc++
1192Warn about violation of some style rules from Effective C++ by Scott Myers.
74291a4b
MM
1193@end table
1194
1195@node Warning Options
1196@section Options to Request or Suppress Warnings
1197@cindex options to control warnings
1198@cindex warning messages
1199@cindex messages, warning
1200@cindex suppressing warnings
1201
1202Warnings are diagnostic messages that report constructions which
1203are not inherently erroneous but which are risky or suggest there
1204may have been an error.
1205
1206You can request many specific warnings with options beginning @samp{-W},
1207for example @samp{-Wimplicit} to request warnings on implicit
1208declarations. Each of these specific warning options also has a
1209negative form beginning @samp{-Wno-} to turn off warnings;
1210for example, @samp{-Wno-implicit}. This manual lists only one of the
1211two forms, whichever is not the default.
1212
1213These options control the amount and kinds of warnings produced by GNU
1214CC:
1215
1216@table @code
1217@cindex syntax checking
1218@item -fsyntax-only
1219Check the code for syntax errors, but don't do anything beyond that.
1220
1221@item -pedantic
b1d16193
JL
1222Issue all the warnings demanded by strict ANSI C and ISO C++;
1223reject all programs that use forbidden extensions.
74291a4b 1224
b1d16193 1225Valid ANSI C and ISO C++ programs should compile properly with or without
74291a4b 1226this option (though a rare few will require @samp{-ansi}). However,
b1d16193
JL
1227without this option, certain GNU extensions and traditional C and C++
1228features are supported as well. With this option, they are rejected.
74291a4b
MM
1229
1230@samp{-pedantic} does not cause warning messages for use of the
1231alternate keywords whose names begin and end with @samp{__}. Pedantic
1232warnings are also disabled in the expression that follows
1233@code{__extension__}. However, only system header files should use
1234these escape routes; application programs should avoid them.
1235@xref{Alternate Keywords}.
1236
1237This option is not intended to be @i{useful}; it exists only to satisfy
1238pedants who would otherwise claim that GNU CC fails to support the ANSI
1239standard.
1240
1241Some users try to use @samp{-pedantic} to check programs for strict ANSI
1242C conformance. They soon find that it does not do quite what they want:
1243it finds some non-ANSI practices, but not all---only those for which
1244ANSI C @emph{requires} a diagnostic.
1245
1246A feature to report any failure to conform to ANSI C might be useful in
1247some instances, but would require considerable additional work and would
892d0a6d
AO
1248be quite different from @samp{-pedantic}. We don't have plans to
1249support such a feature in the near future.
74291a4b
MM
1250
1251@item -pedantic-errors
1252Like @samp{-pedantic}, except that errors are produced rather than
1253warnings.
1254
1255@item -w
1256Inhibit all warning messages.
1257
1258@item -Wno-import
1259Inhibit warning messages about the use of @samp{#import}.
1260
1261@item -Wchar-subscripts
1262Warn if an array subscript has type @code{char}. This is a common cause
1263of error, as programmers often forget that this type is signed on some
1264machines.
1265
1266@item -Wcomment
1267Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*}
1268comment, or whenever a Backslash-Newline appears in a @samp{//} comment.
1269
1270@item -Wformat
1271Check calls to @code{printf} and @code{scanf}, etc., to make sure that
1272the arguments supplied have types appropriate to the format string
1273specified.
1274
e9a25f70
JL
1275@item -Wimplicit-int
1276Warn when a declaration does not specify a type.
1277
f5963e61
JL
1278@item -Wimplicit-function-declaration
1279@itemx -Werror-implicit-function-declaration
1280Give a warning (or error) whenever a function is used before being
1281declared.
e9a25f70 1282
74291a4b 1283@item -Wimplicit
e5e809f4
JL
1284Same as @samp{-Wimplicit-int} and @samp{-Wimplicit-function-}@*
1285@samp{declaration}.
861bb6c1
JL
1286
1287@item -Wmain
1288Warn if the type of @samp{main} is suspicious. @samp{main} should be a
1289function with external linkage, returning int, taking either zero
1290arguments, two, or three arguments of appropriate types.
4a870dba
JM
1291
1292@item -Wmultichar
1293Warn if a multicharacter constant (@samp{'FOOF'}) is used. Usually they
1294indicate a typo in the user's code, as they have implementation-defined
1295values, and should not be used in portable code.
861bb6c1 1296
74291a4b
MM
1297@item -Wparentheses
1298Warn if parentheses are omitted in certain contexts, such
1299as when there is an assignment in a context where a truth value
1300is expected, or when operators are nested whose precedence people
1301often get confused about.
1302
e9a25f70
JL
1303Also warn about constructions where there may be confusion to which
1304@code{if} statement an @code{else} branch belongs. Here is an example of
1305such a case:
1306
1307@smallexample
1308@{
1309 if (a)
1310 if (b)
1311 foo ();
1312 else
1313 bar ();
1314@}
1315@end smallexample
1316
1317In C, every @code{else} branch belongs to the innermost possible @code{if}
1318statement, which in this example is @code{if (b)}. This is often not
1319what the programmer expected, as illustrated in the above example by
1320indentation the programmer chose. When there is the potential for this
1321confusion, GNU C will issue a warning when this flag is specified.
1322To eliminate the warning, add explicit braces around the innermost
1323@code{if} statement so there is no way the @code{else} could belong to
1324the enclosing @code{if}. The resulting code would look like this:
1325
1326@smallexample
1327@{
1328 if (a)
1329 @{
1330 if (b)
1331 foo ();
1332 else
1333 bar ();
1334 @}
1335@}
1336@end smallexample
1337
74291a4b
MM
1338@item -Wreturn-type
1339Warn whenever a function is defined with a return-type that defaults
1340to @code{int}. Also warn about any @code{return} statement with no
1341return-value in a function whose return-type is not @code{void}.
1342
1343@item -Wswitch
1344Warn whenever a @code{switch} statement has an index of enumeral type
1345and lacks a @code{case} for one or more of the named codes of that
1346enumeration. (The presence of a @code{default} label prevents this
1347warning.) @code{case} labels outside the enumeration range also
1348provoke warnings when this option is used.
1349
1350@item -Wtrigraphs
1351Warn if any trigraphs are encountered (assuming they are enabled).
1352
1353@item -Wunused
1354Warn whenever a variable is unused aside from its declaration,
1355whenever a function is declared static but never defined, whenever a
1356label is declared but not used, and whenever a statement computes a
1357result that is explicitly not used.
1358
956d6950
JL
1359In order to get a warning about an unused function parameter, you must
1360specify both @samp{-W} and @samp{-Wunused}.
1361
74291a4b 1362To suppress this warning for an expression, simply cast it to void. For
736b02fd 1363unused variables, parameters and labels, use the @samp{unused} attribute
74291a4b
MM
1364(@pxref{Variable Attributes}).
1365
1366@item -Wuninitialized
1367An automatic variable is used without first being initialized.
1368
1369These warnings are possible only in optimizing compilation,
1370because they require data flow information that is computed only
1371when optimizing. If you don't specify @samp{-O}, you simply won't
1372get these warnings.
1373
1374These warnings occur only for variables that are candidates for
1375register allocation. Therefore, they do not occur for a variable that
1376is declared @code{volatile}, or whose address is taken, or whose size
1377is other than 1, 2, 4 or 8 bytes. Also, they do not occur for
1378structures, unions or arrays, even when they are in registers.
1379
1380Note that there may be no warning about a variable that is used only
1381to compute a value that itself is never used, because such
1382computations may be deleted by data flow analysis before the warnings
1383are printed.
1384
1385These warnings are made optional because GNU CC is not smart
1386enough to see all the reasons why the code might be correct
1387despite appearing to have an error. Here is one example of how
1388this can happen:
1389
1390@smallexample
1391@{
1392 int x;
1393 switch (y)
1394 @{
1395 case 1: x = 1;
1396 break;
1397 case 2: x = 4;
1398 break;
1399 case 3: x = 5;
1400 @}
1401 foo (x);
1402@}
1403@end smallexample
1404
1405@noindent
1406If the value of @code{y} is always 1, 2 or 3, then @code{x} is
1407always initialized, but GNU CC doesn't know this. Here is
1408another common case:
1409
1410@smallexample
1411@{
1412 int save_y;
1413 if (change_y) save_y = y, y = new_y;
1414 @dots{}
1415 if (change_y) y = save_y;
1416@}
1417@end smallexample
1418
1419@noindent
1420This has no bug because @code{save_y} is used only if it is set.
1421
1422Some spurious warnings can be avoided if you declare all the functions
1423you use that never return as @code{noreturn}. @xref{Function
1424Attributes}.
1425
1426@item -Wreorder (C++ only)
1427@cindex reordering, warning
1428@cindex warning for reordering of member initializers
1429Warn when the order of member initializers given in the code does not
1430match the order in which they must be executed. For instance:
1431
1432@smallexample
1433struct A @{
1434 int i;
1435 int j;
1436 A(): j (0), i (1) @{ @}
1437@};
1438@end smallexample
1439
1440Here the compiler will warn that the member initializers for @samp{i}
1441and @samp{j} will be rearranged to match the declaration order of the
1442members.
1443
74291a4b
MM
1444@item -Wtemplate-debugging
1445@cindex template debugging
1446When using templates in a C++ program, warn if debugging is not yet
1447fully available (C++ only).
1448
d300e551
NC
1449@item -Wunknown-pragmas
1450@cindex warning for unknown pragmas
1451@cindex unknown pragmas, warning
1452@cindex pragmas, warning of unknown
1453Warn when a #pragma directive is encountered which is not understood by
1454GCC. If this command line option is used, warnings will even be issued
1455for unknown pragmas in system header files. This is not the case if
1456the warnings were only enabled by the @samp{-Wall} command line option.
1457
74291a4b
MM
1458@item -Wall
1459All of the above @samp{-W} options combined. This enables all the
1460warnings about constructions that some users consider questionable, and
1461that are easy to avoid (or modify to prevent the warning), even in
1462conjunction with macros.
1463@end table
1464
1465The following @samp{-W@dots{}} options are not implied by @samp{-Wall}.
1466Some of them warn about constructions that users generally do not
1467consider questionable, but which occasionally you might wish to check
1468for; others warn about constructions that are necessary or hard to avoid
1469in some cases, and there is no simple way to modify the code to suppress
1470the warning.
1471
1472@table @code
1473@item -W
1474Print extra warning messages for these events:
1475
1476@itemize @bullet
1477@cindex @code{longjmp} warnings
1478@item
1479A nonvolatile automatic variable might be changed by a call to
1480@code{longjmp}. These warnings as well are possible only in
1481optimizing compilation.
1482
1483The compiler sees only the calls to @code{setjmp}. It cannot know
1484where @code{longjmp} will be called; in fact, a signal handler could
1485call it at any point in the code. As a result, you may get a warning
1486even when there is in fact no problem because @code{longjmp} cannot
1487in fact be called at the place which would cause a problem.
1488
1489@item
1490A function can return either with or without a value. (Falling
1491off the end of the function body is considered returning without
1492a value.) For example, this function would evoke such a
1493warning:
1494
1495@smallexample
1496@group
1497foo (a)
1498@{
1499 if (a > 0)
1500 return a;
1501@}
1502@end group
1503@end smallexample
1504
1505@item
1506An expression-statement or the left-hand side of a comma expression
1507contains no side effects.
1508To suppress the warning, cast the unused expression to void.
1509For example, an expression such as @samp{x[i,j]} will cause a warning,
1510but @samp{x[(void)i,j]} will not.
1511
1512@item
1513An unsigned value is compared against zero with @samp{<} or @samp{<=}.
1514
1515@item
1516A comparison like @samp{x<=y<=z} appears; this is equivalent to
1517@samp{(x<=y ? 1 : 0) <= z}, which is a different interpretation from
1518that of ordinary mathematical notation.
1519
1520@item
1521Storage-class specifiers like @code{static} are not the first things in
1522a declaration. According to the C Standard, this usage is obsolescent.
1523
1524@item
1525If @samp{-Wall} or @samp{-Wunused} is also specified, warn about unused
1526arguments.
1527
e9a25f70
JL
1528@item
1529A comparison between signed and unsigned values could produce an
1530incorrect result when the signed value is converted to unsigned.
e5e809f4 1531(But don't warn if @samp{-Wno-sign-compare} is also specified.)
e9a25f70 1532
74291a4b
MM
1533@item
1534An aggregate has a partly bracketed initializer.
1535For example, the following code would evoke such a warning,
1536because braces are missing around the initializer for @code{x.h}:
1537
1538@smallexample
1539struct s @{ int f, g; @};
1540struct t @{ struct s h; int i; @};
1541struct t x = @{ 1, 2, 3 @};
1542@end smallexample
dbde0d5d
BH
1543
1544@item
1545An aggregate has an initializer which does not initialize all members.
1546For example, the following code would cause such a warning, because
1547@code{x.h} would be implicitly initialized to zero:
1548
1549@smallexample
1550struct s @{ int f, g, h; @};
1551struct s x = @{ 3, 4 @};
1552@end smallexample
74291a4b
MM
1553@end itemize
1554
1555@item -Wtraditional
1556Warn about certain constructs that behave differently in traditional and
1557ANSI C.
1558
1559@itemize @bullet
1560@item
1561Macro arguments occurring within string constants in the macro body.
1562These would substitute the argument in traditional C, but are part of
1563the constant in ANSI C.
1564
1565@item
1566A function declared external in one block and then used after the end of
1567the block.
1568
1569@item
1570A @code{switch} statement has an operand of type @code{long}.
db838bb8
KG
1571
1572@item
1573A non-@code{static} function declaration follows a @code{static} one.
1574This construct is not accepted by some traditional C compilers.
74291a4b
MM
1575@end itemize
1576
861bb6c1
JL
1577@item -Wundef
1578Warn if an undefined identifier is evaluated in an @samp{#if} directive.
1579
74291a4b
MM
1580@item -Wshadow
1581Warn whenever a local variable shadows another local variable.
1582
1583@item -Wid-clash-@var{len}
1584Warn whenever two distinct identifiers match in the first @var{len}
1585characters. This may help you prepare a program that will compile
1586with certain obsolete, brain-damaged compilers.
1587
1588@item -Wlarger-than-@var{len}
1589Warn whenever an object of larger than @var{len} bytes is defined.
1590
1591@item -Wpointer-arith
1592Warn about anything that depends on the ``size of'' a function type or
1593of @code{void}. GNU C assigns these types a size of 1, for
1594convenience in calculations with @code{void *} pointers and pointers
1595to functions.
1596
1597@item -Wbad-function-cast
1598Warn whenever a function call is cast to a non-matching type.
1599For example, warn if @code{int malloc()} is cast to @code{anything *}.
1600
1601@item -Wcast-qual
1602Warn whenever a pointer is cast so as to remove a type qualifier from
1603the target type. For example, warn if a @code{const char *} is cast
1604to an ordinary @code{char *}.
1605
1606@item -Wcast-align
1607Warn whenever a pointer is cast such that the required alignment of the
1608target is increased. For example, warn if a @code{char *} is cast to
1609an @code{int *} on machines where integers can only be accessed at
1610two- or four-byte boundaries.
1611
1612@item -Wwrite-strings
1613Give string constants the type @code{const char[@var{length}]} so that
1614copying the address of one into a non-@code{const} @code{char *}
1615pointer will get a warning. These warnings will help you find at
1616compile time code that can try to write into a string constant, but
1617only if you have been very careful about using @code{const} in
1618declarations and prototypes. Otherwise, it will just be a nuisance;
1619this is why we did not make @samp{-Wall} request these warnings.
1620
1621@item -Wconversion
1622Warn if a prototype causes a type conversion that is different from what
1623would happen to the same argument in the absence of a prototype. This
1624includes conversions of fixed point to floating and vice versa, and
1625conversions changing the width or signedness of a fixed point argument
1626except when the same as the default promotion.
1627
1628Also, warn if a negative integer constant expression is implicitly
1629converted to an unsigned type. For example, warn about the assignment
1630@code{x = -1} if @code{x} is unsigned. But do not warn about explicit
1631casts like @code{(unsigned) -1}.
1632
e9a25f70
JL
1633@item -Wsign-compare
1634@cindex warning for comparison of signed and unsigned values
1635@cindex comparison of signed and unsigned values, warning
1636@cindex signed and unsigned values, comparison warning
1637Warn when a comparison between signed and unsigned values could produce
1638an incorrect result when the signed value is converted to unsigned.
1639This warning is also enabled by @samp{-W}; to get the other warnings
1640of @samp{-W} without this warning, use @samp{-W -Wno-sign-compare}.
1641
74291a4b
MM
1642@item -Waggregate-return
1643Warn if any functions that return structures or unions are defined or
1644called. (In languages where you can return an array, this also elicits
1645a warning.)
1646
1647@item -Wstrict-prototypes
1648Warn if a function is declared or defined without specifying the
1649argument types. (An old-style function definition is permitted without
1650a warning if preceded by a declaration which specifies the argument
1651types.)
1652
1653@item -Wmissing-prototypes
1654Warn if a global function is defined without a previous prototype
1655declaration. This warning is issued even if the definition itself
1656provides a prototype. The aim is to detect global functions that fail
1657to be declared in header files.
1658
1659@item -Wmissing-declarations
1660Warn if a global function is defined without a previous declaration.
1661Do so even if the definition itself provides a prototype.
1662Use this option to detect global functions that are not declared in
1663header files.
1664
0ca3fb0a
KG
1665@item -Wmissing-noreturn
1666Warn about functions which might be candidates for attribute @code{noreturn}.
1667Note these are only possible candidates, not absolute ones. Care should
1668be taken to manually verify functions actually do not ever return before
1669adding the @code{noreturn} attribute, otherwise subtle code generation
1670bugs could be introduced.
1671
74291a4b
MM
1672@item -Wredundant-decls
1673Warn if anything is declared more than once in the same scope, even in
1674cases where multiple declaration is valid and changes nothing.
1675
1676@item -Wnested-externs
1677Warn if an @code{extern} declaration is encountered within an function.
1678
d67343c9
BK
1679@item -Wno-non-template-friend
1680Disable warnings when non-templatized friend functions are declared
1681within a template. With the advent of explicit template specification
1682support in g++, if the name of the friend is an unqualified-id (ie,
1683@samp{friend foo(int)}), the C++ language specification demands that the
1684friend declare or define an ordinary, nontemplate function. (Section
168514.5.3). Before g++ implemented explicit specification, unqualified-ids
1686could be interpreted as a particular specialization of a templatized
1687function. Because this non-conforming behavior is no longer the default
1688behavior for g++, @samp{-Wnon-template-friend} allows the compiler to
1689check existing code for potential trouble spots, and is on by default.
1690This new compiler behavior can also be turned off with the flag
1691@samp{-fguiding-decls}, which activates the older, non-specification
1692compiler code, or with @samp{-Wno-non-template-friend} which keeps the
1693conformant compiler code but disables the helpful warning.
1694
74291a4b
MM
1695@item -Winline
1696Warn if a function can not be inlined, and either it was declared as inline,
1697or else the @samp{-finline-functions} option was given.
1698
d770d3b3
JM
1699@item -Wold-style-cast
1700Warn if an old-style (C-style) cast is used within a program.
1701
74291a4b
MM
1702@item -Woverloaded-virtual
1703@cindex overloaded virtual fn, warning
1704@cindex warning for overloaded virtual fn
1705Warn when a derived class function declaration may be an error in
1706defining a virtual function (C++ only). In a derived class, the
1707definitions of virtual functions must match the type signature of a
1708virtual function declared in the base class. With this option, the
1709compiler warns when you define a function with the same name as a
1710virtual function, but with a type signature that does not match any
1711declarations from the base class.
1712
1713@item -Wsynth (C++ only)
1714@cindex warning for synthesized methods
1715@cindex synthesized methods, warning
1716Warn when g++'s synthesis behavior does not match that of cfront. For
1717instance:
1718
1719@smallexample
1720struct A @{
1721 operator int ();
1722 A& operator = (int);
1723@};
1724
1725main ()
1726@{
1727 A a,b;
1728 a = b;
1729@}
1730@end smallexample
1731
1732In this example, g++ will synthesize a default @samp{A& operator =
1733(const A&);}, while cfront will use the user-defined @samp{operator =}.
1734
795add94
VM
1735@item -Wlong-long
1736Warn if @samp{long long} type is used. This is default. To inhibit
1737the warning messages, use @samp{-Wno-long-long}. Flags
1738@samp{-Wlong-long} and @samp{-Wno-long-long} are taken into account
1739only when @samp{-pedantic} flag is used.
1740
74291a4b
MM
1741@item -Werror
1742Make all warnings into errors.
1743@end table
1744
1745@node Debugging Options
1746@section Options for Debugging Your Program or GNU CC
1747@cindex options, debugging
1748@cindex debugging information options
1749
1750GNU CC has various special options that are used for debugging
1751either your program or GCC:
1752
1753@table @code
1754@item -g
1755Produce debugging information in the operating system's native format
1756(stabs, COFF, XCOFF, or DWARF). GDB can work with this debugging
1757information.
1758
1759On most systems that use stabs format, @samp{-g} enables use of extra
1760debugging information that only GDB can use; this extra information
1761makes debugging work better in GDB but will probably make other debuggers
1762crash or
1763refuse to read the program. If you want to control for certain whether
1764to generate the extra information, use @samp{-gstabs+}, @samp{-gstabs},
861bb6c1 1765@samp{-gxcoff+}, @samp{-gxcoff}, @samp{-gdwarf-1+}, or @samp{-gdwarf-1}
74291a4b
MM
1766(see below).
1767
1768Unlike most other C compilers, GNU CC allows you to use @samp{-g} with
1769@samp{-O}. The shortcuts taken by optimized code may occasionally
1770produce surprising results: some variables you declared may not exist
1771at all; flow of control may briefly move where you did not expect it;
1772some statements may not be executed because they compute constant
1773results or their values were already at hand; some statements may
1774execute in different places because they were moved out of loops.
1775
1776Nevertheless it proves possible to debug optimized output. This makes
1777it reasonable to use the optimizer for programs that might have bugs.
1778
1779The following options are useful when GNU CC is generated with the
1780capability for more than one debugging format.
1781
1782@item -ggdb
861bb6c1
JL
1783Produce debugging information for use by GDB. This means to use the
1784most expressive format available (DWARF 2, stabs, or the native format
1785if neither of those are supported), including GDB extensions if at all
1786possible.
74291a4b
MM
1787
1788@item -gstabs
1789Produce debugging information in stabs format (if that is supported),
1790without GDB extensions. This is the format used by DBX on most BSD
1791systems. On MIPS, Alpha and System V Release 4 systems this option
1792produces stabs debugging output which is not understood by DBX or SDB.
1793On System V Release 4 systems this option requires the GNU assembler.
1794
1795@item -gstabs+
1796Produce debugging information in stabs format (if that is supported),
1797using GNU extensions understood only by the GNU debugger (GDB). The
1798use of these extensions is likely to make other debuggers crash or
1799refuse to read the program.
1800
1801@item -gcoff
1802Produce debugging information in COFF format (if that is supported).
1803This is the format used by SDB on most System V systems prior to
1804System V Release 4.
1805
1806@item -gxcoff
1807Produce debugging information in XCOFF format (if that is supported).
1808This is the format used by the DBX debugger on IBM RS/6000 systems.
1809
1810@item -gxcoff+
1811Produce debugging information in XCOFF format (if that is supported),
1812using GNU extensions understood only by the GNU debugger (GDB). The
1813use of these extensions is likely to make other debuggers crash or
1814refuse to read the program, and may cause assemblers other than the GNU
1815assembler (GAS) to fail with an error.
1816
1817@item -gdwarf
861bb6c1
JL
1818Produce debugging information in DWARF version 1 format (if that is
1819supported). This is the format used by SDB on most System V Release 4
1820systems.
74291a4b
MM
1821
1822@item -gdwarf+
861bb6c1
JL
1823Produce debugging information in DWARF version 1 format (if that is
1824supported), using GNU extensions understood only by the GNU debugger
1825(GDB). The use of these extensions is likely to make other debuggers
1826crash or refuse to read the program.
1827
1828@item -gdwarf-2
1829Produce debugging information in DWARF version 2 format (if that is
1830supported). This is the format used by DBX on IRIX 6.
74291a4b
MM
1831
1832@item -g@var{level}
1833@itemx -ggdb@var{level}
1834@itemx -gstabs@var{level}
1835@itemx -gcoff@var{level}
1836@itemx -gxcoff@var{level}
1837@itemx -gdwarf@var{level}
861bb6c1 1838@itemx -gdwarf-2@var{level}
74291a4b
MM
1839Request debugging information and also use @var{level} to specify how
1840much information. The default level is 2.
1841
1842Level 1 produces minimal information, enough for making backtraces in
1843parts of the program that you don't plan to debug. This includes
1844descriptions of functions and external variables, but no information
1845about local variables and no line numbers.
1846
1847Level 3 includes extra information, such as all the macro definitions
1848present in the program. Some debuggers support macro expansion when
1849you use @samp{-g3}.
1850
1851@cindex @code{prof}
1852@item -p
1853Generate extra code to write profile information suitable for the
1854analysis program @code{prof}. You must use this option when compiling
1855the source files you want data about, and you must also use it when
1856linking.
1857
1858@cindex @code{gprof}
1859@item -pg
1860Generate extra code to write profile information suitable for the
1861analysis program @code{gprof}. You must use this option when compiling
1862the source files you want data about, and you must also use it when
1863linking.
1864
1865@cindex @code{tcov}
1866@item -a
1867Generate extra code to write profile information for basic blocks, which will
1868record the number of times each basic block is executed, the basic block start
1869address, and the function name containing the basic block. If @samp{-g} is
1870used, the line number and filename of the start of the basic block will also be
1871recorded. If not overridden by the machine description, the default action is
1872to append to the text file @file{bb.out}.
1873
1874This data could be analyzed by a program like @code{tcov}. Note,
1875however, that the format of the data is not what @code{tcov} expects.
1876Eventually GNU @code{gprof} should be extended to process this data.
1877
898f531b
JL
1878@item -Q
1879Makes the compiler print out each function name as it is compiled, and
1880print some statistics about each pass when it finishes.
1881
74291a4b
MM
1882@item -ax
1883Generate extra code to profile basic blocks. Your executable will
1884produce output that is a superset of that produced when @samp{-a} is
1885used. Additional output is the source and target address of the basic
1886blocks where a jump takes place, the number of times a jump is executed,
1887and (optionally) the complete sequence of basic blocks being executed.
1888The output is appended to file @file{bb.out}.
1889
1890You can examine different profiling aspects without recompilation. Your
956d6950 1891executable will read a list of function names from file @file{bb.in}.
74291a4b
MM
1892Profiling starts when a function on the list is entered and stops when
1893that invocation is exited. To exclude a function from profiling, prefix
1894its name with `-'. If a function name is not unique, you can
1895disambiguate it by writing it in the form
1896@samp{/path/filename.d:functionname}. Your executable will write the
1897available paths and filenames in file @file{bb.out}.
1898
1899Several function names have a special meaning:
1900@table @code
1901@item __bb_jumps__
1902Write source, target and frequency of jumps to file @file{bb.out}.
1903@item __bb_hidecall__
1904Exclude function calls from frequency count.
1905@item __bb_showret__
1906Include function returns in frequency count.
1907@item __bb_trace__
1908Write the sequence of basic blocks executed to file @file{bbtrace.gz}.
1909The file will be compressed using the program @samp{gzip}, which must
1910exist in your @code{PATH}. On systems without the @samp{popen}
1911function, the file will be named @file{bbtrace} and will not be
1912compressed. @strong{Profiling for even a few seconds on these systems
1913will produce a very large file.} Note: @code{__bb_hidecall__} and
1914@code{__bb_showret__} will not affect the sequence written to
1915@file{bbtrace.gz}.
1916@end table
1917
1918Here's a short example using different profiling parameters
1919in file @file{bb.in}. Assume function @code{foo} consists of basic blocks
19201 and 2 and is called twice from block 3 of function @code{main}. After
1921the calls, block 3 transfers control to block 4 of @code{main}.
1922
1923With @code{__bb_trace__} and @code{main} contained in file @file{bb.in},
1924the following sequence of blocks is written to file @file{bbtrace.gz}:
19250 3 1 2 1 2 4. The return from block 2 to block 3 is not shown, because
1926the return is to a point inside the block and not to the top. The
1927block address 0 always indicates, that control is transferred
1928to the trace from somewhere outside the observed functions. With
1929@samp{-foo} added to @file{bb.in}, the blocks of function
1930@code{foo} are removed from the trace, so only 0 3 4 remains.
1931
1932With @code{__bb_jumps__} and @code{main} contained in file @file{bb.in},
1933jump frequencies will be written to file @file{bb.out}. The
1934frequencies are obtained by constructing a trace of blocks
1935and incrementing a counter for every neighbouring pair of blocks
1936in the trace. The trace 0 3 1 2 1 2 4 displays the following
1937frequencies:
1938
1939@example
1940Jump from block 0x0 to block 0x3 executed 1 time(s)
1941Jump from block 0x3 to block 0x1 executed 1 time(s)
1942Jump from block 0x1 to block 0x2 executed 2 time(s)
1943Jump from block 0x2 to block 0x1 executed 1 time(s)
1944Jump from block 0x2 to block 0x4 executed 1 time(s)
1945@end example
1946
1947With @code{__bb_hidecall__}, control transfer due to call instructions
1948is removed from the trace, that is the trace is cut into three parts: 0
19493 4, 0 1 2 and 0 1 2. With @code{__bb_showret__}, control transfer due
1950to return instructions is added to the trace. The trace becomes: 0 3 1
19512 3 1 2 3 4. Note, that this trace is not the same, as the sequence
1952written to @file{bbtrace.gz}. It is solely used for counting jump
1953frequencies.
1954
861bb6c1
JL
1955@item -fprofile-arcs
1956Instrument @dfn{arcs} during compilation. For each function of your
1957program, GNU CC creates a program flow graph, then finds a spanning tree
1958for the graph. Only arcs that are not on the spanning tree have to be
1959instrumented: the compiler adds code to count the number of times that these
1960arcs are executed. When an arc is the only exit or only entrance to a
1961block, the instrumentation code can be added to the block; otherwise, a
1962new basic block must be created to hold the instrumentation code.
1963
1964Since not every arc in the program must be instrumented, programs
1965compiled with this option run faster than programs compiled with
1966@samp{-a}, which adds instrumentation code to every basic block in the
1967program. The tradeoff: since @code{gcov} does not have
1968execution counts for all branches, it must start with the execution
1969counts for the instrumented branches, and then iterate over the program
1970flow graph until the entire graph has been solved. Hence, @code{gcov}
1971runs a little more slowly than a program which uses information from
1972@samp{-a}.
1973
1974@samp{-fprofile-arcs} also makes it possible to estimate branch
1975probabilities, and to calculate basic block execution counts. In
1976general, basic block execution counts do not give enough information to
1977estimate all branch probabilities. When the compiled program exits, it
1978saves the arc execution counts to a file called
1979@file{@var{sourcename}.da}. Use the compiler option
1980@samp{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
1981Control Optimization}) when recompiling, to optimize using estimated
1982branch probabilities.
1983
1984@need 2000
1985@item -ftest-coverage
1986Create data files for the @code{gcov} code-coverage utility
1987(@pxref{Gcov,, @code{gcov}: a GNU CC Test Coverage Program}).
1988The data file names begin with the name of your source file:
1989
1990@table @code
1991@item @var{sourcename}.bb
1992A mapping from basic blocks to line numbers, which @code{gcov} uses to
1993associate basic block execution counts with line numbers.
1994
1995@item @var{sourcename}.bbg
1996A list of all arcs in the program flow graph. This allows @code{gcov}
1997to reconstruct the program flow graph, so that it can compute all basic
1998block and arc execution counts from the information in the
1999@code{@var{sourcename}.da} file (this last file is the output from
2000@samp{-fprofile-arcs}).
2001@end table
2002
956d6950
JL
2003@item -Q
2004Makes the compiler print out each function name as it is compiled, and
2005print some statistics about each pass when it finishes.
2006
74291a4b
MM
2007@item -d@var{letters}
2008Says to make debugging dumps during compilation at times specified by
2009@var{letters}. This is used for debugging the compiler. The file names
2010for most of the dumps are made by appending a word to the source file
2011name (e.g. @file{foo.c.rtl} or @file{foo.c.jump}). Here are the
2012possible letters for use in @var{letters}, and their meanings:
2013
2014@table @samp
956d6950
JL
2015@item b
2016Dump after computing branch probabilities, to @file{@var{file}.bp}.
032713aa
NC
2017@item c
2018Dump after instruction combination, to the file @file{@var{file}.combine}.
2019@item d
2020Dump after delayed branch scheduling, to @file{@var{file}.dbr}.
2021@item D
f5963e61
JL
2022Dump all macro definitions, at the end of preprocessing, in addition to
2023normal output.
2024@item y
2025Dump debugging information during parsing, to standard error.
2026@item r
2027Dump after RTL generation, to @file{@var{file}.rtl}.
2028@item x
2029Just generate RTL for a function instead of compiling it. Usually used
2030with @samp{r}.
2031@item j
2032Dump after first jump optimization, to @file{@var{file}.jump}.
2033@item s
2034Dump after CSE (including the jump optimization that sometimes
2035follows CSE), to @file{@var{file}.cse}.
2036@item F
032713aa 2037Dump after purging ADDRESSOF, to @file{@var{file}.addressof}.
74291a4b
MM
2038@item f
2039Dump after flow analysis, to @file{@var{file}.flow}.
74291a4b 2040@item g
032713aa 2041Dump after global register allocation, to @file{@var{file}.greg}.
7506f491
DE
2042@item G
2043Dump after GCSE, to @file{@var{file}.gcse}.
032713aa
NC
2044@item j
2045Dump after first jump optimization, to @file{@var{file}.jump}.
74291a4b
MM
2046@item J
2047Dump after last jump optimization, to @file{@var{file}.jump2}.
74291a4b
MM
2048@item k
2049Dump after conversion from registers to stack, to @file{@var{file}.stack}.
032713aa
NC
2050@item l
2051Dump after local register allocation, to @file{@var{file}.lreg}.
2052@item L
2053Dump after loop optimization, to @file{@var{file}.loop}.
2054@item M
2055Dump after performing the machine dependent reorganisation pass, to
2056@file{@var{file}.mach}.
2057@item N
2058Dump after the register move pass, to @file{@var{file}.regmove}.
2059@item r
2060Dump after RTL generation, to @file{@var{file}.rtl}.
2061@item R
2062Dump after the second instruction scheduling pass, to @file{@var{file}.sched2}.
2063@item s
2064Dump after CSE (including the jump optimization that sometimes follows
2065CSE), to @file{@var{file}.cse}.
2066@item S
2067Dump after the first instruction scheduling pass, to @file{@var{file}.sched}.
2068@item t
2069Dump after the second CSE pass (including the jump optimization that
2070sometimes follows CSE), to @file{@var{file}.cse2}.
2071@item x
2072Just generate RTL for a function instead of compiling it. Usually used
2073with @samp{r}.
74291a4b
MM
2074@item a
2075Produce all the dumps listed above.
2076@item m
2077Print statistics on memory usage, at the end of the run, to
2078standard error.
2079@item p
2080Annotate the assembler output with a comment indicating which
2081pattern and alternative was used.
032713aa
NC
2082@item y
2083Dump debugging information during parsing, to standard error.
74291a4b
MM
2084@item A
2085Annotate the assembler output with miscellaneous debugging information.
2086@end table
2087
b707b450
R
2088@item -fdump-unnumbered
2089When doing debugging dumps (see -d option above), suppress instruction
2090numbers and line number note output. This makes it more feasible to
2091use diff on debugging dumps for compiler invokations with different
2092options, in particular with and without -g.
2093
74291a4b
MM
2094@item -fpretend-float
2095When running a cross-compiler, pretend that the target machine uses the
2096same floating point format as the host machine. This causes incorrect
2097output of the actual floating constants, but the actual instruction
2098sequence will probably be the same as GNU CC would make when running on
2099the target machine.
2100
2101@item -save-temps
2102Store the usual ``temporary'' intermediate files permanently; place them
2103in the current directory and name them based on the source file. Thus,
2104compiling @file{foo.c} with @samp{-c -save-temps} would produce files
2105@file{foo.i} and @file{foo.s}, as well as @file{foo.o}.
2106
2107@item -print-file-name=@var{library}
2108Print the full absolute name of the library file @var{library} that
2109would be used when linking---and don't do anything else. With this
2110option, GNU CC does not compile or link anything; it just prints the
2111file name.
2112
2113@item -print-prog-name=@var{program}
2114Like @samp{-print-file-name}, but searches for a program such as @samp{cpp}.
2115
2116@item -print-libgcc-file-name
2117Same as @samp{-print-file-name=libgcc.a}.
2118
2119This is useful when you use @samp{-nostdlib} or @samp{-nodefaultlibs}
2120but you do want to link with @file{libgcc.a}. You can do
2121
2122@example
2123gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
2124@end example
2125
2126@item -print-search-dirs
2127Print the name of the configured installation directory and a list of
2128program and library directories gcc will search---and don't do anything else.
2129
2130This is useful when gcc prints the error message
2131@samp{installation problem, cannot exec cpp: No such file or directory}.
2132To resolve this you either need to put @file{cpp} and the other compiler
2133components where gcc expects to find them, or you can set the environment
2134variable @code{GCC_EXEC_PREFIX} to the directory where you installed them.
2135Don't forget the trailing '/'.
2136@xref{Environment Variables}.
2137@end table
2138
2139@node Optimize Options
2140@section Options That Control Optimization
2141@cindex optimize options
2142@cindex options, optimization
2143
2144These options control various sorts of optimizations:
2145
2146@table @code
2147@item -O
2148@itemx -O1
2149Optimize. Optimizing compilation takes somewhat more time, and a lot
2150more memory for a large function.
2151
2152Without @samp{-O}, the compiler's goal is to reduce the cost of
2153compilation and to make debugging produce the expected results.
2154Statements are independent: if you stop the program with a breakpoint
2155between statements, you can then assign a new value to any variable or
2156change the program counter to any other statement in the function and
2157get exactly the results you would expect from the source code.
2158
2159Without @samp{-O}, the compiler only allocates variables declared
2160@code{register} in registers. The resulting compiled code is a little
2161worse than produced by PCC without @samp{-O}.
2162
2163With @samp{-O}, the compiler tries to reduce code size and execution
2164time.
2165
2166When you specify @samp{-O}, the compiler turns on @samp{-fthread-jumps}
2167and @samp{-fdefer-pop} on all machines. The compiler turns on
2168@samp{-fdelayed-branch} on machines that have delay slots, and
2169@samp{-fomit-frame-pointer} on machines that can support debugging even
2170without a frame pointer. On some machines the compiler also turns
2171on other flags.@refill
2172
2173@item -O2
2174Optimize even more. GNU CC performs nearly all supported optimizations
2175that do not involve a space-speed tradeoff. The compiler does not
2176perform loop unrolling or function inlining when you specify @samp{-O2}.
2177As compared to @samp{-O}, this option increases both compilation time
2178and the performance of the generated code.
2179
2180@samp{-O2} turns on all optional optimizations except for loop unrolling
2181and function inlining. It also turns on the @samp{-fforce-mem} option
2182on all machines and frame pointer elimination on machines where doing so
2183does not interfere with debugging.
2184
2185@item -O3
2186Optimize yet more. @samp{-O3} turns on all optimizations specified by
2187@samp{-O2} and also turns on the @samp{inline-functions} option.
2188
2189@item -O0
2190Do not optimize.
2191
c6aded7c
AG
2192@item -Os
2193Optimize for size. @samp{-Os} enables all @samp{-O2} optimizations that
2194do not typically increase code size. It also performs further
2195optimizations designed to reduce code size.
2196
74291a4b
MM
2197If you use multiple @samp{-O} options, with or without level numbers,
2198the last such option is the one that is effective.
2199@end table
2200
2201Options of the form @samp{-f@var{flag}} specify machine-independent
2202flags. Most flags have both positive and negative forms; the negative
2203form of @samp{-ffoo} would be @samp{-fno-foo}. In the table below,
2204only one of the forms is listed---the one which is not the default.
2205You can figure out the other form by either removing @samp{no-} or
2206adding it.
2207
2208@table @code
2209@item -ffloat-store
2210Do not store floating point variables in registers, and inhibit other
2211options that might change whether a floating point value is taken from a
2212register or memory.
2213
2214@cindex floating point precision
2215This option prevents undesirable excess precision on machines such as
2216the 68000 where the floating registers (of the 68881) keep more
2217precision than a @code{double} is supposed to have. Similarly for the
2218x86 architecture. For most programs, the excess precision does only
2219good, but a few programs rely on the precise definition of IEEE floating
6fd74494
CB
2220point. Use @samp{-ffloat-store} for such programs, after modifying
2221them to store all pertinent intermediate computations into variables.
74291a4b
MM
2222
2223@item -fno-default-inline
2224Do not make member functions inline by default merely because they are
2225defined inside the class scope (C++ only). Otherwise, when you specify
2226@w{@samp{-O}}, member functions defined inside class scope are compiled
2227inline by default; i.e., you don't need to add @samp{inline} in front of
2228the member function name.
2229
2230@item -fno-defer-pop
2231Always pop the arguments to each function call as soon as that function
2232returns. For machines which must pop arguments after a function call,
2233the compiler normally lets arguments accumulate on the stack for several
2234function calls and pops them all at once.
2235
2236@item -fforce-mem
2237Force memory operands to be copied into registers before doing
2238arithmetic on them. This produces better code by making all memory
2239references potential common subexpressions. When they are not common
2240subexpressions, instruction combination should eliminate the separate
2241register-load. The @samp{-O2} option turns on this option.
2242
2243@item -fforce-addr
2244Force memory address constants to be copied into registers before
2245doing arithmetic on them. This may produce better code just as
2246@samp{-fforce-mem} may.
2247
2248@item -fomit-frame-pointer
2249Don't keep the frame pointer in a register for functions that
2250don't need one. This avoids the instructions to save, set up and
2251restore frame pointers; it also makes an extra register available
2252in many functions. @strong{It also makes debugging impossible on
2253some machines.}
2254
2255@ifset INTERNALS
2256On some machines, such as the Vax, this flag has no effect, because
2257the standard calling sequence automatically handles the frame pointer
2258and nothing is saved by pretending it doesn't exist. The
2259machine-description macro @code{FRAME_POINTER_REQUIRED} controls
2260whether a target machine supports this flag. @xref{Registers}.@refill
2261@end ifset
2262@ifclear INTERNALS
2263On some machines, such as the Vax, this flag has no effect, because
2264the standard calling sequence automatically handles the frame pointer
2265and nothing is saved by pretending it doesn't exist. The
2266machine-description macro @code{FRAME_POINTER_REQUIRED} controls
2267whether a target machine supports this flag. @xref{Registers,,Register
2268Usage, gcc.info, Using and Porting GCC}.@refill
2269@end ifclear
2270
2271@item -fno-inline
2272Don't pay attention to the @code{inline} keyword. Normally this option
2273is used to keep the compiler from expanding any functions inline.
2274Note that if you are not optimizing, no functions can be expanded inline.
2275
2276@item -finline-functions
2277Integrate all simple functions into their callers. The compiler
2278heuristically decides which functions are simple enough to be worth
2279integrating in this way.
2280
2281If all calls to a given function are integrated, and the function is
2282declared @code{static}, then the function is normally not output as
2283assembler code in its own right.
2284
2285@item -fkeep-inline-functions
2286Even if all calls to a given function are integrated, and the function
2287is declared @code{static}, nevertheless output a separate run-time
2288callable version of the function. This switch does not affect
2289@code{extern inline} functions.
2290
2291@item -fkeep-static-consts
2292Emit variables declared @code{static const} when optimization isn't turned
2293on, even if the variables aren't referenced.
2294
2295GNU CC enables this option by default. If you want to force the compiler to
2296check if the variable was referenced, regardless of whether or not
2297optimization is turned on, use the @samp{-fno-keep-static-consts} option.
2298
2299@item -fno-function-cse
2300Do not put function addresses in registers; make each instruction that
2301calls a constant function contain the function's address explicitly.
2302
2303This option results in less efficient code, but some strange hacks
2304that alter the assembler output may be confused by the optimizations
2305performed when this option is not used.
2306
2307@item -ffast-math
2308This option allows GCC to violate some ANSI or IEEE rules and/or
2309specifications in the interest of optimizing code for speed. For
2310example, it allows the compiler to assume arguments to the @code{sqrt}
2311function are non-negative numbers and that no floating-point values
2312are NaNs.
2313
2314This option should never be turned on by any @samp{-O} option since
2315it can result in incorrect output for programs which depend on
2316an exact implementation of IEEE or ANSI rules/specifications for
2317math functions.
2318@end table
2319
2320@c following causes underfulls.. they don't look great, but we deal.
2321@c --mew 26jan93
2322The following options control specific optimizations. The @samp{-O2}
2323option turns on all of these optimizations except @samp{-funroll-loops}
2324and @samp{-funroll-all-loops}. On most machines, the @samp{-O} option
2325turns on the @samp{-fthread-jumps} and @samp{-fdelayed-branch} options,
2326but specific machines may handle it differently.
2327
2328You can use the following flags in the rare cases when ``fine-tuning''
2329of optimizations to be performed is desired.
2330
2331@table @code
2332@item -fstrength-reduce
2333Perform the optimizations of loop strength reduction and
2334elimination of iteration variables.
2335
2336@item -fthread-jumps
2337Perform optimizations where we check to see if a jump branches to a
2338location where another comparison subsumed by the first is found. If
2339so, the first branch is redirected to either the destination of the
2340second branch or a point immediately following it, depending on whether
2341the condition is known to be true or false.
2342
2343@item -fcse-follow-jumps
2344In common subexpression elimination, scan through jump instructions
2345when the target of the jump is not reached by any other path. For
2346example, when CSE encounters an @code{if} statement with an
2347@code{else} clause, CSE will follow the jump when the condition
2348tested is false.
2349
2350@item -fcse-skip-blocks
2351This is similar to @samp{-fcse-follow-jumps}, but causes CSE to
2352follow jumps which conditionally skip over blocks. When CSE
2353encounters a simple @code{if} statement with no else clause,
2354@samp{-fcse-skip-blocks} causes CSE to follow the jump around the
2355body of the @code{if}.
2356
2357@item -frerun-cse-after-loop
2358Re-run common subexpression elimination after loop optimizations has been
2359performed.
2360
6d6d0fa0
JL
2361@item -frerun-loop-opt
2362Run the loop optimizer twice.
2363
7506f491
DE
2364@item -fgcse
2365Perform a global common subexpression elimination pass.
2366This pass also performs global constant and copy propagation.
2367
74291a4b
MM
2368@item -fexpensive-optimizations
2369Perform a number of minor optimizations that are relatively expensive.
2370
9ec36da5
JL
2371@item -foptimize-register-moves
2372@item -fregmove
2373Attempt to reassign register numbers in move instructions and as
2374operands of other simple instructions in order to maximize the amount of
56159047 2375register tying. This is especially helpful on machines with two-operand
9ec36da5
JL
2376instructions. GNU CC enables this optimization by default with @samp{-O2}
2377or higher.
2378
2379Note @code{-fregmove} and @code{-foptimize-register-moves} are the same
2380optimization.
2381
74291a4b
MM
2382@item -fdelayed-branch
2383If supported for the target machine, attempt to reorder instructions
2384to exploit instruction slots available after delayed branch
2385instructions.
2386
2387@item -fschedule-insns
2388If supported for the target machine, attempt to reorder instructions to
2389eliminate execution stalls due to required data being unavailable. This
2390helps machines that have slow floating point or memory load instructions
2391by allowing other instructions to be issued until the result of the load
2392or floating point instruction is required.
2393
2394@item -fschedule-insns2
2395Similar to @samp{-fschedule-insns}, but requests an additional pass of
2396instruction scheduling after register allocation has been done. This is
2397especially useful on machines with a relatively small number of
2398registers and where memory load instructions take more than one cycle.
2399
2400@item -ffunction-sections
7d0756fb
CM
2401@item -fdata-sections
2402Place each function or data item into its own section in the output
2403file if the target supports arbitrary sections. The name of the
2404function or the name of the data item determines the section's name
2405in the output file.
74291a4b 2406
7d0756fb 2407Use these options on systems where the linker can perform optimizations
74291a4b
MM
2408to improve locality of reference in the instruction space. HPPA
2409processors running HP-UX and Sparc processors running Solaris 2 have
2410linkers with such optimizations. Other systems using the ELF object format
2411as well as AIX may have these optimizations in the future.
2412
7d0756fb
CM
2413Only use these options when there are significant benefits from doing
2414so. When you specify these options, the assembler and linker will
74291a4b
MM
2415create larger object and executable files and will also be slower.
2416You will not be able to use @code{gprof} on all systems if you
2417specify this option and you may have problems with debugging if
2418you specify both this option and @samp{-g}.
2419
2420@item -fcaller-saves
2421Enable values to be allocated in registers that will be clobbered by
2422function calls, by emitting extra instructions to save and restore the
2423registers around such calls. Such allocation is done only when it
2424seems to result in better code than would otherwise be produced.
2425
81610a0d
HPN
2426This option is always enabled by default on certain machines, usually
2427those which have no call-preserved registers to use instead.
2428
2429For all machines, optimization level 2 and higher enables this flag by
2430default.
74291a4b
MM
2431
2432@item -funroll-loops
2433Perform the optimization of loop unrolling. This is only done for loops
2434whose number of iterations can be determined at compile time or run time.
2435@samp{-funroll-loop} implies both @samp{-fstrength-reduce} and
2436@samp{-frerun-cse-after-loop}.
2437
2438@item -funroll-all-loops
2439Perform the optimization of loop unrolling. This is done for all loops
2440and usually makes programs run more slowly. @samp{-funroll-all-loops}
2441implies @samp{-fstrength-reduce} as well as @samp{-frerun-cse-after-loop}.
2442
e5eb27e5
JL
2443@item -fmove-all-movables
2444Forces all invariant computations in loops to be moved
2445outside the loop.
2446
2447@item -freduce-all-givs
2448Forces all general-induction variables in loops to be
2449strength-reduced.
2450
2451@emph{Note:} When compiling programs written in Fortran,
2452@samp{-fmove-all-moveables} and @samp{-freduce-all-givs} are enabled
2453by default when you use the optimizer.
2454
2455These options may generate better or worse code; results are highly
2456dependent on the structure of loops within the source code.
2457
2458These two options are intended to be removed someday, once
2459they have helped determine the efficacy of various
2460approaches to improving loop optimizations.
2461
8d31fdf4 2462Please let us (@code{egcs@@egcs.cygnus.com} and @code{fortran@@gnu.org})
e5eb27e5
JL
2463know how use of these options affects
2464the performance of your production code.
2465We're very interested in code that runs @emph{slower}
2466when these options are @emph{enabled}.
2467
74291a4b
MM
2468@item -fno-peephole
2469Disable any machine-specific peephole optimizations.
861bb6c1
JL
2470
2471@item -fbranch-probabilities
2472After running a program compiled with @samp{-fprofile-arcs}
2473(@pxref{Debugging Options,, Options for Debugging Your Program or
2474@code{gcc}}), you can compile it a second time using
2475@samp{-fbranch-probabilities}, to improve optimizations based on
2476guessing the path a branch might take.
2477
2478@ifset INTERNALS
e5e809f4 2479With @samp{-fbranch-probabilities}, GCC puts a @samp{REG_EXEC_COUNT}
861bb6c1
JL
2480note on the first instruction of each basic block, and a
2481@samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
2482These can be used to improve optimization. Currently, they are only
2483used in one place: in @file{reorg.c}, instead of guessing which path a
2484branch is mostly to take, the @samp{REG_BR_PROB} values are used to
2485exactly determine which path is taken more often.
2486@end ifset
8c660648 2487
41472af8
MM
2488@item -fstrict-aliasing
2489Allows the compiler to assume the strictest aliasing rules applicable to
2490the language being compiled. For C (and C++), this activates
2491optimizations based on the type of expressions. In particular, an
2492object of one type is assumed never to reside at the same address as an
2493object of a different type, unless the types are almost the same. For
2494example, an @code{unsigned int} can alias an @code{int}, but not a
2495@code{void*} or a @code{double}. A character type may alias any other
2496type.
2497
2498Pay special attention to code like this:
2499@example
2500union a_union @{
2501 int i;
2502 double d;
2503@};
2504
2505int f() @{
2506 a_union t;
2507 t.d = 3.0;
2508 return t.i;
2509@}
2510@end example
2511The practice of reading from a different union member than the one most
2512recently written to (called ``type-punning'') is common. Even with
2513@samp{-fstrict-aliasing}, type-punning is allowed, provided the memory
2514is accessed through the union type. So, the code above will work as
2515expected. However, this code might not:
2516@example
2517int f() @{
2518 a_union t;
2519 int* ip;
2520 t.d = 3.0;
2521 ip = &t.i;
2522 return *ip;
2523@}
2524@end example
2525
41472af8
MM
2526@ifset INTERNALS
2527Every language that wishes to perform language-specific alias analysis
2528should define a function that computes, given an @code{tree}
2529node, an alias set for the node. Nodes in different alias sets are not
2530allowed to alias. For an example, see the C front-end function
2531@code{c_get_alias_set}.
2532@end ifset
2533
74291a4b
MM
2534@end table
2535
2536@node Preprocessor Options
2537@section Options Controlling the Preprocessor
2538@cindex preprocessor options
2539@cindex options, preprocessor
2540
2541These options control the C preprocessor, which is run on each C source
2542file before actual compilation.
2543
2544If you use the @samp{-E} option, nothing is done except preprocessing.
2545Some of these options make sense only together with @samp{-E} because
2546they cause the preprocessor output to be unsuitable for actual
2547compilation.
2548
2549@table @code
2550@item -include @var{file}
2551Process @var{file} as input before processing the regular input file.
2552In effect, the contents of @var{file} are compiled first. Any @samp{-D}
2553and @samp{-U} options on the command line are always processed before
2554@samp{-include @var{file}}, regardless of the order in which they are
2555written. All the @samp{-include} and @samp{-imacros} options are
2556processed in the order in which they are written.
2557
2558@item -imacros @var{file}
2559Process @var{file} as input, discarding the resulting output, before
2560processing the regular input file. Because the output generated from
2561@var{file} is discarded, the only effect of @samp{-imacros @var{file}}
2562is to make the macros defined in @var{file} available for use in the
2563main input.
2564
2565Any @samp{-D} and @samp{-U} options on the command line are always
2566processed before @samp{-imacros @var{file}}, regardless of the order in
2567which they are written. All the @samp{-include} and @samp{-imacros}
2568options are processed in the order in which they are written.
2569
2570@item -idirafter @var{dir}
2571@cindex second include path
2572Add the directory @var{dir} to the second include path. The directories
2573on the second include path are searched when a header file is not found
2574in any of the directories in the main include path (the one that
2575@samp{-I} adds to).
2576
2577@item -iprefix @var{prefix}
2578Specify @var{prefix} as the prefix for subsequent @samp{-iwithprefix}
2579options.
2580
2581@item -iwithprefix @var{dir}
2582Add a directory to the second include path. The directory's name is
2583made by concatenating @var{prefix} and @var{dir}, where @var{prefix} was
2584specified previously with @samp{-iprefix}. If you have not specified a
2585prefix yet, the directory containing the installed passes of the
2586compiler is used as the default.
2587
2588@item -iwithprefixbefore @var{dir}
2589Add a directory to the main include path. The directory's name is made
2590by concatenating @var{prefix} and @var{dir}, as in the case of
2591@samp{-iwithprefix}.
2592
2593@item -isystem @var{dir}
2594Add a directory to the beginning of the second include path, marking it
2595as a system directory, so that it gets the same special treatment as
2596is applied to the standard system directories.
2597
2598@item -nostdinc
2599Do not search the standard system directories for header files. Only
2600the directories you have specified with @samp{-I} options (and the
2601current directory, if appropriate) are searched. @xref{Directory
2602Options}, for information on @samp{-I}.
2603
2604By using both @samp{-nostdinc} and @samp{-I-}, you can limit the include-file
2605search path to only those directories you specify explicitly.
2606
2607@item -undef
2608Do not predefine any nonstandard macros. (Including architecture flags).
2609
2610@item -E
2611Run only the C preprocessor. Preprocess all the C source files
2612specified and output the results to standard output or to the
2613specified output file.
2614
2615@item -C
2616Tell the preprocessor not to discard comments. Used with the
2617@samp{-E} option.
2618
2619@item -P
2620Tell the preprocessor not to generate @samp{#line} directives.
2621Used with the @samp{-E} option.
2622
2623@cindex make
2624@cindex dependencies, make
2625@item -M
2626Tell the preprocessor to output a rule suitable for @code{make}
2627describing the dependencies of each object file. For each source file,
2628the preprocessor outputs one @code{make}-rule whose target is the object
2629file name for that source file and whose dependencies are all the
2630@code{#include} header files it uses. This rule may be a single line or
2631may be continued with @samp{\}-newline if it is long. The list of rules
2632is printed on standard output instead of the preprocessed C program.
2633
2634@samp{-M} implies @samp{-E}.
2635
2636Another way to specify output of a @code{make} rule is by setting
2637the environment variable @code{DEPENDENCIES_OUTPUT} (@pxref{Environment
2638Variables}).
2639
2640@item -MM
2641Like @samp{-M} but the output mentions only the user header files
2642included with @samp{#include "@var{file}"}. System header files
2643included with @samp{#include <@var{file}>} are omitted.
2644
2645@item -MD
2646Like @samp{-M} but the dependency information is written to a file made by
2647replacing ".c" with ".d" at the end of the input file names.
2648This is in addition to compiling the file as specified---@samp{-MD} does
2649not inhibit ordinary compilation the way @samp{-M} does.
2650
2651In Mach, you can use the utility @code{md} to merge multiple dependency
2652files into a single dependency file suitable for using with the @samp{make}
2653command.
2654
2655@item -MMD
2656Like @samp{-MD} except mention only user header files, not system
2657header files.
2658
2659@item -MG
2660Treat missing header files as generated files and assume they live in the
2661same directory as the source file. If you specify @samp{-MG}, you
2662must also specify either @samp{-M} or @samp{-MM}. @samp{-MG} is not
2663supported with @samp{-MD} or @samp{-MMD}.
2664
2665@item -H
2666Print the name of each header file used, in addition to other normal
2667activities.
2668
2669@item -A@var{question}(@var{answer})
2670Assert the answer @var{answer} for @var{question}, in case it is tested
2671with a preprocessing conditional such as @samp{#if
2672#@var{question}(@var{answer})}. @samp{-A-} disables the standard
2673assertions that normally describe the target machine.
2674
2675@item -D@var{macro}
2676Define macro @var{macro} with the string @samp{1} as its definition.
2677
2678@item -D@var{macro}=@var{defn}
2679Define macro @var{macro} as @var{defn}. All instances of @samp{-D} on
2680the command line are processed before any @samp{-U} options.
2681
2682@item -U@var{macro}
2683Undefine macro @var{macro}. @samp{-U} options are evaluated after all
2684@samp{-D} options, but before any @samp{-include} and @samp{-imacros}
2685options.
2686
2687@item -dM
2688Tell the preprocessor to output only a list of the macro definitions
2689that are in effect at the end of preprocessing. Used with the @samp{-E}
2690option.
2691
2692@item -dD
2693Tell the preprocessing to pass all macro definitions into the output, in
2694their proper sequence in the rest of the output.
2695
2696@item -dN
2697Like @samp{-dD} except that the macro arguments and contents are omitted.
2698Only @samp{#define @var{name}} is included in the output.
2699
2700@item -trigraphs
2701Support ANSI C trigraphs. The @samp{-ansi} option also has this effect.
2702
2703@item -Wp,@var{option}
2704Pass @var{option} as an option to the preprocessor. If @var{option}
2705contains commas, it is split into multiple options at the commas.
2706@end table
2707
2708@node Assembler Options
2709@section Passing Options to the Assembler
2710
2711@c prevent bad page break with this line
2712You can pass options to the assembler.
2713
2714@table @code
2715@item -Wa,@var{option}
2716Pass @var{option} as an option to the assembler. If @var{option}
2717contains commas, it is split into multiple options at the commas.
2718@end table
2719
2720@node Link Options
2721@section Options for Linking
2722@cindex link options
2723@cindex options, linking
2724
2725These options come into play when the compiler links object files into
2726an executable output file. They are meaningless if the compiler is
2727not doing a link step.
2728
2729@table @code
2730@cindex file names
2731@item @var{object-file-name}
2732A file name that does not end in a special recognized suffix is
2733considered to name an object file or library. (Object files are
2734distinguished from libraries by the linker according to the file
2735contents.) If linking is done, these object files are used as input
2736to the linker.
2737
2738@item -c
2739@itemx -S
2740@itemx -E
2741If any of these options is used, then the linker is not run, and
2742object file names should not be used as arguments. @xref{Overall
2743Options}.
2744
2745@cindex Libraries
2746@item -l@var{library}
2747Search the library named @var{library} when linking.
2748
2749It makes a difference where in the command you write this option; the
2750linker searches processes libraries and object files in the order they
2751are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
2752after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
2753to functions in @samp{z}, those functions may not be loaded.
2754
2755The linker searches a standard list of directories for the library,
2756which is actually a file named @file{lib@var{library}.a}. The linker
2757then uses this file as if it had been specified precisely by name.
2758
2759The directories searched include several standard system directories
2760plus any that you specify with @samp{-L}.
2761
2762Normally the files found this way are library files---archive files
2763whose members are object files. The linker handles an archive file by
2764scanning through it for members which define symbols that have so far
2765been referenced but not defined. But if the file that is found is an
2766ordinary object file, it is linked in the usual fashion. The only
2767difference between using an @samp{-l} option and specifying a file name
2768is that @samp{-l} surrounds @var{library} with @samp{lib} and @samp{.a}
2769and searches several directories.
2770
2771@item -lobjc
2772You need this special case of the @samp{-l} option in order to
2773link an Objective C program.
2774
2775@item -nostartfiles
2776Do not use the standard system startup files when linking.
2777The standard system libraries are used normally, unless @code{-nostdlib}
2778or @code{-nodefaultlibs} is used.
2779
2780@item -nodefaultlibs
2781Do not use the standard system libraries when linking.
2782Only the libraries you specify will be passed to the linker.
2783The standard startup files are used normally, unless @code{-nostartfiles}
4754172c 2784is used. The compiler may generate calls to memcmp, memset, and memcpy
8dd8e764 2785for System V (and ANSI C) environments or to bcopy and bzero for
4754172c
CM
2786BSD environments. These entries are usually resolved by entries in
2787libc. These entry points should be supplied through some other
2788mechanism when this option is specified.
74291a4b
MM
2789
2790@item -nostdlib
2791Do not use the standard system startup files or libraries when linking.
2792No startup files and only the libraries you specify will be passed to
4754172c 2793the linker. The compiler may generate calls to memcmp, memset, and memcpy
8dd8e764 2794for System V (and ANSI C) environments or to bcopy and bzero for
4754172c
CM
2795BSD environments. These entries are usually resolved by entries in
2796libc. These entry points should be supplied through some other
2797mechanism when this option is specified.
74291a4b
MM
2798
2799@cindex @code{-lgcc}, use with @code{-nostdlib}
2800@cindex @code{-nostdlib} and unresolved references
2801@cindex unresolved references and @code{-nostdlib}
2802@cindex @code{-lgcc}, use with @code{-nodefaultlibs}
2803@cindex @code{-nodefaultlibs} and unresolved references
2804@cindex unresolved references and @code{-nodefaultlibs}
2805One of the standard libraries bypassed by @samp{-nostdlib} and
2806@samp{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
2807that GNU CC uses to overcome shortcomings of particular machines, or special
2808needs for some languages.
2809@ifset INTERNALS
2810(@xref{Interface,,Interfacing to GNU CC Output}, for more discussion of
2811@file{libgcc.a}.)
2812@end ifset
2813@ifclear INTERNALS
2814(@xref{Interface,,Interfacing to GNU CC Output,gcc.info,Porting GNU CC},
2815for more discussion of @file{libgcc.a}.)
2816@end ifclear
2817In most cases, you need @file{libgcc.a} even when you want to avoid
2818other standard libraries. In other words, when you specify @samp{-nostdlib}
2819or @samp{-nodefaultlibs} you should usually specify @samp{-lgcc} as well.
2820This ensures that you have no unresolved references to internal GNU CC
2821library subroutines. (For example, @samp{__main}, used to ensure C++
2822constructors will be called; @pxref{Collect2,,@code{collect2}}.)
2823
2824@item -s
2825Remove all symbol table and relocation information from the executable.
2826
2827@item -static
2828On systems that support dynamic linking, this prevents linking with the shared
2829libraries. On other systems, this option has no effect.
2830
2831@item -shared
2832Produce a shared object which can then be linked with other objects to
2833form an executable. Not all systems support this option. You must
2834also specify @samp{-fpic} or @samp{-fPIC} on some systems when
2835you specify this option.
2836
2837@item -symbolic
2838Bind references to global symbols when building a shared object. Warn
2839about any unresolved references (unless overridden by the link editor
2840option @samp{-Xlinker -z -Xlinker defs}). Only a few systems support
2841this option.
2842
2843@item -Xlinker @var{option}
2844Pass @var{option} as an option to the linker. You can use this to
2845supply system-specific linker options which GNU CC does not know how to
2846recognize.
2847
2848If you want to pass an option that takes an argument, you must use
2849@samp{-Xlinker} twice, once for the option and once for the argument.
2850For example, to pass @samp{-assert definitions}, you must write
2851@samp{-Xlinker -assert -Xlinker definitions}. It does not work to write
2852@samp{-Xlinker "-assert definitions"}, because this passes the entire
2853string as a single argument, which is not what the linker expects.
2854
2855@item -Wl,@var{option}
2856Pass @var{option} as an option to the linker. If @var{option} contains
2857commas, it is split into multiple options at the commas.
2858
2859@item -u @var{symbol}
2860Pretend the symbol @var{symbol} is undefined, to force linking of
2861library modules to define it. You can use @samp{-u} multiple times with
2862different symbols to force loading of additional library modules.
2863@end table
2864
2865@node Directory Options
2866@section Options for Directory Search
2867@cindex directory options
2868@cindex options, directory search
2869@cindex search path
2870
2871These options specify directories to search for header files, for
2872libraries and for parts of the compiler:
2873
2874@table @code
2875@item -I@var{dir}
861bb6c1
JL
2876Add the directory @var{dir} to the head of the list of directories to be
2877searched for header files. This can be used to override a system header
2878file, substituting your own version, since these directories are
74291a4b
MM
2879searched before the system header file directories. If you use more
2880than one @samp{-I} option, the directories are scanned in left-to-right
2881order; the standard system directories come after.
2882
2883@item -I-
2884Any directories you specify with @samp{-I} options before the @samp{-I-}
2885option are searched only for the case of @samp{#include "@var{file}"};
2886they are not searched for @samp{#include <@var{file}>}.
2887
2888If additional directories are specified with @samp{-I} options after
2889the @samp{-I-}, these directories are searched for all @samp{#include}
2890directives. (Ordinarily @emph{all} @samp{-I} directories are used
2891this way.)
2892
2893In addition, the @samp{-I-} option inhibits the use of the current
2894directory (where the current input file came from) as the first search
2895directory for @samp{#include "@var{file}"}. There is no way to
2896override this effect of @samp{-I-}. With @samp{-I.} you can specify
2897searching the directory which was current when the compiler was
2898invoked. That is not exactly the same as what the preprocessor does
2899by default, but it is often satisfactory.
2900
2901@samp{-I-} does not inhibit the use of the standard system directories
2902for header files. Thus, @samp{-I-} and @samp{-nostdinc} are
2903independent.
2904
2905@item -L@var{dir}
2906Add directory @var{dir} to the list of directories to be searched
2907for @samp{-l}.
2908
2909@item -B@var{prefix}
2910This option specifies where to find the executables, libraries,
2911include files, and data files of the compiler itself.
2912
2913The compiler driver program runs one or more of the subprograms
2914@file{cpp}, @file{cc1}, @file{as} and @file{ld}. It tries
2915@var{prefix} as a prefix for each program it tries to run, both with and
2916without @samp{@var{machine}/@var{version}/} (@pxref{Target Options}).
2917
2918For each subprogram to be run, the compiler driver first tries the
2919@samp{-B} prefix, if any. If that name is not found, or if @samp{-B}
2920was not specified, the driver tries two standard prefixes, which are
2921@file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc-lib/}. If neither of
2922those results in a file name that is found, the unmodified program
2923name is searched for using the directories specified in your
2924@samp{PATH} environment variable.
2925
2926@samp{-B} prefixes that effectively specify directory names also apply
2927to libraries in the linker, because the compiler translates these
2928options into @samp{-L} options for the linker. They also apply to
2929includes files in the preprocessor, because the compiler translates these
2930options into @samp{-isystem} options for the preprocessor. In this case,
2931the compiler appends @samp{include} to the prefix.
2932
2933The run-time support file @file{libgcc.a} can also be searched for using
2934the @samp{-B} prefix, if needed. If it is not found there, the two
2935standard prefixes above are tried, and that is all. The file is left
2936out of the link if it is not found by those means.
2937
2938Another way to specify a prefix much like the @samp{-B} prefix is to use
2939the environment variable @code{GCC_EXEC_PREFIX}. @xref{Environment
2940Variables}.
861bb6c1
JL
2941
2942@item -specs=@var{file}
2943Process @var{file} after the compiler reads in the standard @file{specs}
2944file, in order to override the defaults that the @file{gcc} driver
2945program uses when determining what switches to pass to @file{cc1},
2946@file{cc1plus}, @file{as}, @file{ld}, etc. More than one
2947@samp{-specs=}@var{file} can be specified on the command line, and they
2948are processed in order, from left to right.
74291a4b
MM
2949@end table
2950
2951@node Target Options
2952@section Specifying Target Machine and Compiler Version
2953@cindex target options
2954@cindex cross compiling
2955@cindex specifying machine version
2956@cindex specifying compiler version and target machine
2957@cindex compiler version, specifying
2958@cindex target machine, specifying
2959
2960By default, GNU CC compiles code for the same type of machine that you
2961are using. However, it can also be installed as a cross-compiler, to
2962compile for some other type of machine. In fact, several different
2963configurations of GNU CC, for different target machines, can be
2964installed side by side. Then you specify which one to use with the
2965@samp{-b} option.
2966
2967In addition, older and newer versions of GNU CC can be installed side
2968by side. One of them (probably the newest) will be the default, but
2969you may sometimes wish to use another.
2970
2971@table @code
2972@item -b @var{machine}
2973The argument @var{machine} specifies the target machine for compilation.
2974This is useful when you have installed GNU CC as a cross-compiler.
2975
2976The value to use for @var{machine} is the same as was specified as the
2977machine type when configuring GNU CC as a cross-compiler. For
2978example, if a cross-compiler was configured with @samp{configure
2979i386v}, meaning to compile for an 80386 running System V, then you
2980would specify @samp{-b i386v} to run that cross compiler.
2981
2982When you do not specify @samp{-b}, it normally means to compile for
2983the same type of machine that you are using.
2984
2985@item -V @var{version}
2986The argument @var{version} specifies which version of GNU CC to run.
2987This is useful when multiple versions are installed. For example,
2988@var{version} might be @samp{2.0}, meaning to run GNU CC version 2.0.
2989
2990The default version, when you do not specify @samp{-V}, is the last
2991version of GNU CC that you installed.
2992@end table
2993
2994The @samp{-b} and @samp{-V} options actually work by controlling part of
2995the file name used for the executable files and libraries used for
2996compilation. A given version of GNU CC, for a given target machine, is
2997normally kept in the directory @file{/usr/local/lib/gcc-lib/@var{machine}/@var{version}}.@refill
2998
2999Thus, sites can customize the effect of @samp{-b} or @samp{-V} either by
3000changing the names of these directories or adding alternate names (or
3001symbolic links). If in directory @file{/usr/local/lib/gcc-lib/} the
3002file @file{80386} is a link to the file @file{i386v}, then @samp{-b
300380386} becomes an alias for @samp{-b i386v}.
3004
3005In one respect, the @samp{-b} or @samp{-V} do not completely change
3006to a different compiler: the top-level driver program @code{gcc}
3007that you originally invoked continues to run and invoke the other
3008executables (preprocessor, compiler per se, assembler and linker)
3009that do the real work. However, since no real work is done in the
3010driver program, it usually does not matter that the driver program
3011in use is not the one for the specified target and version.
3012
3013The only way that the driver program depends on the target machine is
3014in the parsing and handling of special machine-specific options.
3015However, this is controlled by a file which is found, along with the
3016other executables, in the directory for the specified version and
3017target machine. As a result, a single installed driver program adapts
3018to any specified target machine and compiler version.
3019
3020The driver program executable does control one significant thing,
3021however: the default version and target machine. Therefore, you can
3022install different instances of the driver program, compiled for
3023different targets or versions, under different names.
3024
3025For example, if the driver for version 2.0 is installed as @code{ogcc}
3026and that for version 2.1 is installed as @code{gcc}, then the command
3027@code{gcc} will use version 2.1 by default, while @code{ogcc} will use
30282.0 by default. However, you can choose either version with either
3029command with the @samp{-V} option.
3030
3031@node Submodel Options
3032@section Hardware Models and Configurations
3033@cindex submodel options
3034@cindex specifying hardware config
3035@cindex hardware models and configurations, specifying
3036@cindex machine dependent options
3037
3038Earlier we discussed the standard option @samp{-b} which chooses among
3039different installed compilers for completely different target
3040machines, such as Vax vs. 68000 vs. 80386.
3041
3042In addition, each of these target machine types can have its own
3043special options, starting with @samp{-m}, to choose among various
3044hardware models or configurations---for example, 68010 vs 68020,
3045floating coprocessor or none. A single installed version of the
3046compiler can compile for any model or configuration, according to the
3047options specified.
3048
3049Some configurations of the compiler also support additional special
3050options, usually for compatibility with other compilers on the same
3051platform.
3052
3053@ifset INTERNALS
3054These options are defined by the macro @code{TARGET_SWITCHES} in the
3055machine description. The default for the options is also defined by
3056that macro, which enables you to change the defaults.
3057@end ifset
3058
3059@menu
3060* M680x0 Options::
3061* VAX Options::
3062* SPARC Options::
3063* Convex Options::
3064* AMD29K Options::
3065* ARM Options::
157a620e 3066* Thumb Options::
ecff22ab 3067* MN10200 Options::
6d6d0fa0 3068* MN10300 Options::
861bb6c1 3069* M32R/D Options::
74291a4b
MM
3070* M88K Options::
3071* RS/6000 and PowerPC Options::
3072* RT Options::
3073* MIPS Options::
3074* i386 Options::
3075* HPPA Options::
3076* Intel 960 Options::
3077* DEC Alpha Options::
3078* Clipper Options::
3079* H8/300 Options::
3080* SH Options::
3081* System V Options::
f84271d9 3082* V850 Options::
56b2d7a7 3083* ARC Options::
83575957 3084* NS32K Options::
74291a4b
MM
3085@end menu
3086
3087@node M680x0 Options
3088@subsection M680x0 Options
3089@cindex M680x0 options
3090
3091These are the @samp{-m} options defined for the 68000 series. The default
3092values for these options depends on which style of 68000 was selected when
3093the compiler was configured; the defaults for the most common choices are
3094given below.
3095
3096@table @code
3097@item -m68000
3098@itemx -mc68000
3099Generate output for a 68000. This is the default
3100when the compiler is configured for 68000-based systems.
3101
74cf1c6d
RK
3102Use this option for microcontrollers with a 68000 or EC000 core,
3103including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
3104
74291a4b
MM
3105@item -m68020
3106@itemx -mc68020
3107Generate output for a 68020. This is the default
3108when the compiler is configured for 68020-based systems.
3109
3110@item -m68881
3111Generate output containing 68881 instructions for floating point.
3112This is the default for most 68020 systems unless @samp{-nfp} was
3113specified when the compiler was configured.
3114
3115@item -m68030
3116Generate output for a 68030. This is the default when the compiler is
3117configured for 68030-based systems.
3118
3119@item -m68040
3120Generate output for a 68040. This is the default when the compiler is
3121configured for 68040-based systems.
3122
3123This option inhibits the use of 68881/68882 instructions that have to be
74cf1c6d
RK
3124emulated by software on the 68040. Use this option if your 68040 does not
3125have code to emulate those instructions.
74291a4b
MM
3126
3127@item -m68060
3128Generate output for a 68060. This is the default when the compiler is
3129configured for 68060-based systems.
3130
3131This option inhibits the use of 68020 and 68881/68882 instructions that
74cf1c6d
RK
3132have to be emulated by software on the 68060. Use this option if your 68060
3133does not have code to emulate those instructions.
3134
3135@item -mcpu32
3136Generate output for a CPU32. This is the default
3137when the compiler is configured for CPU32-based systems.
3138
3139Use this option for microcontrollers with a
3140CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
314168336, 68340, 68341, 68349 and 68360.
74291a4b
MM
3142
3143@item -m5200
3144Generate output for a 520X "coldfire" family cpu. This is the default
3145when the compiler is configured for 520X-based systems.
3146
74cf1c6d
RK
3147Use this option for microcontroller with a 5200 core, including
3148the MCF5202, MCF5203, MCF5204 and MCF5202.
3149
74291a4b
MM
3150
3151@item -m68020-40
3152Generate output for a 68040, without using any of the new instructions.
3153This results in code which can run relatively efficiently on either a
315468020/68881 or a 68030 or a 68040. The generated code does use the
315568881 instructions that are emulated on the 68040.
3156
861bb6c1
JL
3157@item -m68020-60
3158Generate output for a 68060, without using any of the new instructions.
3159This results in code which can run relatively efficiently on either a
316068020/68881 or a 68030 or a 68040. The generated code does use the
316168881 instructions that are emulated on the 68060.
3162
74291a4b
MM
3163@item -mfpa
3164Generate output containing Sun FPA instructions for floating point.
3165
3166@item -msoft-float
3167Generate output containing library calls for floating point.
3168@strong{Warning:} the requisite libraries are not available for all m68k
3169targets. Normally the facilities of the machine's usual C compiler are
3170used, but this can't be done directly in cross-compilation. You must
3171make your own arrangements to provide suitable library functions for
3172cross-compilation. The embedded targets @samp{m68k-*-aout} and
3173@samp{m68k-*-coff} do provide software floating point support.
3174
3175@item -mshort
3176Consider type @code{int} to be 16 bits wide, like @code{short int}.
3177
3178@item -mnobitfield
74cf1c6d
RK
3179Do not use the bit-field instructions. The @samp{-m68000}, @samp{-mcpu32}
3180and @samp{-m5200} options imply @w{@samp{-mnobitfield}}.
74291a4b
MM
3181
3182@item -mbitfield
3183Do use the bit-field instructions. The @samp{-m68020} option implies
3184@samp{-mbitfield}. This is the default if you use a configuration
3185designed for a 68020.
3186
3187@item -mrtd
3188Use a different function-calling convention, in which functions
3189that take a fixed number of arguments return with the @code{rtd}
3190instruction, which pops their arguments while returning. This
3191saves one instruction in the caller since there is no need to pop
3192the arguments there.
3193
3194This calling convention is incompatible with the one normally
3195used on Unix, so you cannot use it if you need to call libraries
3196compiled with the Unix compiler.
3197
3198Also, you must provide function prototypes for all functions that
3199take variable numbers of arguments (including @code{printf});
3200otherwise incorrect code will be generated for calls to those
3201functions.
3202
3203In addition, seriously incorrect code will result if you call a
3204function with too many arguments. (Normally, extra arguments are
3205harmlessly ignored.)
3206
3207The @code{rtd} instruction is supported by the 68010, 68020, 68030,
74cf1c6d 320868040, 68060 and CPU32 processors, but not by the 68000 or 5200.
861bb6c1
JL
3209
3210@item -malign-int
3211@itemx -mno-align-int
3212Control whether GNU CC aligns @code{int}, @code{long}, @code{long long},
3213@code{float}, @code{double}, and @code{long double} variables on a 32-bit
3214boundary (@samp{-malign-int}) or a 16-bit boundary (@samp{-mno-align-int}).
3215Aligning variables on 32-bit boundaries produces code that runs somewhat
3216faster on processors with 32-bit busses at the expense of more memory.
3217
3218@strong{Warning:} if you use the @samp{-malign-int} switch, GNU CC will
3219align structures containing the above types differently than
3220most published application binary interface specifications for the m68k.
3221
74291a4b
MM
3222@end table
3223
3224@node VAX Options
3225@subsection VAX Options
3226@cindex VAX options
3227
3228These @samp{-m} options are defined for the Vax:
3229
3230@table @code
3231@item -munix
3232Do not output certain jump instructions (@code{aobleq} and so on)
3233that the Unix assembler for the Vax cannot handle across long
3234ranges.
3235
3236@item -mgnu
3237Do output those jump instructions, on the assumption that you
3238will assemble with the GNU assembler.
3239
3240@item -mg
3241Output code for g-format floating point numbers instead of d-format.
3242@end table
3243
3244@node SPARC Options
3245@subsection SPARC Options
3246@cindex SPARC options
3247
3248These @samp{-m} switches are supported on the SPARC:
3249
3250@table @code
3251@item -mno-app-regs
3252@itemx -mapp-regs
3253Specify @samp{-mapp-regs} to generate output using the global registers
32542 through 4, which the SPARC SVR4 ABI reserves for applications. This
3255is the default.
3256
3257To be fully SVR4 ABI compliant at the cost of some performance loss,
3258specify @samp{-mno-app-regs}. You should compile libraries and system
3259software with this option.
3260
3261@item -mfpu
3262@itemx -mhard-float
3263Generate output containing floating point instructions. This is the
3264default.
3265
3266@item -mno-fpu
3267@itemx -msoft-float
3268Generate output containing library calls for floating point.
3269@strong{Warning:} the requisite libraries are not available for all SPARC
3270targets. Normally the facilities of the machine's usual C compiler are
3271used, but this cannot be done directly in cross-compilation. You must make
3272your own arrangements to provide suitable library functions for
3273cross-compilation. The embedded targets @samp{sparc-*-aout} and
3274@samp{sparclite-*-*} do provide software floating point support.
3275
3276@samp{-msoft-float} changes the calling convention in the output file;
3277therefore, it is only useful if you compile @emph{all} of a program with
3278this option. In particular, you need to compile @file{libgcc.a}, the
3279library that comes with GNU CC, with @samp{-msoft-float} in order for
3280this to work.
3281
3282@item -mhard-quad-float
3283Generate output containing quad-word (long double) floating point
3284instructions.
3285
3286@item -msoft-quad-float
3287Generate output containing library calls for quad-word (long double)
3288floating point instructions. The functions called are those specified
3289in the SPARC ABI. This is the default.
3290
3291As of this writing, there are no sparc implementations that have hardware
3292support for the quad-word floating point instructions. They all invoke
3293a trap handler for one of these instructions, and then the trap handler
3294emulates the effect of the instruction. Because of the trap handler overhead,
3295this is much slower than calling the ABI library routines. Thus the
3296@samp{-msoft-quad-float} option is the default.
3297
3298@item -mno-epilogue
3299@itemx -mepilogue
3300With @samp{-mepilogue} (the default), the compiler always emits code for
3301function exit at the end of each function. Any function exit in
3302the middle of the function (such as a return statement in C) will
3303generate a jump to the exit code at the end of the function.
3304
3305With @samp{-mno-epilogue}, the compiler tries to emit exit code inline
3306at every function exit.
3307
3308@item -mno-flat
3309@itemx -mflat
3310With @samp{-mflat}, the compiler does not generate save/restore instructions
3311and will use a "flat" or single register window calling convention.
3312This model uses %i7 as the frame pointer and is compatible with the normal
3313register window model. Code from either may be intermixed.
3314The local registers and the input registers (0-5) are still treated as
3315"call saved" registers and will be saved on the stack as necessary.
3316
3317With @samp{-mno-flat} (the default), the compiler emits save/restore
3318instructions (except for leaf functions) and is the normal mode of operation.
3319
3320@item -mno-unaligned-doubles
3321@itemx -munaligned-doubles
3322Assume that doubles have 8 byte alignment. This is the default.
3323
3324With @samp{-munaligned-doubles}, GNU CC assumes that doubles have 8 byte
3325alignment only if they are contained in another type, or if they have an
3326absolute address. Otherwise, it assumes they have 4 byte alignment.
3327Specifying this option avoids some rare compatibility problems with code
3328generated by other compilers. It is not the default because it results
3329in a performance loss, especially for floating point code.
3330
3331@item -mv8
3332@itemx -msparclite
3333These two options select variations on the SPARC architecture.
3334
3335By default (unless specifically configured for the Fujitsu SPARClite),
3336GCC generates code for the v7 variant of the SPARC architecture.
3337
3338@samp{-mv8} will give you SPARC v8 code. The only difference from v7
3339code is that the compiler emits the integer multiply and integer
3340divide instructions which exist in SPARC v8 but not in SPARC v7.
3341
3342@samp{-msparclite} will give you SPARClite code. This adds the integer
3343multiply, integer divide step and scan (@code{ffs}) instructions which
3344exist in SPARClite but not in SPARC v7.
3345
3346These options are deprecated and will be deleted in GNU CC 2.9.
3347They have been replaced with @samp{-mcpu=xxx}.
3348
3349@item -mcypress
3350@itemx -msupersparc
3351These two options select the processor for which the code is optimised.
3352
3353With @samp{-mcypress} (the default), the compiler optimizes code for the
3354Cypress CY7C602 chip, as used in the SparcStation/SparcServer 3xx series.
3355This is also appropriate for the older SparcStation 1, 2, IPX etc.
3356
3357With @samp{-msupersparc} the compiler optimizes code for the SuperSparc cpu, as
3358used in the SparcStation 10, 1000 and 2000 series. This flag also enables use
3359of the full SPARC v8 instruction set.
3360
3361These options are deprecated and will be deleted in GNU CC 2.9.
3362They have been replaced with @samp{-mcpu=xxx}.
3363
3364@item -mcpu=@var{cpu_type}
c0498f43
DE
3365Set the instruction set, register set, and instruction scheduling parameters
3366for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
3367@samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{sparclite},
ad6843d7
RH
3368@samp{hypersparc}, @samp{sparclite86x}, @samp{f930}, @samp{f934},
3369@samp{sparclet}, @samp{tsc701}, @samp{v9}, and @samp{ultrasparc}.
c0498f43
DE
3370
3371Default instruction scheduling parameters are used for values that select
3372an architecture and not an implementation. These are @samp{v7}, @samp{v8},
3373@samp{sparclite}, @samp{sparclet}, @samp{v9}.
3374
3375Here is a list of each supported architecture and their supported
3376implementations.
3377
3378@smallexample
3379 v7: cypress
ad6843d7
RH
3380 v8: supersparc, hypersparc
3381 sparclite: f930, f934, sparclite86x
c0498f43
DE
3382 sparclet: tsc701
3383 v9: ultrasparc
3384@end smallexample
74291a4b
MM
3385
3386@item -mtune=@var{cpu_type}
3387Set the instruction scheduling parameters for machine type
c0498f43
DE
3388@var{cpu_type}, but do not set the instruction set or register set that the
3389option @samp{-mcpu=}@var{cpu_type} would.
3390
3391The same values for @samp{-mcpu=}@var{cpu_type} are used for
e5e809f4 3392@samp{-mtune=}@*@var{cpu_type}, though the only useful values are those that
c0498f43 3393select a particular cpu implementation: @samp{cypress}, @samp{supersparc},
ad6843d7
RH
3394@samp{hypersparc}, @samp{f930}, @samp{f934}, @samp{sparclite86x},
3395@samp{tsc701}, @samp{ultrasparc}.
74291a4b 3396
6d4312dd
DE
3397@item -malign-loops=@var{num}
3398Align loops to a 2 raised to a @var{num} byte boundary. If
3399@samp{-malign-loops} is not specified, the default is 2.
3400
3401@item -malign-jumps=@var{num}
3402Align instructions that are only jumped to to a 2 raised to a @var{num}
3403byte boundary. If @samp{-malign-jumps} is not specified, the default is 2.
3404
3405@item -malign-functions=@var{num}
3406Align the start of functions to a 2 raised to @var{num} byte boundary.
3407If @samp{-malign-functions} is not specified, the default is 2 if compiling
3408for 32 bit sparc, and 5 if compiling for 64 bit sparc.
3409
74291a4b
MM
3410@end table
3411
3412These @samp{-m} switches are supported in addition to the above
3413on the SPARCLET processor.
3414
3415@table @code
3416@item -mlittle-endian
3417Generate code for a processor running in little-endian mode.
3418
3419@item -mlive-g0
3420Treat register @code{%g0} as a normal register.
3421GCC will continue to clobber it as necessary but will not assume
3422it always reads as 0.
3423
3424@item -mbroken-saverestore
3425Generate code that does not use non-trivial forms of the @code{save} and
3426@code{restore} instructions. Early versions of the SPARCLET processor do
3427not correctly handle @code{save} and @code{restore} instructions used with
3428arguments. They correctly handle them used without arguments. A @code{save}
3429instruction used without arguments increments the current window pointer
3430but does not allocate a new stack frame. It is assumed that the window
3431overflow trap handler will properly handle this case as will interrupt
3432handlers.
3433@end table
3434
3435These @samp{-m} switches are supported in addition to the above
3436on SPARC V9 processors in 64 bit environments.
3437
3438@table @code
3439@item -mlittle-endian
3440Generate code for a processor running in little-endian mode.
3441
ded17aad
DE
3442@item -m32
3443@itemx -m64
3444Generate code for a 32 bit or 64 bit environment.
3445The 32 bit environment sets int, long and pointer to 32 bits.
3446The 64 bit environment sets int to 32 bits and long and pointer
3447to 64 bits.
3448
3449@item -mcmodel=medlow
3450Generate code for the Medium/Low code model: the program must be linked
3451in the low 32 bits of the address space. Pointers are 64 bits.
3452Programs can be statically or dynamically linked.
3453
3454@item -mcmodel=medmid
3455Generate code for the Medium/Middle code model: the program must be linked
3456in the low 44 bits of the address space, the text segment must be less than
34572G bytes, and data segment must be within 2G of the text segment.
3458Pointers are 64 bits.
3459
3460@item -mcmodel=medany
3461Generate code for the Medium/Anywhere code model: the program may be linked
3462anywhere in the address space, the text segment must be less than
34632G bytes, and data segment must be within 2G of the text segment.
3464Pointers are 64 bits.
3465
3466@item -mcmodel=embmedany
3467Generate code for the Medium/Anywhere code model for embedded systems:
3468assume a 32 bit text and a 32 bit data segment, both starting anywhere
3469(determined at link time). Register %g4 points to the base of the
3470data segment. Pointers still 64 bits.
3471Programs are statically linked, PIC is not supported.
74291a4b
MM
3472
3473@item -mstack-bias
3474@itemx -mno-stack-bias
3475With @samp{-mstack-bias}, GNU CC assumes that the stack pointer, and
3476frame pointer if present, are offset by -2047 which must be added back
3477when making stack frame references.
3478Otherwise, assume no such offset is present.
3479@end table
3480
3481@node Convex Options
3482@subsection Convex Options
3483@cindex Convex options
3484
3485These @samp{-m} options are defined for Convex:
3486
3487@table @code
3488@item -mc1
3489Generate output for C1. The code will run on any Convex machine.
3490The preprocessor symbol @code{__convex__c1__} is defined.
3491
3492@item -mc2
3493Generate output for C2. Uses instructions not available on C1.
3494Scheduling and other optimizations are chosen for max performance on C2.
3495The preprocessor symbol @code{__convex_c2__} is defined.
3496
3497@item -mc32
3498Generate output for C32xx. Uses instructions not available on C1.
3499Scheduling and other optimizations are chosen for max performance on C32.
3500The preprocessor symbol @code{__convex_c32__} is defined.
3501
3502@item -mc34
3503Generate output for C34xx. Uses instructions not available on C1.
3504Scheduling and other optimizations are chosen for max performance on C34.
3505The preprocessor symbol @code{__convex_c34__} is defined.
3506
3507@item -mc38
3508Generate output for C38xx. Uses instructions not available on C1.
3509Scheduling and other optimizations are chosen for max performance on C38.
3510The preprocessor symbol @code{__convex_c38__} is defined.
3511
3512@item -margcount
3513Generate code which puts an argument count in the word preceding each
3514argument list. This is compatible with regular CC, and a few programs
3515may need the argument count word. GDB and other source-level debuggers
3516do not need it; this info is in the symbol table.
3517
3518@item -mnoargcount
3519Omit the argument count word. This is the default.
3520
3521@item -mvolatile-cache
3522Allow volatile references to be cached. This is the default.
3523
3524@item -mvolatile-nocache
3525Volatile references bypass the data cache, going all the way to memory.
3526This is only needed for multi-processor code that does not use standard
3527synchronization instructions. Making non-volatile references to volatile
3528locations will not necessarily work.
3529
3530@item -mlong32
3531Type long is 32 bits, the same as type int. This is the default.
3532
3533@item -mlong64
3534Type long is 64 bits, the same as type long long. This option is useless,
3535because no library support exists for it.
3536@end table
3537
3538@node AMD29K Options
3539@subsection AMD29K Options
3540@cindex AMD29K options
3541
3542These @samp{-m} options are defined for the AMD Am29000:
3543
3544@table @code
3545@item -mdw
3546@kindex -mdw
3547@cindex DW bit (29k)
3548Generate code that assumes the @code{DW} bit is set, i.e., that byte and
3549halfword operations are directly supported by the hardware. This is the
3550default.
3551
3552@item -mndw
3553@kindex -mndw
3554Generate code that assumes the @code{DW} bit is not set.
3555
3556@item -mbw
3557@kindex -mbw
3558@cindex byte writes (29k)
3559Generate code that assumes the system supports byte and halfword write
3560operations. This is the default.
3561
3562@item -mnbw
3563@kindex -mnbw
3564Generate code that assumes the systems does not support byte and
3565halfword write operations. @samp{-mnbw} implies @samp{-mndw}.
3566
3567@item -msmall
3568@kindex -msmall
3569@cindex memory model (29k)
3570Use a small memory model that assumes that all function addresses are
3571either within a single 256 KB segment or at an absolute address of less
3572than 256k. This allows the @code{call} instruction to be used instead
3573of a @code{const}, @code{consth}, @code{calli} sequence.
3574
3575@item -mnormal
3576@kindex -mnormal
3577Use the normal memory model: Generate @code{call} instructions only when
3578calling functions in the same file and @code{calli} instructions
3579otherwise. This works if each file occupies less than 256 KB but allows
3580the entire executable to be larger than 256 KB. This is the default.
3581
3582@item -mlarge
3583Always use @code{calli} instructions. Specify this option if you expect
3584a single file to compile into more than 256 KB of code.
3585
3586@item -m29050
3587@kindex -m29050
3588@cindex processor selection (29k)
3589Generate code for the Am29050.
3590
3591@item -m29000
3592@kindex -m29000
3593Generate code for the Am29000. This is the default.
3594
3595@item -mkernel-registers
3596@kindex -mkernel-registers
3597@cindex kernel and user registers (29k)
3598Generate references to registers @code{gr64-gr95} instead of to
3599registers @code{gr96-gr127}. This option can be used when compiling
3600kernel code that wants a set of global registers disjoint from that used
3601by user-mode code.
3602
3603Note that when this option is used, register names in @samp{-f} flags
3604must use the normal, user-mode, names.
3605
3606@item -muser-registers
3607@kindex -muser-registers
3608Use the normal set of global registers, @code{gr96-gr127}. This is the
3609default.
3610
3611@item -mstack-check
3612@itemx -mno-stack-check
3613@kindex -mstack-check
3614@cindex stack checks (29k)
3615Insert (or do not insert) a call to @code{__msp_check} after each stack
3616adjustment. This is often used for kernel code.
3617
3618@item -mstorem-bug
3619@itemx -mno-storem-bug
3620@kindex -mstorem-bug
3621@cindex storem bug (29k)
3622@samp{-mstorem-bug} handles 29k processors which cannot handle the
3623separation of a mtsrim insn and a storem instruction (most 29000 chips
3624to date, but not the 29050).
3625
3626@item -mno-reuse-arg-regs
3627@itemx -mreuse-arg-regs
3628@kindex -mreuse-arg-regs
3629@samp{-mno-reuse-arg-regs} tells the compiler to only use incoming argument
3630registers for copying out arguments. This helps detect calling a function
3631with fewer arguments than it was declared with.
3632
861bb6c1
JL
3633@item -mno-impure-text
3634@itemx -mimpure-text
3635@kindex -mimpure-text
3636@samp{-mimpure-text}, used in addition to @samp{-shared}, tells the compiler to
3637not pass @samp{-assert pure-text} to the linker when linking a shared object.
3638
74291a4b
MM
3639@item -msoft-float
3640@kindex -msoft-float
3641Generate output containing library calls for floating point.
3642@strong{Warning:} the requisite libraries are not part of GNU CC.
3643Normally the facilities of the machine's usual C compiler are used, but
3644this can't be done directly in cross-compilation. You must make your
3645own arrangements to provide suitable library functions for
3646cross-compilation.
3647@end table
3648
3649@node ARM Options
3650@subsection ARM Options
3651@cindex ARM options
3652
3653These @samp{-m} options are defined for Advanced RISC Machines (ARM)
3654architectures:
3655
3656@table @code
3657@item -mapcs-frame
3658@kindex -mapcs-frame
3659Generate a stack frame that is compliant with the ARM Procedure Call
3660Standard for all functions, even if this is not strictly necessary for
157a620e
NC
3661correct execution of the code. Specifying @samp{-fomit-frame-pointer}
3662with this option will cause the stack frames not to be generated for
3663leaf functions. The default is @samp{-mno-apcs-frame}.
3664
3665@item -mapcs
3666@kindex -mapcs
3667This is a synonym for @samp{-mapcs-frame}.
74291a4b
MM
3668
3669@item -mapcs-26
3670@kindex -mapcs-26
3671Generate code for a processor running with a 26-bit program counter,
3672and conforming to the function calling standards for the APCS 26-bit
3673option. This option replaces the @samp{-m2} and @samp{-m3} options
3674of previous releases of the compiler.
3675
3676@item -mapcs-32
3677@kindex -mapcs-32
3678Generate code for a processor running with a 32-bit program counter,
3679and conforming to the function calling standards for the APCS 32-bit
3680option. This option replaces the @samp{-m6} option of previous releases
3681of the compiler.
3682
157a620e
NC
3683@item -mapcs-stack-check
3684@kindex -mapcs-stack-check
3685@kindex -mno-apcs-stack-check
3686Generate code to check the amount of stack space available upon entry to
3687every function (that actually uses some stack space). If there is
3688insufficient space available then either the function
3689@samp{__rt_stkovf_split_small} or @samp{__rt_stkovf_split_big} will be
3690called, depending upon the amount of stack space required. The run time
3691system is required to provide these functions. The default is
3692@samp{-mno-apcs-stack-check}, since this produces smaller code.
3693
3694@item -mapcs-float
3695@kindex -mapcs-float
3696@kindex -mno-apcs-float
3697Pass floating point arguments using the float point registers. This is
3698one of the variants of the APCS. This option is reccommended if the
3699target hardware has a floating point unit or if a lot of floating point
3700arithmetic is going to be performed by the code. The default is
3701@samp{-mno-apcs-float}, since integer only code is slightly increased in
3702size if @samp{-mapcs-float} is used.
3703
3704@item -mapcs-reentrant
3705@kindex -mapcs-reentrant
3706@kindex -mno-apcs-reentrant
3707Generate reentrant, position independent code. This is the equivalent
3708to specifying the @samp{-fpic} option. The default is
3709@samp{-mno-apcs-reentrant}.
3710
3711@item -mthumb-interwork
3712@kindex -mthumb-interwork
3713@kindex -mno-thumb-interwork
3714Generate code which supports calling between the ARM and THUMB
3715instruction sets. Without this option the two instruction sets cannot
3716be reliably used inside one program. The default is
3717@samp{-mno-thumb-interwork}, since slightly larger code is generated
3718when @samp{-mthumb-interwork} is specified.
3719
3720@item -mno-sched-prolog
3721@kindex -mno-sched-prolog
3722@kindex -msched-prolog
3723Prevent the reordering of instructions in the function prolog, or the
3724merging of those instruction with the instructions in the function's
3725body. This means that all functions will start with a recognisable set
3726of instructions (or in fact one of a chioce from a small set of
3727different function prologues), and this information can be used to
3728locate the start if functions inside an executable piece of code. The
3729default is @samp{-msched-prolog}.
3730
74291a4b
MM
3731@item -mhard-float
3732Generate output containing floating point instructions. This is the
3733default.
3734
3735@item -msoft-float
3736Generate output containing library calls for floating point.
3737@strong{Warning:} the requisite libraries are not available for all ARM
3738targets. Normally the facilities of the machine's usual C compiler are
3739used, but this cannot be done directly in cross-compilation. You must make
3740your own arrangements to provide suitable library functions for
3741cross-compilation.
3742
3743@samp{-msoft-float} changes the calling convention in the output file;
3744therefore, it is only useful if you compile @emph{all} of a program with
3745this option. In particular, you need to compile @file{libgcc.a}, the
3746library that comes with GNU CC, with @samp{-msoft-float} in order for
3747this to work.
3748
3749@item -mlittle-endian
3750Generate code for a processor running in little-endian mode. This is
3751the default for all standard configurations.
3752
3753@item -mbig-endian
3754Generate code for a processor running in big-endian mode; the default is
3755to compile code for a little-endian processor.
3756
3757@item -mwords-little-endian
3758This option only applies when generating code for big-endian processors.
3759Generate code for a little-endian word order but a big-endian byte
3760order. That is, a byte order of the form @samp{32107654}. Note: this
3761option should only be used if you require compatibility with code for
3762big-endian ARM processors generated by versions of the compiler prior to
37632.8.
3764
3765@item -mshort-load-bytes
3766@kindex -mshort-load-bytes
3767Do not try to load half-words (eg @samp{short}s) by loading a word from
3768an unaligned address. For some targets the MMU is configured to trap
3769unaligned loads; use this option to generate code that is safe in these
3770environments.
3771
3772@item -mno-short-load-bytes
3773@kindex -mno-short-load-bytes
3774Use unaligned word loads to load half-words (eg @samp{short}s). This
3775option produces more efficient code, but the MMU is sometimes configured
3776to trap these instructions.
3777
157a620e
NC
3778@item -mshort-load-words
3779@kindex -mshort-load-words
3780This is a synonym for the @samp{-mno-short-load-bytes}.
3781
3782@item -mno-short-load-words
3783@kindex -mno-short-load-words
3784This is a synonym for the @samp{-mshort-load-bytes}.
3785
74291a4b
MM
3786@item -mbsd
3787@kindex -mbsd
3788This option only applies to RISC iX. Emulate the native BSD-mode
3789compiler. This is the default if @samp{-ansi} is not specified.
3790
3791@item -mxopen
3792@kindex -mxopen
3793This option only applies to RISC iX. Emulate the native X/Open-mode
3794compiler.
3795
3796@item -mno-symrename
3797@kindex -mno-symrename
3798This option only applies to RISC iX. Do not run the assembler
3799post-processor, @samp{symrename}, after code has been assembled.
3800Normally it is necessary to modify some of the standard symbols in
3801preparation for linking with the RISC iX C library; this option
3802suppresses this pass. The post-processor is never run when the
3803compiler is built for cross-compilation.
157a620e
NC
3804
3805@item -mcpu=<name>
f5a1b0d2 3806@item -mtune=<name>
157a620e 3807@kindex -mcpu=
f5a1b0d2 3808@kindex -mtune=
157a620e
NC
3809This specifies the name of the target ARM processor. GCC uses this name
3810to determine what kind of instructions it can use when generating
3811assembly code. Permissable names are: arm2, arm250, arm3, arm6, arm60,
3812arm600, arm610, arm620, arm7, arm7m, arm7d, arm7dm, arm7di, arm7dmi,
3813arm70, arm700, arm700i, arm710, arm710c, arm7100, arm7500, arm7500fe,
f5a1b0d2
NC
3814arm7tdmi, arm8, strongarm, strongarm110, strongarm1100, arm8, arm810,
3815arm9, arm9tdmi. @samp{-mtune=} is a synonym for @samp{-mcpue=} to
3816support older versions of GCC.
157a620e
NC
3817
3818@item -march=<name>
3819@kindex -march=
3820This specifies the name of the target ARM architecture. GCC uses this
3821name to determine what kind of instructions it can use when generating
3822assembly code. This option can be used in conjunction with or instead
3823of the @samp{-mcpu=} option. Permissable names are: armv2, armv2a,
3824armv3, armv3m, armv4, armv4t
3825
3826@item -mfpe=<number>
f5a1b0d2 3827@item -mfp=<number>
157a620e 3828@kindex -mfpe=
f5a1b0d2 3829@kindex -mfp=
157a620e 3830This specifes the version of the floating point emulation available on
f5a1b0d2
NC
3831the target. Permissable values are 2 and 3. @samp{-mfp=} is a synonym
3832for @samp{-mfpe=} to support older versions of GCC.
157a620e
NC
3833
3834@item -mstructure-size-boundary=<n>
3835@kindex -mstructure-size-boundary
3836The size of all structures and unions will be rounded up to a multiple
3837of the number of bits set by this option. Permissable values are 8 and
383832. The default value varies for different toolchains. For the COFF
3839targeted toolchain the default value is 8. Specifying the larger number
3840can produced faster, more efficient code, but can also increase the size
3841of the program. The two values are potentially incompatible. Code
3842compiled with one value cannot necessarily expect to work with code or
3843libraries compiled with the other value, if they exchange information
3844using structures or unions. Programmers are encouraged to use the 32
3845value as future versions of the toolchain may default to this value.
3846
f5a1b0d2
NC
3847@item -mabort-on-noreturn
3848@kindex -mabort-on-noreturn
3849@kindex -mnoabort-on-noreturn
3850Generate a call to the function abort at the end of a noreturn function.
3851It will be executed if the function tries to return.
3852
74291a4b
MM
3853@end table
3854
157a620e
NC
3855@node Thumb Options
3856@subsection Thumb Options
3857@cindex Thumb Options
3858
3859@table @code
3860
3861@item -mthumb-interwork
3862@kindex -mthumb-interwork
3863@kindex -mno-thumb-interwork
3864Generate code which supports calling between the THUMB and ARM
3865instruction sets. Without this option the two instruction sets cannot
3866be reliably used inside one program. The default is
3867@samp{-mno-thumb-interwork}, since slightly smaller code is generated
3868with this option.
3869
3870@item -mtpcs-frame
3871@kindex -mtpcs-frame
3872@kindex -mno-tpcs-frame
3873Generate a stack frame that is compliant with the Thumb Procedure Call
3874Standard for all non-leaf functions. (A leaf function is one that does
3875not call any other functions). The default is @samp{-mno-apcs-frame}.
3876
3877@item -mtpcs-leaf-frame
3878@kindex -mtpcs-leaf-frame
3879@kindex -mno-tpcs-leaf-frame
3880Generate a stack frame that is compliant with the Thumb Procedure Call
3881Standard for all leaf functions. (A leaf function is one that does
3882not call any other functions). The default is @samp{-mno-apcs-leaf-frame}.
3883
3884@item -mlittle-endian
3885@kindex -mlittle-endian
3886Generate code for a processor running in little-endian mode. This is
3887the default for all standard configurations.
3888
3889@item -mbig-endian
3890@kindex -mbig-endian
3891Generate code for a processor running in big-endian mode.
3892
3893@item -mstructure-size-boundary=<n>
3894@kindex -mstructure-size-boundary
3895The size of all structures and unions will be rounded up to a multiple
3896of the number of bits set by this option. Permissable values are 8 and
389732. The default value varies for different toolchains. For the COFF
3898targeted toolchain the default value is 8. Specifying the larger number
3899can produced faster, more efficient code, but can also increase the size
3900of the program. The two values are potentially incompatible. Code
3901compiled with one value cannot necessarily expect to work with code or
3902libraries compiled with the other value, if they exchange information
3903using structures or unions. Programmers are encouraged to use the 32
3904value as future versions of the toolchain may default to this value.
3905
3906@end table
3907
ecff22ab
JL
3908@node MN10200 Options
3909@subsection MN10200 Options
3910@cindex MN10200 options
3911These @samp{-m} options are defined for Matsushita MN10200 architectures:
3912@table @code
3913
3914@item -mrelax
3915Indicate to the linker that it should perform a relaxation optimization pass
3916to shorten branches, calls and absolute memory addresses. This option only
3917has an effect when used on the command line for the final link step.
3918
3919This option makes symbolic debugging impossible.
3920@end table
157a620e 3921
6d6d0fa0
JL
3922@node MN10300 Options
3923@subsection MN10300 Options
3924@cindex MN10300 options
3925These @samp{-m} options are defined for Matsushita MN10300 architectures:
3926
3927@table @code
3928@item -mmult-bug
3929Generate code to avoid bugs in the multiply instructions for the MN10300
3930processors. This is the default.
3931
3932@item -mno-mult-bug
3933Do not generate code to avoid bugs in the multiply instructions for the
3934MN10300 processors.
ecff22ab
JL
3935
3936@item -mrelax
3937Indicate to the linker that it should perform a relaxation optimization pass
3938to shorten branches, calls and absolute memory addresses. This option only
3939has an effect when used on the command line for the final link step.
3940
3941This option makes symbolic debugging impossible.
6d6d0fa0
JL
3942@end table
3943
ecff22ab 3944
861bb6c1
JL
3945@node M32R/D Options
3946@subsection M32R/D Options
3947@cindex M32R/D options
3948
3949These @samp{-m} options are defined for Mitsubishi M32R/D architectures:
3950
3951@table @code
3952@item -mcode-model=small
3953Assume all objects live in the lower 16MB of memory (so that their addresses
3954can be loaded with the @code{ld24} instruction), and assume all subroutines
3955are reachable with the @code{bl} instruction.
3956This is the default.
3957
3958The addressability of a particular object can be set with the
3959@code{model} attribute.
3960
3961@item -mcode-model=medium
3962Assume objects may be anywhere in the 32 bit address space (the compiler
3963will generate @code{seth/add3} instructions to load their addresses), and
3964assume all subroutines are reachable with the @code{bl} instruction.
3965
3966@item -mcode-model=large
3967Assume objects may be anywhere in the 32 bit address space (the compiler
3968will generate @code{seth/add3} instructions to load their addresses), and
3969assume subroutines may not be reachable with the @code{bl} instruction
3970(the compiler will generate the much slower @code{seth/add3/jl}
3971instruction sequence).
3972
3973@item -msdata=none
3974Disable use of the small data area. Variables will be put into
3975one of @samp{.data}, @samp{bss}, or @samp{.rodata} (unless the
3976@code{section} attribute has been specified).
3977This is the default.
3978
3979The small data area consists of sections @samp{.sdata} and @samp{.sbss}.
3980Objects may be explicitly put in the small data area with the
3981@code{section} attribute using one of these sections.
3982
3983@item -msdata=sdata
3984Put small global and static data in the small data area, but do not
3985generate special code to reference them.
3986
3987@item -msdata=use
3988Put small global and static data in the small data area, and generate
3989special instructions to reference them.
3990
3991@item -G @var{num}
3992@cindex smaller data references
3993Put global and static objects less than or equal to @var{num} bytes
3994into the small data or bss sections instead of the normal data or bss
3995sections. The default value of @var{num} is 8.
3996The @samp{-msdata} option must be set to one of @samp{sdata} or @samp{use}
3997for this option to have any effect.
3998
3999All modules should be compiled with the same @samp{-G @var{num}} value.
4000Compiling with different values of @var{num} may or may not work; if it
4001doesn't the linker will give an error message - incorrect code will not be
4002generated.
4003
4004@end table
4005
74291a4b
MM
4006@node M88K Options
4007@subsection M88K Options
4008@cindex M88k options
4009
4010These @samp{-m} options are defined for Motorola 88k architectures:
4011
4012@table @code
4013@item -m88000
4014@kindex -m88000
4015Generate code that works well on both the m88100 and the
4016m88110.
4017
4018@item -m88100
4019@kindex -m88100
4020Generate code that works best for the m88100, but that also
4021runs on the m88110.
4022
4023@item -m88110
4024@kindex -m88110
4025Generate code that works best for the m88110, and may not run
4026on the m88100.
4027
4028@item -mbig-pic
4029@kindex -mbig-pic
4030Obsolete option to be removed from the next revision.
4031Use @samp{-fPIC}.
4032
4033@item -midentify-revision
4034@kindex -midentify-revision
4035@kindex ident
4036@cindex identifying source, compiler (88k)
4037Include an @code{ident} directive in the assembler output recording the
4038source file name, compiler name and version, timestamp, and compilation
4039flags used.
4040
4041@item -mno-underscores
4042@kindex -mno-underscores
4043@cindex underscores, avoiding (88k)
4044In assembler output, emit symbol names without adding an underscore
4045character at the beginning of each name. The default is to use an
4046underscore as prefix on each name.
4047
4048@item -mocs-debug-info
4049@itemx -mno-ocs-debug-info
4050@kindex -mocs-debug-info
4051@kindex -mno-ocs-debug-info
4052@cindex OCS (88k)
4053@cindex debugging, 88k OCS
4054Include (or omit) additional debugging information (about registers used
4055in each stack frame) as specified in the 88open Object Compatibility
4056Standard, ``OCS''. This extra information allows debugging of code that
4057has had the frame pointer eliminated. The default for DG/UX, SVr4, and
4058Delta 88 SVr3.2 is to include this information; other 88k configurations
4059omit this information by default.
4060
4061@item -mocs-frame-position
4062@kindex -mocs-frame-position
4063@cindex register positions in frame (88k)
4064When emitting COFF debugging information for automatic variables and
4065parameters stored on the stack, use the offset from the canonical frame
4066address, which is the stack pointer (register 31) on entry to the
4067function. The DG/UX, SVr4, Delta88 SVr3.2, and BCS configurations use
4068@samp{-mocs-frame-position}; other 88k configurations have the default
4069@samp{-mno-ocs-frame-position}.
4070
4071@item -mno-ocs-frame-position
4072@kindex -mno-ocs-frame-position
4073@cindex register positions in frame (88k)
4074When emitting COFF debugging information for automatic variables and
4075parameters stored on the stack, use the offset from the frame pointer
4076register (register 30). When this option is in effect, the frame
4077pointer is not eliminated when debugging information is selected by the
4078-g switch.
4079
4080@item -moptimize-arg-area
4081@itemx -mno-optimize-arg-area
4082@kindex -moptimize-arg-area
4083@kindex -mno-optimize-arg-area
4084@cindex arguments in frame (88k)
4085Control how function arguments are stored in stack frames.
4086@samp{-moptimize-arg-area} saves space by optimizing them, but this
4087conflicts with the 88open specifications. The opposite alternative,
4088@samp{-mno-optimize-arg-area}, agrees with 88open standards. By default
4089GNU CC does not optimize the argument area.
4090
4091@item -mshort-data-@var{num}
4092@kindex -mshort-data-@var{num}
4093@cindex smaller data references (88k)
4094@cindex r0-relative references (88k)
4095Generate smaller data references by making them relative to @code{r0},
4096which allows loading a value using a single instruction (rather than the
4097usual two). You control which data references are affected by
4098specifying @var{num} with this option. For example, if you specify
4099@samp{-mshort-data-512}, then the data references affected are those
4100involving displacements of less than 512 bytes.
4101@samp{-mshort-data-@var{num}} is not effective for @var{num} greater
4102than 64k.
4103
4104@item -mserialize-volatile
4105@kindex -mserialize-volatile
4106@itemx -mno-serialize-volatile
4107@kindex -mno-serialize-volatile
4108@cindex sequential consistency on 88k
4109Do, or don't, generate code to guarantee sequential consistency
4110of volatile memory references. By default, consistency is
4111guaranteed.
4112
4113The order of memory references made by the MC88110 processor does
4114not always match the order of the instructions requesting those
4115references. In particular, a load instruction may execute before
4116a preceding store instruction. Such reordering violates
4117sequential consistency of volatile memory references, when there
4118are multiple processors. When consistency must be guaranteed,
4119GNU C generates special instructions, as needed, to force
4120execution in the proper order.
4121
4122The MC88100 processor does not reorder memory references and so
4123always provides sequential consistency. However, by default, GNU
4124C generates the special instructions to guarantee consistency
4125even when you use @samp{-m88100}, so that the code may be run on an
4126MC88110 processor. If you intend to run your code only on the
4127MC88100 processor, you may use @samp{-mno-serialize-volatile}.
4128
4129The extra code generated to guarantee consistency may affect the
4130performance of your application. If you know that you can safely
4131forgo this guarantee, you may use @samp{-mno-serialize-volatile}.
4132
4133@item -msvr4
4134@itemx -msvr3
4135@kindex -msvr4
4136@kindex -msvr3
4137@cindex assembler syntax, 88k
4138@cindex SVr4
4139Turn on (@samp{-msvr4}) or off (@samp{-msvr3}) compiler extensions
4140related to System V release 4 (SVr4). This controls the following:
4141
4142@enumerate
4143@item
4144Which variant of the assembler syntax to emit.
4145@item
4146@samp{-msvr4} makes the C preprocessor recognize @samp{#pragma weak}
4147that is used on System V release 4.
4148@item
4149@samp{-msvr4} makes GNU CC issue additional declaration directives used in
4150SVr4.
4151@end enumerate
4152
4153@samp{-msvr4} is the default for the m88k-motorola-sysv4 and
4154m88k-dg-dgux m88k configurations. @samp{-msvr3} is the default for all
4155other m88k configurations.
4156
4157@item -mversion-03.00
4158@kindex -mversion-03.00
4159This option is obsolete, and is ignored.
4160@c ??? which asm syntax better for GAS? option there too?
4161
4162@item -mno-check-zero-division
4163@itemx -mcheck-zero-division
4164@kindex -mno-check-zero-division
4165@kindex -mcheck-zero-division
4166@cindex zero division on 88k
4167Do, or don't, generate code to guarantee that integer division by
4168zero will be detected. By default, detection is guaranteed.
4169
4170Some models of the MC88100 processor fail to trap upon integer
4171division by zero under certain conditions. By default, when
4172compiling code that might be run on such a processor, GNU C
4173generates code that explicitly checks for zero-valued divisors
4174and traps with exception number 503 when one is detected. Use of
4175mno-check-zero-division suppresses such checking for code
4176generated to run on an MC88100 processor.
4177
4178GNU C assumes that the MC88110 processor correctly detects all
4179instances of integer division by zero. When @samp{-m88110} is
4180specified, both @samp{-mcheck-zero-division} and
4181@samp{-mno-check-zero-division} are ignored, and no explicit checks for
4182zero-valued divisors are generated.
4183
4184@item -muse-div-instruction
4185@kindex -muse-div-instruction
4186@cindex divide instruction, 88k
4187Use the div instruction for signed integer division on the
4188MC88100 processor. By default, the div instruction is not used.
4189
4190On the MC88100 processor the signed integer division instruction
4191div) traps to the operating system on a negative operand. The
4192operating system transparently completes the operation, but at a
4193large cost in execution time. By default, when compiling code
4194that might be run on an MC88100 processor, GNU C emulates signed
4195integer division using the unsigned integer division instruction
4196divu), thereby avoiding the large penalty of a trap to the
4197operating system. Such emulation has its own, smaller, execution
4198cost in both time and space. To the extent that your code's
4199important signed integer division operations are performed on two
4200nonnegative operands, it may be desirable to use the div
4201instruction directly.
4202
4203On the MC88110 processor the div instruction (also known as the
4204divs instruction) processes negative operands without trapping to
4205the operating system. When @samp{-m88110} is specified,
4206@samp{-muse-div-instruction} is ignored, and the div instruction is used
4207for signed integer division.
4208
4209Note that the result of dividing INT_MIN by -1 is undefined. In
4210particular, the behavior of such a division with and without
4211@samp{-muse-div-instruction} may differ.
4212
4213@item -mtrap-large-shift
4214@itemx -mhandle-large-shift
4215@kindex -mtrap-large-shift
4216@kindex -mhandle-large-shift
4217@cindex bit shift overflow (88k)
4218@cindex large bit shifts (88k)
4219Include code to detect bit-shifts of more than 31 bits; respectively,
4220trap such shifts or emit code to handle them properly. By default GNU CC
4221makes no special provision for large bit shifts.
4222
4223@item -mwarn-passed-structs
4224@kindex -mwarn-passed-structs
4225@cindex structure passing (88k)
4226Warn when a function passes a struct as an argument or result.
4227Structure-passing conventions have changed during the evolution of the C
4228language, and are often the source of portability problems. By default,
4229GNU CC issues no such warning.
4230@end table
4231
4232@node RS/6000 and PowerPC Options
4233@subsection IBM RS/6000 and PowerPC Options
4234@cindex RS/6000 and PowerPC Options
4235@cindex IBM RS/6000 and PowerPC Options
4236
4237These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
4238@table @code
4239@item -mpower
4240@itemx -mno-power
4241@itemx -mpower2
4242@itemx -mno-power2
4243@itemx -mpowerpc
4244@itemx -mno-powerpc
4245@itemx -mpowerpc-gpopt
4246@itemx -mno-powerpc-gpopt
4247@itemx -mpowerpc-gfxopt
4248@itemx -mno-powerpc-gfxopt
7fe90e7b
DE
4249@itemx -mpowerpc64
4250@itemx -mno-powerpc64
74291a4b
MM
4251@kindex -mpower
4252@kindex -mpower2
4253@kindex -mpowerpc
4254@kindex -mpowerpc-gpopt
4255@kindex -mpowerpc-gfxopt
7fe90e7b 4256@kindex -mpowerpc64
74291a4b
MM
4257GNU CC supports two related instruction set architectures for the
4258RS/6000 and PowerPC. The @dfn{POWER} instruction set are those
4259instructions supported by the @samp{rios} chip set used in the original
4260RS/6000 systems and the @dfn{PowerPC} instruction set is the
4261architecture of the Motorola MPC5xx, MPC6xx, MPC8xx microprocessors, and
861bb6c1 4262the IBM 4xx microprocessors.
74291a4b
MM
4263
4264Neither architecture is a subset of the other. However there is a
4265large common subset of instructions supported by both. An MQ
4266register is included in processors supporting the POWER architecture.
4267
4268You use these options to specify which instructions are available on the
4269processor you are using. The default value of these options is
4270determined when configuring GNU CC. Specifying the
4271@samp{-mcpu=@var{cpu_type}} overrides the specification of these
4272options. We recommend you use the @samp{-mcpu=@var{cpu_type}} option
4273rather than the options listed above.
4274
4275The @samp{-mpower} option allows GNU CC to generate instructions that
4276are found only in the POWER architecture and to use the MQ register.
4277Specifying @samp{-mpower2} implies @samp{-power} and also allows GNU CC
4278to generate instructions that are present in the POWER2 architecture but
4279not the original POWER architecture.
4280
4281The @samp{-mpowerpc} option allows GNU CC to generate instructions that
4282are found only in the 32-bit subset of the PowerPC architecture.
4283Specifying @samp{-mpowerpc-gpopt} implies @samp{-mpowerpc} and also allows
4284GNU CC to use the optional PowerPC architecture instructions in the
4285General Purpose group, including floating-point square root. Specifying
4286@samp{-mpowerpc-gfxopt} implies @samp{-mpowerpc} and also allows GNU CC to
4287use the optional PowerPC architecture instructions in the Graphics
4288group, including floating-point select.
4289
7fe90e7b
DE
4290The @samp{-mpowerpc64} option allows GNU CC to generate the additional
429164-bit instructions that are found in the full PowerPC64 architecture
4292and to treat GPRs as 64-bit, doubleword quantities. GNU CC defaults to
4293@samp{-mno-powerpc64}.
4294
74291a4b
MM
4295If you specify both @samp{-mno-power} and @samp{-mno-powerpc}, GNU CC
4296will use only the instructions in the common subset of both
4297architectures plus some special AIX common-mode calls, and will not use
4298the MQ register. Specifying both @samp{-mpower} and @samp{-mpowerpc}
4299permits GNU CC to use any instruction from either architecture and to
4300allow use of the MQ register; specify this for the Motorola MPC601.
4301
4302@item -mnew-mnemonics
4303@itemx -mold-mnemonics
4304@kindex -mnew-mnemonics
4305@kindex -mold-mnemonics
4306Select which mnemonics to use in the generated assembler code.
4307@samp{-mnew-mnemonics} requests output that uses the assembler mnemonics
4308defined for the PowerPC architecture, while @samp{-mold-mnemonics}
4309requests the assembler mnemonics defined for the POWER architecture.
4310Instructions defined in only one architecture have only one mnemonic;
4311GNU CC uses that mnemonic irrespective of which of these options is
4312specified.
4313
7fe90e7b
DE
4314GNU CC defaults to the mnemonics appropriate for the architecture in
4315use. Specifying @samp{-mcpu=@var{cpu_type}} sometimes overrides the
4316value of these option. Unless you are building a cross-compiler, you
4317should normally not specify either @samp{-mnew-mnemonics} or
74291a4b
MM
4318@samp{-mold-mnemonics}, but should instead accept the default.
4319
4320@item -mcpu=@var{cpu_type}
7fe90e7b 4321@kindex -mcpu
74291a4b
MM
4322Set architecture type, register usage, choice of mnemonics, and
4323instruction scheduling parameters for machine type @var{cpu_type}.
4324Supported values for @var{cpu_type} are @samp{rs6000}, @samp{rios1},
4325@samp{rios2}, @samp{rsc}, @samp{601}, @samp{602}, @samp{603},
bef84347
VM
4326@samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{740},
4327@samp{750}, @samp{power}, @samp{power2}, @samp{powerpc}, @samp{403},
4328@samp{505}, @samp{801}, @samp{821}, @samp{823}, and @samp{860} and
4329@samp{common}. @samp{-mcpu=power}, @samp{-mcpu=power2}, and
4330@samp{-mcpu=powerpc} specify generic POWER, POWER2 and pure PowerPC
4331(i.e., not MPC601) architecture machine types, with an appropriate,
4332generic processor model assumed for scheduling purposes.@refill
74291a4b
MM
4333
4334@c overfull hbox here --bob 22 jul96
4335@c original text between ignore ... end ignore
4336@ignore
861bb6c1
JL
4337Specifying any of the @samp{-mcpu=rios1}, @samp{-mcpu=rios2},
4338@samp{-mcpu=rsc}, @samp{-mcpu=power}, or @samp{-mcpu=power2} options
4339enables the @samp{-mpower} option and disables the @samp{-mpowerpc}
4340option; @samp{-mcpu=601} enables both the @samp{-mpower} and
4341@samp{-mpowerpc} options; all of @samp{-mcpu=602}, @samp{-mcpu=603},
4342@samp{-mcpu=603e}, @samp{-mcpu=604}, @samp{-mcpu=604e},
4343@samp{-mcpu=620}, @samp{-mcpu=403}, @samp{-mcpu=505}, @samp{-mcpu=801},
4344@samp{-mcpu=821}, @samp{-mcpu=823}, @samp{-mcpu=860} and
4345@samp{-mcpu=powerpc} enable the @samp{-mpowerpc} option and disable the
4346@samp{-mpower} option; @samp{-mcpu=common} disables both the
4347@samp{-mpower} and @samp{-mpowerpc} options.@refill
74291a4b
MM
4348@end ignore
4349@c changed paragraph
4350Specifying any of the following options:
4351@samp{-mcpu=rios1}, @samp{-mcpu=rios2}, @samp{-mcpu=rsc},
4352@samp{-mcpu=power}, or @samp{-mcpu=power2}
4353enables the @samp{-mpower} option and disables the @samp{-mpowerpc} option;
4354@samp{-mcpu=601} enables both the @samp{-mpower} and @samp{-mpowerpc} options.
4355All of @samp{-mcpu=602}, @samp{-mcpu=603}, @samp{-mcpu=603e},
4356@samp{-mcpu=604}, @samp{-mcpu=620},
4357enable the @samp{-mpowerpc} option and disable the @samp{-mpower} option.
4358Exactly similarly, all of @samp{-mcpu=403},
4359@samp{-mcpu=505}, @samp{-mcpu=821}, @samp{-mcpu=860} and @samp{-mcpu=powerpc}
4360enable the @samp{-mpowerpc} option and disable the @samp{-mpower} option.
4361@samp{-mcpu=common} disables both the
4362@samp{-mpower} and @samp{-mpowerpc} options.@refill
4363@c end changes to prevent overfull hboxes
4364
4365AIX versions 4 or greater selects @samp{-mcpu=common} by default, so
4366that code will operate on all members of the RS/6000 and PowerPC
4367families. In that case, GNU CC will use only the instructions in the
4368common subset of both architectures plus some special AIX common-mode
4369calls, and will not use the MQ register. GNU CC assumes a generic
4370processor model for scheduling purposes.
4371
4372Specifying any of the options @samp{-mcpu=rios1}, @samp{-mcpu=rios2},
4373@samp{-mcpu=rsc}, @samp{-mcpu=power}, or @samp{-mcpu=power2} also
4374disables the @samp{new-mnemonics} option. Specifying @samp{-mcpu=601},
4375@samp{-mcpu=602}, @samp{-mcpu=603}, @samp{-mcpu=603e}, @samp{-mcpu=604},
4376@samp{620}, @samp{403}, or @samp{-mcpu=powerpc} also enables the
4377@samp{new-mnemonics} option.@refill
4378
4379Specifying @samp{-mcpu=403}, @samp{-mcpu=821}, or @samp{-mcpu=860} also
4380enables the @samp{-msoft-float} option.
4381
4382@item -mtune=@var{cpu_type}
4383Set the instruction scheduling parameters for machine type
4384@var{cpu_type}, but do not set the architecture type, register usage,
4385choice of mnemonics like @samp{-mcpu=}@var{cpu_type} would. The same
4386values for @var{cpu_type} are used for @samp{-mtune=}@var{cpu_type} as
4387for @samp{-mcpu=}@var{cpu_type}. The @samp{-mtune=}@var{cpu_type}
4388option overrides the @samp{-mcpu=}@var{cpu_type} option in terms of
4389instruction scheduling parameters.
4390
4391@item -mfull-toc
4392@itemx -mno-fp-in-toc
4393@itemx -mno-sum-in-toc
4394@itemx -mminimal-toc
7fe90e7b 4395@kindex -mminimal-toc
74291a4b
MM
4396Modify generation of the TOC (Table Of Contents), which is created for
4397every executable file. The @samp{-mfull-toc} option is selected by
4398default. In that case, GNU CC will allocate at least one TOC entry for
4399each unique non-automatic variable reference in your program. GNU CC
4400will also place floating-point constants in the TOC. However, only
440116,384 entries are available in the TOC.
4402
4403If you receive a linker error message that saying you have overflowed
4404the available TOC space, you can reduce the amount of TOC space used
4405with the @samp{-mno-fp-in-toc} and @samp{-mno-sum-in-toc} options.
4406@samp{-mno-fp-in-toc} prevents GNU CC from putting floating-point
4407constants in the TOC and @samp{-mno-sum-in-toc} forces GNU CC to
4408generate code to calculate the sum of an address and a constant at
4409run-time instead of putting that sum into the TOC. You may specify one
4410or both of these options. Each causes GNU CC to produce very slightly
4411slower and larger code at the expense of conserving TOC space.
4412
4413If you still run out of space in the TOC even when you specify both of
4414these options, specify @samp{-mminimal-toc} instead. This option causes
4415GNU CC to make only one TOC entry for every file. When you specify this
4416option, GNU CC will produce code that is slower and larger but which
4417uses extremely little TOC space. You may wish to use this option
4418only on files that contain less frequently executed code. @refill
4419
7fe90e7b
DE
4420@item -maix64
4421@itemx -maix32
4422@kindex -maix64
4423@kindex -maix32
4424Enable AIX 64-bit ABI and calling convention: 64-bit pointers, 64-bit
4425@code{long} type, and the infrastructure needed to support them.
4426Specifying @samp{-maix64} implies @samp{-mpowerpc64} and
4427@samp{-mpowerpc}, while @samp{-maix32} disables the 64-bit ABI and
4428implies @samp{-mno-powerpc64}. GNU CC defaults to @samp{-maix32}.
4429
74291a4b
MM
4430@item -mxl-call
4431@itemx -mno-xl-call
7fe90e7b 4432@kindex -mxl-call
74291a4b
MM
4433On AIX, pass floating-point arguments to prototyped functions beyond the
4434register save area (RSA) on the stack in addition to argument FPRs. The
4435AIX calling convention was extended but not initially documented to
4436handle an obscure K&R C case of calling a function that takes the
4437address of its arguments with fewer arguments than declared. AIX XL
7fe90e7b
DE
4438compilers access floating point arguments which do not fit in the
4439RSA from the stack when a subroutine is compiled without
74291a4b
MM
4440optimization. Because always storing floating-point arguments on the
4441stack is inefficient and rarely needed, this option is not enabled by
4442default and only is necessary when calling subroutines compiled by AIX
4443XL compilers without optimization.
4444
861bb6c1 4445@item -mthreads
7fe90e7b 4446@kindex -mthreads
861bb6c1
JL
4447Support @dfn{AIX Threads}. Link an application written to use
4448@dfn{pthreads} with special libraries and startup code to enable the
4449application to run.
4450
4451@item -mpe
7fe90e7b 4452@kindex -mpe
861bb6c1
JL
4453Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE). Link an
4454application written to use message passing with special startup code to
4455enable the application to run. The system must have PE installed in the
4456standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
4457must be overridden with the @samp{-specs=} option to specify the
4458appropriate directory location. The Parallel Environment does not
4459support threads, so the @samp{-mpe} option and the @samp{-mthreads}
4460option are incompatible.
4461
74291a4b
MM
4462@item -msoft-float
4463@itemx -mhard-float
7fe90e7b 4464@kindex -msoft-float
74291a4b
MM
4465Generate code that does not use (uses) the floating-point register set.
4466Software floating point emulation is provided if you use the
4467@samp{-msoft-float} option, and pass the option to GNU CC when linking.
4468
4469@item -mmultiple
4470@itemx -mno-multiple
4471Generate code that uses (does not use) the load multiple word
4472instructions and the store multiple word instructions. These
4473instructions are generated by default on POWER systems, and not
4474generated on PowerPC systems. Do not use @samp{-mmultiple} on little
4475endian PowerPC systems, since those instructions do not work when the
bef84347
VM
4476processor is in little endian mode. The exceptions are PPC740 and
4477PPC750 which permit the instructions usage in little endian mode.
74291a4b
MM
4478
4479@item -mstring
4480@itemx -mno-string
7fe90e7b 4481@kindex -mstring
bef84347
VM
4482Generate code that uses (does not use) the load string instructions
4483and the store string word instructions to save multiple registers and
4484do small block moves. These instructions are generated by default on
4485POWER systems, and not generated on PowerPC systems. Do not use
4486@samp{-mstring} on little endian PowerPC systems, since those
4487instructions do not work when the processor is in little endian mode.
4488The exceptions are PPC740 and PPC750 which permit the instructions
4489usage in little endian mode.
74291a4b 4490
861bb6c1
JL
4491@item -mupdate
4492@itemx -mno-update
7fe90e7b 4493@kindex -mupdate
861bb6c1
JL
4494Generate code that uses (does not use) the load or store instructions
4495that update the base register to the address of the calculated memory
4496location. These instructions are generated by default. If you use
4497@samp{-mno-update}, there is a small window between the time that the
4498stack pointer is updated and the address of the previous frame is
4499stored, which means code that walks the stack frame across interrupts or
4500signals may get corrupted data.
4501
4502@item -mfused-madd
4503@itemx -mno-fused-madd
7fe90e7b 4504@kindex -mfused-madd
861bb6c1
JL
4505Generate code that uses (does not use) the floating point multiply and
4506accumulate instructions. These instructions are generated by default if
4507hardware floating is used.
4508
74291a4b
MM
4509@item -mno-bit-align
4510@itemx -mbit-align
7fe90e7b 4511@kindex -mbit-align
74291a4b
MM
4512On System V.4 and embedded PowerPC systems do not (do) force structures
4513and unions that contain bit fields to be aligned to the base type of the
4514bit field.
4515
4516For example, by default a structure containing nothing but 8
4517@code{unsigned} bitfields of length 1 would be aligned to a 4 byte
4518boundary and have a size of 4 bytes. By using @samp{-mno-bit-align},
4519the structure would be aligned to a 1 byte boundary and be one byte in
4520size.
4521
4522@item -mno-strict-align
4523@itemx -mstrict-align
7fe90e7b 4524@kindex -mstrict-align
74291a4b
MM
4525On System V.4 and embedded PowerPC systems do not (do) assume that
4526unaligned memory references will be handled by the system.
4527
4528@item -mrelocatable
4529@itemx -mno-relocatable
7fe90e7b 4530@kindex -mrelocatable
74291a4b
MM
4531On embedded PowerPC systems generate code that allows (does not allow)
4532the program to be relocated to a different address at runtime. If you
4533use @samp{-mrelocatable} on any module, all objects linked together must
4534be compiled with @samp{-mrelocatable} or @samp{-mrelocatable-lib}.
4535
4536@item -mrelocatable-lib
4537@itemx -mno-relocatable-lib
4538On embedded PowerPC systems generate code that allows (does not allow)
4539the program to be relocated to a different address at runtime. Modules
956d6950 4540compiled with @samp{-mrelocatable-lib} can be linked with either modules
74291a4b
MM
4541compiled without @samp{-mrelocatable} and @samp{-mrelocatable-lib} or
4542with modules compiled with the @samp{-mrelocatable} options.
4543
4544@item -mno-toc
4545@itemx -mtoc
4546On System V.4 and embedded PowerPC systems do not (do) assume that
4547register 2 contains a pointer to a global area pointing to the addresses
4548used in the program.
4549
74291a4b
MM
4550@item -mlittle
4551@itemx -mlittle-endian
4552On System V.4 and embedded PowerPC systems compile code for the
4553processor in little endian mode. The @samp{-mlittle-endian} option is
4554the same as @samp{-mlittle}.
4555
4556@item -mbig
4557@itemx -mbig-endian
4558On System V.4 and embedded PowerPC systems compile code for the
4559processor in big endian mode. The @samp{-mbig-endian} option is
4560the same as @samp{-mbig}.
4561
4562@item -mcall-sysv
4563On System V.4 and embedded PowerPC systems compile code using calling
4564conventions that adheres to the March 1995 draft of the System V
4565Application Binary Interface, PowerPC processor supplement. This is the
4566default unless you configured GCC using @samp{powerpc-*-eabiaix}.
4567
4568@item -mcall-sysv-eabi
4569Specify both @samp{-mcall-sysv} and @samp{-meabi} options.
4570
4571@item -mcall-sysv-noeabi
4572Specify both @samp{-mcall-sysv} and @samp{-mno-eabi} options.
4573
4574@item -mcall-aix
4575On System V.4 and embedded PowerPC systems compile code using calling
4576conventions that are similar to those used on AIX. This is the
4577default if you configured GCC using @samp{powerpc-*-eabiaix}.
4578
4579@item -mcall-solaris
4580On System V.4 and embedded PowerPC systems compile code for the Solaris
4581operating system.
4582
4583@item -mcall-linux
861bb6c1
JL
4584On System V.4 and embedded PowerPC systems compile code for the
4585Linux-based GNU system.
74291a4b
MM
4586
4587@item -mprototype
e9a25f70 4588@itemx -mno-prototype
74291a4b
MM
4589On System V.4 and embedded PowerPC systems assume that all calls to
4590variable argument functions are properly prototyped. Otherwise, the
4591compiler must insert an instruction before every non prototyped call to
4592set or clear bit 6 of the condition code register (@var{CR}) to
4593indicate whether floating point values were passed in the floating point
4594registers in case the function takes a variable arguments. With
4595@samp{-mprototype}, only calls to prototyped variable argument functions
4596will set or clear the bit.
4597
4598@item -msim
4599On embedded PowerPC systems, assume that the startup module is called
4600@file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
4601@file{libc.a}. This is the default for @samp{powerpc-*-eabisim}.
4602configurations.
4603
4604@item -mmvme
4605On embedded PowerPC systems, assume that the startup module is called
e9a25f70
JL
4606@file{crt0.o} and the standard C libraries are @file{libmvme.a} and
4607@file{libc.a}.
4608
4609@item -mads
4610On embedded PowerPC systems, assume that the startup module is called
4611@file{crt0.o} and the standard C libraries are @file{libads.a} and
4612@file{libc.a}.
4613
4614@item -myellowknife
4615On embedded PowerPC systems, assume that the startup module is called
4616@file{crt0.o} and the standard C libraries are @file{libyk.a} and
74291a4b
MM
4617@file{libc.a}.
4618
4619@item -memb
4620On embedded PowerPC systems, set the @var{PPC_EMB} bit in the ELF flags
4621header to indicate that @samp{eabi} extended relocations are used.
4622
4623@item -meabi
4624@itemx -mno-eabi
4625On System V.4 and embedded PowerPC systems do (do not) adhere to the
4626Embedded Applications Binary Interface (eabi) which is a set of
4627modifications to the System V.4 specifications. Selecting @code{-meabi}
4628means that the stack is aligned to an 8 byte boundary, a function
4629@code{__eabi} is called to from @code{main} to set up the eabi
4630environment, and the @samp{-msdata} option can use both @code{r2} and
4631@code{r13} to point to two separate small data areas. Selecting
4632@code{-mno-eabi} means that the stack is aligned to a 16 byte boundary,
4633do not call an initialization function from @code{main}, and the
4634@samp{-msdata} option will only use @code{r13} to point to a single
4635small data area. The @samp{-meabi} option is on by default if you
4636configured GCC using one of the @samp{powerpc*-*-eabi*} options.
4637
4638@item -msdata=eabi
4639On System V.4 and embedded PowerPC systems, put small initialized
4640@code{const} global and static data in the @samp{.sdata2} section, which
4641is pointed to by register @code{r2}. Put small initialized
4642non-@code{const} global and static data in the @samp{.sdata} section,
4643which is pointed to by register @code{r13}. Put small uninitialized
4644global and static data in the @samp{.sbss} section, which is adjacent to
4645the @samp{.sdata} section. The @samp{-msdata=eabi} option is
4646incompatible with the @samp{-mrelocatable} option. The
4647@samp{-msdata=eabi} option also sets the @samp{-memb} option.
4648
4649@item -msdata=sysv
4650On System V.4 and embedded PowerPC systems, put small global and static
4651data in the @samp{.sdata} section, which is pointed to by register
4652@code{r13}. Put small uninitialized global and static data in the
4653@samp{.sbss} section, which is adjacent to the @samp{.sdata} section.
4654The @samp{-msdata=sysv} option is incompatible with the
4655@samp{-mrelocatable} option.
4656
4657@item -msdata=default
4658@itemx -msdata
4659On System V.4 and embedded PowerPC systems, if @samp{-meabi} is used,
4660compile code the same as @samp{-msdata=eabi}, otherwise compile code the
4661same as @samp{-msdata=sysv}.
4662
4663@item -msdata-data
4664On System V.4 and embedded PowerPC systems, put small global and static
4665data in the @samp{.sdata} section. Put small uninitialized global and
4666static data in the @samp{.sbss} section. Do not use register @code{r13}
4667to address small data however. This is the default behavior unless
4668other @samp{-msdata} options are used.
4669
4670@item -msdata=none
4671@itemx -mno-sdata
4672On embedded PowerPC systems, put all initialized global and static data
4673in the @samp{.data} section, and all uninitialized data in the
4674@samp{.bss} section.
4675
4676@item -G @var{num}
4677@cindex smaller data references (PowerPC)
4678@cindex .sdata/.sdata2 references (PowerPC)
956d6950 4679On embedded PowerPC systems, put global and static items less than or
74291a4b
MM
4680equal to @var{num} bytes into the small data or bss sections instead of
4681the normal data or bss section. By default, @var{num} is 8. The
4682@samp{-G @var{num}} switch is also passed to the linker.
4683All modules should be compiled with the same @samp{-G @var{num}} value.
4684
4685@item -mregnames
4686@itemx -mno-regnames
4687On System V.4 and embedded PowerPC systems do (do not) emit register
4688names in the assembly language output using symbolic forms.
f5a1b0d2 4689
74291a4b 4690@end table
f5a1b0d2 4691
74291a4b
MM
4692@node RT Options
4693@subsection IBM RT Options
4694@cindex RT options
4695@cindex IBM RT options
4696
4697These @samp{-m} options are defined for the IBM RT PC:
4698
4699@table @code
4700@item -min-line-mul
4701Use an in-line code sequence for integer multiplies. This is the
4702default.
4703
4704@item -mcall-lib-mul
4705Call @code{lmul$$} for integer multiples.
4706
4707@item -mfull-fp-blocks
4708Generate full-size floating point data blocks, including the minimum
4709amount of scratch space recommended by IBM. This is the default.
4710
4711@item -mminimum-fp-blocks
4712Do not include extra scratch space in floating point data blocks. This
4713results in smaller code, but slower execution, since scratch space must
4714be allocated dynamically.
4715
4716@cindex @file{varargs.h} and RT PC
4717@cindex @file{stdarg.h} and RT PC
4718@item -mfp-arg-in-fpregs
4719Use a calling sequence incompatible with the IBM calling convention in
4720which floating point arguments are passed in floating point registers.
4721Note that @code{varargs.h} and @code{stdargs.h} will not work with
4722floating point operands if this option is specified.
4723
4724@item -mfp-arg-in-gregs
4725Use the normal calling convention for floating point arguments. This is
4726the default.
4727
4728@item -mhc-struct-return
4729Return structures of more than one word in memory, rather than in a
4730register. This provides compatibility with the MetaWare HighC (hc)
4731compiler. Use the option @samp{-fpcc-struct-return} for compatibility
4732with the Portable C Compiler (pcc).
4733
4734@item -mnohc-struct-return
4735Return some structures of more than one word in registers, when
4736convenient. This is the default. For compatibility with the
4737IBM-supplied compilers, use the option @samp{-fpcc-struct-return} or the
4738option @samp{-mhc-struct-return}.
4739@end table
4740
4741@node MIPS Options
4742@subsection MIPS Options
4743@cindex MIPS options
4744
4745These @samp{-m} options are defined for the MIPS family of computers:
4746
4747@table @code
4748@item -mcpu=@var{cpu type}
4749Assume the defaults for the machine type @var{cpu type} when scheduling
4750instructions. The choices for @var{cpu type} are @samp{r2000}, @samp{r3000},
4751@samp{r4000}, @samp{r4400}, @samp{r4600}, and @samp{r6000}. While picking a
4752specific @var{cpu type} will schedule things appropriately for that
4753particular chip, the compiler will not generate any code that does not
4754meet level 1 of the MIPS ISA (instruction set architecture) without
4755the @samp{-mips2} or @samp{-mips3} switches being used.
4756
4757@item -mips1
4758Issue instructions from level 1 of the MIPS ISA. This is the default.
4759@samp{r3000} is the default @var{cpu type} at this ISA level.
4760
4761@item -mips2
4762Issue instructions from level 2 of the MIPS ISA (branch likely, square
4763root instructions). @samp{r6000} is the default @var{cpu type} at this
4764ISA level.
4765
4766@item -mips3
4767Issue instructions from level 3 of the MIPS ISA (64 bit instructions).
4768@samp{r4000} is the default @var{cpu type} at this ISA level.
4769This option does not change the sizes of any of the C data types.
4770
3398f47f
MM
4771@item -mips4
4772Issue instructions from level 4 of the MIPS ISA. @samp{r8000} is the
4773default @var{cpu type} at this ISA level.
4774
74291a4b
MM
4775@item -mfp32
4776Assume that 32 32-bit floating point registers are available. This is
4777the default.
4778
4779@item -mfp64
4780Assume that 32 64-bit floating point registers are available. This is
4781the default when the @samp{-mips3} option is used.
4782
4783@item -mgp32
4784Assume that 32 32-bit general purpose registers are available. This is
4785the default.
4786
4787@item -mgp64
4788Assume that 32 64-bit general purpose registers are available. This is
4789the default when the @samp{-mips3} option is used.
4790
4791@item -mint64
4792Types long, int, and pointer are 64 bits. This works only if @samp{-mips3}
4793is also specified.
4794
4795@item -mlong64
4796Types long and pointer are 64 bits, and type int is 32 bits.
4797This works only if @samp{-mips3} is also specified.
4798
3398f47f
MM
4799@itemx -mabi=32
4800@itemx -mabi=n32
4801@itemx -mabi=64
4802@itemx -mabi=eabi
4803Generate code for the indicated ABI.
4804
74291a4b
MM
4805@item -mmips-as
4806Generate code for the MIPS assembler, and invoke @file{mips-tfile} to
4807add normal debug information. This is the default for all
4808platforms except for the OSF/1 reference platform, using the OSF/rose
4809object format. If the either of the @samp{-gstabs} or @samp{-gstabs+}
4810switches are used, the @file{mips-tfile} program will encapsulate the
4811stabs within MIPS ECOFF.
4812
4813@item -mgas
4814Generate code for the GNU assembler. This is the default on the OSF/1
861bb6c1
JL
4815reference platform, using the OSF/rose object format. Also, this is
4816the default if the configure option @samp{--with-gnu-as} is used.
4817
4818@item -msplit-addresses
4819@itemx -mno-split-addresses
4820Generate code to load the high and low parts of address constants separately.
4821This allows @code{gcc} to optimize away redundant loads of the high order
4822bits of addresses. This optimization requires GNU as and GNU ld.
4823This optimization is enabled by default for some embedded targets where
4824GNU as and GNU ld are standard.
74291a4b
MM
4825
4826@item -mrnames
4827@itemx -mno-rnames
4828The @samp{-mrnames} switch says to output code using the MIPS software
4829names for the registers, instead of the hardware names (ie, @var{a0}
4830instead of @var{$4}). The only known assembler that supports this option
4831is the Algorithmics assembler.
4832
4833@item -mgpopt
4834@itemx -mno-gpopt
4835The @samp{-mgpopt} switch says to write all of the data declarations
4836before the instructions in the text section, this allows the MIPS
4837assembler to generate one word memory references instead of using two
4838words for short global or static data items. This is on by default if
4839optimization is selected.
4840
4841@item -mstats
4842@itemx -mno-stats
4843For each non-inline function processed, the @samp{-mstats} switch
4844causes the compiler to emit one line to the standard error file to
4845print statistics about the program (number of registers saved, stack
4846size, etc.).
4847
4848@item -mmemcpy
4849@itemx -mno-memcpy
4850The @samp{-mmemcpy} switch makes all block moves call the appropriate
4851string function (@samp{memcpy} or @samp{bcopy}) instead of possibly
4852generating inline code.
4853
4854@item -mmips-tfile
4855@itemx -mno-mips-tfile
4856The @samp{-mno-mips-tfile} switch causes the compiler not
4857postprocess the object file with the @file{mips-tfile} program,
4858after the MIPS assembler has generated it to add debug support. If
4859@file{mips-tfile} is not run, then no local variables will be
4860available to the debugger. In addition, @file{stage2} and
4861@file{stage3} objects will have the temporary file names passed to the
4862assembler embedded in the object file, which means the objects will
4863not compare the same. The @samp{-mno-mips-tfile} switch should only
4864be used when there are bugs in the @file{mips-tfile} program that
4865prevents compilation.
4866
4867@item -msoft-float
4868Generate output containing library calls for floating point.
4869@strong{Warning:} the requisite libraries are not part of GNU CC.
4870Normally the facilities of the machine's usual C compiler are used, but
4871this can't be done directly in cross-compilation. You must make your
4872own arrangements to provide suitable library functions for
4873cross-compilation.
4874
4875@item -mhard-float
4876Generate output containing floating point instructions. This is the
4877default if you use the unmodified sources.
4878
4879@item -mabicalls
4880@itemx -mno-abicalls
4881Emit (or do not emit) the pseudo operations @samp{.abicalls},
4882@samp{.cpload}, and @samp{.cprestore} that some System V.4 ports use for
4883position independent code.
4884
4885@item -mlong-calls
4886@itemx -mno-long-calls
4887Do all calls with the @samp{JALR} instruction, which requires
4888loading up a function's address into a register before the call.
4889You need to use this switch, if you call outside of the current
4890512 megabyte segment to functions that are not through pointers.
4891
4892@item -mhalf-pic
4893@itemx -mno-half-pic
4894Put pointers to extern references into the data section and load them
4895up, rather than put the references in the text section.
4896
4897@item -membedded-pic
4898@itemx -mno-embedded-pic
69fa83cf
JW
4899Generate PIC code suitable for some embedded systems. All calls are
4900made using PC relative address, and all data is addressed using the $gp
4901register. No more than 65536 bytes of global data may be used. This
4902requires GNU as and GNU ld which do most of the work. This currently
4903only works on targets which use ECOFF; it does not work with ELF.
74291a4b
MM
4904
4905@item -membedded-data
4906@itemx -mno-embedded-data
4907Allocate variables to the read-only data section first if possible, then
4908next in the small data section if possible, otherwise in data. This gives
4909slightly slower code than the default, but reduces the amount of RAM required
4910when executing, and thus may be preferred for some embedded systems.
4911
4912@item -msingle-float
4913@itemx -mdouble-float
4914The @samp{-msingle-float} switch tells gcc to assume that the floating
4915point coprocessor only supports single precision operations, as on the
4916@samp{r4650} chip. The @samp{-mdouble-float} switch permits gcc to use
4917double precision operations. This is the default.
4918
4919@item -mmad
4920@itemx -mno-mad
4921Permit use of the @samp{mad}, @samp{madu} and @samp{mul} instructions,
4922as on the @samp{r4650} chip.
4923
4924@item -m4650
4925Turns on @samp{-msingle-float}, @samp{-mmad}, and, at least for now,
4926@samp{-mcpu=r4650}.
4927
4928@item -EL
4929Compile code for the processor in little endian mode.
4930The requisite libraries are assumed to exist.
4931
4932@item -EB
4933Compile code for the processor in big endian mode.
4934The requisite libraries are assumed to exist.
4935
4936@item -G @var{num}
4937@cindex smaller data references (MIPS)
4938@cindex gp-relative references (MIPS)
4939Put global and static items less than or equal to @var{num} bytes into
4940the small data or bss sections instead of the normal data or bss
4941section. This allows the assembler to emit one word memory reference
4942instructions based on the global pointer (@var{gp} or @var{$28}),
4943instead of the normal two words used. By default, @var{num} is 8 when
4944the MIPS assembler is used, and 0 when the GNU assembler is used. The
4945@samp{-G @var{num}} switch is also passed to the assembler and linker.
4946All modules should be compiled with the same @samp{-G @var{num}}
4947value.
4948
4949@item -nocpp
9ec36da5 4950Tell the MIPS assembler to not run its preprocessor over user
74291a4b
MM
4951assembler files (with a @samp{.s} suffix) when assembling them.
4952@end table
4953
4954@ifset INTERNALS
4955These options are defined by the macro
4956@code{TARGET_SWITCHES} in the machine description. The default for the
4957options is also defined by that macro, which enables you to change the
4958defaults.
4959@end ifset
4960
4961@node i386 Options
4962@subsection Intel 386 Options
4963@cindex i386 Options
4964@cindex Intel 386 Options
4965
4966These @samp{-m} options are defined for the i386 family of computers:
4967
f45ebe47 4968@table @code
a9f3e1a4
JL
4969@item -mcpu=@var{cpu type}
4970Assume the defaults for the machine type @var{cpu type} when scheduling
4971instructions. The choices for @var{cpu type} are: @samp{i386},
4972@samp{i486}, @samp{i586} (@samp{pentium}), @samp{pentium}, @samp{i686}
4973(@samp{pentiumpro}) and @samp{pentiumpro}. While picking a specific
4974@var{cpu type} will schedule things appropriately for that particular
4975chip, the compiler will not generate any code that does not run on the
4976i386 without the @samp{-march=@var{cpu type}} option being used.
4977
4978@item -march=@var{cpu type}
4979Generate instructions for the machine type @var{cpu type}. The choices
4980for @var{cpu type} are: @samp{i386}, @samp{i486}, @samp{pentium}, and
4981@samp{pentiumpro}. Specifying @samp{-march=@var{cpu type}} implies
4982@samp{-mcpu=@var{cpu type}}.
4983
4984@item -m386
4985@itemx -m486
4986@itemx -mpentium
4987@itemx -mpentiumpro
4988Synonyms for -mcpu=i386, -mcpu=i486, -mcpu=pentium, and -mcpu=pentiumpro
4989respectively.
74291a4b
MM
4990
4991@item -mieee-fp
4992@itemx -mno-ieee-fp
4993Control whether or not the compiler uses IEEE floating point
4994comparisons. These handle correctly the case where the result of a
4995comparison is unordered.
4996
4997@item -msoft-float
4998Generate output containing library calls for floating point.
4999@strong{Warning:} the requisite libraries are not part of GNU CC.
5000Normally the facilities of the machine's usual C compiler are used, but
5001this can't be done directly in cross-compilation. You must make your
5002own arrangements to provide suitable library functions for
5003cross-compilation.
5004
5005On machines where a function returns floating point results in the 80387
5006register stack, some floating point opcodes may be emitted even if
5007@samp{-msoft-float} is used.
5008
5009@item -mno-fp-ret-in-387
5010Do not use the FPU registers for return values of functions.
5011
5012The usual calling convention has functions return values of types
5013@code{float} and @code{double} in an FPU register, even if there
5014is no FPU. The idea is that the operating system should emulate
5015an FPU.
5016
5017The option @samp{-mno-fp-ret-in-387} causes such values to be returned
5018in ordinary CPU registers instead.
5019
5020@item -mno-fancy-math-387
5021Some 387 emulators do not support the @code{sin}, @code{cos} and
5022@code{sqrt} instructions for the 387. Specify this option to avoid
5023generating those instructions. This option is the default on FreeBSD.
5024As of revision 2.6.1, these instructions are not generated unless you
5025also use the @samp{-ffast-math} switch.
5026
5027@item -malign-double
5028@itemx -mno-align-double
5029Control whether GNU CC aligns @code{double}, @code{long double}, and
5030@code{long long} variables on a two word boundary or a one word
5031boundary. Aligning @code{double} variables on a two word boundary will
5032produce code that runs somewhat faster on a @samp{Pentium} at the
5033expense of more memory.
5034
5035@strong{Warning:} if you use the @samp{-malign-double} switch,
5036structures containing the above types will be aligned differently than
5037the published application binary interface specifications for the 386.
5038
5039@item -msvr3-shlib
5040@itemx -mno-svr3-shlib
5041Control whether GNU CC places uninitialized locals into @code{bss} or
5042@code{data}. @samp{-msvr3-shlib} places these locals into @code{bss}.
5043These options are meaningful only on System V Release 3.
5044
5045@item -mno-wide-multiply
5046@itemx -mwide-multiply
5047Control whether GNU CC uses the @code{mul} and @code{imul} that produce
504864 bit results in @code{eax:edx} from 32 bit operands to do @code{long
5049long} multiplies and 32-bit division by constants.
5050
5051@item -mrtd
5052Use a different function-calling convention, in which functions that
5053take a fixed number of arguments return with the @code{ret} @var{num}
5054instruction, which pops their arguments while returning. This saves one
5055instruction in the caller since there is no need to pop the arguments
5056there.
5057
5058You can specify that an individual function is called with this calling
5059sequence with the function attribute @samp{stdcall}. You can also
5060override the @samp{-mrtd} option by using the function attribute
5061@samp{cdecl}. @xref{Function Attributes}
5062
5063@strong{Warning:} this calling convention is incompatible with the one
5064normally used on Unix, so you cannot use it if you need to call
5065libraries compiled with the Unix compiler.
5066
5067Also, you must provide function prototypes for all functions that
5068take variable numbers of arguments (including @code{printf});
5069otherwise incorrect code will be generated for calls to those
5070functions.
5071
5072In addition, seriously incorrect code will result if you call a
5073function with too many arguments. (Normally, extra arguments are
5074harmlessly ignored.)
5075
5076@item -mreg-alloc=@var{regs}
5077Control the default allocation order of integer registers. The
5078string @var{regs} is a series of letters specifying a register. The
5079supported letters are: @code{a} allocate EAX; @code{b} allocate EBX;
5080@code{c} allocate ECX; @code{d} allocate EDX; @code{S} allocate ESI;
5081@code{D} allocate EDI; @code{B} allocate EBP.
5082
5083@item -mregparm=@var{num}
5084Control how many registers are used to pass integer arguments. By
5085default, no registers are used to pass arguments, and at most 3
5086registers can be used. You can control this behavior for a specific
5087function by using the function attribute @samp{regparm}. @xref{Function Attributes}
5088
5089@strong{Warning:} if you use this switch, and
5090@var{num} is nonzero, then you must build all modules with the same
5091value, including any libraries. This includes the system libraries and
5092startup modules.
5093
5094@item -malign-loops=@var{num}
5095Align loops to a 2 raised to a @var{num} byte boundary. If
9e423e6d
JW
5096@samp{-malign-loops} is not specified, the default is 2 unless
5097gas 2.8 (or later) is being used in which case the default is
5098to align the loop on a 16 byte boundary if it is less than 8
5099bytes away.
74291a4b
MM
5100
5101@item -malign-jumps=@var{num}
5102Align instructions that are only jumped to to a 2 raised to a @var{num}
5103byte boundary. If @samp{-malign-jumps} is not specified, the default is
9e423e6d
JW
51042 if optimizing for a 386, and 4 if optimizing for a 486 unless
5105gas 2.8 (or later) is being used in which case the default is
5106to align the instruction on a 16 byte boundary if it is less
5107than 8 bytes away.
74291a4b
MM
5108
5109@item -malign-functions=@var{num}
5110Align the start of functions to a 2 raised to @var{num} byte boundary.
6d4312dd 5111If @samp{-malign-functions} is not specified, the default is 2 if optimizing
74291a4b
MM
5112for a 386, and 4 if optimizing for a 486.
5113@end table
5114
5115@node HPPA Options
5116@subsection HPPA Options
5117@cindex HPPA Options
5118
5119These @samp{-m} options are defined for the HPPA family of computers:
5120
5121@table @code
5122@item -mpa-risc-1-0
5123Generate code for a PA 1.0 processor.
5124
5125@item -mpa-risc-1-1
5126Generate code for a PA 1.1 processor.
5127
861bb6c1
JL
5128@item -mbig-switch
5129Generate code suitable for big switch tables. Use this option only if
5130the assembler/linker complain about out of range branches within a switch
5131table.
5132
74291a4b
MM
5133@item -mjump-in-delay
5134Fill delay slots of function calls with unconditional jump instructions
5135by modifying the return pointer for the function call to be the target
5136of the conditional jump.
5137
5138@item -mdisable-fpregs
5139Prevent floating point registers from being used in any manner. This is
5140necessary for compiling kernels which perform lazy context switching of
5141floating point registers. If you use this option and attempt to perform
5142floating point operations, the compiler will abort.
5143
5144@item -mdisable-indexing
5145Prevent the compiler from using indexing address modes. This avoids some
5146rather obscure problems when compiling MIG generated code under MACH.
5147
5148@item -mno-space-regs
5149Generate code that assumes the target has no space registers. This allows
5150GCC to generate faster indirect calls and use unscaled index address modes.
5151
5152Such code is suitable for level 0 PA systems and kernels.
5153
5154@item -mfast-indirect-calls
5155Generate code that assumes calls never cross space boundaries. This
5156allows GCC to emit code which performs faster indirect calls.
5157
5158This option will not work in the presense of shared libraries or nested
5159functions.
5160
5161@item -mspace
5162Optimize for space rather than execution time. Currently this only
5163enables out of line function prologues and epilogues. This option is
956d6950 5164incompatible with PIC code generation and profiling.
74291a4b
MM
5165
5166@item -mlong-load-store
5167Generate 3-instruction load and store sequences as sometimes required by
5168the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
5169the HP compilers.
5170
5171@item -mportable-runtime
5172Use the portable calling conventions proposed by HP for ELF systems.
5173
5174@item -mgas
5175Enable the use of assembler directives only GAS understands.
5176
5177@item -mschedule=@var{cpu type}
5178Schedule code according to the constraints for the machine type
5179@var{cpu type}. The choices for @var{cpu type} are @samp{700} for
9dbb90b3 51807@var{n}0 machines, @samp{7100} for 7@var{n}5 machines, and @samp{7100LC}
74291a4b
MM
5181for 7@var{n}2 machines. @samp{7100} is the default for @var{cpu type}.
5182
5183Note the @samp{7100LC} scheduling information is incomplete and using
5184@samp{7100LC} often leads to bad schedules. For now it's probably best
5185to use @samp{7100} instead of @samp{7100LC} for the 7@var{n}2 machines.
5186
5187@item -mlinker-opt
5188Enable the optimization pass in the HPUX linker. Note this makes symbolic
5189debugging impossible. It also triggers a bug in the HPUX 8 and HPUX 9 linkers
5190in which they give bogus error messages when linking some programs.
5191
5192@item -msoft-float
5193Generate output containing library calls for floating point.
5194@strong{Warning:} the requisite libraries are not available for all HPPA
5195targets. Normally the facilities of the machine's usual C compiler are
5196used, but this cannot be done directly in cross-compilation. You must make
5197your own arrangements to provide suitable library functions for
5198cross-compilation. The embedded target @samp{hppa1.1-*-pro}
5199does provide software floating point support.
5200
5201@samp{-msoft-float} changes the calling convention in the output file;
5202therefore, it is only useful if you compile @emph{all} of a program with
5203this option. In particular, you need to compile @file{libgcc.a}, the
5204library that comes with GNU CC, with @samp{-msoft-float} in order for
5205this to work.
5206@end table
5207
5208@node Intel 960 Options
5209@subsection Intel 960 Options
5210
5211These @samp{-m} options are defined for the Intel 960 implementations:
5212
5213@table @code
5214@item -m@var{cpu type}
5215Assume the defaults for the machine type @var{cpu type} for some of
5216the other options, including instruction scheduling, floating point
5217support, and addressing modes. The choices for @var{cpu type} are
5218@samp{ka}, @samp{kb}, @samp{mc}, @samp{ca}, @samp{cf},
5219@samp{sa}, and @samp{sb}.
5220The default is
5221@samp{kb}.
5222
5223@item -mnumerics
5224@itemx -msoft-float
5225The @samp{-mnumerics} option indicates that the processor does support
5226floating-point instructions. The @samp{-msoft-float} option indicates
5227that floating-point support should not be assumed.
5228
5229@item -mleaf-procedures
5230@itemx -mno-leaf-procedures
5231Do (or do not) attempt to alter leaf procedures to be callable with the
5232@code{bal} instruction as well as @code{call}. This will result in more
5233efficient code for explicit calls when the @code{bal} instruction can be
5234substituted by the assembler or linker, but less efficient code in other
5235cases, such as calls via function pointers, or using a linker that doesn't
5236support this optimization.
5237
5238@item -mtail-call
5239@itemx -mno-tail-call
5240Do (or do not) make additional attempts (beyond those of the
5241machine-independent portions of the compiler) to optimize tail-recursive
5242calls into branches. You may not want to do this because the detection of
5243cases where this is not valid is not totally complete. The default is
5244@samp{-mno-tail-call}.
5245
5246@item -mcomplex-addr
5247@itemx -mno-complex-addr
5248Assume (or do not assume) that the use of a complex addressing mode is a
5249win on this implementation of the i960. Complex addressing modes may not
5250be worthwhile on the K-series, but they definitely are on the C-series.
5251The default is currently @samp{-mcomplex-addr} for all processors except
5252the CB and CC.
5253
5254@item -mcode-align
5255@itemx -mno-code-align
5256Align code to 8-byte boundaries for faster fetching (or don't bother).
5257Currently turned on by default for C-series implementations only.
5258
5259@ignore
5260@item -mclean-linkage
5261@itemx -mno-clean-linkage
5262These options are not fully implemented.
5263@end ignore
5264
5265@item -mic-compat
5266@itemx -mic2.0-compat
5267@itemx -mic3.0-compat
5268Enable compatibility with iC960 v2.0 or v3.0.
5269
5270@item -masm-compat
5271@itemx -mintel-asm
5272Enable compatibility with the iC960 assembler.
5273
5274@item -mstrict-align
5275@itemx -mno-strict-align
5276Do not permit (do permit) unaligned accesses.
5277
5278@item -mold-align
5279Enable structure-alignment compatibility with Intel's gcc release version
861bb6c1 52801.3 (based on gcc 1.37). This option implies @samp{-mstrict-align}.
eaa4b44c
VM
5281
5282@item -mlong-double-64
5283Implement type @samp{long double} as 64-bit floating point numbers.
5284Without the option @samp{long double} is implemented by 80-bit
5285floating point numbers. The only reason we have it because there is
5286no 128-bit @samp{long double} support in @samp{fp-bit.c} yet. So it
5287is only useful for people using soft-float targets. Otherwise, we
5288should recommend against use of it.
5289
74291a4b
MM
5290@end table
5291
5292@node DEC Alpha Options
5293@subsection DEC Alpha Options
5294
5295These @samp{-m} options are defined for the DEC Alpha implementations:
5296
5297@table @code
5298@item -mno-soft-float
5299@itemx -msoft-float
5300Use (do not use) the hardware floating-point instructions for
5301floating-point operations. When @code{-msoft-float} is specified,
5302functions in @file{libgcc1.c} will be used to perform floating-point
5303operations. Unless they are replaced by routines that emulate the
5304floating-point operations, or compiled in such a way as to call such
5305emulations routines, these routines will issue floating-point
5306operations. If you are compiling for an Alpha without floating-point
5307operations, you must ensure that the library is built so as not to call
5308them.
5309
5310Note that Alpha implementations without floating-point operations are
5311required to have floating-point registers.
5312
5313@item -mfp-reg
5314@itemx -mno-fp-regs
5315Generate code that uses (does not use) the floating-point register set.
5316@code{-mno-fp-regs} implies @code{-msoft-float}. If the floating-point
5317register set is not used, floating point operands are passed in integer
5318registers as if they were integers and floating-point results are passed
5319in $0 instead of $f0. This is a non-standard calling sequence, so any
5320function with a floating-point argument or return value called by code
5321compiled with @code{-mno-fp-regs} must also be compiled with that
5322option.
5323
5324A typical use of this option is building a kernel that does not use,
5325and hence need not save and restore, any floating-point registers.
5326
5327@item -mieee
5328The Alpha architecture implements floating-point hardware optimized for
5329maximum performance. It is mostly compliant with the IEEE floating
5330point standard. However, for full compliance, software assistance is
5331required. This option generates code fully IEEE compliant code
5332@emph{except} that the @var{inexact flag} is not maintained (see below).
5333If this option is turned on, the CPP macro @code{_IEEE_FP} is defined
5334during compilation. The option is a shorthand for: @samp{-D_IEEE_FP
5335-mfp-trap-mode=su -mtrap-precision=i -mieee-conformant}. The resulting
5336code is less efficient but is able to correctly support denormalized
5337numbers and exceptional IEEE values such as not-a-number and plus/minus
5338infinity. Other Alpha compilers call this option
5339@code{-ieee_with_no_inexact}.
5340
5341@item -mieee-with-inexact
5342@c overfull hbox here --bob 22 jul96
5343@c original text between ignore ... end ignore
5344@ignore
5345This is like @samp{-mieee} except the generated code also maintains the
5346IEEE @var{inexact flag}. Turning on this option causes the generated
5347code to implement fully-compliant IEEE math. The option is a shorthand
5348for @samp{-D_IEEE_FP -D_IEEE_FP_INEXACT} plus @samp{-mieee-conformant},
5349@samp{-mfp-trap-mode=sui}, and @samp{-mtrap-precision=i}. On some Alpha
5350implementations the resulting code may execute significantly slower than
5351the code generated by default. Since there is very little code that
5352depends on the @var{inexact flag}, you should normally not specify this
5353option. Other Alpha compilers call this option
5354@samp{-ieee_with_inexact}.
5355@end ignore
5356@c changed paragraph
5357This is like @samp{-mieee} except the generated code also maintains the
5358IEEE @var{inexact flag}. Turning on this option causes the generated
5359code to implement fully-compliant IEEE math. The option is a shorthand
5360for @samp{-D_IEEE_FP -D_IEEE_FP_INEXACT} plus the three following:
5361@samp{-mieee-conformant},
5362@samp{-mfp-trap-mode=sui},
5363and @samp{-mtrap-precision=i}.
5364On some Alpha implementations the resulting code may execute
5365significantly slower than the code generated by default. Since there
5366is very little code that depends on the @var{inexact flag}, you should
5367normally not specify this option. Other Alpha compilers call this
5368option @samp{-ieee_with_inexact}.
5369@c end changes to prevent overfull hboxes
5370
5371@item -mfp-trap-mode=@var{trap mode}
5372This option controls what floating-point related traps are enabled.
5373Other Alpha compilers call this option @samp{-fptm }@var{trap mode}.
5374The trap mode can be set to one of four values:
5375
5376@table @samp
5377@item n
5378This is the default (normal) setting. The only traps that are enabled
5379are the ones that cannot be disabled in software (e.g., division by zero
5380trap).
5381
5382@item u
5383In addition to the traps enabled by @samp{n}, underflow traps are enabled
5384as well.
5385
5386@item su
5387Like @samp{su}, but the instructions are marked to be safe for software
5388completion (see Alpha architecture manual for details).
5389
5390@item sui
5391Like @samp{su}, but inexact traps are enabled as well.
5392@end table
5393
5394@item -mfp-rounding-mode=@var{rounding mode}
5395Selects the IEEE rounding mode. Other Alpha compilers call this option
5396@samp{-fprm }@var{rounding mode}. The @var{rounding mode} can be one
5397of:
5398
5399@table @samp
5400@item n
5401Normal IEEE rounding mode. Floating point numbers are rounded towards
5402the nearest machine number or towards the even machine number in case
5403of a tie.
5404
5405@item m
5406Round towards minus infinity.
5407
5408@item c
5409Chopped rounding mode. Floating point numbers are rounded towards zero.
5410
5411@item d
5412Dynamic rounding mode. A field in the floating point control register
5413(@var{fpcr}, see Alpha architecture reference manual) controls the
5414rounding mode in effect. The C library initializes this register for
5415rounding towards plus infinity. Thus, unless your program modifies the
5416@var{fpcr}, @samp{d} corresponds to round towards plus infinity.@end table
5417
5418@item -mtrap-precision=@var{trap precision}
5419In the Alpha architecture, floating point traps are imprecise. This
5420means without software assistance it is impossible to recover from a
5421floating trap and program execution normally needs to be terminated.
5422GNU CC can generate code that can assist operating system trap handlers
5423in determining the exact location that caused a floating point trap.
5424Depending on the requirements of an application, different levels of
5425precisions can be selected:
5426
5427@table @samp
5428@item p
5429Program precision. This option is the default and means a trap handler
5430can only identify which program caused a floating point exception.
5431
5432@item f
5433Function precision. The trap handler can determine the function that
5434caused a floating point exception.
5435
5436@item i
5437Instruction precision. The trap handler can determine the exact
5438instruction that caused a floating point exception.
5439@end table
5440
5441Other Alpha compilers provide the equivalent options called
5442@samp{-scope_safe} and @samp{-resumption_safe}.
5443
5444@item -mieee-conformant
5445This option marks the generated code as IEEE conformant. You must not
5446use this option unless you also specify @samp{-mtrap-precision=i} and either
5447@samp{-mfp-trap-mode=su} or @samp{-mfp-trap-mode=sui}. Its only effect
5448is to emit the line @samp{.eflag 48} in the function prologue of the
5449generated assembly file. Under DEC Unix, this has the effect that
5450IEEE-conformant math library routines will be linked in.
5451
5452@item -mbuild-constants
5453Normally GNU CC examines a 32- or 64-bit integer constant to
5454see if it can construct it from smaller constants in two or three
5455instructions. If it cannot, it will output the constant as a literal and
956d6950 5456generate code to load it from the data segment at runtime.
74291a4b
MM
5457
5458Use this option to require GNU CC to construct @emph{all} integer constants
5459using code, even if it takes more instructions (the maximum is six).
5460
5461You would typically use this option to build a shared library dynamic
5462loader. Itself a shared library, it must relocate itself in memory
5463before it can find the variables and constants in its own data segment.
956d6950
JL
5464
5465@item -malpha-as
5466@itemx -mgas
5467Select whether to generate code to be assembled by the vendor-supplied
5468assembler (@samp{-malpha-as}) or by the GNU assembler @samp{-mgas}.
5469
5470@item -mbwx
5471@itemx -mno-bwx
5472@itemx -mcix
5473@itemx -mno-cix
5474@itemx -mmax
5475@itemx -mno-max
5476Indicate whether GNU CC should generate code to use the optional BWX,
5477CIX, and MAX instruction sets. The default is to use the instruction sets
5478supported by the CPU type specified via @samp{-mcpu=} option or that
5479of the CPU on which GNU CC was built if none was specified.
5480
956d6950
JL
5481@item -mcpu=@var{cpu_type}
5482Set the instruction set, register set, and instruction scheduling
5483parameters for machine type @var{cpu_type}. You can specify either the
5484@samp{EV} style name or the corresponding chip number. GNU CC
5485supports scheduling parameters for the EV4 and EV5 family of processors
5486and will choose the default values for the instruction set from
5487the processor you specify. If you do not specify a processor type,
5488GNU CC will default to the processor on which the compiler was built.
5489
5490Supported values for @var{cpu_type} are
5491
5492@table @samp
5493@item ev4
5494@itemx 21064
5495Schedules as an EV4 and has no instruction set extensions.
5496
5497@item ev5
5498@itemx 21164
5499Schedules as an EV5 and has no instruction set extensions.
5500
5501@item ev56
5502@itemx 21164a
5503Schedules as an EV5 and supports the BWX extension.
5504
5505@item pca56
4f69985c 5506@itemx 21164pc
956d6950
JL
5507@itemx 21164PC
5508Schedules as an EV5 and supports the BWX and MAX extensions.
5509
5510@item ev6
5511@itemx 21264
5512Schedules as an EV5 (until Digital releases the scheduling parameters
5513for the EV6) and supports the BWX, CIX, and MAX extensions.
4f69985c
RH
5514@end table
5515
5516@item -mmemory-latency=@var{time}
5517Sets the latency the scheduler should assume for typical memory
5518references as seen by the application. This number is highly
5519dependant on the memory access patterns used by the application
5520and the size of the external cache on the machine.
5521
5522Valid options for @var{time} are
5523
5524@table @samp
5525@item @var{number}
5526A decimal number representing clock cycles.
5527
5528@item L1
5529@itemx L2
5530@itemx L3
5531@itemx main
5532The compiler contains estimates of the number of clock cycles for
5533``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
5534(also called Dcache, Scache, and Bcache), as well as to main memory.
5535Note that L3 is only valid for EV5.
5536
956d6950 5537@end table
74291a4b
MM
5538@end table
5539
5540@node Clipper Options
5541@subsection Clipper Options
5542
5543These @samp{-m} options are defined for the Clipper implementations:
5544
5545@table @code
5546@item -mc300
5547Produce code for a C300 Clipper processor. This is the default.
5548
5549@itemx -mc400
5550Produce code for a C400 Clipper processor i.e. use floating point
5551registers f8..f15.
5552@end table
5553
5554@node H8/300 Options
5555@subsection H8/300 Options
5556
5557These @samp{-m} options are defined for the H8/300 implementations:
5558
5559@table @code
5560@item -mrelax
5561Shorten some address references at link time, when possible; uses the
5562linker option @samp{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
5563ld.info, Using ld}, for a fuller description.
5564
5565@item -mh
5566Generate code for the H8/300H.
5567
dcb9d1f0
JL
5568@item -ms
5569Generate code for the H8/S.
5570
74291a4b
MM
5571@item -mint32
5572Make @code{int} data 32 bits by default.
5573
5574@item -malign-300
5575On the h8/300h, use the same alignment rules as for the h8/300.
5576The default for the h8/300h is to align longs and floats on 4 byte boundaries.
5577@samp{-malign-300} causes them to be aligned on 2 byte boundaries.
5578This option has no effect on the h8/300.
5579@end table
5580
5581@node SH Options
5582@subsection SH Options
5583
5584These @samp{-m} options are defined for the SH implementations:
5585
5586@table @code
5587@item -m1
5588Generate code for the SH1.
5589
5590@item -m2
5591Generate code for the SH2.
5592
5593@item -m3
5594Generate code for the SH3.
5595
5596@item -m3e
5597Generate code for the SH3e.
5598
5599@item -mb
5600Compile code for the processor in big endian mode.
5601
5602@item -ml
5603Compile code for the processor in little endian mode.
5604
3d5a0820
R
5605@item -mdalign
5606Align doubles at 64 bit boundaries. Note that this changes the calling
5607conventions, and thus some functions from the standard C library will
5608not work unless you recompile it first with -mdalign.
5609
74291a4b
MM
5610@item -mrelax
5611Shorten some address references at link time, when possible; uses the
5612linker option @samp{-relax}.
5613@end table
5614
5615@node System V Options
5616@subsection Options for System V
5617
5618These additional options are available on System V Release 4 for
5619compatibility with other compilers on those systems:
5620
5621@table @code
5622@item -G
5623Create a shared object.
5624It is recommended that @samp{-symbolic} or @samp{-shared} be used instead.
5625
5626@item -Qy
5627Identify the versions of each tool used by the compiler, in a
5628@code{.ident} assembler directive in the output.
5629
5630@item -Qn
5631Refrain from adding @code{.ident} directives to the output file (this is
5632the default).
5633
5634@item -YP,@var{dirs}
5635Search the directories @var{dirs}, and no others, for libraries
5636specified with @samp{-l}.
5637
5638@item -Ym,@var{dir}
5639Look in the directory @var{dir} to find the M4 preprocessor.
5640The assembler uses this option.
5641@c This is supposed to go with a -Yd for predefined M4 macro files, but
5642@c the generic assembler that comes with Solaris takes just -Ym.
5643@end table
5644
f84271d9
JL
5645@node V850 Options
5646@subsection V850 Options
5647@cindex V850 Options
5648
5649These @samp{-m} options are defined for V850 implementations:
5650
5651@table @code
5652@item -mlong-calls
5653@itemx -mno-long-calls
5654Treat all calls as being far away (near). If calls are assumed to be
5655far away, the compiler will always load the functions address up into a
5656register, and call indirect through the pointer.
5657
5658@item -mno-ep
bd762873 5659@itemx -mep
f84271d9
JL
5660Do not optimize (do optimize) basic blocks that use the same index
5661pointer 4 or more times to copy pointer into the @code{ep} register, and
5662use the shorter @code{sld} and @code{sst} instructions. The @samp{-mep}
5663option is on by default if you optimize.
5664
5665@item -mno-prolog-function
5666@itemx -mprolog-function
5667Do not use (do use) external functions to save and restore registers at
5668the prolog and epilog of a function. The external functions are slower,
5669but use less code space if more than one function saves the same number
5670of registers. The @samp{-mprolog-function} option is on by default if
5671you optimize.
5672
5673@item -mspace
5674Try to make the code as small as possible. At present, this just turns
5675on the @samp{-mep} and @samp{-mprolog-function} options.
5676
5677@item -mtda=@var{n}
5678Put static or global variables whose size is @var{n} bytes or less into
5679the tiny data area that register @code{ep} points to. The tiny data
5680area can hold up to 256 bytes in total (128 bytes for byte references).
5681
5682@item -msda=@var{n}
5683Put static or global variables whose size is @var{n} bytes or less into
5684the small data area that register @code{gp} points to. The small data
5685area can hold up to 64 kilobytes.
5686
5687@item -mzda=@var{n}
5688Put static or global variables whose size is @var{n} bytes or less into
5689the first 32 kilobytes of memory.
e9a25f70 5690
48f0be1b
SC
5691@item -mv850
5692Specify that the target processor is the V850.
5693
e9a25f70
JL
5694@item -mbig-switch
5695Generate code suitable for big switch tables. Use this option only if
5696the assembler/linker complain about out of range branches within a switch
5697table.
f84271d9
JL
5698@end table
5699
56b2d7a7
JL
5700@node ARC Options
5701@subsection ARC Options
5702@cindex ARC Options
5703
5704These options are defined for ARC implementations:
5705
5706@table @code
5707@item -EL
5708Compile code for little endian mode. This is the default.
5709
5710@item -EB
5711Compile code for big endian mode.
5712
5713@item -mmangle-cpu
5714Prepend the name of the cpu to all public symbol names.
5715In multiple-processor systems, there are many ARC variants with different
5716instruction and register set characteristics. This flag prevents code
5717compiled for one cpu to be linked with code compiled for another.
5718No facility exists for handling variants that are "almost identical".
5719This is an all or nothing option.
5720
5721@item -mcpu=@var{cpu}
5722Compile code for ARC variant @var{cpu}.
5723Which variants are supported depend on the configuration.
5724All variants support @samp{-mcpu=base}, this is the default.
5725
5726@item -mtext=@var{text section}
5727@item -mdata=@var{data section}
5728@item -mrodata=@var{readonly data section}
5729Put functions, data, and readonly data in @var{text section},
5730@var{data section}, and @var{readonly data section} respectively
5731by default. This can be overridden with the @code{section} attribute.
5732@xref{Variable Attributes}
5733
5734@end table
5735
83575957
ID
5736@node NS32K Options
5737@subsection NS32K Options
5738@cindex NS32K options
5739
5740These are the @samp{-m} options defined for the 32000 series. The default
5741values for these options depends on which style of 32000 was selected when
5742the compiler was configured; the defaults for the most common choices are
5743given below.
5744
5745@table @code
5746@item -m32032
5747@itemx -m32032
5748Generate output for a 32032. This is the default
5749when the compiler is configured for 32032 and 32016 based systems.
5750
5751@item -m32332
5752@itemx -m32332
5753Generate output for a 32332. This is the default
5754when the compiler is configured for 32332-based systems.
5755
5756@item -m32532
5757@itemx -m32532
5758Generate output for a 32532. This is the default
5759when the compiler is configured for 32532-based systems.
5760
5761@item -m32081
5762Generate output containing 32081 instructions for floating point.
5763This is the default for all systems.
5764
5765@item -m32381
5766Generate output containing 32381 instructions for floating point. This
5767also implies @samp{-m32081}. The 32381 is only compatible with the 32332
5768and 32532 cpus. This is the default for the pc532-netbsd configuration.
5769
5770@item -mmulti-add
5771Try and generate multiply-add floating point instructions @code{polyF}
5772and @code{dotF}. This option is only available if the @samp{-m32381}
5773option is in effect. Using these instructions requires changes to to
5774register allocation which generally has a negative impact on
5775performance. This option should only be enabled when compiling code
5776particularly likely to make heavy use of multiply-add instructions.
5777
5778@item -mnomulti-add
5779Do not try and generate multiply-add floating point instructions
5780@code{polyF} and @code{dotF}. This is the default on all platforms.
5781
5782@item -msoft-float
5783Generate output containing library calls for floating point.
5784@strong{Warning:} the requisite libraries may not be available.
5785
5786@item -mnobitfield
5787Do not use the bit-field instructions. On some machines it is faster to
5788use shifting and masking operations. This is the default for the pc532.
5789
5790@item -mbitfield
5791Do use the bit-field instructions. This is the default for all platforms
5792except the pc532.
5793
5794@item -mrtd
5795Use a different function-calling convention, in which functions
5796that take a fixed number of arguments return pop their
5797arguments on return with the @code{ret} instruction.
5798
5799This calling convention is incompatible with the one normally
5800used on Unix, so you cannot use it if you need to call libraries
5801compiled with the Unix compiler.
5802
5803Also, you must provide function prototypes for all functions that
5804take variable numbers of arguments (including @code{printf});
5805otherwise incorrect code will be generated for calls to those
5806functions.
5807
5808In addition, seriously incorrect code will result if you call a
5809function with too many arguments. (Normally, extra arguments are
5810harmlessly ignored.)
5811
5812This option takes its name from the 680x0 @code{rtd} instruction.
5813
5814
5815@item -mregparam
5816Use a different function-calling convention where the first two arguments
5817are passed in registers.
5818
5819This calling convention is incompatible with the one normally
5820used on Unix, so you cannot use it if you need to call libraries
5821compiled with the Unix compiler.
5822
5823@item -mnoregparam
5824Do not pass any arguments in registers. This is the default for all
5825targets.
5826
5827@item -msb
5828It is OK to use the sb as an index register which is always loaded with
5829zero. This is the default for the pc532-netbsd target.
5830
5831@item -mnosb
5832The sb register is not available for use or has not been initialized to
5833zero by the run time system. This is the default for all targets except
5834the pc532-netbsd. It is also implied whenever @samp{-mhimem} or
5835@samp{-fpic} is set.
5836
5837@item -mhimem
5838Many ns32000 series addressing modes use displacements of up to 512MB.
5839If an address is above 512MB then displacements from zero can not be used.
5840This option causes code to be generated which can be loaded above 512MB.
5841This may be useful for operating systems or ROM code.
5842
5843@item -mnohimem
5844Assume code will be loaded in the first 512MB of virtual address space.
5845This is the default for all platforms.
5846
5847
5848@end table
5849
5850
56b2d7a7 5851
74291a4b
MM
5852@node Code Gen Options
5853@section Options for Code Generation Conventions
5854@cindex code generation conventions
5855@cindex options, code generation
5856@cindex run-time options
5857
5858These machine-independent options control the interface conventions
5859used in code generation.
5860
5861Most of them have both positive and negative forms; the negative form
5862of @samp{-ffoo} would be @samp{-fno-foo}. In the table below, only
5863one of the forms is listed---the one which is not the default. You
5864can figure out the other form by either removing @samp{no-} or adding
5865it.
5866
5867@table @code
956d6950 5868@item -fexceptions
89ed4e9d
AM
5869Enable exception handling. Generates extra code needed to propagate
5870exceptions. For some targets, this implies generation of frame unwind
5871information for all functions. This can produce significant data size
5872overhead, although it does not affect execution.
5873If you do not specify this option, it is enabled by
5874default for languages like C++ which normally require exception handling,
956d6950
JL
5875and disabled for languages like C that do not normally require it.
5876However, when compiling C code that needs to interoperate properly with
5877exception handlers written in C++, you may need to enable this option.
5878You may also wish to disable this option is you are compiling older C++
5879programs that don't use exception handling.
5880
74291a4b
MM
5881@item -fpcc-struct-return
5882Return ``short'' @code{struct} and @code{union} values in memory like
5883longer ones, rather than in registers. This convention is less
5884efficient, but it has the advantage of allowing intercallability between
5885GNU CC-compiled files and files compiled with other compilers.
5886
5887The precise convention for returning structures in memory depends
5888on the target configuration macros.
5889
5890Short structures and unions are those whose size and alignment match
5891that of some integer type.
5892
5893@item -freg-struct-return
5894Use the convention that @code{struct} and @code{union} values are
5895returned in registers when possible. This is more efficient for small
5896structures than @samp{-fpcc-struct-return}.
5897
5898If you specify neither @samp{-fpcc-struct-return} nor its contrary
5899@samp{-freg-struct-return}, GNU CC defaults to whichever convention is
5900standard for the target. If there is no standard convention, GNU CC
5901defaults to @samp{-fpcc-struct-return}, except on targets where GNU CC
5902is the principal compiler. In those cases, we can choose the standard,
5903and we chose the more efficient register return alternative.
5904
5905@item -fshort-enums
5906Allocate to an @code{enum} type only as many bytes as it needs for the
5907declared range of possible values. Specifically, the @code{enum} type
5908will be equivalent to the smallest integer type which has enough room.
5909
5910@item -fshort-double
5911Use the same size for @code{double} as for @code{float}.
5912
5913@item -fshared-data
5914Requests that the data and non-@code{const} variables of this
5915compilation be shared data rather than private data. The distinction
5916makes sense only on certain operating systems, where shared data is
5917shared between processes running the same program, while private data
5918exists in one copy per process.
5919
5920@item -fno-common
5921Allocate even uninitialized global variables in the bss section of the
5922object file, rather than generating them as common blocks. This has the
5923effect that if the same variable is declared (without @code{extern}) in
5924two different compilations, you will get an error when you link them.
5925The only reason this might be useful is if you wish to verify that the
5926program will work on other systems which always work this way.
5927
5928@item -fno-ident
5929Ignore the @samp{#ident} directive.
5930
5931@item -fno-gnu-linker
5932Do not output global initializations (such as C++ constructors and
5933destructors) in the form used by the GNU linker (on systems where the GNU
5934linker is the standard method of handling them). Use this option when
5935you want to use a non-GNU linker, which also requires using the
5936@code{collect2} program to make sure the system linker includes
5937constructors and destructors. (@code{collect2} is included in the GNU CC
5938distribution.) For systems which @emph{must} use @code{collect2}, the
5939compiler driver @code{gcc} is configured to do this automatically.
5940
5941@item -finhibit-size-directive
5942Don't output a @code{.size} assembler directive, or anything else that
5943would cause trouble if the function is split in the middle, and the
5944two halves are placed at locations far apart in memory. This option is
5945used when compiling @file{crtstuff.c}; you should not need to use it
5946for anything else.
5947
5948@item -fverbose-asm
5949Put extra commentary information in the generated assembly code to
5950make it more readable. This option is generally only of use to those
5951who actually need to read the generated assembly code (perhaps while
5952debugging the compiler itself).
5953
c85f7c16 5954@samp{-fno-verbose-asm}, the default, causes the
74291a4b
MM
5955extra information to be omitted and is useful when comparing two assembler
5956files.
5957
5958@item -fvolatile
5959Consider all memory references through pointers to be volatile.
5960
5961@item -fvolatile-global
5962Consider all memory references to extern and global data items to
ab87f8c8
JL
5963be volatile. GNU CC does not consider static data items to be volatile
5964because of this switch.
5965
5966@item -fvolatile-static
5967Consider all memory references to static data to be volatile.
74291a4b
MM
5968
5969@item -fpic
5970@cindex global offset table
5971@cindex PIC
5972Generate position-independent code (PIC) suitable for use in a shared
5973library, if supported for the target machine. Such code accesses all
861bb6c1
JL
5974constant addresses through a global offset table (GOT). The dynamic
5975loader resolves the GOT entries when the program starts (the dynamic
5976loader is not part of GNU CC; it is part of the operating system). If
5977the GOT size for the linked executable exceeds a machine-specific
5978maximum size, you get an error message from the linker indicating that
5979@samp{-fpic} does not work; in that case, recompile with @samp{-fPIC}
5980instead. (These maximums are 16k on the m88k, 8k on the Sparc, and 32k
5981on the m68k and RS/6000. The 386 has no such limit.)
74291a4b
MM
5982
5983Position-independent code requires special support, and therefore works
5984only on certain machines. For the 386, GNU CC supports PIC for System V
5985but not for the Sun 386i. Code generated for the IBM RS/6000 is always
5986position-independent.
5987
74291a4b
MM
5988@item -fPIC
5989If supported for the target machine, emit position-independent code,
5990suitable for dynamic linking and avoiding any limit on the size of the
5991global offset table. This option makes a difference on the m68k, m88k,
5992and the Sparc.
5993
5994Position-independent code requires special support, and therefore works
5995only on certain machines.
5996
5997@item -ffixed-@var{reg}
5998Treat the register named @var{reg} as a fixed register; generated code
5999should never refer to it (except perhaps as a stack pointer, frame
6000pointer or in some other fixed role).
6001
6002@var{reg} must be the name of a register. The register names accepted
6003are machine-specific and are defined in the @code{REGISTER_NAMES}
6004macro in the machine description macro file.
6005
6006This flag does not have a negative form, because it specifies a
6007three-way choice.
6008
6009@item -fcall-used-@var{reg}
956d6950 6010Treat the register named @var{reg} as an allocable register that is
74291a4b
MM
6011clobbered by function calls. It may be allocated for temporaries or
6012variables that do not live across a call. Functions compiled this way
6013will not save and restore the register @var{reg}.
6014
cb2fdc84
GRK
6015It is an error to used this flag with the frame pointer or stack pointer.
6016Use of this flag for other registers that have fixed pervasive roles in
6017the machine's execution model will produce disastrous results.
74291a4b
MM
6018
6019This flag does not have a negative form, because it specifies a
6020three-way choice.
6021
6022@item -fcall-saved-@var{reg}
956d6950 6023Treat the register named @var{reg} as an allocable register saved by
74291a4b
MM
6024functions. It may be allocated even for temporaries or variables that
6025live across a call. Functions compiled this way will save and restore
6026the register @var{reg} if they use it.
6027
cb2fdc84
GRK
6028It is an error to used this flag with the frame pointer or stack pointer.
6029Use of this flag for other registers that have fixed pervasive roles in
6030the machine's execution model will produce disastrous results.
74291a4b
MM
6031
6032A different sort of disaster will result from the use of this flag for
6033a register in which function values may be returned.
6034
6035This flag does not have a negative form, because it specifies a
6036three-way choice.
6037
6038@item -fpack-struct
6039Pack all structure members together without holes. Usually you would
6040not want to use this option, since it makes the code suboptimal, and
6041the offsets of structure members won't agree with system libraries.
6042
861bb6c1
JL
6043@item -fcheck-memory-usage
6044Generate extra code to check each memory access. GNU CC will generate
6045code that is suitable for a detector of bad memory accesses such as
7d384cc0 6046@file{Checker}.
861bb6c1
JL
6047
6048You must also specify this option when you compile functions you call that
956d6950 6049have side effects. If you do not, you may get erroneous messages from
861bb6c1
JL
6050the detector. Normally, you should compile all your code with this option.
6051If you use functions from a library that have side-effects (such as
6052@code{read}), you may not be able to recompile the library and
6053specify this option. In that case, you can enable the
6054@samp{-fprefix-function-name} option, which requests GNU CC to encapsulate
6055your code and make other functions look as if they were compiled with
6056@samp{-fcheck-memory-usage}. This is done by calling ``stubs'',
6057which are provided by the detector. If you cannot find or build
6058stubs for every function you call, you may have to specify
6059@samp{-fcheck-memory-usage} without @samp{-fprefix-function-name}.
6060
7d384cc0
KR
6061If you specify this option, you can not use the @code{asm} or
6062@code{__asm__} keywords in functions with memory checking enabled. The
6063compiler cannot understand what the @code{asm} statement will do, and
6064therefore cannot generate the appropriate code, so it is rejected.
6065However, the function attribute @code{no_check_memory_usage} will
6066disable memory checking within a function, and @code{asm} statements can
6067be put inside such functions. Inline expansion of a non-checked
6068function within a checked function is permitted; the inline function's
6069memory accesses won't be checked, but the rest will.
6070
6071If you move your @code{asm} statements to non-checked inline functions,
6072but they do access memory, you can add calls to the support code in your
6073inline function, to indicate any reads, writes, or copies being done.
6074These calls would be similar to those done in the stubs described above.
6075
6076@c FIXME: The support-routine interface is defined by the compiler and
6077@c should be documented!
6078
861bb6c1
JL
6079@item -fprefix-function-name
6080Request GNU CC to add a prefix to the symbols generated for function names.
6081GNU CC adds a prefix to the names of functions defined as well as
6082functions called. Code compiled with this option and code compiled
6083without the option can't be linked together, unless or stubs are used.
6084
6085If you compile the following code with @samp{-fprefix-function-name}
6086@example
6087extern void bar (int);
6088void
6089foo (int a)
6090@{
6091 return bar (a + 5);
6092
6093@}
6094@end example
6095
6096@noindent
6097GNU CC will compile the code as if it was written:
6098@example
6099extern void prefix_bar (int);
6100void
6101prefix_foo (int a)
6102@{
6103 return prefix_bar (a + 5);
6104@}
6105@end example
6106This option is designed to be used with @samp{-fcheck-memory-usage}.
6107
07417085
KR
6108@item -finstrument-functions
6109Generate instrumentation calls for entry and exit to functions. Just
6110after function entry and just before function exit, the following
6111profiling functions will be called with the address of the current
6112function and its call site. (On some platforms,
6113@code{__builtin_return_address} does not work beyond the current
6114function, so the call site information may not be available to the
6115profiling functions otherwise.)
6116
6117@example
6118void __cyg_profile_func_enter (void *this_fn, void *call_site);
6119void __cyg_profile_func_exit (void *this_fn, void *call_site);
6120@end example
6121
6122The first argument is the address of the start of the current function,
6123which may be looked up exactly in the symbol table.
6124
6125This instrumentation is also done for functions expanded inline in other
6126functions. The profiling calls will indicate where, conceptually, the
6127inline function is entered and exited. This means that addressable
6128versions of such functions must be available. If all your uses of a
6129function are expanded inline, this may mean an additional expansion of
6130code size. If you use @samp{extern inline} in your C code, an
6131addressable version of such functions must be provided. (This is
6132normally the case anyways, but if you get lucky and the optimizer always
6133expands the functions inline, you might have gotten away without
6134providing static copies.)
6135
6136A function may be given the attribute @code{no_instrument_function}, in
6137which case this instrumentation will not be done. This can be used, for
6138example, for the profiling functions listed above, high-priority
6139interrupt routines, and any functions from which the profiling functions
6140cannot safely be called (perhaps signal handlers, if the profiling
6141routines generate output or allocate memory).
6142
861bb6c1
JL
6143@item -fstack-check
6144Generate code to verify that you do not go beyond the boundary of the
6145stack. You should specify this flag if you are running in an
6146environment with multiple threads, but only rarely need to specify it in
6147a single-threaded environment since stack overflow is automatically
6148detected on nearly all systems if there is only one stack.
6149
e5eb27e5
JL
6150@cindex aliasing of parameters
6151@cindex parameters, aliased
6152@item -fargument-alias
04afd9d6
JL
6153@itemx -fargument-noalias
6154@itemx -fargument-noalias-global
e5eb27e5
JL
6155Specify the possible relationships among parameters and between
6156parameters and global data.
6157
6158@samp{-fargument-alias} specifies that arguments (parameters) may
6159alias each other and may alias global storage.
6160@samp{-fargument-noalias} specifies that arguments do not alias
6161each other, but may alias global storage.
6162@samp{-fargument-noalias-global} specifies that arguments do not
6163alias each other and do not alias global storage.
6164
6165Each language will automatically use whatever option is required by
6166the language standard. You should not need to use these options yourself.
19283265
RH
6167
6168@item -fleading-underscore
6169This option and its counterpart, -fno-leading-underscore, forcibly
6170change the way C symbols are represented in the object file. One use
6171is to help link with legacy assembly code.
6172
6173Be warned that you should know what you are doing when invoking this
6174option, and that not all targets provide complete support for it.
74291a4b
MM
6175@end table
6176
6177@node Environment Variables
6178@section Environment Variables Affecting GNU CC
6179@cindex environment variables
6180
6181This section describes several environment variables that affect how GNU
56f48ce9
DB
6182CC operates. Some of them work by specifying directories or prefixes to use
6183when searching for various kinds of files. Some are used to specify other
46103ab4 6184aspects of the compilation environment.
74291a4b
MM
6185
6186@ifclear INTERNALS
6187Note that you can also specify places to search using options such as
6188@samp{-B}, @samp{-I} and @samp{-L} (@pxref{Directory Options}). These
6189take precedence over places specified using environment variables, which
6190in turn take precedence over those specified by the configuration of GNU
6191CC.
6192@end ifclear
6193@ifset INTERNALS
6194Note that you can also specify places to search using options such as
6195@samp{-B}, @samp{-I} and @samp{-L} (@pxref{Directory Options}). These
6196take precedence over places specified using environment variables, which
6197in turn take precedence over those specified by the configuration of GNU
6198CC. @xref{Driver}.
6199@end ifset
6200
6201@table @code
ab87f8c8
JL
6202@item LANG
6203@itemx LC_CTYPE
6204@c @itemx LC_COLLATE
6205@itemx LC_MESSAGES
6206@c @itemx LC_MONETARY
6207@c @itemx LC_NUMERIC
6208@c @itemx LC_TIME
6209@itemx LC_ALL
6210@findex LANG
6211@findex LC_CTYPE
6212@c @findex LC_COLLATE
6213@findex LC_MESSAGES
6214@c @findex LC_MONETARY
6215@c @findex LC_NUMERIC
6216@c @findex LC_TIME
6217@findex LC_ALL
6218@cindex locale
6219These environment variables control the way that GNU CC uses
6220localization information that allow GNU CC to work with different
6221national conventions. GNU CC inspects the locale categories
6222@code{LC_CTYPE} and @code{LC_MESSAGES} if it has been configured to do
6223so. These locale categories can be set to any value supported by your
6224installation. A typical value is @samp{en_UK} for English in the United
6225Kingdom.
6226
6227The @code{LC_CTYPE} environment variable specifies character
6228classification. GNU CC uses it to determine the character boundaries in
6229a string; this is needed for some multibyte encodings that contain quote
6230and escape characters that would otherwise be interpreted as a string
6231end or escape.
6232
6233The @code{LC_MESSAGES} environment variable specifies the language to
6234use in diagnostic messages.
6235
6236If the @code{LC_ALL} environment variable is set, it overrides the value
6237of @code{LC_CTYPE} and @code{LC_MESSAGES}; otherwise, @code{LC_CTYPE}
6238and @code{LC_MESSAGES} default to the value of the @code{LANG}
6239environment variable. If none of these variables are set, GNU CC
6240defaults to traditional C English behavior.
6241
74291a4b
MM
6242@item TMPDIR
6243@findex TMPDIR
6244If @code{TMPDIR} is set, it specifies the directory to use for temporary
6245files. GNU CC uses temporary files to hold the output of one stage of
6246compilation which is to be used as input to the next stage: for example,
6247the output of the preprocessor, which is the input to the compiler
6248proper.
6249
6250@item GCC_EXEC_PREFIX
6251@findex GCC_EXEC_PREFIX
6252If @code{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
6253names of the subprograms executed by the compiler. No slash is added
6254when this prefix is combined with the name of a subprogram, but you can
6255specify a prefix that ends with a slash if you wish.
6256
6257If GNU CC cannot find the subprogram using the specified prefix, it
6258tries looking in the usual places for the subprogram.
6259
6260The default value of @code{GCC_EXEC_PREFIX} is
6261@file{@var{prefix}/lib/gcc-lib/} where @var{prefix} is the value
6262of @code{prefix} when you ran the @file{configure} script.
6263
6264Other prefixes specified with @samp{-B} take precedence over this prefix.
6265
6266This prefix is also used for finding files such as @file{crt0.o} that are
6267used for linking.
6268
6269In addition, the prefix is used in an unusual way in finding the
6270directories to search for header files. For each of the standard
6271directories whose name normally begins with @samp{/usr/local/lib/gcc-lib}
6272(more precisely, with the value of @code{GCC_INCLUDE_DIR}), GNU CC tries
6273replacing that beginning with the specified prefix to produce an
6274alternate directory name. Thus, with @samp{-Bfoo/}, GNU CC will search
6275@file{foo/bar} where it would normally search @file{/usr/local/lib/bar}.
6276These alternate directories are searched first; the standard directories
6277come next.
6278
6279@item COMPILER_PATH
6280@findex COMPILER_PATH
6281The value of @code{COMPILER_PATH} is a colon-separated list of
6282directories, much like @code{PATH}. GNU CC tries the directories thus
6283specified when searching for subprograms, if it can't find the
6284subprograms using @code{GCC_EXEC_PREFIX}.
6285
6286@item LIBRARY_PATH
6287@findex LIBRARY_PATH
6288The value of @code{LIBRARY_PATH} is a colon-separated list of
6289directories, much like @code{PATH}. When configured as a native compiler,
6290GNU CC tries the directories thus specified when searching for special
6291linker files, if it can't find them using @code{GCC_EXEC_PREFIX}. Linking
6292using GNU CC also uses these directories when searching for ordinary
6293libraries for the @samp{-l} option (but directories specified with
6294@samp{-L} come first).
6295
6296@item C_INCLUDE_PATH
6297@itemx CPLUS_INCLUDE_PATH
6298@itemx OBJC_INCLUDE_PATH
6299@findex C_INCLUDE_PATH
6300@findex CPLUS_INCLUDE_PATH
6301@findex OBJC_INCLUDE_PATH
6302@c @itemx OBJCPLUS_INCLUDE_PATH
6303These environment variables pertain to particular languages. Each
6304variable's value is a colon-separated list of directories, much like
6305@code{PATH}. When GNU CC searches for header files, it tries the
6306directories listed in the variable for the language you are using, after
6307the directories specified with @samp{-I} but before the standard header
6308file directories.
6309
6310@item DEPENDENCIES_OUTPUT
6311@findex DEPENDENCIES_OUTPUT
6312@cindex dependencies for make as output
6313If this variable is set, its value specifies how to output dependencies
6314for Make based on the header files processed by the compiler. This
6315output looks much like the output from the @samp{-M} option
6316(@pxref{Preprocessor Options}), but it goes to a separate file, and is
6317in addition to the usual results of compilation.
6318
6319The value of @code{DEPENDENCIES_OUTPUT} can be just a file name, in
6320which case the Make rules are written to that file, guessing the target
6321name from the source file name. Or the value can have the form
6322@samp{@var{file} @var{target}}, in which case the rules are written to
6323file @var{file} using @var{target} as the target name.
56f48ce9
DB
6324
6325@item LANG
6326@findex LANG
6327@cindex locale definition
6328This variable is used to pass locale information to the compiler. One way in
6329which this information is used is to determine the character set to be used
6330when character literals, string literals and comments are parsed in C and C++.
6331When the compiler is configured to allow multibyte characters,
6332the following values for @code{LANG} are recognized:
6333
6334@table @code
6335@item C-JIS
6336Recognize JIS characters.
6337@item C-SJIS
6338Recognize SJIS characters.
6339@item C-EUCJP
6340Recognize EUCJP characters.
6341@end table
6342
46103ab4 6343If @code{LANG} is not defined, or if it has some other value, then the
56f48ce9
DB
6344compiler will use mblen and mbtowc as defined by the default locale to
6345recognize and translate multibyte characters.
74291a4b
MM
6346@end table
6347
6348@node Running Protoize
6349@section Running Protoize
6350
6351The program @code{protoize} is an optional part of GNU C. You can use
6352it to add prototypes to a program, thus converting the program to ANSI
6353C in one respect. The companion program @code{unprotoize} does the
6354reverse: it removes argument types from any prototypes that are found.
6355
6356When you run these programs, you must specify a set of source files as
6357command line arguments. The conversion programs start out by compiling
6358these files to see what functions they define. The information gathered
6359about a file @var{foo} is saved in a file named @file{@var{foo}.X}.
6360
6361After scanning comes actual conversion. The specified files are all
6362eligible to be converted; any files they include (whether sources or
6363just headers) are eligible as well.
6364
6365But not all the eligible files are converted. By default,
6366@code{protoize} and @code{unprotoize} convert only source and header
6367files in the current directory. You can specify additional directories
6368whose files should be converted with the @samp{-d @var{directory}}
6369option. You can also specify particular files to exclude with the
6370@samp{-x @var{file}} option. A file is converted if it is eligible, its
6371directory name matches one of the specified directory names, and its
6372name within the directory has not been excluded.
6373
6374Basic conversion with @code{protoize} consists of rewriting most
6375function definitions and function declarations to specify the types of
6376the arguments. The only ones not rewritten are those for varargs
6377functions.
6378
6379@code{protoize} optionally inserts prototype declarations at the
6380beginning of the source file, to make them available for any calls that
6381precede the function's definition. Or it can insert prototype
6382declarations with block scope in the blocks where undeclared functions
6383are called.
6384
6385Basic conversion with @code{unprotoize} consists of rewriting most
6386function declarations to remove any argument types, and rewriting
6387function definitions to the old-style pre-ANSI form.
6388
6389Both conversion programs print a warning for any function declaration or
6390definition that they can't convert. You can suppress these warnings
6391with @samp{-q}.
6392
6393The output from @code{protoize} or @code{unprotoize} replaces the
6394original source file. The original file is renamed to a name ending
6395with @samp{.save}. If the @samp{.save} file already exists, then
6396the source file is simply discarded.
6397
6398@code{protoize} and @code{unprotoize} both depend on GNU CC itself to
6399scan the program and collect information about the functions it uses.
6400So neither of these programs will work until GNU CC is installed.
6401
6402Here is a table of the options you can use with @code{protoize} and
6403@code{unprotoize}. Each option works with both programs unless
6404otherwise stated.
6405
6406@table @code
6407@item -B @var{directory}
6408Look for the file @file{SYSCALLS.c.X} in @var{directory}, instead of the
6409usual directory (normally @file{/usr/local/lib}). This file contains
6410prototype information about standard system functions. This option
6411applies only to @code{protoize}.
6412
6413@item -c @var{compilation-options}
6414Use @var{compilation-options} as the options when running @code{gcc} to
6415produce the @samp{.X} files. The special option @samp{-aux-info} is
6416always passed in addition, to tell @code{gcc} to write a @samp{.X} file.
6417
6418Note that the compilation options must be given as a single argument to
6419@code{protoize} or @code{unprotoize}. If you want to specify several
6420@code{gcc} options, you must quote the entire set of compilation options
6421to make them a single word in the shell.
6422
6423There are certain @code{gcc} arguments that you cannot use, because they
6424would produce the wrong kind of output. These include @samp{-g},
6425@samp{-O}, @samp{-c}, @samp{-S}, and @samp{-o} If you include these in
6426the @var{compilation-options}, they are ignored.
6427
6428@item -C
6429Rename files to end in @samp{.C} instead of @samp{.c}.
6430This is convenient if you are converting a C program to C++.
6431This option applies only to @code{protoize}.
6432
6433@item -g
6434Add explicit global declarations. This means inserting explicit
6435declarations at the beginning of each source file for each function
6436that is called in the file and was not declared. These declarations
6437precede the first function definition that contains a call to an
6438undeclared function. This option applies only to @code{protoize}.
6439
6440@item -i @var{string}
6441Indent old-style parameter declarations with the string @var{string}.
6442This option applies only to @code{protoize}.
6443
6444@code{unprotoize} converts prototyped function definitions to old-style
6445function definitions, where the arguments are declared between the
6446argument list and the initial @samp{@{}. By default, @code{unprotoize}
6447uses five spaces as the indentation. If you want to indent with just
6448one space instead, use @samp{-i " "}.
6449
6450@item -k
6451Keep the @samp{.X} files. Normally, they are deleted after conversion
6452is finished.
6453
6454@item -l
6455Add explicit local declarations. @code{protoize} with @samp{-l} inserts
6456a prototype declaration for each function in each block which calls the
6457function without any declaration. This option applies only to
6458@code{protoize}.
6459
6460@item -n
6461Make no real changes. This mode just prints information about the conversions
6462that would have been done without @samp{-n}.
6463
6464@item -N
6465Make no @samp{.save} files. The original files are simply deleted.
6466Use this option with caution.
6467
6468@item -p @var{program}
6469Use the program @var{program} as the compiler. Normally, the name
6470@file{gcc} is used.
6471
6472@item -q
6473Work quietly. Most warnings are suppressed.
6474
6475@item -v
6476Print the version number, just like @samp{-v} for @code{gcc}.
6477@end table
6478
6479If you need special compiler options to compile one of your program's
6480source files, then you should generate that file's @samp{.X} file
6481specially, by running @code{gcc} on that source file with the
6482appropriate options and the option @samp{-aux-info}. Then run
6483@code{protoize} on the entire set of files. @code{protoize} will use
6484the existing @samp{.X} file because it is newer than the source file.
6485For example:
6486
6487@example
6488gcc -Dfoo=bar file1.c -aux-info
6489protoize *.c
6490@end example
6491
6492@noindent
6493You need to include the special files along with the rest in the
6494@code{protoize} command, even though their @samp{.X} files already
6495exist, because otherwise they won't get converted.
6496
6497@xref{Protoize Caveats}, for more information on how to use
6498@code{protoize} successfully.
6499
This page took 1.057218 seconds and 5 git commands to generate.