]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/invoke.texi
configure.in: Check whether assembler supports section merging.
[thirdparty/gcc.git] / gcc / doc / invoke.texi
CommitLineData
d0a5eb32
RK
1@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2@c 2000, 2001 Free Software Foundation, Inc.
74291a4b
MM
3@c This is part of the GCC manual.
4@c For copying conditions, see the file gcc.texi.
5
9d86bffc
JM
6@ignore
7@c man begin COPYRIGHT
8Copyright @copyright{} 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
21c7361e 91998, 1999, 2000, 2001 Free Software Foundation, Inc.
9d86bffc
JM
10
11Permission is granted to make and distribute verbatim copies of this
12manual provided the copyright notice and this permission notice are
13preserved on all copies.
14
15Permission is granted to copy and distribute modified versions of this
16manual under the conditions for verbatim copying, provided also that the
17entire resulting derived work is distributed under the terms of a
18permission notice identical to this one.
19
20Permission is granted to copy and distribute translations of this manual
21into another language, under the above conditions for modified versions,
22except that this permission notice may be included in translations
23approved by the Free Software Foundation instead of in the original
24English.
25@c man end
26@c Set file name and title for the man page.
27@setfilename gcc
28@settitle GNU project C and C++ compiler
29@c man begin SYNOPSIS
630d3d5a
JM
30gcc [@option{-c}|@option{-S}|@option{-E}] [@option{-std=}@var{standard}]
31 [@option{-g}] [@option{-pg}] [@option{-O}@var{level}]
32 [@option{-W}@var{warn}@dots{}] [@option{-pedantic}]
33 [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
34 [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
35 [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}]
36 [@option{-o} @var{outfile}] @var{infile}@dots{}
9d86bffc
JM
37
38Only the most useful options are listed here; see below for the
39remainder. @samp{g++} accepts mostly the same options as @samp{gcc}.
40@c man end
41@c man begin SEEALSO
42cpp(1), gcov(1), g77(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1)
43and the Info entries for @file{gcc}, @file{cpp}, @file{g77}, @file{as},
44@file{ld}, @file{binutils} and @file{gdb}.
45@c man end
2642624b
JM
46@c man begin BUGS
47For instructions on reporting bugs, see
bedc7537 48@w{@uref{http://gcc.gnu.org/bugs.html}}. Use of the @command{gccbug}
2642624b
JM
49script to report bugs is recommended.
50@c man end
51@c man begin AUTHOR
52See the Info entry for @file{gcc}, or
161d7b59 53@w{@uref{http://gcc.gnu.org/thanks.html}}, for contributors to GCC@.
2642624b 54@c man end
9d86bffc
JM
55@end ignore
56
74291a4b 57@node Invoking GCC
0c2d1a2a
JB
58@chapter GCC Command Options
59@cindex GCC command options
74291a4b 60@cindex command options
0c2d1a2a 61@cindex options, GCC command
74291a4b 62
9d86bffc
JM
63@c man begin DESCRIPTION
64
0c2d1a2a 65When you invoke GCC, it normally does preprocessing, compilation,
74291a4b 66assembly and linking. The ``overall options'' allow you to stop this
630d3d5a 67process at an intermediate stage. For example, the @option{-c} option
74291a4b
MM
68says not to run the linker. Then the output consists of object files
69output by the assembler.
70
71Other options are passed on to one stage of processing. Some options
72control the preprocessor and others the compiler itself. Yet other
73options control the assembler and linker; most of these are not
74documented here, since you rarely need to use any of them.
75
76@cindex C compilation options
0c2d1a2a 77Most of the command line options that you can use with GCC are useful
74291a4b
MM
78for C programs; when an option is only useful with another language
79(usually C++), the explanation says so explicitly. If the description
80for a particular option does not mention a source language, you can use
81that option with all supported languages.
82
83@cindex C++ compilation options
84@xref{Invoking G++,,Compiling C++ Programs}, for a summary of special
85options for compiling C++ programs.
86
87@cindex grouping options
88@cindex options, grouping
bedc7537 89The @command{gcc} program accepts options and file names as operands. Many
b192711e 90options have multi-letter names; therefore multiple single-letter options
630d3d5a 91may @emph{not} be grouped: @option{-dr} is very different from @w{@samp{-d
74291a4b
MM
92-r}}.
93
94@cindex order of options
95@cindex options, order
96You can mix options and other arguments. For the most part, the order
97you use doesn't matter. Order does matter when you use several options
630d3d5a 98of the same kind; for example, if you specify @option{-L} more than once,
74291a4b
MM
99the directories are searched in the order specified.
100
101Many options have long names starting with @samp{-f} or with
630d3d5a
JM
102@samp{-W}---for example, @option{-fforce-mem},
103@option{-fstrength-reduce}, @option{-Wformat} and so on. Most of
74291a4b 104these have both positive and negative forms; the negative form of
630d3d5a 105@option{-ffoo} would be @option{-fno-foo}. This manual documents
74291a4b
MM
106only one of these two forms, whichever one is not the default.
107
9d86bffc
JM
108@c man end
109
cd3bb277
JM
110@xref{Option Index}, for an index to GCC's options.
111
74291a4b
MM
112@menu
113* Option Summary:: Brief list of all options, without explanations.
114* Overall Options:: Controlling the kind of output:
115 an executable, object files, assembler files,
116 or preprocessed source.
117* Invoking G++:: Compiling C++ programs.
118* C Dialect Options:: Controlling the variant of C language compiled.
119* C++ Dialect Options:: Variations on C++.
60de6385 120* Objective-C Dialect Options:: Variations on Objective-C.
764dbbf2 121* Language Independent Options:: Controlling how diagnostics should be
02f52e19 122 formatted.
74291a4b
MM
123* Warning Options:: How picky should the compiler be?
124* Debugging Options:: Symbol tables, measurements, and debugging dumps.
125* Optimize Options:: How much optimization?
126* Preprocessor Options:: Controlling header files and macro definitions.
127 Also, getting dependency information for Make.
128* Assembler Options:: Passing options to the assembler.
129* Link Options:: Specifying libraries and so on.
130* Directory Options:: Where to find header files and libraries.
131 Where to find the compiler executable files.
a743d340 132* Spec Files:: How to pass switches to sub-processes.
0c2d1a2a 133* Target Options:: Running a cross-compiler, or an old version of GCC.
74291a4b
MM
134* Submodel Options:: Specifying minor hardware or convention variations,
135 such as 68010 vs 68020.
136* Code Gen Options:: Specifying conventions for function calls, data layout
137 and register usage.
0c2d1a2a 138* Environment Variables:: Env vars that affect GCC.
74291a4b
MM
139* Running Protoize:: Automatically adding or removing function prototypes.
140@end menu
141
4bc1997b
JM
142@c man begin OPTIONS
143
74291a4b
MM
144@node Option Summary
145@section Option Summary
146
147Here is a summary of all the options, grouped by type. Explanations are
148in the following sections.
149
150@table @emph
151@item Overall Options
152@xref{Overall Options,,Options Controlling the Kind of Output}.
4bc1997b
JM
153@gccoptlist{
154-c -S -E -o @var{file} -pipe -pass-exit-codes -x @var{language} @gol
155-v --target-help --help}
74291a4b
MM
156
157@item C Language Options
158@xref{C Dialect Options,,Options Controlling C Dialect}.
4bc1997b 159@gccoptlist{
b1018de6
AO
160-ansi -std=@var{standard} -aux-info @var{filename} @gol
161-fno-asm -fno-builtin @gol
4bc1997b
JM
162-fhosted -ffreestanding @gol
163-trigraphs -traditional -traditional-cpp @gol
164-fallow-single-precision -fcond-mismatch @gol
165-fsigned-bitfields -fsigned-char @gol
166-funsigned-bitfields -funsigned-char @gol
167-fwritable-strings -fshort-wchar}
74291a4b
MM
168
169@item C++ Language Options
170@xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
4bc1997b
JM
171@gccoptlist{
172-fno-access-control -fcheck-new -fconserve-space @gol
aa0cc562
JM
173-fno-const-strings -fdollars-in-identifiers @gol
174-fno-elide-constructors @gol
4bc1997b
JM
175-fno-enforce-eh-specs -fexternal-templates @gol
176-falt-external-templates @gol
1dbb6023 177-ffor-scope -fno-for-scope -fno-gnu-keywords @gol
90ecce3e 178-fno-implicit-templates @gol
4bc1997b
JM
179-fno-implicit-inline-templates @gol
180-fno-implement-inlines -fms-extensions @gol
aa0cc562 181-fno-nonansi-builtins -fno-operator-names @gol
4bc1997b 182-fno-optional-diags -fpermissive @gol
aa0cc562 183-frepo -fno-rtti -fstats -ftemplate-depth-@var{n} @gol
90ecce3e 184-fuse-cxa-atexit -fvtable-gc -fno-weak -nostdinc++ @gol
4bc1997b
JM
185-fno-default-inline -Wctor-dtor-privacy @gol
186-Wnon-virtual-dtor -Wreorder @gol
187-Weffc++ -Wno-deprecated @gol
188-Wno-non-template-friend -Wold-style-cast @gol
189-Woverloaded-virtual -Wno-pmf-conversions @gol
190-Wsign-promo -Wsynth}
74291a4b 191
60de6385
SS
192@item Objective-C Language Options
193@xref{Objective-C Dialect Options,,Options Controlling Objective-C Dialect}.
194@gccoptlist{
630d3d5a 195-fconstant-string-class=@var{class-name} @gol
310668e8 196-fgnu-runtime -fnext-runtime -gen-decls @gol
60de6385
SS
197-Wno-protocol -Wselector}
198
764dbbf2
GDR
199@item Language Independent Options
200@xref{Language Independent Options,,Options to Control Diagnostic Messages Formatting}.
4bc1997b
JM
201@gccoptlist{
202-fmessage-length=@var{n} @gol
203-fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}}
764dbbf2 204
74291a4b
MM
205@item Warning Options
206@xref{Warning Options,,Options to Request or Suppress Warnings}.
4bc1997b
JM
207@gccoptlist{
208-fsyntax-only -pedantic -pedantic-errors @gol
209-w -W -Wall -Waggregate-return @gol
210-Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
feb48bde 211-Wconversion -Wdisabled-optimization -Werror @gol
4bc1997b 212-Wfloat-equal -Wformat -Wformat=2 @gol
feb48bde
JM
213-Wformat-nonliteral -Wformat-security @gol
214-Wimplicit -Wimplicit-int @gol
4bc1997b
JM
215-Wimplicit-function-declaration @gol
216-Werror-implicit-function-declaration @gol
217-Wimport -Winline @gol
218-Wlarger-than-@var{len} -Wlong-long @gol
1f0c3120 219-Wmain -Wmissing-braces -Wmissing-declarations @gol
4bc1997b 220-Wmissing-format-attribute -Wmissing-noreturn @gol
feb48bde 221-Wmultichar -Wno-format-extra-args -Wno-format-y2k @gol
4bc1997b 222-Wno-import -Wpacked -Wpadded @gol
310668e8 223-Wparentheses -Wpointer-arith -Wredundant-decls @gol
4bc1997b
JM
224-Wreturn-type -Wsequence-point -Wshadow @gol
225-Wsign-compare -Wswitch -Wsystem-headers @gol
226-Wtrigraphs -Wundef -Wuninitialized @gol
227-Wunknown-pragmas -Wunreachable-code @gol
228-Wunused -Wunused-function -Wunused-label -Wunused-parameter @gol
229-Wunused-value -Wunused-variable -Wwrite-strings}
74291a4b 230
fe50c0eb 231@item C-only Warning Options
4bc1997b 232@gccoptlist{
310668e8
JM
233-Wbad-function-cast -Wmissing-prototypes -Wnested-externs @gol
234-Wstrict-prototypes -Wtraditional}
fe50c0eb 235
74291a4b
MM
236@item Debugging Options
237@xref{Debugging Options,,Options for Debugging Your Program or GCC}.
4bc1997b 238@gccoptlist{
1f0c3120 239-a -ax -d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol
aee96fe9
JM
240-fdump-unnumbered -fdump-translation-unit@r{[}-@var{n}@r{]} @gol
241-fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
22367161
NS
242-fdump-tree-original@r{[}-@var{n}@r{]} -fdump-tree-optimized@r{[}-@var{n}@r{]} @gol
243-fdump-tree-inlined@r{[}-@var{n}@r{]} @gol
e76b4820 244-fmem-report -fpretend-float @gol
1f0c3120 245-fprofile-arcs -ftest-coverage -ftime-report @gol
4bc1997b
JM
246-g -g@var{level} -gcoff -gdwarf -gdwarf-1 -gdwarf-1+ -gdwarf-2 @gol
247-ggdb -gstabs -gstabs+ -gxcoff -gxcoff+ @gol
248-p -pg -print-file-name=@var{library} -print-libgcc-file-name @gol
b1018de6 249-print-multi-directory -print-multi-lib @gol
4bc1997b
JM
250-print-prog-name=@var{program} -print-search-dirs -Q @gol
251-save-temps -time}
74291a4b
MM
252
253@item Optimization Options
254@xref{Optimize Options,,Options that Control Optimization}.
4bc1997b
JM
255@gccoptlist{
256-falign-functions=@var{n} -falign-jumps=@var{n} @gol
257-falign-labels=@var{n} -falign-loops=@var{n} @gol
258-fbranch-probabilities -fcaller-saves @gol
62d285ff 259-fcse-follow-jumps -fcse-skip-blocks -fdata-sections @gol
4bc1997b
JM
260-fdelayed-branch -fdelete-null-pointer-checks @gol
261-fexpensive-optimizations -ffast-math -ffloat-store @gol
feb48bde
JM
262-fforce-addr -fforce-mem -ffunction-sections @gol
263-fgcse -fgcse-lm -fgcse-sm @gol
4bc1997b 264-finline-functions -finline-limit=@var{n} -fkeep-inline-functions @gol
201556f0
JJ
265-fkeep-static-consts -fmerge-constants -fmerge-all-constants @gol
266-fmove-all-movables -fno-default-inline -fno-defer-pop @gol
feb48bde 267-fno-function-cse -fno-guess-branch-probability @gol
6cfc0341 268-fno-inline -fno-math-errno -fno-peephole -fno-peephole2 @gol
de6c5979 269-funsafe-math-optimizations -fno-trapping-math @gol
4bc1997b
JM
270-fomit-frame-pointer -foptimize-register-move @gol
271-foptimize-sibling-calls -freduce-all-givs @gol
272-fregmove -frename-registers @gol
273-frerun-cse-after-loop -frerun-loop-opt @gol
274-fschedule-insns -fschedule-insns2 @gol
0b47e4c1 275-fsingle-precision-constant -fssa -fssa-ccp -fssa-dce @gol
4bc1997b
JM
276-fstrength-reduce -fstrict-aliasing -fthread-jumps -ftrapv @gol
277-funroll-all-loops -funroll-loops @gol
3af64fd6 278--param @var{name}=@var{value}
4bc1997b 279-O -O0 -O1 -O2 -O3 -Os}
74291a4b
MM
280
281@item Preprocessor Options
282@xref{Preprocessor Options,,Options Controlling the Preprocessor}.
4bc1997b
JM
283@gccoptlist{
284-$ -A@var{question}=@var{answer} -A-@var{question}@r{[}=@var{answer}@r{]} @gol
285-C -dD -dI -dM -dN @gol
286-D@var{macro}@r{[}=@var{defn}@r{]} -E -H @gol
287-idirafter @var{dir} @gol
288-include @var{file} -imacros @var{file} @gol
289-iprefix @var{file} -iwithprefix @var{dir} @gol
bdd42dd9 290-iwithprefixbefore @var{dir} -isystem @var{dir} @gol
4bc1997b 291-M -MM -MF -MG -MP -MQ -MT -nostdinc -P -remap @gol
aee96fe9 292-trigraphs -undef -U@var{macro} -Wp,@var{option}}
74291a4b
MM
293
294@item Assembler Option
295@xref{Assembler Options,,Passing Options to the Assembler}.
4bc1997b 296@gccoptlist{
aee96fe9 297-Wa,@var{option}}
74291a4b
MM
298
299@item Linker Options
300@xref{Link Options,,Options for Linking}.
4bc1997b
JM
301@gccoptlist{
302@var{object-file-name} -l@var{library} @gol
303-nostartfiles -nodefaultlibs -nostdlib @gol
304-s -static -static-libgcc -shared -shared-libgcc -symbolic @gol
aee96fe9 305-Wl,@var{option} -Xlinker @var{option} @gol
4bc1997b 306-u @var{symbol}}
74291a4b
MM
307
308@item Directory Options
309@xref{Directory Options,,Options for Directory Search}.
4bc1997b
JM
310@gccoptlist{
311-B@var{prefix} -I@var{dir} -I- -L@var{dir} -specs=@var{file}}
74291a4b
MM
312
313@item Target Options
314@c I wrote this xref this way to avoid overfull hbox. -- rms
315@xref{Target Options}.
4bc1997b
JM
316@gccoptlist{
317-b @var{machine} -V @var{version}}
74291a4b
MM
318
319@item Machine Dependent Options
320@xref{Submodel Options,,Hardware Models and Configurations}.
74291a4b 321@emph{M680x0 Options}
4bc1997b
JM
322@gccoptlist{
323-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol
feb48bde 324-m68060 -mcpu32 -m5200 -m68881 -mbitfield -mc68000 -mc68020 @gol
310668e8
JM
325-mfpa -mnobitfield -mrtd -mshort -msoft-float -mpcrel @gol
326-malign-int -mstrict-align}
74291a4b 327
2856c3e3 328@emph{M68hc1x Options}
4bc1997b
JM
329@gccoptlist{
330-m6811 -m6812 -m68hc11 -m68hc12 @gol
331-mauto-incdec -mshort -msoft-reg-count=@var{count}}
2856c3e3 332
74291a4b 333@emph{VAX Options}
4bc1997b
JM
334@gccoptlist{
335-mg -mgnu -munix}
74291a4b
MM
336
337@emph{SPARC Options}
4bc1997b 338@gccoptlist{
630d3d5a
JM
339-mcpu=@var{cpu-type} @gol
340-mtune=@var{cpu-type} @gol
341-mcmodel=@var{code-model} @gol
4bc1997b
JM
342-m32 -m64 @gol
343-mapp-regs -mbroken-saverestore -mcypress @gol
feb48bde 344-mepilogue -mfaster-structs -mflat @gol
4bc1997b
JM
345-mfpu -mhard-float -mhard-quad-float @gol
346-mimpure-text -mlive-g0 -mno-app-regs @gol
310668e8
JM
347-mno-epilogue -mno-faster-structs -mno-flat -mno-fpu @gol
348-mno-impure-text -mno-stack-bias -mno-unaligned-doubles @gol
4bc1997b
JM
349-msoft-float -msoft-quad-float -msparclite -mstack-bias @gol
350-msupersparc -munaligned-doubles -mv8}
74291a4b
MM
351
352@emph{Convex Options}
4bc1997b
JM
353@gccoptlist{
354-mc1 -mc2 -mc32 -mc34 -mc38 @gol
355-margcount -mnoargcount @gol
356-mlong32 -mlong64 @gol
357-mvolatile-cache -mvolatile-nocache}
74291a4b
MM
358
359@emph{AMD29K Options}
4bc1997b
JM
360@gccoptlist{
361-m29000 -m29050 -mbw -mnbw -mdw -mndw @gol
362-mlarge -mnormal -msmall @gol
363-mkernel-registers -mno-reuse-arg-regs @gol
364-mno-stack-check -mno-storem-bug @gol
365-mreuse-arg-regs -msoft-float -mstack-check @gol
366-mstorem-bug -muser-registers}
74291a4b
MM
367
368@emph{ARM Options}
4bc1997b 369@gccoptlist{
310668e8
JM
370-mapcs-frame -mno-apcs-frame @gol
371-mapcs-26 -mapcs-32 @gol
372-mapcs-stack-check -mno-apcs-stack-check @gol
373-mapcs-float -mno-apcs-float @gol
374-mapcs-reentrant -mno-apcs-reentrant @gol
375-msched-prolog -mno-sched-prolog @gol
376-mlittle-endian -mbig-endian -mwords-little-endian @gol
377-malignment-traps -mno-alignment-traps @gol
378-msoft-float -mhard-float -mfpe @gol
379-mthumb-interwork -mno-thumb-interwork @gol
380-mcpu=@var{name} -march=@var{name} -mfpe=@var{name} @gol
247f8561 381-mstructure-size-boundary=@var{n} @gol
310668e8 382-mbsd -mxopen -mno-symrename @gol
4bc1997b 383-mabort-on-noreturn @gol
310668e8
JM
384-mlong-calls -mno-long-calls @gol
385-msingle-pic-base -mno-single-pic-base @gol
247f8561
PB
386-mpic-register=@var{reg} @gol
387-mnop-fun-dllimport @gol
388-mpoke-function-name @gol
310668e8
JM
389-mthumb -marm @gol
390-mtpcs-frame -mtpcs-leaf-frame @gol
391-mcaller-super-interworking -mcallee-super-interworking }
74291a4b 392
ecff22ab 393@emph{MN10200 Options}
4bc1997b
JM
394@gccoptlist{
395-mrelax}
ecff22ab 396
6d6d0fa0 397@emph{MN10300 Options}
4bc1997b 398@gccoptlist{
c474f76b
AO
399-mmult-bug -mno-mult-bug @gol
400-mam33 -mno-am33 @gol
401-mno-crt0 -mrelax}
6d6d0fa0 402
861bb6c1 403@emph{M32R/D Options}
4bc1997b 404@gccoptlist{
630d3d5a 405-mcode-model=@var{model-type} -msdata=@var{sdata-type} @gol
4bc1997b 406-G @var{num}}
861bb6c1 407
74291a4b 408@emph{M88K Options}
4bc1997b
JM
409@gccoptlist{
410-m88000 -m88100 -m88110 -mbig-pic @gol
411-mcheck-zero-division -mhandle-large-shift @gol
412-midentify-revision -mno-check-zero-division @gol
413-mno-ocs-debug-info -mno-ocs-frame-position @gol
414-mno-optimize-arg-area -mno-serialize-volatile @gol
415-mno-underscores -mocs-debug-info @gol
416-mocs-frame-position -moptimize-arg-area @gol
417-mserialize-volatile -mshort-data-@var{num} -msvr3 @gol
418-msvr4 -mtrap-large-shift -muse-div-instruction @gol
419-mversion-03.00 -mwarn-passed-structs}
74291a4b
MM
420
421@emph{RS/6000 and PowerPC Options}
4bc1997b 422@gccoptlist{
630d3d5a
JM
423-mcpu=@var{cpu-type} @gol
424-mtune=@var{cpu-type} @gol
4bc1997b
JM
425-mpower -mno-power -mpower2 -mno-power2 @gol
426-mpowerpc -mpowerpc64 -mno-powerpc @gol
427-mpowerpc-gpopt -mno-powerpc-gpopt @gol
428-mpowerpc-gfxopt -mno-powerpc-gfxopt @gol
429-mnew-mnemonics -mold-mnemonics @gol
430-mfull-toc -mminimal-toc -mno-fop-in-toc -mno-sum-in-toc @gol
431-m64 -m32 -mxl-call -mno-xl-call -mthreads -mpe @gol
432-msoft-float -mhard-float -mmultiple -mno-multiple @gol
433-mstring -mno-string -mupdate -mno-update @gol
434-mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol
435-mstrict-align -mno-strict-align -mrelocatable @gol
436-mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol
437-mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol
9c34dbbf
ZW
438-mcall-aix -mcall-sysv -mcall-netbsd @gol
439-mprototype -mno-prototype @gol
4bc1997b
JM
440-msim -mmvme -mads -myellowknife -memb -msdata @gol
441-msdata=@var{opt} -mvxworks -G @var{num}}
74291a4b
MM
442
443@emph{RT Options}
4bc1997b
JM
444@gccoptlist{
445-mcall-lib-mul -mfp-arg-in-fpregs -mfp-arg-in-gregs @gol
446-mfull-fp-blocks -mhc-struct-return -min-line-mul @gol
447-mminimum-fp-blocks -mnohc-struct-return}
74291a4b
MM
448
449@emph{MIPS Options}
4bc1997b 450@gccoptlist{
7dac2f89
EC
451-mabicalls -march=@var{cpu-type} -mtune=@var{cpu=type} @gol
452-mcpu=@var{cpu-type} -membedded-data -muninit-const-in-rodata @gol
13fac94a
GK
453-membedded-pic -mfp32 -mfp64 -mfused-madd -mno-fused-madd @gol
454-mgas -mgp32 -mgp64 @gol
4bc1997b 455-mgpopt -mhalf-pic -mhard-float -mint64 -mips1 @gol
feb48bde 456-mips2 -mips3 -mips4 -mlong64 -mlong32 -mlong-calls -mmemcpy @gol
4bc1997b 457-mmips-as -mmips-tfile -mno-abicalls @gol
feb48bde
JM
458-mno-embedded-data -mno-uninit-const-in-rodata @gol
459-mno-embedded-pic -mno-gpopt -mno-long-calls @gol
4bc1997b
JM
460-mno-memcpy -mno-mips-tfile -mno-rnames -mno-stats @gol
461-mrnames -msoft-float @gol
462-m4650 -msingle-float -mmad @gol
463-mstats -EL -EB -G @var{num} -nocpp @gol
feb48bde
JM
464-mabi=32 -mabi=n32 -mabi=64 -mabi=eabi @gol
465-mfix7000 -mno-crt0}
74291a4b
MM
466
467@emph{i386 Options}
4bc1997b 468@gccoptlist{
630d3d5a 469-mcpu=@var{cpu-type} -march=@var{cpu-type} @gol
4bc1997b
JM
470-mintel-syntax -mieee-fp -mno-fancy-math-387 @gol
471-mno-fp-ret-in-387 -msoft-float -msvr3-shlib @gol
472-mno-wide-multiply -mrtd -malign-double @gol
3e18fdf6 473-mpreferred-stack-boundary=@var{num} @gol
feb48bde
JM
474-mthreads -mno-align-stringops -minline-all-stringops @gol
475-mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
476-m96bit-long-double -mregparm=@var{num} -momit-leaf-frame-pointer}
74291a4b
MM
477
478@emph{HPPA Options}
4bc1997b 479@gccoptlist{
630d3d5a 480-march=@var{architecture-type} @gol
feb48bde
JM
481-mbig-switch -mdisable-fpregs -mdisable-indexing @gol
482-mfast-indirect-calls -mgas -mjump-in-delay @gol
4bc1997b
JM
483-mlong-load-store -mno-big-switch -mno-disable-fpregs @gol
484-mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol
feb48bde 485-mno-jump-in-delay -mno-long-load-store @gol
4bc1997b 486-mno-portable-runtime -mno-soft-float @gol
feb48bde
JM
487-mno-space-regs -msoft-float -mpa-risc-1-0 @gol
488-mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol
630d3d5a 489-mschedule=@var{cpu-type} -mspace-regs}
74291a4b
MM
490
491@emph{Intel 960 Options}
4bc1997b 492@gccoptlist{
630d3d5a 493-m@var{cpu-type} -masm-compat -mclean-linkage @gol
4bc1997b
JM
494-mcode-align -mcomplex-addr -mleaf-procedures @gol
495-mic-compat -mic2.0-compat -mic3.0-compat @gol
496-mintel-asm -mno-clean-linkage -mno-code-align @gol
497-mno-complex-addr -mno-leaf-procedures @gol
498-mno-old-align -mno-strict-align -mno-tail-call @gol
499-mnumerics -mold-align -msoft-float -mstrict-align @gol
500-mtail-call}
74291a4b
MM
501
502@emph{DEC Alpha Options}
4bc1997b 503@gccoptlist{
310668e8
JM
504-mfp-regs -mno-fp-regs -mno-soft-float -msoft-float @gol
505-malpha-as -mgas @gol
4bc1997b
JM
506-mieee -mieee-with-inexact -mieee-conformant @gol
507-mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} @gol
508-mtrap-precision=@var{mode} -mbuild-constants @gol
630d3d5a 509-mcpu=@var{cpu-type} @gol
310668e8 510-mbwx -mno-bwx -mcix -mno-cix -mmax -mno-max @gol
4bc1997b 511-mmemory-latency=@var{time}}
74291a4b
MM
512
513@emph{Clipper Options}
4bc1997b
JM
514@gccoptlist{
515-mc300 -mc400}
74291a4b
MM
516
517@emph{H8/300 Options}
4bc1997b 518@gccoptlist{
310668e8 519-mrelax -mh -ms -mint32 -malign-300}
74291a4b
MM
520
521@emph{SH Options}
4bc1997b
JM
522@gccoptlist{
523-m1 -m2 -m3 -m3e @gol
524-m4-nofpu -m4-single-only -m4-single -m4 @gol
525-mb -ml -mdalign -mrelax @gol
526-mbigtable -mfmovd -mhitachi -mnomacsave @gol
c474f76b
AO
527-mieee -misize -mpadstruct -mspace @gol
528-mprefergot -musermode}
74291a4b
MM
529
530@emph{System V Options}
4bc1997b 531@gccoptlist{
aee96fe9 532-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
74291a4b 533
56b2d7a7 534@emph{ARC Options}
4bc1997b
JM
535@gccoptlist{
536-EB -EL @gol
630d3d5a
JM
537-mmangle-cpu -mcpu=@var{cpu} -mtext=@var{text-section} @gol
538-mdata=@var{data-section} -mrodata=@var{readonly-data-section}}
56b2d7a7 539
282a61e6 540@emph{TMS320C3x/C4x Options}
4bc1997b 541@gccoptlist{
310668e8
JM
542-mcpu=@var{cpu} -mbig -msmall -mregparm -mmemparm @gol
543-mfast-fix -mmpyi -mbk -mti -mdp-isr-reload @gol
544-mrpts=@var{count} -mrptb -mdb -mloop-unsigned @gol
545-mparallel-insns -mparallel-mpy -mpreserve-float}
282a61e6 546
f84271d9 547@emph{V850 Options}
4bc1997b 548@gccoptlist{
310668e8
JM
549-mlong-calls -mno-long-calls -mep -mno-ep @gol
550-mprolog-function -mno-prolog-function -mspace @gol
551-mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol
552-mv850 -mbig-switch}
83575957
ID
553
554@emph{NS32K Options}
4bc1997b 555@gccoptlist{
310668e8 556-m32032 -m32332 -m32532 -m32081 -m32381 @gol
feb48bde 557-mmult-add -mnomult-add -msoft-float -mrtd -mnortd @gol
310668e8
JM
558-mregparam -mnoregparam -msb -mnosb @gol
559-mbitfield -mnobitfield -mhimem -mnohimem}
789a3090 560
052a4b28 561@emph{AVR Options}
4bc1997b 562@gccoptlist{
310668e8
JM
563-mmcu=@var{mcu} -msize -minit-stack=@var{n} -mno-interrupts @gol
564-mcall-prologues -mno-tablejump -mtiny-stack}
052a4b28 565
789a3090 566@emph{MCore Options}
4bc1997b 567@gccoptlist{
feb48bde 568-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol
310668e8
JM
569-mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol
570-m4byte-functions -mno-4byte-functions -mcallgraph-data @gol
571-mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol
572-mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
f84271d9 573
df6194d4
JW
574@emph{IA-64 Options}
575@gccoptlist{
310668e8
JM
576-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol
577-mvolatile-asm-stop -mb-step -mregister-names -mno-sdata @gol
578-mconstant-gp -mauto-pic -minline-divide-min-latency @gol
579-minline-divide-max-throughput -mno-dwarf2-asm @gol
630d3d5a 580-mfixed-range=@var{register-range}}
df6194d4 581
91abf72d
HP
582@emph{S/390 and zSeries Options}
583@gccoptlist{
584-mhard-float -msoft-float -mbackchain -mno-backchain @gol
585-msmall-exec -mno-small-exec -mmvcle -mno-mvcle @gol
586-m64 -m31 -mdebug -mno-debug}
587
74291a4b
MM
588@item Code Generation Options
589@xref{Code Gen Options,,Options for Code Generation Conventions}.
4bc1997b
JM
590@gccoptlist{
591-fcall-saved-@var{reg} -fcall-used-@var{reg} @gol
6cfc0341
RH
592-ffixed-@var{reg} -fexceptions @gol
593-fnon-call-exceptions -funwind-tables @gol
4bc1997b
JM
594-finhibit-size-directive -finstrument-functions @gol
595-fcheck-memory-usage -fprefix-function-name @gol
596-fno-common -fno-ident -fno-gnu-linker @gol
597-fpcc-struct-return -fpic -fPIC @gol
598-freg-struct-return -fshared-data -fshort-enums @gol
310668e8
JM
599-fshort-double -fvolatile @gol
600-fvolatile-global -fvolatile-static @gol
4bc1997b
JM
601-fverbose-asm -fpack-struct -fstack-check @gol
602-fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol
603-fargument-alias -fargument-noalias @gol
310668e8 604-fargument-noalias-global -fleading-underscore}
74291a4b
MM
605@end table
606
607@menu
608* Overall Options:: Controlling the kind of output:
609 an executable, object files, assembler files,
610 or preprocessed source.
611* C Dialect Options:: Controlling the variant of C language compiled.
612* C++ Dialect Options:: Variations on C++.
60de6385 613* Objective-C Dialect Options:: Variations on Objective-C.
764dbbf2 614* Language Independent Options:: Controlling how diagnostics should be
02f52e19 615 formatted.
74291a4b
MM
616* Warning Options:: How picky should the compiler be?
617* Debugging Options:: Symbol tables, measurements, and debugging dumps.
618* Optimize Options:: How much optimization?
619* Preprocessor Options:: Controlling header files and macro definitions.
620 Also, getting dependency information for Make.
621* Assembler Options:: Passing options to the assembler.
622* Link Options:: Specifying libraries and so on.
623* Directory Options:: Where to find header files and libraries.
624 Where to find the compiler executable files.
a743d340 625* Spec Files:: How to pass switches to sub-processes.
0c2d1a2a 626* Target Options:: Running a cross-compiler, or an old version of GCC.
74291a4b
MM
627@end menu
628
629@node Overall Options
630@section Options Controlling the Kind of Output
631
632Compilation can involve up to four stages: preprocessing, compilation
633proper, assembly and linking, always in that order. The first three
634stages apply to an individual source file, and end by producing an
635object file; linking combines all the object files (those newly
636compiled, and those specified as input) into an executable file.
637
638@cindex file name suffix
639For any given input file, the file name suffix determines what kind of
640compilation is done:
641
2642624b 642@table @gcctabopt
74291a4b
MM
643@item @var{file}.c
644C source code which must be preprocessed.
645
646@item @var{file}.i
647C source code which should not be preprocessed.
648
649@item @var{file}.ii
650C++ source code which should not be preprocessed.
651
652@item @var{file}.m
653Objective-C source code. Note that you must link with the library
654@file{libobjc.a} to make an Objective-C program work.
655
b9265ec1
JM
656@item @var{file}.mi
657Objective-C source code which should not be preprocessed.
658
74291a4b
MM
659@item @var{file}.h
660C header file (not to be compiled or linked).
661
662@item @var{file}.cc
b9265ec1 663@itemx @var{file}.cp
74291a4b
MM
664@itemx @var{file}.cxx
665@itemx @var{file}.cpp
b9265ec1 666@itemx @var{file}.c++
74291a4b
MM
667@itemx @var{file}.C
668C++ source code which must be preprocessed. Note that in @samp{.cxx},
669the last two letters must both be literally @samp{x}. Likewise,
161d7b59 670@samp{.C} refers to a literal capital C@.
74291a4b 671
b9265ec1
JM
672@item @var{file}.f
673@itemx @var{file}.for
674@itemx @var{file}.FOR
675Fortran source code which should not be preprocessed.
676
677@item @var{file}.F
678@itemx @var{file}.fpp
679@itemx @var{file}.FPP
680Fortran source code which must be preprocessed (with the traditional
681preprocessor).
682
683@item @var{file}.r
684Fortran source code which must be preprocessed with a RATFOR
161d7b59 685preprocessor (not included with GCC)@.
b9265ec1
JM
686
687@xref{Overall Options,,Options Controlling the Kind of Output, g77,
688Using and Porting GNU Fortran}, for more details of the handling of
689Fortran input files.
690
691@c FIXME: Descriptions of Java file types.
692@c @var{file}.java
693@c @var{file}.class
694@c @var{file}.zip
695@c @var{file}.jar
696
697@c GCC also knows about some suffixes for languages not yet included:
698@c Ada:
699@c @var{file}.ads
700@c @var{file}.adb
701@c @var{file}.ada
702@c Pascal:
703@c @var{file}.p
704@c @var{file}.pas
705
706@item @var{file}.ch
707@itemx @var{file}.chi
708CHILL source code (preprocessed with the traditional preprocessor).
709
74291a4b
MM
710@item @var{file}.s
711Assembler code.
712
713@item @var{file}.S
714Assembler code which must be preprocessed.
715
716@item @var{other}
717An object file to be fed straight into linking.
718Any file name with no recognized suffix is treated this way.
719@end table
720
cd3bb277 721@opindex x
630d3d5a 722You can specify the input language explicitly with the @option{-x} option:
74291a4b 723
2642624b 724@table @gcctabopt
74291a4b
MM
725@item -x @var{language}
726Specify explicitly the @var{language} for the following input files
727(rather than letting the compiler choose a default based on the file
728name suffix). This option applies to all following input files until
630d3d5a 729the next @option{-x} option. Possible values for @var{language} are:
74291a4b 730@example
b9265ec1
JM
731c c-header cpp-output
732c++ c++-cpp-output
733objective-c objc-cpp-output
74291a4b 734assembler assembler-with-cpp
b9265ec1
JM
735f77 f77-cpp-input ratfor
736java chill
74291a4b 737@end example
b9265ec1 738@c Also f77-version, for internal use only.
74291a4b
MM
739
740@item -x none
741Turn off any specification of a language, so that subsequent files are
630d3d5a 742handled according to their file name suffixes (as they are if @option{-x}
74291a4b 743has not been used at all).
14a774a9
RK
744
745@item -pass-exit-codes
cd3bb277 746@opindex pass-exit-codes
bedc7537 747Normally the @command{gcc} program will exit with the code of 1 if any
14a774a9 748phase of the compiler returns a non-success return code. If you specify
630d3d5a 749@option{-pass-exit-codes}, the @command{gcc} program will instead return with
14a774a9
RK
750numerically highest error produced by any phase that returned an error
751indication.
74291a4b
MM
752@end table
753
754If you only want some of the stages of compilation, you can use
630d3d5a
JM
755@option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
756one of the options @option{-c}, @option{-S}, or @option{-E} to say where
bedc7537
NC
757@command{gcc} is to stop. Note that some combinations (for example,
758@samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
74291a4b 759
2642624b 760@table @gcctabopt
74291a4b 761@item -c
cd3bb277 762@opindex c
74291a4b
MM
763Compile or assemble the source files, but do not link. The linking
764stage simply is not done. The ultimate output is in the form of an
765object file for each source file.
766
767By default, the object file name for a source file is made by replacing
768the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
769
770Unrecognized input files, not requiring compilation or assembly, are
771ignored.
772
773@item -S
cd3bb277 774@opindex S
74291a4b
MM
775Stop after the stage of compilation proper; do not assemble. The output
776is in the form of an assembler code file for each non-assembler input
777file specified.
778
779By default, the assembler file name for a source file is made by
780replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
781
782Input files that don't require compilation are ignored.
783
784@item -E
cd3bb277 785@opindex E
74291a4b
MM
786Stop after the preprocessing stage; do not run the compiler proper. The
787output is in the form of preprocessed source code, which is sent to the
788standard output.
789
790Input files which don't require preprocessing are ignored.
791
792@cindex output file option
793@item -o @var{file}
cd3bb277 794@opindex o
74291a4b
MM
795Place output in file @var{file}. This applies regardless to whatever
796sort of output is being produced, whether it be an executable file,
797an object file, an assembler file or preprocessed C code.
798
799Since only one output file can be specified, it does not make sense to
630d3d5a 800use @option{-o} when compiling more than one input file, unless you are
74291a4b
MM
801producing an executable file as output.
802
630d3d5a 803If @option{-o} is not specified, the default is to put an executable file
74291a4b
MM
804in @file{a.out}, the object file for @file{@var{source}.@var{suffix}} in
805@file{@var{source}.o}, its assembler file in @file{@var{source}.s}, and
bd819a4a 806all preprocessed C source on standard output.
74291a4b
MM
807
808@item -v
cd3bb277 809@opindex v
74291a4b
MM
810Print (on standard error output) the commands executed to run the stages
811of compilation. Also print the version number of the compiler driver
812program and of the preprocessor and the compiler proper.
813
814@item -pipe
cd3bb277 815@opindex pipe
74291a4b
MM
816Use pipes rather than temporary files for communication between the
817various stages of compilation. This fails to work on some systems where
818the assembler is unable to read from a pipe; but the GNU assembler has
819no trouble.
844642e6
NC
820
821@item --help
cd3bb277 822@opindex help
844642e6 823Print (on the standard output) a description of the command line options
bedc7537
NC
824understood by @command{gcc}. If the @option{-v} option is also specified
825then @option{--help} will also be passed on to the various processes
826invoked by @command{gcc}, so that they can display the command line options
827they accept. If the @option{-W} option is also specified then command
844642e6
NC
828line options which have no documentation associated with them will also
829be displayed.
10501d8f
CC
830
831@item --target-help
cd3bb277 832@opindex target-help
10501d8f
CC
833Print (on the standard output) a description of target specific command
834line options for each tool.
74291a4b
MM
835@end table
836
837@node Invoking G++
838@section Compiling C++ Programs
839
840@cindex suffixes for C++ source
841@cindex C++ source file suffixes
842C++ source files conventionally use one of the suffixes @samp{.C},
bba975d4 843@samp{.cc}, @samp{.cpp}, @samp{.c++}, @samp{.cp}, or @samp{.cxx};
0c2d1a2a 844preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
bba975d4
JM
845files with these names and compiles them as C++ programs even if you
846call the compiler the same way as for compiling C programs (usually with
bedc7537 847the name @command{gcc}).
74291a4b
MM
848
849@findex g++
850@findex c++
851However, C++ programs often require class libraries as well as a
852compiler that understands the C++ language---and under some
853circumstances, you might want to compile programs from standard input,
854or otherwise without a suffix that flags them as C++ programs.
bedc7537 855@command{g++} is a program that calls GCC with the default language
e5e809f4 856set to C++, and automatically specifies linking against the C++
bedc7537
NC
857library. On many systems, @command{g++} is also
858installed with the name @command{c++}.
74291a4b 859
bedc7537 860@cindex invoking @command{g++}
74291a4b
MM
861When you compile C++ programs, you may specify many of the same
862command-line options that you use for compiling programs in any
863language; or command-line options meaningful for C and related
864languages; or options that are meaningful only for C++ programs.
865@xref{C Dialect Options,,Options Controlling C Dialect}, for
161d7b59 866explanations of options for languages related to C@.
74291a4b
MM
867@xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
868explanations of options that are meaningful only for C++ programs.
869
870@node C Dialect Options
871@section Options Controlling C Dialect
872@cindex dialect options
873@cindex language dialect options
874@cindex options, dialect
875
876The following options control the dialect of C (or languages derived
2147b154 877from C, such as C++ and Objective-C) that the compiler accepts:
74291a4b 878
2642624b 879@table @gcctabopt
74291a4b 880@cindex ANSI support
c1030c7c 881@cindex ISO support
74291a4b 882@item -ansi
cd3bb277 883@opindex ansi
c1030c7c 884In C mode, support all ISO C89 programs. In C++ mode,
775afb25 885remove GNU extensions that conflict with ISO C++.
74291a4b 886
c1030c7c 887This turns off certain features of GCC that are incompatible with ISO
aee96fe9 888C89 (when compiling C code), or of standard C++ (when compiling C++ code),
0c2d1a2a 889such as the @code{asm} and @code{typeof} keywords, and
74291a4b
MM
890predefined macros such as @code{unix} and @code{vax} that identify the
891type of system you are using. It also enables the undesirable and
02f52e19 892rarely used ISO trigraph feature. For the C compiler,
0c2d1a2a 893it disables recognition of C++ style @samp{//} comments as well as
775afb25 894the @code{inline} keyword.
74291a4b
MM
895
896The alternate keywords @code{__asm__}, @code{__extension__},
897@code{__inline__} and @code{__typeof__} continue to work despite
630d3d5a 898@option{-ansi}. You would not want to use them in an ISO C program, of
74291a4b 899course, but it is useful to put them in header files that might be included
630d3d5a 900in compilations done with @option{-ansi}. Alternate predefined macros
74291a4b 901such as @code{__unix__} and @code{__vax__} are also available, with or
630d3d5a 902without @option{-ansi}.
74291a4b 903
630d3d5a
JM
904The @option{-ansi} option does not cause non-ISO programs to be
905rejected gratuitously. For that, @option{-pedantic} is required in
906addition to @option{-ansi}. @xref{Warning Options}.
74291a4b 907
630d3d5a 908The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
74291a4b
MM
909option is used. Some header files may notice this macro and refrain
910from declaring certain functions or defining certain macros that the
c1030c7c 911ISO standard doesn't call for; this is to avoid interfering with any
74291a4b
MM
912programs that might use these names for other things.
913
c771326b
JM
914Functions which would normally be built in but do not have semantics
915defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
630d3d5a 916functions with @option{-ansi} is used. @xref{Other Builtins,,Other
f0523f02 917built-in functions provided by GCC}, for details of the functions
01702459 918affected.
74291a4b 919
49419c8f 920@item -std=
cd3bb277 921@opindex std
aee96fe9
JM
922Determine the language standard. This option is currently only
923supported when compiling C@. A value for this option must be provided;
02f52e19 924possible values are
3932261a 925
ee457005 926@table @samp
aee96fe9
JM
927@item c89
928@itemx iso9899:1990
929ISO C89 (same as @option{-ansi}).
3043b30e
ML
930
931@item iso9899:199409
aee96fe9 932ISO C89 as modified in amendment 1.
3043b30e 933
49419c8f 934@item c99
aee96fe9
JM
935@itemx c9x
936@itemx iso9899:1999
937@itemx iso9899:199x
938ISO C99. Note that this standard is not yet fully supported; see
939@w{@uref{http://gcc.gnu.org/c99status.html}} for more information. The
940names @samp{c9x} and @samp{iso9899:199x} are deprecated.
3043b30e
ML
941
942@item gnu89
aee96fe9 943Default, ISO C89 plus GNU extensions (including some C99 features).
3043b30e 944
49419c8f 945@item gnu99
7dac2f89 946@item gnu9x
d15a05b3
EC
947ISO C99 plus GNU extensions. When ISO C99 is fully implemented in GCC,
948this will become the default. The name @samp{gnu9x} is deprecated.
49419c8f 949
ee457005 950@end table
3043b30e
ML
951
952Even when this option is not specified, you can still use some of the
953features of newer standards in so far as they do not conflict with
954previous C standards. For example, you may use @code{__restrict__} even
bedc7537 955when @option{-std=c99} is not specified.
3932261a 956
5490d604
JM
957The @option{-std} options specifying some version of ISO C have the same
958effects as @option{-ansi}, except that features that were not in ISO C89
959but are in the specified version (for example, @samp{//} comments and
960the @code{inline} keyword in ISO C99) are not disabled.
961
c1030c7c
JM
962@xref{Standards,,Language Standards Supported by GCC}, for details of
963these standard versions.
964
b1018de6
AO
965@item -aux-info @var{filename}
966@opindex aux-info
967Output to the given filename prototyped declarations for all functions
968declared and/or defined in a translation unit, including those in header
161d7b59 969files. This option is silently ignored in any language other than C@.
b1018de6
AO
970
971Besides declarations, the file indicates, in comments, the origin of
972each declaration (source file and line), whether the declaration was
973implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
974@samp{O} for old, respectively, in the first character after the line
975number and the colon), and whether it came from a declaration or a
976definition (@samp{C} or @samp{F}, respectively, in the following
977character). In the case of function definitions, a K&R-style list of
978arguments followed by their declarations is also provided, inside
979comments, after the declaration.
980
74291a4b 981@item -fno-asm
cd3bb277 982@opindex fno-asm
74291a4b
MM
983Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
984keyword, so that code can use these words as identifiers. You can use
985the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
630d3d5a 986instead. @option{-ansi} implies @option{-fno-asm}.
74291a4b
MM
987
988In C++, this switch only affects the @code{typeof} keyword, since
989@code{asm} and @code{inline} are standard keywords. You may want to
630d3d5a 990use the @option{-fno-gnu-keywords} flag instead, which has the same
5490d604
JM
991effect. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), this
992switch only affects the @code{asm} and @code{typeof} keywords, since
993@code{inline} is a standard keyword in ISO C99.
74291a4b
MM
994
995@item -fno-builtin
cd3bb277 996@opindex fno-builtin
c771326b
JM
997@cindex built-in functions
998Don't recognize built-in functions that do not begin with
01702459 999@samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
f0523f02 1000functions provided by GCC}, for details of the functions affected,
c771326b 1001including those which are not built-in functions when @option{-ansi} or
5490d604
JM
1002@option{-std} options for strict ISO C conformance are used because they
1003do not have an ISO standard meaning.
74291a4b 1004
c771326b 1005GCC normally generates special code to handle certain built-in functions
74291a4b
MM
1006more efficiently; for instance, calls to @code{alloca} may become single
1007instructions that adjust the stack directly, and calls to @code{memcpy}
1008may become inline copy loops. The resulting code is often both smaller
1009and faster, but since the function calls no longer appear as such, you
1010cannot set a breakpoint on those calls, nor can you change the behavior
1011of the functions by linking with a different library.
1012
630d3d5a 1013In C++, @option{-fno-builtin} is always in effect. The @option{-fbuiltin}
0b1161fc 1014option has no effect. Therefore, in C++, the only way to get the
c771326b 1015optimization benefits of built-in functions is to call the function
0b1161fc 1016using the @samp{__builtin_} prefix. The GNU C++ Standard Library uses
c771326b 1017built-in functions to implement many functions (like
0b1161fc
MM
1018@code{std::strchr}), so that you automatically get efficient code.
1019
861bb6c1 1020@item -fhosted
cd3bb277 1021@opindex fhosted
861bb6c1
JL
1022@cindex hosted environment
1023
1024Assert that compilation takes place in a hosted environment. This implies
630d3d5a 1025@option{-fbuiltin}. A hosted environment is one in which the
861bb6c1
JL
1026entire standard library is available, and in which @code{main} has a return
1027type of @code{int}. Examples are nearly everything except a kernel.
630d3d5a 1028This is equivalent to @option{-fno-freestanding}.
861bb6c1
JL
1029
1030@item -ffreestanding
cd3bb277 1031@opindex ffreestanding
861bb6c1
JL
1032@cindex hosted environment
1033
1034Assert that compilation takes place in a freestanding environment. This
630d3d5a 1035implies @option{-fno-builtin}. A freestanding environment
861bb6c1
JL
1036is one in which the standard library may not exist, and program startup may
1037not necessarily be at @code{main}. The most obvious example is an OS kernel.
630d3d5a 1038This is equivalent to @option{-fno-hosted}.
861bb6c1 1039
c1030c7c
JM
1040@xref{Standards,,Language Standards Supported by GCC}, for details of
1041freestanding and hosted environments.
1042
74291a4b 1043@item -trigraphs
cd3bb277 1044@opindex trigraphs
3bce8a01
NB
1045Support ISO C trigraphs. The @option{-ansi} option (and @option{-std}
1046options for strict ISO C conformance) implies @option{-trigraphs}.
74291a4b
MM
1047
1048@cindex traditional C language
1049@cindex C language, traditional
1050@item -traditional
cd3bb277 1051@opindex traditional
74291a4b
MM
1052Attempt to support some aspects of traditional C compilers.
1053Specifically:
1054
1055@itemize @bullet
1056@item
1057All @code{extern} declarations take effect globally even if they
1058are written inside of a function definition. This includes implicit
1059declarations of functions.
1060
1061@item
1062The newer keywords @code{typeof}, @code{inline}, @code{signed}, @code{const}
1063and @code{volatile} are not recognized. (You can still use the
1064alternative keywords such as @code{__typeof__}, @code{__inline__}, and
1065so on.)
1066
1067@item
1068Comparisons between pointers and integers are always allowed.
1069
1070@item
1071Integer types @code{unsigned short} and @code{unsigned char} promote
1072to @code{unsigned int}.
1073
1074@item
1075Out-of-range floating point literals are not an error.
1076
1077@item
c1030c7c 1078Certain constructs which ISO regards as a single invalid preprocessing
74291a4b
MM
1079number, such as @samp{0xe-0xd}, are treated as expressions instead.
1080
1081@item
1082String ``constants'' are not necessarily constant; they are stored in
1083writable space, and identical looking constants are allocated
1084separately. (This is the same as the effect of
630d3d5a 1085@option{-fwritable-strings}.)
74291a4b
MM
1086
1087@cindex @code{longjmp} and automatic variables
1088@item
1089All automatic variables not declared @code{register} are preserved by
c1030c7c 1090@code{longjmp}. Ordinarily, GNU C follows ISO C: automatic variables
74291a4b
MM
1091not declared @code{volatile} may be clobbered.
1092
1093@item
cd3bb277
JM
1094@cindex @samp{\x}
1095@cindex @samp{\a}
74291a4b
MM
1096@cindex escape sequences, traditional
1097The character escape sequences @samp{\x} and @samp{\a} evaluate as the
1098literal characters @samp{x} and @samp{a} respectively. Without
630d3d5a 1099@w{@option{-traditional}}, @samp{\x} is a prefix for the hexadecimal
74291a4b 1100representation of a character, and @samp{\a} produces a bell.
ad299d9b 1101@end itemize
74291a4b 1102
630d3d5a 1103You may wish to use @option{-fno-builtin} as well as @option{-traditional}
c771326b 1104if your program uses names that are normally GNU C built-in functions for
74291a4b
MM
1105other purposes of its own.
1106
630d3d5a 1107You cannot use @option{-traditional} if you include any header files that
c1030c7c 1108rely on ISO C features. Some vendors are starting to ship systems with
630d3d5a 1109ISO C header files and you cannot use @option{-traditional} on such
74291a4b
MM
1110systems to compile files that include any system headers.
1111
9c34dbbf 1112The @option{-traditional} option also enables @option{-traditional-cpp}.
74291a4b
MM
1113
1114@item -traditional-cpp
cd3bb277 1115@opindex traditional-cpp
74291a4b 1116Attempt to support some aspects of traditional C preprocessors.
9c34dbbf 1117See the GNU CPP manual for details.
74291a4b
MM
1118
1119@item -fcond-mismatch
cd3bb277 1120@opindex fcond-mismatch
74291a4b 1121Allow conditional expressions with mismatched types in the second and
a7537031
JM
1122third arguments. The value of such an expression is void. This option
1123is not supported for C++.
74291a4b
MM
1124
1125@item -funsigned-char
cd3bb277 1126@opindex funsigned-char
74291a4b
MM
1127Let the type @code{char} be unsigned, like @code{unsigned char}.
1128
1129Each kind of machine has a default for what @code{char} should
1130be. It is either like @code{unsigned char} by default or like
1131@code{signed char} by default.
1132
1133Ideally, a portable program should always use @code{signed char} or
1134@code{unsigned char} when it depends on the signedness of an object.
1135But many programs have been written to use plain @code{char} and
1136expect it to be signed, or expect it to be unsigned, depending on the
1137machines they were written for. This option, and its inverse, let you
1138make such a program work with the opposite default.
1139
1140The type @code{char} is always a distinct type from each of
1141@code{signed char} or @code{unsigned char}, even though its behavior
1142is always just like one of those two.
1143
1144@item -fsigned-char
cd3bb277 1145@opindex fsigned-char
74291a4b
MM
1146Let the type @code{char} be signed, like @code{signed char}.
1147
630d3d5a
JM
1148Note that this is equivalent to @option{-fno-unsigned-char}, which is
1149the negative form of @option{-funsigned-char}. Likewise, the option
1150@option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
74291a4b 1151
74291a4b
MM
1152@item -fsigned-bitfields
1153@itemx -funsigned-bitfields
1154@itemx -fno-signed-bitfields
1155@itemx -fno-unsigned-bitfields
cd3bb277
JM
1156@opindex fsigned-bitfields
1157@opindex funsigned-bitfields
1158@opindex fno-signed-bitfields
1159@opindex fno-unsigned-bitfields
c771326b 1160These options control whether a bit-field is signed or unsigned, when the
74291a4b 1161declaration does not use either @code{signed} or @code{unsigned}. By
c771326b 1162default, such a bit-field is signed, because this is consistent: the
74291a4b
MM
1163basic integer types such as @code{int} are signed types.
1164
c771326b 1165However, when @option{-traditional} is used, bit-fields are all unsigned
74291a4b
MM
1166no matter what.
1167
1168@item -fwritable-strings
cd3bb277 1169@opindex fwritable-strings
74291a4b
MM
1170Store string constants in the writable data segment and don't uniquize
1171them. This is for compatibility with old programs which assume they can
630d3d5a 1172write into string constants. The option @option{-traditional} also has
74291a4b
MM
1173this effect.
1174
1175Writing into string constants is a very bad idea; ``constants'' should
1176be constant.
1177
1178@item -fallow-single-precision
cd3bb277 1179@opindex fallow-single-precision
74291a4b 1180Do not promote single precision math operations to double precision,
630d3d5a 1181even when compiling with @option{-traditional}.
74291a4b
MM
1182
1183Traditional K&R C promotes all floating point operations to double
1184precision, regardless of the sizes of the operands. On the
1185architecture for which you are compiling, single precision may be faster
630d3d5a 1186than double precision. If you must use @option{-traditional}, but want
74291a4b
MM
1187to use single precision operations when the operands are single
1188precision, use this option. This option has no effect when compiling
c1030c7c 1189with ISO or GNU C conventions (the default).
74291a4b 1190
3e37bef5 1191@item -fshort-wchar
cd3bb277 1192@opindex fshort-wchar
3e37bef5
JM
1193Override the underlying type for @samp{wchar_t} to be @samp{short
1194unsigned int} instead of the default for the target. This option is
161d7b59 1195useful for building programs to run under WINE@.
74291a4b
MM
1196@end table
1197
1198@node C++ Dialect Options
1199@section Options Controlling C++ Dialect
1200
1201@cindex compiler options, C++
1202@cindex C++ options, command line
1203@cindex options, C++
1204This section describes the command-line options that are only meaningful
1205for C++ programs; but you can also use most of the GNU compiler options
1206regardless of what language your program is in. For example, you
1207might compile a file @code{firstClass.C} like this:
1208
1209@example
1dc5fc4b 1210g++ -g -frepo -O -c firstClass.C
74291a4b
MM
1211@end example
1212
1213@noindent
630d3d5a 1214In this example, only @option{-frepo} is an option meant
74291a4b 1215only for C++ programs; you can use the other options with any
161d7b59 1216language supported by GCC@.
74291a4b
MM
1217
1218Here is a list of options that are @emph{only} for compiling C++ programs:
1219
2642624b 1220@table @gcctabopt
74291a4b 1221@item -fno-access-control
cd3bb277 1222@opindex fno-access-control
74291a4b
MM
1223Turn off all access checking. This switch is mainly useful for working
1224around bugs in the access control code.
1225
74291a4b 1226@item -fcheck-new
cd3bb277 1227@opindex fcheck-new
74291a4b
MM
1228Check that the pointer returned by @code{operator new} is non-null
1229before attempting to modify the storage allocated. The current Working
1230Paper requires that @code{operator new} never return a null pointer, so
1231this check is normally unnecessary.
1232
1dc5fc4b
JM
1233An alternative to using this option is to specify that your
1234@code{operator new} does not throw any exceptions; if you declare it
aee96fe9 1235@samp{throw()}, G++ will check the return value. See also @samp{new
1dc5fc4b
JM
1236(nothrow)}.
1237
74291a4b 1238@item -fconserve-space
cd3bb277 1239@opindex fconserve-space
74291a4b
MM
1240Put uninitialized or runtime-initialized global variables into the
1241common segment, as C does. This saves space in the executable at the
1242cost of not diagnosing duplicate definitions. If you compile with this
1243flag and your program mysteriously crashes after @code{main()} has
1244completed, you may have an object that is being destroyed twice because
1245two definitions were merged.
1246
1dc5fc4b
JM
1247This option is no longer useful on most targets, now that support has
1248been added for putting variables into BSS without making them common.
1249
02f52e19 1250@item -fno-const-strings
cd3bb277 1251@opindex fno-const-strings
fcca588c
MM
1252Give string constants type @code{char *} instead of type @code{const
1253char *}. By default, G++ uses type @code{const char *} as required by
630d3d5a 1254the standard. Even if you use @option{-fno-const-strings}, you cannot
fcca588c 1255actually modify the value of a string constant, unless you also use
630d3d5a 1256@option{-fwritable-strings}.
fcca588c
MM
1257
1258This option might be removed in a future release of G++. For maximum
1259portability, you should structure your code so that it works with
1260string constants that have type @code{const char *}.
1261
74291a4b 1262@item -fdollars-in-identifiers
cd3bb277 1263@opindex fdollars-in-identifiers
74291a4b 1264Accept @samp{$} in identifiers. You can also explicitly prohibit use of
630d3d5a 1265@samp{$} with the option @option{-fno-dollars-in-identifiers}. (GNU C allows
eb795509 1266@samp{$} by default on most target systems, but there are a few exceptions.)
74291a4b 1267Traditional C allowed the character @samp{$} to form part of
c1030c7c 1268identifiers. However, ISO C and C++ forbid @samp{$} in identifiers.
74291a4b 1269
1dc5fc4b 1270@item -fno-elide-constructors
cd3bb277 1271@opindex fno-elide-constructors
1dc5fc4b
JM
1272The C++ standard allows an implementation to omit creating a temporary
1273which is only used to initialize another object of the same type.
aee96fe9 1274Specifying this option disables that optimization, and forces G++ to
1dc5fc4b 1275call the copy constructor in all cases.
74291a4b 1276
dd1ba632 1277@item -fno-enforce-eh-specs
cd3bb277 1278@opindex fno-enforce-eh-specs
dd1ba632
JM
1279Don't check for violation of exception specifications at runtime. This
1280option violates the C++ standard, but may be useful for reducing code
1281size in production builds, much like defining @samp{NDEBUG}. The compiler
1282will still optimize based on the exception specifications.
1283
74291a4b 1284@item -fexternal-templates
cd3bb277 1285@opindex fexternal-templates
9c34dbbf
ZW
1286
1287Cause @samp{#pragma interface} and @samp{implementation} to apply to
1288template instantiation; template instances are emitted or not according
74291a4b
MM
1289to the location of the template definition. @xref{Template
1290Instantiation}, for more information.
1291
37f6b6bf
MM
1292This option is deprecated.
1293
74291a4b 1294@item -falt-external-templates
cd3bb277 1295@opindex falt-external-templates
9c34dbbf
ZW
1296Similar to @option{-fexternal-templates}, but template instances are
1297emitted or not according to the place where they are first instantiated.
74291a4b
MM
1298@xref{Template Instantiation}, for more information.
1299
37f6b6bf
MM
1300This option is deprecated.
1301
74291a4b 1302@item -ffor-scope
8c81598d 1303@itemx -fno-for-scope
cd3bb277
JM
1304@opindex ffor-scope
1305@opindex fno-for-scope
695ac33f 1306If @option{-ffor-scope} is specified, the scope of variables declared in
74291a4b 1307a @i{for-init-statement} is limited to the @samp{for} loop itself,
34527c47 1308as specified by the C++ standard.
695ac33f 1309If @option{-fno-for-scope} is specified, the scope of variables declared in
74291a4b 1310a @i{for-init-statement} extends to the end of the enclosing scope,
aee96fe9 1311as was the case in old versions of G++, and other (traditional)
74291a4b
MM
1312implementations of C++.
1313
1314The default if neither flag is given to follow the standard,
1315but to allow and give a warning for old-style code that would
1316otherwise be invalid, or have different behavior.
1317
1318@item -fno-gnu-keywords
cd3bb277 1319@opindex fno-gnu-keywords
9762e8a4 1320Do not recognize @code{typeof} as a keyword, so that code can use this
767094dd 1321word as an identifier. You can use the keyword @code{__typeof__} instead.
630d3d5a 1322@option{-ansi} implies @option{-fno-gnu-keywords}.
74291a4b 1323
1dc5fc4b 1324@item -fno-implicit-templates
cd3bb277 1325@opindex fno-implicit-templates
bba975d4 1326Never emit code for non-inline templates which are instantiated
e979f9e8 1327implicitly (i.e.@: by use); only emit code for explicit instantiations.
bba975d4
JM
1328@xref{Template Instantiation}, for more information.
1329
1330@item -fno-implicit-inline-templates
cd3bb277 1331@opindex fno-implicit-inline-templates
bba975d4
JM
1332Don't emit code for implicit instantiations of inline templates, either.
1333The default is to handle inlines differently so that compiles with and
1334without optimization will need the same set of explicit instantiations.
1dc5fc4b 1335
74291a4b 1336@item -fno-implement-inlines
cd3bb277 1337@opindex fno-implement-inlines
74291a4b
MM
1338To save space, do not emit out-of-line copies of inline functions
1339controlled by @samp{#pragma implementation}. This will cause linker
1340errors if these functions are not inlined everywhere they are called.
1341
631cf95d 1342@item -fms-extensions
cd3bb277 1343@opindex fms-extensions
32fb1fb2
PE
1344Disable pedantic warnings about constructs used in MFC, such as implicit
1345int and getting a pointer to member function via non-standard syntax.
631cf95d 1346
fcca588c 1347@item -fno-nonansi-builtins
cd3bb277 1348@opindex fno-nonansi-builtins
c771326b 1349Disable built-in declarations of functions that are not mandated by
161d7b59 1350ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
fcca588c
MM
1351@code{index}, @code{bzero}, @code{conjf}, and other related functions.
1352
775afb25 1353@item -fno-operator-names
cd3bb277 1354@opindex fno-operator-names
775afb25 1355Do not treat the operator name keywords @code{and}, @code{bitand},
74291a4b 1356@code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
775afb25 1357synonyms as keywords.
74291a4b 1358
4f8b4fd9 1359@item -fno-optional-diags
cd3bb277 1360@opindex fno-optional-diags
4f8b4fd9 1361Disable diagnostics that the standard says a compiler does not need to
aee96fe9 1362issue. Currently, the only such diagnostic issued by G++ is the one for
bba975d4 1363a name having multiple meanings within a class.
4f8b4fd9 1364
8c7707b0 1365@item -fpermissive
cd3bb277 1366@opindex fpermissive
8c7707b0 1367Downgrade messages about nonconformant code from errors to warnings. By
aee96fe9 1368default, G++ effectively sets @option{-pedantic-errors} without
630d3d5a 1369@option{-pedantic}; this option reverses that. This behavior and this
161d7b59 1370option are superseded by @option{-pedantic}, which works as it does for GNU C@.
8c7707b0 1371
8c81598d 1372@item -frepo
cd3bb277 1373@opindex frepo
9c34dbbf
ZW
1374Enable automatic template instantiation at link time. This option also
1375implies @option{-fno-implicit-templates}. @xref{Template
1376Instantiation}, for more information.
8c81598d 1377
8c7707b0 1378@item -fno-rtti
cd3bb277 1379@opindex fno-rtti
a7fbfcf9
JM
1380Disable generation of information about every class with virtual
1381functions for use by the C++ runtime type identification features
1382(@samp{dynamic_cast} and @samp{typeid}). If you don't use those parts
1383of the language, you can save some space by using this flag. Note that
1384exception handling uses the same information, but it will generate it as
1385needed.
8c7707b0 1386
fcca588c 1387@item -fstats
cd3bb277 1388@opindex fstats
fcca588c
MM
1389Emit statistics about front-end processing at the end of the compilation.
1390This information is generally only useful to the G++ development team.
1391
1dc5fc4b 1392@item -ftemplate-depth-@var{n}
cd3bb277 1393@opindex ftemplate-depth
1dc5fc4b
JM
1394Set the maximum instantiation depth for template classes to @var{n}.
1395A limit on the template instantiation depth is needed to detect
767094dd 1396endless recursions during template class instantiation. ANSI/ISO C++
1dc5fc4b
JM
1397conforming programs must not rely on a maximum depth greater than 17.
1398
fc693822 1399@item -fuse-cxa-atexit
cd3bb277 1400@opindex fuse-cxa-atexit
fc693822
MM
1401Register destructors for objects with static storage duration with the
1402@code{__cxa_atexit} function rather than the @code{atexit} function.
1403This option is required for fully standards-compliant handling of static
1404destructors, but will only work if your C library supports
1405@code{__cxa_atexit}.
1406
90ecce3e 1407@item -fvtable-gc
cd3bb277 1408@opindex fvtable-gc
90ecce3e
JM
1409Emit special relocations for vtables and virtual function references
1410so that the linker can identify unused virtual functions and zero out
1411vtable slots that refer to them. This is most useful with
630d3d5a 1412@option{-ffunction-sections} and @option{-Wl,--gc-sections}, in order to
90ecce3e 1413also discard the functions themselves.
f5a1b0d2 1414
90ecce3e 1415This optimization requires GNU as and GNU ld. Not all systems support
630d3d5a 1416this option. @option{-Wl,--gc-sections} is ignored without @option{-static}.
861bb6c1 1417
02f52e19 1418@item -fno-weak
cd3bb277 1419@opindex fno-weak
90ecce3e 1420Do not use weak symbol support, even if it is provided by the linker.
fcca588c
MM
1421By default, G++ will use weak symbols if they are available. This
1422option exists only for testing, and should not be used by end-users;
1423it will result in inferior code and has no benefits. This option may
1424be removed in a future release of G++.
1425
74291a4b 1426@item -nostdinc++
cd3bb277 1427@opindex nostdinc++
74291a4b
MM
1428Do not search for header files in the standard directories specific to
1429C++, but do still search the other standard directories. (This option
e5e809f4 1430is used when building the C++ library.)
74291a4b
MM
1431@end table
1432
1433In addition, these optimization, warning, and code generation options
1434have meanings only for C++ programs:
1435
2642624b 1436@table @gcctabopt
74291a4b 1437@item -fno-default-inline
cd3bb277 1438@opindex fno-default-inline
74291a4b 1439Do not assume @samp{inline} for functions defined inside a class scope.
1dc5fc4b
JM
1440@xref{Optimize Options,,Options That Control Optimization}. Note that these
1441functions will have linkage like inline functions; they just won't be
1442inlined by default.
74291a4b 1443
aee96fe9 1444@item -Wctor-dtor-privacy @r{(C++ only)}
cd3bb277 1445@opindex Wctor-dtor-privacy
bba975d4
JM
1446Warn when a class seems unusable, because all the constructors or
1447destructors in a class are private and the class has no friends or
1448public static member functions.
1449
aee96fe9 1450@item -Wnon-virtual-dtor @r{(C++ only)}
cd3bb277 1451@opindex Wnon-virtual-dtor
bba975d4
JM
1452Warn when a class declares a non-virtual destructor that should probably
1453be virtual, because it looks like the class will be used polymorphically.
1454
aee96fe9 1455@item -Wreorder @r{(C++ only)}
cd3bb277 1456@opindex Wreorder
bba975d4
JM
1457@cindex reordering, warning
1458@cindex warning for reordering of member initializers
1459Warn when the order of member initializers given in the code does not
1460match the order in which they must be executed. For instance:
1461
1462@smallexample
1463struct A @{
1464 int i;
1465 int j;
1466 A(): j (0), i (1) @{ @}
1467@};
1468@end smallexample
1469
1470Here the compiler will warn that the member initializers for @samp{i}
1471and @samp{j} will be rearranged to match the declaration order of the
1472members.
1473@end table
1474
630d3d5a 1475The following @option{-W@dots{}} options are not affected by @option{-Wall}.
bba975d4 1476
2642624b 1477@table @gcctabopt
aee96fe9 1478@item -Weffc++ @r{(C++ only)}
cd3bb277 1479@opindex Weffc++
bba975d4
JM
1480Warn about violations of various style guidelines from Scott Meyers'
1481@cite{Effective C++} books. If you use this option, you should be aware
1482that the standard library headers do not obey all of these guidelines;
1483you can use @samp{grep -v} to filter out those warnings.
1484
aee96fe9 1485@item -Wno-deprecated @r{(C++ only)}
cd3bb277 1486@opindex Wno-deprecated
767094dd 1487Do not warn about usage of deprecated features. @xref{Deprecated Features}.
2de45c06 1488
aee96fe9 1489@item -Wno-non-template-friend @r{(C++ only)}
cd3bb277 1490@opindex Wno-non-template-friend
bba975d4 1491Disable warnings when non-templatized friend functions are declared
767094dd 1492within a template. With the advent of explicit template specification
aee96fe9 1493support in G++, if the name of the friend is an unqualified-id (i.e.,
bba975d4 1494@samp{friend foo(int)}), the C++ language specification demands that the
767094dd 1495friend declare or define an ordinary, nontemplate function. (Section
aee96fe9 149614.5.3). Before G++ implemented explicit specification, unqualified-ids
bba975d4 1497could be interpreted as a particular specialization of a templatized
767094dd 1498function. Because this non-conforming behavior is no longer the default
aee96fe9 1499behavior for G++, @option{-Wnon-template-friend} allows the compiler to
bba975d4 1500check existing code for potential trouble spots, and is on by default.
2228d450 1501This new compiler behavior can be turned off with
630d3d5a 1502@option{-Wno-non-template-friend} which keeps the conformant compiler code
2228d450 1503but disables the helpful warning.
bba975d4 1504
aee96fe9 1505@item -Wold-style-cast @r{(C++ only)}
cd3bb277 1506@opindex Wold-style-cast
bba975d4
JM
1507Warn if an old-style (C-style) cast is used within a C++ program. The
1508new-style casts (@samp{static_cast}, @samp{reinterpret_cast}, and
90ecce3e
JM
1509@samp{const_cast}) are less vulnerable to unintended effects, and much
1510easier to grep for.
bba975d4 1511
aee96fe9 1512@item -Woverloaded-virtual @r{(C++ only)}
cd3bb277 1513@opindex Woverloaded-virtual
bba975d4
JM
1514@cindex overloaded virtual fn, warning
1515@cindex warning for overloaded virtual fn
3747f3dc
MM
1516Warn when a function declaration hides virtual functions from a
1517base class. For example, in:
1518
1519@smallexample
1520struct A @{
1521 virtual void f();
1522@};
1523
1524struct B: public A @{
1525 void f(int);
1526@};
1527@end smallexample
1528
1529the @code{A} class version of @code{f} is hidden in @code{B}, and code
1530like this:
1531
1532@smallexample
1533B* b;
1534b->f();
1535@end smallexample
1536
1537will fail to compile.
bba975d4 1538
aee96fe9 1539@item -Wno-pmf-conversions @r{(C++ only)}
cd3bb277 1540@opindex Wno-pmf-conversions
bba975d4
JM
1541Disable the diagnostic for converting a bound pointer to member function
1542to a plain pointer.
1543
aee96fe9 1544@item -Wsign-promo @r{(C++ only)}
cd3bb277 1545@opindex Wsign-promo
bba975d4
JM
1546Warn when overload resolution chooses a promotion from unsigned or
1547enumeral type to a signed type over a conversion to an unsigned type of
aee96fe9 1548the same size. Previous versions of G++ would try to preserve
bba975d4
JM
1549unsignedness, but the standard mandates the current behavior.
1550
aee96fe9 1551@item -Wsynth @r{(C++ only)}
cd3bb277 1552@opindex Wsynth
bba975d4
JM
1553@cindex warning for synthesized methods
1554@cindex synthesized methods, warning
aee96fe9 1555Warn when G++'s synthesis behavior does not match that of cfront. For
bba975d4
JM
1556instance:
1557
1558@smallexample
1559struct A @{
1560 operator int ();
1561 A& operator = (int);
1562@};
1563
1564main ()
1565@{
1566 A a,b;
1567 a = b;
1568@}
1569@end smallexample
74291a4b 1570
aee96fe9 1571In this example, G++ will synthesize a default @samp{A& operator =
bba975d4 1572(const A&);}, while cfront will use the user-defined @samp{operator =}.
74291a4b
MM
1573@end table
1574
60de6385
SS
1575@node Objective-C Dialect Options
1576@section Options Controlling Objective-C Dialect
1577
1578@cindex compiler options, Objective-C
1579@cindex Objective-C options, command line
1580@cindex options, Objective-C
1581This section describes the command-line options that are only meaningful
1582for Objective-C programs; but you can also use most of the GNU compiler
1583options regardless of what language your program is in. For example,
1584you might compile a file @code{some_class.m} like this:
1585
1586@example
1587gcc -g -fgnu-runtime -O -c some_class.m
1588@end example
1589
1590@noindent
630d3d5a 1591In this example, only @option{-fgnu-runtime} is an option meant only for
60de6385 1592Objective-C programs; you can use the other options with any language
161d7b59 1593supported by GCC@.
60de6385
SS
1594
1595Here is a list of options that are @emph{only} for compiling Objective-C
1596programs:
1597
1598@table @gcctabopt
630d3d5a 1599@item -fconstant-string-class=@var{class-name}
cd3bb277 1600@opindex fconstant-string-class
630d3d5a 1601Use @var{class-name} as the name of the class to instantiate for each
695ac33f 1602literal string specified with the syntax @code{@@"@dots{}"}. The default
60de6385
SS
1603class name is @code{NXConstantString}.
1604
1605@item -fgnu-runtime
cd3bb277 1606@opindex fgnu-runtime
60de6385
SS
1607Generate object code compatible with the standard GNU Objective-C
1608runtime. This is the default for most types of systems.
1609
1610@item -fnext-runtime
cd3bb277 1611@opindex fnext-runtime
60de6385 1612Generate output compatible with the NeXT runtime. This is the default
161d7b59 1613for NeXT-based systems, including Darwin and Mac OS X@.
60de6385
SS
1614
1615@item -gen-decls
cd3bb277 1616@opindex gen-decls
60de6385
SS
1617Dump interface declarations for all classes seen in the source file to a
1618file named @file{@var{sourcename}.decl}.
1619
1620@item -Wno-protocol
cd3bb277 1621@opindex Wno-protocol
60de6385
SS
1622Do not warn if methods required by a protocol are not implemented
1623in the class adopting it.
1624
1625@item -Wselector
cd3bb277 1626@opindex Wselector
60de6385
SS
1627Warn if a selector has multiple methods of different types defined.
1628
1629@c not documented because only avail via -Wp
1630@c @item -print-objc-runtime-info
1631
1632@end table
1633
764dbbf2
GDR
1634@node Language Independent Options
1635@section Options to Control Diagnostic Messages Formatting
1636@cindex options to control diagnostics formatting
1637@cindex diagnostic messages
1638@cindex message formatting
1639
b192711e 1640Traditionally, diagnostic messages have been formatted irrespective of
e979f9e8 1641the output device's aspect (e.g.@: its width, @dots{}). The options described
764dbbf2 1642below can be used to control the diagnostic messages formatting
e979f9e8 1643algorithm, e.g.@: how many characters per line, how often source location
6c0a4eab 1644information should be reported. Right now, only the C++ front end can
764dbbf2 1645honor these options. However it is expected, in the near future, that
6c0a4eab 1646the remaining front ends would be able to digest them correctly.
764dbbf2 1647
2642624b 1648@table @gcctabopt
764dbbf2 1649@item -fmessage-length=@var{n}
cd3bb277 1650@opindex fmessage-length
764dbbf2 1651Try to format error messages so that they fit on lines of about @var{n}
aee96fe9 1652characters. The default is 72 characters for @command{g++} and 0 for the rest of
161d7b59 1653the front ends supported by GCC@. If @var{n} is zero, then no
02f52e19 1654line-wrapping will be done; each error message will appear on a single
764dbbf2
GDR
1655line.
1656
cd3bb277 1657@opindex fdiagnostics-show-location
764dbbf2 1658@item -fdiagnostics-show-location=once
b192711e 1659Only meaningful in line-wrapping mode. Instructs the diagnostic messages
764dbbf2
GDR
1660reporter to emit @emph{once} source location information; that is, in
1661case the message is too long to fit on a single physical line and has to
1662be wrapped, the source location won't be emitted (as prefix) again,
1663over and over, in subsequent continuation lines. This is the default
02f52e19 1664behaviour.
764dbbf2
GDR
1665
1666@item -fdiagnostics-show-location=every-line
1667Only meaningful in line-wrapping mode. Instructs the diagnostic
1668messages reporter to emit the same source location information (as
1669prefix) for physical lines that result from the process of breaking a
b192711e 1670a message which is too long to fit on a single line.
764dbbf2
GDR
1671
1672@end table
1673
74291a4b
MM
1674@node Warning Options
1675@section Options to Request or Suppress Warnings
1676@cindex options to control warnings
1677@cindex warning messages
1678@cindex messages, warning
1679@cindex suppressing warnings
1680
1681Warnings are diagnostic messages that report constructions which
1682are not inherently erroneous but which are risky or suggest there
1683may have been an error.
1684
1685You can request many specific warnings with options beginning @samp{-W},
630d3d5a 1686for example @option{-Wimplicit} to request warnings on implicit
74291a4b
MM
1687declarations. Each of these specific warning options also has a
1688negative form beginning @samp{-Wno-} to turn off warnings;
630d3d5a 1689for example, @option{-Wno-implicit}. This manual lists only one of the
74291a4b
MM
1690two forms, whichever is not the default.
1691
0c2d1a2a 1692These options control the amount and kinds of warnings produced by GCC:
74291a4b 1693
2642624b 1694@table @gcctabopt
74291a4b
MM
1695@cindex syntax checking
1696@item -fsyntax-only
cd3bb277 1697@opindex fsyntax-only
74291a4b
MM
1698Check the code for syntax errors, but don't do anything beyond that.
1699
1700@item -pedantic
cd3bb277 1701@opindex pedantic
074e95e3
JM
1702Issue all the warnings demanded by strict ISO C and ISO C++;
1703reject all programs that use forbidden extensions, and some other
1704programs that do not follow ISO C and ISO C++. For ISO C, follows the
630d3d5a 1705version of the ISO C standard specified by any @option{-std} option used.
74291a4b 1706
074e95e3 1707Valid ISO C and ISO C++ programs should compile properly with or without
5490d604 1708this option (though a rare few will require @option{-ansi} or a
161d7b59 1709@option{-std} option specifying the required version of ISO C)@. However,
b1d16193
JL
1710without this option, certain GNU extensions and traditional C and C++
1711features are supported as well. With this option, they are rejected.
74291a4b 1712
630d3d5a 1713@option{-pedantic} does not cause warning messages for use of the
74291a4b
MM
1714alternate keywords whose names begin and end with @samp{__}. Pedantic
1715warnings are also disabled in the expression that follows
1716@code{__extension__}. However, only system header files should use
1717these escape routes; application programs should avoid them.
1718@xref{Alternate Keywords}.
1719
630d3d5a 1720Some users try to use @option{-pedantic} to check programs for strict ISO
74291a4b 1721C conformance. They soon find that it does not do quite what they want:
c1030c7c 1722it finds some non-ISO practices, but not all---only those for which
074e95e3
JM
1723ISO C @emph{requires} a diagnostic, and some others for which
1724diagnostics have been added.
74291a4b 1725
074e95e3 1726A feature to report any failure to conform to ISO C might be useful in
74291a4b 1727some instances, but would require considerable additional work and would
630d3d5a 1728be quite different from @option{-pedantic}. We don't have plans to
892d0a6d 1729support such a feature in the near future.
74291a4b 1730
91ea548a
JM
1731Where the standard specified with @option{-std} represents a GNU
1732extended dialect of C, such as @samp{gnu89} or @samp{gnu99}, there is a
1733corresponding @dfn{base standard}, the version of ISO C on which the GNU
1734extended dialect is based. Warnings from @option{-pedantic} are given
1735where they are required by the base standard. (It would not make sense
1736for such warnings to be given only for features not in the specified GNU
1737C dialect, since by definition the GNU dialects of C include all
1738features the compiler supports with the given option, and there would be
1739nothing to warn about.)
1740
74291a4b 1741@item -pedantic-errors
cd3bb277 1742@opindex pedantic-errors
630d3d5a 1743Like @option{-pedantic}, except that errors are produced rather than
74291a4b
MM
1744warnings.
1745
1746@item -w
cd3bb277 1747@opindex w
74291a4b
MM
1748Inhibit all warning messages.
1749
1750@item -Wno-import
cd3bb277 1751@opindex Wno-import
74291a4b
MM
1752Inhibit warning messages about the use of @samp{#import}.
1753
1754@item -Wchar-subscripts
cd3bb277 1755@opindex Wchar-subscripts
74291a4b
MM
1756Warn if an array subscript has type @code{char}. This is a common cause
1757of error, as programmers often forget that this type is signed on some
1758machines.
1759
1760@item -Wcomment
cd3bb277 1761@opindex Wcomment
74291a4b
MM
1762Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*}
1763comment, or whenever a Backslash-Newline appears in a @samp{//} comment.
1764
1765@item -Wformat
cd3bb277 1766@opindex Wformat
74291a4b
MM
1767Check calls to @code{printf} and @code{scanf}, etc., to make sure that
1768the arguments supplied have types appropriate to the format string
26f6672d
JM
1769specified, and that the conversions specified in the format string make
1770sense. This includes standard functions, and others specified by format
1771attributes (@pxref{Function Attributes}), in the @code{printf},
1772@code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
1773not in the C standard) families.
74291a4b 1774
8308e0b7
JM
1775The formats are checked against the format features supported by GNU
1776libc version 2.2. These include all ISO C89 and C99 features, as well
1777as features from the Single Unix Specification and some BSD and GNU
1778extensions. Other library implementations may not support all these
1779features; GCC does not support warning about features that go beyond a
630d3d5a
JM
1780particular library's limitations. However, if @option{-pedantic} is used
1781with @option{-Wformat}, warnings will be given about format features not
26f6672d
JM
1782in the selected standard version (but not for @code{strfmon} formats,
1783since those are not in any version of the C standard). @xref{C Dialect
1784Options,,Options Controlling C Dialect}.
8308e0b7 1785
630d3d5a
JM
1786@option{-Wformat} is included in @option{-Wall}. For more control over some
1787aspects of format checking, the options @option{-Wno-format-y2k},
1788@option{-Wno-format-extra-args}, @option{-Wformat-nonliteral},
1789@option{-Wformat-security} and @option{-Wformat=2} are available, but are
1790not included in @option{-Wall}.
4d808927
JM
1791
1792@item -Wno-format-y2k
cd3bb277 1793@opindex Wno-format-y2k
630d3d5a 1794If @option{-Wformat} is specified, do not warn about @code{strftime}
4d808927
JM
1795formats which may yield only a two-digit year.
1796
1797@item -Wno-format-extra-args
cd3bb277 1798@opindex Wno-format-extra-args
630d3d5a 1799If @option{-Wformat} is specified, do not warn about excess arguments to a
4d808927
JM
1800@code{printf} or @code{scanf} format function. The C standard specifies
1801that such arguments are ignored.
1802
1803@item -Wformat-nonliteral
cd3bb277 1804@opindex Wformat-nonliteral
630d3d5a 1805If @option{-Wformat} is specified, also warn if the format string is not a
4d808927
JM
1806string literal and so cannot be checked, unless the format function
1807takes its format arguments as a @code{va_list}.
1808
c907e684 1809@item -Wformat-security
cd3bb277 1810@opindex Wformat-security
630d3d5a 1811If @option{-Wformat} is specified, also warn about uses of format
c907e684
JM
1812functions that represent possible security problems. At present, this
1813warns about calls to @code{printf} and @code{scanf} functions where the
1814format string is not a string literal and there are no format arguments,
1815as in @code{printf (foo);}. This may be a security hole if the format
1816string came from untrusted input and contains @samp{%n}. (This is
630d3d5a
JM
1817currently a subset of what @option{-Wformat-nonliteral} warns about, but
1818in future warnings may be added to @option{-Wformat-security} that are not
1819included in @option{-Wformat-nonliteral}.)
c907e684 1820
4d808927 1821@item -Wformat=2
cd3bb277 1822@opindex Wformat=2
630d3d5a
JM
1823Enable @option{-Wformat} plus format checks not included in
1824@option{-Wformat}. Currently equivalent to @samp{-Wformat
c907e684 1825-Wformat-nonliteral -Wformat-security}.
4d808927 1826
e9a25f70 1827@item -Wimplicit-int
cd3bb277 1828@opindex Wimplicit-int
e9a25f70
JL
1829Warn when a declaration does not specify a type.
1830
f5963e61
JL
1831@item -Wimplicit-function-declaration
1832@itemx -Werror-implicit-function-declaration
cd3bb277
JM
1833@opindex Wimplicit-function-declaration
1834@opindex Werror-implicit-function-declaration
f5963e61
JL
1835Give a warning (or error) whenever a function is used before being
1836declared.
e9a25f70 1837
74291a4b 1838@item -Wimplicit
cd3bb277 1839@opindex Wimplicit
630d3d5a 1840Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
861bb6c1
JL
1841
1842@item -Wmain
cd3bb277 1843@opindex Wmain
861bb6c1
JL
1844Warn if the type of @samp{main} is suspicious. @samp{main} should be a
1845function with external linkage, returning int, taking either zero
1846arguments, two, or three arguments of appropriate types.
4a870dba 1847
1f0c3120 1848@item -Wmissing-braces
cd3bb277 1849@opindex Wmissing-braces
1f0c3120
JM
1850Warn if an aggregate or union initializer is not fully bracketed. In
1851the following example, the initializer for @samp{a} is not fully
1852bracketed, but that for @samp{b} is fully bracketed.
1853
1854@smallexample
1855int a[2][2] = @{ 0, 1, 2, 3 @};
1856int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
1857@end smallexample
1858
4a870dba 1859@item -Wmultichar
cd3bb277 1860@opindex Wmultichar
4a870dba
JM
1861Warn if a multicharacter constant (@samp{'FOOF'}) is used. Usually they
1862indicate a typo in the user's code, as they have implementation-defined
1863values, and should not be used in portable code.
3c12fcc2 1864
74291a4b 1865@item -Wparentheses
cd3bb277 1866@opindex Wparentheses
74291a4b
MM
1867Warn if parentheses are omitted in certain contexts, such
1868as when there is an assignment in a context where a truth value
1869is expected, or when operators are nested whose precedence people
1870often get confused about.
1871
e9a25f70
JL
1872Also warn about constructions where there may be confusion to which
1873@code{if} statement an @code{else} branch belongs. Here is an example of
1874such a case:
1875
1876@smallexample
aee96fe9 1877@group
e9a25f70
JL
1878@{
1879 if (a)
1880 if (b)
1881 foo ();
1882 else
1883 bar ();
1884@}
aee96fe9 1885@end group
e9a25f70
JL
1886@end smallexample
1887
1888In C, every @code{else} branch belongs to the innermost possible @code{if}
1889statement, which in this example is @code{if (b)}. This is often not
1890what the programmer expected, as illustrated in the above example by
1891indentation the programmer chose. When there is the potential for this
f0523f02 1892confusion, GCC will issue a warning when this flag is specified.
e9a25f70
JL
1893To eliminate the warning, add explicit braces around the innermost
1894@code{if} statement so there is no way the @code{else} could belong to
1895the enclosing @code{if}. The resulting code would look like this:
1896
1897@smallexample
aee96fe9 1898@group
e9a25f70
JL
1899@{
1900 if (a)
1901 @{
1902 if (b)
1903 foo ();
1904 else
1905 bar ();
1906 @}
1907@}
aee96fe9 1908@end group
e9a25f70
JL
1909@end smallexample
1910
bb58bec5 1911@item -Wsequence-point
cd3bb277 1912@opindex Wsequence-point
bb58bec5
JM
1913Warn about code that may have undefined semantics because of violations
1914of sequence point rules in the C standard.
1915
1916The C standard defines the order in which expressions in a C program are
1917evaluated in terms of @dfn{sequence points}, which represent a partial
1918ordering between the execution of parts of the program: those executed
1919before the sequence point, and those executed after it. These occur
1920after the evaluation of a full expression (one which is not part of a
1921larger expression), after the evaluation of the first operand of a
1922@code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
1923function is called (but after the evaluation of its arguments and the
1924expression denoting the called function), and in certain other places.
1925Other than as expressed by the sequence point rules, the order of
1926evaluation of subexpressions of an expression is not specified. All
1927these rules describe only a partial order rather than a total order,
1928since, for example, if two functions are called within one expression
1929with no sequence point between them, the order in which the functions
1930are called is not specified. However, the standards committee have
1931ruled that function calls do not overlap.
1932
1933It is not specified when between sequence points modifications to the
1934values of objects take effect. Programs whose behavior depends on this
1935have undefined behavior; the C standard specifies that ``Between the
1936previous and next sequence point an object shall have its stored value
1937modified at most once by the evaluation of an expression. Furthermore,
1938the prior value shall be read only to determine the value to be
1939stored.''. If a program breaks these rules, the results on any
1940particular implementation are entirely unpredictable.
1941
1942Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
1943= b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
1944diagnosed by this option, and it may give an occasional false positive
1945result, but in general it has been found fairly effective at detecting
1946this sort of problem in programs.
1947
1948The present implementation of this option only works for C programs. A
1949future implementation may also work for C++ programs.
1950
9c34dbbf
ZW
1951The C standard is worded confusingly, therefore there is some debate
1952over the precise meaning of the sequence point rules in subtle cases.
1953Links to discussions of the problem, including proposed formal
1954definitions, may be found on our readings page, at
c5122d75 1955@w{@uref{http://gcc.gnu.org/readings.html}}.
bb58bec5 1956
74291a4b 1957@item -Wreturn-type
cd3bb277 1958@opindex Wreturn-type
32c4c36c
ML
1959Warn whenever a function is defined with a return-type that defaults to
1960@code{int}. Also warn about any @code{return} statement with no
02f52e19 1961return-value in a function whose return-type is not @code{void}.
32c4c36c
ML
1962
1963For C++, a function without return type always produces a diagnostic
767094dd 1964message, even when @option{-Wno-return-type} is specified. The only
32c4c36c 1965exceptions are @samp{main} and functions defined in system headers.
74291a4b
MM
1966
1967@item -Wswitch
cd3bb277 1968@opindex Wswitch
74291a4b
MM
1969Warn whenever a @code{switch} statement has an index of enumeral type
1970and lacks a @code{case} for one or more of the named codes of that
1971enumeration. (The presence of a @code{default} label prevents this
1972warning.) @code{case} labels outside the enumeration range also
1973provoke warnings when this option is used.
1974
1975@item -Wtrigraphs
cd3bb277 1976@opindex Wtrigraphs
f2ecb02d
JM
1977Warn if any trigraphs are encountered that might change the meaning of
1978the program (trigraphs within comments are not warned about).
74291a4b 1979
078721e1 1980@item -Wunused-function
cd3bb277 1981@opindex Wunused-function
078721e1
AC
1982Warn whenever a static function is declared but not defined or a
1983non\-inline static function is unused.
74291a4b 1984
078721e1 1985@item -Wunused-label
cd3bb277 1986@opindex Wunused-label
078721e1
AC
1987Warn whenever a label is declared but not used.
1988
1989To suppress this warning use the @samp{unused} attribute
1990(@pxref{Variable Attributes}).
1991
1992@item -Wunused-parameter
cd3bb277 1993@opindex Wunused-parameter
078721e1
AC
1994Warn whenever a function parameter is unused aside from its declaration.
1995
1996To suppress this warning use the @samp{unused} attribute
1997(@pxref{Variable Attributes}).
956d6950 1998
078721e1 1999@item -Wunused-variable
cd3bb277 2000@opindex Wunused-variable
078721e1
AC
2001Warn whenever a local variable or non-constant static variable is unused
2002aside from its declaration
2003
2004To suppress this warning use the @samp{unused} attribute
74291a4b
MM
2005(@pxref{Variable Attributes}).
2006
078721e1 2007@item -Wunused-value
cd3bb277 2008@opindex Wunused-value
078721e1
AC
2009Warn whenever a statement computes a result that is explicitly not used.
2010
2011To suppress this warning cast the expression to @samp{void}.
2012
2013@item -Wunused
cd3bb277 2014@opindex Wunused
630d3d5a 2015All all the above @option{-Wunused} options combined.
078721e1
AC
2016
2017In order to get a warning about an unused function parameter, you must
b192711e 2018either specify @samp{-W -Wunused} or separately specify
630d3d5a 2019@option{-Wunused-parameter}.
078721e1 2020
74291a4b 2021@item -Wuninitialized
cd3bb277 2022@opindex Wuninitialized
c5c76735
JL
2023Warn if an automatic variable is used without first being initialized or
2024if a variable may be clobbered by a @code{setjmp} call.
74291a4b
MM
2025
2026These warnings are possible only in optimizing compilation,
2027because they require data flow information that is computed only
630d3d5a 2028when optimizing. If you don't specify @option{-O}, you simply won't
74291a4b
MM
2029get these warnings.
2030
2031These warnings occur only for variables that are candidates for
2032register allocation. Therefore, they do not occur for a variable that
2033is declared @code{volatile}, or whose address is taken, or whose size
2034is other than 1, 2, 4 or 8 bytes. Also, they do not occur for
2035structures, unions or arrays, even when they are in registers.
2036
2037Note that there may be no warning about a variable that is used only
2038to compute a value that itself is never used, because such
2039computations may be deleted by data flow analysis before the warnings
2040are printed.
2041
0c2d1a2a 2042These warnings are made optional because GCC is not smart
74291a4b
MM
2043enough to see all the reasons why the code might be correct
2044despite appearing to have an error. Here is one example of how
2045this can happen:
2046
2047@smallexample
aee96fe9 2048@group
74291a4b
MM
2049@{
2050 int x;
2051 switch (y)
2052 @{
2053 case 1: x = 1;
2054 break;
2055 case 2: x = 4;
2056 break;
2057 case 3: x = 5;
2058 @}
2059 foo (x);
2060@}
aee96fe9 2061@end group
74291a4b
MM
2062@end smallexample
2063
2064@noindent
2065If the value of @code{y} is always 1, 2 or 3, then @code{x} is
0c2d1a2a 2066always initialized, but GCC doesn't know this. Here is
74291a4b
MM
2067another common case:
2068
2069@smallexample
2070@{
2071 int save_y;
2072 if (change_y) save_y = y, y = new_y;
2073 @dots{}
2074 if (change_y) y = save_y;
2075@}
2076@end smallexample
2077
2078@noindent
2079This has no bug because @code{save_y} is used only if it is set.
2080
20300b05 2081@cindex @code{longjmp} warnings
b192711e 2082This option also warns when a non-volatile automatic variable might be
c5c76735
JL
2083changed by a call to @code{longjmp}. These warnings as well are possible
2084only in optimizing compilation.
20300b05
GK
2085
2086The compiler sees only the calls to @code{setjmp}. It cannot know
2087where @code{longjmp} will be called; in fact, a signal handler could
2088call it at any point in the code. As a result, you may get a warning
2089even when there is in fact no problem because @code{longjmp} cannot
2090in fact be called at the place which would cause a problem.
2091
74291a4b
MM
2092Some spurious warnings can be avoided if you declare all the functions
2093you use that never return as @code{noreturn}. @xref{Function
2094Attributes}.
2095
aee96fe9 2096@item -Wreorder @r{(C++ only)}
cd3bb277 2097@opindex Wreorder
c5c76735
JL
2098@cindex reordering, warning
2099@cindex warning for reordering of member initializers
2100Warn when the order of member initializers given in the code does not
2101match the order in which they must be executed. For instance:
2102
d300e551 2103@item -Wunknown-pragmas
cd3bb277 2104@opindex Wunknown-pragmas
d300e551
NC
2105@cindex warning for unknown pragmas
2106@cindex unknown pragmas, warning
2107@cindex pragmas, warning of unknown
2108Warn when a #pragma directive is encountered which is not understood by
161d7b59 2109GCC@. If this command line option is used, warnings will even be issued
d300e551 2110for unknown pragmas in system header files. This is not the case if
630d3d5a 2111the warnings were only enabled by the @option{-Wall} command line option.
d300e551 2112
74291a4b 2113@item -Wall
cd3bb277 2114@opindex Wall
74291a4b
MM
2115All of the above @samp{-W} options combined. This enables all the
2116warnings about constructions that some users consider questionable, and
2117that are easy to avoid (or modify to prevent the warning), even in
2118conjunction with macros.
317639a8
BC
2119
2120@item -Wsystem-headers
cd3bb277 2121@opindex Wsystem-headers
317639a8
BC
2122@cindex warnings from system headers
2123@cindex system headers, warnings from
2124Print warning messages for constructs found in system header files.
2125Warnings from system headers are normally suppressed, on the assumption
2126that they usually do not indicate real problems and would only make the
2127compiler output harder to read. Using this command line option tells
2128GCC to emit warnings from system headers as if they occurred in user
630d3d5a 2129code. However, note that using @option{-Wall} in conjunction with this
317639a8 2130option will @emph{not} warn about unknown pragmas in system
630d3d5a 2131headers---for that, @option{-Wunknown-pragmas} must also be used.
74291a4b
MM
2132@end table
2133
630d3d5a 2134The following @option{-W@dots{}} options are not implied by @option{-Wall}.
74291a4b
MM
2135Some of them warn about constructions that users generally do not
2136consider questionable, but which occasionally you might wish to check
2137for; others warn about constructions that are necessary or hard to avoid
2138in some cases, and there is no simple way to modify the code to suppress
2139the warning.
2140
2642624b 2141@table @gcctabopt
74291a4b 2142@item -W
cd3bb277 2143@opindex W
74291a4b
MM
2144Print extra warning messages for these events:
2145
2146@itemize @bullet
74291a4b
MM
2147@item
2148A function can return either with or without a value. (Falling
2149off the end of the function body is considered returning without
2150a value.) For example, this function would evoke such a
2151warning:
2152
2153@smallexample
2154@group
2155foo (a)
2156@{
2157 if (a > 0)
2158 return a;
2159@}
2160@end group
2161@end smallexample
2162
2163@item
2164An expression-statement or the left-hand side of a comma expression
2165contains no side effects.
2166To suppress the warning, cast the unused expression to void.
2167For example, an expression such as @samp{x[i,j]} will cause a warning,
2168but @samp{x[(void)i,j]} will not.
2169
2170@item
2171An unsigned value is compared against zero with @samp{<} or @samp{<=}.
2172
2173@item
2174A comparison like @samp{x<=y<=z} appears; this is equivalent to
2175@samp{(x<=y ? 1 : 0) <= z}, which is a different interpretation from
2176that of ordinary mathematical notation.
2177
2178@item
2179Storage-class specifiers like @code{static} are not the first things in
2180a declaration. According to the C Standard, this usage is obsolescent.
2181
e0c9fbb7
JM
2182@item
2183The return type of a function has a type qualifier such as @code{const}.
2184Such a type qualifier has no effect, since the value returned by a
2185function is not an lvalue. (But don't warn about the GNU extension of
2186@code{volatile void} return types. That extension will be warned about
630d3d5a 2187if @option{-pedantic} is specified.)
e0c9fbb7 2188
74291a4b 2189@item
630d3d5a 2190If @option{-Wall} or @option{-Wunused} is also specified, warn about unused
74291a4b
MM
2191arguments.
2192
e9a25f70
JL
2193@item
2194A comparison between signed and unsigned values could produce an
2195incorrect result when the signed value is converted to unsigned.
630d3d5a 2196(But don't warn if @option{-Wno-sign-compare} is also specified.)
e9a25f70 2197
74291a4b
MM
2198@item
2199An aggregate has a partly bracketed initializer.
2200For example, the following code would evoke such a warning,
2201because braces are missing around the initializer for @code{x.h}:
2202
2203@smallexample
2204struct s @{ int f, g; @};
2205struct t @{ struct s h; int i; @};
2206struct t x = @{ 1, 2, 3 @};
2207@end smallexample
dbde0d5d
BH
2208
2209@item
2210An aggregate has an initializer which does not initialize all members.
2211For example, the following code would cause such a warning, because
2212@code{x.h} would be implicitly initialized to zero:
2213
2214@smallexample
2215struct s @{ int f, g, h; @};
2216struct s x = @{ 3, 4 @};
2217@end smallexample
74291a4b
MM
2218@end itemize
2219
f793a95e 2220@item -Wfloat-equal
cd3bb277 2221@opindex Wfloat-equal
f793a95e
JL
2222Warn if floating point values are used in equality comparisons.
2223
488d3985
GK
2224The idea behind this is that sometimes it is convenient (for the
2225programmer) to consider floating-point values as approximations to
2226infinitely precise real numbers. If you are doing this, then you need
2227to compute (by analysing the code, or in some other way) the maximum or
2228likely maximum error that the computation introduces, and allow for it
2229when performing comparisons (and when producing output, but that's a
2230different problem). In particular, instead of testing for equality, you
2231would check to see whether the two values have ranges that overlap; and
2232this is done with the relational operators, so equality comparisons are
2233probably mistaken.
2234
aee96fe9 2235@item -Wtraditional @r{(C only)}
cd3bb277 2236@opindex Wtraditional
74291a4b 2237Warn about certain constructs that behave differently in traditional and
161d7b59 2238ISO C@. Also warn about ISO C constructs that have no traditional C
c8abc684 2239equivalent, and/or problematic constructs which should be avoided.
74291a4b
MM
2240
2241@itemize @bullet
2242@item
da312b55
NB
2243Macro parameters that appear within string literals in the macro body.
2244In traditional C macro replacement takes place within string literals,
161d7b59 2245but does not in ISO C@.
da312b55
NB
2246
2247@item
2248In traditional C, some preprocessor directives did not exist.
2249Traditional preprocessors would only consider a line to be a directive
2250if the @samp{#} appeared in column 1 on the line. Therefore
630d3d5a 2251@option{-Wtraditional} warns about directives that traditional C
da312b55
NB
2252understands but would ignore because the @samp{#} does not appear as the
2253first character on the line. It also suggests you hide directives like
2254@samp{#pragma} not understood by traditional C by indenting them. Some
2255traditional implementations would not recognise @samp{#elif}, so it
2256suggests avoiding it altogether.
2257
2258@item
2259A function-like macro that appears without arguments.
2260
2261@item
2262The unary plus operator.
2263
2264@item
c771326b
JM
2265The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating point
2266constant suffixes. (Traditional C does support the @samp{L} suffix on integer
da312b55 2267constants.) Note, these suffixes appear in macros defined in the system
e979f9e8 2268headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
c8abc684
KG
2269Use of these macros in user code might normally lead to spurious
2270warnings, however gcc's integrated preprocessor has enough context to
2271avoid warning in these cases.
74291a4b
MM
2272
2273@item
2274A function declared external in one block and then used after the end of
2275the block.
2276
2277@item
2278A @code{switch} statement has an operand of type @code{long}.
db838bb8
KG
2279
2280@item
2281A non-@code{static} function declaration follows a @code{static} one.
2282This construct is not accepted by some traditional C compilers.
48776cde
KG
2283
2284@item
c1030c7c 2285The ISO type of an integer constant has a different width or
48776cde 2286signedness from its traditional type. This warning is only issued if
e979f9e8 2287the base of the constant is ten. I.e.@: hexadecimal or octal values, which
48776cde 2288typically represent bit patterns, are not warned about.
bb66adca
KG
2289
2290@item
c1030c7c 2291Usage of ISO string concatenation is detected.
7f094a94 2292
895ea614
KG
2293@item
2294Initialization of automatic aggregates.
2295
2296@item
2297Identifier conflicts with labels. Traditional C lacks a separate
2298namespace for labels.
253b6b82
KG
2299
2300@item
2301Initialization of unions. If the initializer is zero, the warning is
2302omitted. This is done under the assumption that the zero initializer in
e979f9e8 2303user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
253b6b82
KG
2304initializer warnings and relies on default initialization to zero in the
2305traditional C case.
03829ad2
KG
2306
2307@item
3ed56f8a
KG
2308Conversions by prototypes between fixed/floating point values and vice
2309versa. The absence of these prototypes when compiling with traditional
2310C would cause serious problems. This is a subset of the possible
630d3d5a 2311conversion warnings, for the full set use @option{-Wconversion}.
74291a4b
MM
2312@end itemize
2313
861bb6c1 2314@item -Wundef
cd3bb277 2315@opindex Wundef
861bb6c1
JL
2316Warn if an undefined identifier is evaluated in an @samp{#if} directive.
2317
74291a4b 2318@item -Wshadow
cd3bb277 2319@opindex Wshadow
d773df5a
DB
2320Warn whenever a local variable shadows another local variable, parameter or
2321global variable or whenever a built-in function is shadowed.
74291a4b 2322
74291a4b 2323@item -Wlarger-than-@var{len}
cd3bb277 2324@opindex Wlarger-than
74291a4b
MM
2325Warn whenever an object of larger than @var{len} bytes is defined.
2326
2327@item -Wpointer-arith
cd3bb277 2328@opindex Wpointer-arith
74291a4b
MM
2329Warn about anything that depends on the ``size of'' a function type or
2330of @code{void}. GNU C assigns these types a size of 1, for
2331convenience in calculations with @code{void *} pointers and pointers
2332to functions.
2333
aee96fe9 2334@item -Wbad-function-cast @r{(C only)}
cd3bb277 2335@opindex Wbad-function-cast
74291a4b
MM
2336Warn whenever a function call is cast to a non-matching type.
2337For example, warn if @code{int malloc()} is cast to @code{anything *}.
2338
2339@item -Wcast-qual
cd3bb277 2340@opindex Wcast-qual
74291a4b
MM
2341Warn whenever a pointer is cast so as to remove a type qualifier from
2342the target type. For example, warn if a @code{const char *} is cast
2343to an ordinary @code{char *}.
2344
2345@item -Wcast-align
cd3bb277 2346@opindex Wcast-align
74291a4b
MM
2347Warn whenever a pointer is cast such that the required alignment of the
2348target is increased. For example, warn if a @code{char *} is cast to
2349an @code{int *} on machines where integers can only be accessed at
2350two- or four-byte boundaries.
2351
2352@item -Wwrite-strings
cd3bb277 2353@opindex Wwrite-strings
aee96fe9
JM
2354When compiling C, give string constants the type @code{const
2355char[@var{length}]} so that
74291a4b 2356copying the address of one into a non-@code{const} @code{char *}
aee96fe9
JM
2357pointer will get a warning; when compiling C++, warn about the
2358deprecated conversion from string constants to @code{char *}.
2359These warnings will help you find at
74291a4b
MM
2360compile time code that can try to write into a string constant, but
2361only if you have been very careful about using @code{const} in
2362declarations and prototypes. Otherwise, it will just be a nuisance;
630d3d5a 2363this is why we did not make @option{-Wall} request these warnings.
74291a4b
MM
2364
2365@item -Wconversion
cd3bb277 2366@opindex Wconversion
74291a4b
MM
2367Warn if a prototype causes a type conversion that is different from what
2368would happen to the same argument in the absence of a prototype. This
2369includes conversions of fixed point to floating and vice versa, and
2370conversions changing the width or signedness of a fixed point argument
2371except when the same as the default promotion.
2372
2373Also, warn if a negative integer constant expression is implicitly
2374converted to an unsigned type. For example, warn about the assignment
2375@code{x = -1} if @code{x} is unsigned. But do not warn about explicit
2376casts like @code{(unsigned) -1}.
2377
e9a25f70 2378@item -Wsign-compare
cd3bb277 2379@opindex Wsign-compare
e9a25f70
JL
2380@cindex warning for comparison of signed and unsigned values
2381@cindex comparison of signed and unsigned values, warning
2382@cindex signed and unsigned values, comparison warning
2383Warn when a comparison between signed and unsigned values could produce
2384an incorrect result when the signed value is converted to unsigned.
630d3d5a
JM
2385This warning is also enabled by @option{-W}; to get the other warnings
2386of @option{-W} without this warning, use @samp{-W -Wno-sign-compare}.
e9a25f70 2387
74291a4b 2388@item -Waggregate-return
cd3bb277 2389@opindex Waggregate-return
74291a4b
MM
2390Warn if any functions that return structures or unions are defined or
2391called. (In languages where you can return an array, this also elicits
2392a warning.)
2393
aee96fe9 2394@item -Wstrict-prototypes @r{(C only)}
cd3bb277 2395@opindex Wstrict-prototypes
74291a4b
MM
2396Warn if a function is declared or defined without specifying the
2397argument types. (An old-style function definition is permitted without
2398a warning if preceded by a declaration which specifies the argument
2399types.)
2400
aee96fe9 2401@item -Wmissing-prototypes @r{(C only)}
cd3bb277 2402@opindex Wmissing-prototypes
74291a4b
MM
2403Warn if a global function is defined without a previous prototype
2404declaration. This warning is issued even if the definition itself
2405provides a prototype. The aim is to detect global functions that fail
2406to be declared in header files.
2407
2408@item -Wmissing-declarations
cd3bb277 2409@opindex Wmissing-declarations
74291a4b
MM
2410Warn if a global function is defined without a previous declaration.
2411Do so even if the definition itself provides a prototype.
2412Use this option to detect global functions that are not declared in
2413header files.
2414
0ca3fb0a 2415@item -Wmissing-noreturn
cd3bb277 2416@opindex Wmissing-noreturn
0ca3fb0a
KG
2417Warn about functions which might be candidates for attribute @code{noreturn}.
2418Note these are only possible candidates, not absolute ones. Care should
2419be taken to manually verify functions actually do not ever return before
2420adding the @code{noreturn} attribute, otherwise subtle code generation
21c7361e
AJ
2421bugs could be introduced. You will not get a warning for @code{main} in
2422hosted C environments.
0ca3fb0a 2423
74ff4629 2424@item -Wmissing-format-attribute
cd3bb277
JM
2425@opindex Wmissing-format-attribute
2426@opindex Wformat
630d3d5a 2427If @option{-Wformat} is enabled, also warn about functions which might be
74ff4629
JM
2428candidates for @code{format} attributes. Note these are only possible
2429candidates, not absolute ones. GCC will guess that @code{format}
2430attributes might be appropriate for any function that calls a function
2431like @code{vprintf} or @code{vscanf}, but this might not always be the
2432case, and some functions for which @code{format} attributes are
2433appropriate may not be detected. This option has no effect unless
630d3d5a 2434@option{-Wformat} is enabled (possibly by @option{-Wall}).
74ff4629 2435
3c12fcc2 2436@item -Wpacked
cd3bb277 2437@opindex Wpacked
3c12fcc2 2438Warn if a structure is given the packed attribute, but the packed
02f52e19 2439attribute has no effect on the layout or size of the structure.
3c12fcc2
GM
2440Such structures may be mis-aligned for little benefit. For
2441instance, in this code, the variable @code{f.x} in @code{struct bar}
2442will be misaligned even though @code{struct bar} does not itself
2443have the packed attribute:
2444
2445@smallexample
2446@group
2447struct foo @{
2448 int x;
2449 char a, b, c, d;
2450@} __attribute__((packed));
2451struct bar @{
2452 char z;
2453 struct foo f;
2454@};
2455@end group
2456@end smallexample
2457
2458@item -Wpadded
cd3bb277 2459@opindex Wpadded
3c12fcc2
GM
2460Warn if padding is included in a structure, either to align an element
2461of the structure or to align the whole structure. Sometimes when this
2462happens it is possible to rearrange the fields of the structure to
2463reduce the padding and so make the structure smaller.
2464
74291a4b 2465@item -Wredundant-decls
cd3bb277 2466@opindex Wredundant-decls
74291a4b
MM
2467Warn if anything is declared more than once in the same scope, even in
2468cases where multiple declaration is valid and changes nothing.
2469
aee96fe9 2470@item -Wnested-externs @r{(C only)}
cd3bb277 2471@opindex Wnested-externs
252215a7 2472Warn if an @code{extern} declaration is encountered within a function.
74291a4b 2473
312f6255 2474@item -Wunreachable-code
cd3bb277 2475@opindex Wunreachable-code
312f6255
GK
2476Warn if the compiler detects that code will never be executed.
2477
2478This option is intended to warn when the compiler detects that at
2479least a whole line of source code will never be executed, because
2480some condition is never satisfied or because it is after a
2481procedure that never returns.
2482
2483It is possible for this option to produce a warning even though there
2484are circumstances under which part of the affected line can be executed,
2485so care should be taken when removing apparently-unreachable code.
2486
2487For instance, when a function is inlined, a warning may mean that the
02f52e19 2488line is unreachable in only one inlined copy of the function.
312f6255 2489
630d3d5a 2490This option is not made part of @option{-Wall} because in a debugging
312f6255
GK
2491version of a program there is often substantial code which checks
2492correct functioning of the program and is, hopefully, unreachable
2493because the program does work. Another common use of unreachable
2494code is to provide behaviour which is selectable at compile-time.
2495
74291a4b 2496@item -Winline
cd3bb277 2497@opindex Winline
c5c76735 2498Warn if a function can not be inlined and it was declared as inline.
74291a4b 2499
795add94 2500@item -Wlong-long
cd3bb277
JM
2501@opindex Wlong-long
2502@opindex Wno-long-long
795add94 2503Warn if @samp{long long} type is used. This is default. To inhibit
630d3d5a
JM
2504the warning messages, use @option{-Wno-long-long}. Flags
2505@option{-Wlong-long} and @option{-Wno-long-long} are taken into account
2506only when @option{-pedantic} flag is used.
795add94 2507
18424ae1 2508@item -Wdisabled-optimization
cd3bb277 2509@opindex Wdisabled-optimization
18424ae1
BL
2510Warn if a requested optimization pass is disabled. This warning does
2511not generally indicate that there is anything wrong with your code; it
2512merely indicates that GCC's optimizers were unable to handle the code
2513effectively. Often, the problem is that your code is too big or too
2514complex; GCC will refuse to optimize programs when the optimization
2515itself is likely to take inordinate amounts of time.
2516
74291a4b 2517@item -Werror
cd3bb277 2518@opindex Werror
74291a4b
MM
2519Make all warnings into errors.
2520@end table
2521
2522@node Debugging Options
0c2d1a2a 2523@section Options for Debugging Your Program or GCC
74291a4b
MM
2524@cindex options, debugging
2525@cindex debugging information options
2526
0c2d1a2a 2527GCC has various special options that are used for debugging
74291a4b
MM
2528either your program or GCC:
2529
2642624b 2530@table @gcctabopt
74291a4b 2531@item -g
cd3bb277 2532@opindex g
74291a4b 2533Produce debugging information in the operating system's native format
161d7b59 2534(stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
74291a4b
MM
2535information.
2536
630d3d5a 2537On most systems that use stabs format, @option{-g} enables use of extra
74291a4b
MM
2538debugging information that only GDB can use; this extra information
2539makes debugging work better in GDB but will probably make other debuggers
2540crash or
2541refuse to read the program. If you want to control for certain whether
630d3d5a
JM
2542to generate the extra information, use @option{-gstabs+}, @option{-gstabs},
2543@option{-gxcoff+}, @option{-gxcoff}, @option{-gdwarf-1+}, or @option{-gdwarf-1}
74291a4b
MM
2544(see below).
2545
630d3d5a
JM
2546Unlike most other C compilers, GCC allows you to use @option{-g} with
2547@option{-O}. The shortcuts taken by optimized code may occasionally
74291a4b
MM
2548produce surprising results: some variables you declared may not exist
2549at all; flow of control may briefly move where you did not expect it;
2550some statements may not be executed because they compute constant
2551results or their values were already at hand; some statements may
2552execute in different places because they were moved out of loops.
2553
2554Nevertheless it proves possible to debug optimized output. This makes
2555it reasonable to use the optimizer for programs that might have bugs.
2556
0c2d1a2a 2557The following options are useful when GCC is generated with the
74291a4b
MM
2558capability for more than one debugging format.
2559
2560@item -ggdb
cd3bb277 2561@opindex ggdb
161d7b59 2562Produce debugging information for use by GDB@. This means to use the
861bb6c1
JL
2563most expressive format available (DWARF 2, stabs, or the native format
2564if neither of those are supported), including GDB extensions if at all
2565possible.
74291a4b
MM
2566
2567@item -gstabs
cd3bb277 2568@opindex gstabs
74291a4b
MM
2569Produce debugging information in stabs format (if that is supported),
2570without GDB extensions. This is the format used by DBX on most BSD
2571systems. On MIPS, Alpha and System V Release 4 systems this option
161d7b59 2572produces stabs debugging output which is not understood by DBX or SDB@.
74291a4b
MM
2573On System V Release 4 systems this option requires the GNU assembler.
2574
2575@item -gstabs+
cd3bb277 2576@opindex gstabs+
74291a4b 2577Produce debugging information in stabs format (if that is supported),
161d7b59 2578using GNU extensions understood only by the GNU debugger (GDB)@. The
74291a4b
MM
2579use of these extensions is likely to make other debuggers crash or
2580refuse to read the program.
2581
2582@item -gcoff
cd3bb277 2583@opindex gcoff
74291a4b
MM
2584Produce debugging information in COFF format (if that is supported).
2585This is the format used by SDB on most System V systems prior to
2586System V Release 4.
2587
2588@item -gxcoff
cd3bb277 2589@opindex gxcoff
74291a4b
MM
2590Produce debugging information in XCOFF format (if that is supported).
2591This is the format used by the DBX debugger on IBM RS/6000 systems.
2592
2593@item -gxcoff+
cd3bb277 2594@opindex gxcoff+
74291a4b 2595Produce debugging information in XCOFF format (if that is supported),
161d7b59 2596using GNU extensions understood only by the GNU debugger (GDB)@. The
74291a4b
MM
2597use of these extensions is likely to make other debuggers crash or
2598refuse to read the program, and may cause assemblers other than the GNU
2599assembler (GAS) to fail with an error.
2600
2601@item -gdwarf
cd3bb277 2602@opindex gdwarf
861bb6c1
JL
2603Produce debugging information in DWARF version 1 format (if that is
2604supported). This is the format used by SDB on most System V Release 4
2605systems.
74291a4b
MM
2606
2607@item -gdwarf+
cd3bb277 2608@opindex gdwarf+
861bb6c1
JL
2609Produce debugging information in DWARF version 1 format (if that is
2610supported), using GNU extensions understood only by the GNU debugger
161d7b59 2611(GDB)@. The use of these extensions is likely to make other debuggers
861bb6c1
JL
2612crash or refuse to read the program.
2613
2614@item -gdwarf-2
cd3bb277 2615@opindex gdwarf-2
861bb6c1
JL
2616Produce debugging information in DWARF version 2 format (if that is
2617supported). This is the format used by DBX on IRIX 6.
74291a4b
MM
2618
2619@item -g@var{level}
2620@itemx -ggdb@var{level}
2621@itemx -gstabs@var{level}
2622@itemx -gcoff@var{level}
2623@itemx -gxcoff@var{level}
2624@itemx -gdwarf@var{level}
861bb6c1 2625@itemx -gdwarf-2@var{level}
74291a4b
MM
2626Request debugging information and also use @var{level} to specify how
2627much information. The default level is 2.
2628
2629Level 1 produces minimal information, enough for making backtraces in
2630parts of the program that you don't plan to debug. This includes
2631descriptions of functions and external variables, but no information
2632about local variables and no line numbers.
2633
2634Level 3 includes extra information, such as all the macro definitions
2635present in the program. Some debuggers support macro expansion when
630d3d5a 2636you use @option{-g3}.
74291a4b
MM
2637
2638@cindex @code{prof}
2639@item -p
cd3bb277 2640@opindex p
74291a4b
MM
2641Generate extra code to write profile information suitable for the
2642analysis program @code{prof}. You must use this option when compiling
2643the source files you want data about, and you must also use it when
2644linking.
2645
2646@cindex @code{gprof}
2647@item -pg
cd3bb277 2648@opindex pg
74291a4b
MM
2649Generate extra code to write profile information suitable for the
2650analysis program @code{gprof}. You must use this option when compiling
2651the source files you want data about, and you must also use it when
2652linking.
2653
2654@cindex @code{tcov}
2655@item -a
cd3bb277 2656@opindex a
74291a4b
MM
2657Generate extra code to write profile information for basic blocks, which will
2658record the number of times each basic block is executed, the basic block start
630d3d5a 2659address, and the function name containing the basic block. If @option{-g} is
74291a4b
MM
2660used, the line number and filename of the start of the basic block will also be
2661recorded. If not overridden by the machine description, the default action is
2662to append to the text file @file{bb.out}.
2663
2664This data could be analyzed by a program like @code{tcov}. Note,
2665however, that the format of the data is not what @code{tcov} expects.
2666Eventually GNU @code{gprof} should be extended to process this data.
2667
898f531b 2668@item -Q
cd3bb277 2669@opindex Q
898f531b
JL
2670Makes the compiler print out each function name as it is compiled, and
2671print some statistics about each pass when it finishes.
2672
1f0c3120 2673@item -ftime-report
cd3bb277 2674@opindex ftime-report
1f0c3120
JM
2675Makes the compiler print some statistics about the time consumed by each
2676pass when it finishes.
2677
2678@item -fmem-report
cd3bb277 2679@opindex fmem-report
1f0c3120
JM
2680Makes the compiler print some statistics about permanent memory
2681allocation when it finishes.
2682
74291a4b 2683@item -ax
cd3bb277 2684@opindex ax
74291a4b 2685Generate extra code to profile basic blocks. Your executable will
630d3d5a 2686produce output that is a superset of that produced when @option{-a} is
74291a4b
MM
2687used. Additional output is the source and target address of the basic
2688blocks where a jump takes place, the number of times a jump is executed,
2689and (optionally) the complete sequence of basic blocks being executed.
2690The output is appended to file @file{bb.out}.
2691
2692You can examine different profiling aspects without recompilation. Your
956d6950 2693executable will read a list of function names from file @file{bb.in}.
74291a4b
MM
2694Profiling starts when a function on the list is entered and stops when
2695that invocation is exited. To exclude a function from profiling, prefix
c771326b 2696its name with @samp{-}. If a function name is not unique, you can
74291a4b
MM
2697disambiguate it by writing it in the form
2698@samp{/path/filename.d:functionname}. Your executable will write the
2699available paths and filenames in file @file{bb.out}.
2700
2701Several function names have a special meaning:
2702@table @code
2703@item __bb_jumps__
2704Write source, target and frequency of jumps to file @file{bb.out}.
2705@item __bb_hidecall__
2706Exclude function calls from frequency count.
2707@item __bb_showret__
2708Include function returns in frequency count.
2709@item __bb_trace__
2710Write the sequence of basic blocks executed to file @file{bbtrace.gz}.
2711The file will be compressed using the program @samp{gzip}, which must
bedc7537 2712exist in your @env{PATH}. On systems without the @samp{popen}
74291a4b
MM
2713function, the file will be named @file{bbtrace} and will not be
2714compressed. @strong{Profiling for even a few seconds on these systems
2715will produce a very large file.} Note: @code{__bb_hidecall__} and
2716@code{__bb_showret__} will not affect the sequence written to
2717@file{bbtrace.gz}.
2718@end table
2719
2720Here's a short example using different profiling parameters
2721in file @file{bb.in}. Assume function @code{foo} consists of basic blocks
27221 and 2 and is called twice from block 3 of function @code{main}. After
2723the calls, block 3 transfers control to block 4 of @code{main}.
2724
2725With @code{__bb_trace__} and @code{main} contained in file @file{bb.in},
2726the following sequence of blocks is written to file @file{bbtrace.gz}:
27270 3 1 2 1 2 4. The return from block 2 to block 3 is not shown, because
2728the return is to a point inside the block and not to the top. The
2729block address 0 always indicates, that control is transferred
2730to the trace from somewhere outside the observed functions. With
2731@samp{-foo} added to @file{bb.in}, the blocks of function
2732@code{foo} are removed from the trace, so only 0 3 4 remains.
2733
2734With @code{__bb_jumps__} and @code{main} contained in file @file{bb.in},
2735jump frequencies will be written to file @file{bb.out}. The
2736frequencies are obtained by constructing a trace of blocks
2737and incrementing a counter for every neighbouring pair of blocks
2738in the trace. The trace 0 3 1 2 1 2 4 displays the following
2739frequencies:
2740
2741@example
2742Jump from block 0x0 to block 0x3 executed 1 time(s)
2743Jump from block 0x3 to block 0x1 executed 1 time(s)
2744Jump from block 0x1 to block 0x2 executed 2 time(s)
2745Jump from block 0x2 to block 0x1 executed 1 time(s)
2746Jump from block 0x2 to block 0x4 executed 1 time(s)
2747@end example
2748
2749With @code{__bb_hidecall__}, control transfer due to call instructions
2750is removed from the trace, that is the trace is cut into three parts: 0
27513 4, 0 1 2 and 0 1 2. With @code{__bb_showret__}, control transfer due
2752to return instructions is added to the trace. The trace becomes: 0 3 1
27532 3 1 2 3 4. Note, that this trace is not the same, as the sequence
2754written to @file{bbtrace.gz}. It is solely used for counting jump
2755frequencies.
2756
861bb6c1 2757@item -fprofile-arcs
cd3bb277 2758@opindex fprofile-arcs
3de87bf2
JJ
2759Instrument @dfn{arcs} during compilation to generate coverage data
2760or for profile-directed block ordering. During execution the program
2761records how many times each branch is executed and how many times it is
2762taken. When the compiled program exits it saves this data to a file
2763called @file{@var{sourcename}.da} for each source file.
2764
2765For profile-directed block ordering, compile the program with
2766@option{-fprofile-arcs} plus optimization and code generation options,
2767generate the arc profile information by running the program on a
2768selected workload, and then compile the program again with the same
2769optimization and code generation options plus
630d3d5a 2770@option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
3de87bf2
JJ
2771Control Optimization}).
2772
2773The other use of @option{-fprofile-arcs} is for use with @code{gcov},
2774when it is used with the @option{-ftest-coverage} option. GCC
2775supports two methods of determining code coverage: the options that
2776support @code{gcov}, and options @option{-a} and @option{-ax}, which
2777write information to text files. The options that support @code{gcov}
2778do not need to instrument every arc in the program, so a program compiled
2779with them runs faster than a program compiled with @option{-a}, which
2780adds instrumentation code to every basic block in the program. The
2781tradeoff: since @code{gcov} does not have execution counts for all
2782branches, it must start with the execution counts for the instrumented
2783branches, and then iterate over the program flow graph until the entire
2784graph has been solved. Hence, @code{gcov} runs a little more slowly than
2785a program which uses information from @option{-a} and @option{-ax}.
2786
2787With @option{-fprofile-arcs}, for each function of your program GCC
2788creates a program flow graph, then finds a spanning tree for the graph.
2789Only arcs that are not on the spanning tree have to be instrumented: the
2790compiler adds code to count the number of times that these arcs are
2791executed. When an arc is the only exit or only entrance to a block, the
2792instrumentation code can be added to the block; otherwise, a new basic
2793block must be created to hold the instrumentation code.
2794
2795This option makes it possible to estimate branch probabilities and to
2796calculate basic block execution counts. In general, basic block
2797execution counts as provided by @option{-a} do not give enough
2798information to estimate all branch probabilities.
861bb6c1
JL
2799
2800@need 2000
2801@item -ftest-coverage
cd3bb277 2802@opindex ftest-coverage
861bb6c1 2803Create data files for the @code{gcov} code-coverage utility
0c2d1a2a 2804(@pxref{Gcov,, @code{gcov}: a GCC Test Coverage Program}).
861bb6c1
JL
2805The data file names begin with the name of your source file:
2806
2642624b 2807@table @gcctabopt
861bb6c1
JL
2808@item @var{sourcename}.bb
2809A mapping from basic blocks to line numbers, which @code{gcov} uses to
2810associate basic block execution counts with line numbers.
2811
2812@item @var{sourcename}.bbg
2813A list of all arcs in the program flow graph. This allows @code{gcov}
2814to reconstruct the program flow graph, so that it can compute all basic
2815block and arc execution counts from the information in the
3de87bf2 2816@code{@var{sourcename}.da} file.
861bb6c1
JL
2817@end table
2818
3de87bf2
JJ
2819Use @option{-ftest-coverage} with @option{-fprofile-arcs}; the latter
2820option adds instrumentation to the program, which then writes
2821execution counts to another data file:
2822
2823@table @gcctabopt
2824@item @var{sourcename}.da
2825Runtime arc execution counts, used in conjunction with the arc
2826information in the file @code{@var{sourcename}.bbg}.
2827@end table
2828
2829Coverage data will map better to the source files if
2830@option{-ftest-coverage} is used without optimization.
2831
74291a4b 2832@item -d@var{letters}
cd3bb277 2833@opindex d
74291a4b
MM
2834Says to make debugging dumps during compilation at times specified by
2835@var{letters}. This is used for debugging the compiler. The file names
375e2d5c 2836for most of the dumps are made by appending a pass number and a word to
02f52e19 2837the source file name (e.g. @file{foo.c.00.rtl} or @file{foo.c.01.sibling}).
375e2d5c 2838Here are the possible letters for use in @var{letters}, and their meanings:
74291a4b
MM
2839
2840@table @samp
375e2d5c 2841@item A
cd3bb277 2842@opindex dA
375e2d5c 2843Annotate the assembler output with miscellaneous debugging information.
956d6950 2844@item b
cd3bb277 2845@opindex db
0b47e4c1 2846Dump after computing branch probabilities, to @file{@var{file}.14.bp}.
48d9ade5 2847@item B
cd3bb277 2848@opindex dB
0b47e4c1 2849Dump after block reordering, to @file{@var{file}.28.bbro}.
032713aa 2850@item c
cd3bb277 2851@opindex dc
0b47e4c1 2852Dump after instruction combination, to the file @file{@var{file}.16.combine}.
470fc13d 2853@item C
cd3bb277 2854@opindex dC
0b47e4c1 2855Dump after the first if conversion, to the file @file{@var{file}.17.ce}.
032713aa 2856@item d
cd3bb277 2857@opindex dd
0b47e4c1 2858Dump after delayed branch scheduling, to @file{@var{file}.31.dbr}.
032713aa 2859@item D
cd3bb277 2860@opindex dD
f5963e61
JL
2861Dump all macro definitions, at the end of preprocessing, in addition to
2862normal output.
48d9ade5 2863@item e
cd3bb277 2864@opindex de
0826f1d8 2865Dump after SSA optimizations, to @file{@var{file}.04.ssa} and
0b47e4c1 2866@file{@var{file}.07.ussa}.
470fc13d 2867@item E
cd3bb277 2868@opindex dE
0b47e4c1 2869Dump after the second if conversion, to @file{@var{file}.26.ce2}.
74291a4b 2870@item f
cd3bb277 2871@opindex df
0b47e4c1 2872Dump after life analysis, to @file{@var{file}.15.life}.
48d9ade5 2873@item F
cd3bb277 2874@opindex dF
0b47e4c1 2875Dump after purging @code{ADDRESSOF} codes, to @file{@var{file}.09.addressof}.
74291a4b 2876@item g
cd3bb277 2877@opindex dg
0b47e4c1 2878Dump after global register allocation, to @file{@var{file}.21.greg}.
0826f1d8
JL
2879@item h
2880@opindex dh
2881Dump after finalization of EH handling code, to @file{@var{file}.02.eh}.
2882@item o
cd3bb277 2883@opindex do
9c34dbbf 2884Dump after post-reload optimizations, to @file{@var{file}.22.postreload}.
02f52e19 2885@item G
cd3bb277 2886@opindex dG
0b47e4c1 2887Dump after GCSE, to @file{@var{file}.10.gcse}.
48d9ade5 2888@item i
cd3bb277 2889@opindex di
48d9ade5 2890Dump after sibling call optimizations, to @file{@var{file}.01.sibling}.
032713aa 2891@item j
cd3bb277 2892@opindex dj
0826f1d8 2893Dump after the first jump optimization, to @file{@var{file}.03.jump}.
74291a4b 2894@item k
cd3bb277 2895@opindex dk
0b47e4c1 2896Dump after conversion from registers to stack, to @file{@var{file}.32.stack}.
032713aa 2897@item l
cd3bb277 2898@opindex dl
0b47e4c1 2899Dump after local register allocation, to @file{@var{file}.20.lreg}.
032713aa 2900@item L
cd3bb277 2901@opindex dL
0b47e4c1 2902Dump after loop optimization, to @file{@var{file}.11.loop}.
032713aa 2903@item M
cd3bb277 2904@opindex dM
032713aa 2905Dump after performing the machine dependent reorganisation pass, to
0b47e4c1 2906@file{@var{file}.30.mach}.
48d9ade5 2907@item n
cd3bb277 2908@opindex dn
0b47e4c1 2909Dump after register renumbering, to @file{@var{file}.25.rnreg}.
032713aa 2910@item N
cd3bb277 2911@opindex dN
0b47e4c1 2912Dump after the register move pass, to @file{@var{file}.18.regmove}.
032713aa 2913@item r
cd3bb277 2914@opindex dr
375e2d5c 2915Dump after RTL generation, to @file{@var{file}.00.rtl}.
032713aa 2916@item R
cd3bb277 2917@opindex dR
9c34dbbf 2918Dump after the second scheduling pass, to @file{@var{file}.27.sched2}.
032713aa 2919@item s
cd3bb277 2920@opindex ds
032713aa 2921Dump after CSE (including the jump optimization that sometimes follows
0b47e4c1 2922CSE), to @file{@var{file}.08.cse}.
032713aa 2923@item S
cd3bb277 2924@opindex dS
9c34dbbf 2925Dump after the first scheduling pass, to @file{@var{file}.19.sched}.
032713aa 2926@item t
cd3bb277 2927@opindex dt
032713aa 2928Dump after the second CSE pass (including the jump optimization that
0b47e4c1 2929sometimes follows CSE), to @file{@var{file}.12.cse2}.
48d9ade5 2930@item w
cd3bb277 2931@opindex dw
0b47e4c1 2932Dump after the second flow pass, to @file{@var{file}.23.flow2}.
470fc13d 2933@item X
cd3bb277 2934@opindex dX
9c34dbbf 2935Dump after SSA dead code elimination, to @file{@var{file}.06.ssadce}.
48d9ade5 2936@item z
cd3bb277 2937@opindex dz
0b47e4c1 2938Dump after the peephole pass, to @file{@var{file}.24.peephole2}.
74291a4b 2939@item a
cd3bb277 2940@opindex da
74291a4b
MM
2941Produce all the dumps listed above.
2942@item m
cd3bb277 2943@opindex dm
74291a4b
MM
2944Print statistics on memory usage, at the end of the run, to
2945standard error.
2946@item p
cd3bb277 2947@opindex dp
74291a4b 2948Annotate the assembler output with a comment indicating which
f20b5577
MM
2949pattern and alternative was used. The length of each instruction is
2950also printed.
2856c3e3 2951@item P
cd3bb277 2952@opindex dP
2856c3e3 2953Dump the RTL in the assembler output as a comment before each instruction.
630d3d5a 2954Also turns on @option{-dp} annotation.
375e2d5c 2955@item v
cd3bb277 2956@opindex dv
375e2d5c
RH
2957For each of the other indicated dump files (except for
2958@file{@var{file}.00.rtl}), dump a representation of the control flow graph
b192711e 2959suitable for viewing with VCG to @file{@var{file}.@var{pass}.vcg}.
62a1403d 2960@item x
cd3bb277 2961@opindex dx
62a1403d
AS
2962Just generate RTL for a function instead of compiling it. Usually used
2963with @samp{r}.
032713aa 2964@item y
cd3bb277 2965@opindex dy
032713aa 2966Dump debugging information during parsing, to standard error.
74291a4b
MM
2967@end table
2968
b707b450 2969@item -fdump-unnumbered
cd3bb277 2970@opindex fdump-unnumbered
695ac33f 2971When doing debugging dumps (see @option{-d} option above), suppress instruction
b707b450 2972numbers and line number note output. This makes it more feasible to
b192711e 2973use diff on debugging dumps for compiler invocations with different
695ac33f 2974options, in particular with and without @option{-g}.
b707b450 2975
aee96fe9 2976@item -fdump-translation-unit @r{(C and C++ only)}
22367161 2977@itemx -fdump-translation-unit-@var{options} @r{(C and C++ only)}
cd3bb277 2978@opindex fdump-translation-unit
f71f87f9 2979Dump a representation of the tree structure for the entire translation
767094dd 2980unit to a file. The file name is made by appending @file{.tu} to the
22367161
NS
2981source file name. If the @samp{-@var{options}} form is used, @var{options}
2982controls the details of the dump as described for the
2983@option{-fdump-tree} options.
e76b4820 2984
aee96fe9 2985@item -fdump-class-hierarchy @r{(C++ only)}
22367161 2986@itemx -fdump-class-hierarchy-@var{options} @r{(C++ only)}
cd3bb277 2987@opindex fdump-class-hierarchy
e76b4820 2988Dump a representation of each class's hierarchy and virtual function
767094dd 2989table layout to a file. The file name is made by appending @file{.class}
22367161
NS
2990to the source file name. If the @samp{-@var{options}} form is used,
2991@var{options} controls the details of the dump as described for the
2992@option{-fdump-tree} options.
2993
2994@item -fdump-tree-@var{switch} @r{(C++ only)}
2995@itemx -fdump-tree-@var{switch}-@var{options} @r{(C++ only)}
2996@opindex fdump-tree
2997Control the dumping at various stages of processing the intermediate
2998language tree to a file. The file name is generated by appending a switch
2999specific suffix to the source file name. If the @samp{-@var{options}}
3000form is used, @var{options} is a list of @samp{-} separated options that
3001control the details of the dump. Not all options are applicable to all
3002dumps, those which are not meaningful will be ignored. The following
3003options are available
f71f87f9 3004
e76b4820 3005@table @samp
22367161 3006@item address
767094dd 3007Print the address of each node. Usually this is not meaningful as it
22367161
NS
3008changes according to the environment and source file. Its primary use
3009is for tying up a dump file with a debug environment.
3010@item slim
3011Inhibit dumping of members of a scope or body of a function merely
3012because that scope has been reached. Only dump such items when they
3013are directly reachable by some other path.
3014@item all
3015Turn on all options.
e76b4820
NS
3016@end table
3017
3018The following tree dumps are possible:
3019@table @samp
3020@item original
3021Dump before any tree based optimization, to @file{@var{file}.original}.
3022@item optimized
3023Dump after all tree based optimization, to @file{@var{file}.optimized}.
6be77748 3024@item inlined
9c34dbbf 3025Dump after function inlining, to @file{@var{file}.inlined}.
e76b4820 3026@end table
9965d119 3027
74291a4b 3028@item -fpretend-float
cd3bb277 3029@opindex fpretend-float
74291a4b
MM
3030When running a cross-compiler, pretend that the target machine uses the
3031same floating point format as the host machine. This causes incorrect
3032output of the actual floating constants, but the actual instruction
0c2d1a2a 3033sequence will probably be the same as GCC would make when running on
74291a4b
MM
3034the target machine.
3035
3036@item -save-temps
cd3bb277 3037@opindex save-temps
74291a4b
MM
3038Store the usual ``temporary'' intermediate files permanently; place them
3039in the current directory and name them based on the source file. Thus,
3040compiling @file{foo.c} with @samp{-c -save-temps} would produce files
f2ecb02d
JM
3041@file{foo.i} and @file{foo.s}, as well as @file{foo.o}. This creates a
3042preprocessed @file{foo.i} output file even though the compiler now
3043normally uses an integrated preprocessor.
74291a4b 3044
03c41c05 3045@item -time
cd3bb277 3046@opindex time
03c41c05 3047Report the CPU time taken by each subprocess in the compilation
f2ecb02d
JM
3048sequence. For C source files, this is the compiler proper and assembler
3049(plus the linker if linking is done). The output looks like this:
03c41c05
ZW
3050
3051@smallexample
03c41c05
ZW
3052# cc1 0.12 0.01
3053# as 0.00 0.01
3054@end smallexample
3055
3056The first number on each line is the ``user time,'' that is time spent
3057executing the program itself. The second number is ``system time,''
3058time spent executing operating system routines on behalf of the program.
3059Both numbers are in seconds.
3060
74291a4b 3061@item -print-file-name=@var{library}
cd3bb277 3062@opindex print-file-name
74291a4b
MM
3063Print the full absolute name of the library file @var{library} that
3064would be used when linking---and don't do anything else. With this
0c2d1a2a 3065option, GCC does not compile or link anything; it just prints the
74291a4b
MM
3066file name.
3067
b1018de6
AO
3068@item -print-multi-directory
3069@opindex print-multi-directory
3070Print the directory name corresponding to the multilib selected by any
3071other switches present in the command line. This directory is supposed
3072to exist in @env{GCC_EXEC_PREFIX}.
3073
3074@item -print-multi-lib
3075@opindex print-multi-lib
3076Print the mapping from multilib directory names to compiler switches
3077that enable them. The directory name is separated from the switches by
3078@samp{;}, and each switch starts with an @samp{@@} instead of the
3079@samp{-}, without spaces between multiple switches. This is supposed to
3080ease shell-processing.
3081
74291a4b 3082@item -print-prog-name=@var{program}
cd3bb277 3083@opindex print-prog-name
630d3d5a 3084Like @option{-print-file-name}, but searches for a program such as @samp{cpp}.
74291a4b
MM
3085
3086@item -print-libgcc-file-name
cd3bb277 3087@opindex print-libgcc-file-name
630d3d5a 3088Same as @option{-print-file-name=libgcc.a}.
74291a4b 3089
630d3d5a 3090This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
74291a4b
MM
3091but you do want to link with @file{libgcc.a}. You can do
3092
3093@example
3094gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
3095@end example
3096
3097@item -print-search-dirs
cd3bb277 3098@opindex print-search-dirs
74291a4b
MM
3099Print the name of the configured installation directory and a list of
3100program and library directories gcc will search---and don't do anything else.
3101
3102This is useful when gcc prints the error message
3c0b7970
JM
3103@samp{installation problem, cannot exec cpp0: No such file or directory}.
3104To resolve this you either need to put @file{cpp0} and the other compiler
74291a4b 3105components where gcc expects to find them, or you can set the environment
bedc7537 3106variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
74291a4b
MM
3107Don't forget the trailing '/'.
3108@xref{Environment Variables}.
1f0c3120
JM
3109
3110@item -dumpmachine
cd3bb277 3111@opindex dumpmachine
1f0c3120
JM
3112Print the compiler's target machine (for example,
3113@samp{i686-pc-linux-gnu})---and don't do anything else.
3114
3115@item -dumpversion
cd3bb277 3116@opindex dumpversion
1f0c3120
JM
3117Print the compiler version (for example, @samp{3.0})---and don't do
3118anything else.
3119
3120@item -dumpspecs
cd3bb277 3121@opindex dumpspecs
1f0c3120
JM
3122Print the compiler's built-in specs---and don't do anything else. (This
3123is used when GCC itself is being built.) @xref{Spec Files}.
74291a4b
MM
3124@end table
3125
3126@node Optimize Options
3127@section Options That Control Optimization
3128@cindex optimize options
3129@cindex options, optimization
3130
3131These options control various sorts of optimizations:
3132
2642624b 3133@table @gcctabopt
74291a4b
MM
3134@item -O
3135@itemx -O1
cd3bb277
JM
3136@opindex O
3137@opindex O1
74291a4b
MM
3138Optimize. Optimizing compilation takes somewhat more time, and a lot
3139more memory for a large function.
3140
630d3d5a 3141Without @option{-O}, the compiler's goal is to reduce the cost of
74291a4b
MM
3142compilation and to make debugging produce the expected results.
3143Statements are independent: if you stop the program with a breakpoint
3144between statements, you can then assign a new value to any variable or
3145change the program counter to any other statement in the function and
3146get exactly the results you would expect from the source code.
3147
630d3d5a 3148With @option{-O}, the compiler tries to reduce code size and execution
9c34dbbf
ZW
3149time, without performing any optimizations that take a great deal of
3150compilation time.
74291a4b
MM
3151
3152@item -O2
cd3bb277 3153@opindex O2
0c2d1a2a 3154Optimize even more. GCC performs nearly all supported optimizations
74291a4b 3155that do not involve a space-speed tradeoff. The compiler does not
630d3d5a
JM
3156perform loop unrolling or function inlining when you specify @option{-O2}.
3157As compared to @option{-O}, this option increases both compilation time
74291a4b
MM
3158and the performance of the generated code.
3159
630d3d5a 3160@option{-O2} turns on all optional optimizations except for loop unrolling,
2b2a8f1f 3161function inlining, and register renaming. It also turns on the
630d3d5a 3162@option{-fforce-mem} option on all machines and frame pointer elimination
2b2a8f1f 3163on machines where doing so does not interfere with debugging.
74291a4b 3164
081ca317
BL
3165Please note the warning under @option{-fgcse} about
3166invoking @option{-O2} on programs that use computed gotos.
3167
74291a4b 3168@item -O3
cd3bb277 3169@opindex O3
630d3d5a
JM
3170Optimize yet more. @option{-O3} turns on all optimizations specified by
3171@option{-O2} and also turns on the @option{-finline-functions} and
3172@option{-frename-registers} options.
74291a4b
MM
3173
3174@item -O0
cd3bb277 3175@opindex O0
74291a4b
MM
3176Do not optimize.
3177
c6aded7c 3178@item -Os
cd3bb277 3179@opindex Os
630d3d5a 3180Optimize for size. @option{-Os} enables all @option{-O2} optimizations that
c6aded7c
AG
3181do not typically increase code size. It also performs further
3182optimizations designed to reduce code size.
3183
630d3d5a 3184If you use multiple @option{-O} options, with or without level numbers,
74291a4b
MM
3185the last such option is the one that is effective.
3186@end table
3187
630d3d5a 3188Options of the form @option{-f@var{flag}} specify machine-independent
74291a4b 3189flags. Most flags have both positive and negative forms; the negative
630d3d5a 3190form of @option{-ffoo} would be @option{-fno-foo}. In the table below,
74291a4b
MM
3191only one of the forms is listed---the one which is not the default.
3192You can figure out the other form by either removing @samp{no-} or
3193adding it.
3194
2642624b 3195@table @gcctabopt
74291a4b 3196@item -ffloat-store
cd3bb277 3197@opindex ffloat-store
74291a4b
MM
3198Do not store floating point variables in registers, and inhibit other
3199options that might change whether a floating point value is taken from a
3200register or memory.
3201
3202@cindex floating point precision
3203This option prevents undesirable excess precision on machines such as
3204the 68000 where the floating registers (of the 68881) keep more
3205precision than a @code{double} is supposed to have. Similarly for the
3206x86 architecture. For most programs, the excess precision does only
3207good, but a few programs rely on the precise definition of IEEE floating
630d3d5a 3208point. Use @option{-ffloat-store} for such programs, after modifying
6fd74494 3209them to store all pertinent intermediate computations into variables.
74291a4b
MM
3210
3211@item -fno-default-inline
cd3bb277 3212@opindex fno-default-inline
74291a4b
MM
3213Do not make member functions inline by default merely because they are
3214defined inside the class scope (C++ only). Otherwise, when you specify
630d3d5a 3215@w{@option{-O}}, member functions defined inside class scope are compiled
74291a4b
MM
3216inline by default; i.e., you don't need to add @samp{inline} in front of
3217the member function name.
3218
3219@item -fno-defer-pop
cd3bb277 3220@opindex fno-defer-pop
74291a4b
MM
3221Always pop the arguments to each function call as soon as that function
3222returns. For machines which must pop arguments after a function call,
3223the compiler normally lets arguments accumulate on the stack for several
3224function calls and pops them all at once.
3225
3226@item -fforce-mem
cd3bb277 3227@opindex fforce-mem
74291a4b
MM
3228Force memory operands to be copied into registers before doing
3229arithmetic on them. This produces better code by making all memory
3230references potential common subexpressions. When they are not common
3231subexpressions, instruction combination should eliminate the separate
630d3d5a 3232register-load. The @option{-O2} option turns on this option.
74291a4b
MM
3233
3234@item -fforce-addr
cd3bb277 3235@opindex fforce-addr
74291a4b
MM
3236Force memory address constants to be copied into registers before
3237doing arithmetic on them. This may produce better code just as
630d3d5a 3238@option{-fforce-mem} may.
74291a4b
MM
3239
3240@item -fomit-frame-pointer
cd3bb277 3241@opindex fomit-frame-pointer
74291a4b
MM
3242Don't keep the frame pointer in a register for functions that
3243don't need one. This avoids the instructions to save, set up and
3244restore frame pointers; it also makes an extra register available
3245in many functions. @strong{It also makes debugging impossible on
3246some machines.}
3247
3248@ifset INTERNALS
8aeea6e6 3249On some machines, such as the VAX, this flag has no effect, because
74291a4b
MM
3250the standard calling sequence automatically handles the frame pointer
3251and nothing is saved by pretending it doesn't exist. The
3252machine-description macro @code{FRAME_POINTER_REQUIRED} controls
bd819a4a 3253whether a target machine supports this flag. @xref{Registers}.
74291a4b
MM
3254@end ifset
3255@ifclear INTERNALS
8aeea6e6 3256On some machines, such as the VAX, this flag has no effect, because
74291a4b
MM
3257the standard calling sequence automatically handles the frame pointer
3258and nothing is saved by pretending it doesn't exist. The
3259machine-description macro @code{FRAME_POINTER_REQUIRED} controls
3260whether a target machine supports this flag. @xref{Registers,,Register
bd819a4a 3261Usage, gcc.info, Using and Porting GCC}.
74291a4b
MM
3262@end ifclear
3263
1aaef9c1 3264@item -foptimize-sibling-calls
cd3bb277 3265@opindex foptimize-sibling-calls
1aaef9c1
JH
3266Optimize sibling and tail recursive calls.
3267
91ce572a 3268@item -ftrapv
cd3bb277 3269@opindex ftrapv
91ce572a
CC
3270This option generates traps for signed overflow on addition, subtraction,
3271multiplication operations.
3272
74291a4b 3273@item -fno-inline
cd3bb277 3274@opindex fno-inline
74291a4b
MM
3275Don't pay attention to the @code{inline} keyword. Normally this option
3276is used to keep the compiler from expanding any functions inline.
3277Note that if you are not optimizing, no functions can be expanded inline.
3278
3279@item -finline-functions
cd3bb277 3280@opindex finline-functions
74291a4b
MM
3281Integrate all simple functions into their callers. The compiler
3282heuristically decides which functions are simple enough to be worth
3283integrating in this way.
3284
3285If all calls to a given function are integrated, and the function is
3286declared @code{static}, then the function is normally not output as
3287assembler code in its own right.
3288
efa3896a 3289@item -finline-limit=@var{n}
cd3bb277 3290@opindex finline-limit
f9e814f1
TP
3291By default, gcc limits the size of functions that can be inlined. This flag
3292allows the control of this limit for functions that are explicitly marked as
02f52e19
AJ
3293inline (ie marked with the inline keyword or defined within the class
3294definition in c++). @var{n} is the size of functions that can be inlined in
f9e814f1 3295number of pseudo instructions (not counting parameter handling). The default
93ee12c4
GP
3296value of @var{n} is 600.
3297Increasing this value can result in more inlined code at
f9e814f1 3298the cost of compilation time and memory consumption. Decreasing usually makes
02f52e19
AJ
3299the compilation faster and less code will be inlined (which presumably
3300means slower programs). This option is particularly useful for programs that
aee96fe9 3301use inlining heavily such as those based on recursive templates with C++.
f9e814f1
TP
3302
3303@emph{Note:} pseudo instruction represents, in this particular context, an
3304abstract measurement of function's size. In no way, it represents a count
3305of assembly instructions and as such its exact meaning might change from one
3306release to an another.
3307
74291a4b 3308@item -fkeep-inline-functions
cd3bb277 3309@opindex fkeep-inline-functions
74291a4b
MM
3310Even if all calls to a given function are integrated, and the function
3311is declared @code{static}, nevertheless output a separate run-time
3312callable version of the function. This switch does not affect
3313@code{extern inline} functions.
3314
3315@item -fkeep-static-consts
cd3bb277 3316@opindex fkeep-static-consts
74291a4b
MM
3317Emit variables declared @code{static const} when optimization isn't turned
3318on, even if the variables aren't referenced.
3319
0c2d1a2a 3320GCC enables this option by default. If you want to force the compiler to
74291a4b 3321check if the variable was referenced, regardless of whether or not
630d3d5a 3322optimization is turned on, use the @option{-fno-keep-static-consts} option.
74291a4b 3323
201556f0
JJ
3324@item -fmerge-constants
3325Attempt to merge identical constants (string constants and floating point
3326constants) accross compilation units.
3327
3328This option is default for optimized compilation if assembler and linker
3329support it. Use @option{-fno-merge-constants} to inhibit this behaviour.
3330
3331@item -fmerge-all-constants
3332Attempt to merge identical constants and identical variables.
3333
3334This option implies @option{-fmerge-constants}. In addition to
3335@option{-fmerge-constants} this considers e.g. even constant initialized
3336arrays or initialized constant variables with integral or floating point
3337types. Languages like C or C++ require each non-automatic variable to
3338have distinct location, so using this option will result in non-conforming
3339behaviour.
3340
74291a4b 3341@item -fno-function-cse
cd3bb277 3342@opindex fno-function-cse
74291a4b
MM
3343Do not put function addresses in registers; make each instruction that
3344calls a constant function contain the function's address explicitly.
3345
3346This option results in less efficient code, but some strange hacks
3347that alter the assembler output may be confused by the optimizations
3348performed when this option is not used.
3349
3350@item -ffast-math
cd3bb277 3351@opindex ffast-math
9c34dbbf
ZW
3352Sets @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, and @*
3353@option{-fno-trapping-math}.
de6c5979 3354
630d3d5a 3355This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
74291a4b 3356
630d3d5a 3357This option should never be turned on by any @option{-O} option since
74291a4b 3358it can result in incorrect output for programs which depend on
c1030c7c 3359an exact implementation of IEEE or ISO rules/specifications for
74291a4b 3360math functions.
9605da8a
BL
3361
3362@item -fno-math-errno
cd3bb277 3363@opindex fno-math-errno
9605da8a
BL
3364Do not set ERRNO after calling math functions that are executed
3365with a single instruction, e.g., sqrt. A program that relies on
3366IEEE exceptions for math error handling may want to use this flag
3367for speed while maintaining IEEE arithmetic compatibility.
3368
630d3d5a 3369This option should never be turned on by any @option{-O} option since
de6c5979
BL
3370it can result in incorrect output for programs which depend on
3371an exact implementation of IEEE or ISO rules/specifications for
3372math functions.
3373
9c34dbbf 3374The default is @option{-fmath-errno}.
de6c5979
BL
3375
3376@item -funsafe-math-optimizations
cd3bb277 3377@opindex funsafe-math-optimizations
de6c5979
BL
3378Allow optimizations for floating-point arithmetic that (a) assume
3379that arguments and results are valid and (b) may violate IEEE or
237b14f7
RH
3380ANSI standards. When used at link-time, it may include libraries
3381or startup files that change the default FPU control word or other
3382similar optimizations.
de6c5979 3383
630d3d5a 3384This option should never be turned on by any @option{-O} option since
de6c5979
BL
3385it can result in incorrect output for programs which depend on
3386an exact implementation of IEEE or ISO rules/specifications for
3387math functions.
3388
9c34dbbf 3389The default is @option{-fno-unsafe-math-optimizations}.
de6c5979
BL
3390
3391@item -fno-trapping-math
cd3bb277 3392@opindex fno-trapping-math
de6c5979
BL
3393Compile code assuming that floating-point operations cannot generate
3394user-visible traps. Setting this option may allow faster code
3395if one relies on ``non-stop'' IEEE arithmetic, for example.
3396
630d3d5a 3397This option should never be turned on by any @option{-O} option since
de6c5979
BL
3398it can result in incorrect output for programs which depend on
3399an exact implementation of IEEE or ISO rules/specifications for
3400math functions.
3401
9c34dbbf 3402The default is @option{-ftrapping-math}.
74291a4b
MM
3403@end table
3404
630d3d5a
JM
3405The following options control specific optimizations. The @option{-O2}
3406option turns on all of these optimizations except @option{-funroll-loops}
3407and @option{-funroll-all-loops}. On most machines, the @option{-O} option
3408turns on the @option{-fthread-jumps} and @option{-fdelayed-branch} options,
74291a4b
MM
3409but specific machines may handle it differently.
3410
3411You can use the following flags in the rare cases when ``fine-tuning''
3412of optimizations to be performed is desired.
3413
9c34dbbf
ZW
3414Not all of the optimizations performed by GCC have @option{-f} options
3415to control them.
3416
2642624b 3417@table @gcctabopt
74291a4b 3418@item -fstrength-reduce
cd3bb277 3419@opindex fstrength-reduce
74291a4b
MM
3420Perform the optimizations of loop strength reduction and
3421elimination of iteration variables.
3422
3423@item -fthread-jumps
cd3bb277 3424@opindex fthread-jumps
74291a4b
MM
3425Perform optimizations where we check to see if a jump branches to a
3426location where another comparison subsumed by the first is found. If
3427so, the first branch is redirected to either the destination of the
3428second branch or a point immediately following it, depending on whether
3429the condition is known to be true or false.
3430
3431@item -fcse-follow-jumps
cd3bb277 3432@opindex fcse-follow-jumps
74291a4b
MM
3433In common subexpression elimination, scan through jump instructions
3434when the target of the jump is not reached by any other path. For
3435example, when CSE encounters an @code{if} statement with an
3436@code{else} clause, CSE will follow the jump when the condition
3437tested is false.
3438
3439@item -fcse-skip-blocks
cd3bb277 3440@opindex fcse-skip-blocks
630d3d5a 3441This is similar to @option{-fcse-follow-jumps}, but causes CSE to
74291a4b
MM
3442follow jumps which conditionally skip over blocks. When CSE
3443encounters a simple @code{if} statement with no else clause,
630d3d5a 3444@option{-fcse-skip-blocks} causes CSE to follow the jump around the
74291a4b
MM
3445body of the @code{if}.
3446
3447@item -frerun-cse-after-loop
cd3bb277 3448@opindex frerun-cse-after-loop
74291a4b
MM
3449Re-run common subexpression elimination after loop optimizations has been
3450performed.
3451
6d6d0fa0 3452@item -frerun-loop-opt
cd3bb277 3453@opindex frerun-loop-opt
6d6d0fa0
JL
3454Run the loop optimizer twice.
3455
7506f491 3456@item -fgcse
cd3bb277 3457@opindex fgcse
7506f491
DE
3458Perform a global common subexpression elimination pass.
3459This pass also performs global constant and copy propagation.
3460
081ca317
BL
3461@emph{Note:} When compiling a program using computed gotos, a GCC
3462extension, you may get better runtime performance if you disable
3463the global common subexpression elmination pass by adding
3464@option{-fno-gcse} to the command line.
3465
a13d4ebf 3466@item -fgcse-lm
cd3bb277 3467@opindex fgcse-lm
695ac33f 3468When @option{-fgcse-lm} is enabled, global common subexpression elimination will
767094dd 3469attempt to move loads which are only killed by stores into themselves. This
a13d4ebf 3470allows a loop containing a load/store sequence to be changed to a load outside
02f52e19 3471the loop, and a copy/store within the loop.
a13d4ebf
AM
3472
3473@item -fgcse-sm
cd3bb277 3474@opindex fgcse-sm
695ac33f 3475When @option{-fgcse-sm} is enabled, A store motion pass is run after global common
767094dd 3476subexpression elimination. This pass will attempt to move stores out of loops.
695ac33f 3477When used in conjunction with @option{-fgcse-lm}, loops containing a load/store sequence
a13d4ebf
AM
3478can be changed to a load before the loop and a store after the loop.
3479
b6d24183 3480@item -fdelete-null-pointer-checks
cd3bb277 3481@opindex fdelete-null-pointer-checks
9c34dbbf
ZW
3482Use global dataflow analysis to identify and eliminate useless checks
3483for null pointers. The compiler assumes that dereferencing a null
3484pointer would have halted the program. If a pointer is checked after
3485it has already been dereferenced, it cannot be null.
3486
3487In some environments, this assumption is not true, and programs can
3488safely dereference null pointers. Use
3489@option{-fno-delete-null-pointer-checks} to disable this optimization
3490for programs which depend on that behavior.
b6d24183 3491
74291a4b 3492@item -fexpensive-optimizations
cd3bb277 3493@opindex fexpensive-optimizations
74291a4b
MM
3494Perform a number of minor optimizations that are relatively expensive.
3495
639726ba 3496@item -foptimize-register-move
59d40964 3497@itemx -fregmove
cd3bb277
JM
3498@opindex foptimize-register-move
3499@opindex fregmove
9ec36da5
JL
3500Attempt to reassign register numbers in move instructions and as
3501operands of other simple instructions in order to maximize the amount of
56159047 3502register tying. This is especially helpful on machines with two-operand
630d3d5a 3503instructions. GCC enables this optimization by default with @option{-O2}
9ec36da5
JL
3504or higher.
3505
bedc7537 3506Note @option{-fregmove} and @option{-foptimize-register-move} are the same
9ec36da5
JL
3507optimization.
3508
74291a4b 3509@item -fdelayed-branch
cd3bb277 3510@opindex fdelayed-branch
74291a4b
MM
3511If supported for the target machine, attempt to reorder instructions
3512to exploit instruction slots available after delayed branch
3513instructions.
3514
3515@item -fschedule-insns
cd3bb277 3516@opindex fschedule-insns
74291a4b
MM
3517If supported for the target machine, attempt to reorder instructions to
3518eliminate execution stalls due to required data being unavailable. This
3519helps machines that have slow floating point or memory load instructions
3520by allowing other instructions to be issued until the result of the load
3521or floating point instruction is required.
3522
3523@item -fschedule-insns2
cd3bb277 3524@opindex fschedule-insns2
630d3d5a 3525Similar to @option{-fschedule-insns}, but requests an additional pass of
74291a4b
MM
3526instruction scheduling after register allocation has been done. This is
3527especially useful on machines with a relatively small number of
3528registers and where memory load instructions take more than one cycle.
3529
3530@item -ffunction-sections
59d40964 3531@itemx -fdata-sections
cd3bb277
JM
3532@opindex ffunction-sections
3533@opindex fdata-sections
7d0756fb
CM
3534Place each function or data item into its own section in the output
3535file if the target supports arbitrary sections. The name of the
3536function or the name of the data item determines the section's name
3537in the output file.
74291a4b 3538
7d0756fb 3539Use these options on systems where the linker can perform optimizations
74291a4b
MM
3540to improve locality of reference in the instruction space. HPPA
3541processors running HP-UX and Sparc processors running Solaris 2 have
3542linkers with such optimizations. Other systems using the ELF object format
3543as well as AIX may have these optimizations in the future.
3544
7d0756fb
CM
3545Only use these options when there are significant benefits from doing
3546so. When you specify these options, the assembler and linker will
74291a4b
MM
3547create larger object and executable files and will also be slower.
3548You will not be able to use @code{gprof} on all systems if you
3549specify this option and you may have problems with debugging if
630d3d5a 3550you specify both this option and @option{-g}.
74291a4b
MM
3551
3552@item -fcaller-saves
cd3bb277 3553@opindex fcaller-saves
74291a4b
MM
3554Enable values to be allocated in registers that will be clobbered by
3555function calls, by emitting extra instructions to save and restore the
3556registers around such calls. Such allocation is done only when it
3557seems to result in better code than would otherwise be produced.
3558
81610a0d
HPN
3559This option is always enabled by default on certain machines, usually
3560those which have no call-preserved registers to use instead.
3561
3562For all machines, optimization level 2 and higher enables this flag by
3563default.
74291a4b
MM
3564
3565@item -funroll-loops
cd3bb277 3566@opindex funroll-loops
9c34dbbf
ZW
3567Unroll loops whose number of iterations can be determined at compile
3568time or upon entry to the loop. @option{-funroll-loops} implies both
3569@option{-fstrength-reduce} and @option{-frerun-cse-after-loop}. This
3570option makes code larger, and may or may not make it run faster.
74291a4b
MM
3571
3572@item -funroll-all-loops
cd3bb277 3573@opindex funroll-all-loops
9c34dbbf
ZW
3574Unroll all loops, even if their number of iterations is uncertain when
3575the loop is entered. This usually makes programs run more slowly.
3576@option{-funroll-all-loops} implies the same options as
3577@option{-funroll-loops},
3578
74291a4b 3579
e5eb27e5 3580@item -fmove-all-movables
cd3bb277 3581@opindex fmove-all-movables
e5eb27e5
JL
3582Forces all invariant computations in loops to be moved
3583outside the loop.
3584
3585@item -freduce-all-givs
cd3bb277 3586@opindex freduce-all-givs
e5eb27e5
JL
3587Forces all general-induction variables in loops to be
3588strength-reduced.
3589
3590@emph{Note:} When compiling programs written in Fortran,
630d3d5a 3591@option{-fmove-all-movables} and @option{-freduce-all-givs} are enabled
e5eb27e5
JL
3592by default when you use the optimizer.
3593
3594These options may generate better or worse code; results are highly
3595dependent on the structure of loops within the source code.
3596
3597These two options are intended to be removed someday, once
3598they have helped determine the efficacy of various
3599approaches to improving loop optimizations.
3600
2642624b 3601Please let us (@w{@email{gcc@@gcc.gnu.org}} and @w{@email{fortran@@gnu.org}})
e5eb27e5
JL
3602know how use of these options affects
3603the performance of your production code.
3604We're very interested in code that runs @emph{slower}
3605when these options are @emph{enabled}.
3606
74291a4b 3607@item -fno-peephole
6cfc0341 3608@itemx -fno-peephole2
cd3bb277 3609@opindex fno-peephole
6cfc0341
RH
3610@opindex fno-peephole2
3611Disable any machine-specific peephole optimizations. The difference
630d3d5a 3612between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
6cfc0341
RH
3613are implemented in the compiler; some targets use one, some use the
3614other, a few use both.
861bb6c1
JL
3615
3616@item -fbranch-probabilities
cd3bb277 3617@opindex fbranch-probabilities
630d3d5a 3618After running a program compiled with @option{-fprofile-arcs}
861bb6c1 3619(@pxref{Debugging Options,, Options for Debugging Your Program or
bedc7537 3620@command{gcc}}), you can compile it a second time using
630d3d5a 3621@option{-fbranch-probabilities}, to improve optimizations based on
3de87bf2
JJ
3622the number of times each branch was taken. When the program
3623compiled with @option{-fprofile-arcs} exits it saves arc execution
3624counts to a file called @file{@var{sourcename}.da} for each source
3625file The information in this data file is very dependent on the
3626structure of the generated code, so you must use the same source code
3627and the same optimization options for both compilations.
861bb6c1
JL
3628
3629@ifset INTERNALS
630d3d5a 3630With @option{-fbranch-probabilities}, GCC puts a @samp{REG_EXEC_COUNT}
861bb6c1
JL
3631note on the first instruction of each basic block, and a
3632@samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
3633These can be used to improve optimization. Currently, they are only
3634used in one place: in @file{reorg.c}, instead of guessing which path a
3635branch is mostly to take, the @samp{REG_BR_PROB} values are used to
3636exactly determine which path is taken more often.
3637@end ifset
8c660648 3638
454d0cc7 3639@item -fno-guess-branch-probability
cd3bb277 3640@opindex fno-guess-branch-probability
9c34dbbf
ZW
3641Do not guess branch probabilities using a randomized model.
3642
3643Sometimes gcc will opt to use a randomized model to guess branch
3644probabilities, when none are available from either profiling feedback
3645(@option{-fprofile-arcs}) or @samp{__builtin_expect}. This means that
3646different runs of the compiler on the same program may produce different
3647object code.
3648
3649In a hard real-time system, people don't want different runs of the
3650compiler to produce code that has different behavior; minimizing
3651non-determinism is of paramount import. This switch allows users to
3652reduce non-determinism, possibly at the expense of inferior
3653optimization.
454d0cc7 3654
41472af8 3655@item -fstrict-aliasing
cd3bb277 3656@opindex fstrict-aliasing
41472af8
MM
3657Allows the compiler to assume the strictest aliasing rules applicable to
3658the language being compiled. For C (and C++), this activates
3659optimizations based on the type of expressions. In particular, an
3660object of one type is assumed never to reside at the same address as an
3661object of a different type, unless the types are almost the same. For
3662example, an @code{unsigned int} can alias an @code{int}, but not a
3663@code{void*} or a @code{double}. A character type may alias any other
02f52e19 3664type.
41472af8
MM
3665
3666Pay special attention to code like this:
3667@example
02f52e19 3668union a_union @{
41472af8
MM
3669 int i;
3670 double d;
3671@};
3672
3673int f() @{
3674 a_union t;
3675 t.d = 3.0;
3676 return t.i;
3677@}
3678@end example
3679The practice of reading from a different union member than the one most
3680recently written to (called ``type-punning'') is common. Even with
630d3d5a 3681@option{-fstrict-aliasing}, type-punning is allowed, provided the memory
41472af8
MM
3682is accessed through the union type. So, the code above will work as
3683expected. However, this code might not:
3684@example
02f52e19 3685int f() @{
41472af8
MM
3686 a_union t;
3687 int* ip;
3688 t.d = 3.0;
3689 ip = &t.i;
3690 return *ip;
3691@}
3692@end example
3693
41472af8
MM
3694@ifset INTERNALS
3695Every language that wishes to perform language-specific alias analysis
3696should define a function that computes, given an @code{tree}
3697node, an alias set for the node. Nodes in different alias sets are not
3698allowed to alias. For an example, see the C front-end function
3699@code{c_get_alias_set}.
3700@end ifset
3701
efa3896a
GK
3702@item -falign-functions
3703@itemx -falign-functions=@var{n}
cd3bb277 3704@opindex falign-functions
efa3896a
GK
3705Align the start of functions to the next power-of-two greater than
3706@var{n}, skipping up to @var{n} bytes. For instance,
630d3d5a
JM
3707@option{-falign-functions=32} aligns functions to the next 32-byte
3708boundary, but @option{-falign-functions=24} would align to the next
efa3896a
GK
370932-byte boundary only if this can be done by skipping 23 bytes or less.
3710
630d3d5a 3711@option{-fno-align-functions} and @option{-falign-functions=1} are
efa3896a
GK
3712equivalent and mean that functions will not be aligned.
3713
3714Some assemblers only support this flag when @var{n} is a power of two;
3715in that case, it is rounded up.
3716
3717If @var{n} is not specified, use a machine-dependent default.
3718
3719@item -falign-labels
3720@itemx -falign-labels=@var{n}
cd3bb277 3721@opindex falign-labels
efa3896a 3722Align all branch targets to a power-of-two boundary, skipping up to
630d3d5a 3723@var{n} bytes like @option{-falign-functions}. This option can easily
efa3896a
GK
3724make code slower, because it must insert dummy operations for when the
3725branch target is reached in the usual flow of the code.
3726
630d3d5a 3727If @option{-falign-loops} or @option{-falign-jumps} are applicable and
efa3896a
GK
3728are greater than this value, then their values are used instead.
3729
3730If @var{n} is not specified, use a machine-dependent default which is
3731very likely to be @samp{1}, meaning no alignment.
3732
3733@item -falign-loops
3734@itemx -falign-loops=@var{n}
cd3bb277 3735@opindex falign-loops
efa3896a 3736Align loops to a power-of-two boundary, skipping up to @var{n} bytes
630d3d5a 3737like @option{-falign-functions}. The hope is that the loop will be
efa3896a
GK
3738executed many times, which will make up for any execution of the dummy
3739operations.
3740
3741If @var{n} is not specified, use a machine-dependent default.
3742
3743@item -falign-jumps
3744@itemx -falign-jumps=@var{n}
cd3bb277 3745@opindex falign-jumps
efa3896a
GK
3746Align branch targets to a power-of-two boundary, for branch targets
3747where the targets can only be reached by jumping, skipping up to @var{n}
630d3d5a 3748bytes like @option{-falign-functions}. In this case, no dummy operations
efa3896a
GK
3749need be executed.
3750
3751If @var{n} is not specified, use a machine-dependent default.
3752
4bae0b47 3753@item -fssa
cd3bb277 3754@opindex fssa
4bae0b47
AS
3755Perform optimizations in static single assignment form. Each function's
3756flow graph is translated into SSA form, optimizations are performed, and
90ecce3e 3757the flow graph is translated back from SSA form. Users should not
b53978a3
JO
3758specify this option, since it is not yet ready for production use.
3759
0b47e4c1
JL
3760@item -fssa-ccp
3761@opindex fssa-ccp
3762Perform Sparse Conditional Constant Propagation in SSA form. Requires
3763@option{-fssa}. Like @option{-fssa}, this is an experimental feature.
3764
62d285ff
JL
3765@item -fssa-dce
3766@opindex fssa-dce
3767Perform aggressive dead-code elimination in SSA form. Requires @option{-fssa}.
3768Like @option{-fssa}, this is an experimental feature.
4bae0b47 3769
46d3a873 3770@item -fsingle-precision-constant
cd3bb277 3771@opindex fsingle-precision-constant
46d3a873
CC
3772Treat floating point constant as single precision constant instead of
3773implicitly converting it to double precision constant.
3774
2b2a8f1f 3775@item -frename-registers
cd3bb277 3776@opindex frename-registers
c771326b 3777Attempt to avoid false dependencies in scheduled code by making use
2b2a8f1f
RH
3778of registers left over after register allocation. This optimization
3779will most benefit processors with lots of registers. It can, however,
3780make debugging impossible, since variables will no longer stay in
3781a ``home register''.
3af64fd6
MM
3782
3783@item --param @var{name}=@var{value}
cd3bb277 3784@opindex param
3af64fd6
MM
3785In some places, GCC uses various constants to control the amount of
3786optimization that is done. For example, GCC will not inline functions
3787that contain more that a certain number of instructions. You can
3788control some of these constants on the command-line using the
630d3d5a 3789@option{--param} option.
3af64fd6
MM
3790
3791In each case, the @var{value} is a integer. The allowable choices for
3792@var{name} are given in the following table:
3793
3794@table @gcctabopt
1c4c47db
JO
3795@item max-delay-slot-insn-search
3796The maximum number of instructions to consider when looking for an
3797instruction to fill a delay slot. If more than this arbitrary number of
3798instructions is searched, the time savings from filling the delay slot
3799will be minimal so stop searching. Increasing values mean more
3800aggressive optimization, making the compile time increase with probably
3801small improvement in executable run time.
3802
3803@item max-delay-slot-live-search
3804When trying to fill delay slots, the maximum number of instructions to
3805consider when searching for a block with valid live register
3806information. Increasing this arbitrarily chosen value means more
3807aggressive optimization, increasing the compile time. This parameter
3808should be removed when the delay slot code is rewritten to maintain the
3809control-flow graph.
33d3b05b
MM
3810
3811@item max-gcse-memory
3812The approximate maximum amount of memory that will be allocated in
3813order to perform the global common subexpression elimination
3814optimization. If more memory than specified is required, the
3815optimization will not be done.
3af64fd6 3816
740f35a0 3817@item max-gcse-passes
7dac2f89 3818The maximum number of passes of GCSE to run.
740f35a0 3819
4a121cc3
AM
3820@item max-pending-list-length
3821The maximum number of pending dependancies scheduling will allow
3822before flushing the current state and starting over. Large functions
3823with few branches or calls can create excessively large lists which
3824needlessly consume memory and resources.
3825
1c4c47db
JO
3826@item max-inline-insns
3827If an function contains more than this many instructions, it
3828will not be inlined. This option is precisely equivalent to
630d3d5a 3829@option{-finline-limit}.
1c4c47db
JO
3830
3831@end table
74291a4b
MM
3832@end table
3833
3834@node Preprocessor Options
3835@section Options Controlling the Preprocessor
3836@cindex preprocessor options
3837@cindex options, preprocessor
3838
3839These options control the C preprocessor, which is run on each C source
3840file before actual compilation.
3841
630d3d5a
JM
3842If you use the @option{-E} option, nothing is done except preprocessing.
3843Some of these options make sense only together with @option{-E} because
74291a4b
MM
3844they cause the preprocessor output to be unsuitable for actual
3845compilation.
3846
2642624b 3847@table @gcctabopt
74291a4b 3848@item -include @var{file}
cd3bb277 3849@opindex include
74291a4b 3850Process @var{file} as input before processing the regular input file.
630d3d5a
JM
3851In effect, the contents of @var{file} are compiled first. Any @option{-D}
3852and @option{-U} options on the command line are always processed before
3853@option{-include @var{file}}, regardless of the order in which they are
3854written. All the @option{-include} and @option{-imacros} options are
74291a4b
MM
3855processed in the order in which they are written.
3856
3857@item -imacros @var{file}
cd3bb277 3858@opindex imacros
74291a4b
MM
3859Process @var{file} as input, discarding the resulting output, before
3860processing the regular input file. Because the output generated from
630d3d5a 3861@var{file} is discarded, the only effect of @option{-imacros @var{file}}
74291a4b 3862is to make the macros defined in @var{file} available for use in the
630d3d5a 3863main input. All the @option{-include} and @option{-imacros} options are
e582248c 3864processed in the order in which they are written.
74291a4b
MM
3865
3866@item -idirafter @var{dir}
cd3bb277 3867@opindex idirafter
74291a4b
MM
3868@cindex second include path
3869Add the directory @var{dir} to the second include path. The directories
3870on the second include path are searched when a header file is not found
3871in any of the directories in the main include path (the one that
630d3d5a 3872@option{-I} adds to).
74291a4b
MM
3873
3874@item -iprefix @var{prefix}
cd3bb277 3875@opindex iprefix
630d3d5a 3876Specify @var{prefix} as the prefix for subsequent @option{-iwithprefix}
74291a4b
MM
3877options.
3878
3879@item -iwithprefix @var{dir}
cd3bb277 3880@opindex iwithprefix
74291a4b
MM
3881Add a directory to the second include path. The directory's name is
3882made by concatenating @var{prefix} and @var{dir}, where @var{prefix} was
630d3d5a 3883specified previously with @option{-iprefix}. If you have not specified a
74291a4b
MM
3884prefix yet, the directory containing the installed passes of the
3885compiler is used as the default.
3886
3887@item -iwithprefixbefore @var{dir}
cd3bb277 3888@opindex iwithprefixbefore
74291a4b
MM
3889Add a directory to the main include path. The directory's name is made
3890by concatenating @var{prefix} and @var{dir}, as in the case of
630d3d5a 3891@option{-iwithprefix}.
74291a4b
MM
3892
3893@item -isystem @var{dir}
cd3bb277 3894@opindex isystem
74291a4b
MM
3895Add a directory to the beginning of the second include path, marking it
3896as a system directory, so that it gets the same special treatment as
3897is applied to the standard system directories.
3898
3899@item -nostdinc
cd3bb277 3900@opindex nostdinc
74291a4b 3901Do not search the standard system directories for header files. Only
630d3d5a 3902the directories you have specified with @option{-I} options (and the
74291a4b 3903current directory, if appropriate) are searched. @xref{Directory
630d3d5a 3904Options}, for information on @option{-I}.
74291a4b 3905
dfb5868d
NS
3906By using both @option{-nostdinc} and @option{-I-}, you can limit the include-file
3907search path to only those directories you specify explicitly.
74291a4b 3908
e582248c 3909@item -remap
cd3bb277 3910@opindex remap
e582248c
NB
3911When searching for a header file in a directory, remap file names if a
3912file named @file{header.gcc} exists in that directory. This can be used
3913to work around limitations of file systems with file name restrictions.
3914The @file{header.gcc} file should contain a series of lines with two
3915tokens on each line: the first token is the name to map, and the second
3916token is the actual name to use.
3917
74291a4b 3918@item -undef
cd3bb277 3919@opindex undef
74291a4b
MM
3920Do not predefine any nonstandard macros. (Including architecture flags).
3921
3922@item -E
cd3bb277 3923@opindex E
74291a4b
MM
3924Run only the C preprocessor. Preprocess all the C source files
3925specified and output the results to standard output or to the
3926specified output file.
3927
3928@item -C
cd3bb277 3929@opindex C
74291a4b 3930Tell the preprocessor not to discard comments. Used with the
630d3d5a 3931@option{-E} option.
74291a4b
MM
3932
3933@item -P
cd3bb277 3934@opindex P
74291a4b 3935Tell the preprocessor not to generate @samp{#line} directives.
630d3d5a 3936Used with the @option{-E} option.
74291a4b
MM
3937
3938@cindex make
3939@cindex dependencies, make
3940@item -M
cd3bb277 3941@opindex M
e582248c
NB
3942Instead of outputting the result of preprocessing, output a rule
3943suitable for @code{make} describing the dependencies of the main source
3944file. The preprocessor outputs one @code{make} rule containing the
3945object file name for that source file, a colon, and the names of all the
48ce6bbb
NS
3946included files. Unless overridden explicitly, the object file name
3947consists of the basename of the source file with any suffix replaced with
767094dd 3948object file suffix. If there are many included files then the
48ce6bbb 3949rule is split into several lines using @samp{\}-newline.
74291a4b 3950
630d3d5a 3951@option{-M} implies @option{-E}.
74291a4b 3952
e582248c 3953@item -MM
cd3bb277 3954@opindex MM
630d3d5a 3955Like @option{-M}, but mention only the files included with @samp{#include
e582248c
NB
3956"@var{file}"}. System header files included with @samp{#include
3957<@var{file}>} are omitted.
3958
7da723ef 3959@item -MD
cd3bb277 3960@opindex MD
630d3d5a 3961Like @option{-M} but the dependency information is written to a file
7da723ef 3962rather than stdout. @code{gcc} will use the same file name and
695ac33f 3963directory as the object file, but with the suffix @file{.d} instead.
7da723ef 3964
630d3d5a
JM
3965This is in addition to compiling the main file as specified---@option{-MD}
3966does not inhibit ordinary compilation the way @option{-M} does,
3967unless you also specify @option{-MG}.
7da723ef
NB
3968
3969With Mach, you can use the utility @code{md} to merge multiple
3970dependency files into a single dependency file suitable for using with
3971the @samp{make} command.
3972
d396403a 3973@item -MMD
cd3bb277 3974@opindex MMD
630d3d5a 3975Like @option{-MD} except mention only user header files, not system
7da723ef
NB
3976-header files.
3977
e582248c 3978@item -MF @var{file}
cd3bb277 3979@opindex MF
630d3d5a 3980When used with @option{-M} or @option{-MM}, specifies a file to write the
e582248c 3981dependencies to. This allows the preprocessor to write the preprocessed
630d3d5a 3982file to stdout normally. If no @option{-MF} switch is given, CPP sends
e582248c
NB
3983the rules to stdout and suppresses normal preprocessed output.
3984
74291a4b 3985Another way to specify output of a @code{make} rule is by setting
bedc7537 3986the environment variable @env{DEPENDENCIES_OUTPUT} (@pxref{Environment
74291a4b
MM
3987Variables}).
3988
74291a4b 3989@item -MG
cd3bb277 3990@opindex MG
630d3d5a 3991When used with @option{-M} or @option{-MM}, @option{-MG} says to treat missing
e582248c
NB
3992header files as generated files and assume they live in the same
3993directory as the source file. It suppresses preprocessed output, as a
3994missing header file is ordinarily an error.
3995
3996This feature is used in automatic updating of makefiles.
3997
3998@item -MP
cd3bb277 3999@opindex MP
e582248c
NB
4000This option instructs CPP to add a phony target for each dependency
4001other than the main file, causing each to depend on nothing. These
4002dummy rules work around errors @code{make} gives if you remove header
4003files without updating the @code{Makefile} to match.
4004
4005This is typical output:-
4006
4007@smallexample
4008/tmp/test.o: /tmp/test.c /tmp/test.h
4009
4010/tmp/test.h:
4011@end smallexample
4012
4013@item -MQ @var{target}
4014@item -MT @var{target}
cd3bb277
JM
4015@opindex MQ
4016@opindex MT
e582248c
NB
4017By default CPP uses the main file name, including any path, and appends
4018the object suffix, normally ``.o'', to it to obtain the name of the
630d3d5a 4019target for dependency generation. With @option{-MT} you can specify a
e582248c
NB
4020target yourself, overriding the default one.
4021
4022If you want multiple targets, you can specify them as a single argument
630d3d5a 4023to @option{-MT}, or use multiple @option{-MT} options.
e582248c
NB
4024
4025The targets you specify are output in the order they appear on the
630d3d5a
JM
4026command line. @option{-MQ} is identical to @option{-MT}, except that the
4027target name is quoted for Make, but with @option{-MT} it isn't. For
4028example, @option{-MT '$(objpfx)foo.o'} gives
e582248c
NB
4029
4030@smallexample
4031$(objpfx)foo.o: /tmp/foo.c
4032@end smallexample
4033
630d3d5a 4034but @option{-MQ '$(objpfx)foo.o'} gives
e582248c
NB
4035
4036@smallexample
4037$$(objpfx)foo.o: /tmp/foo.c
4038@end smallexample
4039
4040The default target is automatically quoted, as if it were given with
630d3d5a 4041@option{-MQ}.
74291a4b
MM
4042
4043@item -H
cd3bb277 4044@opindex H
74291a4b
MM
4045Print the name of each header file used, in addition to other normal
4046activities.
4047
4048@item -A@var{question}(@var{answer})
cd3bb277 4049@opindex A
74291a4b
MM
4050Assert the answer @var{answer} for @var{question}, in case it is tested
4051with a preprocessing conditional such as @samp{#if
630d3d5a 4052#@var{question}(@var{answer})}. @option{-A-} disables the standard
74291a4b
MM
4053assertions that normally describe the target machine.
4054
4055@item -D@var{macro}
cd3bb277 4056@opindex D
74291a4b
MM
4057Define macro @var{macro} with the string @samp{1} as its definition.
4058
4059@item -D@var{macro}=@var{defn}
630d3d5a
JM
4060Define macro @var{macro} as @var{defn}. All instances of @option{-D} on
4061the command line are processed before any @option{-U} options.
74291a4b 4062
630d3d5a
JM
4063Any @option{-D} and @option{-U} options on the command line are processed in
4064order, and always before @option{-imacros @var{file}}, regardless of the
e582248c
NB
4065order in which they are written.
4066
74291a4b 4067@item -U@var{macro}
cd3bb277 4068@opindex U
630d3d5a
JM
4069Undefine macro @var{macro}. @option{-U} options are evaluated after all
4070@option{-D} options, but before any @option{-include} and @option{-imacros}
74291a4b
MM
4071options.
4072
630d3d5a
JM
4073Any @option{-D} and @option{-U} options on the command line are processed in
4074order, and always before @option{-imacros @var{file}}, regardless of the
e582248c
NB
4075order in which they are written.
4076
74291a4b 4077@item -dM
cd3bb277 4078@opindex dM
74291a4b 4079Tell the preprocessor to output only a list of the macro definitions
630d3d5a 4080that are in effect at the end of preprocessing. Used with the @option{-E}
74291a4b
MM
4081option.
4082
4083@item -dD
cd3bb277 4084@opindex dD
74291a4b
MM
4085Tell the preprocessing to pass all macro definitions into the output, in
4086their proper sequence in the rest of the output.
4087
4088@item -dN
cd3bb277 4089@opindex dN
630d3d5a 4090Like @option{-dD} except that the macro arguments and contents are omitted.
74291a4b
MM
4091Only @samp{#define @var{name}} is included in the output.
4092
e582248c 4093@item -dI
cd3bb277 4094@opindex dI
e582248c
NB
4095Output @samp{#include} directives in addition to the result of
4096preprocessing.
4097
3bce8a01
NB
4098@item -fpreprocessed
4099@opindex fpreprocessed
4100Indicate to the preprocessor that the input file has already been
4101preprocessed. This suppresses things like macro expansion, trigraph
4102conversion, escaped newline splicing, and processing of most directives.
6d34c1c4
NB
4103The preprocessor still recognizes and removes comments, so that you can
4104pass a file preprocessed with @option{-C} to the compiler without
4105problems. In this mode the integrated preprocessor is little more than
4106a tokenizer for the front ends.
3bce8a01 4107
630d3d5a 4108@option{-fpreprocessed} is implicit if the input file has one of the
6d34c1c4
NB
4109extensions @samp{i}, @samp{ii} or @samp{mi}. These are the extensions
4110that GCC uses for preprocessed files created by @option{-save-temps}.
3bce8a01 4111
74291a4b 4112@item -trigraphs
cd3bb277 4113@opindex trigraphs
e582248c
NB
4114Process ISO standard trigraph sequences. These are three-character
4115sequences, all starting with @samp{??}, that are defined by ISO C to
4116stand for single characters. For example, @samp{??/} stands for
4117@samp{\}, so @samp{'??/n'} is a character constant for a newline. By
4118default, GCC ignores trigraphs, but in standard-conforming modes it
630d3d5a 4119converts them. See the @option{-std} and @option{-ansi} options.
e582248c
NB
4120
4121The nine trigraph sequences are
4122@table @samp
4123@item ??(
aee96fe9 4124@expansion{} @samp{[}
e582248c
NB
4125
4126@item ??)
aee96fe9 4127@expansion{} @samp{]}
e582248c
NB
4128
4129@item ??<
aee96fe9 4130@expansion{} @samp{@{}
e582248c
NB
4131
4132@item ??>
aee96fe9 4133@expansion{} @samp{@}}
e582248c
NB
4134
4135@item ??=
aee96fe9 4136@expansion{} @samp{#}
e582248c
NB
4137
4138@item ??/
aee96fe9 4139@expansion{} @samp{\}
e582248c
NB
4140
4141@item ??'
aee96fe9 4142@expansion{} @samp{^}
e582248c
NB
4143
4144@item ??!
aee96fe9 4145@expansion{} @samp{|}
e582248c
NB
4146
4147@item ??-
aee96fe9 4148@expansion{} @samp{~}
e582248c
NB
4149
4150@end table
4151
4152Trigraph support is not popular, so many compilers do not implement it
4153properly. Portable code should not rely on trigraphs being either
4154converted or ignored.
74291a4b 4155
aee96fe9 4156@item -Wp,@var{option}
cd3bb277 4157@opindex Wp
bedc7537 4158Pass @var{option} as an option to the preprocessor. If @var{option}
74291a4b
MM
4159contains commas, it is split into multiple options at the commas.
4160@end table
4161
4162@node Assembler Options
4163@section Passing Options to the Assembler
4164
4165@c prevent bad page break with this line
4166You can pass options to the assembler.
4167
2642624b 4168@table @gcctabopt
aee96fe9 4169@item -Wa,@var{option}
cd3bb277 4170@opindex Wa
74291a4b
MM
4171Pass @var{option} as an option to the assembler. If @var{option}
4172contains commas, it is split into multiple options at the commas.
4173@end table
4174
4175@node Link Options
4176@section Options for Linking
4177@cindex link options
4178@cindex options, linking
4179
4180These options come into play when the compiler links object files into
4181an executable output file. They are meaningless if the compiler is
4182not doing a link step.
4183
2642624b 4184@table @gcctabopt
74291a4b
MM
4185@cindex file names
4186@item @var{object-file-name}
4187A file name that does not end in a special recognized suffix is
4188considered to name an object file or library. (Object files are
4189distinguished from libraries by the linker according to the file
4190contents.) If linking is done, these object files are used as input
4191to the linker.
4192
4193@item -c
4194@itemx -S
4195@itemx -E
cd3bb277
JM
4196@opindex c
4197@opindex S
4198@opindex E
74291a4b
MM
4199If any of these options is used, then the linker is not run, and
4200object file names should not be used as arguments. @xref{Overall
4201Options}.
4202
4203@cindex Libraries
4204@item -l@var{library}
4275c4c4 4205@itemx -l @var{library}
cd3bb277 4206@opindex l
4275c4c4
JS
4207Search the library named @var{library} when linking. (The second
4208alternative with the library as a separate argument is only for
4209POSIX compliance and is not recommended.)
74291a4b
MM
4210
4211It makes a difference where in the command you write this option; the
4275c4c4 4212linker searches and processes libraries and object files in the order they
74291a4b
MM
4213are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
4214after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
4215to functions in @samp{z}, those functions may not be loaded.
4216
4217The linker searches a standard list of directories for the library,
4218which is actually a file named @file{lib@var{library}.a}. The linker
4219then uses this file as if it had been specified precisely by name.
4220
4221The directories searched include several standard system directories
630d3d5a 4222plus any that you specify with @option{-L}.
74291a4b
MM
4223
4224Normally the files found this way are library files---archive files
4225whose members are object files. The linker handles an archive file by
4226scanning through it for members which define symbols that have so far
4227been referenced but not defined. But if the file that is found is an
4228ordinary object file, it is linked in the usual fashion. The only
630d3d5a
JM
4229difference between using an @option{-l} option and specifying a file name
4230is that @option{-l} surrounds @var{library} with @samp{lib} and @samp{.a}
74291a4b
MM
4231and searches several directories.
4232
4233@item -lobjc
cd3bb277 4234@opindex lobjc
630d3d5a 4235You need this special case of the @option{-l} option in order to
2147b154 4236link an Objective-C program.
74291a4b
MM
4237
4238@item -nostartfiles
cd3bb277 4239@opindex nostartfiles
74291a4b 4240Do not use the standard system startup files when linking.
bedc7537
NC
4241The standard system libraries are used normally, unless @option{-nostdlib}
4242or @option{-nodefaultlibs} is used.
74291a4b
MM
4243
4244@item -nodefaultlibs
cd3bb277 4245@opindex nodefaultlibs
74291a4b
MM
4246Do not use the standard system libraries when linking.
4247Only the libraries you specify will be passed to the linker.
bedc7537 4248The standard startup files are used normally, unless @option{-nostartfiles}
4754172c 4249is used. The compiler may generate calls to memcmp, memset, and memcpy
c1030c7c 4250for System V (and ISO C) environments or to bcopy and bzero for
4754172c
CM
4251BSD environments. These entries are usually resolved by entries in
4252libc. These entry points should be supplied through some other
4253mechanism when this option is specified.
74291a4b
MM
4254
4255@item -nostdlib
cd3bb277 4256@opindex nostdlib
74291a4b
MM
4257Do not use the standard system startup files or libraries when linking.
4258No startup files and only the libraries you specify will be passed to
767094dd 4259the linker. The compiler may generate calls to memcmp, memset, and memcpy
c1030c7c 4260for System V (and ISO C) environments or to bcopy and bzero for
4754172c
CM
4261BSD environments. These entries are usually resolved by entries in
4262libc. These entry points should be supplied through some other
4263mechanism when this option is specified.
74291a4b 4264
630d3d5a
JM
4265@cindex @option{-lgcc}, use with @option{-nostdlib}
4266@cindex @option{-nostdlib} and unresolved references
4267@cindex unresolved references and @option{-nostdlib}
4268@cindex @option{-lgcc}, use with @option{-nodefaultlibs}
4269@cindex @option{-nodefaultlibs} and unresolved references
4270@cindex unresolved references and @option{-nodefaultlibs}
4271One of the standard libraries bypassed by @option{-nostdlib} and
4272@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
0c2d1a2a 4273that GCC uses to overcome shortcomings of particular machines, or special
74291a4b
MM
4274needs for some languages.
4275@ifset INTERNALS
0c2d1a2a 4276(@xref{Interface,,Interfacing to GCC Output}, for more discussion of
74291a4b
MM
4277@file{libgcc.a}.)
4278@end ifset
4279@ifclear INTERNALS
0c2d1a2a 4280(@xref{Interface,,Interfacing to GCC Output,gcc.info,Porting GCC},
74291a4b
MM
4281for more discussion of @file{libgcc.a}.)
4282@end ifclear
4283In most cases, you need @file{libgcc.a} even when you want to avoid
630d3d5a
JM
4284other standard libraries. In other words, when you specify @option{-nostdlib}
4285or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
0c2d1a2a 4286This ensures that you have no unresolved references to internal GCC
74291a4b 4287library subroutines. (For example, @samp{__main}, used to ensure C++
bedc7537 4288constructors will be called; @pxref{Collect2,,@command{collect2}}.)
74291a4b
MM
4289
4290@item -s
cd3bb277 4291@opindex s
74291a4b
MM
4292Remove all symbol table and relocation information from the executable.
4293
4294@item -static
cd3bb277 4295@opindex static
74291a4b
MM
4296On systems that support dynamic linking, this prevents linking with the shared
4297libraries. On other systems, this option has no effect.
4298
4299@item -shared
cd3bb277 4300@opindex shared
74291a4b 4301Produce a shared object which can then be linked with other objects to
1d3b0e2c 4302form an executable. Not all systems support this option. For predictable
02f52e19 4303results, you must also specify the same set of options that were used to
630d3d5a 4304generate code (@option{-fpic}, @option{-fPIC}, or model suboptions)
2642624b 4305when you specify this option.@footnote{On some systems, @samp{gcc -shared}
767094dd 4306needs to build supplementary stub code for constructors to work. On
2642624b 4307multi-libbed systems, @samp{gcc -shared} must select the correct support
1d3b0e2c 4308libraries to link against. Failing to supply the correct flags may lead
767094dd 4309to subtle defects. Supplying them in cases where they are not necessary
1d3b0e2c 4310is innocuous.}
74291a4b 4311
9db0819e
RH
4312@item -shared-libgcc
4313@itemx -static-libgcc
cd3bb277
JM
4314@opindex shared-libgcc
4315@opindex static-libgcc
9db0819e
RH
4316On systems that provide @file{libgcc} as a shared library, these options
4317force the use of either the shared or static version respectively.
4318If no shared version of @file{libgcc} was built when the compiler was
4319configured, these options have no effect.
4320
4321There are several situations in which an application should use the
4322shared @file{libgcc} instead of the static version. The most common
4323of these is when the application wishes to throw and catch exceptions
4324across different shared libraries. In that case, each of the libraries
4325as well as the application itself should use the shared @file{libgcc}.
4326
630d3d5a
JM
4327Therefore, whenever you specify the @option{-shared} option, the GCC
4328driver automatically adds @option{-shared-libgcc}, unless you explicitly
4329specify @option{-static-libgcc}. The G++ driver automatically adds
4330@option{-shared-libgcc} when you build a main executable as well because
049f6ec9
MM
4331for C++ programs that is typically the right thing to do.
4332(Exception-handling will not work reliably otherwise.)
4333
4334However, when linking a main executable written in C, you must
630d3d5a 4335explicitly say @option{-shared-libgcc} if you want to use the shared
049f6ec9 4336@file{libgcc}.
9db0819e 4337
74291a4b 4338@item -symbolic
cd3bb277 4339@opindex symbolic
74291a4b
MM
4340Bind references to global symbols when building a shared object. Warn
4341about any unresolved references (unless overridden by the link editor
4342option @samp{-Xlinker -z -Xlinker defs}). Only a few systems support
4343this option.
4344
4345@item -Xlinker @var{option}
cd3bb277 4346@opindex Xlinker
74291a4b 4347Pass @var{option} as an option to the linker. You can use this to
0c2d1a2a 4348supply system-specific linker options which GCC does not know how to
74291a4b
MM
4349recognize.
4350
4351If you want to pass an option that takes an argument, you must use
630d3d5a
JM
4352@option{-Xlinker} twice, once for the option and once for the argument.
4353For example, to pass @option{-assert definitions}, you must write
74291a4b 4354@samp{-Xlinker -assert -Xlinker definitions}. It does not work to write
630d3d5a 4355@option{-Xlinker "-assert definitions"}, because this passes the entire
74291a4b
MM
4356string as a single argument, which is not what the linker expects.
4357
aee96fe9 4358@item -Wl,@var{option}
cd3bb277 4359@opindex Wl
74291a4b
MM
4360Pass @var{option} as an option to the linker. If @var{option} contains
4361commas, it is split into multiple options at the commas.
4362
4363@item -u @var{symbol}
cd3bb277 4364@opindex u
74291a4b 4365Pretend the symbol @var{symbol} is undefined, to force linking of
630d3d5a 4366library modules to define it. You can use @option{-u} multiple times with
74291a4b
MM
4367different symbols to force loading of additional library modules.
4368@end table
4369
4370@node Directory Options
4371@section Options for Directory Search
4372@cindex directory options
4373@cindex options, directory search
4374@cindex search path
4375
4376These options specify directories to search for header files, for
4377libraries and for parts of the compiler:
4378
2642624b 4379@table @gcctabopt
74291a4b 4380@item -I@var{dir}
cd3bb277 4381@opindex I
861bb6c1
JL
4382Add the directory @var{dir} to the head of the list of directories to be
4383searched for header files. This can be used to override a system header
4384file, substituting your own version, since these directories are
d0a5eb32
RK
4385searched before the system header file directories. However, you should
4386not use this option to add directories that contain vendor-supplied
767094dd 4387system header files (use @option{-isystem} for that). If you use more than
630d3d5a 4388one @option{-I} option, the directories are scanned in left-to-right
74291a4b
MM
4389order; the standard system directories come after.
4390
dbead49c
NS
4391If a standard system include directory, or a directory specified with
4392@option{-isystem}, is also specified with @option{-I}, it will be
4393searched only in the position requested by @option{-I}. Also, it will
4394not be considered a system include directory. If that directory really
4395does contain system headers, there is a good chance that they will
4396break. For instance, if GCC's installation procedure edited the headers
4397in @file{/usr/include} to fix bugs, @samp{-I/usr/include} will cause the
4398original, buggy headers to be found instead of the corrected ones. GCC
4399will issue a warning when a system include directory is hidden in this
4400way.
4401
74291a4b 4402@item -I-
cd3bb277 4403@opindex I-
630d3d5a 4404Any directories you specify with @option{-I} options before the @option{-I-}
74291a4b
MM
4405option are searched only for the case of @samp{#include "@var{file}"};
4406they are not searched for @samp{#include <@var{file}>}.
4407
630d3d5a
JM
4408If additional directories are specified with @option{-I} options after
4409the @option{-I-}, these directories are searched for all @samp{#include}
4410directives. (Ordinarily @emph{all} @option{-I} directories are used
74291a4b
MM
4411this way.)
4412
630d3d5a 4413In addition, the @option{-I-} option inhibits the use of the current
74291a4b
MM
4414directory (where the current input file came from) as the first search
4415directory for @samp{#include "@var{file}"}. There is no way to
630d3d5a 4416override this effect of @option{-I-}. With @option{-I.} you can specify
74291a4b
MM
4417searching the directory which was current when the compiler was
4418invoked. That is not exactly the same as what the preprocessor does
4419by default, but it is often satisfactory.
4420
630d3d5a
JM
4421@option{-I-} does not inhibit the use of the standard system directories
4422for header files. Thus, @option{-I-} and @option{-nostdinc} are
74291a4b
MM
4423independent.
4424
4425@item -L@var{dir}
cd3bb277 4426@opindex L
74291a4b 4427Add directory @var{dir} to the list of directories to be searched
630d3d5a 4428for @option{-l}.
74291a4b
MM
4429
4430@item -B@var{prefix}
cd3bb277 4431@opindex B
74291a4b
MM
4432This option specifies where to find the executables, libraries,
4433include files, and data files of the compiler itself.
4434
4435The compiler driver program runs one or more of the subprograms
4436@file{cpp}, @file{cc1}, @file{as} and @file{ld}. It tries
4437@var{prefix} as a prefix for each program it tries to run, both with and
4438without @samp{@var{machine}/@var{version}/} (@pxref{Target Options}).
4439
4440For each subprogram to be run, the compiler driver first tries the
630d3d5a 4441@option{-B} prefix, if any. If that name is not found, or if @option{-B}
74291a4b
MM
4442was not specified, the driver tries two standard prefixes, which are
4443@file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc-lib/}. If neither of
4444those results in a file name that is found, the unmodified program
4445name is searched for using the directories specified in your
bedc7537 4446@env{PATH} environment variable.
74291a4b 4447
07804c3b
NC
4448The compiler will check to see if the path provided by the @option{-B}
4449refers to a directory, and if necessary it will add a directory
4450separator character at the end of the path.
4451
630d3d5a 4452@option{-B} prefixes that effectively specify directory names also apply
74291a4b 4453to libraries in the linker, because the compiler translates these
630d3d5a 4454options into @option{-L} options for the linker. They also apply to
74291a4b 4455includes files in the preprocessor, because the compiler translates these
630d3d5a 4456options into @option{-isystem} options for the preprocessor. In this case,
74291a4b
MM
4457the compiler appends @samp{include} to the prefix.
4458
4459The run-time support file @file{libgcc.a} can also be searched for using
630d3d5a 4460the @option{-B} prefix, if needed. If it is not found there, the two
74291a4b
MM
4461standard prefixes above are tried, and that is all. The file is left
4462out of the link if it is not found by those means.
4463
630d3d5a 4464Another way to specify a prefix much like the @option{-B} prefix is to use
bedc7537 4465the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
74291a4b 4466Variables}.
861bb6c1 4467
07804c3b 4468As a special kludge, if the path provided by @option{-B} is
bf4eebe0
NC
4469@file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
44709, then it will be replaced by @file{[dir/]include}. This is to help
7dac2f89 4471with boot-strapping the compiler.
07804c3b 4472
861bb6c1 4473@item -specs=@var{file}
cd3bb277 4474@opindex specs
861bb6c1
JL
4475Process @var{file} after the compiler reads in the standard @file{specs}
4476file, in order to override the defaults that the @file{gcc} driver
4477program uses when determining what switches to pass to @file{cc1},
4478@file{cc1plus}, @file{as}, @file{ld}, etc. More than one
630d3d5a 4479@option{-specs=@var{file}} can be specified on the command line, and they
861bb6c1 4480are processed in order, from left to right.
74291a4b
MM
4481@end table
4482
ee457005
JM
4483@c man end
4484
a743d340
NC
4485@node Spec Files
4486@section Specifying subprocesses and the switches to pass to them
4487@cindex Spec Files
bedc7537 4488@command{gcc} is a driver program. It performs its job by invoking a
a743d340
NC
4489sequence of other programs to do the work of compiling, assembling and
4490linking. GCC interprets its command-line parameters and uses these to
4491deduce which programs it should invoke, and which command-line options
4492it ought to place on their command lines. This behaviour is controlled
4493by @dfn{spec strings}. In most cases there is one spec string for each
4494program that GCC can invoke, but a few programs have multiple spec
4495strings to control their behaviour. The spec strings built into GCC can
630d3d5a 4496be overridden by using the @option{-specs=} command-line switch to specify
a743d340
NC
4497a spec file.
4498
4499@dfn{Spec files} are plaintext files that are used to construct spec
4500strings. They consist of a sequence of directives separated by blank
4501lines. The type of directive is determined by the first non-whitespace
4502character on the line and it can be one of the following:
4503
4504@table @code
4505@item %@var{command}
4506Issues a @var{command} to the spec file processor. The commands that can
02f52e19 4507appear here are:
a743d340
NC
4508
4509@table @code
4510@item %include <@var{file}>
4511@cindex %include
4512Search for @var{file} and insert its text at the current point in the
4513specs file.
4514
4515@item %include_noerr <@var{file}>
4516@cindex %include_noerr
4517Just like @samp{%include}, but do not generate an error message if the include
4518file cannot be found.
4519
4520@item %rename @var{old_name} @var{new_name}
4521@cindex %rename
4522Rename the spec string @var{old_name} to @var{new_name}.
4523
4524@end table
4525
4526@item *[@var{spec_name}]:
4527This tells the compiler to create, override or delete the named spec
4528string. All lines after this directive up to the next directive or
4529blank line are considered to be the text for the spec string. If this
4530results in an empty string then the spec will be deleted. (Or, if the
4531spec did not exist, then nothing will happened.) Otherwise, if the spec
4532does not currently exist a new spec will be created. If the spec does
4533exist then its contents will be overridden by the text of this
4534directive, unless the first character of that text is the @samp{+}
4535character, in which case the text will be appended to the spec.
4536
4537@item [@var{suffix}]:
4538Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
4539and up to the next directive or blank line are considered to make up the
02f52e19 4540spec string for the indicated suffix. When the compiler encounters an
a743d340
NC
4541input file with the named suffix, it will processes the spec string in
4542order to work out how to compile that file. For example:
4543
4544@smallexample
4545.ZZ:
4546z-compile -input %i
4547@end smallexample
4548
4549This says that any input file whose name ends in @samp{.ZZ} should be
4550passed to the program @samp{z-compile}, which should be invoked with the
630d3d5a 4551command-line switch @option{-input} and with the result of performing the
a743d340
NC
4552@samp{%i} substitution. (See below.)
4553
4554As an alternative to providing a spec string, the text that follows a
4555suffix directive can be one of the following:
4556
4557@table @code
4558@item @@@var{language}
4559This says that the suffix is an alias for a known @var{language}. This is
bedc7537 4560similar to using the @option{-x} command-line switch to GCC to specify a
a743d340
NC
4561language explicitly. For example:
4562
4563@smallexample
4564.ZZ:
4565@@c++
4566@end smallexample
4567
4568Says that .ZZ files are, in fact, C++ source files.
4569
4570@item #@var{name}
4571This causes an error messages saying:
4572
4573@smallexample
4574@var{name} compiler not installed on this system.
4575@end smallexample
4576@end table
4577
4578GCC already has an extensive list of suffixes built into it.
4579This directive will add an entry to the end of the list of suffixes, but
4580since the list is searched from the end backwards, it is effectively
4581possible to override earlier entries using this technique.
4582
4583@end table
4584
4585GCC has the following spec strings built into it. Spec files can
4586override these strings or create their own. Note that individual
02f52e19 4587targets can also add their own spec strings to this list.
a743d340
NC
4588
4589@smallexample
4590asm Options to pass to the assembler
4591asm_final Options to pass to the assembler post-processor
4592cpp Options to pass to the C preprocessor
4593cc1 Options to pass to the C compiler
4594cc1plus Options to pass to the C++ compiler
4595endfile Object files to include at the end of the link
4596link Options to pass to the linker
4597lib Libraries to include on the command line to the linker
4598libgcc Decides which GCC support library to pass to the linker
4599linker Sets the name of the linker
4600predefines Defines to be passed to the C preprocessor
310668e8
JM
4601signed_char Defines to pass to CPP to say whether @code{char} is signed
4602 by default
a743d340
NC
4603startfile Object files to include at the start of the link
4604@end smallexample
4605
4606Here is a small example of a spec file:
4607
4608@smallexample
4609%rename lib old_lib
4610
4611*lib:
4612--start-group -lgcc -lc -leval1 --end-group %(old_lib)
4613@end smallexample
4614
4615This example renames the spec called @samp{lib} to @samp{old_lib} and
4616then overrides the previous definition of @samp{lib} with a new one.
4617The new definition adds in some extra command-line options before
4618including the text of the old definition.
4619
4620@dfn{Spec strings} are a list of command-line options to be passed to their
4621corresponding program. In addition, the spec strings can contain
4622@samp{%}-prefixed sequences to substitute variable text or to
4623conditionally insert text into the command line. Using these constructs
4624it is possible to generate quite complex command lines.
4625
4626Here is a table of all defined @samp{%}-sequences for spec
4627strings. Note that spaces are not generated automatically around the
4628results of expanding these sequences. Therefore you can concatenate them
02f52e19 4629together or combine them with constant text in a single argument.
a743d340
NC
4630
4631@table @code
4632@item %%
4633Substitute one @samp{%} into the program name or argument.
4634
4635@item %i
4636Substitute the name of the input file being processed.
4637
4638@item %b
4639Substitute the basename of the input file being processed.
4640This is the substring up to (and not including) the last period
4641and not including the directory.
4642
371e300b
NC
4643@item %B
4644This is the same as @samp{%b}, but include the file suffix (text after
4645the last period).
4646
a743d340
NC
4647@item %d
4648Marks the argument containing or following the @samp{%d} as a
4649temporary file name, so that that file will be deleted if GCC exits
4650successfully. Unlike @samp{%g}, this contributes no text to the
02f52e19 4651argument.
a743d340
NC
4652
4653@item %g@var{suffix}
4654Substitute a file name that has suffix @var{suffix} and is chosen
4655once per compilation, and mark the argument in the same way as
4656@samp{%d}. To reduce exposure to denial-of-service attacks, the file
02f52e19 4657name is now chosen in a way that is hard to predict even when previously
695ac33f 4658chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
a743d340
NC
4659might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
4660the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
4661treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
4662was simply substituted with a file name chosen once per compilation,
4663without regard to any appended suffix (which was therefore treated
4664just like ordinary text), making such attacks more likely to succeed.
4665
4666@item %u@var{suffix}
4667Like @samp{%g}, but generates a new temporary file name even if
4668@samp{%u@var{suffix}} was already seen.
4669
4670@item %U@var{suffix}
4671Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
4672new one if there is no such last file name. In the absence of any
4673@samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
695ac33f 4674the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
a743d340
NC
4675would involve the generation of two distinct file names, one
4676for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
4677simply substituted with a file name chosen for the previous @samp{%u},
4678without regard to any appended suffix.
4679
371e300b 4680@item %j@var{SUFFIX}
aee96fe9 4681Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
371e300b
NC
4682writable, and if save-temps is off; otherwise, substitute the name
4683of a temporary file, just like @samp{%u}. This temporary file is not
4684meant for communication between processes, but rather as a junk
4685disposal mechanism.
4686
4687@item %.@var{SUFFIX}
4688Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
767094dd 4689when it is subsequently output with @samp{%*}. @var{SUFFIX} is
371e300b
NC
4690terminated by the next space or %.
4691
a743d340
NC
4692@item %w
4693Marks the argument containing or following the @samp{%w} as the
4694designated output file of this compilation. This puts the argument
4695into the sequence of arguments that @samp{%o} will substitute later.
4696
4697@item %o
4698Substitutes the names of all the output files, with spaces
4699automatically placed around them. You should write spaces
4700around the @samp{%o} as well or the results are undefined.
4701@samp{%o} is for use in the specs for running the linker.
4702Input files whose names have no recognized suffix are not compiled
4703at all, but they are included among the output files, so they will
4704be linked.
4705
4706@item %O
4707Substitutes the suffix for object files. Note that this is
4708handled specially when it immediately follows @samp{%g, %u, or %U},
4709because of the need for those to form complete file names. The
4710handling is such that @samp{%O} is treated exactly as if it had already
4711been substituted, except that @samp{%g, %u, and %U} do not currently
4712support additional @var{suffix} characters following @samp{%O} as they would
4713following, for example, @samp{.o}.
4714
4715@item %p
4716Substitutes the standard macro predefinitions for the
4717current target machine. Use this when running @code{cpp}.
4718
4719@item %P
4720Like @samp{%p}, but puts @samp{__} before and after the name of each
4721predefined macro, except for macros that start with @samp{__} or with
c1030c7c 4722@samp{_@var{L}}, where @var{L} is an uppercase letter. This is for ISO
161d7b59 4723C@.
a743d340
NC
4724
4725@item %I
aee96fe9 4726Substitute a @option{-iprefix} option made from @env{GCC_EXEC_PREFIX}.
a743d340
NC
4727
4728@item %s
4729Current argument is the name of a library or startup file of some sort.
4730Search for that file in a standard list of directories and substitute
02f52e19 4731the full name found.
a743d340
NC
4732
4733@item %e@var{str}
4734Print @var{str} as an error message. @var{str} is terminated by a newline.
4735Use this when inconsistent options are detected.
4736
4737@item %|
4738Output @samp{-} if the input for the current command is coming from a pipe.
4739
4740@item %(@var{name})
4741Substitute the contents of spec string @var{name} at this point.
4742
4743@item %[@var{name}]
630d3d5a 4744Like @samp{%(@dots{})} but put @samp{__} around @option{-D} arguments.
a743d340
NC
4745
4746@item %x@{@var{option}@}
4747Accumulate an option for @samp{%X}.
4748
4749@item %X
630d3d5a 4750Output the accumulated linker options specified by @option{-Wl} or a @samp{%x}
a743d340
NC
4751spec string.
4752
4753@item %Y
630d3d5a 4754Output the accumulated assembler options specified by @option{-Wa}.
a743d340
NC
4755
4756@item %Z
630d3d5a 4757Output the accumulated preprocessor options specified by @option{-Wp}.
a743d340
NC
4758
4759@item %v1
161d7b59 4760Substitute the major version number of GCC@.
a743d340
NC
4761(For version 2.9.5, this is 2.)
4762
4763@item %v2
161d7b59 4764Substitute the minor version number of GCC@.
a743d340
NC
4765(For version 2.9.5, this is 9.)
4766
371e300b 4767@item %v3
161d7b59 4768Substitute the patch level number of GCC@.
371e300b
NC
4769(For version 2.9.5, this is 5.)
4770
a743d340
NC
4771@item %a
4772Process the @code{asm} spec. This is used to compute the
4773switches to be passed to the assembler.
4774
4775@item %A
4776Process the @code{asm_final} spec. This is a spec string for
4777passing switches to an assembler post-processor, if such a program is
4778needed.
4779
4780@item %l
4781Process the @code{link} spec. This is the spec for computing the
4782command line passed to the linker. Typically it will make use of the
4783@samp{%L %G %S %D and %E} sequences.
4784
4785@item %D
630d3d5a 4786Dump out a @option{-L} option for each directory that GCC believes might
a743d340 4787contain startup files. If the target supports multilibs then the
02f52e19 4788current multilib directory will be prepended to each of these paths.
a743d340 4789
371e300b 4790@item %M
c771326b 4791Output the multilib directory with directory separators replaced with
695ac33f
JM
4792@samp{_}. If multilib directories are not set, or the multilib directory is
4793@file{.} then this option emits nothing.
371e300b 4794
a743d340
NC
4795@item %L
4796Process the @code{lib} spec. This is a spec string for deciding which
02f52e19 4797libraries should be included on the command line to the linker.
a743d340
NC
4798
4799@item %G
4800Process the @code{libgcc} spec. This is a spec string for deciding
02f52e19 4801which GCC support library should be included on the command line to the linker.
a743d340
NC
4802
4803@item %S
4804Process the @code{startfile} spec. This is a spec for deciding which
4805object files should be the first ones passed to the linker. Typically
02f52e19 4806this might be a file named @file{crt0.o}.
a743d340
NC
4807
4808@item %E
4809Process the @code{endfile} spec. This is a spec string that specifies
02f52e19 4810the last object files that will be passed to the linker.
a743d340
NC
4811
4812@item %C
4813Process the @code{cpp} spec. This is used to construct the arguments
4814to be passed to the C preprocessor.
4815
4816@item %c
4817Process the @code{signed_char} spec. This is intended to be used
02f52e19 4818to tell cpp whether a char is signed. It typically has the definition:
a743d340
NC
4819@smallexample
4820%@{funsigned-char:-D__CHAR_UNSIGNED__@}
4821@end smallexample
4822
4823@item %1
4824Process the @code{cc1} spec. This is used to construct the options to be
4825passed to the actual C compiler (@samp{cc1}).
4826
4827@item %2
4828Process the @code{cc1plus} spec. This is used to construct the options to be
4829passed to the actual C++ compiler (@samp{cc1plus}).
4830
4831@item %*
4832Substitute the variable part of a matched option. See below.
4833Note that each comma in the substituted string is replaced by
4834a single space.
4835
4836@item %@{@code{S}@}
161d7b59 4837Substitutes the @code{-S} switch, if that switch was given to GCC@.
a743d340
NC
4838If that switch was not specified, this substitutes nothing. Note that
4839the leading dash is omitted when specifying this option, and it is
4840automatically inserted if the substitution is performed. Thus the spec
630d3d5a
JM
4841string @samp{%@{foo@}} would match the command-line option @option{-foo}
4842and would output the command line option @option{-foo}.
a743d340
NC
4843
4844@item %W@{@code{S}@}
4845Like %@{@code{S}@} but mark last argument supplied within as a file to be
02f52e19 4846deleted on failure.
a743d340
NC
4847
4848@item %@{@code{S}*@}
4849Substitutes all the switches specified to GCC whose names start
4850with @code{-S}, but which also take an argument. This is used for
695ac33f 4851switches like @option{-o}, @option{-D}, @option{-I}, etc.
630d3d5a 4852GCC considers @option{-o foo} as being
a743d340 4853one switch whose names starts with @samp{o}. %@{o*@} would substitute this
02f52e19 4854text, including the space. Thus two arguments would be generated.
a743d340
NC
4855
4856@item %@{^@code{S}*@}
4857Like %@{@code{S}*@}, but don't put a blank between a switch and its
4858argument. Thus %@{^o*@} would only generate one argument, not two.
4859
371e300b
NC
4860@item %@{@code{S}*&@code{T}*@}
4861Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
4862(the order of @code{S} and @code{T} in the spec is not significant).
4863There can be any number of ampersand-separated variables; for each the
4864wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
4865
d630442f 4866@item %@{<@code{S}@}
695ac33f 4867Remove all occurrences of @code{-S} from the command line. Note---this
d630442f 4868command is position dependent. @samp{%} commands in the spec string
50c57e7b 4869before this option will see @code{-S}, @samp{%} commands in the spec
d630442f
NC
4870string after this option will not.
4871
a743d340
NC
4872@item %@{@code{S}*:@code{X}@}
4873Substitutes @code{X} if one or more switches whose names start with
161d7b59 4874@code{-S} are specified to GCC@. Note that the tail part of the
e979f9e8 4875@code{-S} option (i.e.@: the part matched by the @samp{*}) will be substituted
02f52e19 4876for each occurrence of @samp{%*} within @code{X}.
a743d340
NC
4877
4878@item %@{@code{S}:@code{X}@}
161d7b59 4879Substitutes @code{X}, but only if the @samp{-S} switch was given to GCC@.
a743d340
NC
4880
4881@item %@{!@code{S}:@code{X}@}
161d7b59 4882Substitutes @code{X}, but only if the @samp{-S} switch was @emph{not} given to GCC@.
a743d340
NC
4883
4884@item %@{|@code{S}:@code{X}@}
4885Like %@{@code{S}:@code{X}@}, but if no @code{S} switch, substitute @samp{-}.
4886
4887@item %@{|!@code{S}:@code{X}@}
4888Like %@{!@code{S}:@code{X}@}, but if there is an @code{S} switch, substitute @samp{-}.
4889
4890@item %@{.@code{S}:@code{X}@}
4891Substitutes @code{X}, but only if processing a file with suffix @code{S}.
4892
4893@item %@{!.@code{S}:@code{X}@}
4894Substitutes @code{X}, but only if @emph{not} processing a file with suffix @code{S}.
4895
4896@item %@{@code{S}|@code{P}:@code{X}@}
161d7b59 4897Substitutes @code{X} if either @code{-S} or @code{-P} was given to GCC@. This may be
a743d340
NC
4898combined with @samp{!} and @samp{.} sequences as well, although they
4899have a stronger binding than the @samp{|}. For example a spec string
4900like this:
4901
4902@smallexample
4903%@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
4904@end smallexample
4905
4906will output the following command-line options from the following input
4907command-line options:
4908
4909@smallexample
4910fred.c -foo -baz
4911jim.d -bar -boggle
4912-d fred.c -foo -baz -boggle
4913-d jim.d -bar -baz -boggle
4914@end smallexample
4915
4916@end table
4917
4918The conditional text @code{X} in a %@{@code{S}:@code{X}@} or
4919%@{!@code{S}:@code{X}@} construct may contain other nested @samp{%} constructs
4920or spaces, or even newlines. They are processed as usual, as described
02f52e19 4921above.
a743d340 4922
695ac33f
JM
4923The @option{-O}, @option{-f}, @option{-m}, and @option{-W}
4924switches are handled specifically in these
630d3d5a
JM
4925constructs. If another value of @option{-O} or the negated form of a @option{-f}, @option{-m}, or
4926@option{-W} switch is found later in the command line, the earlier switch
a743d340
NC
4927value is ignored, except with @{@code{S}*@} where @code{S} is just one
4928letter, which passes all matching options.
4929
4930The character @samp{|} at the beginning of the predicate text is used to indicate
630d3d5a 4931that a command should be piped to the following command, but only if @option{-pipe}
a743d340
NC
4932is specified.
4933
4934It is built into GCC which switches take arguments and which do not.
4935(You might think it would be useful to generalize this to allow each
4936compiler's spec to say which switches take arguments. But this cannot
4937be done in a consistent fashion. GCC cannot even decide which input
4938files have been specified without knowing which switches take arguments,
4939and it must know which input files to compile in order to tell which
02f52e19 4940compilers to run).
a743d340 4941
630d3d5a 4942GCC also knows implicitly that arguments starting in @option{-l} are to be
a743d340
NC
4943treated as compiler output files, and passed to the linker in their
4944proper position among the other output files.
4945
ee457005
JM
4946@c man begin OPTIONS
4947
74291a4b
MM
4948@node Target Options
4949@section Specifying Target Machine and Compiler Version
4950@cindex target options
4951@cindex cross compiling
4952@cindex specifying machine version
4953@cindex specifying compiler version and target machine
4954@cindex compiler version, specifying
4955@cindex target machine, specifying
4956
0c2d1a2a 4957By default, GCC compiles code for the same type of machine that you
74291a4b
MM
4958are using. However, it can also be installed as a cross-compiler, to
4959compile for some other type of machine. In fact, several different
0c2d1a2a 4960configurations of GCC, for different target machines, can be
74291a4b 4961installed side by side. Then you specify which one to use with the
630d3d5a 4962@option{-b} option.
74291a4b 4963
0c2d1a2a 4964In addition, older and newer versions of GCC can be installed side
74291a4b
MM
4965by side. One of them (probably the newest) will be the default, but
4966you may sometimes wish to use another.
4967
2642624b 4968@table @gcctabopt
74291a4b 4969@item -b @var{machine}
cd3bb277 4970@opindex b
74291a4b 4971The argument @var{machine} specifies the target machine for compilation.
0c2d1a2a 4972This is useful when you have installed GCC as a cross-compiler.
74291a4b
MM
4973
4974The value to use for @var{machine} is the same as was specified as the
0c2d1a2a 4975machine type when configuring GCC as a cross-compiler. For
74291a4b
MM
4976example, if a cross-compiler was configured with @samp{configure
4977i386v}, meaning to compile for an 80386 running System V, then you
630d3d5a 4978would specify @option{-b i386v} to run that cross compiler.
74291a4b 4979
630d3d5a 4980When you do not specify @option{-b}, it normally means to compile for
74291a4b
MM
4981the same type of machine that you are using.
4982
4983@item -V @var{version}
cd3bb277 4984@opindex V
0c2d1a2a 4985The argument @var{version} specifies which version of GCC to run.
74291a4b 4986This is useful when multiple versions are installed. For example,
0c2d1a2a 4987@var{version} might be @samp{2.0}, meaning to run GCC version 2.0.
74291a4b 4988
630d3d5a 4989The default version, when you do not specify @option{-V}, is the last
0c2d1a2a 4990version of GCC that you installed.
74291a4b
MM
4991@end table
4992
630d3d5a 4993The @option{-b} and @option{-V} options actually work by controlling part of
74291a4b 4994the file name used for the executable files and libraries used for
0c2d1a2a 4995compilation. A given version of GCC, for a given target machine, is
bd819a4a 4996normally kept in the directory @file{/usr/local/lib/gcc-lib/@var{machine}/@var{version}}.
74291a4b 4997
630d3d5a 4998Thus, sites can customize the effect of @option{-b} or @option{-V} either by
74291a4b
MM
4999changing the names of these directories or adding alternate names (or
5000symbolic links). If in directory @file{/usr/local/lib/gcc-lib/} the
630d3d5a
JM
5001file @file{80386} is a link to the file @file{i386v}, then @option{-b
500280386} becomes an alias for @option{-b i386v}.
74291a4b 5003
630d3d5a 5004In one respect, the @option{-b} or @option{-V} do not completely change
bedc7537 5005to a different compiler: the top-level driver program @command{gcc}
74291a4b
MM
5006that you originally invoked continues to run and invoke the other
5007executables (preprocessor, compiler per se, assembler and linker)
5008that do the real work. However, since no real work is done in the
5009driver program, it usually does not matter that the driver program
8c7b74b9
JM
5010in use is not the one for the specified target. It is common for the
5011interface to the other executables to change incompatibly between
5012compiler versions, so unless the version specified is very close to that
630d3d5a
JM
5013of the driver (for example, @option{-V 3.0} with a driver program from GCC
5014version 3.0.1), use of @option{-V} may not work; for example, using
5015@option{-V 2.95.2} will not work with a driver program from GCC 3.0.
74291a4b
MM
5016
5017The only way that the driver program depends on the target machine is
5018in the parsing and handling of special machine-specific options.
5019However, this is controlled by a file which is found, along with the
5020other executables, in the directory for the specified version and
5021target machine. As a result, a single installed driver program adapts
8c7b74b9
JM
5022to any specified target machine, and sufficiently similar compiler
5023versions.
74291a4b
MM
5024
5025The driver program executable does control one significant thing,
5026however: the default version and target machine. Therefore, you can
5027install different instances of the driver program, compiled for
5028different targets or versions, under different names.
5029
bedc7537
NC
5030For example, if the driver for version 2.0 is installed as @command{ogcc}
5031and that for version 2.1 is installed as @command{gcc}, then the command
5032@command{gcc} will use version 2.1 by default, while @command{ogcc} will use
74291a4b 50332.0 by default. However, you can choose either version with either
630d3d5a 5034command with the @option{-V} option.
74291a4b
MM
5035
5036@node Submodel Options
5037@section Hardware Models and Configurations
5038@cindex submodel options
5039@cindex specifying hardware config
5040@cindex hardware models and configurations, specifying
5041@cindex machine dependent options
5042
630d3d5a 5043Earlier we discussed the standard option @option{-b} which chooses among
74291a4b 5044different installed compilers for completely different target
8aeea6e6 5045machines, such as VAX vs.@: 68000 vs.@: 80386.
74291a4b
MM
5046
5047In addition, each of these target machine types can have its own
5048special options, starting with @samp{-m}, to choose among various
5049hardware models or configurations---for example, 68010 vs 68020,
5050floating coprocessor or none. A single installed version of the
5051compiler can compile for any model or configuration, according to the
5052options specified.
5053
5054Some configurations of the compiler also support additional special
5055options, usually for compatibility with other compilers on the same
5056platform.
5057
5058@ifset INTERNALS
5059These options are defined by the macro @code{TARGET_SWITCHES} in the
5060machine description. The default for the options is also defined by
5061that macro, which enables you to change the defaults.
5062@end ifset
5063
5064@menu
5065* M680x0 Options::
2856c3e3 5066* M68hc1x Options::
74291a4b
MM
5067* VAX Options::
5068* SPARC Options::
5069* Convex Options::
5070* AMD29K Options::
5071* ARM Options::
ecff22ab 5072* MN10200 Options::
6d6d0fa0 5073* MN10300 Options::
861bb6c1 5074* M32R/D Options::
74291a4b
MM
5075* M88K Options::
5076* RS/6000 and PowerPC Options::
5077* RT Options::
5078* MIPS Options::
5079* i386 Options::
5080* HPPA Options::
5081* Intel 960 Options::
5082* DEC Alpha Options::
5083* Clipper Options::
5084* H8/300 Options::
5085* SH Options::
5086* System V Options::
282a61e6 5087* TMS320C3x/C4x Options::
f84271d9 5088* V850 Options::
56b2d7a7 5089* ARC Options::
83575957 5090* NS32K Options::
052a4b28
DC
5091* AVR Options::
5092* MCore Options::
df6194d4 5093* IA-64 Options::
e8ad90e5 5094* D30V Options::
91abf72d 5095* S/390 and zSeries Options::
74291a4b
MM
5096@end menu
5097
5098@node M680x0 Options
5099@subsection M680x0 Options
5100@cindex M680x0 options
5101
5102These are the @samp{-m} options defined for the 68000 series. The default
5103values for these options depends on which style of 68000 was selected when
5104the compiler was configured; the defaults for the most common choices are
5105given below.
5106
2642624b 5107@table @gcctabopt
74291a4b
MM
5108@item -m68000
5109@itemx -mc68000
cd3bb277
JM
5110@opindex m68000
5111@opindex mc68000
74291a4b
MM
5112Generate output for a 68000. This is the default
5113when the compiler is configured for 68000-based systems.
5114
74cf1c6d
RK
5115Use this option for microcontrollers with a 68000 or EC000 core,
5116including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
5117
74291a4b
MM
5118@item -m68020
5119@itemx -mc68020
cd3bb277
JM
5120@opindex m68020
5121@opindex mc68020
74291a4b
MM
5122Generate output for a 68020. This is the default
5123when the compiler is configured for 68020-based systems.
5124
5125@item -m68881
cd3bb277 5126@opindex m68881
74291a4b 5127Generate output containing 68881 instructions for floating point.
630d3d5a 5128This is the default for most 68020 systems unless @option{--nfp} was
74291a4b
MM
5129specified when the compiler was configured.
5130
5131@item -m68030
cd3bb277 5132@opindex m68030
74291a4b
MM
5133Generate output for a 68030. This is the default when the compiler is
5134configured for 68030-based systems.
5135
5136@item -m68040
cd3bb277 5137@opindex m68040
74291a4b
MM
5138Generate output for a 68040. This is the default when the compiler is
5139configured for 68040-based systems.
5140
5141This option inhibits the use of 68881/68882 instructions that have to be
74cf1c6d
RK
5142emulated by software on the 68040. Use this option if your 68040 does not
5143have code to emulate those instructions.
74291a4b
MM
5144
5145@item -m68060
cd3bb277 5146@opindex m68060
74291a4b
MM
5147Generate output for a 68060. This is the default when the compiler is
5148configured for 68060-based systems.
5149
5150This option inhibits the use of 68020 and 68881/68882 instructions that
74cf1c6d
RK
5151have to be emulated by software on the 68060. Use this option if your 68060
5152does not have code to emulate those instructions.
5153
5154@item -mcpu32
cd3bb277 5155@opindex mcpu32
767094dd 5156Generate output for a CPU32. This is the default
74cf1c6d
RK
5157when the compiler is configured for CPU32-based systems.
5158
5159Use this option for microcontrollers with a
5160CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
516168336, 68340, 68341, 68349 and 68360.
74291a4b
MM
5162
5163@item -m5200
cd3bb277 5164@opindex m5200
695ac33f 5165Generate output for a 520X ``coldfire'' family cpu. This is the default
74291a4b
MM
5166when the compiler is configured for 520X-based systems.
5167
02f52e19 5168Use this option for microcontroller with a 5200 core, including
74cf1c6d
RK
5169the MCF5202, MCF5203, MCF5204 and MCF5202.
5170
74291a4b
MM
5171
5172@item -m68020-40
cd3bb277 5173@opindex m68020-40
74291a4b
MM
5174Generate output for a 68040, without using any of the new instructions.
5175This results in code which can run relatively efficiently on either a
517668020/68881 or a 68030 or a 68040. The generated code does use the
517768881 instructions that are emulated on the 68040.
5178
861bb6c1 5179@item -m68020-60
cd3bb277 5180@opindex m68020-60
861bb6c1
JL
5181Generate output for a 68060, without using any of the new instructions.
5182This results in code which can run relatively efficiently on either a
518368020/68881 or a 68030 or a 68040. The generated code does use the
518468881 instructions that are emulated on the 68060.
5185
74291a4b 5186@item -mfpa
cd3bb277 5187@opindex mfpa
74291a4b
MM
5188Generate output containing Sun FPA instructions for floating point.
5189
5190@item -msoft-float
cd3bb277 5191@opindex msoft-float
74291a4b
MM
5192Generate output containing library calls for floating point.
5193@strong{Warning:} the requisite libraries are not available for all m68k
5194targets. Normally the facilities of the machine's usual C compiler are
5195used, but this can't be done directly in cross-compilation. You must
5196make your own arrangements to provide suitable library functions for
5197cross-compilation. The embedded targets @samp{m68k-*-aout} and
5198@samp{m68k-*-coff} do provide software floating point support.
5199
5200@item -mshort
cd3bb277 5201@opindex mshort
74291a4b
MM
5202Consider type @code{int} to be 16 bits wide, like @code{short int}.
5203
5204@item -mnobitfield
cd3bb277 5205@opindex mnobitfield
630d3d5a
JM
5206Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
5207and @option{-m5200} options imply @w{@option{-mnobitfield}}.
74291a4b
MM
5208
5209@item -mbitfield
cd3bb277 5210@opindex mbitfield
630d3d5a
JM
5211Do use the bit-field instructions. The @option{-m68020} option implies
5212@option{-mbitfield}. This is the default if you use a configuration
74291a4b
MM
5213designed for a 68020.
5214
5215@item -mrtd
cd3bb277 5216@opindex mrtd
74291a4b
MM
5217Use a different function-calling convention, in which functions
5218that take a fixed number of arguments return with the @code{rtd}
5219instruction, which pops their arguments while returning. This
5220saves one instruction in the caller since there is no need to pop
5221the arguments there.
5222
5223This calling convention is incompatible with the one normally
5224used on Unix, so you cannot use it if you need to call libraries
5225compiled with the Unix compiler.
5226
5227Also, you must provide function prototypes for all functions that
5228take variable numbers of arguments (including @code{printf});
5229otherwise incorrect code will be generated for calls to those
5230functions.
5231
5232In addition, seriously incorrect code will result if you call a
5233function with too many arguments. (Normally, extra arguments are
5234harmlessly ignored.)
5235
5236The @code{rtd} instruction is supported by the 68010, 68020, 68030,
74cf1c6d 523768040, 68060 and CPU32 processors, but not by the 68000 or 5200.
861bb6c1
JL
5238
5239@item -malign-int
5240@itemx -mno-align-int
cd3bb277
JM
5241@opindex malign-int
5242@opindex mno-align-int
02f52e19 5243Control whether GCC aligns @code{int}, @code{long}, @code{long long},
861bb6c1 5244@code{float}, @code{double}, and @code{long double} variables on a 32-bit
630d3d5a 5245boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
861bb6c1
JL
5246Aligning variables on 32-bit boundaries produces code that runs somewhat
5247faster on processors with 32-bit busses at the expense of more memory.
5248
630d3d5a 5249@strong{Warning:} if you use the @option{-malign-int} switch, GCC will
861bb6c1
JL
5250align structures containing the above types differently than
5251most published application binary interface specifications for the m68k.
5252
fb868474 5253@item -mpcrel
cd3bb277 5254@opindex mpcrel
fb868474 5255Use the pc-relative addressing mode of the 68000 directly, instead of
695ac33f
JM
5256using a global offset table. At present, this option implies @option{-fpic},
5257allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
5258not presently supported with @option{-mpcrel}, though this could be supported for
fb868474
DL
525968020 and higher processors.
5260
b71733d5
GM
5261@item -mno-strict-align
5262@itemx -mstrict-align
cd3bb277
JM
5263@opindex mno-strict-align
5264@opindex mstrict-align
b71733d5
GM
5265Do not (do) assume that unaligned memory references will be handled by
5266the system.
5267
74291a4b
MM
5268@end table
5269
2856c3e3
SC
5270@node M68hc1x Options
5271@subsection M68hc1x Options
5272@cindex M68hc1x options
5273
5274These are the @samp{-m} options defined for the 68hc11 and 68hc12
02f52e19 5275microcontrollers. The default values for these options depends on
2856c3e3
SC
5276which style of microcontroller was selected when the compiler was configured;
5277the defaults for the most common choices are given below.
5278
2642624b 5279@table @gcctabopt
2856c3e3
SC
5280@item -m6811
5281@itemx -m68hc11
cd3bb277
JM
5282@opindex m6811
5283@opindex m68hc11
2856c3e3
SC
5284Generate output for a 68HC11. This is the default
5285when the compiler is configured for 68HC11-based systems.
5286
5287@item -m6812
5288@itemx -m68hc12
cd3bb277
JM
5289@opindex m6812
5290@opindex m68hc12
2856c3e3
SC
5291Generate output for a 68HC12. This is the default
5292when the compiler is configured for 68HC12-based systems.
5293
5294@item -mauto-incdec
cd3bb277 5295@opindex mauto-incdec
2856c3e3
SC
5296Enable the use of 68HC12 pre and post auto-increment and auto-decrement
5297addressing modes.
5298
5299@item -mshort
cd3bb277 5300@opindex mshort
2856c3e3
SC
5301Consider type @code{int} to be 16 bits wide, like @code{short int}.
5302
5303@item -msoft-reg-count=@var{count}
cd3bb277 5304@opindex msoft-reg-count
2856c3e3
SC
5305Specify the number of pseudo-soft registers which are used for the
5306code generation. The maximum number is 32. Using more pseudo-soft
5307register may or may not result in better code depending on the program.
5308The default is 4 for 68HC11 and 2 for 68HC12.
5309
5310@end table
5311
74291a4b
MM
5312@node VAX Options
5313@subsection VAX Options
5314@cindex VAX options
5315
8aeea6e6 5316These @samp{-m} options are defined for the VAX:
74291a4b 5317
2642624b 5318@table @gcctabopt
74291a4b 5319@item -munix
cd3bb277 5320@opindex munix
74291a4b 5321Do not output certain jump instructions (@code{aobleq} and so on)
8aeea6e6 5322that the Unix assembler for the VAX cannot handle across long
74291a4b
MM
5323ranges.
5324
5325@item -mgnu
cd3bb277 5326@opindex mgnu
74291a4b
MM
5327Do output those jump instructions, on the assumption that you
5328will assemble with the GNU assembler.
5329
5330@item -mg
cd3bb277 5331@opindex mg
74291a4b
MM
5332Output code for g-format floating point numbers instead of d-format.
5333@end table
5334
5335@node SPARC Options
5336@subsection SPARC Options
5337@cindex SPARC options
5338
5339These @samp{-m} switches are supported on the SPARC:
5340
2642624b 5341@table @gcctabopt
74291a4b
MM
5342@item -mno-app-regs
5343@itemx -mapp-regs
cd3bb277
JM
5344@opindex mno-app-regs
5345@opindex mapp-regs
630d3d5a 5346Specify @option{-mapp-regs} to generate output using the global registers
74291a4b
MM
53472 through 4, which the SPARC SVR4 ABI reserves for applications. This
5348is the default.
5349
5350To be fully SVR4 ABI compliant at the cost of some performance loss,
630d3d5a 5351specify @option{-mno-app-regs}. You should compile libraries and system
74291a4b
MM
5352software with this option.
5353
5354@item -mfpu
5355@itemx -mhard-float
cd3bb277
JM
5356@opindex mfpu
5357@opindex mhard-float
74291a4b
MM
5358Generate output containing floating point instructions. This is the
5359default.
5360
5361@item -mno-fpu
5362@itemx -msoft-float
cd3bb277
JM
5363@opindex mno-fpu
5364@opindex msoft-float
74291a4b
MM
5365Generate output containing library calls for floating point.
5366@strong{Warning:} the requisite libraries are not available for all SPARC
5367targets. Normally the facilities of the machine's usual C compiler are
5368used, but this cannot be done directly in cross-compilation. You must make
5369your own arrangements to provide suitable library functions for
5370cross-compilation. The embedded targets @samp{sparc-*-aout} and
5371@samp{sparclite-*-*} do provide software floating point support.
5372
630d3d5a 5373@option{-msoft-float} changes the calling convention in the output file;
74291a4b
MM
5374therefore, it is only useful if you compile @emph{all} of a program with
5375this option. In particular, you need to compile @file{libgcc.a}, the
630d3d5a 5376library that comes with GCC, with @option{-msoft-float} in order for
74291a4b
MM
5377this to work.
5378
5379@item -mhard-quad-float
cd3bb277 5380@opindex mhard-quad-float
74291a4b
MM
5381Generate output containing quad-word (long double) floating point
5382instructions.
5383
5384@item -msoft-quad-float
cd3bb277 5385@opindex msoft-quad-float
74291a4b
MM
5386Generate output containing library calls for quad-word (long double)
5387floating point instructions. The functions called are those specified
161d7b59 5388in the SPARC ABI@. This is the default.
74291a4b
MM
5389
5390As of this writing, there are no sparc implementations that have hardware
5391support for the quad-word floating point instructions. They all invoke
5392a trap handler for one of these instructions, and then the trap handler
5393emulates the effect of the instruction. Because of the trap handler overhead,
5394this is much slower than calling the ABI library routines. Thus the
630d3d5a 5395@option{-msoft-quad-float} option is the default.
74291a4b
MM
5396
5397@item -mno-epilogue
5398@itemx -mepilogue
cd3bb277
JM
5399@opindex mno-epilogue
5400@opindex mepilogue
630d3d5a 5401With @option{-mepilogue} (the default), the compiler always emits code for
74291a4b
MM
5402function exit at the end of each function. Any function exit in
5403the middle of the function (such as a return statement in C) will
5404generate a jump to the exit code at the end of the function.
5405
630d3d5a 5406With @option{-mno-epilogue}, the compiler tries to emit exit code inline
74291a4b
MM
5407at every function exit.
5408
5409@item -mno-flat
5410@itemx -mflat
cd3bb277
JM
5411@opindex mno-flat
5412@opindex mflat
630d3d5a 5413With @option{-mflat}, the compiler does not generate save/restore instructions
695ac33f 5414and will use a ``flat'' or single register window calling convention.
74291a4b
MM
5415This model uses %i7 as the frame pointer and is compatible with the normal
5416register window model. Code from either may be intermixed.
aee96fe9 5417The local registers and the input registers (0--5) are still treated as
695ac33f 5418``call saved'' registers and will be saved on the stack as necessary.
74291a4b 5419
630d3d5a 5420With @option{-mno-flat} (the default), the compiler emits save/restore
74291a4b
MM
5421instructions (except for leaf functions) and is the normal mode of operation.
5422
5423@item -mno-unaligned-doubles
5424@itemx -munaligned-doubles
cd3bb277
JM
5425@opindex mno-unaligned-doubles
5426@opindex munaligned-doubles
74291a4b
MM
5427Assume that doubles have 8 byte alignment. This is the default.
5428
630d3d5a 5429With @option{-munaligned-doubles}, GCC assumes that doubles have 8 byte
74291a4b
MM
5430alignment only if they are contained in another type, or if they have an
5431absolute address. Otherwise, it assumes they have 4 byte alignment.
5432Specifying this option avoids some rare compatibility problems with code
5433generated by other compilers. It is not the default because it results
5434in a performance loss, especially for floating point code.
5435
c219ddf7
BK
5436@item -mno-faster-structs
5437@itemx -mfaster-structs
cd3bb277
JM
5438@opindex mno-faster-structs
5439@opindex mfaster-structs
630d3d5a 5440With @option{-mfaster-structs}, the compiler assumes that structures
c219ddf7
BK
5441should have 8 byte alignment. This enables the use of pairs of
5442@code{ldd} and @code{std} instructions for copies in structure
5443assignment, in place of twice as many @code{ld} and @code{st} pairs.
5444However, the use of this changed alignment directly violates the Sparc
161d7b59 5445ABI@. Thus, it's intended only for use on targets where the developer
c219ddf7 5446acknowledges that their resulting code will not be directly in line with
161d7b59 5447the rules of the ABI@.
c219ddf7 5448
74291a4b
MM
5449@item -mv8
5450@itemx -msparclite
cd3bb277
JM
5451@opindex mv8
5452@opindex msparclite
74291a4b
MM
5453These two options select variations on the SPARC architecture.
5454
5455By default (unless specifically configured for the Fujitsu SPARClite),
5456GCC generates code for the v7 variant of the SPARC architecture.
5457
630d3d5a 5458@option{-mv8} will give you SPARC v8 code. The only difference from v7
74291a4b
MM
5459code is that the compiler emits the integer multiply and integer
5460divide instructions which exist in SPARC v8 but not in SPARC v7.
5461
630d3d5a 5462@option{-msparclite} will give you SPARClite code. This adds the integer
74291a4b
MM
5463multiply, integer divide step and scan (@code{ffs}) instructions which
5464exist in SPARClite but not in SPARC v7.
5465
0c2d1a2a 5466These options are deprecated and will be deleted in a future GCC release.
630d3d5a 5467They have been replaced with @option{-mcpu=xxx}.
74291a4b
MM
5468
5469@item -mcypress
5470@itemx -msupersparc
cd3bb277
JM
5471@opindex mcypress
5472@opindex msupersparc
74291a4b
MM
5473These two options select the processor for which the code is optimised.
5474
630d3d5a 5475With @option{-mcypress} (the default), the compiler optimizes code for the
74291a4b
MM
5476Cypress CY7C602 chip, as used in the SparcStation/SparcServer 3xx series.
5477This is also appropriate for the older SparcStation 1, 2, IPX etc.
5478
630d3d5a 5479With @option{-msupersparc} the compiler optimizes code for the SuperSparc cpu, as
767094dd 5480used in the SparcStation 10, 1000 and 2000 series. This flag also enables use
74291a4b
MM
5481of the full SPARC v8 instruction set.
5482
0c2d1a2a 5483These options are deprecated and will be deleted in a future GCC release.
630d3d5a 5484They have been replaced with @option{-mcpu=xxx}.
74291a4b
MM
5485
5486@item -mcpu=@var{cpu_type}
cd3bb277 5487@opindex mcpu
c0498f43
DE
5488Set the instruction set, register set, and instruction scheduling parameters
5489for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
5490@samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{sparclite},
ad6843d7
RH
5491@samp{hypersparc}, @samp{sparclite86x}, @samp{f930}, @samp{f934},
5492@samp{sparclet}, @samp{tsc701}, @samp{v9}, and @samp{ultrasparc}.
c0498f43
DE
5493
5494Default instruction scheduling parameters are used for values that select
5495an architecture and not an implementation. These are @samp{v7}, @samp{v8},
5496@samp{sparclite}, @samp{sparclet}, @samp{v9}.
5497
5498Here is a list of each supported architecture and their supported
5499implementations.
5500
5501@smallexample
5502 v7: cypress
ad6843d7
RH
5503 v8: supersparc, hypersparc
5504 sparclite: f930, f934, sparclite86x
c0498f43
DE
5505 sparclet: tsc701
5506 v9: ultrasparc
5507@end smallexample
74291a4b
MM
5508
5509@item -mtune=@var{cpu_type}
cd3bb277 5510@opindex mtune
74291a4b 5511Set the instruction scheduling parameters for machine type
c0498f43 5512@var{cpu_type}, but do not set the instruction set or register set that the
630d3d5a 5513option @option{-mcpu=@var{cpu_type}} would.
c0498f43 5514
9c34dbbf
ZW
5515The same values for @option{-mcpu=@var{cpu_type}} can be used for
5516@option{-mtune=@var{cpu_type}}, but the only useful values are those
5517that select a particular cpu implementation. Those are @samp{cypress},
5518@samp{supersparc}, @samp{hypersparc}, @samp{f930}, @samp{f934},
5519@samp{sparclite86x}, @samp{tsc701}, and @samp{ultrasparc}.
74291a4b
MM
5520
5521@end table
5522
5523These @samp{-m} switches are supported in addition to the above
5524on the SPARCLET processor.
5525
2642624b 5526@table @gcctabopt
74291a4b 5527@item -mlittle-endian
cd3bb277 5528@opindex mlittle-endian
74291a4b
MM
5529Generate code for a processor running in little-endian mode.
5530
5531@item -mlive-g0
cd3bb277 5532@opindex mlive-g0
74291a4b
MM
5533Treat register @code{%g0} as a normal register.
5534GCC will continue to clobber it as necessary but will not assume
5535it always reads as 0.
5536
5537@item -mbroken-saverestore
cd3bb277 5538@opindex mbroken-saverestore
74291a4b
MM
5539Generate code that does not use non-trivial forms of the @code{save} and
5540@code{restore} instructions. Early versions of the SPARCLET processor do
5541not correctly handle @code{save} and @code{restore} instructions used with
5542arguments. They correctly handle them used without arguments. A @code{save}
5543instruction used without arguments increments the current window pointer
5544but does not allocate a new stack frame. It is assumed that the window
5545overflow trap handler will properly handle this case as will interrupt
5546handlers.
5547@end table
5548
5549These @samp{-m} switches are supported in addition to the above
02f52e19 5550on SPARC V9 processors in 64-bit environments.
74291a4b 5551
2642624b 5552@table @gcctabopt
74291a4b 5553@item -mlittle-endian
cd3bb277 5554@opindex mlittle-endian
74291a4b
MM
5555Generate code for a processor running in little-endian mode.
5556
ded17aad
DE
5557@item -m32
5558@itemx -m64
cd3bb277
JM
5559@opindex m32
5560@opindex m64
02f52e19
AJ
5561Generate code for a 32-bit or 64-bit environment.
5562The 32-bit environment sets int, long and pointer to 32 bits.
5563The 64-bit environment sets int to 32 bits and long and pointer
ded17aad
DE
5564to 64 bits.
5565
5566@item -mcmodel=medlow
cd3bb277 5567@opindex mcmodel=medlow
ded17aad
DE
5568Generate code for the Medium/Low code model: the program must be linked
5569in the low 32 bits of the address space. Pointers are 64 bits.
5570Programs can be statically or dynamically linked.
5571
5572@item -mcmodel=medmid
cd3bb277 5573@opindex mcmodel=medmid
ded17aad
DE
5574Generate code for the Medium/Middle code model: the program must be linked
5575in the low 44 bits of the address space, the text segment must be less than
55762G bytes, and data segment must be within 2G of the text segment.
5577Pointers are 64 bits.
5578
5579@item -mcmodel=medany
cd3bb277 5580@opindex mcmodel=medany
ded17aad
DE
5581Generate code for the Medium/Anywhere code model: the program may be linked
5582anywhere in the address space, the text segment must be less than
55832G bytes, and data segment must be within 2G of the text segment.
5584Pointers are 64 bits.
5585
5586@item -mcmodel=embmedany
cd3bb277 5587@opindex mcmodel=embmedany
ded17aad 5588Generate code for the Medium/Anywhere code model for embedded systems:
02f52e19 5589assume a 32-bit text and a 32-bit data segment, both starting anywhere
ded17aad 5590(determined at link time). Register %g4 points to the base of the
02f52e19 5591data segment. Pointers are still 64 bits.
ded17aad 5592Programs are statically linked, PIC is not supported.
74291a4b
MM
5593
5594@item -mstack-bias
5595@itemx -mno-stack-bias
cd3bb277
JM
5596@opindex mstack-bias
5597@opindex mno-stack-bias
630d3d5a
JM
5598With @option{-mstack-bias}, GCC assumes that the stack pointer, and
5599frame pointer if present, are offset by @minus{}2047 which must be added back
74291a4b
MM
5600when making stack frame references.
5601Otherwise, assume no such offset is present.
5602@end table
5603
5604@node Convex Options
5605@subsection Convex Options
5606@cindex Convex options
5607
5608These @samp{-m} options are defined for Convex:
5609
2642624b 5610@table @gcctabopt
74291a4b 5611@item -mc1
cd3bb277 5612@opindex mc1
74291a4b
MM
5613Generate output for C1. The code will run on any Convex machine.
5614The preprocessor symbol @code{__convex__c1__} is defined.
5615
5616@item -mc2
cd3bb277 5617@opindex mc2
74291a4b
MM
5618Generate output for C2. Uses instructions not available on C1.
5619Scheduling and other optimizations are chosen for max performance on C2.
5620The preprocessor symbol @code{__convex_c2__} is defined.
5621
5622@item -mc32
cd3bb277 5623@opindex mc32
74291a4b
MM
5624Generate output for C32xx. Uses instructions not available on C1.
5625Scheduling and other optimizations are chosen for max performance on C32.
5626The preprocessor symbol @code{__convex_c32__} is defined.
5627
5628@item -mc34
cd3bb277 5629@opindex mc34
74291a4b
MM
5630Generate output for C34xx. Uses instructions not available on C1.
5631Scheduling and other optimizations are chosen for max performance on C34.
5632The preprocessor symbol @code{__convex_c34__} is defined.
5633
5634@item -mc38
cd3bb277 5635@opindex mc38
74291a4b
MM
5636Generate output for C38xx. Uses instructions not available on C1.
5637Scheduling and other optimizations are chosen for max performance on C38.
5638The preprocessor symbol @code{__convex_c38__} is defined.
5639
5640@item -margcount
cd3bb277 5641@opindex margcount
74291a4b
MM
5642Generate code which puts an argument count in the word preceding each
5643argument list. This is compatible with regular CC, and a few programs
5644may need the argument count word. GDB and other source-level debuggers
5645do not need it; this info is in the symbol table.
5646
5647@item -mnoargcount
cd3bb277 5648@opindex mnoargcount
74291a4b
MM
5649Omit the argument count word. This is the default.
5650
5651@item -mvolatile-cache
cd3bb277 5652@opindex mvolatile-cache
74291a4b
MM
5653Allow volatile references to be cached. This is the default.
5654
5655@item -mvolatile-nocache
cd3bb277 5656@opindex mvolatile-nocache
74291a4b
MM
5657Volatile references bypass the data cache, going all the way to memory.
5658This is only needed for multi-processor code that does not use standard
5659synchronization instructions. Making non-volatile references to volatile
5660locations will not necessarily work.
5661
5662@item -mlong32
cd3bb277 5663@opindex mlong32
74291a4b
MM
5664Type long is 32 bits, the same as type int. This is the default.
5665
5666@item -mlong64
cd3bb277 5667@opindex mlong64
74291a4b
MM
5668Type long is 64 bits, the same as type long long. This option is useless,
5669because no library support exists for it.
5670@end table
5671
5672@node AMD29K Options
5673@subsection AMD29K Options
5674@cindex AMD29K options
5675
5676These @samp{-m} options are defined for the AMD Am29000:
5677
2642624b 5678@table @gcctabopt
74291a4b 5679@item -mdw
cd3bb277 5680@opindex mdw
74291a4b
MM
5681@cindex DW bit (29k)
5682Generate code that assumes the @code{DW} bit is set, i.e., that byte and
5683halfword operations are directly supported by the hardware. This is the
5684default.
5685
5686@item -mndw
cd3bb277 5687@opindex mndw
74291a4b
MM
5688Generate code that assumes the @code{DW} bit is not set.
5689
5690@item -mbw
cd3bb277 5691@opindex mbw
74291a4b
MM
5692@cindex byte writes (29k)
5693Generate code that assumes the system supports byte and halfword write
5694operations. This is the default.
5695
5696@item -mnbw
cd3bb277 5697@opindex mnbw
74291a4b 5698Generate code that assumes the systems does not support byte and
630d3d5a 5699halfword write operations. @option{-mnbw} implies @option{-mndw}.
74291a4b
MM
5700
5701@item -msmall
cd3bb277 5702@opindex msmall
74291a4b
MM
5703@cindex memory model (29k)
5704Use a small memory model that assumes that all function addresses are
5705either within a single 256 KB segment or at an absolute address of less
5706than 256k. This allows the @code{call} instruction to be used instead
5707of a @code{const}, @code{consth}, @code{calli} sequence.
5708
5709@item -mnormal
cd3bb277 5710@opindex mnormal
74291a4b
MM
5711Use the normal memory model: Generate @code{call} instructions only when
5712calling functions in the same file and @code{calli} instructions
5713otherwise. This works if each file occupies less than 256 KB but allows
161d7b59 5714the entire executable to be larger than 256 KB@. This is the default.
74291a4b
MM
5715
5716@item -mlarge
cd3bb277 5717@opindex mlarge
74291a4b
MM
5718Always use @code{calli} instructions. Specify this option if you expect
5719a single file to compile into more than 256 KB of code.
5720
5721@item -m29050
cd3bb277 5722@opindex m29050
74291a4b
MM
5723@cindex processor selection (29k)
5724Generate code for the Am29050.
5725
5726@item -m29000
cd3bb277 5727@opindex m29000
74291a4b
MM
5728Generate code for the Am29000. This is the default.
5729
5730@item -mkernel-registers
cd3bb277 5731@opindex mkernel-registers
74291a4b
MM
5732@cindex kernel and user registers (29k)
5733Generate references to registers @code{gr64-gr95} instead of to
5734registers @code{gr96-gr127}. This option can be used when compiling
5735kernel code that wants a set of global registers disjoint from that used
5736by user-mode code.
5737
5738Note that when this option is used, register names in @samp{-f} flags
5739must use the normal, user-mode, names.
5740
5741@item -muser-registers
cd3bb277 5742@opindex muser-registers
74291a4b
MM
5743Use the normal set of global registers, @code{gr96-gr127}. This is the
5744default.
5745
5746@item -mstack-check
5747@itemx -mno-stack-check
cd3bb277
JM
5748@opindex mstack-check
5749@opindex mno-stack-check
74291a4b
MM
5750@cindex stack checks (29k)
5751Insert (or do not insert) a call to @code{__msp_check} after each stack
5752adjustment. This is often used for kernel code.
5753
5754@item -mstorem-bug
5755@itemx -mno-storem-bug
cd3bb277
JM
5756@opindex mstorem-bug
5757@opindex mno-storem-bug
74291a4b 5758@cindex storem bug (29k)
630d3d5a 5759@option{-mstorem-bug} handles 29k processors which cannot handle the
74291a4b
MM
5760separation of a mtsrim insn and a storem instruction (most 29000 chips
5761to date, but not the 29050).
5762
5763@item -mno-reuse-arg-regs
5764@itemx -mreuse-arg-regs
cd3bb277
JM
5765@opindex mno-reuse-arg-regs
5766@opindex mreuse-arg-regs
630d3d5a 5767@option{-mno-reuse-arg-regs} tells the compiler to only use incoming argument
74291a4b
MM
5768registers for copying out arguments. This helps detect calling a function
5769with fewer arguments than it was declared with.
5770
861bb6c1
JL
5771@item -mno-impure-text
5772@itemx -mimpure-text
cd3bb277
JM
5773@opindex mno-impure-text
5774@opindex mimpure-text
630d3d5a
JM
5775@option{-mimpure-text}, used in addition to @option{-shared}, tells the compiler to
5776not pass @option{-assert pure-text} to the linker when linking a shared object.
861bb6c1 5777
74291a4b 5778@item -msoft-float
cd3bb277 5779@opindex msoft-float
74291a4b 5780Generate output containing library calls for floating point.
161d7b59 5781@strong{Warning:} the requisite libraries are not part of GCC@.
74291a4b
MM
5782Normally the facilities of the machine's usual C compiler are used, but
5783this can't be done directly in cross-compilation. You must make your
5784own arrangements to provide suitable library functions for
5785cross-compilation.
4e8d7ddc
JW
5786
5787@item -mno-multm
cd3bb277 5788@opindex mno-multm
4e8d7ddc
JW
5789Do not generate multm or multmu instructions. This is useful for some embedded
5790systems which do not have trap handlers for these instructions.
74291a4b
MM
5791@end table
5792
5793@node ARM Options
5794@subsection ARM Options
5795@cindex ARM options
5796
5797These @samp{-m} options are defined for Advanced RISC Machines (ARM)
5798architectures:
5799
2642624b 5800@table @gcctabopt
74291a4b 5801@item -mapcs-frame
cd3bb277 5802@opindex mapcs-frame
74291a4b
MM
5803Generate a stack frame that is compliant with the ARM Procedure Call
5804Standard for all functions, even if this is not strictly necessary for
630d3d5a 5805correct execution of the code. Specifying @option{-fomit-frame-pointer}
157a620e 5806with this option will cause the stack frames not to be generated for
630d3d5a 5807leaf functions. The default is @option{-mno-apcs-frame}.
157a620e
NC
5808
5809@item -mapcs
cd3bb277 5810@opindex mapcs
630d3d5a 5811This is a synonym for @option{-mapcs-frame}.
74291a4b
MM
5812
5813@item -mapcs-26
cd3bb277 5814@opindex mapcs-26
74291a4b
MM
5815Generate code for a processor running with a 26-bit program counter,
5816and conforming to the function calling standards for the APCS 26-bit
630d3d5a 5817option. This option replaces the @option{-m2} and @option{-m3} options
74291a4b
MM
5818of previous releases of the compiler.
5819
5820@item -mapcs-32
cd3bb277 5821@opindex mapcs-32
74291a4b
MM
5822Generate code for a processor running with a 32-bit program counter,
5823and conforming to the function calling standards for the APCS 32-bit
630d3d5a 5824option. This option replaces the @option{-m6} option of previous releases
74291a4b
MM
5825of the compiler.
5826
247f8561
PB
5827@ignore
5828@c not currently implemented
157a620e 5829@item -mapcs-stack-check
cd3bb277 5830@opindex mapcs-stack-check
157a620e
NC
5831Generate code to check the amount of stack space available upon entry to
5832every function (that actually uses some stack space). If there is
5833insufficient space available then either the function
5834@samp{__rt_stkovf_split_small} or @samp{__rt_stkovf_split_big} will be
5835called, depending upon the amount of stack space required. The run time
5836system is required to provide these functions. The default is
630d3d5a 5837@option{-mno-apcs-stack-check}, since this produces smaller code.
157a620e 5838
247f8561 5839@c not currently implemented
157a620e 5840@item -mapcs-float
cd3bb277 5841@opindex mapcs-float
157a620e 5842Pass floating point arguments using the float point registers. This is
161d7b59 5843one of the variants of the APCS@. This option is recommended if the
157a620e
NC
5844target hardware has a floating point unit or if a lot of floating point
5845arithmetic is going to be performed by the code. The default is
630d3d5a
JM
5846@option{-mno-apcs-float}, since integer only code is slightly increased in
5847size if @option{-mapcs-float} is used.
157a620e 5848
247f8561 5849@c not currently implemented
157a620e 5850@item -mapcs-reentrant
cd3bb277 5851@opindex mapcs-reentrant
247f8561 5852Generate reentrant, position independent code. The default is
630d3d5a 5853@option{-mno-apcs-reentrant}.
247f8561 5854@end ignore
157a620e
NC
5855
5856@item -mthumb-interwork
cd3bb277 5857@opindex mthumb-interwork
247f8561 5858Generate code which supports calling between the ARM and Thumb
157a620e
NC
5859instruction sets. Without this option the two instruction sets cannot
5860be reliably used inside one program. The default is
630d3d5a
JM
5861@option{-mno-thumb-interwork}, since slightly larger code is generated
5862when @option{-mthumb-interwork} is specified.
157a620e
NC
5863
5864@item -mno-sched-prolog
cd3bb277 5865@opindex mno-sched-prolog
157a620e
NC
5866Prevent the reordering of instructions in the function prolog, or the
5867merging of those instruction with the instructions in the function's
ed0e6530
PB
5868body. This means that all functions will start with a recognizable set
5869of instructions (or in fact one of a choice from a small set of
157a620e
NC
5870different function prologues), and this information can be used to
5871locate the start if functions inside an executable piece of code. The
630d3d5a 5872default is @option{-msched-prolog}.
157a620e 5873
74291a4b 5874@item -mhard-float
cd3bb277 5875@opindex mhard-float
74291a4b
MM
5876Generate output containing floating point instructions. This is the
5877default.
5878
5879@item -msoft-float
cd3bb277 5880@opindex msoft-float
74291a4b
MM
5881Generate output containing library calls for floating point.
5882@strong{Warning:} the requisite libraries are not available for all ARM
5883targets. Normally the facilities of the machine's usual C compiler are
5884used, but this cannot be done directly in cross-compilation. You must make
5885your own arrangements to provide suitable library functions for
5886cross-compilation.
5887
630d3d5a 5888@option{-msoft-float} changes the calling convention in the output file;
74291a4b
MM
5889therefore, it is only useful if you compile @emph{all} of a program with
5890this option. In particular, you need to compile @file{libgcc.a}, the
630d3d5a 5891library that comes with GCC, with @option{-msoft-float} in order for
74291a4b
MM
5892this to work.
5893
5894@item -mlittle-endian
cd3bb277 5895@opindex mlittle-endian
74291a4b
MM
5896Generate code for a processor running in little-endian mode. This is
5897the default for all standard configurations.
5898
5899@item -mbig-endian
cd3bb277 5900@opindex mbig-endian
74291a4b
MM
5901Generate code for a processor running in big-endian mode; the default is
5902to compile code for a little-endian processor.
5903
5904@item -mwords-little-endian
cd3bb277 5905@opindex mwords-little-endian
74291a4b
MM
5906This option only applies when generating code for big-endian processors.
5907Generate code for a little-endian word order but a big-endian byte
5908order. That is, a byte order of the form @samp{32107654}. Note: this
5909option should only be used if you require compatibility with code for
5910big-endian ARM processors generated by versions of the compiler prior to
59112.8.
5912
5f1e6755 5913@item -malignment-traps
cd3bb277 5914@opindex malignment-traps
5f1e6755
NC
5915Generate code that will not trap if the MMU has alignment traps enabled.
5916On ARM architectures prior to ARMv4, there were no instructions to
5917access half-word objects stored in memory. However, when reading from
5918memory a feature of the ARM architecture allows a word load to be used,
5919even if the address is unaligned, and the processor core will rotate the
5920data as it is being loaded. This option tells the compiler that such
5921misaligned accesses will cause a MMU trap and that it should instead
5922synthesise the access as a series of byte accesses. The compiler can
5923still use word accesses to load half-word data if it knows that the
5924address is aligned to a word boundary.
5925
5926This option is ignored when compiling for ARM architecture 4 or later,
5927since these processors have instructions to directly access half-word
02f52e19
AJ
5928objects in memory.
5929
5f1e6755 5930@item -mno-alignment-traps
cd3bb277 5931@opindex mno-alignment-traps
5f1e6755
NC
5932Generate code that assumes that the MMU will not trap unaligned
5933accesses. This produces better code when the target instruction set
e979f9e8 5934does not have half-word memory operations (i.e.@: implementations prior to
02f52e19 5935ARMv4).
5f1e6755
NC
5936
5937Note that you cannot use this option to access unaligned word objects,
5938since the processor will only fetch one 32-bit aligned object from
02f52e19 5939memory.
5f1e6755 5940
695ac33f 5941The default setting for most targets is @option{-mno-alignment-traps}, since
5f1e6755 5942this produces better code when there are no half-word memory
02f52e19 5943instructions available.
5f1e6755 5944
74291a4b 5945@item -mshort-load-bytes
247f8561 5946@itemx -mno-short-load-words
cd3bb277
JM
5947@opindex mshort-load-bytes
5948@opindex mno-short-load-words
630d3d5a 5949These are deprecated aliases for @option{-malignment-traps}.
74291a4b
MM
5950
5951@item -mno-short-load-bytes
247f8561 5952@itemx -mshort-load-words
cd3bb277
JM
5953@opindex mno-short-load-bytes
5954@opindex mshort-load-words
630d3d5a 5955This are deprecated aliases for @option{-mno-alignment-traps}.
157a620e 5956
74291a4b 5957@item -mbsd
cd3bb277 5958@opindex mbsd
161d7b59 5959This option only applies to RISC iX@. Emulate the native BSD-mode
630d3d5a 5960compiler. This is the default if @option{-ansi} is not specified.
74291a4b
MM
5961
5962@item -mxopen
cd3bb277 5963@opindex mxopen
161d7b59 5964This option only applies to RISC iX@. Emulate the native X/Open-mode
74291a4b
MM
5965compiler.
5966
5967@item -mno-symrename
cd3bb277 5968@opindex mno-symrename
161d7b59 5969This option only applies to RISC iX@. Do not run the assembler
74291a4b
MM
5970post-processor, @samp{symrename}, after code has been assembled.
5971Normally it is necessary to modify some of the standard symbols in
5972preparation for linking with the RISC iX C library; this option
5973suppresses this pass. The post-processor is never run when the
5974compiler is built for cross-compilation.
157a620e 5975
cd3bb277
JM
5976@item -mcpu=@var{name}
5977@opindex mcpu
157a620e 5978This specifies the name of the target ARM processor. GCC uses this name
247f8561 5979to determine what kind of instructions it can emit when generating
aee96fe9
JM
5980assembly code. Permissible names are: @samp{arm2}, @samp{arm250},
5981@samp{arm3}, @samp{arm6}, @samp{arm60}, @samp{arm600}, @samp{arm610},
5982@samp{arm620}, @samp{arm7}, @samp{arm7m}, @samp{arm7d}, @samp{arm7dm},
5983@samp{arm7di}, @samp{arm7dmi}, @samp{arm70}, @samp{arm700},
5984@samp{arm700i}, @samp{arm710}, @samp{arm710c}, @samp{arm7100},
5985@samp{arm7500}, @samp{arm7500fe}, @samp{arm7tdmi}, @samp{arm8},
5986@samp{strongarm}, @samp{strongarm110}, @samp{strongarm1100},
5987@samp{arm8}, @samp{arm810}, @samp{arm9}, @samp{arm9e}, @samp{arm920},
5988@samp{arm920t}, @samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi},
5989@samp{arm1020t}, @samp{xscale}.
62b10bbc 5990
cd3bb277
JM
5991@itemx -mtune=@var{name}
5992@opindex mtune
630d3d5a 5993This option is very similar to the @option{-mcpu=} option, except that
62b10bbc
NC
5994instead of specifying the actual target processor type, and hence
5995restricting which instructions can be used, it specifies that GCC should
5996tune the performance of the code as if the target were of the type
5997specified in this option, but still choosing the instructions that it
630d3d5a 5998will generate based on the cpu specified by a @option{-mcpu=} option.
247f8561 5999For some ARM implementations better performance can be obtained by using
62b10bbc 6000this option.
157a620e 6001
cd3bb277
JM
6002@item -march=@var{name}
6003@opindex march
157a620e 6004This specifies the name of the target ARM architecture. GCC uses this
247f8561 6005name to determine what kind of instructions it can emit when generating
157a620e 6006assembly code. This option can be used in conjunction with or instead
aee96fe9
JM
6007of the @option{-mcpu=} option. Permissible names are: @samp{armv2},
6008@samp{armv2a}, @samp{armv3}, @samp{armv3m}, @samp{armv4}, @samp{armv4t},
6009@samp{armv5}, @samp{armv5t}, @samp{armv5te}.
157a620e 6010
cd3bb277
JM
6011@item -mfpe=@var{number}
6012@itemx -mfp=@var{number}
6013@opindex mfpe
6014@opindex mfp
b192711e 6015This specifies the version of the floating point emulation available on
630d3d5a 6016the target. Permissible values are 2 and 3. @option{-mfp=} is a synonym
161d7b59 6017for @option{-mfpe=}, for compatibility with older versions of GCC@.
157a620e 6018
cd3bb277
JM
6019@item -mstructure-size-boundary=@var{n}
6020@opindex mstructure-size-boundary
157a620e 6021The size of all structures and unions will be rounded up to a multiple
ed0e6530 6022of the number of bits set by this option. Permissible values are 8 and
157a620e
NC
602332. The default value varies for different toolchains. For the COFF
6024targeted toolchain the default value is 8. Specifying the larger number
ed0e6530 6025can produce faster, more efficient code, but can also increase the size
157a620e
NC
6026of the program. The two values are potentially incompatible. Code
6027compiled with one value cannot necessarily expect to work with code or
6028libraries compiled with the other value, if they exchange information
247f8561 6029using structures or unions.
157a620e 6030
f5a1b0d2 6031@item -mabort-on-noreturn
cd3bb277 6032@opindex mabort-on-noreturn
247f8561
PB
6033Generate a call to the function @code{abort} at the end of a
6034@code{noreturn} function. It will be executed if the function tries to
6035return.
f5a1b0d2 6036
c27ba912
DM
6037@item -mlong-calls
6038@itemx -mno-long-calls
cd3bb277
JM
6039@opindex mlong-calls
6040@opindex mno-long-calls
c27ba912
DM
6041Tells the compiler to perform function calls by first loading the
6042address of the function into a register and then performing a subroutine
6043call on this register. This switch is needed if the target function
6044will lie outside of the 64 megabyte addressing range of the offset based
02f52e19 6045version of subroutine call instruction.
c27ba912
DM
6046
6047Even if this switch is enabled, not all function calls will be turned
6048into long calls. The heuristic is that static functions, functions
6049which have the @samp{short-call} attribute, functions that are inside
6050the scope of a @samp{#pragma no_long_calls} directive and functions whose
6051definitions have already been compiled within the current compilation
6052unit, will not be turned into long calls. The exception to this rule is
b192711e 6053that weak function definitions, functions with the @samp{long-call}
c27ba912
DM
6054attribute or the @samp{section} attribute, and functions that are within
6055the scope of a @samp{#pragma long_calls} directive, will always be
6056turned into long calls.
6057
6058This feature is not enabled by default. Specifying
630d3d5a 6059@option{-mno-long-calls} will restore the default behaviour, as will
c27ba912
DM
6060placing the function calls within the scope of a @samp{#pragma
6061long_calls_off} directive. Note these switches have no effect on how
6062the compiler generates code to handle function calls via function
02f52e19 6063pointers.
c27ba912 6064
62b10bbc 6065@item -mnop-fun-dllimport
cd3bb277 6066@opindex mnop-fun-dllimport
aee96fe9 6067Disable support for the @code{dllimport} attribute.
62b10bbc 6068
ed0e6530 6069@item -msingle-pic-base
cd3bb277 6070@opindex msingle-pic-base
ed0e6530
PB
6071Treat the register used for PIC addressing as read-only, rather than
6072loading it in the prologue for each function. The run-time system is
6073responsible for initialising this register with an appropriate value
6074before execution begins.
6075
cd3bb277
JM
6076@item -mpic-register=@var{reg}
6077@opindex mpic-register
ed0e6530
PB
6078Specify the register to be used for PIC addressing. The default is R10
6079unless stack-checking is enabled, when R9 is used.
6080
247f8561 6081@item -mpoke-function-name
cd3bb277 6082@opindex mpoke-function-name
247f8561
PB
6083Write the name of each function into the text section, directly
6084preceding the function prologue. The generated code is similar to this:
74291a4b 6085
247f8561
PB
6086@smallexample
6087 t0
6088 .ascii "arm_poke_function_name", 0
6089 .align
6090 t1
6091 .word 0xff000000 + (t1 - t0)
6092 arm_poke_function_name
6093 mov ip, sp
6094 stmfd sp!, @{fp, ip, lr, pc@}
6095 sub fp, ip, #4
6096@end smallexample
157a620e 6097
247f8561
PB
6098When performing a stack backtrace, code can inspect the value of
6099@code{pc} stored at @code{fp + 0}. If the trace function then looks at
6100location @code{pc - 12} and the top 8 bits are set, then we know that
6101there is a function name embedded immediately preceding this location
6102and has length @code{((pc[-3]) & 0xff000000)}.
157a620e 6103
247f8561 6104@item -mthumb
cd3bb277 6105@opindex mthumb
247f8561
PB
6106Generate code for the 16-bit Thumb instruction set. The default is to
6107use the 32-bit ARM instruction set.
157a620e
NC
6108
6109@item -mtpcs-frame
cd3bb277 6110@opindex mtpcs-frame
157a620e
NC
6111Generate a stack frame that is compliant with the Thumb Procedure Call
6112Standard for all non-leaf functions. (A leaf function is one that does
630d3d5a 6113not call any other functions.) The default is @option{-mno-tpcs-frame}.
157a620e
NC
6114
6115@item -mtpcs-leaf-frame
cd3bb277 6116@opindex mtpcs-leaf-frame
157a620e
NC
6117Generate a stack frame that is compliant with the Thumb Procedure Call
6118Standard for all leaf functions. (A leaf function is one that does
630d3d5a 6119not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
62b10bbc
NC
6120
6121@item -mcallee-super-interworking
cd3bb277 6122@opindex mcallee-super-interworking
62b10bbc
NC
6123Gives all externally visible functions in the file being compiled an ARM
6124instruction set header which switches to Thumb mode before executing the
6125rest of the function. This allows these functions to be called from
6126non-interworking code.
6127
6128@item -mcaller-super-interworking
cd3bb277 6129@opindex mcaller-super-interworking
62b10bbc
NC
6130Allows calls via function pointers (including virtual functions) to
6131execute correctly regardless of whether the target code has been
6132compiled for interworking or not. There is a small overhead in the cost
4bdc1ac7
PB
6133of executing a function pointer if this option is enabled.
6134
157a620e
NC
6135@end table
6136
ecff22ab
JL
6137@node MN10200 Options
6138@subsection MN10200 Options
6139@cindex MN10200 options
630d3d5a 6140These @option{-m} options are defined for Matsushita MN10200 architectures:
2642624b 6141@table @gcctabopt
ecff22ab
JL
6142
6143@item -mrelax
cd3bb277 6144@opindex mrelax
ecff22ab
JL
6145Indicate to the linker that it should perform a relaxation optimization pass
6146to shorten branches, calls and absolute memory addresses. This option only
6147has an effect when used on the command line for the final link step.
6148
02f52e19 6149This option makes symbolic debugging impossible.
ecff22ab 6150@end table
157a620e 6151
6d6d0fa0
JL
6152@node MN10300 Options
6153@subsection MN10300 Options
6154@cindex MN10300 options
630d3d5a 6155These @option{-m} options are defined for Matsushita MN10300 architectures:
6d6d0fa0 6156
2642624b 6157@table @gcctabopt
6d6d0fa0 6158@item -mmult-bug
cd3bb277 6159@opindex mmult-bug
6d6d0fa0
JL
6160Generate code to avoid bugs in the multiply instructions for the MN10300
6161processors. This is the default.
6162
6163@item -mno-mult-bug
cd3bb277 6164@opindex mno-mult-bug
6d6d0fa0
JL
6165Do not generate code to avoid bugs in the multiply instructions for the
6166MN10300 processors.
ecff22ab 6167
705ac34f 6168@item -mam33
cd3bb277 6169@opindex mam33
705ac34f
JL
6170Generate code which uses features specific to the AM33 processor.
6171
6172@item -mno-am33
cd3bb277 6173@opindex mno-am33
705ac34f
JL
6174Do not generate code which uses features specific to the AM33 processor. This
6175is the default.
6176
c474f76b
AO
6177@item -mno-crt0
6178@opindex mno-crt0
6179Do not link in the C run-time initialization object file.
6180
ecff22ab 6181@item -mrelax
cd3bb277 6182@opindex mrelax
ecff22ab
JL
6183Indicate to the linker that it should perform a relaxation optimization pass
6184to shorten branches, calls and absolute memory addresses. This option only
6185has an effect when used on the command line for the final link step.
6186
02f52e19 6187This option makes symbolic debugging impossible.
6d6d0fa0
JL
6188@end table
6189
ecff22ab 6190
861bb6c1
JL
6191@node M32R/D Options
6192@subsection M32R/D Options
6193@cindex M32R/D options
6194
630d3d5a 6195These @option{-m} options are defined for Mitsubishi M32R/D architectures:
861bb6c1 6196
2642624b 6197@table @gcctabopt
861bb6c1 6198@item -mcode-model=small
cd3bb277 6199@opindex mcode-model=small
861bb6c1
JL
6200Assume all objects live in the lower 16MB of memory (so that their addresses
6201can be loaded with the @code{ld24} instruction), and assume all subroutines
6202are reachable with the @code{bl} instruction.
6203This is the default.
6204
6205The addressability of a particular object can be set with the
6206@code{model} attribute.
6207
6208@item -mcode-model=medium
cd3bb277 6209@opindex mcode-model=medium
02f52e19 6210Assume objects may be anywhere in the 32-bit address space (the compiler
861bb6c1
JL
6211will generate @code{seth/add3} instructions to load their addresses), and
6212assume all subroutines are reachable with the @code{bl} instruction.
6213
6214@item -mcode-model=large
cd3bb277 6215@opindex mcode-model=large
02f52e19 6216Assume objects may be anywhere in the 32-bit address space (the compiler
861bb6c1
JL
6217will generate @code{seth/add3} instructions to load their addresses), and
6218assume subroutines may not be reachable with the @code{bl} instruction
6219(the compiler will generate the much slower @code{seth/add3/jl}
6220instruction sequence).
6221
6222@item -msdata=none
cd3bb277 6223@opindex msdata=none
861bb6c1
JL
6224Disable use of the small data area. Variables will be put into
6225one of @samp{.data}, @samp{bss}, or @samp{.rodata} (unless the
6226@code{section} attribute has been specified).
6227This is the default.
6228
6229The small data area consists of sections @samp{.sdata} and @samp{.sbss}.
6230Objects may be explicitly put in the small data area with the
6231@code{section} attribute using one of these sections.
6232
6233@item -msdata=sdata
cd3bb277 6234@opindex msdata=sdata
861bb6c1
JL
6235Put small global and static data in the small data area, but do not
6236generate special code to reference them.
6237
6238@item -msdata=use
cd3bb277 6239@opindex msdata=use
861bb6c1
JL
6240Put small global and static data in the small data area, and generate
6241special instructions to reference them.
6242
6243@item -G @var{num}
cd3bb277 6244@opindex G
861bb6c1
JL
6245@cindex smaller data references
6246Put global and static objects less than or equal to @var{num} bytes
6247into the small data or bss sections instead of the normal data or bss
6248sections. The default value of @var{num} is 8.
630d3d5a 6249The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
861bb6c1
JL
6250for this option to have any effect.
6251
630d3d5a 6252All modules should be compiled with the same @option{-G @var{num}} value.
861bb6c1 6253Compiling with different values of @var{num} may or may not work; if it
695ac33f 6254doesn't the linker will give an error message---incorrect code will not be
861bb6c1
JL
6255generated.
6256
6257@end table
6258
74291a4b
MM
6259@node M88K Options
6260@subsection M88K Options
6261@cindex M88k options
6262
6263These @samp{-m} options are defined for Motorola 88k architectures:
6264
2642624b 6265@table @gcctabopt
74291a4b 6266@item -m88000
cd3bb277 6267@opindex m88000
74291a4b
MM
6268Generate code that works well on both the m88100 and the
6269m88110.
6270
6271@item -m88100
cd3bb277 6272@opindex m88100
74291a4b
MM
6273Generate code that works best for the m88100, but that also
6274runs on the m88110.
6275
6276@item -m88110
cd3bb277 6277@opindex m88110
74291a4b
MM
6278Generate code that works best for the m88110, and may not run
6279on the m88100.
6280
6281@item -mbig-pic
cd3bb277 6282@opindex mbig-pic
74291a4b 6283Obsolete option to be removed from the next revision.
630d3d5a 6284Use @option{-fPIC}.
74291a4b
MM
6285
6286@item -midentify-revision
cd3bb277 6287@opindex midentify-revision
74291a4b
MM
6288@cindex identifying source, compiler (88k)
6289Include an @code{ident} directive in the assembler output recording the
6290source file name, compiler name and version, timestamp, and compilation
6291flags used.
6292
6293@item -mno-underscores
cd3bb277 6294@opindex mno-underscores
74291a4b
MM
6295@cindex underscores, avoiding (88k)
6296In assembler output, emit symbol names without adding an underscore
6297character at the beginning of each name. The default is to use an
6298underscore as prefix on each name.
6299
6300@item -mocs-debug-info
6301@itemx -mno-ocs-debug-info
cd3bb277
JM
6302@opindex mocs-debug-info
6303@opindex mno-ocs-debug-info
74291a4b
MM
6304@cindex OCS (88k)
6305@cindex debugging, 88k OCS
6306Include (or omit) additional debugging information (about registers used
6307in each stack frame) as specified in the 88open Object Compatibility
161d7b59 6308Standard, ``OCS''@. This extra information allows debugging of code that
74291a4b
MM
6309has had the frame pointer eliminated. The default for DG/UX, SVr4, and
6310Delta 88 SVr3.2 is to include this information; other 88k configurations
6311omit this information by default.
6312
6313@item -mocs-frame-position
cd3bb277 6314@opindex mocs-frame-position
74291a4b
MM
6315@cindex register positions in frame (88k)
6316When emitting COFF debugging information for automatic variables and
6317parameters stored on the stack, use the offset from the canonical frame
6318address, which is the stack pointer (register 31) on entry to the
6319function. The DG/UX, SVr4, Delta88 SVr3.2, and BCS configurations use
630d3d5a
JM
6320@option{-mocs-frame-position}; other 88k configurations have the default
6321@option{-mno-ocs-frame-position}.
74291a4b
MM
6322
6323@item -mno-ocs-frame-position
cd3bb277 6324@opindex mno-ocs-frame-position
74291a4b
MM
6325@cindex register positions in frame (88k)
6326When emitting COFF debugging information for automatic variables and
6327parameters stored on the stack, use the offset from the frame pointer
6328register (register 30). When this option is in effect, the frame
6329pointer is not eliminated when debugging information is selected by the
6330-g switch.
6331
6332@item -moptimize-arg-area
cd3bb277 6333@opindex moptimize-arg-area
74291a4b 6334@cindex arguments in frame (88k)
9c34dbbf
ZW
6335Save space by reorganizing the stack frame. This option generates code
6336that does not agree with the 88open specifications, but uses less
6337memory.
6338
6339@itemx -mno-optimize-arg-area
6340@opindex mno-optimize-arg-area
6341Do not reorganize the stack frame to save space. This is the default.
6342The generated conforms to the specification, but uses more memory.
74291a4b
MM
6343
6344@item -mshort-data-@var{num}
cd3bb277 6345@opindex mshort-data
74291a4b
MM
6346@cindex smaller data references (88k)
6347@cindex r0-relative references (88k)
6348Generate smaller data references by making them relative to @code{r0},
6349which allows loading a value using a single instruction (rather than the
6350usual two). You control which data references are affected by
6351specifying @var{num} with this option. For example, if you specify
630d3d5a 6352@option{-mshort-data-512}, then the data references affected are those
74291a4b 6353involving displacements of less than 512 bytes.
630d3d5a 6354@option{-mshort-data-@var{num}} is not effective for @var{num} greater
74291a4b
MM
6355than 64k.
6356
6357@item -mserialize-volatile
cd3bb277 6358@opindex mserialize-volatile
74291a4b 6359@itemx -mno-serialize-volatile
cd3bb277 6360@opindex mno-serialize-volatile
74291a4b
MM
6361@cindex sequential consistency on 88k
6362Do, or don't, generate code to guarantee sequential consistency
6363of volatile memory references. By default, consistency is
6364guaranteed.
6365
6366The order of memory references made by the MC88110 processor does
6367not always match the order of the instructions requesting those
6368references. In particular, a load instruction may execute before
6369a preceding store instruction. Such reordering violates
6370sequential consistency of volatile memory references, when there
6371are multiple processors. When consistency must be guaranteed,
f0523f02 6372GCC generates special instructions, as needed, to force
74291a4b
MM
6373execution in the proper order.
6374
6375The MC88100 processor does not reorder memory references and so
f0523f02
JM
6376always provides sequential consistency. However, by default, GCC
6377generates the special instructions to guarantee consistency
630d3d5a 6378even when you use @option{-m88100}, so that the code may be run on an
74291a4b 6379MC88110 processor. If you intend to run your code only on the
630d3d5a 6380MC88100 processor, you may use @option{-mno-serialize-volatile}.
74291a4b
MM
6381
6382The extra code generated to guarantee consistency may affect the
6383performance of your application. If you know that you can safely
630d3d5a 6384forgo this guarantee, you may use @option{-mno-serialize-volatile}.
74291a4b
MM
6385
6386@item -msvr4
6387@itemx -msvr3
cd3bb277
JM
6388@opindex msvr4
6389@opindex msvr3
74291a4b
MM
6390@cindex assembler syntax, 88k
6391@cindex SVr4
630d3d5a 6392Turn on (@option{-msvr4}) or off (@option{-msvr3}) compiler extensions
74291a4b
MM
6393related to System V release 4 (SVr4). This controls the following:
6394
6395@enumerate
6396@item
6397Which variant of the assembler syntax to emit.
6398@item
630d3d5a 6399@option{-msvr4} makes the C preprocessor recognize @samp{#pragma weak}
74291a4b
MM
6400that is used on System V release 4.
6401@item
630d3d5a 6402@option{-msvr4} makes GCC issue additional declaration directives used in
74291a4b
MM
6403SVr4.
6404@end enumerate
6405
630d3d5a 6406@option{-msvr4} is the default for the m88k-motorola-sysv4 and
767094dd 6407m88k-dg-dgux m88k configurations. @option{-msvr3} is the default for all
74291a4b
MM
6408other m88k configurations.
6409
6410@item -mversion-03.00
cd3bb277 6411@opindex mversion-03.00
74291a4b
MM
6412This option is obsolete, and is ignored.
6413@c ??? which asm syntax better for GAS? option there too?
6414
6415@item -mno-check-zero-division
6416@itemx -mcheck-zero-division
cd3bb277
JM
6417@opindex mno-check-zero-division
6418@opindex mcheck-zero-division
74291a4b
MM
6419@cindex zero division on 88k
6420Do, or don't, generate code to guarantee that integer division by
6421zero will be detected. By default, detection is guaranteed.
6422
6423Some models of the MC88100 processor fail to trap upon integer
6424division by zero under certain conditions. By default, when
f0523f02 6425compiling code that might be run on such a processor, GCC
74291a4b
MM
6426generates code that explicitly checks for zero-valued divisors
6427and traps with exception number 503 when one is detected. Use of
9c34dbbf 6428@option{-mno-check-zero-division} suppresses such checking for code
74291a4b
MM
6429generated to run on an MC88100 processor.
6430
9c34dbbf
ZW
6431GCC assumes that the MC88110 processor correctly detects all instances
6432of integer division by zero. When @option{-m88110} is specified, no
6433explicit checks for zero-valued divisors are generated, and both
6434@option{-mcheck-zero-division} and @option{-mno-check-zero-division} are
6435ignored.
74291a4b
MM
6436
6437@item -muse-div-instruction
cd3bb277 6438@opindex muse-div-instruction
74291a4b
MM
6439@cindex divide instruction, 88k
6440Use the div instruction for signed integer division on the
6441MC88100 processor. By default, the div instruction is not used.
6442
6443On the MC88100 processor the signed integer division instruction
6444div) traps to the operating system on a negative operand. The
6445operating system transparently completes the operation, but at a
6446large cost in execution time. By default, when compiling code
f0523f02 6447that might be run on an MC88100 processor, GCC emulates signed
74291a4b
MM
6448integer division using the unsigned integer division instruction
6449divu), thereby avoiding the large penalty of a trap to the
6450operating system. Such emulation has its own, smaller, execution
6451cost in both time and space. To the extent that your code's
6452important signed integer division operations are performed on two
6453nonnegative operands, it may be desirable to use the div
6454instruction directly.
6455
6456On the MC88110 processor the div instruction (also known as the
6457divs instruction) processes negative operands without trapping to
630d3d5a
JM
6458the operating system. When @option{-m88110} is specified,
6459@option{-muse-div-instruction} is ignored, and the div instruction is used
74291a4b
MM
6460for signed integer division.
6461
630d3d5a 6462Note that the result of dividing @code{INT_MIN} by @minus{}1 is undefined. In
74291a4b 6463particular, the behavior of such a division with and without
630d3d5a 6464@option{-muse-div-instruction} may differ.
74291a4b
MM
6465
6466@item -mtrap-large-shift
6467@itemx -mhandle-large-shift
cd3bb277
JM
6468@opindex mtrap-large-shift
6469@opindex mhandle-large-shift
74291a4b
MM
6470@cindex bit shift overflow (88k)
6471@cindex large bit shifts (88k)
6472Include code to detect bit-shifts of more than 31 bits; respectively,
0c2d1a2a 6473trap such shifts or emit code to handle them properly. By default GCC
74291a4b
MM
6474makes no special provision for large bit shifts.
6475
6476@item -mwarn-passed-structs
cd3bb277 6477@opindex mwarn-passed-structs
74291a4b
MM
6478@cindex structure passing (88k)
6479Warn when a function passes a struct as an argument or result.
6480Structure-passing conventions have changed during the evolution of the C
6481language, and are often the source of portability problems. By default,
0c2d1a2a 6482GCC issues no such warning.
74291a4b
MM
6483@end table
6484
9c34dbbf
ZW
6485@c break page here to avoid unsightly interparagraph stretch.
6486@c -zw, 2001-8-17
6487@page
6488
74291a4b
MM
6489@node RS/6000 and PowerPC Options
6490@subsection IBM RS/6000 and PowerPC Options
6491@cindex RS/6000 and PowerPC Options
6492@cindex IBM RS/6000 and PowerPC Options
6493
6494These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
2642624b 6495@table @gcctabopt
74291a4b
MM
6496@item -mpower
6497@itemx -mno-power
6498@itemx -mpower2
6499@itemx -mno-power2
6500@itemx -mpowerpc
6501@itemx -mno-powerpc
6502@itemx -mpowerpc-gpopt
6503@itemx -mno-powerpc-gpopt
6504@itemx -mpowerpc-gfxopt
6505@itemx -mno-powerpc-gfxopt
7fe90e7b
DE
6506@itemx -mpowerpc64
6507@itemx -mno-powerpc64
cd3bb277
JM
6508@opindex mpower
6509@opindex mno-power
6510@opindex mpower2
6511@opindex mno-power2
6512@opindex mpowerpc
6513@opindex mno-powerpc
6514@opindex mpowerpc-gpopt
6515@opindex mno-powerpc-gpopt
6516@opindex mpowerpc-gfxopt
6517@opindex mno-powerpc-gfxopt
6518@opindex mpowerpc64
6519@opindex mno-powerpc64
0c2d1a2a 6520GCC supports two related instruction set architectures for the
161d7b59 6521RS/6000 and PowerPC@. The @dfn{POWER} instruction set are those
74291a4b
MM
6522instructions supported by the @samp{rios} chip set used in the original
6523RS/6000 systems and the @dfn{PowerPC} instruction set is the
6524architecture of the Motorola MPC5xx, MPC6xx, MPC8xx microprocessors, and
861bb6c1 6525the IBM 4xx microprocessors.
74291a4b
MM
6526
6527Neither architecture is a subset of the other. However there is a
6528large common subset of instructions supported by both. An MQ
6529register is included in processors supporting the POWER architecture.
6530
6531You use these options to specify which instructions are available on the
6532processor you are using. The default value of these options is
161d7b59 6533determined when configuring GCC@. Specifying the
630d3d5a
JM
6534@option{-mcpu=@var{cpu_type}} overrides the specification of these
6535options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
74291a4b
MM
6536rather than the options listed above.
6537
630d3d5a 6538The @option{-mpower} option allows GCC to generate instructions that
74291a4b 6539are found only in the POWER architecture and to use the MQ register.
630d3d5a 6540Specifying @option{-mpower2} implies @option{-power} and also allows GCC
74291a4b
MM
6541to generate instructions that are present in the POWER2 architecture but
6542not the original POWER architecture.
6543
630d3d5a 6544The @option{-mpowerpc} option allows GCC to generate instructions that
74291a4b 6545are found only in the 32-bit subset of the PowerPC architecture.
630d3d5a 6546Specifying @option{-mpowerpc-gpopt} implies @option{-mpowerpc} and also allows
0c2d1a2a 6547GCC to use the optional PowerPC architecture instructions in the
74291a4b 6548General Purpose group, including floating-point square root. Specifying
630d3d5a 6549@option{-mpowerpc-gfxopt} implies @option{-mpowerpc} and also allows GCC to
74291a4b
MM
6550use the optional PowerPC architecture instructions in the Graphics
6551group, including floating-point select.
6552
630d3d5a 6553The @option{-mpowerpc64} option allows GCC to generate the additional
7fe90e7b 655464-bit instructions that are found in the full PowerPC64 architecture
0c2d1a2a 6555and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
630d3d5a 6556@option{-mno-powerpc64}.
7fe90e7b 6557
630d3d5a 6558If you specify both @option{-mno-power} and @option{-mno-powerpc}, GCC
74291a4b
MM
6559will use only the instructions in the common subset of both
6560architectures plus some special AIX common-mode calls, and will not use
630d3d5a 6561the MQ register. Specifying both @option{-mpower} and @option{-mpowerpc}
0c2d1a2a 6562permits GCC to use any instruction from either architecture and to
74291a4b
MM
6563allow use of the MQ register; specify this for the Motorola MPC601.
6564
6565@item -mnew-mnemonics
6566@itemx -mold-mnemonics
cd3bb277
JM
6567@opindex mnew-mnemonics
6568@opindex mold-mnemonics
9c34dbbf
ZW
6569Select which mnemonics to use in the generated assembler code. With
6570@option{-mnew-mnemonics}, GCC uses the assembler mnemonics defined for
6571the PowerPC architecture. With @option{-mold-mnemonics} it uses the
6572assembler mnemonics defined for the POWER architecture. Instructions
6573defined in only one architecture have only one mnemonic; GCC uses that
6574mnemonic irrespective of which of these options is specified.
74291a4b 6575
0c2d1a2a 6576GCC defaults to the mnemonics appropriate for the architecture in
630d3d5a 6577use. Specifying @option{-mcpu=@var{cpu_type}} sometimes overrides the
7fe90e7b 6578value of these option. Unless you are building a cross-compiler, you
630d3d5a
JM
6579should normally not specify either @option{-mnew-mnemonics} or
6580@option{-mold-mnemonics}, but should instead accept the default.
74291a4b
MM
6581
6582@item -mcpu=@var{cpu_type}
cd3bb277 6583@opindex mcpu
74291a4b
MM
6584Set architecture type, register usage, choice of mnemonics, and
6585instruction scheduling parameters for machine type @var{cpu_type}.
5f59ecb7
DE
6586Supported values for @var{cpu_type} are @samp{rios}, @samp{rios1},
6587@samp{rsc}, @samp{rios2}, @samp{rs64a}, @samp{601}, @samp{602},
6588@samp{603}, @samp{603e}, @samp{604}, @samp{604e}, @samp{620},
6589@samp{630}, @samp{740}, @samp{750}, @samp{power}, @samp{power2},
6590@samp{powerpc}, @samp{403}, @samp{505}, @samp{801}, @samp{821},
9c34dbbf
ZW
6591@samp{823}, and @samp{860} and @samp{common}.
6592
6593@option{-mcpu=common} selects a completely generic processor. Code
6594generated under this option will run on any POWER or PowerPC processor.
6595GCC will use only the instructions in the common subset of both
6596architectures, and will not use the MQ register. GCC assumes a generic
74291a4b
MM
6597processor model for scheduling purposes.
6598
9c34dbbf
ZW
6599@option{-mcpu=power}, @option{-mcpu=power2}, @option{-mcpu=powerpc}, and
6600@option{-mcpu=powerpc64} specify generic POWER, POWER2, pure 32-bit
6601PowerPC (i.e., not MPC601), and 64-bit PowerPC architecture machine
6602types, with an appropriate, generic processor model assumed for
6603scheduling purposes.
74291a4b 6604
9c34dbbf
ZW
6605The other options specify a specific processor. Code generated under
6606those options will run best on that processor, and may not run at all on
6607others.
6608
6609The @option{-mcpu} options automatically enable or disable other
6610@option{-m} options as follows:
6611
6612@table @samp
6613@item common
6614@option{-mno-power}, @option{-mno-powerc}
6615
6616@item power
6617@itemx power2
6618@itemx rios1
6619@itemx rios2
6620@itemx rsc
6621@option{-mpower}, @option{-mno-powerpc}, @option{-mno-new-mnemonics}
6622
6623@item powerpc
6624@itemx rs64a
6625@itemx 602
6626@itemx 603
6627@itemx 603e
6628@itemx 604
6629@itemx 620
6630@itemx 630
6631@itemx 740
6632@itemx 750
6633@itemx 505
6634@option{-mno-power}, @option{-mpowerpc}, @option{-mnew-mnemonics}
6635
6636@item 601
6637@option{-mpower}, @option{-mpowerpc}, @option{-mnew-mnemonics}
6638
6639@item 403
6640@itemx 821
6641@itemx 860
6642@option{-mno-power}, @option{-mpowerpc}, @option{-mnew-mnemonics}, @option{-msoft-float}
6643@end table
74291a4b
MM
6644
6645@item -mtune=@var{cpu_type}
cd3bb277 6646@opindex mtune
74291a4b 6647Set the instruction scheduling parameters for machine type
9c34dbbf
ZW
6648@var{cpu_type}, but do not set the architecture type, register usage, or
6649choice of mnemonics, as @option{-mcpu=@var{cpu_type}} would. The same
6650values for @var{cpu_type} are used for @option{-mtune} as for
6651@option{-mcpu}. If both are specified, the code generated will use the
6652architecture, registers, and mnemonics set by @option{-mcpu}, but the
6653scheduling parameters set by @option{-mtune}.
74291a4b
MM
6654
6655@item -mfull-toc
6656@itemx -mno-fp-in-toc
6657@itemx -mno-sum-in-toc
6658@itemx -mminimal-toc
cd3bb277
JM
6659@opindex mfull-toc
6660@opindex mno-fp-in-toc
6661@opindex mno-sum-in-toc
6662@opindex mminimal-toc
74291a4b 6663Modify generation of the TOC (Table Of Contents), which is created for
630d3d5a 6664every executable file. The @option{-mfull-toc} option is selected by
0c2d1a2a
JB
6665default. In that case, GCC will allocate at least one TOC entry for
6666each unique non-automatic variable reference in your program. GCC
161d7b59
JM
6667will also place floating-point constants in the TOC@. However, only
666816,384 entries are available in the TOC@.
74291a4b
MM
6669
6670If you receive a linker error message that saying you have overflowed
6671the available TOC space, you can reduce the amount of TOC space used
630d3d5a
JM
6672with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
6673@option{-mno-fp-in-toc} prevents GCC from putting floating-point
6674constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
74291a4b 6675generate code to calculate the sum of an address and a constant at
161d7b59 6676run-time instead of putting that sum into the TOC@. You may specify one
0c2d1a2a 6677or both of these options. Each causes GCC to produce very slightly
74291a4b
MM
6678slower and larger code at the expense of conserving TOC space.
6679
6680If you still run out of space in the TOC even when you specify both of
630d3d5a 6681these options, specify @option{-mminimal-toc} instead. This option causes
0c2d1a2a
JB
6682GCC to make only one TOC entry for every file. When you specify this
6683option, GCC will produce code that is slower and larger but which
74291a4b 6684uses extremely little TOC space. You may wish to use this option
bd819a4a 6685only on files that contain less frequently executed code.
74291a4b 6686
fa06229f
GK
6687@item -maix64
6688@itemx -maix32
cd3bb277
JM
6689@opindex maix64
6690@opindex maix32
fa06229f 6691Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
7fe90e7b 6692@code{long} type, and the infrastructure needed to support them.
630d3d5a
JM
6693Specifying @option{-maix64} implies @option{-mpowerpc64} and
6694@option{-mpowerpc}, while @option{-maix32} disables the 64-bit ABI and
6695implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
7fe90e7b 6696
74291a4b
MM
6697@item -mxl-call
6698@itemx -mno-xl-call
cd3bb277
JM
6699@opindex mxl-call
6700@opindex mno-xl-call
74291a4b
MM
6701On AIX, pass floating-point arguments to prototyped functions beyond the
6702register save area (RSA) on the stack in addition to argument FPRs. The
6703AIX calling convention was extended but not initially documented to
6704handle an obscure K&R C case of calling a function that takes the
6705address of its arguments with fewer arguments than declared. AIX XL
7fe90e7b
DE
6706compilers access floating point arguments which do not fit in the
6707RSA from the stack when a subroutine is compiled without
74291a4b
MM
6708optimization. Because always storing floating-point arguments on the
6709stack is inefficient and rarely needed, this option is not enabled by
6710default and only is necessary when calling subroutines compiled by AIX
6711XL compilers without optimization.
6712
861bb6c1 6713@item -mthreads
cd3bb277 6714@opindex mthreads
861bb6c1
JL
6715Support @dfn{AIX Threads}. Link an application written to use
6716@dfn{pthreads} with special libraries and startup code to enable the
6717application to run.
6718
6719@item -mpe
cd3bb277 6720@opindex mpe
161d7b59 6721Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
861bb6c1
JL
6722application written to use message passing with special startup code to
6723enable the application to run. The system must have PE installed in the
6724standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
630d3d5a 6725must be overridden with the @option{-specs=} option to specify the
861bb6c1 6726appropriate directory location. The Parallel Environment does not
630d3d5a 6727support threads, so the @option{-mpe} option and the @option{-mthreads}
861bb6c1
JL
6728option are incompatible.
6729
74291a4b
MM
6730@item -msoft-float
6731@itemx -mhard-float
cd3bb277
JM
6732@opindex msoft-float
6733@opindex mhard-float
74291a4b
MM
6734Generate code that does not use (uses) the floating-point register set.
6735Software floating point emulation is provided if you use the
630d3d5a 6736@option{-msoft-float} option, and pass the option to GCC when linking.
74291a4b
MM
6737
6738@item -mmultiple
6739@itemx -mno-multiple
cd3bb277
JM
6740@opindex mmultiple
6741@opindex mno-multiple
74291a4b
MM
6742Generate code that uses (does not use) the load multiple word
6743instructions and the store multiple word instructions. These
6744instructions are generated by default on POWER systems, and not
630d3d5a 6745generated on PowerPC systems. Do not use @option{-mmultiple} on little
74291a4b 6746endian PowerPC systems, since those instructions do not work when the
bef84347
VM
6747processor is in little endian mode. The exceptions are PPC740 and
6748PPC750 which permit the instructions usage in little endian mode.
74291a4b
MM
6749
6750@item -mstring
6751@itemx -mno-string
cd3bb277
JM
6752@opindex mstring
6753@opindex mno-string
bef84347
VM
6754Generate code that uses (does not use) the load string instructions
6755and the store string word instructions to save multiple registers and
6756do small block moves. These instructions are generated by default on
6757POWER systems, and not generated on PowerPC systems. Do not use
630d3d5a 6758@option{-mstring} on little endian PowerPC systems, since those
bef84347
VM
6759instructions do not work when the processor is in little endian mode.
6760The exceptions are PPC740 and PPC750 which permit the instructions
6761usage in little endian mode.
74291a4b 6762
861bb6c1
JL
6763@item -mupdate
6764@itemx -mno-update
cd3bb277
JM
6765@opindex mupdate
6766@opindex mno-update
861bb6c1
JL
6767Generate code that uses (does not use) the load or store instructions
6768that update the base register to the address of the calculated memory
6769location. These instructions are generated by default. If you use
630d3d5a 6770@option{-mno-update}, there is a small window between the time that the
861bb6c1
JL
6771stack pointer is updated and the address of the previous frame is
6772stored, which means code that walks the stack frame across interrupts or
6773signals may get corrupted data.
6774
6775@item -mfused-madd
6776@itemx -mno-fused-madd
cd3bb277
JM
6777@opindex mfused-madd
6778@opindex mno-fused-madd
861bb6c1
JL
6779Generate code that uses (does not use) the floating point multiply and
6780accumulate instructions. These instructions are generated by default if
6781hardware floating is used.
6782
74291a4b
MM
6783@item -mno-bit-align
6784@itemx -mbit-align
cd3bb277
JM
6785@opindex mno-bit-align
6786@opindex mbit-align
74291a4b 6787On System V.4 and embedded PowerPC systems do not (do) force structures
c771326b
JM
6788and unions that contain bit-fields to be aligned to the base type of the
6789bit-field.
74291a4b
MM
6790
6791For example, by default a structure containing nothing but 8
c771326b 6792@code{unsigned} bit-fields of length 1 would be aligned to a 4 byte
630d3d5a 6793boundary and have a size of 4 bytes. By using @option{-mno-bit-align},
74291a4b
MM
6794the structure would be aligned to a 1 byte boundary and be one byte in
6795size.
6796
6797@item -mno-strict-align
6798@itemx -mstrict-align
cd3bb277
JM
6799@opindex mno-strict-align
6800@opindex mstrict-align
74291a4b
MM
6801On System V.4 and embedded PowerPC systems do not (do) assume that
6802unaligned memory references will be handled by the system.
6803
6804@item -mrelocatable
6805@itemx -mno-relocatable
cd3bb277
JM
6806@opindex mrelocatable
6807@opindex mno-relocatable
74291a4b
MM
6808On embedded PowerPC systems generate code that allows (does not allow)
6809the program to be relocated to a different address at runtime. If you
630d3d5a
JM
6810use @option{-mrelocatable} on any module, all objects linked together must
6811be compiled with @option{-mrelocatable} or @option{-mrelocatable-lib}.
74291a4b
MM
6812
6813@item -mrelocatable-lib
6814@itemx -mno-relocatable-lib
cd3bb277
JM
6815@opindex mrelocatable-lib
6816@opindex mno-relocatable-lib
74291a4b
MM
6817On embedded PowerPC systems generate code that allows (does not allow)
6818the program to be relocated to a different address at runtime. Modules
630d3d5a
JM
6819compiled with @option{-mrelocatable-lib} can be linked with either modules
6820compiled without @option{-mrelocatable} and @option{-mrelocatable-lib} or
6821with modules compiled with the @option{-mrelocatable} options.
74291a4b
MM
6822
6823@item -mno-toc
6824@itemx -mtoc
cd3bb277
JM
6825@opindex mno-toc
6826@opindex mtoc
74291a4b
MM
6827On System V.4 and embedded PowerPC systems do not (do) assume that
6828register 2 contains a pointer to a global area pointing to the addresses
6829used in the program.
6830
74291a4b
MM
6831@item -mlittle
6832@itemx -mlittle-endian
cd3bb277
JM
6833@opindex mlittle
6834@opindex mlittle-endian
74291a4b 6835On System V.4 and embedded PowerPC systems compile code for the
630d3d5a
JM
6836processor in little endian mode. The @option{-mlittle-endian} option is
6837the same as @option{-mlittle}.
74291a4b
MM
6838
6839@item -mbig
6840@itemx -mbig-endian
cd3bb277
JM
6841@opindex mbig
6842@opindex mbig-endian
74291a4b 6843On System V.4 and embedded PowerPC systems compile code for the
630d3d5a
JM
6844processor in big endian mode. The @option{-mbig-endian} option is
6845the same as @option{-mbig}.
74291a4b
MM
6846
6847@item -mcall-sysv
cd3bb277 6848@opindex mcall-sysv
74291a4b
MM
6849On System V.4 and embedded PowerPC systems compile code using calling
6850conventions that adheres to the March 1995 draft of the System V
6851Application Binary Interface, PowerPC processor supplement. This is the
6852default unless you configured GCC using @samp{powerpc-*-eabiaix}.
6853
6854@item -mcall-sysv-eabi
cd3bb277 6855@opindex mcall-sysv-eabi
630d3d5a 6856Specify both @option{-mcall-sysv} and @option{-meabi} options.
74291a4b
MM
6857
6858@item -mcall-sysv-noeabi
cd3bb277 6859@opindex mcall-sysv-noeabi
630d3d5a 6860Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
74291a4b
MM
6861
6862@item -mcall-aix
cd3bb277 6863@opindex mcall-aix
74291a4b 6864On System V.4 and embedded PowerPC systems compile code using calling
161d7b59 6865conventions that are similar to those used on AIX@. This is the
74291a4b
MM
6866default if you configured GCC using @samp{powerpc-*-eabiaix}.
6867
6868@item -mcall-solaris
cd3bb277 6869@opindex mcall-solaris
74291a4b
MM
6870On System V.4 and embedded PowerPC systems compile code for the Solaris
6871operating system.
6872
6873@item -mcall-linux
cd3bb277 6874@opindex mcall-linux
861bb6c1
JL
6875On System V.4 and embedded PowerPC systems compile code for the
6876Linux-based GNU system.
74291a4b 6877
edf1b3f3
AC
6878@item -mcall-netbsd
6879@opindex mcall-netbsd
6880On System V.4 and embedded PowerPC systems compile code for the
6881NetBSD operating system.
6882
74291a4b 6883@item -mprototype
e9a25f70 6884@itemx -mno-prototype
cd3bb277
JM
6885@opindex mprototype
6886@opindex mno-prototype
74291a4b
MM
6887On System V.4 and embedded PowerPC systems assume that all calls to
6888variable argument functions are properly prototyped. Otherwise, the
6889compiler must insert an instruction before every non prototyped call to
6890set or clear bit 6 of the condition code register (@var{CR}) to
6891indicate whether floating point values were passed in the floating point
6892registers in case the function takes a variable arguments. With
630d3d5a 6893@option{-mprototype}, only calls to prototyped variable argument functions
74291a4b
MM
6894will set or clear the bit.
6895
6896@item -msim
cd3bb277 6897@opindex msim
74291a4b
MM
6898On embedded PowerPC systems, assume that the startup module is called
6899@file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
6900@file{libc.a}. This is the default for @samp{powerpc-*-eabisim}.
6901configurations.
6902
6903@item -mmvme
cd3bb277 6904@opindex mmvme
74291a4b 6905On embedded PowerPC systems, assume that the startup module is called
e9a25f70
JL
6906@file{crt0.o} and the standard C libraries are @file{libmvme.a} and
6907@file{libc.a}.
6908
6909@item -mads
cd3bb277 6910@opindex mads
e9a25f70
JL
6911On embedded PowerPC systems, assume that the startup module is called
6912@file{crt0.o} and the standard C libraries are @file{libads.a} and
6913@file{libc.a}.
6914
6915@item -myellowknife
cd3bb277 6916@opindex myellowknife
e9a25f70
JL
6917On embedded PowerPC systems, assume that the startup module is called
6918@file{crt0.o} and the standard C libraries are @file{libyk.a} and
74291a4b
MM
6919@file{libc.a}.
6920
bff46771 6921@item -mvxworks
cd3bb277 6922@opindex mvxworks
bff46771
GK
6923On System V.4 and embedded PowerPC systems, specify that you are
6924compiling for a VxWorks system.
6925
74291a4b 6926@item -memb
cd3bb277 6927@opindex memb
74291a4b
MM
6928On embedded PowerPC systems, set the @var{PPC_EMB} bit in the ELF flags
6929header to indicate that @samp{eabi} extended relocations are used.
6930
6931@item -meabi
6932@itemx -mno-eabi
cd3bb277
JM
6933@opindex meabi
6934@opindex mno-eabi
74291a4b
MM
6935On System V.4 and embedded PowerPC systems do (do not) adhere to the
6936Embedded Applications Binary Interface (eabi) which is a set of
bedc7537 6937modifications to the System V.4 specifications. Selecting @option{-meabi}
74291a4b
MM
6938means that the stack is aligned to an 8 byte boundary, a function
6939@code{__eabi} is called to from @code{main} to set up the eabi
630d3d5a 6940environment, and the @option{-msdata} option can use both @code{r2} and
74291a4b 6941@code{r13} to point to two separate small data areas. Selecting
bedc7537 6942@option{-mno-eabi} means that the stack is aligned to a 16 byte boundary,
74291a4b 6943do not call an initialization function from @code{main}, and the
630d3d5a
JM
6944@option{-msdata} option will only use @code{r13} to point to a single
6945small data area. The @option{-meabi} option is on by default if you
74291a4b
MM
6946configured GCC using one of the @samp{powerpc*-*-eabi*} options.
6947
6948@item -msdata=eabi
cd3bb277 6949@opindex msdata=eabi
74291a4b
MM
6950On System V.4 and embedded PowerPC systems, put small initialized
6951@code{const} global and static data in the @samp{.sdata2} section, which
6952is pointed to by register @code{r2}. Put small initialized
6953non-@code{const} global and static data in the @samp{.sdata} section,
6954which is pointed to by register @code{r13}. Put small uninitialized
6955global and static data in the @samp{.sbss} section, which is adjacent to
630d3d5a
JM
6956the @samp{.sdata} section. The @option{-msdata=eabi} option is
6957incompatible with the @option{-mrelocatable} option. The
6958@option{-msdata=eabi} option also sets the @option{-memb} option.
74291a4b
MM
6959
6960@item -msdata=sysv
cd3bb277 6961@opindex msdata=sysv
74291a4b
MM
6962On System V.4 and embedded PowerPC systems, put small global and static
6963data in the @samp{.sdata} section, which is pointed to by register
6964@code{r13}. Put small uninitialized global and static data in the
6965@samp{.sbss} section, which is adjacent to the @samp{.sdata} section.
630d3d5a
JM
6966The @option{-msdata=sysv} option is incompatible with the
6967@option{-mrelocatable} option.
74291a4b
MM
6968
6969@item -msdata=default
6970@itemx -msdata
cd3bb277
JM
6971@opindex msdata=default
6972@opindex msdata
630d3d5a
JM
6973On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
6974compile code the same as @option{-msdata=eabi}, otherwise compile code the
6975same as @option{-msdata=sysv}.
74291a4b
MM
6976
6977@item -msdata-data
cd3bb277 6978@opindex msdata-data
74291a4b
MM
6979On System V.4 and embedded PowerPC systems, put small global and static
6980data in the @samp{.sdata} section. Put small uninitialized global and
6981static data in the @samp{.sbss} section. Do not use register @code{r13}
6982to address small data however. This is the default behavior unless
630d3d5a 6983other @option{-msdata} options are used.
74291a4b
MM
6984
6985@item -msdata=none
6986@itemx -mno-sdata
cd3bb277
JM
6987@opindex msdata=none
6988@opindex mno-sdata
74291a4b
MM
6989On embedded PowerPC systems, put all initialized global and static data
6990in the @samp{.data} section, and all uninitialized data in the
6991@samp{.bss} section.
6992
6993@item -G @var{num}
cd3bb277 6994@opindex G
74291a4b
MM
6995@cindex smaller data references (PowerPC)
6996@cindex .sdata/.sdata2 references (PowerPC)
956d6950 6997On embedded PowerPC systems, put global and static items less than or
74291a4b
MM
6998equal to @var{num} bytes into the small data or bss sections instead of
6999the normal data or bss section. By default, @var{num} is 8. The
630d3d5a
JM
7000@option{-G @var{num}} switch is also passed to the linker.
7001All modules should be compiled with the same @option{-G @var{num}} value.
74291a4b
MM
7002
7003@item -mregnames
7004@itemx -mno-regnames
cd3bb277
JM
7005@opindex mregnames
7006@opindex mno-regnames
74291a4b
MM
7007On System V.4 and embedded PowerPC systems do (do not) emit register
7008names in the assembly language output using symbolic forms.
f5a1b0d2 7009
74291a4b 7010@end table
f5a1b0d2 7011
74291a4b
MM
7012@node RT Options
7013@subsection IBM RT Options
7014@cindex RT options
7015@cindex IBM RT options
7016
7017These @samp{-m} options are defined for the IBM RT PC:
7018
2642624b 7019@table @gcctabopt
74291a4b 7020@item -min-line-mul
cd3bb277 7021@opindex min-line-mul
74291a4b
MM
7022Use an in-line code sequence for integer multiplies. This is the
7023default.
7024
7025@item -mcall-lib-mul
cd3bb277 7026@opindex mcall-lib-mul
74291a4b
MM
7027Call @code{lmul$$} for integer multiples.
7028
7029@item -mfull-fp-blocks
cd3bb277 7030@opindex mfull-fp-blocks
74291a4b 7031Generate full-size floating point data blocks, including the minimum
161d7b59 7032amount of scratch space recommended by IBM@. This is the default.
74291a4b
MM
7033
7034@item -mminimum-fp-blocks
cd3bb277 7035@opindex mminimum-fp-blocks
74291a4b
MM
7036Do not include extra scratch space in floating point data blocks. This
7037results in smaller code, but slower execution, since scratch space must
7038be allocated dynamically.
7039
7040@cindex @file{varargs.h} and RT PC
7041@cindex @file{stdarg.h} and RT PC
7042@item -mfp-arg-in-fpregs
cd3bb277 7043@opindex mfp-arg-in-fpregs
74291a4b
MM
7044Use a calling sequence incompatible with the IBM calling convention in
7045which floating point arguments are passed in floating point registers.
c771326b 7046Note that @code{varargs.h} and @code{stdarg.h} will not work with
74291a4b
MM
7047floating point operands if this option is specified.
7048
7049@item -mfp-arg-in-gregs
cd3bb277 7050@opindex mfp-arg-in-gregs
74291a4b
MM
7051Use the normal calling convention for floating point arguments. This is
7052the default.
7053
7054@item -mhc-struct-return
cd3bb277 7055@opindex mhc-struct-return
74291a4b
MM
7056Return structures of more than one word in memory, rather than in a
7057register. This provides compatibility with the MetaWare HighC (hc)
630d3d5a 7058compiler. Use the option @option{-fpcc-struct-return} for compatibility
74291a4b
MM
7059with the Portable C Compiler (pcc).
7060
7061@item -mnohc-struct-return
cd3bb277 7062@opindex mnohc-struct-return
74291a4b
MM
7063Return some structures of more than one word in registers, when
7064convenient. This is the default. For compatibility with the
630d3d5a
JM
7065IBM-supplied compilers, use the option @option{-fpcc-struct-return} or the
7066option @option{-mhc-struct-return}.
74291a4b
MM
7067@end table
7068
7069@node MIPS Options
7070@subsection MIPS Options
7071@cindex MIPS options
7072
7073These @samp{-m} options are defined for the MIPS family of computers:
7074
2642624b 7075@table @gcctabopt
7dac2f89
EC
7076
7077@item -march=@var{cpu-type}
7078@opindex march
7079Assume the defaults for the machine type @var{cpu-type} when generating
7080instructions. The choices for @var{cpu-type} are @samp{r2000}, @samp{r3000},
7081@samp{r3900}, @samp{r4000}, @samp{r4100}, @samp{r4300}, @samp{r4400},
7082@samp{r4600}, @samp{r4650}, @samp{r5000}, @samp{r6000}, @samp{r8000},
7083and @samp{orion}. Additionally, the @samp{r2000}, @samp{r3000},
7084@samp{r4000}, @samp{r5000}, and @samp{r6000} can be abbreviated as
7085@samp{r2k} (or @samp{r2K}), @samp{r3k}, etc.
7086
7087@item -mtune=@var{cpu-type}
7088@opindex mtune
630d3d5a
JM
7089Assume the defaults for the machine type @var{cpu-type} when scheduling
7090instructions. The choices for @var{cpu-type} are @samp{r2000}, @samp{r3000},
8b9243df
JJ
7091@samp{r3900}, @samp{r4000}, @samp{r4100}, @samp{r4300}, @samp{r4400},
7092@samp{r4600}, @samp{r4650}, @samp{r5000}, @samp{r6000}, @samp{r8000},
7093and @samp{orion}. Additionally, the @samp{r2000}, @samp{r3000},
7094@samp{r4000}, @samp{r5000}, and @samp{r6000} can be abbreviated as
7095@samp{r2k} (or @samp{r2K}), @samp{r3k}, etc. While picking a specific
630d3d5a 7096@var{cpu-type} will schedule things appropriately for that particular
8b9243df 7097chip, the compiler will not generate any code that does not meet level 1
630d3d5a
JM
7098of the MIPS ISA (instruction set architecture) without a @option{-mipsX}
7099or @option{-mabi} switch being used.
74291a4b 7100
7dac2f89
EC
7101@item -mcpu=@var{cpu-type}
7102@opindex mcpu
7103This is identical to specifying both @option{-march} and @option{-mtune}.
7104
74291a4b 7105@item -mips1
cd3bb277 7106@opindex mips1
161d7b59 7107Issue instructions from level 1 of the MIPS ISA@. This is the default.
630d3d5a 7108@samp{r3000} is the default @var{cpu-type} at this ISA level.
74291a4b
MM
7109
7110@item -mips2
cd3bb277 7111@opindex mips2
74291a4b 7112Issue instructions from level 2 of the MIPS ISA (branch likely, square
630d3d5a 7113root instructions). @samp{r6000} is the default @var{cpu-type} at this
74291a4b
MM
7114ISA level.
7115
7116@item -mips3
cd3bb277 7117@opindex mips3
02f52e19 7118Issue instructions from level 3 of the MIPS ISA (64-bit instructions).
630d3d5a 7119@samp{r4000} is the default @var{cpu-type} at this ISA level.
74291a4b 7120
3398f47f 7121@item -mips4
cd3bb277 7122@opindex mips4
8b9243df
JJ
7123Issue instructions from level 4 of the MIPS ISA (conditional move,
7124prefetch, enhanced FPU instructions). @samp{r8000} is the default
630d3d5a 7125@var{cpu-type} at this ISA level.
3398f47f 7126
74291a4b 7127@item -mfp32
cd3bb277 7128@opindex mfp32
74291a4b
MM
7129Assume that 32 32-bit floating point registers are available. This is
7130the default.
7131
7132@item -mfp64
cd3bb277 7133@opindex mfp64
74291a4b 7134Assume that 32 64-bit floating point registers are available. This is
630d3d5a 7135the default when the @option{-mips3} option is used.
74291a4b 7136
13fac94a
GK
7137@item -mfused-madd
7138@itemx -mno-fused-madd
7139@opindex mfused-madd
7140@opindex mno-fused-madd
7141Generate code that uses (does not use) the floating point multiply and
7142accumulate instructions, when they are available. These instructions
7143are generated by default if they are available, but this may be
7144undesirable if the extra precision causes problems or on certain chips
7145in the mode where denormals are rounded to zero where denormals
7146generated by multiply and accumulate instructions cause exceptions
7147anyway.
7148
74291a4b 7149@item -mgp32
cd3bb277 7150@opindex mgp32
74291a4b
MM
7151Assume that 32 32-bit general purpose registers are available. This is
7152the default.
7153
7154@item -mgp64
cd3bb277 7155@opindex mgp64
74291a4b 7156Assume that 32 64-bit general purpose registers are available. This is
630d3d5a 7157the default when the @option{-mips3} option is used.
74291a4b
MM
7158
7159@item -mint64
cd3bb277 7160@opindex mint64
630d3d5a 7161Force int and long types to be 64 bits wide. See @option{-mlong32} for an
3ce1ba83 7162explanation of the default, and the width of pointers.
74291a4b
MM
7163
7164@item -mlong64
cd3bb277 7165@opindex mlong64
630d3d5a 7166Force long types to be 64 bits wide. See @option{-mlong32} for an
3ce1ba83 7167explanation of the default, and the width of pointers.
fb1bf66d 7168
3ce1ba83 7169@item -mlong32
cd3bb277 7170@opindex mlong32
3ce1ba83
GRK
7171Force long, int, and pointer types to be 32 bits wide.
7172
630d3d5a 7173If none of @option{-mlong32}, @option{-mlong64}, or @option{-mint64} are set,
b192711e 7174the size of ints, longs, and pointers depends on the ABI and ISA chosen.
630d3d5a
JM
7175For @option{-mabi=32}, and @option{-mabi=n32}, ints and longs are 32 bits
7176wide. For @option{-mabi=64}, ints are 32 bits, and longs are 64 bits wide.
7177For @option{-mabi=eabi} and either @option{-mips1} or @option{-mips2}, ints
7178and longs are 32 bits wide. For @option{-mabi=eabi} and higher ISAs, ints
3ce1ba83
GRK
7179are 32 bits, and longs are 64 bits wide. The width of pointer types is
7180the smaller of the width of longs or the width of general purpose
161d7b59 7181registers (which in turn depends on the ISA)@.
74291a4b 7182
62a1403d 7183@item -mabi=32
8b9243df 7184@itemx -mabi=o64
3398f47f
MM
7185@itemx -mabi=n32
7186@itemx -mabi=64
7187@itemx -mabi=eabi
cd3bb277
JM
7188@opindex mabi=32
7189@opindex mabi=o64
7190@opindex mabi=n32
7191@opindex mabi=64
7192@opindex mabi=eabi
161d7b59 7193Generate code for the indicated ABI@. The default instruction level is
630d3d5a
JM
7194@option{-mips1} for @samp{32}, @option{-mips3} for @samp{n32}, and
7195@option{-mips4} otherwise. Conversely, with @option{-mips1} or
7196@option{-mips2}, the default ABI is @samp{32}; otherwise, the default ABI
8b9243df 7197is @samp{64}.
3398f47f 7198
74291a4b 7199@item -mmips-as
cd3bb277 7200@opindex mmips-as
74291a4b
MM
7201Generate code for the MIPS assembler, and invoke @file{mips-tfile} to
7202add normal debug information. This is the default for all
7203platforms except for the OSF/1 reference platform, using the OSF/rose
630d3d5a 7204object format. If the either of the @option{-gstabs} or @option{-gstabs+}
74291a4b 7205switches are used, the @file{mips-tfile} program will encapsulate the
161d7b59 7206stabs within MIPS ECOFF@.
74291a4b
MM
7207
7208@item -mgas
cd3bb277 7209@opindex mgas
74291a4b 7210Generate code for the GNU assembler. This is the default on the OSF/1
861bb6c1 7211reference platform, using the OSF/rose object format. Also, this is
630d3d5a 7212the default if the configure option @option{--with-gnu-as} is used.
861bb6c1
JL
7213
7214@item -msplit-addresses
7215@itemx -mno-split-addresses
cd3bb277
JM
7216@opindex msplit-addresses
7217@opindex mno-split-addresses
861bb6c1 7218Generate code to load the high and low parts of address constants separately.
aee96fe9 7219This allows GCC to optimize away redundant loads of the high order
861bb6c1
JL
7220bits of addresses. This optimization requires GNU as and GNU ld.
7221This optimization is enabled by default for some embedded targets where
7222GNU as and GNU ld are standard.
74291a4b
MM
7223
7224@item -mrnames
7225@itemx -mno-rnames
cd3bb277
JM
7226@opindex mrnames
7227@opindex mno-rnames
630d3d5a 7228The @option{-mrnames} switch says to output code using the MIPS software
74291a4b
MM
7229names for the registers, instead of the hardware names (ie, @var{a0}
7230instead of @var{$4}). The only known assembler that supports this option
7231is the Algorithmics assembler.
7232
7233@item -mgpopt
7234@itemx -mno-gpopt
cd3bb277
JM
7235@opindex mgpopt
7236@opindex mno-gpopt
630d3d5a 7237The @option{-mgpopt} switch says to write all of the data declarations
74291a4b
MM
7238before the instructions in the text section, this allows the MIPS
7239assembler to generate one word memory references instead of using two
7240words for short global or static data items. This is on by default if
7241optimization is selected.
7242
7243@item -mstats
7244@itemx -mno-stats
cd3bb277
JM
7245@opindex mstats
7246@opindex mno-stats
630d3d5a 7247For each non-inline function processed, the @option{-mstats} switch
74291a4b
MM
7248causes the compiler to emit one line to the standard error file to
7249print statistics about the program (number of registers saved, stack
7250size, etc.).
7251
7252@item -mmemcpy
7253@itemx -mno-memcpy
cd3bb277
JM
7254@opindex mmemcpy
7255@opindex mno-memcpy
630d3d5a 7256The @option{-mmemcpy} switch makes all block moves call the appropriate
74291a4b
MM
7257string function (@samp{memcpy} or @samp{bcopy}) instead of possibly
7258generating inline code.
7259
7260@item -mmips-tfile
7261@itemx -mno-mips-tfile
cd3bb277
JM
7262@opindex mmips-tfile
7263@opindex mno-mips-tfile
630d3d5a 7264The @option{-mno-mips-tfile} switch causes the compiler not
74291a4b
MM
7265postprocess the object file with the @file{mips-tfile} program,
7266after the MIPS assembler has generated it to add debug support. If
7267@file{mips-tfile} is not run, then no local variables will be
7268available to the debugger. In addition, @file{stage2} and
7269@file{stage3} objects will have the temporary file names passed to the
7270assembler embedded in the object file, which means the objects will
630d3d5a 7271not compare the same. The @option{-mno-mips-tfile} switch should only
74291a4b
MM
7272be used when there are bugs in the @file{mips-tfile} program that
7273prevents compilation.
7274
7275@item -msoft-float
cd3bb277 7276@opindex msoft-float
74291a4b 7277Generate output containing library calls for floating point.
161d7b59 7278@strong{Warning:} the requisite libraries are not part of GCC@.
74291a4b
MM
7279Normally the facilities of the machine's usual C compiler are used, but
7280this can't be done directly in cross-compilation. You must make your
7281own arrangements to provide suitable library functions for
7282cross-compilation.
7283
7284@item -mhard-float
cd3bb277 7285@opindex mhard-float
74291a4b
MM
7286Generate output containing floating point instructions. This is the
7287default if you use the unmodified sources.
7288
7289@item -mabicalls
7290@itemx -mno-abicalls
cd3bb277
JM
7291@opindex mabicalls
7292@opindex mno-abicalls
74291a4b
MM
7293Emit (or do not emit) the pseudo operations @samp{.abicalls},
7294@samp{.cpload}, and @samp{.cprestore} that some System V.4 ports use for
7295position independent code.
7296
7297@item -mlong-calls
7298@itemx -mno-long-calls
cd3bb277
JM
7299@opindex mlong-calls
7300@opindex mno-long-calls
74291a4b
MM
7301Do all calls with the @samp{JALR} instruction, which requires
7302loading up a function's address into a register before the call.
7303You need to use this switch, if you call outside of the current
7304512 megabyte segment to functions that are not through pointers.
7305
7306@item -mhalf-pic
7307@itemx -mno-half-pic
cd3bb277
JM
7308@opindex mhalf-pic
7309@opindex mno-half-pic
74291a4b
MM
7310Put pointers to extern references into the data section and load them
7311up, rather than put the references in the text section.
7312
7313@item -membedded-pic
7314@itemx -mno-embedded-pic
cd3bb277
JM
7315@opindex membedded-pic
7316@opindex mno-embedded-pic
69fa83cf
JW
7317Generate PIC code suitable for some embedded systems. All calls are
7318made using PC relative address, and all data is addressed using the $gp
7319register. No more than 65536 bytes of global data may be used. This
7320requires GNU as and GNU ld which do most of the work. This currently
161d7b59 7321only works on targets which use ECOFF; it does not work with ELF@.
74291a4b
MM
7322
7323@item -membedded-data
7324@itemx -mno-embedded-data
cd3bb277
JM
7325@opindex membedded-data
7326@opindex mno-embedded-data
74291a4b
MM
7327Allocate variables to the read-only data section first if possible, then
7328next in the small data section if possible, otherwise in data. This gives
7329slightly slower code than the default, but reduces the amount of RAM required
7330when executing, and thus may be preferred for some embedded systems.
7331
919509ce
DN
7332@item -muninit-const-in-rodata
7333@itemx -mno-uninit-const-in-rodata
cd3bb277
JM
7334@opindex muninit-const-in-rodata
7335@opindex mno-uninit-const-in-rodata
695ac33f 7336When used together with @option{-membedded-data}, it will always store uninitialized
919509ce 7337const variables in the read-only data section.
02f52e19 7338
74291a4b
MM
7339@item -msingle-float
7340@itemx -mdouble-float
cd3bb277
JM
7341@opindex msingle-float
7342@opindex mdouble-float
630d3d5a 7343The @option{-msingle-float} switch tells gcc to assume that the floating
74291a4b 7344point coprocessor only supports single precision operations, as on the
630d3d5a 7345@samp{r4650} chip. The @option{-mdouble-float} switch permits gcc to use
74291a4b
MM
7346double precision operations. This is the default.
7347
7348@item -mmad
7349@itemx -mno-mad
cd3bb277
JM
7350@opindex mmad
7351@opindex mno-mad
74291a4b
MM
7352Permit use of the @samp{mad}, @samp{madu} and @samp{mul} instructions,
7353as on the @samp{r4650} chip.
7354
7355@item -m4650
cd3bb277 7356@opindex m4650
630d3d5a
JM
7357Turns on @option{-msingle-float}, @option{-mmad}, and, at least for now,
7358@option{-mcpu=r4650}.
74291a4b 7359
8b9243df
JJ
7360@item -mips16
7361@itemx -mno-mips16
cd3bb277
JM
7362@opindex mips16
7363@opindex mno-mips16
8b9243df
JJ
7364Enable 16-bit instructions.
7365
7366@item -mentry
cd3bb277 7367@opindex mentry
8b9243df 7368Use the entry and exit pseudo ops. This option can only be used with
630d3d5a 7369@option{-mips16}.
8b9243df 7370
74291a4b 7371@item -EL
cd3bb277 7372@opindex EL
74291a4b
MM
7373Compile code for the processor in little endian mode.
7374The requisite libraries are assumed to exist.
7375
7376@item -EB
cd3bb277 7377@opindex EB
74291a4b
MM
7378Compile code for the processor in big endian mode.
7379The requisite libraries are assumed to exist.
7380
7381@item -G @var{num}
cd3bb277 7382@opindex G
74291a4b
MM
7383@cindex smaller data references (MIPS)
7384@cindex gp-relative references (MIPS)
7385Put global and static items less than or equal to @var{num} bytes into
7386the small data or bss sections instead of the normal data or bss
7387section. This allows the assembler to emit one word memory reference
7388instructions based on the global pointer (@var{gp} or @var{$28}),
7389instead of the normal two words used. By default, @var{num} is 8 when
7390the MIPS assembler is used, and 0 when the GNU assembler is used. The
630d3d5a
JM
7391@option{-G @var{num}} switch is also passed to the assembler and linker.
7392All modules should be compiled with the same @option{-G @var{num}}
74291a4b
MM
7393value.
7394
7395@item -nocpp
cd3bb277 7396@opindex nocpp
9ec36da5 7397Tell the MIPS assembler to not run its preprocessor over user
74291a4b 7398assembler files (with a @samp{.s} suffix) when assembling them.
63357d93 7399
1e387156 7400@item -mfix7000
cd3bb277 7401@opindex mfix7000
1e387156
CM
7402Pass an option to gas which will cause nops to be inserted if
7403the read of the destination register of an mfhi or mflo instruction
7404occurs in the following two instructions.
7405
63357d93 7406@item -no-crt0
cd3bb277 7407@opindex no-crt0
63357d93 7408Do not include the default crt0.
74291a4b
MM
7409@end table
7410
7411@ifset INTERNALS
7412These options are defined by the macro
7413@code{TARGET_SWITCHES} in the machine description. The default for the
7414options is also defined by that macro, which enables you to change the
7415defaults.
7416@end ifset
7417
7418@node i386 Options
7419@subsection Intel 386 Options
7420@cindex i386 Options
7421@cindex Intel 386 Options
7422
7423These @samp{-m} options are defined for the i386 family of computers:
7424
2642624b 7425@table @gcctabopt
630d3d5a 7426@item -mcpu=@var{cpu-type}
cd3bb277 7427@opindex mcpu
630d3d5a
JM
7428Assume the defaults for the machine type @var{cpu-type} when scheduling
7429instructions. The choices for @var{cpu-type} are @samp{i386},
9d86bffc 7430@samp{i486}, @samp{i586}, @samp{i686}, @samp{pentium},
b4e89e2d 7431@samp{pentiumpro}, @samp{pentium4}, @samp{k6}, and @samp{athlon}
6f670fde 7432
630d3d5a 7433While picking a specific @var{cpu-type} will schedule things appropriately
6f670fde 7434for that particular chip, the compiler will not generate any code that
630d3d5a 7435does not run on the i386 without the @option{-march=@var{cpu-type}} option
7001ee2d 7436being used. @samp{i586} is equivalent to @samp{pentium} and @samp{i686}
6ca3ad1b 7437is equivalent to @samp{pentiumpro}. @samp{k6} and @samp{athlon} are the
b4e89e2d 7438AMD chips as opposed to the Intel ones.
a9f3e1a4 7439
630d3d5a 7440@item -march=@var{cpu-type}
cd3bb277 7441@opindex march
630d3d5a
JM
7442Generate instructions for the machine type @var{cpu-type}. The choices
7443for @var{cpu-type} are the same as for @option{-mcpu}. Moreover,
7444specifying @option{-march=@var{cpu-type}} implies @option{-mcpu=@var{cpu-type}}.
a9f3e1a4
JL
7445
7446@item -m386
7447@itemx -m486
7448@itemx -mpentium
7449@itemx -mpentiumpro
cd3bb277
JM
7450@opindex m386
7451@opindex m486
7452@opindex mpentium
7453@opindex mpentiumpro
9c34dbbf
ZW
7454These options are synonyms for @option{-mcpu=i386}, @option{-mcpu=i486},
7455@option{-mcpu=pentium}, and @option{-mcpu=pentiumpro} respectively.
7456These synonyms are deprecated.
74291a4b 7457
04e149ab 7458@item -mintel-syntax
cd3bb277 7459@opindex mintel-syntax
04e149ab
KC
7460Emit assembly using Intel syntax opcodes instead of AT&T syntax.
7461
74291a4b
MM
7462@item -mieee-fp
7463@itemx -mno-ieee-fp
cd3bb277
JM
7464@opindex mieee-fp
7465@opindex mno-ieee-fp
74291a4b
MM
7466Control whether or not the compiler uses IEEE floating point
7467comparisons. These handle correctly the case where the result of a
7468comparison is unordered.
7469
7470@item -msoft-float
cd3bb277 7471@opindex msoft-float
74291a4b 7472Generate output containing library calls for floating point.
161d7b59 7473@strong{Warning:} the requisite libraries are not part of GCC@.
74291a4b
MM
7474Normally the facilities of the machine's usual C compiler are used, but
7475this can't be done directly in cross-compilation. You must make your
7476own arrangements to provide suitable library functions for
7477cross-compilation.
7478
7479On machines where a function returns floating point results in the 80387
7480register stack, some floating point opcodes may be emitted even if
630d3d5a 7481@option{-msoft-float} is used.
74291a4b
MM
7482
7483@item -mno-fp-ret-in-387
cd3bb277 7484@opindex mno-fp-ret-in-387
74291a4b
MM
7485Do not use the FPU registers for return values of functions.
7486
7487The usual calling convention has functions return values of types
7488@code{float} and @code{double} in an FPU register, even if there
161d7b59
JM
7489is no FPU@. The idea is that the operating system should emulate
7490an FPU@.
74291a4b 7491
630d3d5a 7492The option @option{-mno-fp-ret-in-387} causes such values to be returned
74291a4b
MM
7493in ordinary CPU registers instead.
7494
7495@item -mno-fancy-math-387
cd3bb277 7496@opindex mno-fancy-math-387
74291a4b
MM
7497Some 387 emulators do not support the @code{sin}, @code{cos} and
7498@code{sqrt} instructions for the 387. Specify this option to avoid
161d7b59 7499generating those instructions. This option is the default on FreeBSD@.
74291a4b 7500As of revision 2.6.1, these instructions are not generated unless you
630d3d5a 7501also use the @option{-funsafe-math-optimizations} switch.
74291a4b
MM
7502
7503@item -malign-double
7504@itemx -mno-align-double
cd3bb277
JM
7505@opindex malign-double
7506@opindex mno-align-double
0c2d1a2a 7507Control whether GCC aligns @code{double}, @code{long double}, and
74291a4b
MM
7508@code{long long} variables on a two word boundary or a one word
7509boundary. Aligning @code{double} variables on a two word boundary will
7510produce code that runs somewhat faster on a @samp{Pentium} at the
7511expense of more memory.
7512
2b589241 7513@item -m128bit-long-double
cd3bb277 7514@opindex m128bit-long-double
2b589241
JH
7515Control the size of @code{long double} type. i386 application binary interface
7516specify the size to be 12 bytes, while modern architectures (Pentium and newer)
c771326b 7517prefer @code{long double} aligned to 8 or 16 byte boundary. This is
2b589241
JH
7518impossible to reach with 12 byte long doubles in the array accesses.
7519
630d3d5a 7520@strong{Warning:} if you use the @option{-m128bit-long-double} switch, the
2b589241
JH
7521structures and arrays containing @code{long double} will change their size as
7522well as function calling convention for function taking @code{long double}
02f52e19 7523will be modified.
2b589241
JH
7524
7525@item -m96bit-long-double
cd3bb277 7526@opindex m96bit-long-double
0a75e5c3 7527Set the size of @code{long double} to 96 bits as required by the i386
2b589241 7528application binary interface. This is the default.
74291a4b
MM
7529
7530@item -msvr3-shlib
7531@itemx -mno-svr3-shlib
cd3bb277
JM
7532@opindex msvr3-shlib
7533@opindex mno-svr3-shlib
9c34dbbf
ZW
7534Control whether GCC places uninitialized local variables into the
7535@code{bss} or @code{data} segments. @option{-msvr3-shlib} places them
7536into @code{bss}. These options are meaningful only on System V Release 3.
74291a4b 7537
74291a4b 7538@item -mrtd
cd3bb277 7539@opindex mrtd
74291a4b
MM
7540Use a different function-calling convention, in which functions that
7541take a fixed number of arguments return with the @code{ret} @var{num}
7542instruction, which pops their arguments while returning. This saves one
7543instruction in the caller since there is no need to pop the arguments
7544there.
7545
7546You can specify that an individual function is called with this calling
7547sequence with the function attribute @samp{stdcall}. You can also
630d3d5a 7548override the @option{-mrtd} option by using the function attribute
0b433de6 7549@samp{cdecl}. @xref{Function Attributes}.
74291a4b
MM
7550
7551@strong{Warning:} this calling convention is incompatible with the one
7552normally used on Unix, so you cannot use it if you need to call
7553libraries compiled with the Unix compiler.
7554
7555Also, you must provide function prototypes for all functions that
7556take variable numbers of arguments (including @code{printf});
7557otherwise incorrect code will be generated for calls to those
7558functions.
7559
7560In addition, seriously incorrect code will result if you call a
7561function with too many arguments. (Normally, extra arguments are
7562harmlessly ignored.)
7563
74291a4b 7564@item -mregparm=@var{num}
cd3bb277 7565@opindex mregparm
74291a4b
MM
7566Control how many registers are used to pass integer arguments. By
7567default, no registers are used to pass arguments, and at most 3
7568registers can be used. You can control this behavior for a specific
0b433de6
JL
7569function by using the function attribute @samp{regparm}.
7570@xref{Function Attributes}.
74291a4b
MM
7571
7572@strong{Warning:} if you use this switch, and
7573@var{num} is nonzero, then you must build all modules with the same
7574value, including any libraries. This includes the system libraries and
7575startup modules.
7576
3af4bd89 7577@item -mpreferred-stack-boundary=@var{num}
cd3bb277 7578@opindex mpreferred-stack-boundary
3af4bd89 7579Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
630d3d5a 7580byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
3af4bd89
JH
7581the default is 4 (16 bytes or 128 bits).
7582
7583The stack is required to be aligned on a 4 byte boundary. On Pentium
7584and PentiumPro, @code{double} and @code{long double} values should be
630d3d5a 7585aligned to an 8 byte boundary (see @option{-malign-double}) or suffer
3af4bd89 7586significant run time performance penalties. On Pentium III, the
b192711e 7587Streaming SIMD Extension (SSE) data type @code{__m128} suffers similar
3af4bd89
JH
7588penalties if it is not 16 byte aligned.
7589
7590To ensure proper alignment of this values on the stack, the stack boundary
02f52e19 7591must be as aligned as that required by any value stored on the stack.
3af4bd89
JH
7592Further, every function must be generated such that it keeps the stack
7593aligned. Thus calling a function compiled with a higher preferred
7594stack boundary from a function compiled with a lower preferred stack
7595boundary will most likely misalign the stack. It is recommended that
7596libraries that use callbacks always use the default setting.
7597
7598This extra alignment does consume extra stack space. Code that is sensitive
7599to stack space usage, such as embedded systems and operating system kernels,
7600may want to reduce the preferred alignment to
630d3d5a 7601@option{-mpreferred-stack-boundary=2}.
f22a97d2 7602
f73ad30e 7603@item -mpush-args
a7939b1d 7604@itemx -mno-push-args
cd3bb277 7605@opindex mpush-args
a7939b1d 7606@opindex mno-push-args
767094dd 7607Use PUSH operations to store outgoing parameters. This method is shorter
f73ad30e 7608and usually equally fast as method using SUB/MOV operations and is enabled
767094dd 7609by default. In some cases disabling it may improve performance because of
f73ad30e
JH
7610improved scheduling and reduced dependencies.
7611
7612@item -maccumulate-outgoing-args
cd3bb277 7613@opindex maccumulate-outgoing-args
f73ad30e 7614If enabled, the maximum amount of space required for outgoing arguments will be
a7939b1d 7615computed in the function prologue. This is faster on most modern CPUs
b192711e 7616because of reduced dependencies, improved scheduling and reduced stack usage
f73ad30e 7617when preferred stack boundary is not equal to 2. The drawback is a notable
767094dd 7618increase in code size. This switch implies @option{-mno-push-args}.
f73ad30e 7619
f22a97d2 7620@item -mthreads
cd3bb277 7621@opindex mthreads
767094dd 7622Support thread-safe exception handling on @samp{Mingw32}. Code that relies
02f52e19 7623on thread-safe exception handling must compile and link all code with the
767094dd 7624@option{-mthreads} option. When compiling, @option{-mthreads} defines
630d3d5a
JM
7625@option{-D_MT}; when linking, it links in a special thread helper library
7626@option{-lmingwthrd} which cleans up per thread exception handling data.
79f05c19
JH
7627
7628@item -mno-align-stringops
cd3bb277 7629@opindex mno-align-stringops
767094dd 7630Do not align destination of inlined string operations. This switch reduces
79f05c19
JH
7631code size and improves performance in case the destination is already aligned,
7632but gcc don't know about it.
7633
7634@item -minline-all-stringops
cd3bb277 7635@opindex minline-all-stringops
79f05c19 7636By default GCC inlines string operations only when destination is known to be
767094dd 7637aligned at least to 4 byte boundary. This enables more inlining, increase code
79f05c19
JH
7638size, but may improve performance of code that depends on fast memcpy, strlen
7639and memset for short lengths.
762e166b
AJ
7640
7641@item -momit-leaf-frame-pointer
cd3bb277 7642@opindex momit-leaf-frame-pointer
762e166b
AJ
7643Don't keep the frame pointer in a register for leaf functions. This
7644avoids the instructions to save, set up and restore frame pointers and
7645makes an extra register available in leaf functions. The option
630d3d5a 7646@option{-fomit-frame-pointer} removes the frame pointer for all functions
762e166b 7647which might make debugging harder.
3af4bd89
JH
7648@end table
7649
74291a4b
MM
7650@node HPPA Options
7651@subsection HPPA Options
7652@cindex HPPA Options
7653
7654These @samp{-m} options are defined for the HPPA family of computers:
7655
2642624b 7656@table @gcctabopt
630d3d5a 7657@item -march=@var{architecture-type}
cd3bb277 7658@opindex march
ea3bfbfe 7659Generate code for the specified architecture. The choices for
630d3d5a 7660@var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
ea3bfbfe
JQ
76611.1, and @samp{2.0} for PA 2.0 processors. Refer to
7662@file{/usr/lib/sched.models} on an HP-UX system to determine the proper
7663architecture option for your machine. Code compiled for lower numbered
7664architectures will run on higher numbered architectures, but not the
7665other way around.
7666
7667PA 2.0 support currently requires gas snapshot 19990413 or later. The
7668next release of binutils (current is 2.9.1) will probably contain PA 2.0
02f52e19 7669support.
74291a4b 7670
ea3bfbfe 7671@item -mpa-risc-1-0
62a1403d
AS
7672@itemx -mpa-risc-1-1
7673@itemx -mpa-risc-2-0
cd3bb277
JM
7674@opindex mpa-risc-1-0
7675@opindex mpa-risc-1-1
7676@opindex mpa-risc-2-0
695ac33f 7677Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
74291a4b 7678
861bb6c1 7679@item -mbig-switch
cd3bb277 7680@opindex mbig-switch
861bb6c1
JL
7681Generate code suitable for big switch tables. Use this option only if
7682the assembler/linker complain about out of range branches within a switch
7683table.
7684
74291a4b 7685@item -mjump-in-delay
cd3bb277 7686@opindex mjump-in-delay
74291a4b
MM
7687Fill delay slots of function calls with unconditional jump instructions
7688by modifying the return pointer for the function call to be the target
7689of the conditional jump.
7690
7691@item -mdisable-fpregs
cd3bb277 7692@opindex mdisable-fpregs
74291a4b
MM
7693Prevent floating point registers from being used in any manner. This is
7694necessary for compiling kernels which perform lazy context switching of
7695floating point registers. If you use this option and attempt to perform
7696floating point operations, the compiler will abort.
7697
7698@item -mdisable-indexing
cd3bb277 7699@opindex mdisable-indexing
74291a4b 7700Prevent the compiler from using indexing address modes. This avoids some
161d7b59 7701rather obscure problems when compiling MIG generated code under MACH@.
74291a4b
MM
7702
7703@item -mno-space-regs
cd3bb277 7704@opindex mno-space-regs
74291a4b
MM
7705Generate code that assumes the target has no space registers. This allows
7706GCC to generate faster indirect calls and use unscaled index address modes.
7707
7708Such code is suitable for level 0 PA systems and kernels.
7709
7710@item -mfast-indirect-calls
cd3bb277 7711@opindex mfast-indirect-calls
74291a4b
MM
7712Generate code that assumes calls never cross space boundaries. This
7713allows GCC to emit code which performs faster indirect calls.
7714
b192711e 7715This option will not work in the presence of shared libraries or nested
74291a4b
MM
7716functions.
7717
74291a4b 7718@item -mlong-load-store
cd3bb277 7719@opindex mlong-load-store
74291a4b
MM
7720Generate 3-instruction load and store sequences as sometimes required by
7721the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
7722the HP compilers.
7723
7724@item -mportable-runtime
cd3bb277 7725@opindex mportable-runtime
74291a4b
MM
7726Use the portable calling conventions proposed by HP for ELF systems.
7727
7728@item -mgas
cd3bb277 7729@opindex mgas
74291a4b
MM
7730Enable the use of assembler directives only GAS understands.
7731
630d3d5a 7732@item -mschedule=@var{cpu-type}
cd3bb277 7733@opindex mschedule
74291a4b 7734Schedule code according to the constraints for the machine type
630d3d5a 7735@var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
02f52e19 7736@samp{7100}, @samp{7100LC}, @samp{7200}, and @samp{8000}. Refer to
732135bf
JL
7737@file{/usr/lib/sched.models} on an HP-UX system to determine the
7738proper scheduling option for your machine.
74291a4b
MM
7739
7740@item -mlinker-opt
cd3bb277 7741@opindex mlinker-opt
74291a4b
MM
7742Enable the optimization pass in the HPUX linker. Note this makes symbolic
7743debugging impossible. It also triggers a bug in the HPUX 8 and HPUX 9 linkers
7744in which they give bogus error messages when linking some programs.
7745
7746@item -msoft-float
cd3bb277 7747@opindex msoft-float
74291a4b
MM
7748Generate output containing library calls for floating point.
7749@strong{Warning:} the requisite libraries are not available for all HPPA
7750targets. Normally the facilities of the machine's usual C compiler are
7751used, but this cannot be done directly in cross-compilation. You must make
7752your own arrangements to provide suitable library functions for
7753cross-compilation. The embedded target @samp{hppa1.1-*-pro}
7754does provide software floating point support.
7755
630d3d5a 7756@option{-msoft-float} changes the calling convention in the output file;
74291a4b
MM
7757therefore, it is only useful if you compile @emph{all} of a program with
7758this option. In particular, you need to compile @file{libgcc.a}, the
630d3d5a 7759library that comes with GCC, with @option{-msoft-float} in order for
74291a4b
MM
7760this to work.
7761@end table
7762
7763@node Intel 960 Options
7764@subsection Intel 960 Options
7765
7766These @samp{-m} options are defined for the Intel 960 implementations:
7767
2642624b 7768@table @gcctabopt
cd3bb277
JM
7769@item -m@var{cpu-type}
7770@opindex mka
7771@opindex mkb
7772@opindex mmc
7773@opindex mca
7774@opindex mcf
7775@opindex msa
7776@opindex msb
7777Assume the defaults for the machine type @var{cpu-type} for some of
74291a4b 7778the other options, including instruction scheduling, floating point
cd3bb277 7779support, and addressing modes. The choices for @var{cpu-type} are
74291a4b
MM
7780@samp{ka}, @samp{kb}, @samp{mc}, @samp{ca}, @samp{cf},
7781@samp{sa}, and @samp{sb}.
7782The default is
7783@samp{kb}.
7784
7785@item -mnumerics
7786@itemx -msoft-float
cd3bb277
JM
7787@opindex mnumerics
7788@opindex msoft-float
630d3d5a
JM
7789The @option{-mnumerics} option indicates that the processor does support
7790floating-point instructions. The @option{-msoft-float} option indicates
74291a4b
MM
7791that floating-point support should not be assumed.
7792
7793@item -mleaf-procedures
7794@itemx -mno-leaf-procedures
cd3bb277
JM
7795@opindex mleaf-procedures
7796@opindex mno-leaf-procedures
74291a4b
MM
7797Do (or do not) attempt to alter leaf procedures to be callable with the
7798@code{bal} instruction as well as @code{call}. This will result in more
7799efficient code for explicit calls when the @code{bal} instruction can be
7800substituted by the assembler or linker, but less efficient code in other
7801cases, such as calls via function pointers, or using a linker that doesn't
7802support this optimization.
7803
7804@item -mtail-call
7805@itemx -mno-tail-call
cd3bb277
JM
7806@opindex mtail-call
7807@opindex mno-tail-call
74291a4b
MM
7808Do (or do not) make additional attempts (beyond those of the
7809machine-independent portions of the compiler) to optimize tail-recursive
7810calls into branches. You may not want to do this because the detection of
7811cases where this is not valid is not totally complete. The default is
630d3d5a 7812@option{-mno-tail-call}.
74291a4b
MM
7813
7814@item -mcomplex-addr
7815@itemx -mno-complex-addr
cd3bb277
JM
7816@opindex mcomplex-addr
7817@opindex mno-complex-addr
74291a4b
MM
7818Assume (or do not assume) that the use of a complex addressing mode is a
7819win on this implementation of the i960. Complex addressing modes may not
7820be worthwhile on the K-series, but they definitely are on the C-series.
630d3d5a 7821The default is currently @option{-mcomplex-addr} for all processors except
161d7b59 7822the CB and CC@.
74291a4b
MM
7823
7824@item -mcode-align
7825@itemx -mno-code-align
cd3bb277
JM
7826@opindex mcode-align
7827@opindex mno-code-align
74291a4b
MM
7828Align code to 8-byte boundaries for faster fetching (or don't bother).
7829Currently turned on by default for C-series implementations only.
7830
7831@ignore
7832@item -mclean-linkage
7833@itemx -mno-clean-linkage
cd3bb277
JM
7834@opindex mclean-linkage
7835@opindex mno-clean-linkage
74291a4b
MM
7836These options are not fully implemented.
7837@end ignore
7838
7839@item -mic-compat
7840@itemx -mic2.0-compat
7841@itemx -mic3.0-compat
cd3bb277
JM
7842@opindex mic-compat
7843@opindex mic2.0-compat
7844@opindex mic3.0-compat
74291a4b
MM
7845Enable compatibility with iC960 v2.0 or v3.0.
7846
7847@item -masm-compat
7848@itemx -mintel-asm
cd3bb277
JM
7849@opindex masm-compat
7850@opindex mintel-asm
74291a4b
MM
7851Enable compatibility with the iC960 assembler.
7852
7853@item -mstrict-align
7854@itemx -mno-strict-align
cd3bb277
JM
7855@opindex mstrict-align
7856@opindex mno-strict-align
74291a4b
MM
7857Do not permit (do permit) unaligned accesses.
7858
7859@item -mold-align
cd3bb277 7860@opindex mold-align
74291a4b 7861Enable structure-alignment compatibility with Intel's gcc release version
630d3d5a 78621.3 (based on gcc 1.37). This option implies @option{-mstrict-align}.
eaa4b44c
VM
7863
7864@item -mlong-double-64
cd3bb277 7865@opindex mlong-double-64
eaa4b44c
VM
7866Implement type @samp{long double} as 64-bit floating point numbers.
7867Without the option @samp{long double} is implemented by 80-bit
7868floating point numbers. The only reason we have it because there is
7869no 128-bit @samp{long double} support in @samp{fp-bit.c} yet. So it
7870is only useful for people using soft-float targets. Otherwise, we
7871should recommend against use of it.
7872
74291a4b
MM
7873@end table
7874
7875@node DEC Alpha Options
7876@subsection DEC Alpha Options
7877
7878These @samp{-m} options are defined for the DEC Alpha implementations:
7879
2642624b 7880@table @gcctabopt
74291a4b
MM
7881@item -mno-soft-float
7882@itemx -msoft-float
cd3bb277
JM
7883@opindex mno-soft-float
7884@opindex msoft-float
74291a4b 7885Use (do not use) the hardware floating-point instructions for
bedc7537 7886floating-point operations. When @option{-msoft-float} is specified,
7857f134 7887functions in @file{libgcc.a} will be used to perform floating-point
74291a4b
MM
7888operations. Unless they are replaced by routines that emulate the
7889floating-point operations, or compiled in such a way as to call such
7890emulations routines, these routines will issue floating-point
7891operations. If you are compiling for an Alpha without floating-point
7892operations, you must ensure that the library is built so as not to call
7893them.
7894
7895Note that Alpha implementations without floating-point operations are
7896required to have floating-point registers.
7897
7898@item -mfp-reg
7899@itemx -mno-fp-regs
cd3bb277
JM
7900@opindex mfp-reg
7901@opindex mno-fp-regs
74291a4b 7902Generate code that uses (does not use) the floating-point register set.
bedc7537 7903@option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
74291a4b
MM
7904register set is not used, floating point operands are passed in integer
7905registers as if they were integers and floating-point results are passed
7906in $0 instead of $f0. This is a non-standard calling sequence, so any
7907function with a floating-point argument or return value called by code
bedc7537 7908compiled with @option{-mno-fp-regs} must also be compiled with that
74291a4b
MM
7909option.
7910
7911A typical use of this option is building a kernel that does not use,
7912and hence need not save and restore, any floating-point registers.
7913
7914@item -mieee
cd3bb277 7915@opindex mieee
74291a4b
MM
7916The Alpha architecture implements floating-point hardware optimized for
7917maximum performance. It is mostly compliant with the IEEE floating
7918point standard. However, for full compliance, software assistance is
7919required. This option generates code fully IEEE compliant code
630d3d5a 7920@emph{except} that the @var{inexact-flag} is not maintained (see below).
9c34dbbf
ZW
7921If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
7922defined during compilation. The resulting code is less efficient but is
7923able to correctly support denormalized numbers and exceptional IEEE
7924values such as not-a-number and plus/minus infinity. Other Alpha
7925compilers call this option @option{-ieee_with_no_inexact}.
74291a4b
MM
7926
7927@item -mieee-with-inexact
cd3bb277 7928@opindex mieee-with-inexact
9c34dbbf
ZW
7929This is like @option{-mieee} except the generated code also maintains
7930the IEEE @var{inexact-flag}. Turning on this option causes the
7931generated code to implement fully-compliant IEEE math. In addition to
7932@code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
7933macro. On some Alpha implementations the resulting code may execute
7934significantly slower than the code generated by default. Since there is
7935very little code that depends on the @var{inexact-flag}, you should
74291a4b 7936normally not specify this option. Other Alpha compilers call this
630d3d5a 7937option @option{-ieee_with_inexact}.
74291a4b 7938
630d3d5a 7939@item -mfp-trap-mode=@var{trap-mode}
cd3bb277 7940@opindex mfp-trap-mode
74291a4b 7941This option controls what floating-point related traps are enabled.
630d3d5a 7942Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
74291a4b
MM
7943The trap mode can be set to one of four values:
7944
7945@table @samp
7946@item n
7947This is the default (normal) setting. The only traps that are enabled
7948are the ones that cannot be disabled in software (e.g., division by zero
7949trap).
7950
7951@item u
7952In addition to the traps enabled by @samp{n}, underflow traps are enabled
7953as well.
7954
7955@item su
7956Like @samp{su}, but the instructions are marked to be safe for software
7957completion (see Alpha architecture manual for details).
7958
7959@item sui
7960Like @samp{su}, but inexact traps are enabled as well.
7961@end table
7962
630d3d5a 7963@item -mfp-rounding-mode=@var{rounding-mode}
cd3bb277 7964@opindex mfp-rounding-mode
74291a4b 7965Selects the IEEE rounding mode. Other Alpha compilers call this option
630d3d5a 7966@option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
74291a4b
MM
7967of:
7968
7969@table @samp
7970@item n
7971Normal IEEE rounding mode. Floating point numbers are rounded towards
7972the nearest machine number or towards the even machine number in case
7973of a tie.
7974
7975@item m
7976Round towards minus infinity.
7977
7978@item c
7979Chopped rounding mode. Floating point numbers are rounded towards zero.
7980
7981@item d
7982Dynamic rounding mode. A field in the floating point control register
7983(@var{fpcr}, see Alpha architecture reference manual) controls the
7984rounding mode in effect. The C library initializes this register for
7985rounding towards plus infinity. Thus, unless your program modifies the
ec4b2ecb
CB
7986@var{fpcr}, @samp{d} corresponds to round towards plus infinity.
7987@end table
74291a4b 7988
630d3d5a 7989@item -mtrap-precision=@var{trap-precision}
cd3bb277 7990@opindex mtrap-precision
74291a4b
MM
7991In the Alpha architecture, floating point traps are imprecise. This
7992means without software assistance it is impossible to recover from a
7993floating trap and program execution normally needs to be terminated.
0c2d1a2a 7994GCC can generate code that can assist operating system trap handlers
74291a4b
MM
7995in determining the exact location that caused a floating point trap.
7996Depending on the requirements of an application, different levels of
7997precisions can be selected:
7998
7999@table @samp
8000@item p
8001Program precision. This option is the default and means a trap handler
8002can only identify which program caused a floating point exception.
8003
8004@item f
8005Function precision. The trap handler can determine the function that
8006caused a floating point exception.
8007
8008@item i
8009Instruction precision. The trap handler can determine the exact
8010instruction that caused a floating point exception.
8011@end table
8012
8013Other Alpha compilers provide the equivalent options called
630d3d5a 8014@option{-scope_safe} and @option{-resumption_safe}.
74291a4b
MM
8015
8016@item -mieee-conformant
cd3bb277 8017@opindex mieee-conformant
74291a4b 8018This option marks the generated code as IEEE conformant. You must not
630d3d5a
JM
8019use this option unless you also specify @option{-mtrap-precision=i} and either
8020@option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
74291a4b
MM
8021is to emit the line @samp{.eflag 48} in the function prologue of the
8022generated assembly file. Under DEC Unix, this has the effect that
8023IEEE-conformant math library routines will be linked in.
8024
8025@item -mbuild-constants
cd3bb277 8026@opindex mbuild-constants
0c2d1a2a 8027Normally GCC examines a 32- or 64-bit integer constant to
74291a4b
MM
8028see if it can construct it from smaller constants in two or three
8029instructions. If it cannot, it will output the constant as a literal and
956d6950 8030generate code to load it from the data segment at runtime.
74291a4b 8031
0c2d1a2a 8032Use this option to require GCC to construct @emph{all} integer constants
74291a4b
MM
8033using code, even if it takes more instructions (the maximum is six).
8034
8035You would typically use this option to build a shared library dynamic
8036loader. Itself a shared library, it must relocate itself in memory
8037before it can find the variables and constants in its own data segment.
956d6950
JL
8038
8039@item -malpha-as
8040@itemx -mgas
cd3bb277
JM
8041@opindex malpha-as
8042@opindex mgas
956d6950 8043Select whether to generate code to be assembled by the vendor-supplied
630d3d5a 8044assembler (@option{-malpha-as}) or by the GNU assembler @option{-mgas}.
956d6950
JL
8045
8046@item -mbwx
8047@itemx -mno-bwx
8048@itemx -mcix
8049@itemx -mno-cix
8050@itemx -mmax
8051@itemx -mno-max
cd3bb277
JM
8052@opindex mbwx
8053@opindex mno-bwx
8054@opindex mcix
8055@opindex mno-cix
8056@opindex mmax
8057@opindex mno-max
0c2d1a2a 8058Indicate whether GCC should generate code to use the optional BWX,
956d6950 8059CIX, and MAX instruction sets. The default is to use the instruction sets
630d3d5a 8060supported by the CPU type specified via @option{-mcpu=} option or that
0c2d1a2a 8061of the CPU on which GCC was built if none was specified.
956d6950 8062
956d6950 8063@item -mcpu=@var{cpu_type}
cd3bb277 8064@opindex mcpu
956d6950
JL
8065Set the instruction set, register set, and instruction scheduling
8066parameters for machine type @var{cpu_type}. You can specify either the
0c2d1a2a 8067@samp{EV} style name or the corresponding chip number. GCC
956d6950
JL
8068supports scheduling parameters for the EV4 and EV5 family of processors
8069and will choose the default values for the instruction set from
8070the processor you specify. If you do not specify a processor type,
0c2d1a2a 8071GCC will default to the processor on which the compiler was built.
956d6950
JL
8072
8073Supported values for @var{cpu_type} are
8074
8075@table @samp
8076@item ev4
8077@itemx 21064
8078Schedules as an EV4 and has no instruction set extensions.
8079
8080@item ev5
8081@itemx 21164
8082Schedules as an EV5 and has no instruction set extensions.
8083
8084@item ev56
8085@itemx 21164a
8086Schedules as an EV5 and supports the BWX extension.
8087
8088@item pca56
4f69985c 8089@itemx 21164pc
956d6950
JL
8090@itemx 21164PC
8091Schedules as an EV5 and supports the BWX and MAX extensions.
8092
8093@item ev6
8094@itemx 21264
8095Schedules as an EV5 (until Digital releases the scheduling parameters
8096for the EV6) and supports the BWX, CIX, and MAX extensions.
4f69985c
RH
8097@end table
8098
8099@item -mmemory-latency=@var{time}
cd3bb277 8100@opindex mmemory-latency
4f69985c
RH
8101Sets the latency the scheduler should assume for typical memory
8102references as seen by the application. This number is highly
b192711e 8103dependent on the memory access patterns used by the application
4f69985c
RH
8104and the size of the external cache on the machine.
8105
8106Valid options for @var{time} are
8107
8108@table @samp
8109@item @var{number}
8110A decimal number representing clock cycles.
8111
8112@item L1
8113@itemx L2
8114@itemx L3
8115@itemx main
8116The compiler contains estimates of the number of clock cycles for
8117``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
8118(also called Dcache, Scache, and Bcache), as well as to main memory.
8119Note that L3 is only valid for EV5.
8120
956d6950 8121@end table
74291a4b
MM
8122@end table
8123
8124@node Clipper Options
8125@subsection Clipper Options
8126
8127These @samp{-m} options are defined for the Clipper implementations:
8128
2642624b 8129@table @gcctabopt
74291a4b 8130@item -mc300
cd3bb277 8131@opindex mc300
767094dd 8132Produce code for a C300 Clipper processor. This is the default.
74291a4b 8133
62a1403d 8134@item -mc400
cd3bb277 8135@opindex mc400
9c34dbbf
ZW
8136Produce code for a C400 Clipper processor, i.e.@: use floating point
8137registers f8--f15.
74291a4b
MM
8138@end table
8139
8140@node H8/300 Options
8141@subsection H8/300 Options
8142
8143These @samp{-m} options are defined for the H8/300 implementations:
8144
2642624b 8145@table @gcctabopt
74291a4b 8146@item -mrelax
cd3bb277 8147@opindex mrelax
74291a4b 8148Shorten some address references at link time, when possible; uses the
630d3d5a 8149linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
74291a4b
MM
8150ld.info, Using ld}, for a fuller description.
8151
8152@item -mh
cd3bb277 8153@opindex mh
161d7b59 8154Generate code for the H8/300H@.
74291a4b 8155
dcb9d1f0 8156@item -ms
cd3bb277 8157@opindex ms
161d7b59 8158Generate code for the H8/S@.
dcb9d1f0 8159
17f0f8fa 8160@item -ms2600
cd3bb277 8161@opindex ms2600
695ac33f 8162Generate code for the H8/S2600. This switch must be used with @option{-ms}.
17f0f8fa 8163
74291a4b 8164@item -mint32
cd3bb277 8165@opindex mint32
74291a4b
MM
8166Make @code{int} data 32 bits by default.
8167
8168@item -malign-300
cd3bb277 8169@opindex malign-300
2c54abce
KH
8170On the H8/300H and H8/S, use the same alignment rules as for the H8/300.
8171The default for the H8/300H and H8/S is to align longs and floats on 4
8172byte boundaries.
630d3d5a 8173@option{-malign-300} causes them to be aligned on 2 byte boundaries.
2c54abce 8174This option has no effect on the H8/300.
74291a4b
MM
8175@end table
8176
8177@node SH Options
8178@subsection SH Options
8179
8180These @samp{-m} options are defined for the SH implementations:
8181
2642624b 8182@table @gcctabopt
74291a4b 8183@item -m1
cd3bb277 8184@opindex m1
74291a4b
MM
8185Generate code for the SH1.
8186
8187@item -m2
cd3bb277 8188@opindex m2
74291a4b
MM
8189Generate code for the SH2.
8190
8191@item -m3
cd3bb277 8192@opindex m3
74291a4b
MM
8193Generate code for the SH3.
8194
8195@item -m3e
cd3bb277 8196@opindex m3e
74291a4b
MM
8197Generate code for the SH3e.
8198
3cadd778 8199@item -m4-nofpu
cd3bb277 8200@opindex m4-nofpu
3cadd778
AO
8201Generate code for the SH4 without a floating-point unit.
8202
8203@item -m4-single-only
cd3bb277 8204@opindex m4-single-only
3cadd778 8205Generate code for the SH4 with a floating-point unit that only
c771326b 8206supports single-precision arithmetic.
3cadd778
AO
8207
8208@item -m4-single
cd3bb277 8209@opindex m4-single
3cadd778
AO
8210Generate code for the SH4 assuming the floating-point unit is in
8211single-precision mode by default.
8212
8213@item -m4
cd3bb277 8214@opindex m4
3cadd778
AO
8215Generate code for the SH4.
8216
74291a4b 8217@item -mb
cd3bb277 8218@opindex mb
74291a4b
MM
8219Compile code for the processor in big endian mode.
8220
8221@item -ml
cd3bb277 8222@opindex ml
74291a4b
MM
8223Compile code for the processor in little endian mode.
8224
3d5a0820 8225@item -mdalign
cd3bb277 8226@opindex mdalign
02f52e19 8227Align doubles at 64-bit boundaries. Note that this changes the calling
3d5a0820 8228conventions, and thus some functions from the standard C library will
695ac33f 8229not work unless you recompile it first with @option{-mdalign}.
3d5a0820 8230
74291a4b 8231@item -mrelax
cd3bb277 8232@opindex mrelax
74291a4b 8233Shorten some address references at link time, when possible; uses the
630d3d5a 8234linker option @option{-relax}.
3cadd778
AO
8235
8236@item -mbigtable
cd3bb277 8237@opindex mbigtable
3cadd778
AO
8238Use 32-bit offsets in @code{switch} tables. The default is to use
823916-bit offsets.
8240
8241@item -mfmovd
cd3bb277 8242@opindex mfmovd
3cadd778
AO
8243Enable the use of the instruction @code{fmovd}.
8244
8245@item -mhitachi
cd3bb277 8246@opindex mhitachi
3cadd778
AO
8247Comply with the calling conventions defined by Hitachi.
8248
8249@item -mnomacsave
cd3bb277 8250@opindex mnomacsave
3cadd778 8251Mark the @code{MAC} register as call-clobbered, even if
bedc7537 8252@option{-mhitachi} is given.
3cadd778 8253
c474f76b
AO
8254@item -mieee
8255@opindex mieee
8256Increase IEEE-compliance of floating-point code.
8257
3cadd778 8258@item -misize
cd3bb277 8259@opindex misize
3cadd778
AO
8260Dump instruction size and location in the assembly code.
8261
8262@item -mpadstruct
cd3bb277 8263@opindex mpadstruct
3cadd778 8264This option is deprecated. It pads structures to multiple of 4 bytes,
161d7b59 8265which is incompatible with the SH ABI@.
3cadd778
AO
8266
8267@item -mspace
cd3bb277 8268@opindex mspace
bedc7537 8269Optimize for space instead of speed. Implied by @option{-Os}.
1a66cd67
AO
8270
8271@item -mprefergot
cd3bb277 8272@opindex mprefergot
1a66cd67
AO
8273When generating position-independent code, emit function calls using
8274the Global Offset Table instead of the Procedure Linkage Table.
93ca1662
NY
8275
8276@item -musermode
cd3bb277 8277@opindex musermode
93ca1662
NY
8278Generate a library function call to invalidate instruction cache
8279entries, after fixing up a trampoline. This library function call
8280doesn't assume it can write to the whole memory address space. This
8281is the default when the target is @code{sh-*-linux*}.
74291a4b
MM
8282@end table
8283
8284@node System V Options
8285@subsection Options for System V
8286
8287These additional options are available on System V Release 4 for
8288compatibility with other compilers on those systems:
8289
2642624b 8290@table @gcctabopt
74291a4b 8291@item -G
cd3bb277 8292@opindex G
74291a4b 8293Create a shared object.
630d3d5a 8294It is recommended that @option{-symbolic} or @option{-shared} be used instead.
74291a4b
MM
8295
8296@item -Qy
cd3bb277 8297@opindex Qy
74291a4b
MM
8298Identify the versions of each tool used by the compiler, in a
8299@code{.ident} assembler directive in the output.
8300
8301@item -Qn
cd3bb277 8302@opindex Qn
74291a4b
MM
8303Refrain from adding @code{.ident} directives to the output file (this is
8304the default).
8305
aee96fe9 8306@item -YP,@var{dirs}
cd3bb277 8307@opindex YP
74291a4b 8308Search the directories @var{dirs}, and no others, for libraries
630d3d5a 8309specified with @option{-l}.
74291a4b 8310
aee96fe9 8311@item -Ym,@var{dir}
cd3bb277 8312@opindex Ym
bedc7537 8313Look in the directory @var{dir} to find the M4 preprocessor.
74291a4b
MM
8314The assembler uses this option.
8315@c This is supposed to go with a -Yd for predefined M4 macro files, but
8316@c the generic assembler that comes with Solaris takes just -Ym.
8317@end table
8318
282a61e6
MH
8319@node TMS320C3x/C4x Options
8320@subsection TMS320C3x/C4x Options
8321@cindex TMS320C3x/C4x Options
8322
8323These @samp{-m} options are defined for TMS320C3x/C4x implementations:
8324
2642624b 8325@table @gcctabopt
282a61e6
MH
8326
8327@item -mcpu=@var{cpu_type}
cd3bb277 8328@opindex mcpu
282a61e6
MH
8329Set the instruction set, register set, and instruction scheduling
8330parameters for machine type @var{cpu_type}. Supported values for
8331@var{cpu_type} are @samp{c30}, @samp{c31}, @samp{c32}, @samp{c40}, and
8332@samp{c44}. The default is @samp{c40} to generate code for the
8333TMS320C40.
8334
8335@item -mbig-memory
8336@item -mbig
8337@itemx -msmall-memory
8338@itemx -msmall
cd3bb277
JM
8339@opindex mbig-memory
8340@opindex mbig
8341@opindex msmall-memory
8342@opindex msmall
282a61e6
MH
8343Generates code for the big or small memory model. The small memory
8344model assumed that all data fits into one 64K word page. At run-time
8345the data page (DP) register must be set to point to the 64K page
8346containing the .bss and .data program sections. The big memory model is
8347the default and requires reloading of the DP register for every direct
8348memory access.
8349
8350@item -mbk
8351@itemx -mno-bk
cd3bb277
JM
8352@opindex mbk
8353@opindex mno-bk
282a61e6 8354Allow (disallow) allocation of general integer operands into the block
161d7b59 8355count register BK@.
282a61e6
MH
8356
8357@item -mdb
8358@itemx -mno-db
cd3bb277
JM
8359@opindex mdb
8360@opindex mno-db
282a61e6
MH
8361Enable (disable) generation of code using decrement and branch,
8362DBcond(D), instructions. This is enabled by default for the C4x. To be
8363on the safe side, this is disabled for the C3x, since the maximum
aee96fe9
JM
8364iteration count on the C3x is @math{2^23 + 1} (but who iterates loops more than
8365@math{2^23} times on the C3x?). Note that GCC will try to reverse a loop so
282a61e6
MH
8366that it can utilise the decrement and branch instruction, but will give
8367up if there is more than one memory reference in the loop. Thus a loop
8368where the loop counter is decremented can generate slightly more
8369efficient code, in cases where the RPTB instruction cannot be utilised.
8370
8371@item -mdp-isr-reload
8372@itemx -mparanoid
cd3bb277
JM
8373@opindex mdp-isr-reload
8374@opindex mparanoid
282a61e6
MH
8375Force the DP register to be saved on entry to an interrupt service
8376routine (ISR), reloaded to point to the data section, and restored on
161d7b59 8377exit from the ISR@. This should not be required unless someone has
282a61e6
MH
8378violated the small memory model by modifying the DP register, say within
8379an object library.
8380
8381@item -mmpyi
8382@itemx -mno-mpyi
cd3bb277
JM
8383@opindex mmpyi
8384@opindex mno-mpyi
282a61e6
MH
8385For the C3x use the 24-bit MPYI instruction for integer multiplies
8386instead of a library call to guarantee 32-bit results. Note that if one
8387of the operands is a constant, then the multiplication will be performed
695ac33f 8388using shifts and adds. If the @option{-mmpyi} option is not specified for the C3x,
282a61e6
MH
8389then squaring operations are performed inline instead of a library call.
8390
8391@item -mfast-fix
8392@itemx -mno-fast-fix
cd3bb277
JM
8393@opindex mfast-fix
8394@opindex mno-fast-fix
282a61e6
MH
8395The C3x/C4x FIX instruction to convert a floating point value to an
8396integer value chooses the nearest integer less than or equal to the
8397floating point value rather than to the nearest integer. Thus if the
8398floating point number is negative, the result will be incorrectly
8399truncated an additional code is necessary to detect and correct this
8400case. This option can be used to disable generation of the additional
8401code required to correct the result.
8402
8403@item -mrptb
8404@itemx -mno-rptb
cd3bb277
JM
8405@opindex mrptb
8406@opindex mno-rptb
282a61e6
MH
8407Enable (disable) generation of repeat block sequences using the RPTB
8408instruction for zero overhead looping. The RPTB construct is only used
8409for innermost loops that do not call functions or jump across the loop
8410boundaries. There is no advantage having nested RPTB loops due to the
8411overhead required to save and restore the RC, RS, and RE registers.
695ac33f 8412This is enabled by default with @option{-O2}.
282a61e6
MH
8413
8414@item -mrpts=@var{count}
8415@itemx -mno-rpts
cd3bb277
JM
8416@opindex mrpts
8417@opindex mno-rpts
282a61e6 8418Enable (disable) the use of the single instruction repeat instruction
161d7b59 8419RPTS@. If a repeat block contains a single instruction, and the loop
282a61e6 8420count can be guaranteed to be less than the value @var{count}, GCC will
161d7b59 8421emit a RPTS instruction instead of a RPTB@. If no value is specified,
282a61e6
MH
8422then a RPTS will be emitted even if the loop count cannot be determined
8423at compile time. Note that the repeated instruction following RPTS does
8424not have to be reloaded from memory each iteration, thus freeing up the
b192711e 8425CPU buses for operands. However, since interrupts are blocked by this
282a61e6
MH
8426instruction, it is disabled by default.
8427
8428@item -mloop-unsigned
8429@itemx -mno-loop-unsigned
cd3bb277
JM
8430@opindex mloop-unsigned
8431@opindex mno-loop-unsigned
282a61e6 8432The maximum iteration count when using RPTS and RPTB (and DB on the C40)
aee96fe9 8433is @math{2^31 + 1} since these instructions test if the iteration count is
282a61e6 8434negative to terminate the loop. If the iteration count is unsigned
aee96fe9 8435there is a possibility than the @math{2^31 + 1} maximum iteration count may be
282a61e6
MH
8436exceeded. This switch allows an unsigned iteration count.
8437
8438@item -mti
cd3bb277 8439@opindex mti
282a61e6
MH
8440Try to emit an assembler syntax that the TI assembler (asm30) is happy
8441with. This also enforces compatibility with the API employed by the TI
8442C3x C compiler. For example, long doubles are passed as structures
8443rather than in floating point registers.
8444
8445@item -mregparm
8446@itemx -mmemparm
cd3bb277
JM
8447@opindex mregparm
8448@opindex mmemparm
282a61e6
MH
8449Generate code that uses registers (stack) for passing arguments to functions.
8450By default, arguments are passed in registers where possible rather
8451than by pushing arguments on to the stack.
8452
8453@item -mparallel-insns
8454@itemx -mno-parallel-insns
cd3bb277
JM
8455@opindex mparallel-insns
8456@opindex mno-parallel-insns
282a61e6 8457Allow the generation of parallel instructions. This is enabled by
695ac33f 8458default with @option{-O2}.
282a61e6
MH
8459
8460@item -mparallel-mpy
8461@itemx -mno-parallel-mpy
cd3bb277
JM
8462@opindex mparallel-mpy
8463@opindex mno-parallel-mpy
282a61e6 8464Allow the generation of MPY||ADD and MPY||SUB parallel instructions,
695ac33f 8465provided @option{-mparallel-insns} is also specified. These instructions have
282a61e6
MH
8466tight register constraints which can pessimize the code generation
8467of large functions.
8468
8469@end table
8470
f84271d9
JL
8471@node V850 Options
8472@subsection V850 Options
8473@cindex V850 Options
8474
8475These @samp{-m} options are defined for V850 implementations:
8476
2642624b 8477@table @gcctabopt
f84271d9
JL
8478@item -mlong-calls
8479@itemx -mno-long-calls
cd3bb277
JM
8480@opindex mlong-calls
8481@opindex mno-long-calls
f84271d9
JL
8482Treat all calls as being far away (near). If calls are assumed to be
8483far away, the compiler will always load the functions address up into a
8484register, and call indirect through the pointer.
8485
8486@item -mno-ep
bd762873 8487@itemx -mep
cd3bb277
JM
8488@opindex mno-ep
8489@opindex mep
f84271d9
JL
8490Do not optimize (do optimize) basic blocks that use the same index
8491pointer 4 or more times to copy pointer into the @code{ep} register, and
630d3d5a 8492use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
f84271d9
JL
8493option is on by default if you optimize.
8494
8495@item -mno-prolog-function
8496@itemx -mprolog-function
cd3bb277
JM
8497@opindex mno-prolog-function
8498@opindex mprolog-function
f84271d9
JL
8499Do not use (do use) external functions to save and restore registers at
8500the prolog and epilog of a function. The external functions are slower,
8501but use less code space if more than one function saves the same number
630d3d5a 8502of registers. The @option{-mprolog-function} option is on by default if
f84271d9
JL
8503you optimize.
8504
8505@item -mspace
cd3bb277 8506@opindex mspace
f84271d9 8507Try to make the code as small as possible. At present, this just turns
630d3d5a 8508on the @option{-mep} and @option{-mprolog-function} options.
f84271d9
JL
8509
8510@item -mtda=@var{n}
cd3bb277 8511@opindex mtda
f84271d9
JL
8512Put static or global variables whose size is @var{n} bytes or less into
8513the tiny data area that register @code{ep} points to. The tiny data
8514area can hold up to 256 bytes in total (128 bytes for byte references).
8515
8516@item -msda=@var{n}
cd3bb277 8517@opindex msda
f84271d9
JL
8518Put static or global variables whose size is @var{n} bytes or less into
8519the small data area that register @code{gp} points to. The small data
8520area can hold up to 64 kilobytes.
8521
8522@item -mzda=@var{n}
cd3bb277 8523@opindex mzda
f84271d9
JL
8524Put static or global variables whose size is @var{n} bytes or less into
8525the first 32 kilobytes of memory.
02f52e19 8526
48f0be1b 8527@item -mv850
cd3bb277 8528@opindex mv850
48f0be1b
SC
8529Specify that the target processor is the V850.
8530
e9a25f70 8531@item -mbig-switch
cd3bb277 8532@opindex mbig-switch
e9a25f70
JL
8533Generate code suitable for big switch tables. Use this option only if
8534the assembler/linker complain about out of range branches within a switch
8535table.
f84271d9
JL
8536@end table
8537
56b2d7a7
JL
8538@node ARC Options
8539@subsection ARC Options
8540@cindex ARC Options
8541
8542These options are defined for ARC implementations:
8543
2642624b 8544@table @gcctabopt
56b2d7a7 8545@item -EL
cd3bb277 8546@opindex EL
56b2d7a7
JL
8547Compile code for little endian mode. This is the default.
8548
8549@item -EB
cd3bb277 8550@opindex EB
56b2d7a7
JL
8551Compile code for big endian mode.
8552
8553@item -mmangle-cpu
cd3bb277 8554@opindex mmangle-cpu
56b2d7a7
JL
8555Prepend the name of the cpu to all public symbol names.
8556In multiple-processor systems, there are many ARC variants with different
8557instruction and register set characteristics. This flag prevents code
8558compiled for one cpu to be linked with code compiled for another.
695ac33f 8559No facility exists for handling variants that are ``almost identical''.
56b2d7a7
JL
8560This is an all or nothing option.
8561
8562@item -mcpu=@var{cpu}
cd3bb277 8563@opindex mcpu
56b2d7a7
JL
8564Compile code for ARC variant @var{cpu}.
8565Which variants are supported depend on the configuration.
630d3d5a 8566All variants support @option{-mcpu=base}, this is the default.
56b2d7a7 8567
630d3d5a
JM
8568@item -mtext=@var{text-section}
8569@itemx -mdata=@var{data-section}
8570@itemx -mrodata=@var{readonly-data-section}
cd3bb277
JM
8571@opindex mtext
8572@opindex mdata
8573@opindex mrodata
630d3d5a
JM
8574Put functions, data, and readonly data in @var{text-section},
8575@var{data-section}, and @var{readonly-data-section} respectively
56b2d7a7 8576by default. This can be overridden with the @code{section} attribute.
0b433de6 8577@xref{Variable Attributes}.
56b2d7a7
JL
8578
8579@end table
8580
83575957
ID
8581@node NS32K Options
8582@subsection NS32K Options
8583@cindex NS32K options
8584
8585These are the @samp{-m} options defined for the 32000 series. The default
8586values for these options depends on which style of 32000 was selected when
8587the compiler was configured; the defaults for the most common choices are
8588given below.
8589
2642624b 8590@table @gcctabopt
83575957
ID
8591@item -m32032
8592@itemx -m32032
cd3bb277
JM
8593@opindex m32032
8594@opindex m32032
83575957
ID
8595Generate output for a 32032. This is the default
8596when the compiler is configured for 32032 and 32016 based systems.
8597
8598@item -m32332
8599@itemx -m32332
cd3bb277
JM
8600@opindex m32332
8601@opindex m32332
83575957
ID
8602Generate output for a 32332. This is the default
8603when the compiler is configured for 32332-based systems.
8604
8605@item -m32532
8606@itemx -m32532
cd3bb277
JM
8607@opindex m32532
8608@opindex m32532
83575957
ID
8609Generate output for a 32532. This is the default
8610when the compiler is configured for 32532-based systems.
8611
8612@item -m32081
cd3bb277 8613@opindex m32081
83575957
ID
8614Generate output containing 32081 instructions for floating point.
8615This is the default for all systems.
8616
8617@item -m32381
cd3bb277 8618@opindex m32381
83575957 8619Generate output containing 32381 instructions for floating point. This
767094dd
JM
8620also implies @option{-m32081}. The 32381 is only compatible with the 32332
8621and 32532 cpus. This is the default for the pc532-netbsd configuration.
83575957
ID
8622
8623@item -mmulti-add
cd3bb277 8624@opindex mmulti-add
83575957 8625Try and generate multiply-add floating point instructions @code{polyF}
767094dd
JM
8626and @code{dotF}. This option is only available if the @option{-m32381}
8627option is in effect. Using these instructions requires changes to to
83575957
ID
8628register allocation which generally has a negative impact on
8629performance. This option should only be enabled when compiling code
8630particularly likely to make heavy use of multiply-add instructions.
8631
8632@item -mnomulti-add
cd3bb277 8633@opindex mnomulti-add
83575957 8634Do not try and generate multiply-add floating point instructions
767094dd 8635@code{polyF} and @code{dotF}. This is the default on all platforms.
83575957
ID
8636
8637@item -msoft-float
cd3bb277 8638@opindex msoft-float
83575957
ID
8639Generate output containing library calls for floating point.
8640@strong{Warning:} the requisite libraries may not be available.
8641
8642@item -mnobitfield
cd3bb277 8643@opindex mnobitfield
767094dd
JM
8644Do not use the bit-field instructions. On some machines it is faster to
8645use shifting and masking operations. This is the default for the pc532.
83575957
ID
8646
8647@item -mbitfield
cd3bb277 8648@opindex mbitfield
767094dd 8649Do use the bit-field instructions. This is the default for all platforms
83575957
ID
8650except the pc532.
8651
8652@item -mrtd
cd3bb277 8653@opindex mrtd
83575957
ID
8654Use a different function-calling convention, in which functions
8655that take a fixed number of arguments return pop their
8656arguments on return with the @code{ret} instruction.
8657
8658This calling convention is incompatible with the one normally
8659used on Unix, so you cannot use it if you need to call libraries
8660compiled with the Unix compiler.
8661
8662Also, you must provide function prototypes for all functions that
8663take variable numbers of arguments (including @code{printf});
8664otherwise incorrect code will be generated for calls to those
8665functions.
8666
8667In addition, seriously incorrect code will result if you call a
8668function with too many arguments. (Normally, extra arguments are
8669harmlessly ignored.)
8670
8671This option takes its name from the 680x0 @code{rtd} instruction.
8672
8673
8674@item -mregparam
cd3bb277 8675@opindex mregparam
83575957
ID
8676Use a different function-calling convention where the first two arguments
8677are passed in registers.
8678
8679This calling convention is incompatible with the one normally
8680used on Unix, so you cannot use it if you need to call libraries
8681compiled with the Unix compiler.
8682
8683@item -mnoregparam
cd3bb277 8684@opindex mnoregparam
767094dd 8685Do not pass any arguments in registers. This is the default for all
83575957
ID
8686targets.
8687
8688@item -msb
cd3bb277 8689@opindex msb
83575957 8690It is OK to use the sb as an index register which is always loaded with
767094dd 8691zero. This is the default for the pc532-netbsd target.
83575957
ID
8692
8693@item -mnosb
cd3bb277 8694@opindex mnosb
83575957 8695The sb register is not available for use or has not been initialized to
767094dd
JM
8696zero by the run time system. This is the default for all targets except
8697the pc532-netbsd. It is also implied whenever @option{-mhimem} or
630d3d5a 8698@option{-fpic} is set.
83575957
ID
8699
8700@item -mhimem
cd3bb277 8701@opindex mhimem
161d7b59 8702Many ns32000 series addressing modes use displacements of up to 512MB@.
83575957 8703If an address is above 512MB then displacements from zero can not be used.
161d7b59 8704This option causes code to be generated which can be loaded above 512MB@.
83575957
ID
8705This may be useful for operating systems or ROM code.
8706
8707@item -mnohimem
cd3bb277 8708@opindex mnohimem
83575957
ID
8709Assume code will be loaded in the first 512MB of virtual address space.
8710This is the default for all platforms.
8711
8712
8713@end table
8714
052a4b28
DC
8715@node AVR Options
8716@subsection AVR Options
8717@cindex AVR Options
8718
8719These options are defined for AVR implementations:
8720
2642624b 8721@table @gcctabopt
052a4b28 8722@item -mmcu=@var{mcu}
cd3bb277 8723@opindex mmcu
3a69a7d5
MM
8724Specify ATMEL AVR instruction set or MCU type.
8725
8726Instruction set avr1 is for the minimal AVR core, not supported by the C
8727compiler, only for assembler programs (MCU types: at90s1200, attiny10,
8728attiny11, attiny12, attiny15, attiny28).
8729
8730Instruction set avr2 (default) is for the classic AVR core with up to
87318K program memory space (MCU types: at90s2313, at90s2323, attiny22,
8732at90s2333, at90s2343, at90s4414, at90s4433, at90s4434, at90s8515,
8733at90c8534, at90s8535).
8734
8735Instruction set avr3 is for the classic AVR core with up to 128K program
8736memory space (MCU types: atmega103, atmega603).
8737
8738Instruction set avr4 is for the enhanced AVR core with up to 8K program
8739memory space (MCU types: atmega83, atmega85).
8740
8741Instruction set avr5 is for the enhanced AVR core with up to 128K program
8742memory space (MCU types: atmega161, atmega163, atmega32, at94k).
052a4b28
DC
8743
8744@item -msize
cd3bb277 8745@opindex msize
3a69a7d5 8746Output instruction sizes to the asm file.
052a4b28
DC
8747
8748@item -minit-stack=@var{N}
cd3bb277 8749@opindex minit-stack
3a69a7d5 8750Specify the initial stack address, which may be a symbol or numeric value,
aee96fe9 8751@samp{__stack} is the default.
052a4b28
DC
8752
8753@item -mno-interrupts
cd3bb277 8754@opindex mno-interrupts
052a4b28
DC
8755Generated code is not compatible with hardware interrupts.
8756Code size will be smaller.
8757
8758@item -mcall-prologues
cd3bb277 8759@opindex mcall-prologues
052a4b28 8760Functions prologues/epilogues expanded as call to appropriate
767094dd 8761subroutines. Code size will be smaller.
3a69a7d5
MM
8762
8763@item -mno-tablejump
cd3bb277 8764@opindex mno-tablejump
3a69a7d5
MM
8765Do not generate tablejump insns which sometimes increase code size.
8766
8767@item -mtiny-stack
cd3bb277 8768@opindex mtiny-stack
3a69a7d5 8769Change only the low 8 bits of the stack pointer.
052a4b28
DC
8770@end table
8771
789a3090
NC
8772@node MCore Options
8773@subsection MCore Options
8774@cindex MCore options
8775
8776These are the @samp{-m} options defined for the Motorola M*Core
02f52e19 8777processors.
789a3090 8778
2642624b 8779@table @gcctabopt
789a3090
NC
8780
8781@item -mhardlit
8782@itemx -mhardlit
8783@itemx -mno-hardlit
cd3bb277
JM
8784@opindex mhardlit
8785@opindex mhardlit
8786@opindex mno-hardlit
789a3090
NC
8787Inline constants into the code stream if it can be done in two
8788instructions or less.
8789
8790@item -mdiv
8791@itemx -mdiv
8792@itemx -mno-div
cd3bb277
JM
8793@opindex mdiv
8794@opindex mdiv
8795@opindex mno-div
789a3090
NC
8796Use the divide instruction. (Enabled by default).
8797
8798@item -mrelax-immediate
8799@itemx -mrelax-immediate
8800@itemx -mno-relax-immediate
cd3bb277
JM
8801@opindex mrelax-immediate
8802@opindex mrelax-immediate
8803@opindex mno-relax-immediate
b192711e 8804Allow arbitrary sized immediates in bit operations.
789a3090
NC
8805
8806@item -mwide-bitfields
8807@itemx -mwide-bitfields
8808@itemx -mno-wide-bitfields
cd3bb277
JM
8809@opindex mwide-bitfields
8810@opindex mwide-bitfields
8811@opindex mno-wide-bitfields
c771326b 8812Always treat bit-fields as int-sized.
789a3090
NC
8813
8814@item -m4byte-functions
8815@itemx -m4byte-functions
8816@itemx -mno-4byte-functions
cd3bb277
JM
8817@opindex m4byte-functions
8818@opindex m4byte-functions
8819@opindex mno-4byte-functions
b192711e 8820Force all functions to be aligned to a four byte boundary.
789a3090
NC
8821
8822@item -mcallgraph-data
8823@itemx -mcallgraph-data
8824@itemx -mno-callgraph-data
cd3bb277
JM
8825@opindex mcallgraph-data
8826@opindex mcallgraph-data
8827@opindex mno-callgraph-data
789a3090
NC
8828Emit callgraph information.
8829
8830@item -mslow-bytes
8831@itemx -mslow-bytes
8832@itemx -mno-slow-bytes
cd3bb277
JM
8833@opindex mslow-bytes
8834@opindex mslow-bytes
8835@opindex mno-slow-bytes
789a3090
NC
8836Prefer word access when reading byte quantities.
8837
8838@item -mlittle-endian
8839@itemx -mlittle-endian
8840@itemx -mbig-endian
cd3bb277
JM
8841@opindex mlittle-endian
8842@opindex mlittle-endian
8843@opindex mbig-endian
b192711e 8844Generate code for a little endian target.
789a3090
NC
8845
8846@item -m210
8847@itemx -m210
8848@itemx -m340
cd3bb277
JM
8849@opindex m210
8850@opindex m210
8851@opindex m340
789a3090 8852Generate code for the 210 processor.
789a3090 8853@end table
83575957 8854
df6194d4
JW
8855@node IA-64 Options
8856@subsection IA-64 Options
8857@cindex IA-64 Options
8858
8859These are the @samp{-m} options defined for the Intel IA-64 architecture.
8860
8861@table @gcctabopt
8862@item -mbig-endian
cd3bb277 8863@opindex mbig-endian
161d7b59 8864Generate code for a big endian target. This is the default for HPUX@.
df6194d4
JW
8865
8866@item -mlittle-endian
cd3bb277 8867@opindex mlittle-endian
df6194d4
JW
8868Generate code for a little endian target. This is the default for AIX5
8869and Linux.
8870
8871@item -mgnu-as
8872@itemx -mno-gnu-as
cd3bb277
JM
8873@opindex mgnu-as
8874@opindex mno-gnu-as
15d3a111 8875Generate (or don't) code for the GNU assembler. This is the default.
630d3d5a 8876@c Also, this is the default if the configure option @option{--with-gnu-as}
15d3a111 8877@c is used.
df6194d4
JW
8878
8879@item -mgnu-ld
8880@itemx -mno-gnu-ld
cd3bb277
JM
8881@opindex mgnu-ld
8882@opindex mno-gnu-ld
15d3a111 8883Generate (or don't) code for the GNU linker. This is the default.
630d3d5a 8884@c Also, this is the default if the configure option @option{--with-gnu-ld}
15d3a111 8885@c is used.
df6194d4
JW
8886
8887@item -mno-pic
cd3bb277 8888@opindex mno-pic
15d3a111 8889Generate code that does not use a global pointer register. The result
161d7b59 8890is not position independent code, and violates the IA-64 ABI@.
df6194d4
JW
8891
8892@item -mvolatile-asm-stop
8893@itemx -mno-volatile-asm-stop
cd3bb277
JM
8894@opindex mvolatile-asm-stop
8895@opindex mno-volatile-asm-stop
15d3a111
JW
8896Generate (or don't) a stop bit immediately before and after volatile asm
8897statements.
df6194d4
JW
8898
8899@item -mb-step
cd3bb277 8900@opindex mb-step
df6194d4
JW
8901Generate code that works around Itanium B step errata.
8902
8903@item -mregister-names
8904@itemx -mno-register-names
cd3bb277
JM
8905@opindex mregister-names
8906@opindex mno-register-names
15d3a111
JW
8907Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
8908the stacked registers. This may make assembler output more readable.
df6194d4
JW
8909
8910@item -mno-sdata
8911@itemx -msdata
cd3bb277
JM
8912@opindex mno-sdata
8913@opindex msdata
15d3a111
JW
8914Disable (or enable) optimizations that use the small data section. This may
8915be useful for working around optimizer bugs.
df6194d4
JW
8916
8917@item -mconstant-gp
cd3bb277 8918@opindex mconstant-gp
df6194d4
JW
8919Generate code that uses a single constant global pointer value. This is
8920useful when compiling kernel code.
8921
8922@item -mauto-pic
cd3bb277 8923@opindex mauto-pic
630d3d5a 8924Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
df6194d4
JW
8925This is useful when compiling firmware code.
8926
8927@item -minline-divide-min-latency
cd3bb277 8928@opindex minline-divide-min-latency
df6194d4
JW
8929Generate code for inline divides using the minimum latency algorithm.
8930
8931@item -minline-divide-max-throughput
cd3bb277 8932@opindex minline-divide-max-throughput
df6194d4
JW
8933Generate code for inline divides using the maximum throughput algorithm.
8934
8935@item -mno-dwarf2-asm
8936@itemx -mdwarf2-asm
cd3bb277
JM
8937@opindex mno-dwarf2-asm
8938@opindex mdwarf2-asm
15d3a111
JW
8939Don't (or do) generate assembler code for the DWARF2 line number debugging
8940info. This may be useful when not using the GNU assembler.
df6194d4 8941
630d3d5a 8942@item -mfixed-range=@var{register-range}
cd3bb277 8943@opindex mfixed-range
df6194d4
JW
8944Generate code treating the given register range as fixed registers.
8945A fixed register is one that the register allocator can not use. This is
8946useful when compiling kernel code. A register range is specified as
8947two registers separated by a dash. Multiple register ranges can be
8948specified separated by a comma.
8949@end table
8950
e8ad90e5
MM
8951@node D30V Options
8952@subsection D30V Options
8953@cindex D30V Options
8954
8955These @samp{-m} options are defined for D30V implementations:
8956
2642624b 8957@table @gcctabopt
e8ad90e5 8958@item -mextmem
cd3bb277 8959@opindex mextmem
e8ad90e5
MM
8960Link the @samp{.text}, @samp{.data}, @samp{.bss}, @samp{.strings},
8961@samp{.rodata}, @samp{.rodata1}, @samp{.data1} sections into external
8962memory, which starts at location @code{0x80000000}.
8963
8964@item -mextmemory
cd3bb277 8965@opindex mextmemory
630d3d5a 8966Same as the @option{-mextmem} switch.
e8ad90e5
MM
8967
8968@item -monchip
cd3bb277 8969@opindex monchip
e8ad90e5
MM
8970Link the @samp{.text} section into onchip text memory, which starts at
8971location @code{0x0}. Also link @samp{.data}, @samp{.bss},
8972@samp{.strings}, @samp{.rodata}, @samp{.rodata1}, @samp{.data1} sections
8973into onchip data memory, which starts at location @code{0x20000000}.
8974
8975@item -mno-asm-optimize
8976@itemx -masm-optimize
cd3bb277
JM
8977@opindex mno-asm-optimize
8978@opindex masm-optimize
630d3d5a
JM
8979Disable (enable) passing @option{-O} to the assembler when optimizing.
8980The assembler uses the @option{-O} option to automatically parallelize
e8ad90e5
MM
8981adjacent short instructions where possible.
8982
8983@item -mbranch-cost=@var{n}
cd3bb277 8984@opindex mbranch-cost
e8ad90e5
MM
8985Increase the internal costs of branches to @var{n}. Higher costs means
8986that the compiler will issue more instructions to avoid doing a branch.
8987The default is 2.
8988
8989@item -mcond-exec=@var{n}
cd3bb277 8990@opindex mcond-exec
e8ad90e5
MM
8991Specify the maximum number of conditionally executed instructions that
8992replace a branch. The default is 4.
8993@end table
56b2d7a7 8994
91abf72d
HP
8995@node S/390 and zSeries Options
8996@subsection S/390 and zSeries Options
8997@cindex S/390 and zSeries Options
8998
8999These are the @samp{-m} options defined for the S/390 and zSeries architecture.
9000
9001@table @gcctabopt
9002@item -mhard-float
9003@itemx -msoft-float
9004@opindex mhard-float
9005@opindex msoft-float
9006Use (do not use) the hardware floating-point instructions and registers
9007for floating-point operations. When @option{-msoft-float} is specified,
9008functions in @file{libgcc.a} will be used to perform floating-point
9009operations. When @option{-mhard-float} is specified, the compiler
9010generates IEEE floating-point instructions. This is the default.
9011
9012@item -mbackchain
9013@itemx -mno-backchain
9014@opindex mbackchain
9015@opindex mno-backchain
9016Generate (or do not generate) code which maintains an explicit
9017backchain within the stack frame that points to the caller's frame.
9018This is currently needed to allow debugging. The default is to
9019generate the backchain.
9020
9021@item -msmall-exec
9022@itemx -mno-small-exec
9023@opindex msmall-exec
9024@opindex mno-small-exec
9025Generate (or do not generate) code using the @code{bras} instruction
9026to do subroutine calls.
9027This only works reliably if the total executable size does not
9028exceed 64k. The default is to use the @code{basr} instruction instead,
9029which does not have this limitation.
9030
9031@item -m64
9032@itemx -m31
9033@opindex m64
9034@opindex m31
9035When @option{-m31} is specified, generate code compliant to the
9036Linux for S/390 ABI@. When @option{-m64} is specified, generate
9037code compliant to the Linux for zSeries ABI@. This allows GCC in
9038particular to generate 64-bit instructions. For the @samp{s390}
9039targets, the default is @option{-m31}, while the @samp{s390x}
9040targets default to @option{-m64}.
9041
9042@item -mmvcle
9043@itemx -mno-mvcle
9044@opindex mmvcle
9045@opindex mno-mvcle
9046Generate (or do not generate) code using the @code{mvcle} instruction
9047to perform block moves. When @option{-mno-mvcle} is specifed,
9048use a @code{mvc} loop instead. This is the default.
9049
9050@item -mdebug
9051@itemx -mno-debug
9052@opindex mdebug
9053@opindex mno-debug
9054Print (or do not print) additional debug information when compiling.
9055The default is to not print debug information.
9056
9057@end table
9058
9059
74291a4b
MM
9060@node Code Gen Options
9061@section Options for Code Generation Conventions
9062@cindex code generation conventions
9063@cindex options, code generation
9064@cindex run-time options
9065
9066These machine-independent options control the interface conventions
9067used in code generation.
9068
9069Most of them have both positive and negative forms; the negative form
630d3d5a 9070of @option{-ffoo} would be @option{-fno-foo}. In the table below, only
74291a4b
MM
9071one of the forms is listed---the one which is not the default. You
9072can figure out the other form by either removing @samp{no-} or adding
9073it.
9074
2642624b 9075@table @gcctabopt
956d6950 9076@item -fexceptions
cd3bb277 9077@opindex fexceptions
767094dd 9078Enable exception handling. Generates extra code needed to propagate
f0523f02 9079exceptions. For some targets, this implies GCC will generate frame
c5c76735
JL
9080unwind information for all functions, which can produce significant data
9081size overhead, although it does not affect execution. If you do not
f0523f02 9082specify this option, GCC will enable it by default for languages like
90ecce3e 9083C++ which normally require exception handling, and disable it for
c5c76735
JL
9084languages like C that do not normally require it. However, you may need
9085to enable this option when compiling C code that needs to interoperate
9086properly with exception handlers written in C++. You may also wish to
9087disable this option if you are compiling older C++ programs that don't
9088use exception handling.
956d6950 9089
6cfc0341
RH
9090@item -fnon-call-exceptions
9091@opindex fnon-call-exceptions
9092Generate code that allows trapping instructions to throw exceptions.
9093Note that this requires platform-specific runtime support that does
9094not exist everywhere. Moreover, it only allows @emph{trapping}
e979f9e8 9095instructions to throw exceptions, i.e.@: memory references or floating
6cfc0341
RH
9096point instructions. It does not allow exceptions to be thrown from
9097arbitrary signal handlers such as @code{SIGALRM}.
9098
14a774a9 9099@item -funwind-tables
cd3bb277 9100@opindex funwind-tables
bedc7537 9101Similar to @option{-fexceptions}, except that it will just generate any needed
14a774a9
RK
9102static data, but will not affect the generated code in any other way.
9103You will normally not enable this option; instead, a language processor
9104that needs this handling would enable it on your behalf.
9105
74291a4b 9106@item -fpcc-struct-return
cd3bb277 9107@opindex fpcc-struct-return
74291a4b
MM
9108Return ``short'' @code{struct} and @code{union} values in memory like
9109longer ones, rather than in registers. This convention is less
9110efficient, but it has the advantage of allowing intercallability between
0c2d1a2a 9111GCC-compiled files and files compiled with other compilers.
74291a4b
MM
9112
9113The precise convention for returning structures in memory depends
9114on the target configuration macros.
9115
9116Short structures and unions are those whose size and alignment match
9117that of some integer type.
9118
9119@item -freg-struct-return
cd3bb277 9120@opindex freg-struct-return
9c34dbbf
ZW
9121Return @code{struct} and @code{union} values in registers when possible.
9122This is more efficient for small structures than
9123@option{-fpcc-struct-return}.
74291a4b 9124
9c34dbbf 9125If you specify neither @option{-fpcc-struct-return} nor
630d3d5a 9126@option{-freg-struct-return}, GCC defaults to whichever convention is
0c2d1a2a 9127standard for the target. If there is no standard convention, GCC
9c34dbbf
ZW
9128defaults to @option{-fpcc-struct-return}, except on targets where GCC is
9129the principal compiler. In those cases, we can choose the standard, and
9130we chose the more efficient register return alternative.
74291a4b
MM
9131
9132@item -fshort-enums
cd3bb277 9133@opindex fshort-enums
74291a4b
MM
9134Allocate to an @code{enum} type only as many bytes as it needs for the
9135declared range of possible values. Specifically, the @code{enum} type
9136will be equivalent to the smallest integer type which has enough room.
9137
9138@item -fshort-double
cd3bb277 9139@opindex fshort-double
74291a4b
MM
9140Use the same size for @code{double} as for @code{float}.
9141
9142@item -fshared-data
cd3bb277 9143@opindex fshared-data
74291a4b
MM
9144Requests that the data and non-@code{const} variables of this
9145compilation be shared data rather than private data. The distinction
9146makes sense only on certain operating systems, where shared data is
9147shared between processes running the same program, while private data
9148exists in one copy per process.
9149
9150@item -fno-common
cd3bb277 9151@opindex fno-common
90ecce3e 9152In C, allocate even uninitialized global variables in the data section of the
74291a4b
MM
9153object file, rather than generating them as common blocks. This has the
9154effect that if the same variable is declared (without @code{extern}) in
9155two different compilations, you will get an error when you link them.
9156The only reason this might be useful is if you wish to verify that the
9157program will work on other systems which always work this way.
9158
9159@item -fno-ident
cd3bb277 9160@opindex fno-ident
74291a4b
MM
9161Ignore the @samp{#ident} directive.
9162
9163@item -fno-gnu-linker
cd3bb277 9164@opindex fno-gnu-linker
74291a4b
MM
9165Do not output global initializations (such as C++ constructors and
9166destructors) in the form used by the GNU linker (on systems where the GNU
9167linker is the standard method of handling them). Use this option when
9168you want to use a non-GNU linker, which also requires using the
bedc7537
NC
9169@command{collect2} program to make sure the system linker includes
9170constructors and destructors. (@command{collect2} is included in the GCC
9171distribution.) For systems which @emph{must} use @command{collect2}, the
9172compiler driver @command{gcc} is configured to do this automatically.
74291a4b
MM
9173
9174@item -finhibit-size-directive
cd3bb277 9175@opindex finhibit-size-directive
74291a4b
MM
9176Don't output a @code{.size} assembler directive, or anything else that
9177would cause trouble if the function is split in the middle, and the
9178two halves are placed at locations far apart in memory. This option is
9179used when compiling @file{crtstuff.c}; you should not need to use it
9180for anything else.
9181
9182@item -fverbose-asm
cd3bb277 9183@opindex fverbose-asm
74291a4b
MM
9184Put extra commentary information in the generated assembly code to
9185make it more readable. This option is generally only of use to those
9186who actually need to read the generated assembly code (perhaps while
9187debugging the compiler itself).
9188
630d3d5a 9189@option{-fno-verbose-asm}, the default, causes the
74291a4b
MM
9190extra information to be omitted and is useful when comparing two assembler
9191files.
9192
9193@item -fvolatile
cd3bb277 9194@opindex fvolatile
74291a4b
MM
9195Consider all memory references through pointers to be volatile.
9196
9197@item -fvolatile-global
cd3bb277 9198@opindex fvolatile-global
74291a4b 9199Consider all memory references to extern and global data items to
0c2d1a2a 9200be volatile. GCC does not consider static data items to be volatile
ab87f8c8
JL
9201because of this switch.
9202
9203@item -fvolatile-static
cd3bb277 9204@opindex fvolatile-static
ab87f8c8 9205Consider all memory references to static data to be volatile.
74291a4b
MM
9206
9207@item -fpic
cd3bb277 9208@opindex fpic
74291a4b
MM
9209@cindex global offset table
9210@cindex PIC
9211Generate position-independent code (PIC) suitable for use in a shared
9212library, if supported for the target machine. Such code accesses all
161d7b59 9213constant addresses through a global offset table (GOT)@. The dynamic
861bb6c1 9214loader resolves the GOT entries when the program starts (the dynamic
0c2d1a2a 9215loader is not part of GCC; it is part of the operating system). If
861bb6c1
JL
9216the GOT size for the linked executable exceeds a machine-specific
9217maximum size, you get an error message from the linker indicating that
630d3d5a 9218@option{-fpic} does not work; in that case, recompile with @option{-fPIC}
861bb6c1
JL
9219instead. (These maximums are 16k on the m88k, 8k on the Sparc, and 32k
9220on the m68k and RS/6000. The 386 has no such limit.)
74291a4b
MM
9221
9222Position-independent code requires special support, and therefore works
0c2d1a2a 9223only on certain machines. For the 386, GCC supports PIC for System V
74291a4b
MM
9224but not for the Sun 386i. Code generated for the IBM RS/6000 is always
9225position-independent.
9226
74291a4b 9227@item -fPIC
cd3bb277 9228@opindex fPIC
74291a4b
MM
9229If supported for the target machine, emit position-independent code,
9230suitable for dynamic linking and avoiding any limit on the size of the
9231global offset table. This option makes a difference on the m68k, m88k,
9232and the Sparc.
9233
9234Position-independent code requires special support, and therefore works
9235only on certain machines.
9236
9237@item -ffixed-@var{reg}
cd3bb277 9238@opindex ffixed
74291a4b
MM
9239Treat the register named @var{reg} as a fixed register; generated code
9240should never refer to it (except perhaps as a stack pointer, frame
9241pointer or in some other fixed role).
9242
9243@var{reg} must be the name of a register. The register names accepted
9244are machine-specific and are defined in the @code{REGISTER_NAMES}
9245macro in the machine description macro file.
9246
9247This flag does not have a negative form, because it specifies a
9248three-way choice.
9249
9250@item -fcall-used-@var{reg}
cd3bb277 9251@opindex fcall-used
956d6950 9252Treat the register named @var{reg} as an allocable register that is
74291a4b
MM
9253clobbered by function calls. It may be allocated for temporaries or
9254variables that do not live across a call. Functions compiled this way
9255will not save and restore the register @var{reg}.
9256
cb2fdc84
GRK
9257It is an error to used this flag with the frame pointer or stack pointer.
9258Use of this flag for other registers that have fixed pervasive roles in
9259the machine's execution model will produce disastrous results.
74291a4b
MM
9260
9261This flag does not have a negative form, because it specifies a
9262three-way choice.
9263
9264@item -fcall-saved-@var{reg}
cd3bb277 9265@opindex fcall-saved
956d6950 9266Treat the register named @var{reg} as an allocable register saved by
74291a4b
MM
9267functions. It may be allocated even for temporaries or variables that
9268live across a call. Functions compiled this way will save and restore
9269the register @var{reg} if they use it.
9270
cb2fdc84
GRK
9271It is an error to used this flag with the frame pointer or stack pointer.
9272Use of this flag for other registers that have fixed pervasive roles in
9273the machine's execution model will produce disastrous results.
74291a4b
MM
9274
9275A different sort of disaster will result from the use of this flag for
9276a register in which function values may be returned.
9277
9278This flag does not have a negative form, because it specifies a
9279three-way choice.
9280
9281@item -fpack-struct
cd3bb277 9282@opindex fpack-struct
74291a4b
MM
9283Pack all structure members together without holes. Usually you would
9284not want to use this option, since it makes the code suboptimal, and
9285the offsets of structure members won't agree with system libraries.
9286
861bb6c1 9287@item -fcheck-memory-usage
cd3bb277 9288@opindex fcheck-memory-usage
0c2d1a2a 9289Generate extra code to check each memory access. GCC will generate
861bb6c1 9290code that is suitable for a detector of bad memory accesses such as
7d384cc0 9291@file{Checker}.
861bb6c1 9292
d3111037
CB
9293Normally, you should compile all, or none, of your code with this option.
9294
9295If you do mix code compiled with and without this option,
9296you must ensure that all code that has side effects
9297and that is called by code compiled with this option
9298is, itself, compiled with this option.
9299If you do not, you might get erroneous messages from the detector.
9300
861bb6c1 9301If you use functions from a library that have side-effects (such as
d3111037 9302@code{read}), you might not be able to recompile the library and
861bb6c1 9303specify this option. In that case, you can enable the
630d3d5a 9304@option{-fprefix-function-name} option, which requests GCC to encapsulate
861bb6c1 9305your code and make other functions look as if they were compiled with
630d3d5a 9306@option{-fcheck-memory-usage}. This is done by calling ``stubs'',
861bb6c1 9307which are provided by the detector. If you cannot find or build
d3111037 9308stubs for every function you call, you might have to specify
630d3d5a 9309@option{-fcheck-memory-usage} without @option{-fprefix-function-name}.
861bb6c1 9310
7d384cc0 9311If you specify this option, you can not use the @code{asm} or
f0523f02
JM
9312@code{__asm__} keywords in functions with memory checking enabled. GCC
9313cannot understand what the @code{asm} statement may do, and therefore
c5c76735 9314cannot generate the appropriate code, so it will reject it. However, if
ee457005 9315you specify the function attribute @code{no_check_memory_usage}
f0523f02 9316(@pxref{Function Attributes}), GCC will disable memory checking within a
c5c76735
JL
9317function; you may use @code{asm} statements inside such functions. You
9318may have an inline expansion of a non-checked function within a checked
f0523f02 9319function; in that case GCC will not generate checks for the inlined
c5c76735
JL
9320function's memory accesses.
9321
9322If you move your @code{asm} statements to non-checked inline functions
9323and they do access memory, you can add calls to the support code in your
7d384cc0
KR
9324inline function, to indicate any reads, writes, or copies being done.
9325These calls would be similar to those done in the stubs described above.
9326
861bb6c1 9327@item -fprefix-function-name
cd3bb277 9328@opindex fprefix-function-name
0c2d1a2a
JB
9329Request GCC to add a prefix to the symbols generated for function names.
9330GCC adds a prefix to the names of functions defined as well as
861bb6c1 9331functions called. Code compiled with this option and code compiled
d3111037 9332without the option can't be linked together, unless stubs are used.
861bb6c1 9333
630d3d5a 9334If you compile the following code with @option{-fprefix-function-name}
861bb6c1
JL
9335@example
9336extern void bar (int);
9337void
9338foo (int a)
9339@{
9340 return bar (a + 5);
861bb6c1
JL
9341@}
9342@end example
9343
9344@noindent
0c2d1a2a 9345GCC will compile the code as if it was written:
861bb6c1
JL
9346@example
9347extern void prefix_bar (int);
9348void
9349prefix_foo (int a)
9350@{
9351 return prefix_bar (a + 5);
9352@}
9353@end example
630d3d5a 9354This option is designed to be used with @option{-fcheck-memory-usage}.
861bb6c1 9355
07417085 9356@item -finstrument-functions
cd3bb277 9357@opindex finstrument-functions
07417085
KR
9358Generate instrumentation calls for entry and exit to functions. Just
9359after function entry and just before function exit, the following
9360profiling functions will be called with the address of the current
9361function and its call site. (On some platforms,
9362@code{__builtin_return_address} does not work beyond the current
9363function, so the call site information may not be available to the
9364profiling functions otherwise.)
9365
9366@example
310668e8
JM
9367void __cyg_profile_func_enter (void *this_fn,
9368 void *call_site);
9369void __cyg_profile_func_exit (void *this_fn,
9370 void *call_site);
07417085
KR
9371@end example
9372
9373The first argument is the address of the start of the current function,
9374which may be looked up exactly in the symbol table.
9375
9376This instrumentation is also done for functions expanded inline in other
9377functions. The profiling calls will indicate where, conceptually, the
9378inline function is entered and exited. This means that addressable
9379versions of such functions must be available. If all your uses of a
9380function are expanded inline, this may mean an additional expansion of
9381code size. If you use @samp{extern inline} in your C code, an
9382addressable version of such functions must be provided. (This is
9383normally the case anyways, but if you get lucky and the optimizer always
9384expands the functions inline, you might have gotten away without
9385providing static copies.)
9386
9387A function may be given the attribute @code{no_instrument_function}, in
9388which case this instrumentation will not be done. This can be used, for
9389example, for the profiling functions listed above, high-priority
9390interrupt routines, and any functions from which the profiling functions
9391cannot safely be called (perhaps signal handlers, if the profiling
9392routines generate output or allocate memory).
9393
861bb6c1 9394@item -fstack-check
cd3bb277 9395@opindex fstack-check
861bb6c1
JL
9396Generate code to verify that you do not go beyond the boundary of the
9397stack. You should specify this flag if you are running in an
9398environment with multiple threads, but only rarely need to specify it in
9399a single-threaded environment since stack overflow is automatically
9400detected on nearly all systems if there is only one stack.
9401
a157febd
GK
9402Note that this switch does not actually cause checking to be done; the
9403operating system must do that. The switch causes generation of code
9404to ensure that the operating system sees the stack being extended.
9405
9406@item -fstack-limit-register=@var{reg}
9407@itemx -fstack-limit-symbol=@var{sym}
9408@itemx -fno-stack-limit
cd3bb277
JM
9409@opindex fstack-limit-register
9410@opindex fstack-limit-symbol
9411@opindex fno-stack-limit
a157febd
GK
9412Generate code to ensure that the stack does not grow beyond a certain value,
9413either the value of a register or the address of a symbol. If the stack
9414would grow beyond the value, a signal is raised. For most targets,
9415the signal is raised before the stack overruns the boundary, so
9416it is possible to catch the signal without taking special precautions.
9417
9c34dbbf
ZW
9418For instance, if the stack starts at absolute address @samp{0x80000000}
9419and grows downwards, you can use the flags
9420@option{-fstack-limit-symbol=__stack_limit} and
9421@option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
9422of 128KB@. Note that this may only work with the GNU linker.
a157febd 9423
e5eb27e5
JL
9424@cindex aliasing of parameters
9425@cindex parameters, aliased
9426@item -fargument-alias
04afd9d6
JL
9427@itemx -fargument-noalias
9428@itemx -fargument-noalias-global
cd3bb277
JM
9429@opindex fargument-alias
9430@opindex fargument-noalias
9431@opindex fargument-noalias-global
e5eb27e5
JL
9432Specify the possible relationships among parameters and between
9433parameters and global data.
9434
630d3d5a 9435@option{-fargument-alias} specifies that arguments (parameters) may
9c34dbbf 9436alias each other and may alias global storage.@*
630d3d5a 9437@option{-fargument-noalias} specifies that arguments do not alias
9c34dbbf 9438each other, but may alias global storage.@*
630d3d5a 9439@option{-fargument-noalias-global} specifies that arguments do not
e5eb27e5
JL
9440alias each other and do not alias global storage.
9441
9442Each language will automatically use whatever option is required by
9443the language standard. You should not need to use these options yourself.
19283265
RH
9444
9445@item -fleading-underscore
cd3bb277 9446@opindex fleading-underscore
695ac33f 9447This option and its counterpart, @option{-fno-leading-underscore}, forcibly
19283265
RH
9448change the way C symbols are represented in the object file. One use
9449is to help link with legacy assembly code.
9450
9451Be warned that you should know what you are doing when invoking this
9452option, and that not all targets provide complete support for it.
74291a4b
MM
9453@end table
9454
ee457005
JM
9455@c man end
9456
74291a4b 9457@node Environment Variables
0c2d1a2a 9458@section Environment Variables Affecting GCC
74291a4b
MM
9459@cindex environment variables
9460
ee457005
JM
9461@c man begin ENVIRONMENT
9462
0c2d1a2a
JB
9463This section describes several environment variables that affect how GCC
9464operates. Some of them work by specifying directories or prefixes to use
767094dd 9465when searching for various kinds of files. Some are used to specify other
46103ab4 9466aspects of the compilation environment.
74291a4b
MM
9467
9468@ifclear INTERNALS
9469Note that you can also specify places to search using options such as
630d3d5a 9470@option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
74291a4b 9471take precedence over places specified using environment variables, which
161d7b59 9472in turn take precedence over those specified by the configuration of GCC@.
0c2d1a2a 9473
74291a4b
MM
9474@end ifclear
9475@ifset INTERNALS
9476Note that you can also specify places to search using options such as
630d3d5a 9477@option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
74291a4b 9478take precedence over places specified using environment variables, which
161d7b59 9479in turn take precedence over those specified by the configuration of GCC@.
0c2d1a2a 9480@xref{Driver}.
74291a4b
MM
9481@end ifset
9482
bedc7537 9483@table @env
ab87f8c8
JL
9484@item LANG
9485@itemx LC_CTYPE
9486@c @itemx LC_COLLATE
9487@itemx LC_MESSAGES
9488@c @itemx LC_MONETARY
9489@c @itemx LC_NUMERIC
9490@c @itemx LC_TIME
9491@itemx LC_ALL
9492@findex LANG
9493@findex LC_CTYPE
9494@c @findex LC_COLLATE
9495@findex LC_MESSAGES
9496@c @findex LC_MONETARY
9497@c @findex LC_NUMERIC
9498@c @findex LC_TIME
9499@findex LC_ALL
9500@cindex locale
0c2d1a2a
JB
9501These environment variables control the way that GCC uses
9502localization information that allow GCC to work with different
9503national conventions. GCC inspects the locale categories
bedc7537 9504@env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
ab87f8c8
JL
9505so. These locale categories can be set to any value supported by your
9506installation. A typical value is @samp{en_UK} for English in the United
9507Kingdom.
9508
bedc7537 9509The @env{LC_CTYPE} environment variable specifies character
0c2d1a2a 9510classification. GCC uses it to determine the character boundaries in
ab87f8c8
JL
9511a string; this is needed for some multibyte encodings that contain quote
9512and escape characters that would otherwise be interpreted as a string
9513end or escape.
9514
bedc7537 9515The @env{LC_MESSAGES} environment variable specifies the language to
ab87f8c8
JL
9516use in diagnostic messages.
9517
bedc7537
NC
9518If the @env{LC_ALL} environment variable is set, it overrides the value
9519of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
9520and @env{LC_MESSAGES} default to the value of the @env{LANG}
0c2d1a2a 9521environment variable. If none of these variables are set, GCC
ab87f8c8
JL
9522defaults to traditional C English behavior.
9523
74291a4b
MM
9524@item TMPDIR
9525@findex TMPDIR
bedc7537 9526If @env{TMPDIR} is set, it specifies the directory to use for temporary
0c2d1a2a 9527files. GCC uses temporary files to hold the output of one stage of
74291a4b
MM
9528compilation which is to be used as input to the next stage: for example,
9529the output of the preprocessor, which is the input to the compiler
9530proper.
9531
9532@item GCC_EXEC_PREFIX
9533@findex GCC_EXEC_PREFIX
bedc7537 9534If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
74291a4b
MM
9535names of the subprograms executed by the compiler. No slash is added
9536when this prefix is combined with the name of a subprogram, but you can
9537specify a prefix that ends with a slash if you wish.
9538
f0523f02 9539If @env{GCC_EXEC_PREFIX} is not set, GCC will attempt to figure out
0deb20df
TT
9540an appropriate prefix to use based on the pathname it was invoked with.
9541
0c2d1a2a 9542If GCC cannot find the subprogram using the specified prefix, it
74291a4b
MM
9543tries looking in the usual places for the subprogram.
9544
bedc7537 9545The default value of @env{GCC_EXEC_PREFIX} is
74291a4b
MM
9546@file{@var{prefix}/lib/gcc-lib/} where @var{prefix} is the value
9547of @code{prefix} when you ran the @file{configure} script.
9548
630d3d5a 9549Other prefixes specified with @option{-B} take precedence over this prefix.
74291a4b
MM
9550
9551This prefix is also used for finding files such as @file{crt0.o} that are
9552used for linking.
9553
9554In addition, the prefix is used in an unusual way in finding the
9555directories to search for header files. For each of the standard
9556directories whose name normally begins with @samp{/usr/local/lib/gcc-lib}
bedc7537 9557(more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
74291a4b 9558replacing that beginning with the specified prefix to produce an
630d3d5a 9559alternate directory name. Thus, with @option{-Bfoo/}, GCC will search
74291a4b
MM
9560@file{foo/bar} where it would normally search @file{/usr/local/lib/bar}.
9561These alternate directories are searched first; the standard directories
9562come next.
9563
9564@item COMPILER_PATH
9565@findex COMPILER_PATH
bedc7537
NC
9566The value of @env{COMPILER_PATH} is a colon-separated list of
9567directories, much like @env{PATH}. GCC tries the directories thus
74291a4b 9568specified when searching for subprograms, if it can't find the
bedc7537 9569subprograms using @env{GCC_EXEC_PREFIX}.
74291a4b
MM
9570
9571@item LIBRARY_PATH
9572@findex LIBRARY_PATH
bedc7537
NC
9573The value of @env{LIBRARY_PATH} is a colon-separated list of
9574directories, much like @env{PATH}. When configured as a native compiler,
0c2d1a2a 9575GCC tries the directories thus specified when searching for special
bedc7537 9576linker files, if it can't find them using @env{GCC_EXEC_PREFIX}. Linking
0c2d1a2a 9577using GCC also uses these directories when searching for ordinary
630d3d5a
JM
9578libraries for the @option{-l} option (but directories specified with
9579@option{-L} come first).
74291a4b
MM
9580
9581@item C_INCLUDE_PATH
9582@itemx CPLUS_INCLUDE_PATH
9583@itemx OBJC_INCLUDE_PATH
9584@findex C_INCLUDE_PATH
9585@findex CPLUS_INCLUDE_PATH
9586@findex OBJC_INCLUDE_PATH
9587@c @itemx OBJCPLUS_INCLUDE_PATH
9588These environment variables pertain to particular languages. Each
9589variable's value is a colon-separated list of directories, much like
bedc7537 9590@env{PATH}. When GCC searches for header files, it tries the
74291a4b 9591directories listed in the variable for the language you are using, after
630d3d5a 9592the directories specified with @option{-I} but before the standard header
74291a4b
MM
9593file directories.
9594
9595@item DEPENDENCIES_OUTPUT
9596@findex DEPENDENCIES_OUTPUT
9597@cindex dependencies for make as output
9598If this variable is set, its value specifies how to output dependencies
9599for Make based on the header files processed by the compiler. This
630d3d5a 9600output looks much like the output from the @option{-M} option
74291a4b
MM
9601(@pxref{Preprocessor Options}), but it goes to a separate file, and is
9602in addition to the usual results of compilation.
9603
bedc7537 9604The value of @env{DEPENDENCIES_OUTPUT} can be just a file name, in
74291a4b
MM
9605which case the Make rules are written to that file, guessing the target
9606name from the source file name. Or the value can have the form
9607@samp{@var{file} @var{target}}, in which case the rules are written to
9608file @var{file} using @var{target} as the target name.
56f48ce9
DB
9609
9610@item LANG
9611@findex LANG
9612@cindex locale definition
767094dd 9613This variable is used to pass locale information to the compiler. One way in
56f48ce9
DB
9614which this information is used is to determine the character set to be used
9615when character literals, string literals and comments are parsed in C and C++.
9616When the compiler is configured to allow multibyte characters,
bedc7537 9617the following values for @env{LANG} are recognized:
56f48ce9 9618
2642624b 9619@table @samp
56f48ce9
DB
9620@item C-JIS
9621Recognize JIS characters.
9622@item C-SJIS
9623Recognize SJIS characters.
9624@item C-EUCJP
9625Recognize EUCJP characters.
9626@end table
9627
bedc7537 9628If @env{LANG} is not defined, or if it has some other value, then the
56f48ce9
DB
9629compiler will use mblen and mbtowc as defined by the default locale to
9630recognize and translate multibyte characters.
74291a4b
MM
9631@end table
9632
9d86bffc
JM
9633@c man end
9634
74291a4b
MM
9635@node Running Protoize
9636@section Running Protoize
9637
161d7b59 9638The program @code{protoize} is an optional part of GCC@. You can use
c1030c7c 9639it to add prototypes to a program, thus converting the program to ISO
74291a4b
MM
9640C in one respect. The companion program @code{unprotoize} does the
9641reverse: it removes argument types from any prototypes that are found.
9642
9643When you run these programs, you must specify a set of source files as
9644command line arguments. The conversion programs start out by compiling
9645these files to see what functions they define. The information gathered
9646about a file @var{foo} is saved in a file named @file{@var{foo}.X}.
9647
9648After scanning comes actual conversion. The specified files are all
9649eligible to be converted; any files they include (whether sources or
9650just headers) are eligible as well.
9651
9652But not all the eligible files are converted. By default,
9653@code{protoize} and @code{unprotoize} convert only source and header
9654files in the current directory. You can specify additional directories
630d3d5a 9655whose files should be converted with the @option{-d @var{directory}}
74291a4b 9656option. You can also specify particular files to exclude with the
630d3d5a 9657@option{-x @var{file}} option. A file is converted if it is eligible, its
74291a4b
MM
9658directory name matches one of the specified directory names, and its
9659name within the directory has not been excluded.
9660
9661Basic conversion with @code{protoize} consists of rewriting most
9662function definitions and function declarations to specify the types of
9663the arguments. The only ones not rewritten are those for varargs
9664functions.
9665
9666@code{protoize} optionally inserts prototype declarations at the
9667beginning of the source file, to make them available for any calls that
9668precede the function's definition. Or it can insert prototype
9669declarations with block scope in the blocks where undeclared functions
9670are called.
9671
9672Basic conversion with @code{unprotoize} consists of rewriting most
9673function declarations to remove any argument types, and rewriting
c1030c7c 9674function definitions to the old-style pre-ISO form.
74291a4b
MM
9675
9676Both conversion programs print a warning for any function declaration or
9677definition that they can't convert. You can suppress these warnings
630d3d5a 9678with @option{-q}.
74291a4b
MM
9679
9680The output from @code{protoize} or @code{unprotoize} replaces the
9681original source file. The original file is renamed to a name ending
02f52e19 9682with @samp{.save} (for DOS, the saved filename ends in @samp{.sav}
a7db8bbb
MK
9683without the original @samp{.c} suffix). If the @samp{.save} (@samp{.sav}
9684for DOS) file already exists, then the source file is simply discarded.
74291a4b 9685
0c2d1a2a 9686@code{protoize} and @code{unprotoize} both depend on GCC itself to
74291a4b 9687scan the program and collect information about the functions it uses.
0c2d1a2a 9688So neither of these programs will work until GCC is installed.
74291a4b
MM
9689
9690Here is a table of the options you can use with @code{protoize} and
9691@code{unprotoize}. Each option works with both programs unless
9692otherwise stated.
9693
9694@table @code
9695@item -B @var{directory}
9696Look for the file @file{SYSCALLS.c.X} in @var{directory}, instead of the
9697usual directory (normally @file{/usr/local/lib}). This file contains
9698prototype information about standard system functions. This option
9699applies only to @code{protoize}.
9700
9701@item -c @var{compilation-options}
9702Use @var{compilation-options} as the options when running @code{gcc} to
630d3d5a 9703produce the @samp{.X} files. The special option @option{-aux-info} is
74291a4b
MM
9704always passed in addition, to tell @code{gcc} to write a @samp{.X} file.
9705
9706Note that the compilation options must be given as a single argument to
9707@code{protoize} or @code{unprotoize}. If you want to specify several
9708@code{gcc} options, you must quote the entire set of compilation options
9709to make them a single word in the shell.
9710
9711There are certain @code{gcc} arguments that you cannot use, because they
630d3d5a
JM
9712would produce the wrong kind of output. These include @option{-g},
9713@option{-O}, @option{-c}, @option{-S}, and @option{-o} If you include these in
74291a4b
MM
9714the @var{compilation-options}, they are ignored.
9715
9716@item -C
a7db8bbb 9717Rename files to end in @samp{.C} (@samp{.cc} for DOS-based file
02f52e19 9718systems) instead of @samp{.c}. This is convenient if you are converting
ee77eda5 9719a C program to C++. This option applies only to @code{protoize}.
74291a4b
MM
9720
9721@item -g
9722Add explicit global declarations. This means inserting explicit
9723declarations at the beginning of each source file for each function
9724that is called in the file and was not declared. These declarations
9725precede the first function definition that contains a call to an
9726undeclared function. This option applies only to @code{protoize}.
9727
9728@item -i @var{string}
9729Indent old-style parameter declarations with the string @var{string}.
9730This option applies only to @code{protoize}.
9731
9732@code{unprotoize} converts prototyped function definitions to old-style
9733function definitions, where the arguments are declared between the
9734argument list and the initial @samp{@{}. By default, @code{unprotoize}
9735uses five spaces as the indentation. If you want to indent with just
630d3d5a 9736one space instead, use @option{-i " "}.
74291a4b
MM
9737
9738@item -k
9739Keep the @samp{.X} files. Normally, they are deleted after conversion
9740is finished.
9741
9742@item -l
630d3d5a 9743Add explicit local declarations. @code{protoize} with @option{-l} inserts
74291a4b
MM
9744a prototype declaration for each function in each block which calls the
9745function without any declaration. This option applies only to
9746@code{protoize}.
9747
9748@item -n
9749Make no real changes. This mode just prints information about the conversions
630d3d5a 9750that would have been done without @option{-n}.
74291a4b
MM
9751
9752@item -N
9753Make no @samp{.save} files. The original files are simply deleted.
9754Use this option with caution.
9755
9756@item -p @var{program}
9757Use the program @var{program} as the compiler. Normally, the name
9758@file{gcc} is used.
9759
9760@item -q
9761Work quietly. Most warnings are suppressed.
9762
9763@item -v
630d3d5a 9764Print the version number, just like @option{-v} for @code{gcc}.
74291a4b
MM
9765@end table
9766
9767If you need special compiler options to compile one of your program's
9768source files, then you should generate that file's @samp{.X} file
9769specially, by running @code{gcc} on that source file with the
630d3d5a 9770appropriate options and the option @option{-aux-info}. Then run
74291a4b
MM
9771@code{protoize} on the entire set of files. @code{protoize} will use
9772the existing @samp{.X} file because it is newer than the source file.
9773For example:
9774
9775@example
b1018de6 9776gcc -Dfoo=bar file1.c -aux-info file1.X
74291a4b
MM
9777protoize *.c
9778@end example
9779
9780@noindent
9781You need to include the special files along with the rest in the
9782@code{protoize} command, even though their @samp{.X} files already
9783exist, because otherwise they won't get converted.
9784
9785@xref{Protoize Caveats}, for more information on how to use
9786@code{protoize} successfully.