]> gcc.gnu.org Git - gcc.git/blame - gcc/invoke.texi
invoke.texi: Add support for using texi2pod.pl.
[gcc.git] / gcc / invoke.texi
CommitLineData
3b708058 1@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
74291a4b
MM
2@c This is part of the GCC manual.
3@c For copying conditions, see the file gcc.texi.
4
9d86bffc
JM
5@ignore
6@c man begin COPYRIGHT
7Copyright @copyright{} 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
81998, 1999, 2000 Free Software Foundation, Inc.
9
10Permission is granted to make and distribute verbatim copies of this
11manual provided the copyright notice and this permission notice are
12preserved on all copies.
13
14Permission is granted to copy and distribute modified versions of this
15manual under the conditions for verbatim copying, provided also that the
16entire resulting derived work is distributed under the terms of a
17permission notice identical to this one.
18
19Permission is granted to copy and distribute translations of this manual
20into another language, under the above conditions for modified versions,
21except that this permission notice may be included in translations
22approved by the Free Software Foundation instead of in the original
23English.
24@c man end
25@c Set file name and title for the man page.
26@setfilename gcc
27@settitle GNU project C and C++ compiler
28@c man begin SYNOPSIS
29gcc [@samp{-c}|@samp{-S}|@samp{-E}] [@samp{-std=}@var{standard}]
30 [@samp{-g}] [@samp{-pg}] [@samp{-O}@var{level}]
31 [@samp{-W}@var{warn}...] [@samp{-pedantic}]
32 [@samp{-I}@var{dir}...] [@samp{-L}@var{dir}...]
33 [@samp{-D}@var{macro}[=@var{defn}]...] [@samp{-U}@var{macro}]
34 [@samp{-f}@var{option}...] [@samp{-m}@var{machine-option}...]
35 [@samp{-o} @var{outfile}] @var{infile}...
36
37Only the most useful options are listed here; see below for the
38remainder. @samp{g++} accepts mostly the same options as @samp{gcc}.
39@c man end
40@c man begin SEEALSO
41cpp(1), gcov(1), g77(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1)
42and the Info entries for @file{gcc}, @file{cpp}, @file{g77}, @file{as},
43@file{ld}, @file{binutils} and @file{gdb}.
44@c man end
45@end ignore
46
74291a4b 47@node Invoking GCC
0c2d1a2a
JB
48@chapter GCC Command Options
49@cindex GCC command options
74291a4b 50@cindex command options
0c2d1a2a 51@cindex options, GCC command
74291a4b 52
9d86bffc
JM
53@c man begin DESCRIPTION
54
0c2d1a2a 55When you invoke GCC, it normally does preprocessing, compilation,
74291a4b
MM
56assembly and linking. The ``overall options'' allow you to stop this
57process at an intermediate stage. For example, the @samp{-c} option
58says not to run the linker. Then the output consists of object files
59output by the assembler.
60
61Other options are passed on to one stage of processing. Some options
62control the preprocessor and others the compiler itself. Yet other
63options control the assembler and linker; most of these are not
64documented here, since you rarely need to use any of them.
65
66@cindex C compilation options
0c2d1a2a 67Most of the command line options that you can use with GCC are useful
74291a4b
MM
68for C programs; when an option is only useful with another language
69(usually C++), the explanation says so explicitly. If the description
70for a particular option does not mention a source language, you can use
71that option with all supported languages.
72
73@cindex C++ compilation options
74@xref{Invoking G++,,Compiling C++ Programs}, for a summary of special
75options for compiling C++ programs.
76
77@cindex grouping options
78@cindex options, grouping
79The @code{gcc} program accepts options and file names as operands. Many
b192711e 80options have multi-letter names; therefore multiple single-letter options
74291a4b
MM
81may @emph{not} be grouped: @samp{-dr} is very different from @w{@samp{-d
82-r}}.
83
84@cindex order of options
85@cindex options, order
86You can mix options and other arguments. For the most part, the order
87you use doesn't matter. Order does matter when you use several options
88of the same kind; for example, if you specify @samp{-L} more than once,
89the directories are searched in the order specified.
90
91Many options have long names starting with @samp{-f} or with
92@samp{-W}---for example, @samp{-fforce-mem},
93@samp{-fstrength-reduce}, @samp{-Wformat} and so on. Most of
94these have both positive and negative forms; the negative form of
95@samp{-ffoo} would be @samp{-fno-foo}. This manual documents
96only one of these two forms, whichever one is not the default.
97
9d86bffc
JM
98@c man end
99
74291a4b
MM
100@menu
101* Option Summary:: Brief list of all options, without explanations.
102* Overall Options:: Controlling the kind of output:
103 an executable, object files, assembler files,
104 or preprocessed source.
105* Invoking G++:: Compiling C++ programs.
106* C Dialect Options:: Controlling the variant of C language compiled.
107* C++ Dialect Options:: Variations on C++.
764dbbf2
GDR
108* Language Independent Options:: Controlling how diagnostics should be
109 formatted.
74291a4b
MM
110* Warning Options:: How picky should the compiler be?
111* Debugging Options:: Symbol tables, measurements, and debugging dumps.
112* Optimize Options:: How much optimization?
113* Preprocessor Options:: Controlling header files and macro definitions.
114 Also, getting dependency information for Make.
115* Assembler Options:: Passing options to the assembler.
116* Link Options:: Specifying libraries and so on.
117* Directory Options:: Where to find header files and libraries.
118 Where to find the compiler executable files.
a743d340 119* Spec Files:: How to pass switches to sub-processes.
0c2d1a2a 120* Target Options:: Running a cross-compiler, or an old version of GCC.
74291a4b
MM
121* Submodel Options:: Specifying minor hardware or convention variations,
122 such as 68010 vs 68020.
123* Code Gen Options:: Specifying conventions for function calls, data layout
124 and register usage.
0c2d1a2a 125* Environment Variables:: Env vars that affect GCC.
74291a4b
MM
126* Running Protoize:: Automatically adding or removing function prototypes.
127@end menu
128
129@node Option Summary
130@section Option Summary
131
132Here is a summary of all the options, grouped by type. Explanations are
133in the following sections.
134
135@table @emph
136@item Overall Options
137@xref{Overall Options,,Options Controlling the Kind of Output}.
138@smallexample
84a0e7b8
JM
139-c -S -E -o @var{file} -pipe -pass-exit-codes -x @var{language}
140-v --target-help --help
74291a4b
MM
141@end smallexample
142
143@item C Language Options
144@xref{C Dialect Options,,Options Controlling C Dialect}.
145@smallexample
84a0e7b8
JM
146-ansi -std=@var{standard} -fno-asm -fno-builtin
147-fhosted -ffreestanding
148-trigraphs -traditional -traditional-cpp
149-fallow-single-precision -fcond-mismatch
150-fsigned-bitfields -fsigned-char
151-funsigned-bitfields -funsigned-char
152-fwritable-strings -fshort-wchar
74291a4b
MM
153@end smallexample
154
155@item C++ Language Options
156@xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
157@smallexample
84a0e7b8
JM
158-fno-access-control -fcheck-new -fconserve-space
159-fdollars-in-identifiers -fno-elide-constructors
160-fno-enforce-eh-specs -fexternal-templates
161-falt-external-templates
162-ffor-scope -fno-for-scope -fno-gnu-keywords -fhonor-std
163-fhuge-objects -fno-implicit-templates
164-fno-implicit-inline-templates -finit-priority
165-fno-implement-inlines -fms-extensions
166-fname-mangling-version-@var{n} -fno-operator-names
167-fno-optional-diags -fpermissive
168-frepo -fno-rtti -fsquangle -ftemplate-depth-@var{n}
169-fuse-cxa-atexit -fvtable-thunks -nostdinc++
170-fno-default-inline -Wctor-dtor-privacy
171-Wnon-virtual-dtor -Wreorder
172-Weffc++ -Wno-deprecated
173-Wno-non-template-friend -Wold-style-cast
174-Woverloaded-virtual -Wno-pmf-conversions
175-Wsign-promo -Wsynth
74291a4b
MM
176@end smallexample
177
764dbbf2
GDR
178@item Language Independent Options
179@xref{Language Independent Options,,Options to Control Diagnostic Messages Formatting}.
180@smallexample
181-fmessage-length=@var{n}
182-fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}
183@end smallexample
184
74291a4b
MM
185@item Warning Options
186@xref{Warning Options,,Options to Request or Suppress Warnings}.
187@smallexample
188-fsyntax-only -pedantic -pedantic-errors
84a0e7b8 189-w -W -Wall -Waggregate-return
08c5b6e8 190-Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment
84a0e7b8 191-Wconversion -Wdisabled-optimization -Werror
4d808927
JM
192-Wfloat-equal -Wformat -Wformat=2
193-Wformat-nonliteral
e9a25f70 194-Wid-clash-@var{len} -Wimplicit -Wimplicit-int
84a0e7b8
JM
195-Wimplicit-function-declaration
196-Werror-implicit-function-declaration
197-Wimport -Winline
795add94 198-Wlarger-than-@var{len} -Wlong-long
84a0e7b8
JM
199-Wmain -Wmissing-declarations
200-Wmissing-format-attribute -Wmissing-noreturn
4d808927
JM
201-Wmultichar -Wno-format-extra-args -Wno-format-y2k
202-Wno-import -Wpacked -Wpadded
bba975d4 203-Wparentheses -Wpointer-arith -Wredundant-decls
84a0e7b8
JM
204-Wreturn-type -Wsequence-point -Wshadow
205-Wsign-compare -Wswitch -Wsystem-headers
206-Wtrigraphs -Wundef -Wuninitialized
207-Wunknown-pragmas -Wunreachable-code
208-Wunused -Wunused-function -Wunused-label -Wunused-parameter
209-Wunused-value -Wunused-variable -Wwrite-strings
74291a4b
MM
210@end smallexample
211
fe50c0eb
GP
212@item C-only Warning Options
213@smallexample
214-Wbad-function-cast -Wmissing-prototypes -Wnested-externs
215-Wstrict-prototypes -Wtraditional
216@end smallexample
217
74291a4b
MM
218@item Debugging Options
219@xref{Debugging Options,,Options for Debugging Your Program or GCC}.
220@smallexample
f71f87f9
MM
221-a -ax -d@var{letters} -fdump-unnumbered -fdump-translation-unit-@var{file}
222-fpretend-float -fprofile-arcs -ftest-coverage
8c81598d 223-g -g@var{level} -gcoff -gdwarf -gdwarf-1 -gdwarf-1+ -gdwarf-2
74291a4b
MM
224-ggdb -gstabs -gstabs+ -gxcoff -gxcoff+
225-p -pg -print-file-name=@var{library} -print-libgcc-file-name
84a0e7b8
JM
226-print-prog-name=@var{program} -print-search-dirs -Q
227-save-temps -time
74291a4b
MM
228@end smallexample
229
230@item Optimization Options
231@xref{Optimize Options,,Options that Control Optimization}.
232@smallexample
84a0e7b8
JM
233-falign-functions=@var{n} -falign-jumps=@var{n}
234-falign-labels=@var{n} -falign-loops=@var{n}
235-fbranch-probabilities -fcaller-saves
236-fcse-follow-jumps -fcse-skip-blocks -fdata-sections -fdce
237-fdelayed-branch -fdelete-null-pointer-checks
238-fexpensive-optimizations -ffast-math -ffloat-store
239-fforce-addr -fforce-mem -ffunction-sections -fgcse
efa3896a 240-finline-functions -finline-limit=@var{n} -fkeep-inline-functions
84a0e7b8
JM
241-fkeep-static-consts -fmove-all-movables
242-fno-default-inline -fno-defer-pop
243-fno-function-cse -fno-inline -fno-math-errno -fno-peephole
244-fomit-frame-pointer -foptimize-register-move
245-foptimize-sibling-calls -freduce-all-givs
246-fregmove -frename-registers
247-frerun-cse-after-loop -frerun-loop-opt
248-fschedule-insns -fschedule-insns2
249-fsingle-precision-constant -fssa
250-fstrength-reduce -fstrict-aliasing -fthread-jumps -ftrapv
251-funroll-all-loops -funroll-loops
252-O -O0 -O1 -O2 -O3 -Os
74291a4b
MM
253@end smallexample
254
255@item Preprocessor Options
256@xref{Preprocessor Options,,Options Controlling the Preprocessor}.
257@smallexample
258-A@var{question}(@var{answer}) -C -dD -dM -dN
259-D@var{macro}@r{[}=@var{defn}@r{]} -E -H
260-idirafter @var{dir}
261-include @var{file} -imacros @var{file}
262-iprefix @var{file} -iwithprefix @var{dir}
f5a1b0d2 263-iwithprefixbefore @var{dir} -isystem @var{dir} -isystem-c++ @var{dir}
74291a4b
MM
264-M -MD -MM -MMD -MG -nostdinc -P -trigraphs
265-undef -U@var{macro} -Wp,@var{option}
266@end smallexample
267
268@item Assembler Option
269@xref{Assembler Options,,Passing Options to the Assembler}.
270@smallexample
271-Wa,@var{option}
272@end smallexample
273
274@item Linker Options
275@xref{Link Options,,Options for Linking}.
276@smallexample
277@var{object-file-name} -l@var{library}
278-nostartfiles -nodefaultlibs -nostdlib
279-s -static -shared -symbolic
280-Wl,@var{option} -Xlinker @var{option}
281-u @var{symbol}
282@end smallexample
283
284@item Directory Options
285@xref{Directory Options,,Options for Directory Search}.
286@smallexample
8c81598d 287-B@var{prefix} -I@var{dir} -I- -L@var{dir} -specs=@var{file}
74291a4b
MM
288@end smallexample
289
290@item Target Options
291@c I wrote this xref this way to avoid overfull hbox. -- rms
292@xref{Target Options}.
293@smallexample
294-b @var{machine} -V @var{version}
295@end smallexample
296
297@item Machine Dependent Options
298@xref{Submodel Options,,Hardware Models and Configurations}.
299@smallexample
300@emph{M680x0 Options}
8c81598d 301-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040
e5e809f4 302-m68060 -mcpu32 -m5200 -m68881 -mbitfield -mc68000 -mc68020
fb868474 303-mfpa -mnobitfield -mrtd -mshort -msoft-float -mpcrel
b71733d5 304-malign-int -mstrict-align
74291a4b 305
2856c3e3
SC
306@emph{M68hc1x Options}
307-m6811 -m6812 -m68hc11 -m68hc12
308-mauto-incdec -mshort -msoft-reg-count=@var{count}
309
74291a4b
MM
310@emph{VAX Options}
311-mg -mgnu -munix
312
313@emph{SPARC Options}
ded17aad
DE
314-mcpu=@var{cpu type}
315-mtune=@var{cpu type}
316-mcmodel=@var{code model}
ded17aad 317-m32 -m64
c219ddf7
BK
318-mapp-regs -mbroken-saverestore -mcypress
319-mepilogue -mfaster-structs -mflat
320-mfpu -mhard-float -mhard-quad-float
321-mimpure-text -mlive-g0 -mno-app-regs
322-mno-epilogue -mno-faster-structs -mno-flat -mno-fpu
323-mno-impure-text -mno-stack-bias -mno-unaligned-doubles
74291a4b
MM
324-msoft-float -msoft-quad-float -msparclite -mstack-bias
325-msupersparc -munaligned-doubles -mv8
326
327@emph{Convex Options}
328-mc1 -mc2 -mc32 -mc34 -mc38
329-margcount -mnoargcount
330-mlong32 -mlong64
331-mvolatile-cache -mvolatile-nocache
332
333@emph{AMD29K Options}
334-m29000 -m29050 -mbw -mnbw -mdw -mndw
335-mlarge -mnormal -msmall
336-mkernel-registers -mno-reuse-arg-regs
337-mno-stack-check -mno-storem-bug
338-mreuse-arg-regs -msoft-float -mstack-check
339-mstorem-bug -muser-registers
340
341@emph{ARM Options}
157a620e
NC
342-mapcs-frame -mno-apcs-frame
343-mapcs-26 -mapcs-32
344-mapcs-stack-check -mno-apcs-stack-check
345-mapcs-float -mno-apcs-float
346-mapcs-reentrant -mno-apcs-reentrant
347-msched-prolog -mno-sched-prolog
348-mlittle-endian -mbig-endian -mwords-little-endian
2ef56612 349-malignment-traps -mno-alignment-traps
157a620e
NC
350-msoft-float -mhard-float -mfpe
351-mthumb-interwork -mno-thumb-interwork
352-mcpu= -march= -mfpe=
353-mstructure-size-boundary=
354-mbsd -mxopen -mno-symrename
f5a1b0d2 355-mabort-on-noreturn
c27ba912 356-mlong-calls -mno-long-calls
62b10bbc 357-mnop-fun-dllimport -mno-nop-fun-dllimport
ed0e6530
PB
358-msingle-pic-base -mno-single-pic-base
359-mpic-register=
157a620e
NC
360
361@emph{Thumb Options}
362-mtpcs-frame -mno-tpcs-frame
363-mtpcs-leaf-frame -mno-tpcs-leaf-frame
364-mlittle-endian -mbig-endian
365-mthumb-interwork -mno-thumb-interwork
366-mstructure-size-boundary=
62b10bbc
NC
367-mnop-fun-dllimport -mno-nop-fun-dllimport
368-mcallee-super-interworking -mno-callee-super-interworking
369-mcaller-super-interworking -mno-caller-super-interworking
4bdc1ac7
PB
370-msingle-pic-base -mno-single-pic-base
371-mpic-register=
74291a4b 372
ecff22ab
JL
373@emph{MN10200 Options}
374-mrelax
375
6d6d0fa0
JL
376@emph{MN10300 Options}
377-mmult-bug
378-mno-mult-bug
705ac34f
JL
379-mam33
380-mno-am33
ecff22ab 381-mrelax
6d6d0fa0 382
861bb6c1
JL
383@emph{M32R/D Options}
384-mcode-model=@var{model type} -msdata=@var{sdata type}
385-G @var{num}
386
74291a4b
MM
387@emph{M88K Options}
388-m88000 -m88100 -m88110 -mbig-pic
389-mcheck-zero-division -mhandle-large-shift
390-midentify-revision -mno-check-zero-division
391-mno-ocs-debug-info -mno-ocs-frame-position
392-mno-optimize-arg-area -mno-serialize-volatile
393-mno-underscores -mocs-debug-info
394-mocs-frame-position -moptimize-arg-area
395-mserialize-volatile -mshort-data-@var{num} -msvr3
396-msvr4 -mtrap-large-shift -muse-div-instruction
397-mversion-03.00 -mwarn-passed-structs
398
399@emph{RS/6000 and PowerPC Options}
8c81598d
JM
400-mcpu=@var{cpu type}
401-mtune=@var{cpu type}
74291a4b 402-mpower -mno-power -mpower2 -mno-power2
5f59ecb7 403-mpowerpc -mpowerpc64 -mno-powerpc
74291a4b
MM
404-mpowerpc-gpopt -mno-powerpc-gpopt
405-mpowerpc-gfxopt -mno-powerpc-gfxopt
d77b4575 406-mnew-mnemonics -mold-mnemonics
74291a4b 407-mfull-toc -mminimal-toc -mno-fop-in-toc -mno-sum-in-toc
5f59ecb7 408-m64 -m32 -mxl-call -mno-xl-call -mthreads -mpe
74291a4b 409-msoft-float -mhard-float -mmultiple -mno-multiple
861bb6c1
JL
410-mstring -mno-string -mupdate -mno-update
411-mfused-madd -mno-fused-madd -mbit-align -mno-bit-align
74291a4b
MM
412-mstrict-align -mno-strict-align -mrelocatable
413-mno-relocatable -mrelocatable-lib -mno-relocatable-lib
2880d0aa 414-mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian
74291a4b 415-mcall-aix -mcall-sysv -mprototype -mno-prototype
2880d0aa 416-msim -mmvme -mads -myellowknife -memb -msdata
bff46771 417-msdata=@var{opt} -mvxworks -G @var{num}
74291a4b
MM
418
419@emph{RT Options}
420-mcall-lib-mul -mfp-arg-in-fpregs -mfp-arg-in-gregs
421-mfull-fp-blocks -mhc-struct-return -min-line-mul
422-mminimum-fp-blocks -mnohc-struct-return
423
424@emph{MIPS Options}
84a0e7b8
JM
425-mabicalls -mcpu=@var{cpu type}
426-membedded-data -muninit-const-in-rodata
74291a4b 427-membedded-pic -mfp32 -mfp64 -mgas -mgp32 -mgp64
8c81598d 428-mgpopt -mhalf-pic -mhard-float -mint64 -mips1
3ce1ba83 429-mips2 -mips3 -mips4 -mlong64 -mlong32 -mlong-calls -mmemcpy
74291a4b 430-mmips-as -mmips-tfile -mno-abicalls
919509ce 431-mno-embedded-data -mno-uninit-const-in-rodata -mno-embedded-pic
74291a4b
MM
432-mno-gpopt -mno-long-calls
433-mno-memcpy -mno-mips-tfile -mno-rnames -mno-stats
8c81598d
JM
434-mrnames -msoft-float
435-m4650 -msingle-float -mmad
74291a4b 436-mstats -EL -EB -G @var{num} -nocpp
3398f47f 437-mabi=32 -mabi=n32 -mabi=64 -mabi=eabi
1e387156 438-mfix7000 -mno-crt0
74291a4b
MM
439
440@emph{i386 Options}
04e149ab
KC
441-mcpu=@var{cpu type} -march=@var{cpu type}
442-mintel-syntax -mieee-fp -mno-fancy-math-387
74291a4b 443-mno-fp-ret-in-387 -msoft-float -msvr3-shlib
8c81598d
JM
444-mno-wide-multiply -mrtd -malign-double
445-mreg-alloc=@var{list} -mregparm=@var{num}
446-malign-jumps=@var{num} -malign-loops=@var{num}
00e59549 447-malign-functions=@var{num} -mpreferred-stack-boundary=@var{num}
79f05c19 448-mthreads -mno-align-stringops -minline-all-stringops
f73ad30e 449-mpush-args -maccumulate-outgoing-args
74291a4b
MM
450
451@emph{HPPA Options}
ea3bfbfe 452-march=@var{architecture type}
e5e809f4
JL
453-mbig-switch -mdisable-fpregs -mdisable-indexing
454-mfast-indirect-calls -mgas -mjump-in-delay
455-mlong-load-store -mno-big-switch -mno-disable-fpregs
8c81598d 456-mno-disable-indexing -mno-fast-indirect-calls -mno-gas
e5e809f4 457-mno-jump-in-delay -mno-long-load-store
c8730d93 458-mno-portable-runtime -mno-soft-float
e5e809f4 459-mno-space-regs -msoft-float -mpa-risc-1-0
ea3bfbfe 460-mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime
c8730d93 461-mschedule=@var{cpu type} -mspace-regs
74291a4b
MM
462
463@emph{Intel 960 Options}
464-m@var{cpu type} -masm-compat -mclean-linkage
465-mcode-align -mcomplex-addr -mleaf-procedures
466-mic-compat -mic2.0-compat -mic3.0-compat
467-mintel-asm -mno-clean-linkage -mno-code-align
468-mno-complex-addr -mno-leaf-procedures
469-mno-old-align -mno-strict-align -mno-tail-call
470-mnumerics -mold-align -msoft-float -mstrict-align
471-mtail-call
472
473@emph{DEC Alpha Options}
956d6950
JL
474-mfp-regs -mno-fp-regs -mno-soft-float -msoft-float
475-malpha-as -mgas
8c81598d 476-mieee -mieee-with-inexact -mieee-conformant
956d6950
JL
477-mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode}
478-mtrap-precision=@var{mode} -mbuild-constants
479-mcpu=@var{cpu type}
480-mbwx -mno-bwx -mcix -mno-cix -mmax -mno-max
4f69985c 481-mmemory-latency=@var{time}
74291a4b
MM
482
483@emph{Clipper Options}
8c81598d 484-mc300 -mc400
74291a4b
MM
485
486@emph{H8/300 Options}
dcb9d1f0 487-mrelax -mh -ms -mint32 -malign-300
74291a4b
MM
488
489@emph{SH Options}
3cadd778
AO
490-m1 -m2 -m3 -m3e
491-m4-nofpu -m4-single-only -m4-single -m4
492-mb -ml -mdalign -mrelax
493-mbigtable -mfmovd -mhitachi -mnomacsave
494-misize -mpadstruct -mspace
1a66cd67 495-mprefergot
93ca1662 496-musermode
74291a4b
MM
497
498@emph{System V Options}
499-Qy -Qn -YP,@var{paths} -Ym,@var{dir}
74291a4b 500
56b2d7a7
JL
501@emph{ARC Options}
502-EB -EL
503-mmangle-cpu -mcpu=@var{cpu} -mtext=@var{text section}
504-mdata=@var{data section} -mrodata=@var{readonly data section}
505
282a61e6
MH
506@emph{TMS320C3x/C4x Options}
507-mcpu=@var{cpu} -mbig -msmall -mregparm -mmemparm
508-mfast-fix -mmpyi -mbk -mti -mdp-isr-reload
509-mrpts=@var{count} -mrptb -mdb -mloop-unsigned
510-mparallel-insns -mparallel-mpy -mpreserve-float
511
f84271d9
JL
512@emph{V850 Options}
513-mlong-calls -mno-long-calls -mep -mno-ep
514-mprolog-function -mno-prolog-function -mspace
515-mtda=@var{n} -msda=@var{n} -mzda=@var{n}
e9a25f70 516-mv850 -mbig-switch
83575957
ID
517
518@emph{NS32K Options}
519-m32032 -m32332 -m32532 -m32081 -m32381 -mmult-add -mnomult-add
520-msoft-float -mrtd -mnortd -mregparam -mnoregparam -msb -mnosb
521-mbitfield -mnobitfield -mhimem -mnohimem
789a3090 522
052a4b28
DC
523@emph{AVR Options}
524-mmcu=@var{mcu} -msize -minit-stack=@var{n} -mno-interrupts
3a69a7d5 525-mcall-prologues -mno-tablejump -mtiny-stack
052a4b28 526
789a3090
NC
527@emph{MCore Options}
528-mhardlit, -mno-hardlit -mdiv -mno-div -mrelax-immediates
529-mno-relax-immediates -mwide-bitfields -mno-wide-bitfields
530-m4byte-functions -mno-4byte-functions -mcallgraph-data
531-mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim
532-mlittle-endian -mbig-endian -m210 -m340 -mstack-increment
f84271d9
JL
533@end smallexample
534
74291a4b
MM
535@item Code Generation Options
536@xref{Code Gen Options,,Options for Code Generation Conventions}.
537@smallexample
538-fcall-saved-@var{reg} -fcall-used-@var{reg}
84a0e7b8
JM
539-fexceptions -funwind-tables -ffixed-@var{reg}
540-finhibit-size-directive -finstrument-functions
861bb6c1 541-fcheck-memory-usage -fprefix-function-name
74291a4b
MM
542-fno-common -fno-ident -fno-gnu-linker
543-fpcc-struct-return -fpic -fPIC
544-freg-struct-return -fshared-data -fshort-enums
ab87f8c8 545-fshort-double -fvolatile -fvolatile-global -fvolatile-static
84a0e7b8 546-fverbose-asm -fpack-struct -fstack-check
a157febd 547-fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym}
e5eb27e5
JL
548-fargument-alias -fargument-noalias
549-fargument-noalias-global
19283265 550-fleading-underscore
74291a4b
MM
551@end smallexample
552@end table
553
554@menu
555* Overall Options:: Controlling the kind of output:
556 an executable, object files, assembler files,
557 or preprocessed source.
558* C Dialect Options:: Controlling the variant of C language compiled.
559* C++ Dialect Options:: Variations on C++.
764dbbf2
GDR
560* Language Independent Options:: Controlling how diagnostics should be
561 formatted.
74291a4b
MM
562* Warning Options:: How picky should the compiler be?
563* Debugging Options:: Symbol tables, measurements, and debugging dumps.
564* Optimize Options:: How much optimization?
565* Preprocessor Options:: Controlling header files and macro definitions.
566 Also, getting dependency information for Make.
567* Assembler Options:: Passing options to the assembler.
568* Link Options:: Specifying libraries and so on.
569* Directory Options:: Where to find header files and libraries.
570 Where to find the compiler executable files.
a743d340 571* Spec Files:: How to pass switches to sub-processes.
0c2d1a2a 572* Target Options:: Running a cross-compiler, or an old version of GCC.
74291a4b
MM
573@end menu
574
9d86bffc
JM
575@c man begin OPTIONS
576
74291a4b
MM
577@node Overall Options
578@section Options Controlling the Kind of Output
579
580Compilation can involve up to four stages: preprocessing, compilation
581proper, assembly and linking, always in that order. The first three
582stages apply to an individual source file, and end by producing an
583object file; linking combines all the object files (those newly
584compiled, and those specified as input) into an executable file.
585
586@cindex file name suffix
587For any given input file, the file name suffix determines what kind of
588compilation is done:
589
590@table @code
591@item @var{file}.c
592C source code which must be preprocessed.
593
594@item @var{file}.i
595C source code which should not be preprocessed.
596
597@item @var{file}.ii
598C++ source code which should not be preprocessed.
599
600@item @var{file}.m
601Objective-C source code. Note that you must link with the library
602@file{libobjc.a} to make an Objective-C program work.
603
b9265ec1
JM
604@item @var{file}.mi
605Objective-C source code which should not be preprocessed.
606
74291a4b
MM
607@item @var{file}.h
608C header file (not to be compiled or linked).
609
610@item @var{file}.cc
b9265ec1 611@itemx @var{file}.cp
74291a4b
MM
612@itemx @var{file}.cxx
613@itemx @var{file}.cpp
b9265ec1 614@itemx @var{file}.c++
74291a4b
MM
615@itemx @var{file}.C
616C++ source code which must be preprocessed. Note that in @samp{.cxx},
617the last two letters must both be literally @samp{x}. Likewise,
618@samp{.C} refers to a literal capital C.
619
b9265ec1
JM
620@item @var{file}.f
621@itemx @var{file}.for
622@itemx @var{file}.FOR
623Fortran source code which should not be preprocessed.
624
625@item @var{file}.F
626@itemx @var{file}.fpp
627@itemx @var{file}.FPP
628Fortran source code which must be preprocessed (with the traditional
629preprocessor).
630
631@item @var{file}.r
632Fortran source code which must be preprocessed with a RATFOR
633preprocessor (not included with GCC).
634
635@xref{Overall Options,,Options Controlling the Kind of Output, g77,
636Using and Porting GNU Fortran}, for more details of the handling of
637Fortran input files.
638
639@c FIXME: Descriptions of Java file types.
640@c @var{file}.java
641@c @var{file}.class
642@c @var{file}.zip
643@c @var{file}.jar
644
645@c GCC also knows about some suffixes for languages not yet included:
646@c Ada:
647@c @var{file}.ads
648@c @var{file}.adb
649@c @var{file}.ada
650@c Pascal:
651@c @var{file}.p
652@c @var{file}.pas
653
654@item @var{file}.ch
655@itemx @var{file}.chi
656CHILL source code (preprocessed with the traditional preprocessor).
657
74291a4b
MM
658@item @var{file}.s
659Assembler code.
660
661@item @var{file}.S
662Assembler code which must be preprocessed.
663
664@item @var{other}
665An object file to be fed straight into linking.
666Any file name with no recognized suffix is treated this way.
667@end table
668
669You can specify the input language explicitly with the @samp{-x} option:
670
671@table @code
672@item -x @var{language}
673Specify explicitly the @var{language} for the following input files
674(rather than letting the compiler choose a default based on the file
675name suffix). This option applies to all following input files until
676the next @samp{-x} option. Possible values for @var{language} are:
677@example
b9265ec1
JM
678c c-header cpp-output
679c++ c++-cpp-output
680objective-c objc-cpp-output
74291a4b 681assembler assembler-with-cpp
b9265ec1
JM
682f77 f77-cpp-input ratfor
683java chill
74291a4b 684@end example
b9265ec1 685@c Also f77-version, for internal use only.
74291a4b
MM
686
687@item -x none
688Turn off any specification of a language, so that subsequent files are
689handled according to their file name suffixes (as they are if @samp{-x}
690has not been used at all).
14a774a9
RK
691
692@item -pass-exit-codes
693Normally the @code{gcc} program will exit with the code of 1 if any
694phase of the compiler returns a non-success return code. If you specify
695@samp{-pass-exit-codes}, the @code{gcc} program will instead return with
696numerically highest error produced by any phase that returned an error
697indication.
74291a4b
MM
698@end table
699
700If you only want some of the stages of compilation, you can use
701@samp{-x} (or filename suffixes) to tell @code{gcc} where to start, and
702one of the options @samp{-c}, @samp{-S}, or @samp{-E} to say where
703@code{gcc} is to stop. Note that some combinations (for example,
704@samp{-x cpp-output -E} instruct @code{gcc} to do nothing at all.
705
706@table @code
707@item -c
708Compile or assemble the source files, but do not link. The linking
709stage simply is not done. The ultimate output is in the form of an
710object file for each source file.
711
712By default, the object file name for a source file is made by replacing
713the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
714
715Unrecognized input files, not requiring compilation or assembly, are
716ignored.
717
718@item -S
719Stop after the stage of compilation proper; do not assemble. The output
720is in the form of an assembler code file for each non-assembler input
721file specified.
722
723By default, the assembler file name for a source file is made by
724replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
725
726Input files that don't require compilation are ignored.
727
728@item -E
729Stop after the preprocessing stage; do not run the compiler proper. The
730output is in the form of preprocessed source code, which is sent to the
731standard output.
732
733Input files which don't require preprocessing are ignored.
734
735@cindex output file option
736@item -o @var{file}
737Place output in file @var{file}. This applies regardless to whatever
738sort of output is being produced, whether it be an executable file,
739an object file, an assembler file or preprocessed C code.
740
741Since only one output file can be specified, it does not make sense to
742use @samp{-o} when compiling more than one input file, unless you are
743producing an executable file as output.
744
745If @samp{-o} is not specified, the default is to put an executable file
746in @file{a.out}, the object file for @file{@var{source}.@var{suffix}} in
747@file{@var{source}.o}, its assembler file in @file{@var{source}.s}, and
748all preprocessed C source on standard output.@refill
749
750@item -v
751Print (on standard error output) the commands executed to run the stages
752of compilation. Also print the version number of the compiler driver
753program and of the preprocessor and the compiler proper.
754
755@item -pipe
756Use pipes rather than temporary files for communication between the
757various stages of compilation. This fails to work on some systems where
758the assembler is unable to read from a pipe; but the GNU assembler has
759no trouble.
844642e6
NC
760
761@item --help
762Print (on the standard output) a description of the command line options
763understood by @code{gcc}. If the @code{-v} option is also specified
764then @code{--help} will also be passed on to the various processes
765invoked by @code{gcc}, so that they can display the command line options
766they accept. If the @code{-W} option is also specified then command
767line options which have no documentation associated with them will also
768be displayed.
10501d8f
CC
769
770@item --target-help
771Print (on the standard output) a description of target specific command
772line options for each tool.
74291a4b
MM
773@end table
774
775@node Invoking G++
776@section Compiling C++ Programs
777
778@cindex suffixes for C++ source
779@cindex C++ source file suffixes
780C++ source files conventionally use one of the suffixes @samp{.C},
bba975d4 781@samp{.cc}, @samp{.cpp}, @samp{.c++}, @samp{.cp}, or @samp{.cxx};
0c2d1a2a 782preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
bba975d4
JM
783files with these names and compiles them as C++ programs even if you
784call the compiler the same way as for compiling C programs (usually with
785the name @code{gcc}).
74291a4b
MM
786
787@findex g++
788@findex c++
789However, C++ programs often require class libraries as well as a
790compiler that understands the C++ language---and under some
791circumstances, you might want to compile programs from standard input,
792or otherwise without a suffix that flags them as C++ programs.
0c2d1a2a 793@code{g++} is a program that calls GCC with the default language
e5e809f4 794set to C++, and automatically specifies linking against the C++
d8c70cd0 795library. On many systems, @code{g++} is also
74291a4b
MM
796installed with the name @code{c++}.
797
798@cindex invoking @code{g++}
799When you compile C++ programs, you may specify many of the same
800command-line options that you use for compiling programs in any
801language; or command-line options meaningful for C and related
802languages; or options that are meaningful only for C++ programs.
803@xref{C Dialect Options,,Options Controlling C Dialect}, for
804explanations of options for languages related to C.
805@xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
806explanations of options that are meaningful only for C++ programs.
807
808@node C Dialect Options
809@section Options Controlling C Dialect
810@cindex dialect options
811@cindex language dialect options
812@cindex options, dialect
813
814The following options control the dialect of C (or languages derived
815from C, such as C++ and Objective C) that the compiler accepts:
816
817@table @code
818@cindex ANSI support
c1030c7c 819@cindex ISO support
74291a4b 820@item -ansi
c1030c7c 821In C mode, support all ISO C89 programs. In C++ mode,
775afb25 822remove GNU extensions that conflict with ISO C++.
74291a4b 823
c1030c7c 824This turns off certain features of GCC that are incompatible with ISO
775afb25 825C (when compiling C code), or of standard C++ (when compiling C++ code),
0c2d1a2a 826such as the @code{asm} and @code{typeof} keywords, and
74291a4b
MM
827predefined macros such as @code{unix} and @code{vax} that identify the
828type of system you are using. It also enables the undesirable and
c1030c7c 829rarely used ISO trigraph feature. For the C compiler,
0c2d1a2a 830it disables recognition of C++ style @samp{//} comments as well as
775afb25 831the @code{inline} keyword.
74291a4b
MM
832
833The alternate keywords @code{__asm__}, @code{__extension__},
834@code{__inline__} and @code{__typeof__} continue to work despite
c1030c7c 835@samp{-ansi}. You would not want to use them in an ISO C program, of
74291a4b
MM
836course, but it is useful to put them in header files that might be included
837in compilations done with @samp{-ansi}. Alternate predefined macros
838such as @code{__unix__} and @code{__vax__} are also available, with or
839without @samp{-ansi}.
840
c1030c7c 841The @samp{-ansi} option does not cause non-ISO programs to be
74291a4b
MM
842rejected gratuitously. For that, @samp{-pedantic} is required in
843addition to @samp{-ansi}. @xref{Warning Options}.
844
845The macro @code{__STRICT_ANSI__} is predefined when the @samp{-ansi}
846option is used. Some header files may notice this macro and refrain
847from declaring certain functions or defining certain macros that the
c1030c7c 848ISO standard doesn't call for; this is to avoid interfering with any
74291a4b
MM
849programs that might use these names for other things.
850
01702459
JM
851Functions which would normally be builtin but do not have semantics
852defined by ISO C (such as @code{alloca} and @code{ffs}) are not builtin
853functions with @samp{-ansi} is used. @xref{Other Builtins,,Other
854built-in functions provided by GNU CC}, for details of the functions
855affected.
74291a4b 856
49419c8f 857@item -std=
3043b30e
ML
858Determine the language standard. A value for this option must be provided;
859possible values are
3932261a 860
3043b30e
ML
861@itemize @minus
862@item iso9899:1990
863Same as -ansi
864
865@item iso9899:199409
866ISO C as modified in amend. 1
867
49419c8f
JM
868@item iso9899:1999
869ISO C99. Note that this standard is not yet fully supported; see
59c5d27a 870@uref{http://gcc.gnu.org/c99status.html} for more information.
3043b30e
ML
871
872@item c89
873same as -std=iso9899:1990
874
49419c8f
JM
875@item c99
876same as -std=iso9899:1999
3043b30e
ML
877
878@item gnu89
879default, iso9899:1990 + gnu extensions
880
49419c8f
JM
881@item gnu99
882iso9899:1999 + gnu extensions
883
884@item iso9899:199x
885same as -std=iso9899:1999, deprecated
886
887@item c9x
888same as -std=iso9899:1999, deprecated
889
3043b30e 890@item gnu9x
49419c8f
JM
891same as -std=gnu99, deprecated
892
3043b30e
ML
893@end itemize
894
895Even when this option is not specified, you can still use some of the
896features of newer standards in so far as they do not conflict with
897previous C standards. For example, you may use @code{__restrict__} even
49419c8f 898when -std=c99 is not specified.
3932261a 899
c1030c7c
JM
900@xref{Standards,,Language Standards Supported by GCC}, for details of
901these standard versions.
902
74291a4b
MM
903@item -fno-asm
904Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
905keyword, so that code can use these words as identifiers. You can use
906the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
907instead. @samp{-ansi} implies @samp{-fno-asm}.
908
909In C++, this switch only affects the @code{typeof} keyword, since
910@code{asm} and @code{inline} are standard keywords. You may want to
9762e8a4 911use the @samp{-fno-gnu-keywords} flag instead, which has the same effect.
74291a4b
MM
912
913@item -fno-builtin
914@cindex builtin functions
01702459
JM
915Don't recognize builtin functions that do not begin with
916@samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
917functions provided by GNU CC}, for details of the functions affected,
918including those which are not builtin functions when @samp{-ansi} is
919used because they do not have an ISO standard meaning.
74291a4b
MM
920
921GCC normally generates special code to handle certain builtin functions
922more efficiently; for instance, calls to @code{alloca} may become single
923instructions that adjust the stack directly, and calls to @code{memcpy}
924may become inline copy loops. The resulting code is often both smaller
925and faster, but since the function calls no longer appear as such, you
926cannot set a breakpoint on those calls, nor can you change the behavior
927of the functions by linking with a different library.
928
861bb6c1
JL
929@item -fhosted
930@cindex hosted environment
931
932Assert that compilation takes place in a hosted environment. This implies
933@samp{-fbuiltin}. A hosted environment is one in which the
934entire standard library is available, and in which @code{main} has a return
935type of @code{int}. Examples are nearly everything except a kernel.
936This is equivalent to @samp{-fno-freestanding}.
937
938@item -ffreestanding
939@cindex hosted environment
940
941Assert that compilation takes place in a freestanding environment. This
942implies @samp{-fno-builtin}. A freestanding environment
943is one in which the standard library may not exist, and program startup may
944not necessarily be at @code{main}. The most obvious example is an OS kernel.
945This is equivalent to @samp{-fno-hosted}.
946
c1030c7c
JM
947@xref{Standards,,Language Standards Supported by GCC}, for details of
948freestanding and hosted environments.
949
74291a4b 950@item -trigraphs
c1030c7c 951Support ISO C trigraphs. You don't want to know about this
74291a4b
MM
952brain-damage. The @samp{-ansi} option implies @samp{-trigraphs}.
953
954@cindex traditional C language
955@cindex C language, traditional
956@item -traditional
957Attempt to support some aspects of traditional C compilers.
958Specifically:
959
960@itemize @bullet
961@item
962All @code{extern} declarations take effect globally even if they
963are written inside of a function definition. This includes implicit
964declarations of functions.
965
966@item
967The newer keywords @code{typeof}, @code{inline}, @code{signed}, @code{const}
968and @code{volatile} are not recognized. (You can still use the
969alternative keywords such as @code{__typeof__}, @code{__inline__}, and
970so on.)
971
972@item
973Comparisons between pointers and integers are always allowed.
974
975@item
976Integer types @code{unsigned short} and @code{unsigned char} promote
977to @code{unsigned int}.
978
979@item
980Out-of-range floating point literals are not an error.
981
982@item
c1030c7c 983Certain constructs which ISO regards as a single invalid preprocessing
74291a4b
MM
984number, such as @samp{0xe-0xd}, are treated as expressions instead.
985
986@item
987String ``constants'' are not necessarily constant; they are stored in
988writable space, and identical looking constants are allocated
989separately. (This is the same as the effect of
990@samp{-fwritable-strings}.)
991
992@cindex @code{longjmp} and automatic variables
993@item
994All automatic variables not declared @code{register} are preserved by
c1030c7c 995@code{longjmp}. Ordinarily, GNU C follows ISO C: automatic variables
74291a4b
MM
996not declared @code{volatile} may be clobbered.
997
998@item
999@kindex \x
1000@kindex \a
1001@cindex escape sequences, traditional
1002The character escape sequences @samp{\x} and @samp{\a} evaluate as the
1003literal characters @samp{x} and @samp{a} respectively. Without
1004@w{@samp{-traditional}}, @samp{\x} is a prefix for the hexadecimal
1005representation of a character, and @samp{\a} produces a bell.
ad299d9b 1006@end itemize
74291a4b 1007
74291a4b
MM
1008You may wish to use @samp{-fno-builtin} as well as @samp{-traditional}
1009if your program uses names that are normally GNU C builtin functions for
1010other purposes of its own.
1011
1012You cannot use @samp{-traditional} if you include any header files that
c1030c7c
JM
1013rely on ISO C features. Some vendors are starting to ship systems with
1014ISO C header files and you cannot use @samp{-traditional} on such
74291a4b
MM
1015systems to compile files that include any system headers.
1016
e5e809f4
JL
1017The @samp{-traditional} option also enables @samp{-traditional-cpp},
1018which is described next.
74291a4b
MM
1019
1020@item -traditional-cpp
1021Attempt to support some aspects of traditional C preprocessors.
1022Specifically:
1023
1024@itemize @bullet
1025@item
1026Comments convert to nothing at all, rather than to a space. This allows
1027traditional token concatenation.
1028
1029@item
1030In a preprocessing directive, the @samp{#} symbol must appear as the first
1031character of a line.
1032
1033@item
1034Macro arguments are recognized within string constants in a macro
1035definition (and their values are stringified, though without additional
1036quote marks, when they appear in such a context). The preprocessor
1037always considers a string constant to end at a newline.
1038
1039@item
1040@cindex detecting @w{@samp{-traditional}}
1041The predefined macro @code{__STDC__} is not defined when you use
1042@samp{-traditional}, but @code{__GNUC__} is (since the GNU extensions
1043which @code{__GNUC__} indicates are not affected by
1044@samp{-traditional}). If you need to write header files that work
1045differently depending on whether @samp{-traditional} is in use, by
1046testing both of these predefined macros you can distinguish four
c1030c7c 1047situations: GNU C, traditional GNU C, other ISO C compilers, and other
74291a4b
MM
1048old C compilers. The predefined macro @code{__STDC_VERSION__} is also
1049not defined when you use @samp{-traditional}. @xref{Standard
1050Predefined,,Standard Predefined Macros,cpp.info,The C Preprocessor},
1051for more discussion of these and other predefined macros.
1052
1053@item
1054@cindex string constants vs newline
1055@cindex newline vs string constants
1056The preprocessor considers a string constant to end at a newline (unless
1057the newline is escaped with @samp{\}). (Without @w{@samp{-traditional}},
1058string constants can contain the newline character as typed.)
1059@end itemize
1060
1061@item -fcond-mismatch
1062Allow conditional expressions with mismatched types in the second and
1063third arguments. The value of such an expression is void.
1064
1065@item -funsigned-char
1066Let the type @code{char} be unsigned, like @code{unsigned char}.
1067
1068Each kind of machine has a default for what @code{char} should
1069be. It is either like @code{unsigned char} by default or like
1070@code{signed char} by default.
1071
1072Ideally, a portable program should always use @code{signed char} or
1073@code{unsigned char} when it depends on the signedness of an object.
1074But many programs have been written to use plain @code{char} and
1075expect it to be signed, or expect it to be unsigned, depending on the
1076machines they were written for. This option, and its inverse, let you
1077make such a program work with the opposite default.
1078
1079The type @code{char} is always a distinct type from each of
1080@code{signed char} or @code{unsigned char}, even though its behavior
1081is always just like one of those two.
1082
1083@item -fsigned-char
1084Let the type @code{char} be signed, like @code{signed char}.
1085
1086Note that this is equivalent to @samp{-fno-unsigned-char}, which is
1087the negative form of @samp{-funsigned-char}. Likewise, the option
1088@samp{-fno-signed-char} is equivalent to @samp{-funsigned-char}.
1089
1090You may wish to use @samp{-fno-builtin} as well as @samp{-traditional}
1091if your program uses names that are normally GNU C builtin functions for
1092other purposes of its own.
1093
1094You cannot use @samp{-traditional} if you include any header files that
c1030c7c
JM
1095rely on ISO C features. Some vendors are starting to ship systems with
1096ISO C header files and you cannot use @samp{-traditional} on such
74291a4b
MM
1097systems to compile files that include any system headers.
1098
1099@item -fsigned-bitfields
1100@itemx -funsigned-bitfields
1101@itemx -fno-signed-bitfields
1102@itemx -fno-unsigned-bitfields
1103These options control whether a bitfield is signed or unsigned, when the
1104declaration does not use either @code{signed} or @code{unsigned}. By
1105default, such a bitfield is signed, because this is consistent: the
1106basic integer types such as @code{int} are signed types.
1107
1108However, when @samp{-traditional} is used, bitfields are all unsigned
1109no matter what.
1110
1111@item -fwritable-strings
1112Store string constants in the writable data segment and don't uniquize
1113them. This is for compatibility with old programs which assume they can
1114write into string constants. The option @samp{-traditional} also has
1115this effect.
1116
1117Writing into string constants is a very bad idea; ``constants'' should
1118be constant.
1119
1120@item -fallow-single-precision
1121Do not promote single precision math operations to double precision,
1122even when compiling with @samp{-traditional}.
1123
1124Traditional K&R C promotes all floating point operations to double
1125precision, regardless of the sizes of the operands. On the
1126architecture for which you are compiling, single precision may be faster
1127than double precision. If you must use @samp{-traditional}, but want
1128to use single precision operations when the operands are single
1129precision, use this option. This option has no effect when compiling
c1030c7c 1130with ISO or GNU C conventions (the default).
74291a4b 1131
3e37bef5
JM
1132@item -fshort-wchar
1133Override the underlying type for @samp{wchar_t} to be @samp{short
1134unsigned int} instead of the default for the target. This option is
1135useful for building programs to run under WINE.
74291a4b
MM
1136@end table
1137
1138@node C++ Dialect Options
1139@section Options Controlling C++ Dialect
1140
1141@cindex compiler options, C++
1142@cindex C++ options, command line
1143@cindex options, C++
1144This section describes the command-line options that are only meaningful
1145for C++ programs; but you can also use most of the GNU compiler options
1146regardless of what language your program is in. For example, you
1147might compile a file @code{firstClass.C} like this:
1148
1149@example
1dc5fc4b 1150g++ -g -frepo -O -c firstClass.C
74291a4b
MM
1151@end example
1152
1153@noindent
1dc5fc4b 1154In this example, only @samp{-frepo} is an option meant
74291a4b 1155only for C++ programs; you can use the other options with any
0c2d1a2a 1156language supported by GCC.
74291a4b
MM
1157
1158Here is a list of options that are @emph{only} for compiling C++ programs:
1159
1160@table @code
1161@item -fno-access-control
1162Turn off all access checking. This switch is mainly useful for working
1163around bugs in the access control code.
1164
74291a4b
MM
1165@item -fcheck-new
1166Check that the pointer returned by @code{operator new} is non-null
1167before attempting to modify the storage allocated. The current Working
1168Paper requires that @code{operator new} never return a null pointer, so
1169this check is normally unnecessary.
1170
1dc5fc4b
JM
1171An alternative to using this option is to specify that your
1172@code{operator new} does not throw any exceptions; if you declare it
1173@samp{throw()}, g++ will check the return value. See also @samp{new
1174(nothrow)}.
1175
74291a4b
MM
1176@item -fconserve-space
1177Put uninitialized or runtime-initialized global variables into the
1178common segment, as C does. This saves space in the executable at the
1179cost of not diagnosing duplicate definitions. If you compile with this
1180flag and your program mysteriously crashes after @code{main()} has
1181completed, you may have an object that is being destroyed twice because
1182two definitions were merged.
1183
1dc5fc4b
JM
1184This option is no longer useful on most targets, now that support has
1185been added for putting variables into BSS without making them common.
1186
74291a4b
MM
1187@item -fdollars-in-identifiers
1188Accept @samp{$} in identifiers. You can also explicitly prohibit use of
eb795509
RK
1189@samp{$} with the option @samp{-fno-dollars-in-identifiers}. (GNU C allows
1190@samp{$} by default on most target systems, but there are a few exceptions.)
74291a4b 1191Traditional C allowed the character @samp{$} to form part of
c1030c7c 1192identifiers. However, ISO C and C++ forbid @samp{$} in identifiers.
74291a4b 1193
1dc5fc4b
JM
1194@item -fno-elide-constructors
1195The C++ standard allows an implementation to omit creating a temporary
1196which is only used to initialize another object of the same type.
1197Specifying this option disables that optimization, and forces g++ to
1198call the copy constructor in all cases.
74291a4b 1199
dd1ba632
JM
1200@item -fno-enforce-eh-specs
1201Don't check for violation of exception specifications at runtime. This
1202option violates the C++ standard, but may be useful for reducing code
1203size in production builds, much like defining @samp{NDEBUG}. The compiler
1204will still optimize based on the exception specifications.
1205
74291a4b
MM
1206@item -fexternal-templates
1207Cause template instantiations to obey @samp{#pragma interface} and
1208@samp{implementation}; template instances are emitted or not according
1209to the location of the template definition. @xref{Template
1210Instantiation}, for more information.
1211
37f6b6bf
MM
1212This option is deprecated.
1213
74291a4b
MM
1214@item -falt-external-templates
1215Similar to -fexternal-templates, but template instances are emitted or
1216not according to the place where they are first instantiated.
1217@xref{Template Instantiation}, for more information.
1218
37f6b6bf
MM
1219This option is deprecated.
1220
74291a4b 1221@item -ffor-scope
8c81598d 1222@itemx -fno-for-scope
74291a4b
MM
1223If -ffor-scope is specified, the scope of variables declared in
1224a @i{for-init-statement} is limited to the @samp{for} loop itself,
34527c47 1225as specified by the C++ standard.
74291a4b
MM
1226If -fno-for-scope is specified, the scope of variables declared in
1227a @i{for-init-statement} extends to the end of the enclosing scope,
1228as was the case in old versions of gcc, and other (traditional)
1229implementations of C++.
1230
1231The default if neither flag is given to follow the standard,
1232but to allow and give a warning for old-style code that would
1233otherwise be invalid, or have different behavior.
1234
1235@item -fno-gnu-keywords
9762e8a4
ML
1236Do not recognize @code{typeof} as a keyword, so that code can use this
1237word as an identifier. You can use the keyword @code{__typeof__} instead.
1238@samp{-ansi} implies @samp{-fno-gnu-keywords}.
74291a4b 1239
95c81fb8
ML
1240@item -fhonor-std
1241Treat the @code{namespace std} as a namespace, instead of ignoring
1242it. For compatibility with earlier versions of g++, the compiler will,
1243by default, ignore @code{namespace-declarations},
1244@code{using-declarations}, @code{using-directives}, and
1245@code{namespace-names}, if they involve @code{std}.
1246
74291a4b
MM
1247@item -fhuge-objects
1248Support virtual function calls for objects that exceed the size
1249representable by a @samp{short int}. Users should not use this flag by
1dc5fc4b 1250default; if you need to use it, the compiler will tell you so.
74291a4b
MM
1251
1252This flag is not useful when compiling with -fvtable-thunks.
1253
1dc5fc4b
JM
1254Like all options that change the ABI, all C++ code, @emph{including
1255libgcc} must be built with the same setting of this option.
1256
1257@item -fno-implicit-templates
bba975d4
JM
1258Never emit code for non-inline templates which are instantiated
1259implicitly (i.e. by use); only emit code for explicit instantiations.
1260@xref{Template Instantiation}, for more information.
1261
1262@item -fno-implicit-inline-templates
1263Don't emit code for implicit instantiations of inline templates, either.
1264The default is to handle inlines differently so that compiles with and
1265without optimization will need the same set of explicit instantiations.
1dc5fc4b 1266
2ce3c6c6
JM
1267@item -finit-priority
1268Support @samp{__attribute__ ((init_priority (n)))} for controlling the
1269order of initialization of file-scope objects. On ELF targets, this
1270requires GNU ld 2.10 or later.
1271
74291a4b
MM
1272@item -fno-implement-inlines
1273To save space, do not emit out-of-line copies of inline functions
1274controlled by @samp{#pragma implementation}. This will cause linker
1275errors if these functions are not inlined everywhere they are called.
1276
631cf95d 1277@item -fms-extensions
32fb1fb2
PE
1278Disable pedantic warnings about constructs used in MFC, such as implicit
1279int and getting a pointer to member function via non-standard syntax.
631cf95d 1280
669ec2b4
JM
1281@item -fname-mangling-version-@var{n}
1282Control the way in which names are mangled. Version 0 is compatible
1283with versions of g++ before 2.8. Version 1 is the default. Version 1
1284will allow correct mangling of function templates. For example,
1285version 0 mangling does not mangle foo<int, double> and foo<int, char>
1286given this declaration:
1287
1288@example
1289template <class T, class U> void foo(T t);
1290@end example
1291
1292Like all options that change the ABI, all C++ code, @emph{including
1293libgcc} must be built with the same setting of this option.
1294
775afb25
ML
1295@item -fno-operator-names
1296Do not treat the operator name keywords @code{and}, @code{bitand},
74291a4b 1297@code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
775afb25 1298synonyms as keywords.
74291a4b 1299
4f8b4fd9
JM
1300@item -fno-optional-diags
1301Disable diagnostics that the standard says a compiler does not need to
bba975d4
JM
1302issue. Currently, the only such diagnostic issued by g++ is the one for
1303a name having multiple meanings within a class.
4f8b4fd9 1304
8c7707b0
JM
1305@item -fpermissive
1306Downgrade messages about nonconformant code from errors to warnings. By
1307default, g++ effectively sets @samp{-pedantic-errors} without
1308@samp{-pedantic}; this option reverses that. This behavior and this
2d9f9cf1 1309option are superseded by @samp{-pedantic}, which works as it does for GNU C.
8c7707b0 1310
8c81598d
JM
1311@item -frepo
1312Enable automatic template instantiation. This option also implies
1313@samp{-fno-implicit-templates}. @xref{Template Instantiation}, for more
1314information.
1315
8c7707b0 1316@item -fno-rtti
a7fbfcf9
JM
1317Disable generation of information about every class with virtual
1318functions for use by the C++ runtime type identification features
1319(@samp{dynamic_cast} and @samp{typeid}). If you don't use those parts
1320of the language, you can save some space by using this flag. Note that
1321exception handling uses the same information, but it will generate it as
1322needed.
8c7707b0 1323
669ec2b4
JM
1324@item -fsquangle
1325@itemx -fno-squangle
1326@samp{-fsquangle} will enable a compressed form of name mangling for
1327identifiers. In particular, it helps to shorten very long names by recognizing
1328types and class names which occur more than once, replacing them with special
1329short ID codes. This option also requires any C++ libraries being used to
1330be compiled with this option as well. The compiler has this disabled (the
1331equivalent of @samp{-fno-squangle}) by default.
1332
1333Like all options that change the ABI, all C++ code, @emph{including
1334libgcc.a} must be built with the same setting of this option.
1335
1dc5fc4b
JM
1336@item -ftemplate-depth-@var{n}
1337Set the maximum instantiation depth for template classes to @var{n}.
1338A limit on the template instantiation depth is needed to detect
1339endless recursions during template class instantiation. ANSI/ISO C++
1340conforming programs must not rely on a maximum depth greater than 17.
1341
fc693822
MM
1342@item -fuse-cxa-atexit
1343Register destructors for objects with static storage duration with the
1344@code{__cxa_atexit} function rather than the @code{atexit} function.
1345This option is required for fully standards-compliant handling of static
1346destructors, but will only work if your C library supports
1347@code{__cxa_atexit}.
1348
74291a4b
MM
1349@item -fvtable-thunks
1350Use @samp{thunks} to implement the virtual function dispatch table
1351(@samp{vtable}). The traditional (cfront-style) approach to
1352implementing vtables was to store a pointer to the function and two
1353offsets for adjusting the @samp{this} pointer at the call site. Newer
1354implementations store a single pointer to a @samp{thunk} function which
1355does any necessary adjustment and then calls the target function.
1356
f5a1b0d2
NC
1357This option also enables a heuristic for controlling emission of
1358vtables; if a class has any non-inline virtual functions, the vtable
1359will be emitted in the translation unit containing the first one of
1360those.
1361
1dc5fc4b
JM
1362Like all options that change the ABI, all C++ code, @emph{including
1363libgcc.a} must be built with the same setting of this option.
861bb6c1 1364
74291a4b
MM
1365@item -nostdinc++
1366Do not search for header files in the standard directories specific to
1367C++, but do still search the other standard directories. (This option
e5e809f4 1368is used when building the C++ library.)
74291a4b
MM
1369@end table
1370
1371In addition, these optimization, warning, and code generation options
1372have meanings only for C++ programs:
1373
1374@table @code
1375@item -fno-default-inline
1376Do not assume @samp{inline} for functions defined inside a class scope.
1dc5fc4b
JM
1377@xref{Optimize Options,,Options That Control Optimization}. Note that these
1378functions will have linkage like inline functions; they just won't be
1379inlined by default.
74291a4b 1380
bba975d4
JM
1381@item -Wctor-dtor-privacy (C++ only)
1382Warn when a class seems unusable, because all the constructors or
1383destructors in a class are private and the class has no friends or
1384public static member functions.
1385
1386@item -Wnon-virtual-dtor (C++ only)
1387Warn when a class declares a non-virtual destructor that should probably
1388be virtual, because it looks like the class will be used polymorphically.
1389
1390@item -Wreorder (C++ only)
1391@cindex reordering, warning
1392@cindex warning for reordering of member initializers
1393Warn when the order of member initializers given in the code does not
1394match the order in which they must be executed. For instance:
1395
1396@smallexample
1397struct A @{
1398 int i;
1399 int j;
1400 A(): j (0), i (1) @{ @}
1401@};
1402@end smallexample
1403
1404Here the compiler will warn that the member initializers for @samp{i}
1405and @samp{j} will be rearranged to match the declaration order of the
1406members.
1407@end table
1408
1409The following @samp{-W@dots{}} options are not affected by @samp{-Wall}.
1410
1411@table @code
1412@item -Weffc++ (C++ only)
1413Warn about violations of various style guidelines from Scott Meyers'
1414@cite{Effective C++} books. If you use this option, you should be aware
1415that the standard library headers do not obey all of these guidelines;
1416you can use @samp{grep -v} to filter out those warnings.
1417
2de45c06
ML
1418@item -Wno-deprecated (C++ only)
1419Do not warn about usage of deprecated features. @xref{Deprecated Features}.
1420
bba975d4
JM
1421@item -Wno-non-template-friend (C++ only)
1422Disable warnings when non-templatized friend functions are declared
1423within a template. With the advent of explicit template specification
1424support in g++, if the name of the friend is an unqualified-id (ie,
1425@samp{friend foo(int)}), the C++ language specification demands that the
1426friend declare or define an ordinary, nontemplate function. (Section
142714.5.3). Before g++ implemented explicit specification, unqualified-ids
1428could be interpreted as a particular specialization of a templatized
1429function. Because this non-conforming behavior is no longer the default
1430behavior for g++, @samp{-Wnon-template-friend} allows the compiler to
1431check existing code for potential trouble spots, and is on by default.
2228d450
MM
1432This new compiler behavior can be turned off with
1433@samp{-Wno-non-template-friend} which keeps the conformant compiler code
1434but disables the helpful warning.
bba975d4
JM
1435
1436@item -Wold-style-cast (C++ only)
1437Warn if an old-style (C-style) cast is used within a C++ program. The
1438new-style casts (@samp{static_cast}, @samp{reinterpret_cast}, and
1439@samp{const_cast}) are less vulnerable to unintended effects.
1440
1441@item -Woverloaded-virtual (C++ only)
1442@cindex overloaded virtual fn, warning
1443@cindex warning for overloaded virtual fn
1444Warn when a derived class function declaration may be an error in
1445defining a virtual function. In a derived class, the
1446definitions of virtual functions must match the type signature of a
1447virtual function declared in the base class. With this option, the
1448compiler warns when you define a function with the same name as a
1449virtual function, but with a type signature that does not match any
1450declarations from the base class.
1451
1452@item -Wno-pmf-conversions (C++ only)
1453Disable the diagnostic for converting a bound pointer to member function
1454to a plain pointer.
1455
1456@item -Wsign-promo (C++ only)
1457Warn when overload resolution chooses a promotion from unsigned or
1458enumeral type to a signed type over a conversion to an unsigned type of
1459the same size. Previous versions of g++ would try to preserve
1460unsignedness, but the standard mandates the current behavior.
1461
1462@item -Wsynth (C++ only)
1463@cindex warning for synthesized methods
1464@cindex synthesized methods, warning
1465Warn when g++'s synthesis behavior does not match that of cfront. For
1466instance:
1467
1468@smallexample
1469struct A @{
1470 operator int ();
1471 A& operator = (int);
1472@};
1473
1474main ()
1475@{
1476 A a,b;
1477 a = b;
1478@}
1479@end smallexample
74291a4b 1480
bba975d4
JM
1481In this example, g++ will synthesize a default @samp{A& operator =
1482(const A&);}, while cfront will use the user-defined @samp{operator =}.
74291a4b
MM
1483@end table
1484
764dbbf2
GDR
1485@node Language Independent Options
1486@section Options to Control Diagnostic Messages Formatting
1487@cindex options to control diagnostics formatting
1488@cindex diagnostic messages
1489@cindex message formatting
1490
b192711e 1491Traditionally, diagnostic messages have been formatted irrespective of
764dbbf2
GDR
1492the output device's aspect (e.g. its width, ...). The options described
1493below can be used to control the diagnostic messages formatting
1494algorithm, e.g. how many characters per line, how often source location
1495information should be reported. Right now, only the C++ front-end can
1496honor these options. However it is expected, in the near future, that
1497the remaining front-ends would be able to digest them correctly.
1498
1499@table @code
1500@item -fmessage-length=@var{n}
1501Try to format error messages so that they fit on lines of about @var{n}
1502characters. The default is 72 characters for g++ and 0 for the rest of
1503the front-ends supported by GCC. If @var{n} is zero, then no
1504line-wrapping will be done; each error message will appear on a single
1505line.
1506
1507@item -fdiagnostics-show-location=once
b192711e 1508Only meaningful in line-wrapping mode. Instructs the diagnostic messages
764dbbf2
GDR
1509reporter to emit @emph{once} source location information; that is, in
1510case the message is too long to fit on a single physical line and has to
1511be wrapped, the source location won't be emitted (as prefix) again,
1512over and over, in subsequent continuation lines. This is the default
1513behaviour.
1514
1515@item -fdiagnostics-show-location=every-line
1516Only meaningful in line-wrapping mode. Instructs the diagnostic
1517messages reporter to emit the same source location information (as
1518prefix) for physical lines that result from the process of breaking a
b192711e 1519a message which is too long to fit on a single line.
764dbbf2
GDR
1520
1521@end table
1522
74291a4b
MM
1523@node Warning Options
1524@section Options to Request or Suppress Warnings
1525@cindex options to control warnings
1526@cindex warning messages
1527@cindex messages, warning
1528@cindex suppressing warnings
1529
1530Warnings are diagnostic messages that report constructions which
1531are not inherently erroneous but which are risky or suggest there
1532may have been an error.
1533
1534You can request many specific warnings with options beginning @samp{-W},
1535for example @samp{-Wimplicit} to request warnings on implicit
1536declarations. Each of these specific warning options also has a
1537negative form beginning @samp{-Wno-} to turn off warnings;
1538for example, @samp{-Wno-implicit}. This manual lists only one of the
1539two forms, whichever is not the default.
1540
0c2d1a2a 1541These options control the amount and kinds of warnings produced by GCC:
74291a4b
MM
1542
1543@table @code
1544@cindex syntax checking
1545@item -fsyntax-only
1546Check the code for syntax errors, but don't do anything beyond that.
1547
1548@item -pedantic
074e95e3
JM
1549Issue all the warnings demanded by strict ISO C and ISO C++;
1550reject all programs that use forbidden extensions, and some other
1551programs that do not follow ISO C and ISO C++. For ISO C, follows the
1552version of the ISO C standard specified by any @samp{-std} option used.
74291a4b 1553
074e95e3 1554Valid ISO C and ISO C++ programs should compile properly with or without
74291a4b 1555this option (though a rare few will require @samp{-ansi}). However,
b1d16193
JL
1556without this option, certain GNU extensions and traditional C and C++
1557features are supported as well. With this option, they are rejected.
74291a4b
MM
1558
1559@samp{-pedantic} does not cause warning messages for use of the
1560alternate keywords whose names begin and end with @samp{__}. Pedantic
1561warnings are also disabled in the expression that follows
1562@code{__extension__}. However, only system header files should use
1563these escape routes; application programs should avoid them.
1564@xref{Alternate Keywords}.
1565
074e95e3 1566Some users try to use @samp{-pedantic} to check programs for strict ISO
74291a4b 1567C conformance. They soon find that it does not do quite what they want:
c1030c7c 1568it finds some non-ISO practices, but not all---only those for which
074e95e3
JM
1569ISO C @emph{requires} a diagnostic, and some others for which
1570diagnostics have been added.
74291a4b 1571
074e95e3 1572A feature to report any failure to conform to ISO C might be useful in
74291a4b 1573some instances, but would require considerable additional work and would
892d0a6d
AO
1574be quite different from @samp{-pedantic}. We don't have plans to
1575support such a feature in the near future.
74291a4b
MM
1576
1577@item -pedantic-errors
1578Like @samp{-pedantic}, except that errors are produced rather than
1579warnings.
1580
1581@item -w
1582Inhibit all warning messages.
1583
1584@item -Wno-import
1585Inhibit warning messages about the use of @samp{#import}.
1586
1587@item -Wchar-subscripts
1588Warn if an array subscript has type @code{char}. This is a common cause
1589of error, as programmers often forget that this type is signed on some
1590machines.
1591
1592@item -Wcomment
1593Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*}
1594comment, or whenever a Backslash-Newline appears in a @samp{//} comment.
1595
1596@item -Wformat
1597Check calls to @code{printf} and @code{scanf}, etc., to make sure that
1598the arguments supplied have types appropriate to the format string
1599specified.
1600
4d808927
JM
1601@samp{-Wformat} is included in @samp{-Wall}. For more control over some
1602aspects of format checking, the options @samp{-Wno-format-y2k},
1603@samp{-Wno-format-extra-args}, @samp{-Wformat-nonliteral} and
1604@samp{-Wformat=2} are available, but are not included in @samp{-Wall}.
1605
1606@item -Wno-format-y2k
1607If @samp{-Wformat} is specified, do not warn about @code{strftime}
1608formats which may yield only a two-digit year.
1609
1610@item -Wno-format-extra-args
1611If @samp{-Wformat} is specified, do not warn about excess arguments to a
1612@code{printf} or @code{scanf} format function. The C standard specifies
1613that such arguments are ignored.
1614
1615@item -Wformat-nonliteral
1616If @samp{-Wformat} is specified, also warn if the format string is not a
1617string literal and so cannot be checked, unless the format function
1618takes its format arguments as a @code{va_list}.
1619
1620@item -Wformat=2
1621Enable @samp{-Wformat} plus format checks not included in
1622@samp{-Wformat}. Currently equivalent to @samp{-Wformat
1623-Wformat-nonliteral}.
1624
e9a25f70
JL
1625@item -Wimplicit-int
1626Warn when a declaration does not specify a type.
1627
f5963e61
JL
1628@item -Wimplicit-function-declaration
1629@itemx -Werror-implicit-function-declaration
1630Give a warning (or error) whenever a function is used before being
1631declared.
e9a25f70 1632
74291a4b 1633@item -Wimplicit
e5e809f4
JL
1634Same as @samp{-Wimplicit-int} and @samp{-Wimplicit-function-}@*
1635@samp{declaration}.
861bb6c1
JL
1636
1637@item -Wmain
1638Warn if the type of @samp{main} is suspicious. @samp{main} should be a
1639function with external linkage, returning int, taking either zero
1640arguments, two, or three arguments of appropriate types.
4a870dba
JM
1641
1642@item -Wmultichar
1643Warn if a multicharacter constant (@samp{'FOOF'}) is used. Usually they
1644indicate a typo in the user's code, as they have implementation-defined
1645values, and should not be used in portable code.
3c12fcc2 1646
74291a4b
MM
1647@item -Wparentheses
1648Warn if parentheses are omitted in certain contexts, such
1649as when there is an assignment in a context where a truth value
1650is expected, or when operators are nested whose precedence people
1651often get confused about.
1652
e9a25f70
JL
1653Also warn about constructions where there may be confusion to which
1654@code{if} statement an @code{else} branch belongs. Here is an example of
1655such a case:
1656
1657@smallexample
1658@{
1659 if (a)
1660 if (b)
1661 foo ();
1662 else
1663 bar ();
1664@}
1665@end smallexample
1666
1667In C, every @code{else} branch belongs to the innermost possible @code{if}
1668statement, which in this example is @code{if (b)}. This is often not
1669what the programmer expected, as illustrated in the above example by
1670indentation the programmer chose. When there is the potential for this
1671confusion, GNU C will issue a warning when this flag is specified.
1672To eliminate the warning, add explicit braces around the innermost
1673@code{if} statement so there is no way the @code{else} could belong to
1674the enclosing @code{if}. The resulting code would look like this:
1675
1676@smallexample
1677@{
1678 if (a)
1679 @{
1680 if (b)
1681 foo ();
1682 else
1683 bar ();
1684 @}
1685@}
1686@end smallexample
1687
bb58bec5
JM
1688@item -Wsequence-point
1689Warn about code that may have undefined semantics because of violations
1690of sequence point rules in the C standard.
1691
1692The C standard defines the order in which expressions in a C program are
1693evaluated in terms of @dfn{sequence points}, which represent a partial
1694ordering between the execution of parts of the program: those executed
1695before the sequence point, and those executed after it. These occur
1696after the evaluation of a full expression (one which is not part of a
1697larger expression), after the evaluation of the first operand of a
1698@code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
1699function is called (but after the evaluation of its arguments and the
1700expression denoting the called function), and in certain other places.
1701Other than as expressed by the sequence point rules, the order of
1702evaluation of subexpressions of an expression is not specified. All
1703these rules describe only a partial order rather than a total order,
1704since, for example, if two functions are called within one expression
1705with no sequence point between them, the order in which the functions
1706are called is not specified. However, the standards committee have
1707ruled that function calls do not overlap.
1708
1709It is not specified when between sequence points modifications to the
1710values of objects take effect. Programs whose behavior depends on this
1711have undefined behavior; the C standard specifies that ``Between the
1712previous and next sequence point an object shall have its stored value
1713modified at most once by the evaluation of an expression. Furthermore,
1714the prior value shall be read only to determine the value to be
1715stored.''. If a program breaks these rules, the results on any
1716particular implementation are entirely unpredictable.
1717
1718Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
1719= b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
1720diagnosed by this option, and it may give an occasional false positive
1721result, but in general it has been found fairly effective at detecting
1722this sort of problem in programs.
1723
1724The present implementation of this option only works for C programs. A
1725future implementation may also work for C++ programs.
1726
1727There is some controversy over the precise meaning of the sequence point
1728rules in subtle cases. Alternative formal definitions may be found in
1729Clive Feather's ``Annex S''
163686bd 1730@uref{http://wwwold.dkuug.dk/JTC1/SC22/WG14/www/docs/n925.htm} and in
bb58bec5
JM
1731Michael Norrish's thesis
1732@uref{http://www.cl.cam.ac.uk/users/mn200/PhD/thesis-report.ps.gz}.
163686bd
JM
1733Other discussions are by Raymond Mak
1734@uref{http://wwwold.dkuug.dk/JTC1/SC22/WG14/www/docs/n926.htm} and
1735D. Hugh Redelmeier
1736@uref{http://wwwold.dkuug.dk/JTC1/SC22/WG14/www/docs/n927.htm}.
bb58bec5 1737
74291a4b 1738@item -Wreturn-type
32c4c36c
ML
1739Warn whenever a function is defined with a return-type that defaults to
1740@code{int}. Also warn about any @code{return} statement with no
1741return-value in a function whose return-type is not @code{void}.
1742
1743For C++, a function without return type always produces a diagnostic
1744message, even when @samp{-Wno-return-type} is specified. The only
1745exceptions are @samp{main} and functions defined in system headers.
74291a4b
MM
1746
1747@item -Wswitch
1748Warn whenever a @code{switch} statement has an index of enumeral type
1749and lacks a @code{case} for one or more of the named codes of that
1750enumeration. (The presence of a @code{default} label prevents this
1751warning.) @code{case} labels outside the enumeration range also
1752provoke warnings when this option is used.
1753
1754@item -Wtrigraphs
f2ecb02d
JM
1755Warn if any trigraphs are encountered that might change the meaning of
1756the program (trigraphs within comments are not warned about).
74291a4b 1757
078721e1
AC
1758@item -Wunused-function
1759Warn whenever a static function is declared but not defined or a
1760non\-inline static function is unused.
74291a4b 1761
078721e1
AC
1762@item -Wunused-label
1763Warn whenever a label is declared but not used.
1764
1765To suppress this warning use the @samp{unused} attribute
1766(@pxref{Variable Attributes}).
1767
1768@item -Wunused-parameter
1769Warn whenever a function parameter is unused aside from its declaration.
1770
1771To suppress this warning use the @samp{unused} attribute
1772(@pxref{Variable Attributes}).
956d6950 1773
078721e1
AC
1774@item -Wunused-variable
1775Warn whenever a local variable or non-constant static variable is unused
1776aside from its declaration
1777
1778To suppress this warning use the @samp{unused} attribute
74291a4b
MM
1779(@pxref{Variable Attributes}).
1780
078721e1
AC
1781@item -Wunused-value
1782Warn whenever a statement computes a result that is explicitly not used.
1783
1784To suppress this warning cast the expression to @samp{void}.
1785
1786@item -Wunused
1787All all the above @samp{-Wunused} options combined.
1788
1789In order to get a warning about an unused function parameter, you must
b192711e 1790either specify @samp{-W -Wunused} or separately specify
078721e1
AC
1791@samp{-Wunused-parameter}.
1792
74291a4b 1793@item -Wuninitialized
c5c76735
JL
1794Warn if an automatic variable is used without first being initialized or
1795if a variable may be clobbered by a @code{setjmp} call.
74291a4b
MM
1796
1797These warnings are possible only in optimizing compilation,
1798because they require data flow information that is computed only
1799when optimizing. If you don't specify @samp{-O}, you simply won't
1800get these warnings.
1801
1802These warnings occur only for variables that are candidates for
1803register allocation. Therefore, they do not occur for a variable that
1804is declared @code{volatile}, or whose address is taken, or whose size
1805is other than 1, 2, 4 or 8 bytes. Also, they do not occur for
1806structures, unions or arrays, even when they are in registers.
1807
1808Note that there may be no warning about a variable that is used only
1809to compute a value that itself is never used, because such
1810computations may be deleted by data flow analysis before the warnings
1811are printed.
1812
0c2d1a2a 1813These warnings are made optional because GCC is not smart
74291a4b
MM
1814enough to see all the reasons why the code might be correct
1815despite appearing to have an error. Here is one example of how
1816this can happen:
1817
1818@smallexample
1819@{
1820 int x;
1821 switch (y)
1822 @{
1823 case 1: x = 1;
1824 break;
1825 case 2: x = 4;
1826 break;
1827 case 3: x = 5;
1828 @}
1829 foo (x);
1830@}
1831@end smallexample
1832
1833@noindent
1834If the value of @code{y} is always 1, 2 or 3, then @code{x} is
0c2d1a2a 1835always initialized, but GCC doesn't know this. Here is
74291a4b
MM
1836another common case:
1837
1838@smallexample
1839@{
1840 int save_y;
1841 if (change_y) save_y = y, y = new_y;
1842 @dots{}
1843 if (change_y) y = save_y;
1844@}
1845@end smallexample
1846
1847@noindent
1848This has no bug because @code{save_y} is used only if it is set.
1849
20300b05 1850@cindex @code{longjmp} warnings
b192711e 1851This option also warns when a non-volatile automatic variable might be
c5c76735
JL
1852changed by a call to @code{longjmp}. These warnings as well are possible
1853only in optimizing compilation.
20300b05
GK
1854
1855The compiler sees only the calls to @code{setjmp}. It cannot know
1856where @code{longjmp} will be called; in fact, a signal handler could
1857call it at any point in the code. As a result, you may get a warning
1858even when there is in fact no problem because @code{longjmp} cannot
1859in fact be called at the place which would cause a problem.
1860
74291a4b
MM
1861Some spurious warnings can be avoided if you declare all the functions
1862you use that never return as @code{noreturn}. @xref{Function
1863Attributes}.
1864
c5c76735
JL
1865@item -Wreorder (C++ only)
1866@cindex reordering, warning
1867@cindex warning for reordering of member initializers
1868Warn when the order of member initializers given in the code does not
1869match the order in which they must be executed. For instance:
1870
d300e551
NC
1871@item -Wunknown-pragmas
1872@cindex warning for unknown pragmas
1873@cindex unknown pragmas, warning
1874@cindex pragmas, warning of unknown
1875Warn when a #pragma directive is encountered which is not understood by
1876GCC. If this command line option is used, warnings will even be issued
1877for unknown pragmas in system header files. This is not the case if
1878the warnings were only enabled by the @samp{-Wall} command line option.
1879
74291a4b
MM
1880@item -Wall
1881All of the above @samp{-W} options combined. This enables all the
1882warnings about constructions that some users consider questionable, and
1883that are easy to avoid (or modify to prevent the warning), even in
1884conjunction with macros.
317639a8
BC
1885
1886@item -Wsystem-headers
1887@cindex warnings from system headers
1888@cindex system headers, warnings from
1889Print warning messages for constructs found in system header files.
1890Warnings from system headers are normally suppressed, on the assumption
1891that they usually do not indicate real problems and would only make the
1892compiler output harder to read. Using this command line option tells
1893GCC to emit warnings from system headers as if they occurred in user
1894code. However, note that using @samp{-Wall} in conjunction with this
1895option will @emph{not} warn about unknown pragmas in system
1896headers---for that, @samp{-Wunknown-pragmas} must also be used.
74291a4b
MM
1897@end table
1898
1899The following @samp{-W@dots{}} options are not implied by @samp{-Wall}.
1900Some of them warn about constructions that users generally do not
1901consider questionable, but which occasionally you might wish to check
1902for; others warn about constructions that are necessary or hard to avoid
1903in some cases, and there is no simple way to modify the code to suppress
1904the warning.
1905
1906@table @code
1907@item -W
1908Print extra warning messages for these events:
1909
1910@itemize @bullet
74291a4b
MM
1911@item
1912A function can return either with or without a value. (Falling
1913off the end of the function body is considered returning without
1914a value.) For example, this function would evoke such a
1915warning:
1916
1917@smallexample
1918@group
1919foo (a)
1920@{
1921 if (a > 0)
1922 return a;
1923@}
1924@end group
1925@end smallexample
1926
1927@item
1928An expression-statement or the left-hand side of a comma expression
1929contains no side effects.
1930To suppress the warning, cast the unused expression to void.
1931For example, an expression such as @samp{x[i,j]} will cause a warning,
1932but @samp{x[(void)i,j]} will not.
1933
1934@item
1935An unsigned value is compared against zero with @samp{<} or @samp{<=}.
1936
1937@item
1938A comparison like @samp{x<=y<=z} appears; this is equivalent to
1939@samp{(x<=y ? 1 : 0) <= z}, which is a different interpretation from
1940that of ordinary mathematical notation.
1941
1942@item
1943Storage-class specifiers like @code{static} are not the first things in
1944a declaration. According to the C Standard, this usage is obsolescent.
1945
e0c9fbb7
JM
1946@item
1947The return type of a function has a type qualifier such as @code{const}.
1948Such a type qualifier has no effect, since the value returned by a
1949function is not an lvalue. (But don't warn about the GNU extension of
1950@code{volatile void} return types. That extension will be warned about
1951if @samp{-pedantic} is specified.)
1952
74291a4b
MM
1953@item
1954If @samp{-Wall} or @samp{-Wunused} is also specified, warn about unused
1955arguments.
1956
e9a25f70
JL
1957@item
1958A comparison between signed and unsigned values could produce an
1959incorrect result when the signed value is converted to unsigned.
e5e809f4 1960(But don't warn if @samp{-Wno-sign-compare} is also specified.)
e9a25f70 1961
74291a4b
MM
1962@item
1963An aggregate has a partly bracketed initializer.
1964For example, the following code would evoke such a warning,
1965because braces are missing around the initializer for @code{x.h}:
1966
1967@smallexample
1968struct s @{ int f, g; @};
1969struct t @{ struct s h; int i; @};
1970struct t x = @{ 1, 2, 3 @};
1971@end smallexample
dbde0d5d
BH
1972
1973@item
1974An aggregate has an initializer which does not initialize all members.
1975For example, the following code would cause such a warning, because
1976@code{x.h} would be implicitly initialized to zero:
1977
1978@smallexample
1979struct s @{ int f, g, h; @};
1980struct s x = @{ 3, 4 @};
1981@end smallexample
74291a4b
MM
1982@end itemize
1983
f793a95e
JL
1984@item -Wfloat-equal
1985Warn if floating point values are used in equality comparisons.
1986
488d3985
GK
1987The idea behind this is that sometimes it is convenient (for the
1988programmer) to consider floating-point values as approximations to
1989infinitely precise real numbers. If you are doing this, then you need
1990to compute (by analysing the code, or in some other way) the maximum or
1991likely maximum error that the computation introduces, and allow for it
1992when performing comparisons (and when producing output, but that's a
1993different problem). In particular, instead of testing for equality, you
1994would check to see whether the two values have ranges that overlap; and
1995this is done with the relational operators, so equality comparisons are
1996probably mistaken.
1997
fe50c0eb 1998@item -Wtraditional (C only)
74291a4b 1999Warn about certain constructs that behave differently in traditional and
c1030c7c 2000ISO C.
74291a4b
MM
2001
2002@itemize @bullet
2003@item
2004Macro arguments occurring within string constants in the macro body.
2005These would substitute the argument in traditional C, but are part of
c1030c7c 2006the constant in ISO C.
74291a4b
MM
2007
2008@item
2009A function declared external in one block and then used after the end of
2010the block.
2011
2012@item
2013A @code{switch} statement has an operand of type @code{long}.
db838bb8
KG
2014
2015@item
2016A non-@code{static} function declaration follows a @code{static} one.
2017This construct is not accepted by some traditional C compilers.
48776cde
KG
2018
2019@item
c1030c7c 2020The ISO type of an integer constant has a different width or
48776cde
KG
2021signedness from its traditional type. This warning is only issued if
2022the base of the constant is ten. I.e. hexadecimal or octal values, which
2023typically represent bit patterns, are not warned about.
bb66adca
KG
2024
2025@item
c1030c7c 2026Usage of ISO string concatenation is detected.
7f094a94
KG
2027
2028@item
2029A function macro appears without arguments.
895ea614
KG
2030
2031@item
2032The unary plus operator.
2033
2034@item
2035Initialization of automatic aggregates.
2036
2037@item
2038Identifier conflicts with labels. Traditional C lacks a separate
2039namespace for labels.
253b6b82
KG
2040
2041@item
2042Initialization of unions. If the initializer is zero, the warning is
2043omitted. This is done under the assumption that the zero initializer in
2044user code appears conditioned on e.g. @code{__STDC__} to avoid missing
2045initializer warnings and relies on default initialization to zero in the
2046traditional C case.
7da92c08
KG
2047
2048@item
2049The `U' integer constant suffix, or the `F' or `L' floating point
2050constant suffixes. (Traditonal C does support the `L' suffix on integer
2051constants.) Note, these suffixes appear in macros defined in the system
2052headers of most modern systems, e.g. the _MIN/_MAX macros in limits.h.
2053Use of these macros can lead to spurious warnings as they do not
2054necessarily reflect whether the code in question is any less portable to
2055traditional C given that suitable backup definitions are provided.
74291a4b
MM
2056@end itemize
2057
861bb6c1
JL
2058@item -Wundef
2059Warn if an undefined identifier is evaluated in an @samp{#if} directive.
2060
74291a4b
MM
2061@item -Wshadow
2062Warn whenever a local variable shadows another local variable.
2063
2064@item -Wid-clash-@var{len}
2065Warn whenever two distinct identifiers match in the first @var{len}
2066characters. This may help you prepare a program that will compile
2067with certain obsolete, brain-damaged compilers.
2068
2069@item -Wlarger-than-@var{len}
2070Warn whenever an object of larger than @var{len} bytes is defined.
2071
2072@item -Wpointer-arith
2073Warn about anything that depends on the ``size of'' a function type or
2074of @code{void}. GNU C assigns these types a size of 1, for
2075convenience in calculations with @code{void *} pointers and pointers
2076to functions.
2077
fe50c0eb 2078@item -Wbad-function-cast (C only)
74291a4b
MM
2079Warn whenever a function call is cast to a non-matching type.
2080For example, warn if @code{int malloc()} is cast to @code{anything *}.
2081
2082@item -Wcast-qual
2083Warn whenever a pointer is cast so as to remove a type qualifier from
2084the target type. For example, warn if a @code{const char *} is cast
2085to an ordinary @code{char *}.
2086
2087@item -Wcast-align
2088Warn whenever a pointer is cast such that the required alignment of the
2089target is increased. For example, warn if a @code{char *} is cast to
2090an @code{int *} on machines where integers can only be accessed at
2091two- or four-byte boundaries.
2092
2093@item -Wwrite-strings
2094Give string constants the type @code{const char[@var{length}]} so that
2095copying the address of one into a non-@code{const} @code{char *}
2096pointer will get a warning. These warnings will help you find at
2097compile time code that can try to write into a string constant, but
2098only if you have been very careful about using @code{const} in
2099declarations and prototypes. Otherwise, it will just be a nuisance;
2100this is why we did not make @samp{-Wall} request these warnings.
2101
2102@item -Wconversion
2103Warn if a prototype causes a type conversion that is different from what
2104would happen to the same argument in the absence of a prototype. This
2105includes conversions of fixed point to floating and vice versa, and
2106conversions changing the width or signedness of a fixed point argument
2107except when the same as the default promotion.
2108
2109Also, warn if a negative integer constant expression is implicitly
2110converted to an unsigned type. For example, warn about the assignment
2111@code{x = -1} if @code{x} is unsigned. But do not warn about explicit
2112casts like @code{(unsigned) -1}.
2113
e9a25f70
JL
2114@item -Wsign-compare
2115@cindex warning for comparison of signed and unsigned values
2116@cindex comparison of signed and unsigned values, warning
2117@cindex signed and unsigned values, comparison warning
2118Warn when a comparison between signed and unsigned values could produce
2119an incorrect result when the signed value is converted to unsigned.
2120This warning is also enabled by @samp{-W}; to get the other warnings
2121of @samp{-W} without this warning, use @samp{-W -Wno-sign-compare}.
2122
74291a4b
MM
2123@item -Waggregate-return
2124Warn if any functions that return structures or unions are defined or
2125called. (In languages where you can return an array, this also elicits
2126a warning.)
2127
fe50c0eb 2128@item -Wstrict-prototypes (C only)
74291a4b
MM
2129Warn if a function is declared or defined without specifying the
2130argument types. (An old-style function definition is permitted without
2131a warning if preceded by a declaration which specifies the argument
2132types.)
2133
fe50c0eb 2134@item -Wmissing-prototypes (C only)
74291a4b
MM
2135Warn if a global function is defined without a previous prototype
2136declaration. This warning is issued even if the definition itself
2137provides a prototype. The aim is to detect global functions that fail
2138to be declared in header files.
2139
2140@item -Wmissing-declarations
2141Warn if a global function is defined without a previous declaration.
2142Do so even if the definition itself provides a prototype.
2143Use this option to detect global functions that are not declared in
2144header files.
2145
0ca3fb0a
KG
2146@item -Wmissing-noreturn
2147Warn about functions which might be candidates for attribute @code{noreturn}.
2148Note these are only possible candidates, not absolute ones. Care should
2149be taken to manually verify functions actually do not ever return before
2150adding the @code{noreturn} attribute, otherwise subtle code generation
2151bugs could be introduced.
2152
74ff4629
JM
2153@item -Wmissing-format-attribute
2154If @samp{-Wformat} is enabled, also warn about functions which might be
2155candidates for @code{format} attributes. Note these are only possible
2156candidates, not absolute ones. GCC will guess that @code{format}
2157attributes might be appropriate for any function that calls a function
2158like @code{vprintf} or @code{vscanf}, but this might not always be the
2159case, and some functions for which @code{format} attributes are
2160appropriate may not be detected. This option has no effect unless
2161@samp{-Wformat} is enabled (possibly by @samp{-Wall}).
2162
3c12fcc2
GM
2163@item -Wpacked
2164Warn if a structure is given the packed attribute, but the packed
2165attribute has no effect on the layout or size of the structure.
2166Such structures may be mis-aligned for little benefit. For
2167instance, in this code, the variable @code{f.x} in @code{struct bar}
2168will be misaligned even though @code{struct bar} does not itself
2169have the packed attribute:
2170
2171@smallexample
2172@group
2173struct foo @{
2174 int x;
2175 char a, b, c, d;
2176@} __attribute__((packed));
2177struct bar @{
2178 char z;
2179 struct foo f;
2180@};
2181@end group
2182@end smallexample
2183
2184@item -Wpadded
2185Warn if padding is included in a structure, either to align an element
2186of the structure or to align the whole structure. Sometimes when this
2187happens it is possible to rearrange the fields of the structure to
2188reduce the padding and so make the structure smaller.
2189
74291a4b
MM
2190@item -Wredundant-decls
2191Warn if anything is declared more than once in the same scope, even in
2192cases where multiple declaration is valid and changes nothing.
2193
fe50c0eb 2194@item -Wnested-externs (C only)
252215a7 2195Warn if an @code{extern} declaration is encountered within a function.
74291a4b 2196
312f6255
GK
2197@item -Wunreachable-code
2198Warn if the compiler detects that code will never be executed.
2199
2200This option is intended to warn when the compiler detects that at
2201least a whole line of source code will never be executed, because
2202some condition is never satisfied or because it is after a
2203procedure that never returns.
2204
2205It is possible for this option to produce a warning even though there
2206are circumstances under which part of the affected line can be executed,
2207so care should be taken when removing apparently-unreachable code.
2208
2209For instance, when a function is inlined, a warning may mean that the
2210line is unreachable in only one inlined copy of the function.
2211
2212This option is not made part of @samp{-Wall} because in a debugging
2213version of a program there is often substantial code which checks
2214correct functioning of the program and is, hopefully, unreachable
2215because the program does work. Another common use of unreachable
2216code is to provide behaviour which is selectable at compile-time.
2217
74291a4b 2218@item -Winline
c5c76735 2219Warn if a function can not be inlined and it was declared as inline.
74291a4b 2220
795add94
VM
2221@item -Wlong-long
2222Warn if @samp{long long} type is used. This is default. To inhibit
2223the warning messages, use @samp{-Wno-long-long}. Flags
2224@samp{-Wlong-long} and @samp{-Wno-long-long} are taken into account
2225only when @samp{-pedantic} flag is used.
2226
18424ae1
BL
2227@item -Wdisabled-optimization
2228Warn if a requested optimization pass is disabled. This warning does
2229not generally indicate that there is anything wrong with your code; it
2230merely indicates that GCC's optimizers were unable to handle the code
2231effectively. Often, the problem is that your code is too big or too
2232complex; GCC will refuse to optimize programs when the optimization
2233itself is likely to take inordinate amounts of time.
2234
74291a4b
MM
2235@item -Werror
2236Make all warnings into errors.
2237@end table
2238
2239@node Debugging Options
0c2d1a2a 2240@section Options for Debugging Your Program or GCC
74291a4b
MM
2241@cindex options, debugging
2242@cindex debugging information options
2243
0c2d1a2a 2244GCC has various special options that are used for debugging
74291a4b
MM
2245either your program or GCC:
2246
2247@table @code
2248@item -g
2249Produce debugging information in the operating system's native format
2250(stabs, COFF, XCOFF, or DWARF). GDB can work with this debugging
2251information.
2252
2253On most systems that use stabs format, @samp{-g} enables use of extra
2254debugging information that only GDB can use; this extra information
2255makes debugging work better in GDB but will probably make other debuggers
2256crash or
2257refuse to read the program. If you want to control for certain whether
2258to generate the extra information, use @samp{-gstabs+}, @samp{-gstabs},
861bb6c1 2259@samp{-gxcoff+}, @samp{-gxcoff}, @samp{-gdwarf-1+}, or @samp{-gdwarf-1}
74291a4b
MM
2260(see below).
2261
0c2d1a2a 2262Unlike most other C compilers, GCC allows you to use @samp{-g} with
74291a4b
MM
2263@samp{-O}. The shortcuts taken by optimized code may occasionally
2264produce surprising results: some variables you declared may not exist
2265at all; flow of control may briefly move where you did not expect it;
2266some statements may not be executed because they compute constant
2267results or their values were already at hand; some statements may
2268execute in different places because they were moved out of loops.
2269
2270Nevertheless it proves possible to debug optimized output. This makes
2271it reasonable to use the optimizer for programs that might have bugs.
2272
0c2d1a2a 2273The following options are useful when GCC is generated with the
74291a4b
MM
2274capability for more than one debugging format.
2275
2276@item -ggdb
861bb6c1
JL
2277Produce debugging information for use by GDB. This means to use the
2278most expressive format available (DWARF 2, stabs, or the native format
2279if neither of those are supported), including GDB extensions if at all
2280possible.
74291a4b
MM
2281
2282@item -gstabs
2283Produce debugging information in stabs format (if that is supported),
2284without GDB extensions. This is the format used by DBX on most BSD
2285systems. On MIPS, Alpha and System V Release 4 systems this option
2286produces stabs debugging output which is not understood by DBX or SDB.
2287On System V Release 4 systems this option requires the GNU assembler.
2288
2289@item -gstabs+
2290Produce debugging information in stabs format (if that is supported),
2291using GNU extensions understood only by the GNU debugger (GDB). The
2292use of these extensions is likely to make other debuggers crash or
2293refuse to read the program.
2294
2295@item -gcoff
2296Produce debugging information in COFF format (if that is supported).
2297This is the format used by SDB on most System V systems prior to
2298System V Release 4.
2299
2300@item -gxcoff
2301Produce debugging information in XCOFF format (if that is supported).
2302This is the format used by the DBX debugger on IBM RS/6000 systems.
2303
2304@item -gxcoff+
2305Produce debugging information in XCOFF format (if that is supported),
2306using GNU extensions understood only by the GNU debugger (GDB). The
2307use of these extensions is likely to make other debuggers crash or
2308refuse to read the program, and may cause assemblers other than the GNU
2309assembler (GAS) to fail with an error.
2310
2311@item -gdwarf
861bb6c1
JL
2312Produce debugging information in DWARF version 1 format (if that is
2313supported). This is the format used by SDB on most System V Release 4
2314systems.
74291a4b
MM
2315
2316@item -gdwarf+
861bb6c1
JL
2317Produce debugging information in DWARF version 1 format (if that is
2318supported), using GNU extensions understood only by the GNU debugger
2319(GDB). The use of these extensions is likely to make other debuggers
2320crash or refuse to read the program.
2321
2322@item -gdwarf-2
2323Produce debugging information in DWARF version 2 format (if that is
2324supported). This is the format used by DBX on IRIX 6.
74291a4b
MM
2325
2326@item -g@var{level}
2327@itemx -ggdb@var{level}
2328@itemx -gstabs@var{level}
2329@itemx -gcoff@var{level}
2330@itemx -gxcoff@var{level}
2331@itemx -gdwarf@var{level}
861bb6c1 2332@itemx -gdwarf-2@var{level}
74291a4b
MM
2333Request debugging information and also use @var{level} to specify how
2334much information. The default level is 2.
2335
2336Level 1 produces minimal information, enough for making backtraces in
2337parts of the program that you don't plan to debug. This includes
2338descriptions of functions and external variables, but no information
2339about local variables and no line numbers.
2340
2341Level 3 includes extra information, such as all the macro definitions
2342present in the program. Some debuggers support macro expansion when
2343you use @samp{-g3}.
2344
2345@cindex @code{prof}
2346@item -p
2347Generate extra code to write profile information suitable for the
2348analysis program @code{prof}. You must use this option when compiling
2349the source files you want data about, and you must also use it when
2350linking.
2351
2352@cindex @code{gprof}
2353@item -pg
2354Generate extra code to write profile information suitable for the
2355analysis program @code{gprof}. You must use this option when compiling
2356the source files you want data about, and you must also use it when
2357linking.
2358
2359@cindex @code{tcov}
2360@item -a
2361Generate extra code to write profile information for basic blocks, which will
2362record the number of times each basic block is executed, the basic block start
2363address, and the function name containing the basic block. If @samp{-g} is
2364used, the line number and filename of the start of the basic block will also be
2365recorded. If not overridden by the machine description, the default action is
2366to append to the text file @file{bb.out}.
2367
2368This data could be analyzed by a program like @code{tcov}. Note,
2369however, that the format of the data is not what @code{tcov} expects.
2370Eventually GNU @code{gprof} should be extended to process this data.
2371
898f531b
JL
2372@item -Q
2373Makes the compiler print out each function name as it is compiled, and
2374print some statistics about each pass when it finishes.
2375
74291a4b
MM
2376@item -ax
2377Generate extra code to profile basic blocks. Your executable will
2378produce output that is a superset of that produced when @samp{-a} is
2379used. Additional output is the source and target address of the basic
2380blocks where a jump takes place, the number of times a jump is executed,
2381and (optionally) the complete sequence of basic blocks being executed.
2382The output is appended to file @file{bb.out}.
2383
2384You can examine different profiling aspects without recompilation. Your
956d6950 2385executable will read a list of function names from file @file{bb.in}.
74291a4b
MM
2386Profiling starts when a function on the list is entered and stops when
2387that invocation is exited. To exclude a function from profiling, prefix
2388its name with `-'. If a function name is not unique, you can
2389disambiguate it by writing it in the form
2390@samp{/path/filename.d:functionname}. Your executable will write the
2391available paths and filenames in file @file{bb.out}.
2392
2393Several function names have a special meaning:
2394@table @code
2395@item __bb_jumps__
2396Write source, target and frequency of jumps to file @file{bb.out}.
2397@item __bb_hidecall__
2398Exclude function calls from frequency count.
2399@item __bb_showret__
2400Include function returns in frequency count.
2401@item __bb_trace__
2402Write the sequence of basic blocks executed to file @file{bbtrace.gz}.
2403The file will be compressed using the program @samp{gzip}, which must
2404exist in your @code{PATH}. On systems without the @samp{popen}
2405function, the file will be named @file{bbtrace} and will not be
2406compressed. @strong{Profiling for even a few seconds on these systems
2407will produce a very large file.} Note: @code{__bb_hidecall__} and
2408@code{__bb_showret__} will not affect the sequence written to
2409@file{bbtrace.gz}.
2410@end table
2411
2412Here's a short example using different profiling parameters
2413in file @file{bb.in}. Assume function @code{foo} consists of basic blocks
24141 and 2 and is called twice from block 3 of function @code{main}. After
2415the calls, block 3 transfers control to block 4 of @code{main}.
2416
2417With @code{__bb_trace__} and @code{main} contained in file @file{bb.in},
2418the following sequence of blocks is written to file @file{bbtrace.gz}:
24190 3 1 2 1 2 4. The return from block 2 to block 3 is not shown, because
2420the return is to a point inside the block and not to the top. The
2421block address 0 always indicates, that control is transferred
2422to the trace from somewhere outside the observed functions. With
2423@samp{-foo} added to @file{bb.in}, the blocks of function
2424@code{foo} are removed from the trace, so only 0 3 4 remains.
2425
2426With @code{__bb_jumps__} and @code{main} contained in file @file{bb.in},
2427jump frequencies will be written to file @file{bb.out}. The
2428frequencies are obtained by constructing a trace of blocks
2429and incrementing a counter for every neighbouring pair of blocks
2430in the trace. The trace 0 3 1 2 1 2 4 displays the following
2431frequencies:
2432
2433@example
2434Jump from block 0x0 to block 0x3 executed 1 time(s)
2435Jump from block 0x3 to block 0x1 executed 1 time(s)
2436Jump from block 0x1 to block 0x2 executed 2 time(s)
2437Jump from block 0x2 to block 0x1 executed 1 time(s)
2438Jump from block 0x2 to block 0x4 executed 1 time(s)
2439@end example
2440
2441With @code{__bb_hidecall__}, control transfer due to call instructions
2442is removed from the trace, that is the trace is cut into three parts: 0
24433 4, 0 1 2 and 0 1 2. With @code{__bb_showret__}, control transfer due
2444to return instructions is added to the trace. The trace becomes: 0 3 1
24452 3 1 2 3 4. Note, that this trace is not the same, as the sequence
2446written to @file{bbtrace.gz}. It is solely used for counting jump
2447frequencies.
2448
861bb6c1
JL
2449@item -fprofile-arcs
2450Instrument @dfn{arcs} during compilation. For each function of your
0c2d1a2a 2451program, GCC creates a program flow graph, then finds a spanning tree
861bb6c1
JL
2452for the graph. Only arcs that are not on the spanning tree have to be
2453instrumented: the compiler adds code to count the number of times that these
2454arcs are executed. When an arc is the only exit or only entrance to a
2455block, the instrumentation code can be added to the block; otherwise, a
2456new basic block must be created to hold the instrumentation code.
2457
2458Since not every arc in the program must be instrumented, programs
2459compiled with this option run faster than programs compiled with
2460@samp{-a}, which adds instrumentation code to every basic block in the
2461program. The tradeoff: since @code{gcov} does not have
2462execution counts for all branches, it must start with the execution
2463counts for the instrumented branches, and then iterate over the program
2464flow graph until the entire graph has been solved. Hence, @code{gcov}
2465runs a little more slowly than a program which uses information from
2466@samp{-a}.
2467
2468@samp{-fprofile-arcs} also makes it possible to estimate branch
2469probabilities, and to calculate basic block execution counts. In
2470general, basic block execution counts do not give enough information to
2471estimate all branch probabilities. When the compiled program exits, it
2472saves the arc execution counts to a file called
2473@file{@var{sourcename}.da}. Use the compiler option
2474@samp{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
2475Control Optimization}) when recompiling, to optimize using estimated
2476branch probabilities.
2477
2478@need 2000
2479@item -ftest-coverage
2480Create data files for the @code{gcov} code-coverage utility
0c2d1a2a 2481(@pxref{Gcov,, @code{gcov}: a GCC Test Coverage Program}).
861bb6c1
JL
2482The data file names begin with the name of your source file:
2483
2484@table @code
2485@item @var{sourcename}.bb
2486A mapping from basic blocks to line numbers, which @code{gcov} uses to
2487associate basic block execution counts with line numbers.
2488
2489@item @var{sourcename}.bbg
2490A list of all arcs in the program flow graph. This allows @code{gcov}
2491to reconstruct the program flow graph, so that it can compute all basic
2492block and arc execution counts from the information in the
2493@code{@var{sourcename}.da} file (this last file is the output from
2494@samp{-fprofile-arcs}).
2495@end table
2496
74291a4b
MM
2497@item -d@var{letters}
2498Says to make debugging dumps during compilation at times specified by
2499@var{letters}. This is used for debugging the compiler. The file names
375e2d5c 2500for most of the dumps are made by appending a pass number and a word to
923c2d86 2501the source file name (e.g. @file{foo.c.00.rtl} or @file{foo.c.01.sibling}).
375e2d5c 2502Here are the possible letters for use in @var{letters}, and their meanings:
74291a4b
MM
2503
2504@table @samp
375e2d5c
RH
2505@item A
2506Annotate the assembler output with miscellaneous debugging information.
956d6950 2507@item b
923c2d86 2508Dump after computing branch probabilities, to @file{@var{file}.11.bp}.
48d9ade5 2509@item B
8bb16620 2510Dump after block reordering, to @file{@var{file}.26.bbro}.
032713aa 2511@item c
470fc13d
KH
2512Dump after instruction combination, to the file @file{@var{file}.14.combine}.
2513@item C
2514Dump after the first if conversion, to the file @file{@var{file}.15.ce}.
032713aa 2515@item d
8bb16620 2516Dump after delayed branch scheduling, to @file{@var{file}.29.dbr}.
032713aa 2517@item D
f5963e61
JL
2518Dump all macro definitions, at the end of preprocessing, in addition to
2519normal output.
48d9ade5
RK
2520@item e
2521Dump after SSA optimizations, to @file{@var{file}.05.ssa} and
2522@file{@var{file}.06.ussa}.
470fc13d 2523@item E
8bb16620 2524Dump after the second if conversion, to @file{@var{file}.24.ce2}.
74291a4b 2525@item f
470fc13d 2526Dump after life analysis, to @file{@var{file}.13.life}.
48d9ade5
RK
2527@item F
2528Dump after purging @code{ADDRESSOF} codes, to @file{@var{file}.04.addressof}.
74291a4b 2529@item g
470fc13d 2530Dump after global register allocation, to @file{@var{file}.19.greg}.
8bb16620
BS
2531@item o
2532Dump after post-reload CSE and other optimizations, to @file{@var{file}.20.postreload}.
7506f491 2533@item G
470fc13d 2534Dump after GCSE, to @file{@var{file}.08.gcse}.
48d9ade5
RK
2535@item i
2536Dump after sibling call optimizations, to @file{@var{file}.01.sibling}.
032713aa 2537@item j
470fc13d 2538Dump after the first jump optimization, to @file{@var{file}.02.jump}.
74291a4b 2539@item J
8bb16620 2540Dump after the last jump optimization, to @file{@var{file}.27.jump2}.
74291a4b 2541@item k
470fc13d 2542Dump after conversion from registers to stack, to @file{@var{file}.29.stack}.
032713aa 2543@item l
470fc13d 2544Dump after local register allocation, to @file{@var{file}.18.lreg}.
032713aa 2545@item L
470fc13d 2546Dump after loop optimization, to @file{@var{file}.09.loop}.
032713aa
NC
2547@item M
2548Dump after performing the machine dependent reorganisation pass, to
8bb16620 2549@file{@var{file}.28.mach}.
48d9ade5 2550@item n
470fc13d 2551Dump after register renumbering, to @file{@var{file}.23.rnreg}.
032713aa 2552@item N
470fc13d 2553Dump after the register move pass, to @file{@var{file}.16.regmove}.
032713aa 2554@item r
375e2d5c 2555Dump after RTL generation, to @file{@var{file}.00.rtl}.
032713aa 2556@item R
375e2d5c 2557Dump after the second instruction scheduling pass, to
8bb16620 2558@file{@var{file}.25.sched2}.
032713aa
NC
2559@item s
2560Dump after CSE (including the jump optimization that sometimes follows
48d9ade5 2561CSE), to @file{@var{file}.03.cse}.
032713aa 2562@item S
375e2d5c 2563Dump after the first instruction scheduling pass, to
470fc13d 2564@file{@var{file}.17.sched}.
032713aa
NC
2565@item t
2566Dump after the second CSE pass (including the jump optimization that
470fc13d 2567sometimes follows CSE), to @file{@var{file}.10.cse2}.
48d9ade5 2568@item w
8bb16620 2569Dump after the second flow pass, to @file{@var{file}.21.flow2}.
470fc13d
KH
2570@item X
2571Dump after dead code elimination, to @file{@var{file}.06.dce}.
48d9ade5 2572@item z
470fc13d 2573Dump after the peephole pass, to @file{@var{file}.22.peephole2}.
74291a4b
MM
2574@item a
2575Produce all the dumps listed above.
2576@item m
2577Print statistics on memory usage, at the end of the run, to
2578standard error.
2579@item p
2580Annotate the assembler output with a comment indicating which
f20b5577
MM
2581pattern and alternative was used. The length of each instruction is
2582also printed.
2856c3e3
SC
2583@item P
2584Dump the RTL in the assembler output as a comment before each instruction.
2585Also turns on @samp{-dp} annotation.
375e2d5c
RH
2586@item v
2587For each of the other indicated dump files (except for
2588@file{@var{file}.00.rtl}), dump a representation of the control flow graph
b192711e 2589suitable for viewing with VCG to @file{@var{file}.@var{pass}.vcg}.
62a1403d
AS
2590@item x
2591Just generate RTL for a function instead of compiling it. Usually used
2592with @samp{r}.
032713aa
NC
2593@item y
2594Dump debugging information during parsing, to standard error.
74291a4b
MM
2595@end table
2596
b707b450
R
2597@item -fdump-unnumbered
2598When doing debugging dumps (see -d option above), suppress instruction
2599numbers and line number note output. This makes it more feasible to
b192711e 2600use diff on debugging dumps for compiler invocations with different
b707b450
R
2601options, in particular with and without -g.
2602
f2ecb02d 2603@item -fdump-translation-unit-@var{file} (C and C++ only)
f71f87f9
MM
2604Dump a representation of the tree structure for the entire translation
2605unit to @var{file}.
2606
74291a4b
MM
2607@item -fpretend-float
2608When running a cross-compiler, pretend that the target machine uses the
2609same floating point format as the host machine. This causes incorrect
2610output of the actual floating constants, but the actual instruction
0c2d1a2a 2611sequence will probably be the same as GCC would make when running on
74291a4b
MM
2612the target machine.
2613
2614@item -save-temps
2615Store the usual ``temporary'' intermediate files permanently; place them
2616in the current directory and name them based on the source file. Thus,
2617compiling @file{foo.c} with @samp{-c -save-temps} would produce files
f2ecb02d
JM
2618@file{foo.i} and @file{foo.s}, as well as @file{foo.o}. This creates a
2619preprocessed @file{foo.i} output file even though the compiler now
2620normally uses an integrated preprocessor.
74291a4b 2621
03c41c05
ZW
2622@item -time
2623Report the CPU time taken by each subprocess in the compilation
f2ecb02d
JM
2624sequence. For C source files, this is the compiler proper and assembler
2625(plus the linker if linking is done). The output looks like this:
03c41c05
ZW
2626
2627@smallexample
03c41c05
ZW
2628# cc1 0.12 0.01
2629# as 0.00 0.01
2630@end smallexample
2631
2632The first number on each line is the ``user time,'' that is time spent
2633executing the program itself. The second number is ``system time,''
2634time spent executing operating system routines on behalf of the program.
2635Both numbers are in seconds.
2636
74291a4b
MM
2637@item -print-file-name=@var{library}
2638Print the full absolute name of the library file @var{library} that
2639would be used when linking---and don't do anything else. With this
0c2d1a2a 2640option, GCC does not compile or link anything; it just prints the
74291a4b
MM
2641file name.
2642
2643@item -print-prog-name=@var{program}
2644Like @samp{-print-file-name}, but searches for a program such as @samp{cpp}.
2645
2646@item -print-libgcc-file-name
2647Same as @samp{-print-file-name=libgcc.a}.
2648
2649This is useful when you use @samp{-nostdlib} or @samp{-nodefaultlibs}
2650but you do want to link with @file{libgcc.a}. You can do
2651
2652@example
2653gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
2654@end example
2655
2656@item -print-search-dirs
2657Print the name of the configured installation directory and a list of
2658program and library directories gcc will search---and don't do anything else.
2659
2660This is useful when gcc prints the error message
2661@samp{installation problem, cannot exec cpp: No such file or directory}.
2662To resolve this you either need to put @file{cpp} and the other compiler
2663components where gcc expects to find them, or you can set the environment
2664variable @code{GCC_EXEC_PREFIX} to the directory where you installed them.
2665Don't forget the trailing '/'.
2666@xref{Environment Variables}.
2667@end table
2668
2669@node Optimize Options
2670@section Options That Control Optimization
2671@cindex optimize options
2672@cindex options, optimization
2673
2674These options control various sorts of optimizations:
2675
2676@table @code
2677@item -O
2678@itemx -O1
2679Optimize. Optimizing compilation takes somewhat more time, and a lot
2680more memory for a large function.
2681
2682Without @samp{-O}, the compiler's goal is to reduce the cost of
2683compilation and to make debugging produce the expected results.
2684Statements are independent: if you stop the program with a breakpoint
2685between statements, you can then assign a new value to any variable or
2686change the program counter to any other statement in the function and
2687get exactly the results you would expect from the source code.
2688
2689Without @samp{-O}, the compiler only allocates variables declared
2690@code{register} in registers. The resulting compiled code is a little
2691worse than produced by PCC without @samp{-O}.
2692
2693With @samp{-O}, the compiler tries to reduce code size and execution
2694time.
2695
2696When you specify @samp{-O}, the compiler turns on @samp{-fthread-jumps}
2697and @samp{-fdefer-pop} on all machines. The compiler turns on
2698@samp{-fdelayed-branch} on machines that have delay slots, and
2699@samp{-fomit-frame-pointer} on machines that can support debugging even
2700without a frame pointer. On some machines the compiler also turns
2701on other flags.@refill
2702
2703@item -O2
0c2d1a2a 2704Optimize even more. GCC performs nearly all supported optimizations
74291a4b
MM
2705that do not involve a space-speed tradeoff. The compiler does not
2706perform loop unrolling or function inlining when you specify @samp{-O2}.
2707As compared to @samp{-O}, this option increases both compilation time
2708and the performance of the generated code.
2709
2b2a8f1f
RH
2710@samp{-O2} turns on all optional optimizations except for loop unrolling,
2711function inlining, and register renaming. It also turns on the
2712@samp{-fforce-mem} option on all machines and frame pointer elimination
2713on machines where doing so does not interfere with debugging.
74291a4b
MM
2714
2715@item -O3
2716Optimize yet more. @samp{-O3} turns on all optimizations specified by
2b2a8f1f
RH
2717@samp{-O2} and also turns on the @samp{-finline-functions} and
2718@samp{-frename-registers} options.
74291a4b
MM
2719
2720@item -O0
2721Do not optimize.
2722
c6aded7c
AG
2723@item -Os
2724Optimize for size. @samp{-Os} enables all @samp{-O2} optimizations that
2725do not typically increase code size. It also performs further
2726optimizations designed to reduce code size.
2727
74291a4b
MM
2728If you use multiple @samp{-O} options, with or without level numbers,
2729the last such option is the one that is effective.
2730@end table
2731
2732Options of the form @samp{-f@var{flag}} specify machine-independent
2733flags. Most flags have both positive and negative forms; the negative
2734form of @samp{-ffoo} would be @samp{-fno-foo}. In the table below,
2735only one of the forms is listed---the one which is not the default.
2736You can figure out the other form by either removing @samp{no-} or
2737adding it.
2738
2739@table @code
2740@item -ffloat-store
2741Do not store floating point variables in registers, and inhibit other
2742options that might change whether a floating point value is taken from a
2743register or memory.
2744
2745@cindex floating point precision
2746This option prevents undesirable excess precision on machines such as
2747the 68000 where the floating registers (of the 68881) keep more
2748precision than a @code{double} is supposed to have. Similarly for the
2749x86 architecture. For most programs, the excess precision does only
2750good, but a few programs rely on the precise definition of IEEE floating
6fd74494
CB
2751point. Use @samp{-ffloat-store} for such programs, after modifying
2752them to store all pertinent intermediate computations into variables.
74291a4b
MM
2753
2754@item -fno-default-inline
2755Do not make member functions inline by default merely because they are
2756defined inside the class scope (C++ only). Otherwise, when you specify
2757@w{@samp{-O}}, member functions defined inside class scope are compiled
2758inline by default; i.e., you don't need to add @samp{inline} in front of
2759the member function name.
2760
2761@item -fno-defer-pop
2762Always pop the arguments to each function call as soon as that function
2763returns. For machines which must pop arguments after a function call,
2764the compiler normally lets arguments accumulate on the stack for several
2765function calls and pops them all at once.
2766
2767@item -fforce-mem
2768Force memory operands to be copied into registers before doing
2769arithmetic on them. This produces better code by making all memory
2770references potential common subexpressions. When they are not common
2771subexpressions, instruction combination should eliminate the separate
2772register-load. The @samp{-O2} option turns on this option.
2773
2774@item -fforce-addr
2775Force memory address constants to be copied into registers before
2776doing arithmetic on them. This may produce better code just as
2777@samp{-fforce-mem} may.
2778
2779@item -fomit-frame-pointer
2780Don't keep the frame pointer in a register for functions that
2781don't need one. This avoids the instructions to save, set up and
2782restore frame pointers; it also makes an extra register available
2783in many functions. @strong{It also makes debugging impossible on
2784some machines.}
2785
2786@ifset INTERNALS
2787On some machines, such as the Vax, this flag has no effect, because
2788the standard calling sequence automatically handles the frame pointer
2789and nothing is saved by pretending it doesn't exist. The
2790machine-description macro @code{FRAME_POINTER_REQUIRED} controls
2791whether a target machine supports this flag. @xref{Registers}.@refill
2792@end ifset
2793@ifclear INTERNALS
2794On some machines, such as the Vax, this flag has no effect, because
2795the standard calling sequence automatically handles the frame pointer
2796and nothing is saved by pretending it doesn't exist. The
2797machine-description macro @code{FRAME_POINTER_REQUIRED} controls
2798whether a target machine supports this flag. @xref{Registers,,Register
2799Usage, gcc.info, Using and Porting GCC}.@refill
2800@end ifclear
2801
1aaef9c1
JH
2802@item -foptimize-sibling-calls
2803Optimize sibling and tail recursive calls.
2804
91ce572a
CC
2805@item -ftrapv
2806This option generates traps for signed overflow on addition, subtraction,
2807multiplication operations.
2808
74291a4b
MM
2809@item -fno-inline
2810Don't pay attention to the @code{inline} keyword. Normally this option
2811is used to keep the compiler from expanding any functions inline.
2812Note that if you are not optimizing, no functions can be expanded inline.
2813
2814@item -finline-functions
2815Integrate all simple functions into their callers. The compiler
2816heuristically decides which functions are simple enough to be worth
2817integrating in this way.
2818
2819If all calls to a given function are integrated, and the function is
2820declared @code{static}, then the function is normally not output as
2821assembler code in its own right.
2822
efa3896a 2823@item -finline-limit=@var{n}
f9e814f1
TP
2824By default, gcc limits the size of functions that can be inlined. This flag
2825allows the control of this limit for functions that are explicitly marked as
2826inline (ie marked with the inline keyword or defined within the class
2827definition in c++). @var{n} is the size of functions that can be inlined in
2828number of pseudo instructions (not counting parameter handling). The default
2829value of n is 10000. Increasing this value can result in more inlined code at
2830the cost of compilation time and memory consumption. Decreasing usually makes
2831the compilation faster and less code will be inlined (which presumably
2832means slower programs). This option is particularly useful for programs that
2833use inlining heavily such as those based on recursive templates with c++.
2834
2835@emph{Note:} pseudo instruction represents, in this particular context, an
2836abstract measurement of function's size. In no way, it represents a count
2837of assembly instructions and as such its exact meaning might change from one
2838release to an another.
2839
74291a4b
MM
2840@item -fkeep-inline-functions
2841Even if all calls to a given function are integrated, and the function
2842is declared @code{static}, nevertheless output a separate run-time
2843callable version of the function. This switch does not affect
2844@code{extern inline} functions.
2845
2846@item -fkeep-static-consts
2847Emit variables declared @code{static const} when optimization isn't turned
2848on, even if the variables aren't referenced.
2849
0c2d1a2a 2850GCC enables this option by default. If you want to force the compiler to
74291a4b
MM
2851check if the variable was referenced, regardless of whether or not
2852optimization is turned on, use the @samp{-fno-keep-static-consts} option.
2853
2854@item -fno-function-cse
2855Do not put function addresses in registers; make each instruction that
2856calls a constant function contain the function's address explicitly.
2857
2858This option results in less efficient code, but some strange hacks
2859that alter the assembler output may be confused by the optimizations
2860performed when this option is not used.
2861
2862@item -ffast-math
c1030c7c 2863This option allows GCC to violate some ISO or IEEE rules and/or
74291a4b
MM
2864specifications in the interest of optimizing code for speed. For
2865example, it allows the compiler to assume arguments to the @code{sqrt}
2866function are non-negative numbers and that no floating-point values
2867are NaNs.
2868
2869This option should never be turned on by any @samp{-O} option since
2870it can result in incorrect output for programs which depend on
c1030c7c 2871an exact implementation of IEEE or ISO rules/specifications for
74291a4b 2872math functions.
9605da8a
BL
2873
2874@item -fno-math-errno
2875Do not set ERRNO after calling math functions that are executed
2876with a single instruction, e.g., sqrt. A program that relies on
2877IEEE exceptions for math error handling may want to use this flag
2878for speed while maintaining IEEE arithmetic compatibility.
2879
2880The default is @samp{-fmath-errno}. The @samp{-ffast-math} option
2881sets @samp{-fno-math-errno}.
74291a4b
MM
2882@end table
2883
2884@c following causes underfulls.. they don't look great, but we deal.
2885@c --mew 26jan93
2886The following options control specific optimizations. The @samp{-O2}
2887option turns on all of these optimizations except @samp{-funroll-loops}
2888and @samp{-funroll-all-loops}. On most machines, the @samp{-O} option
2889turns on the @samp{-fthread-jumps} and @samp{-fdelayed-branch} options,
2890but specific machines may handle it differently.
2891
2892You can use the following flags in the rare cases when ``fine-tuning''
2893of optimizations to be performed is desired.
2894
2895@table @code
2896@item -fstrength-reduce
2897Perform the optimizations of loop strength reduction and
2898elimination of iteration variables.
2899
2900@item -fthread-jumps
2901Perform optimizations where we check to see if a jump branches to a
2902location where another comparison subsumed by the first is found. If
2903so, the first branch is redirected to either the destination of the
2904second branch or a point immediately following it, depending on whether
2905the condition is known to be true or false.
2906
2907@item -fcse-follow-jumps
2908In common subexpression elimination, scan through jump instructions
2909when the target of the jump is not reached by any other path. For
2910example, when CSE encounters an @code{if} statement with an
2911@code{else} clause, CSE will follow the jump when the condition
2912tested is false.
2913
2914@item -fcse-skip-blocks
2915This is similar to @samp{-fcse-follow-jumps}, but causes CSE to
2916follow jumps which conditionally skip over blocks. When CSE
2917encounters a simple @code{if} statement with no else clause,
2918@samp{-fcse-skip-blocks} causes CSE to follow the jump around the
2919body of the @code{if}.
2920
2921@item -frerun-cse-after-loop
2922Re-run common subexpression elimination after loop optimizations has been
2923performed.
2924
6d6d0fa0
JL
2925@item -frerun-loop-opt
2926Run the loop optimizer twice.
2927
7506f491
DE
2928@item -fgcse
2929Perform a global common subexpression elimination pass.
2930This pass also performs global constant and copy propagation.
2931
b6d24183
JL
2932@item -fdelete-null-pointer-checks
2933Use global dataflow analysis to identify and eliminate useless null
2934pointer checks. Programs which rely on NULL pointer dereferences @emph{not}
2935halting the program may not work properly with this option. Use
2936-fno-delete-null-pointer-checks to disable this optimizing for programs
2937which depend on that behavior.
2938
74291a4b
MM
2939@item -fexpensive-optimizations
2940Perform a number of minor optimizations that are relatively expensive.
2941
639726ba 2942@item -foptimize-register-move
59d40964 2943@itemx -fregmove
9ec36da5
JL
2944Attempt to reassign register numbers in move instructions and as
2945operands of other simple instructions in order to maximize the amount of
56159047 2946register tying. This is especially helpful on machines with two-operand
0c2d1a2a 2947instructions. GCC enables this optimization by default with @samp{-O2}
9ec36da5
JL
2948or higher.
2949
639726ba 2950Note @code{-fregmove} and @code{-foptimize-register-move} are the same
9ec36da5
JL
2951optimization.
2952
74291a4b
MM
2953@item -fdelayed-branch
2954If supported for the target machine, attempt to reorder instructions
2955to exploit instruction slots available after delayed branch
2956instructions.
2957
2958@item -fschedule-insns
2959If supported for the target machine, attempt to reorder instructions to
2960eliminate execution stalls due to required data being unavailable. This
2961helps machines that have slow floating point or memory load instructions
2962by allowing other instructions to be issued until the result of the load
2963or floating point instruction is required.
2964
2965@item -fschedule-insns2
2966Similar to @samp{-fschedule-insns}, but requests an additional pass of
2967instruction scheduling after register allocation has been done. This is
2968especially useful on machines with a relatively small number of
2969registers and where memory load instructions take more than one cycle.
2970
2971@item -ffunction-sections
59d40964 2972@itemx -fdata-sections
7d0756fb
CM
2973Place each function or data item into its own section in the output
2974file if the target supports arbitrary sections. The name of the
2975function or the name of the data item determines the section's name
2976in the output file.
74291a4b 2977
7d0756fb 2978Use these options on systems where the linker can perform optimizations
74291a4b
MM
2979to improve locality of reference in the instruction space. HPPA
2980processors running HP-UX and Sparc processors running Solaris 2 have
2981linkers with such optimizations. Other systems using the ELF object format
2982as well as AIX may have these optimizations in the future.
2983
7d0756fb
CM
2984Only use these options when there are significant benefits from doing
2985so. When you specify these options, the assembler and linker will
74291a4b
MM
2986create larger object and executable files and will also be slower.
2987You will not be able to use @code{gprof} on all systems if you
2988specify this option and you may have problems with debugging if
2989you specify both this option and @samp{-g}.
2990
2991@item -fcaller-saves
2992Enable values to be allocated in registers that will be clobbered by
2993function calls, by emitting extra instructions to save and restore the
2994registers around such calls. Such allocation is done only when it
2995seems to result in better code than would otherwise be produced.
2996
81610a0d
HPN
2997This option is always enabled by default on certain machines, usually
2998those which have no call-preserved registers to use instead.
2999
3000For all machines, optimization level 2 and higher enables this flag by
3001default.
74291a4b
MM
3002
3003@item -funroll-loops
3004Perform the optimization of loop unrolling. This is only done for loops
3005whose number of iterations can be determined at compile time or run time.
1bd31d56 3006@samp{-funroll-loops} implies both @samp{-fstrength-reduce} and
74291a4b
MM
3007@samp{-frerun-cse-after-loop}.
3008
3009@item -funroll-all-loops
3010Perform the optimization of loop unrolling. This is done for all loops
3011and usually makes programs run more slowly. @samp{-funroll-all-loops}
3012implies @samp{-fstrength-reduce} as well as @samp{-frerun-cse-after-loop}.
3013
e5eb27e5
JL
3014@item -fmove-all-movables
3015Forces all invariant computations in loops to be moved
3016outside the loop.
3017
3018@item -freduce-all-givs
3019Forces all general-induction variables in loops to be
3020strength-reduced.
3021
3022@emph{Note:} When compiling programs written in Fortran,
1bd31d56 3023@samp{-fmove-all-movables} and @samp{-freduce-all-givs} are enabled
e5eb27e5
JL
3024by default when you use the optimizer.
3025
3026These options may generate better or worse code; results are highly
3027dependent on the structure of loops within the source code.
3028
3029These two options are intended to be removed someday, once
3030they have helped determine the efficacy of various
3031approaches to improving loop optimizations.
3032
28e6b1c2 3033Please let us (@email{gcc@@gcc.gnu.org} and @email{fortran@@gnu.org})
e5eb27e5
JL
3034know how use of these options affects
3035the performance of your production code.
3036We're very interested in code that runs @emph{slower}
3037when these options are @emph{enabled}.
3038
74291a4b
MM
3039@item -fno-peephole
3040Disable any machine-specific peephole optimizations.
861bb6c1
JL
3041
3042@item -fbranch-probabilities
3043After running a program compiled with @samp{-fprofile-arcs}
3044(@pxref{Debugging Options,, Options for Debugging Your Program or
3045@code{gcc}}), you can compile it a second time using
3046@samp{-fbranch-probabilities}, to improve optimizations based on
3047guessing the path a branch might take.
3048
3049@ifset INTERNALS
e5e809f4 3050With @samp{-fbranch-probabilities}, GCC puts a @samp{REG_EXEC_COUNT}
861bb6c1
JL
3051note on the first instruction of each basic block, and a
3052@samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
3053These can be used to improve optimization. Currently, they are only
3054used in one place: in @file{reorg.c}, instead of guessing which path a
3055branch is mostly to take, the @samp{REG_BR_PROB} values are used to
3056exactly determine which path is taken more often.
3057@end ifset
8c660648 3058
41472af8
MM
3059@item -fstrict-aliasing
3060Allows the compiler to assume the strictest aliasing rules applicable to
3061the language being compiled. For C (and C++), this activates
3062optimizations based on the type of expressions. In particular, an
3063object of one type is assumed never to reside at the same address as an
3064object of a different type, unless the types are almost the same. For
3065example, an @code{unsigned int} can alias an @code{int}, but not a
3066@code{void*} or a @code{double}. A character type may alias any other
3067type.
3068
3069Pay special attention to code like this:
3070@example
3071union a_union @{
3072 int i;
3073 double d;
3074@};
3075
3076int f() @{
3077 a_union t;
3078 t.d = 3.0;
3079 return t.i;
3080@}
3081@end example
3082The practice of reading from a different union member than the one most
3083recently written to (called ``type-punning'') is common. Even with
3084@samp{-fstrict-aliasing}, type-punning is allowed, provided the memory
3085is accessed through the union type. So, the code above will work as
3086expected. However, this code might not:
3087@example
3088int f() @{
3089 a_union t;
3090 int* ip;
3091 t.d = 3.0;
3092 ip = &t.i;
3093 return *ip;
3094@}
3095@end example
3096
41472af8
MM
3097@ifset INTERNALS
3098Every language that wishes to perform language-specific alias analysis
3099should define a function that computes, given an @code{tree}
3100node, an alias set for the node. Nodes in different alias sets are not
3101allowed to alias. For an example, see the C front-end function
3102@code{c_get_alias_set}.
3103@end ifset
3104
efa3896a
GK
3105@item -falign-functions
3106@itemx -falign-functions=@var{n}
3107Align the start of functions to the next power-of-two greater than
3108@var{n}, skipping up to @var{n} bytes. For instance,
3109@samp{-falign-functions=32} aligns functions to the next 32-byte
3110boundary, but @samp{-falign-functions=24} would align to the next
311132-byte boundary only if this can be done by skipping 23 bytes or less.
3112
3113@samp{-fno-align-functions} and @samp{-falign-functions=1} are
3114equivalent and mean that functions will not be aligned.
3115
3116Some assemblers only support this flag when @var{n} is a power of two;
3117in that case, it is rounded up.
3118
3119If @var{n} is not specified, use a machine-dependent default.
3120
3121@item -falign-labels
3122@itemx -falign-labels=@var{n}
3123Align all branch targets to a power-of-two boundary, skipping up to
3124@var{n} bytes like @samp{-falign-functions}. This option can easily
3125make code slower, because it must insert dummy operations for when the
3126branch target is reached in the usual flow of the code.
3127
3128If @samp{-falign-loops} or @samp{-falign-jumps} are applicable and
3129are greater than this value, then their values are used instead.
3130
3131If @var{n} is not specified, use a machine-dependent default which is
3132very likely to be @samp{1}, meaning no alignment.
3133
3134@item -falign-loops
3135@itemx -falign-loops=@var{n}
3136Align loops to a power-of-two boundary, skipping up to @var{n} bytes
3137like @samp{-falign-functions}. The hope is that the loop will be
3138executed many times, which will make up for any execution of the dummy
3139operations.
3140
3141If @var{n} is not specified, use a machine-dependent default.
3142
3143@item -falign-jumps
3144@itemx -falign-jumps=@var{n}
3145Align branch targets to a power-of-two boundary, for branch targets
3146where the targets can only be reached by jumping, skipping up to @var{n}
3147bytes like @samp{-falign-functions}. In this case, no dummy operations
3148need be executed.
3149
3150If @var{n} is not specified, use a machine-dependent default.
3151
4bae0b47
AS
3152@item -fssa
3153Perform optimizations in static single assignment form. Each function's
3154flow graph is translated into SSA form, optimizations are performed, and
b53978a3
JO
3155the flow graph is translated back from SSA form. User's should not
3156specify this option, since it is not yet ready for production use.
3157
3158@item -fdce
3159Perform dead-code elimination in SSA form. Requires @samp{-fssa}. Like
3160@samp{-fssa}, this is an experimental feature.
4bae0b47 3161
46d3a873
CC
3162@item -fsingle-precision-constant
3163Treat floating point constant as single precision constant instead of
3164implicitly converting it to double precision constant.
3165
2b2a8f1f
RH
3166@item -frename-registers
3167Attempt to avoid false dependancies in scheduled code by making use
3168of registers left over after register allocation. This optimization
3169will most benefit processors with lots of registers. It can, however,
3170make debugging impossible, since variables will no longer stay in
3171a ``home register''.
74291a4b
MM
3172@end table
3173
3174@node Preprocessor Options
3175@section Options Controlling the Preprocessor
3176@cindex preprocessor options
3177@cindex options, preprocessor
3178
3179These options control the C preprocessor, which is run on each C source
3180file before actual compilation.
3181
3182If you use the @samp{-E} option, nothing is done except preprocessing.
3183Some of these options make sense only together with @samp{-E} because
3184they cause the preprocessor output to be unsuitable for actual
3185compilation.
3186
3187@table @code
3188@item -include @var{file}
3189Process @var{file} as input before processing the regular input file.
3190In effect, the contents of @var{file} are compiled first. Any @samp{-D}
3191and @samp{-U} options on the command line are always processed before
3192@samp{-include @var{file}}, regardless of the order in which they are
3193written. All the @samp{-include} and @samp{-imacros} options are
3194processed in the order in which they are written.
3195
3196@item -imacros @var{file}
3197Process @var{file} as input, discarding the resulting output, before
3198processing the regular input file. Because the output generated from
3199@var{file} is discarded, the only effect of @samp{-imacros @var{file}}
3200is to make the macros defined in @var{file} available for use in the
3201main input.
3202
3203Any @samp{-D} and @samp{-U} options on the command line are always
3204processed before @samp{-imacros @var{file}}, regardless of the order in
3205which they are written. All the @samp{-include} and @samp{-imacros}
3206options are processed in the order in which they are written.
3207
3208@item -idirafter @var{dir}
3209@cindex second include path
3210Add the directory @var{dir} to the second include path. The directories
3211on the second include path are searched when a header file is not found
3212in any of the directories in the main include path (the one that
3213@samp{-I} adds to).
3214
3215@item -iprefix @var{prefix}
3216Specify @var{prefix} as the prefix for subsequent @samp{-iwithprefix}
3217options.
3218
3219@item -iwithprefix @var{dir}
3220Add a directory to the second include path. The directory's name is
3221made by concatenating @var{prefix} and @var{dir}, where @var{prefix} was
3222specified previously with @samp{-iprefix}. If you have not specified a
3223prefix yet, the directory containing the installed passes of the
3224compiler is used as the default.
3225
3226@item -iwithprefixbefore @var{dir}
3227Add a directory to the main include path. The directory's name is made
3228by concatenating @var{prefix} and @var{dir}, as in the case of
3229@samp{-iwithprefix}.
3230
3231@item -isystem @var{dir}
3232Add a directory to the beginning of the second include path, marking it
3233as a system directory, so that it gets the same special treatment as
3234is applied to the standard system directories.
3235
3236@item -nostdinc
3237Do not search the standard system directories for header files. Only
3238the directories you have specified with @samp{-I} options (and the
3239current directory, if appropriate) are searched. @xref{Directory
3240Options}, for information on @samp{-I}.
3241
3242By using both @samp{-nostdinc} and @samp{-I-}, you can limit the include-file
3243search path to only those directories you specify explicitly.
3244
3245@item -undef
3246Do not predefine any nonstandard macros. (Including architecture flags).
3247
3248@item -E
3249Run only the C preprocessor. Preprocess all the C source files
3250specified and output the results to standard output or to the
3251specified output file.
3252
3253@item -C
3254Tell the preprocessor not to discard comments. Used with the
3255@samp{-E} option.
3256
3257@item -P
3258Tell the preprocessor not to generate @samp{#line} directives.
3259Used with the @samp{-E} option.
3260
3261@cindex make
3262@cindex dependencies, make
3263@item -M
3264Tell the preprocessor to output a rule suitable for @code{make}
3265describing the dependencies of each object file. For each source file,
3266the preprocessor outputs one @code{make}-rule whose target is the object
3267file name for that source file and whose dependencies are all the
3268@code{#include} header files it uses. This rule may be a single line or
3269may be continued with @samp{\}-newline if it is long. The list of rules
3270is printed on standard output instead of the preprocessed C program.
3271
3272@samp{-M} implies @samp{-E}.
3273
3274Another way to specify output of a @code{make} rule is by setting
3275the environment variable @code{DEPENDENCIES_OUTPUT} (@pxref{Environment
3276Variables}).
3277
3278@item -MM
3279Like @samp{-M} but the output mentions only the user header files
3280included with @samp{#include "@var{file}"}. System header files
3281included with @samp{#include <@var{file}>} are omitted.
3282
3283@item -MD
3284Like @samp{-M} but the dependency information is written to a file made by
3285replacing ".c" with ".d" at the end of the input file names.
3286This is in addition to compiling the file as specified---@samp{-MD} does
3287not inhibit ordinary compilation the way @samp{-M} does.
3288
3289In Mach, you can use the utility @code{md} to merge multiple dependency
3290files into a single dependency file suitable for using with the @samp{make}
3291command.
3292
3293@item -MMD
3294Like @samp{-MD} except mention only user header files, not system
3295header files.
3296
3297@item -MG
3298Treat missing header files as generated files and assume they live in the
3299same directory as the source file. If you specify @samp{-MG}, you
3300must also specify either @samp{-M} or @samp{-MM}. @samp{-MG} is not
3301supported with @samp{-MD} or @samp{-MMD}.
3302
3303@item -H
3304Print the name of each header file used, in addition to other normal
3305activities.
3306
3307@item -A@var{question}(@var{answer})
3308Assert the answer @var{answer} for @var{question}, in case it is tested
3309with a preprocessing conditional such as @samp{#if
3310#@var{question}(@var{answer})}. @samp{-A-} disables the standard
3311assertions that normally describe the target machine.
3312
3313@item -D@var{macro}
3314Define macro @var{macro} with the string @samp{1} as its definition.
3315
3316@item -D@var{macro}=@var{defn}
3317Define macro @var{macro} as @var{defn}. All instances of @samp{-D} on
3318the command line are processed before any @samp{-U} options.
3319
3320@item -U@var{macro}
3321Undefine macro @var{macro}. @samp{-U} options are evaluated after all
3322@samp{-D} options, but before any @samp{-include} and @samp{-imacros}
3323options.
3324
3325@item -dM
3326Tell the preprocessor to output only a list of the macro definitions
3327that are in effect at the end of preprocessing. Used with the @samp{-E}
3328option.
3329
3330@item -dD
3331Tell the preprocessing to pass all macro definitions into the output, in
3332their proper sequence in the rest of the output.
3333
3334@item -dN
3335Like @samp{-dD} except that the macro arguments and contents are omitted.
3336Only @samp{#define @var{name}} is included in the output.
3337
3338@item -trigraphs
c1030c7c 3339Support ISO C trigraphs. The @samp{-ansi} option also has this effect.
74291a4b
MM
3340
3341@item -Wp,@var{option}
3342Pass @var{option} as an option to the preprocessor. If @var{option}
3343contains commas, it is split into multiple options at the commas.
3344@end table
3345
3346@node Assembler Options
3347@section Passing Options to the Assembler
3348
3349@c prevent bad page break with this line
3350You can pass options to the assembler.
3351
3352@table @code
3353@item -Wa,@var{option}
3354Pass @var{option} as an option to the assembler. If @var{option}
3355contains commas, it is split into multiple options at the commas.
3356@end table
3357
3358@node Link Options
3359@section Options for Linking
3360@cindex link options
3361@cindex options, linking
3362
3363These options come into play when the compiler links object files into
3364an executable output file. They are meaningless if the compiler is
3365not doing a link step.
3366
3367@table @code
3368@cindex file names
3369@item @var{object-file-name}
3370A file name that does not end in a special recognized suffix is
3371considered to name an object file or library. (Object files are
3372distinguished from libraries by the linker according to the file
3373contents.) If linking is done, these object files are used as input
3374to the linker.
3375
3376@item -c
3377@itemx -S
3378@itemx -E
3379If any of these options is used, then the linker is not run, and
3380object file names should not be used as arguments. @xref{Overall
3381Options}.
3382
3383@cindex Libraries
3384@item -l@var{library}
3385Search the library named @var{library} when linking.
3386
3387It makes a difference where in the command you write this option; the
3388linker searches processes libraries and object files in the order they
3389are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
3390after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
3391to functions in @samp{z}, those functions may not be loaded.
3392
3393The linker searches a standard list of directories for the library,
3394which is actually a file named @file{lib@var{library}.a}. The linker
3395then uses this file as if it had been specified precisely by name.
3396
3397The directories searched include several standard system directories
3398plus any that you specify with @samp{-L}.
3399
3400Normally the files found this way are library files---archive files
3401whose members are object files. The linker handles an archive file by
3402scanning through it for members which define symbols that have so far
3403been referenced but not defined. But if the file that is found is an
3404ordinary object file, it is linked in the usual fashion. The only
3405difference between using an @samp{-l} option and specifying a file name
3406is that @samp{-l} surrounds @var{library} with @samp{lib} and @samp{.a}
3407and searches several directories.
3408
3409@item -lobjc
3410You need this special case of the @samp{-l} option in order to
3411link an Objective C program.
3412
3413@item -nostartfiles
3414Do not use the standard system startup files when linking.
3415The standard system libraries are used normally, unless @code{-nostdlib}
3416or @code{-nodefaultlibs} is used.
3417
3418@item -nodefaultlibs
3419Do not use the standard system libraries when linking.
3420Only the libraries you specify will be passed to the linker.
3421The standard startup files are used normally, unless @code{-nostartfiles}
4754172c 3422is used. The compiler may generate calls to memcmp, memset, and memcpy
c1030c7c 3423for System V (and ISO C) environments or to bcopy and bzero for
4754172c
CM
3424BSD environments. These entries are usually resolved by entries in
3425libc. These entry points should be supplied through some other
3426mechanism when this option is specified.
74291a4b
MM
3427
3428@item -nostdlib
3429Do not use the standard system startup files or libraries when linking.
3430No startup files and only the libraries you specify will be passed to
4754172c 3431the linker. The compiler may generate calls to memcmp, memset, and memcpy
c1030c7c 3432for System V (and ISO C) environments or to bcopy and bzero for
4754172c
CM
3433BSD environments. These entries are usually resolved by entries in
3434libc. These entry points should be supplied through some other
3435mechanism when this option is specified.
74291a4b
MM
3436
3437@cindex @code{-lgcc}, use with @code{-nostdlib}
3438@cindex @code{-nostdlib} and unresolved references
3439@cindex unresolved references and @code{-nostdlib}
3440@cindex @code{-lgcc}, use with @code{-nodefaultlibs}
3441@cindex @code{-nodefaultlibs} and unresolved references
3442@cindex unresolved references and @code{-nodefaultlibs}
3443One of the standard libraries bypassed by @samp{-nostdlib} and
3444@samp{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
0c2d1a2a 3445that GCC uses to overcome shortcomings of particular machines, or special
74291a4b
MM
3446needs for some languages.
3447@ifset INTERNALS
0c2d1a2a 3448(@xref{Interface,,Interfacing to GCC Output}, for more discussion of
74291a4b
MM
3449@file{libgcc.a}.)
3450@end ifset
3451@ifclear INTERNALS
0c2d1a2a 3452(@xref{Interface,,Interfacing to GCC Output,gcc.info,Porting GCC},
74291a4b
MM
3453for more discussion of @file{libgcc.a}.)
3454@end ifclear
3455In most cases, you need @file{libgcc.a} even when you want to avoid
3456other standard libraries. In other words, when you specify @samp{-nostdlib}
3457or @samp{-nodefaultlibs} you should usually specify @samp{-lgcc} as well.
0c2d1a2a 3458This ensures that you have no unresolved references to internal GCC
74291a4b
MM
3459library subroutines. (For example, @samp{__main}, used to ensure C++
3460constructors will be called; @pxref{Collect2,,@code{collect2}}.)
3461
3462@item -s
3463Remove all symbol table and relocation information from the executable.
3464
3465@item -static
3466On systems that support dynamic linking, this prevents linking with the shared
3467libraries. On other systems, this option has no effect.
3468
3469@item -shared
3470Produce a shared object which can then be linked with other objects to
1d3b0e2c
ME
3471form an executable. Not all systems support this option. For predictable
3472results, you must also specify the same set of options that were used to
3473generate code (@samp{-fpic}, @samp{-fPIC}, or model suboptions)
3474when you specify this option.@footnote{On some systems, @code{gcc -shared}
3475needs to build supplementary stub code for constructors to work. On
3476multi-libbed systems, @code{gcc -shared} must select the correct support
3477libraries to link against. Failing to supply the correct flags may lead
3478to subtle defects. Supplying them in cases where they are not necessary
3479is innocuous.}
74291a4b
MM
3480
3481@item -symbolic
3482Bind references to global symbols when building a shared object. Warn
3483about any unresolved references (unless overridden by the link editor
3484option @samp{-Xlinker -z -Xlinker defs}). Only a few systems support
3485this option.
3486
3487@item -Xlinker @var{option}
3488Pass @var{option} as an option to the linker. You can use this to
0c2d1a2a 3489supply system-specific linker options which GCC does not know how to
74291a4b
MM
3490recognize.
3491
3492If you want to pass an option that takes an argument, you must use
3493@samp{-Xlinker} twice, once for the option and once for the argument.
3494For example, to pass @samp{-assert definitions}, you must write
3495@samp{-Xlinker -assert -Xlinker definitions}. It does not work to write
3496@samp{-Xlinker "-assert definitions"}, because this passes the entire
3497string as a single argument, which is not what the linker expects.
3498
3499@item -Wl,@var{option}
3500Pass @var{option} as an option to the linker. If @var{option} contains
3501commas, it is split into multiple options at the commas.
3502
3503@item -u @var{symbol}
3504Pretend the symbol @var{symbol} is undefined, to force linking of
3505library modules to define it. You can use @samp{-u} multiple times with
3506different symbols to force loading of additional library modules.
3507@end table
3508
3509@node Directory Options
3510@section Options for Directory Search
3511@cindex directory options
3512@cindex options, directory search
3513@cindex search path
3514
3515These options specify directories to search for header files, for
3516libraries and for parts of the compiler:
3517
3518@table @code
3519@item -I@var{dir}
861bb6c1
JL
3520Add the directory @var{dir} to the head of the list of directories to be
3521searched for header files. This can be used to override a system header
3522file, substituting your own version, since these directories are
74291a4b
MM
3523searched before the system header file directories. If you use more
3524than one @samp{-I} option, the directories are scanned in left-to-right
3525order; the standard system directories come after.
3526
3527@item -I-
3528Any directories you specify with @samp{-I} options before the @samp{-I-}
3529option are searched only for the case of @samp{#include "@var{file}"};
3530they are not searched for @samp{#include <@var{file}>}.
3531
3532If additional directories are specified with @samp{-I} options after
3533the @samp{-I-}, these directories are searched for all @samp{#include}
3534directives. (Ordinarily @emph{all} @samp{-I} directories are used
3535this way.)
3536
3537In addition, the @samp{-I-} option inhibits the use of the current
3538directory (where the current input file came from) as the first search
3539directory for @samp{#include "@var{file}"}. There is no way to
3540override this effect of @samp{-I-}. With @samp{-I.} you can specify
3541searching the directory which was current when the compiler was
3542invoked. That is not exactly the same as what the preprocessor does
3543by default, but it is often satisfactory.
3544
3545@samp{-I-} does not inhibit the use of the standard system directories
3546for header files. Thus, @samp{-I-} and @samp{-nostdinc} are
3547independent.
3548
3549@item -L@var{dir}
3550Add directory @var{dir} to the list of directories to be searched
3551for @samp{-l}.
3552
3553@item -B@var{prefix}
3554This option specifies where to find the executables, libraries,
3555include files, and data files of the compiler itself.
3556
3557The compiler driver program runs one or more of the subprograms
3558@file{cpp}, @file{cc1}, @file{as} and @file{ld}. It tries
3559@var{prefix} as a prefix for each program it tries to run, both with and
3560without @samp{@var{machine}/@var{version}/} (@pxref{Target Options}).
3561
3562For each subprogram to be run, the compiler driver first tries the
3563@samp{-B} prefix, if any. If that name is not found, or if @samp{-B}
3564was not specified, the driver tries two standard prefixes, which are
3565@file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc-lib/}. If neither of
3566those results in a file name that is found, the unmodified program
3567name is searched for using the directories specified in your
3568@samp{PATH} environment variable.
3569
3570@samp{-B} prefixes that effectively specify directory names also apply
3571to libraries in the linker, because the compiler translates these
3572options into @samp{-L} options for the linker. They also apply to
3573includes files in the preprocessor, because the compiler translates these
3574options into @samp{-isystem} options for the preprocessor. In this case,
3575the compiler appends @samp{include} to the prefix.
3576
3577The run-time support file @file{libgcc.a} can also be searched for using
3578the @samp{-B} prefix, if needed. If it is not found there, the two
3579standard prefixes above are tried, and that is all. The file is left
3580out of the link if it is not found by those means.
3581
3582Another way to specify a prefix much like the @samp{-B} prefix is to use
3583the environment variable @code{GCC_EXEC_PREFIX}. @xref{Environment
3584Variables}.
861bb6c1
JL
3585
3586@item -specs=@var{file}
3587Process @var{file} after the compiler reads in the standard @file{specs}
3588file, in order to override the defaults that the @file{gcc} driver
3589program uses when determining what switches to pass to @file{cc1},
3590@file{cc1plus}, @file{as}, @file{ld}, etc. More than one
3591@samp{-specs=}@var{file} can be specified on the command line, and they
3592are processed in order, from left to right.
74291a4b
MM
3593@end table
3594
a743d340
NC
3595@node Spec Files
3596@section Specifying subprocesses and the switches to pass to them
3597@cindex Spec Files
3598@code{GCC} is a driver program. It performs its job by invoking a
3599sequence of other programs to do the work of compiling, assembling and
3600linking. GCC interprets its command-line parameters and uses these to
3601deduce which programs it should invoke, and which command-line options
3602it ought to place on their command lines. This behaviour is controlled
3603by @dfn{spec strings}. In most cases there is one spec string for each
3604program that GCC can invoke, but a few programs have multiple spec
3605strings to control their behaviour. The spec strings built into GCC can
3606be overridden by using the @samp{-specs=} command-line switch to specify
3607a spec file.
3608
3609@dfn{Spec files} are plaintext files that are used to construct spec
3610strings. They consist of a sequence of directives separated by blank
3611lines. The type of directive is determined by the first non-whitespace
3612character on the line and it can be one of the following:
3613
3614@table @code
3615@item %@var{command}
3616Issues a @var{command} to the spec file processor. The commands that can
3617appear here are:
3618
3619@table @code
3620@item %include <@var{file}>
3621@cindex %include
3622Search for @var{file} and insert its text at the current point in the
3623specs file.
3624
3625@item %include_noerr <@var{file}>
3626@cindex %include_noerr
3627Just like @samp{%include}, but do not generate an error message if the include
3628file cannot be found.
3629
3630@item %rename @var{old_name} @var{new_name}
3631@cindex %rename
3632Rename the spec string @var{old_name} to @var{new_name}.
3633
3634@end table
3635
3636@item *[@var{spec_name}]:
3637This tells the compiler to create, override or delete the named spec
3638string. All lines after this directive up to the next directive or
3639blank line are considered to be the text for the spec string. If this
3640results in an empty string then the spec will be deleted. (Or, if the
3641spec did not exist, then nothing will happened.) Otherwise, if the spec
3642does not currently exist a new spec will be created. If the spec does
3643exist then its contents will be overridden by the text of this
3644directive, unless the first character of that text is the @samp{+}
3645character, in which case the text will be appended to the spec.
3646
3647@item [@var{suffix}]:
3648Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
3649and up to the next directive or blank line are considered to make up the
3650spec string for the indicated suffix. When the compiler encounters an
3651input file with the named suffix, it will processes the spec string in
3652order to work out how to compile that file. For example:
3653
3654@smallexample
3655.ZZ:
3656z-compile -input %i
3657@end smallexample
3658
3659This says that any input file whose name ends in @samp{.ZZ} should be
3660passed to the program @samp{z-compile}, which should be invoked with the
3661command-line switch @samp{-input} and with the result of performing the
3662@samp{%i} substitution. (See below.)
3663
3664As an alternative to providing a spec string, the text that follows a
3665suffix directive can be one of the following:
3666
3667@table @code
3668@item @@@var{language}
3669This says that the suffix is an alias for a known @var{language}. This is
3670similar to using the @code{-x} command-line switch to GCC to specify a
3671language explicitly. For example:
3672
3673@smallexample
3674.ZZ:
3675@@c++
3676@end smallexample
3677
3678Says that .ZZ files are, in fact, C++ source files.
3679
3680@item #@var{name}
3681This causes an error messages saying:
3682
3683@smallexample
3684@var{name} compiler not installed on this system.
3685@end smallexample
3686@end table
3687
3688GCC already has an extensive list of suffixes built into it.
3689This directive will add an entry to the end of the list of suffixes, but
3690since the list is searched from the end backwards, it is effectively
3691possible to override earlier entries using this technique.
3692
3693@end table
3694
3695GCC has the following spec strings built into it. Spec files can
3696override these strings or create their own. Note that individual
3697targets can also add their own spec strings to this list.
3698
3699@smallexample
3700asm Options to pass to the assembler
3701asm_final Options to pass to the assembler post-processor
3702cpp Options to pass to the C preprocessor
3703cc1 Options to pass to the C compiler
3704cc1plus Options to pass to the C++ compiler
3705endfile Object files to include at the end of the link
3706link Options to pass to the linker
3707lib Libraries to include on the command line to the linker
3708libgcc Decides which GCC support library to pass to the linker
3709linker Sets the name of the linker
3710predefines Defines to be passed to the C preprocessor
3711signed_char Defines to pass to CPP to say whether @code{char} is signed by default
3712startfile Object files to include at the start of the link
3713@end smallexample
3714
3715Here is a small example of a spec file:
3716
3717@smallexample
3718%rename lib old_lib
3719
3720*lib:
3721--start-group -lgcc -lc -leval1 --end-group %(old_lib)
3722@end smallexample
3723
3724This example renames the spec called @samp{lib} to @samp{old_lib} and
3725then overrides the previous definition of @samp{lib} with a new one.
3726The new definition adds in some extra command-line options before
3727including the text of the old definition.
3728
3729@dfn{Spec strings} are a list of command-line options to be passed to their
3730corresponding program. In addition, the spec strings can contain
3731@samp{%}-prefixed sequences to substitute variable text or to
3732conditionally insert text into the command line. Using these constructs
3733it is possible to generate quite complex command lines.
3734
3735Here is a table of all defined @samp{%}-sequences for spec
3736strings. Note that spaces are not generated automatically around the
3737results of expanding these sequences. Therefore you can concatenate them
3738together or combine them with constant text in a single argument.
3739
3740@table @code
3741@item %%
3742Substitute one @samp{%} into the program name or argument.
3743
3744@item %i
3745Substitute the name of the input file being processed.
3746
3747@item %b
3748Substitute the basename of the input file being processed.
3749This is the substring up to (and not including) the last period
3750and not including the directory.
3751
3752@item %d
3753Marks the argument containing or following the @samp{%d} as a
3754temporary file name, so that that file will be deleted if GCC exits
3755successfully. Unlike @samp{%g}, this contributes no text to the
3756argument.
3757
3758@item %g@var{suffix}
3759Substitute a file name that has suffix @var{suffix} and is chosen
3760once per compilation, and mark the argument in the same way as
3761@samp{%d}. To reduce exposure to denial-of-service attacks, the file
3762name is now chosen in a way that is hard to predict even when previously
3763chosen file names are known. For example, @samp{%g.s ... %g.o ... %g.s}
3764might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
3765the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
3766treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
3767was simply substituted with a file name chosen once per compilation,
3768without regard to any appended suffix (which was therefore treated
3769just like ordinary text), making such attacks more likely to succeed.
3770
3771@item %u@var{suffix}
3772Like @samp{%g}, but generates a new temporary file name even if
3773@samp{%u@var{suffix}} was already seen.
3774
3775@item %U@var{suffix}
3776Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
3777new one if there is no such last file name. In the absence of any
3778@samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
3779the same suffix @emph{space}, so @samp{%g.s ... %U.s ... %g.s ... %U.s}
3780would involve the generation of two distinct file names, one
3781for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
3782simply substituted with a file name chosen for the previous @samp{%u},
3783without regard to any appended suffix.
3784
3785@item %w
3786Marks the argument containing or following the @samp{%w} as the
3787designated output file of this compilation. This puts the argument
3788into the sequence of arguments that @samp{%o} will substitute later.
3789
3790@item %o
3791Substitutes the names of all the output files, with spaces
3792automatically placed around them. You should write spaces
3793around the @samp{%o} as well or the results are undefined.
3794@samp{%o} is for use in the specs for running the linker.
3795Input files whose names have no recognized suffix are not compiled
3796at all, but they are included among the output files, so they will
3797be linked.
3798
3799@item %O
3800Substitutes the suffix for object files. Note that this is
3801handled specially when it immediately follows @samp{%g, %u, or %U},
3802because of the need for those to form complete file names. The
3803handling is such that @samp{%O} is treated exactly as if it had already
3804been substituted, except that @samp{%g, %u, and %U} do not currently
3805support additional @var{suffix} characters following @samp{%O} as they would
3806following, for example, @samp{.o}.
3807
3808@item %p
3809Substitutes the standard macro predefinitions for the
3810current target machine. Use this when running @code{cpp}.
3811
3812@item %P
3813Like @samp{%p}, but puts @samp{__} before and after the name of each
3814predefined macro, except for macros that start with @samp{__} or with
c1030c7c 3815@samp{_@var{L}}, where @var{L} is an uppercase letter. This is for ISO
a743d340
NC
3816C.
3817
3818@item %I
3819Substitute a @samp{-iprefix} option made from GCC_EXEC_PREFIX.
3820
3821@item %s
3822Current argument is the name of a library or startup file of some sort.
3823Search for that file in a standard list of directories and substitute
3824the full name found.
3825
3826@item %e@var{str}
3827Print @var{str} as an error message. @var{str} is terminated by a newline.
3828Use this when inconsistent options are detected.
3829
3830@item %|
3831Output @samp{-} if the input for the current command is coming from a pipe.
3832
3833@item %(@var{name})
3834Substitute the contents of spec string @var{name} at this point.
3835
3836@item %[@var{name}]
3837Like @samp{%(...)} but put @samp{__} around @samp{-D} arguments.
3838
3839@item %x@{@var{option}@}
3840Accumulate an option for @samp{%X}.
3841
3842@item %X
3843Output the accumulated linker options specified by @samp{-Wl} or a @samp{%x}
3844spec string.
3845
3846@item %Y
3847Output the accumulated assembler options specified by @samp{-Wa}.
3848
3849@item %Z
3850Output the accumulated preprocessor options specified by @samp{-Wp}.
3851
3852@item %v1
3853Substitute the major version number of GCC.
3854(For version 2.9.5, this is 2.)
3855
3856@item %v2
3857Substitute the minor version number of GCC.
3858(For version 2.9.5, this is 9.)
3859
3860@item %a
3861Process the @code{asm} spec. This is used to compute the
3862switches to be passed to the assembler.
3863
3864@item %A
3865Process the @code{asm_final} spec. This is a spec string for
3866passing switches to an assembler post-processor, if such a program is
3867needed.
3868
3869@item %l
3870Process the @code{link} spec. This is the spec for computing the
3871command line passed to the linker. Typically it will make use of the
3872@samp{%L %G %S %D and %E} sequences.
3873
3874@item %D
3875Dump out a @samp{-L} option for each directory that GCC believes might
3876contain startup files. If the target supports multilibs then the
3877current multilib directory will be prepended to each of these paths.
3878
3879@item %L
3880Process the @code{lib} spec. This is a spec string for deciding which
3881libraries should be included on the command line to the linker.
3882
3883@item %G
3884Process the @code{libgcc} spec. This is a spec string for deciding
3885which GCC support library should be included on the command line to the linker.
3886
3887@item %S
3888Process the @code{startfile} spec. This is a spec for deciding which
3889object files should be the first ones passed to the linker. Typically
3890this might be a file named @file{crt0.o}.
3891
3892@item %E
3893Process the @code{endfile} spec. This is a spec string that specifies
3894the last object files that will be passed to the linker.
3895
3896@item %C
3897Process the @code{cpp} spec. This is used to construct the arguments
3898to be passed to the C preprocessor.
3899
3900@item %c
3901Process the @code{signed_char} spec. This is intended to be used
3902to tell cpp whether a char is signed. It typically has the definition:
3903@smallexample
3904%@{funsigned-char:-D__CHAR_UNSIGNED__@}
3905@end smallexample
3906
3907@item %1
3908Process the @code{cc1} spec. This is used to construct the options to be
3909passed to the actual C compiler (@samp{cc1}).
3910
3911@item %2
3912Process the @code{cc1plus} spec. This is used to construct the options to be
3913passed to the actual C++ compiler (@samp{cc1plus}).
3914
3915@item %*
3916Substitute the variable part of a matched option. See below.
3917Note that each comma in the substituted string is replaced by
3918a single space.
3919
3920@item %@{@code{S}@}
3921Substitutes the @code{-S} switch, if that switch was given to GCC.
3922If that switch was not specified, this substitutes nothing. Note that
3923the leading dash is omitted when specifying this option, and it is
3924automatically inserted if the substitution is performed. Thus the spec
3925string @samp{%@{foo@}} would match the command-line option @samp{-foo}
3926and would output the command line option @samp{-foo}.
3927
3928@item %W@{@code{S}@}
3929Like %@{@code{S}@} but mark last argument supplied within as a file to be
3930deleted on failure.
3931
3932@item %@{@code{S}*@}
3933Substitutes all the switches specified to GCC whose names start
3934with @code{-S}, but which also take an argument. This is used for
3935switches like @samp{-o, -D, -I}, etc. GCC considers @samp{-o foo} as being
3936one switch whose names starts with @samp{o}. %@{o*@} would substitute this
3937text, including the space. Thus two arguments would be generated.
3938
3939@item %@{^@code{S}*@}
3940Like %@{@code{S}*@}, but don't put a blank between a switch and its
3941argument. Thus %@{^o*@} would only generate one argument, not two.
3942
d630442f 3943@item %@{<@code{S}@}
50c57e7b 3944Remove all occurrences of @code{-S} from the command line. Note - this
d630442f 3945command is position dependent. @samp{%} commands in the spec string
50c57e7b 3946before this option will see @code{-S}, @samp{%} commands in the spec
d630442f
NC
3947string after this option will not.
3948
a743d340
NC
3949@item %@{@code{S}*:@code{X}@}
3950Substitutes @code{X} if one or more switches whose names start with
3951@code{-S} are specified to GCC. Note that the tail part of the
3952@code{-S} option (i.e. the part matched by the @samp{*}) will be substituted
3953for each occurrence of @samp{%*} within @code{X}.
3954
3955@item %@{@code{S}:@code{X}@}
3956Substitutes @code{X}, but only if the @samp{-S} switch was given to GCC.
3957
3958@item %@{!@code{S}:@code{X}@}
3959Substitutes @code{X}, but only if the @samp{-S} switch was @emph{not} given to GCC.
3960
3961@item %@{|@code{S}:@code{X}@}
3962Like %@{@code{S}:@code{X}@}, but if no @code{S} switch, substitute @samp{-}.
3963
3964@item %@{|!@code{S}:@code{X}@}
3965Like %@{!@code{S}:@code{X}@}, but if there is an @code{S} switch, substitute @samp{-}.
3966
3967@item %@{.@code{S}:@code{X}@}
3968Substitutes @code{X}, but only if processing a file with suffix @code{S}.
3969
3970@item %@{!.@code{S}:@code{X}@}
3971Substitutes @code{X}, but only if @emph{not} processing a file with suffix @code{S}.
3972
3973@item %@{@code{S}|@code{P}:@code{X}@}
3974Substitutes @code{X} if either @code{-S} or @code{-P} was given to GCC. This may be
3975combined with @samp{!} and @samp{.} sequences as well, although they
3976have a stronger binding than the @samp{|}. For example a spec string
3977like this:
3978
3979@smallexample
3980%@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
3981@end smallexample
3982
3983will output the following command-line options from the following input
3984command-line options:
3985
3986@smallexample
3987fred.c -foo -baz
3988jim.d -bar -boggle
3989-d fred.c -foo -baz -boggle
3990-d jim.d -bar -baz -boggle
3991@end smallexample
3992
3993@end table
3994
3995The conditional text @code{X} in a %@{@code{S}:@code{X}@} or
3996%@{!@code{S}:@code{X}@} construct may contain other nested @samp{%} constructs
3997or spaces, or even newlines. They are processed as usual, as described
3998above.
3999
4000The @samp{-O, -f, -m, and -W} switches are handled specifically in these
4001constructs. If another value of @samp{-O} or the negated form of a @samp{-f, -m, or
4002-W} switch is found later in the command line, the earlier switch
4003value is ignored, except with @{@code{S}*@} where @code{S} is just one
4004letter, which passes all matching options.
4005
4006The character @samp{|} at the beginning of the predicate text is used to indicate
4007that a command should be piped to the following command, but only if @samp{-pipe}
4008is specified.
4009
4010It is built into GCC which switches take arguments and which do not.
4011(You might think it would be useful to generalize this to allow each
4012compiler's spec to say which switches take arguments. But this cannot
4013be done in a consistent fashion. GCC cannot even decide which input
4014files have been specified without knowing which switches take arguments,
4015and it must know which input files to compile in order to tell which
4016compilers to run).
4017
4018GCC also knows implicitly that arguments starting in @samp{-l} are to be
4019treated as compiler output files, and passed to the linker in their
4020proper position among the other output files.
4021
74291a4b
MM
4022@node Target Options
4023@section Specifying Target Machine and Compiler Version
4024@cindex target options
4025@cindex cross compiling
4026@cindex specifying machine version
4027@cindex specifying compiler version and target machine
4028@cindex compiler version, specifying
4029@cindex target machine, specifying
4030
0c2d1a2a 4031By default, GCC compiles code for the same type of machine that you
74291a4b
MM
4032are using. However, it can also be installed as a cross-compiler, to
4033compile for some other type of machine. In fact, several different
0c2d1a2a 4034configurations of GCC, for different target machines, can be
74291a4b
MM
4035installed side by side. Then you specify which one to use with the
4036@samp{-b} option.
4037
0c2d1a2a 4038In addition, older and newer versions of GCC can be installed side
74291a4b
MM
4039by side. One of them (probably the newest) will be the default, but
4040you may sometimes wish to use another.
4041
4042@table @code
4043@item -b @var{machine}
4044The argument @var{machine} specifies the target machine for compilation.
0c2d1a2a 4045This is useful when you have installed GCC as a cross-compiler.
74291a4b
MM
4046
4047The value to use for @var{machine} is the same as was specified as the
0c2d1a2a 4048machine type when configuring GCC as a cross-compiler. For
74291a4b
MM
4049example, if a cross-compiler was configured with @samp{configure
4050i386v}, meaning to compile for an 80386 running System V, then you
4051would specify @samp{-b i386v} to run that cross compiler.
4052
4053When you do not specify @samp{-b}, it normally means to compile for
4054the same type of machine that you are using.
4055
4056@item -V @var{version}
0c2d1a2a 4057The argument @var{version} specifies which version of GCC to run.
74291a4b 4058This is useful when multiple versions are installed. For example,
0c2d1a2a 4059@var{version} might be @samp{2.0}, meaning to run GCC version 2.0.
74291a4b
MM
4060
4061The default version, when you do not specify @samp{-V}, is the last
0c2d1a2a 4062version of GCC that you installed.
74291a4b
MM
4063@end table
4064
4065The @samp{-b} and @samp{-V} options actually work by controlling part of
4066the file name used for the executable files and libraries used for
0c2d1a2a 4067compilation. A given version of GCC, for a given target machine, is
74291a4b
MM
4068normally kept in the directory @file{/usr/local/lib/gcc-lib/@var{machine}/@var{version}}.@refill
4069
4070Thus, sites can customize the effect of @samp{-b} or @samp{-V} either by
4071changing the names of these directories or adding alternate names (or
4072symbolic links). If in directory @file{/usr/local/lib/gcc-lib/} the
4073file @file{80386} is a link to the file @file{i386v}, then @samp{-b
407480386} becomes an alias for @samp{-b i386v}.
4075
4076In one respect, the @samp{-b} or @samp{-V} do not completely change
4077to a different compiler: the top-level driver program @code{gcc}
4078that you originally invoked continues to run and invoke the other
4079executables (preprocessor, compiler per se, assembler and linker)
4080that do the real work. However, since no real work is done in the
4081driver program, it usually does not matter that the driver program
8c7b74b9
JM
4082in use is not the one for the specified target. It is common for the
4083interface to the other executables to change incompatibly between
4084compiler versions, so unless the version specified is very close to that
4085of the driver (for example, @samp{-V 3.0} with a driver program from GCC
4086version 3.0.1), use of @samp{-V} may not work; for example, using
4087@samp{-V 2.95.2} will not work with a driver program from GCC 3.0.
74291a4b
MM
4088
4089The only way that the driver program depends on the target machine is
4090in the parsing and handling of special machine-specific options.
4091However, this is controlled by a file which is found, along with the
4092other executables, in the directory for the specified version and
4093target machine. As a result, a single installed driver program adapts
8c7b74b9
JM
4094to any specified target machine, and sufficiently similar compiler
4095versions.
74291a4b
MM
4096
4097The driver program executable does control one significant thing,
4098however: the default version and target machine. Therefore, you can
4099install different instances of the driver program, compiled for
4100different targets or versions, under different names.
4101
4102For example, if the driver for version 2.0 is installed as @code{ogcc}
4103and that for version 2.1 is installed as @code{gcc}, then the command
4104@code{gcc} will use version 2.1 by default, while @code{ogcc} will use
41052.0 by default. However, you can choose either version with either
4106command with the @samp{-V} option.
4107
4108@node Submodel Options
4109@section Hardware Models and Configurations
4110@cindex submodel options
4111@cindex specifying hardware config
4112@cindex hardware models and configurations, specifying
4113@cindex machine dependent options
4114
4115Earlier we discussed the standard option @samp{-b} which chooses among
4116different installed compilers for completely different target
4117machines, such as Vax vs. 68000 vs. 80386.
4118
4119In addition, each of these target machine types can have its own
4120special options, starting with @samp{-m}, to choose among various
4121hardware models or configurations---for example, 68010 vs 68020,
4122floating coprocessor or none. A single installed version of the
4123compiler can compile for any model or configuration, according to the
4124options specified.
4125
4126Some configurations of the compiler also support additional special
4127options, usually for compatibility with other compilers on the same
4128platform.
4129
4130@ifset INTERNALS
4131These options are defined by the macro @code{TARGET_SWITCHES} in the
4132machine description. The default for the options is also defined by
4133that macro, which enables you to change the defaults.
4134@end ifset
4135
4136@menu
4137* M680x0 Options::
2856c3e3 4138* M68hc1x Options::
74291a4b
MM
4139* VAX Options::
4140* SPARC Options::
4141* Convex Options::
4142* AMD29K Options::
4143* ARM Options::
157a620e 4144* Thumb Options::
ecff22ab 4145* MN10200 Options::
6d6d0fa0 4146* MN10300 Options::
861bb6c1 4147* M32R/D Options::
74291a4b
MM
4148* M88K Options::
4149* RS/6000 and PowerPC Options::
4150* RT Options::
4151* MIPS Options::
4152* i386 Options::
4153* HPPA Options::
4154* Intel 960 Options::
4155* DEC Alpha Options::
4156* Clipper Options::
4157* H8/300 Options::
4158* SH Options::
4159* System V Options::
282a61e6 4160* TMS320C3x/C4x Options::
f84271d9 4161* V850 Options::
56b2d7a7 4162* ARC Options::
83575957 4163* NS32K Options::
052a4b28
DC
4164* AVR Options::
4165* MCore Options::
e8ad90e5 4166* D30V Options::
74291a4b
MM
4167@end menu
4168
4169@node M680x0 Options
4170@subsection M680x0 Options
4171@cindex M680x0 options
4172
4173These are the @samp{-m} options defined for the 68000 series. The default
4174values for these options depends on which style of 68000 was selected when
4175the compiler was configured; the defaults for the most common choices are
4176given below.
4177
4178@table @code
4179@item -m68000
4180@itemx -mc68000
4181Generate output for a 68000. This is the default
4182when the compiler is configured for 68000-based systems.
4183
74cf1c6d
RK
4184Use this option for microcontrollers with a 68000 or EC000 core,
4185including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
4186
74291a4b
MM
4187@item -m68020
4188@itemx -mc68020
4189Generate output for a 68020. This is the default
4190when the compiler is configured for 68020-based systems.
4191
4192@item -m68881
4193Generate output containing 68881 instructions for floating point.
4194This is the default for most 68020 systems unless @samp{-nfp} was
4195specified when the compiler was configured.
4196
4197@item -m68030
4198Generate output for a 68030. This is the default when the compiler is
4199configured for 68030-based systems.
4200
4201@item -m68040
4202Generate output for a 68040. This is the default when the compiler is
4203configured for 68040-based systems.
4204
4205This option inhibits the use of 68881/68882 instructions that have to be
74cf1c6d
RK
4206emulated by software on the 68040. Use this option if your 68040 does not
4207have code to emulate those instructions.
74291a4b
MM
4208
4209@item -m68060
4210Generate output for a 68060. This is the default when the compiler is
4211configured for 68060-based systems.
4212
4213This option inhibits the use of 68020 and 68881/68882 instructions that
74cf1c6d
RK
4214have to be emulated by software on the 68060. Use this option if your 68060
4215does not have code to emulate those instructions.
4216
4217@item -mcpu32
4218Generate output for a CPU32. This is the default
4219when the compiler is configured for CPU32-based systems.
4220
4221Use this option for microcontrollers with a
4222CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
422368336, 68340, 68341, 68349 and 68360.
74291a4b
MM
4224
4225@item -m5200
4226Generate output for a 520X "coldfire" family cpu. This is the default
4227when the compiler is configured for 520X-based systems.
4228
74cf1c6d
RK
4229Use this option for microcontroller with a 5200 core, including
4230the MCF5202, MCF5203, MCF5204 and MCF5202.
4231
74291a4b
MM
4232
4233@item -m68020-40
4234Generate output for a 68040, without using any of the new instructions.
4235This results in code which can run relatively efficiently on either a
423668020/68881 or a 68030 or a 68040. The generated code does use the
423768881 instructions that are emulated on the 68040.
4238
861bb6c1
JL
4239@item -m68020-60
4240Generate output for a 68060, without using any of the new instructions.
4241This results in code which can run relatively efficiently on either a
424268020/68881 or a 68030 or a 68040. The generated code does use the
424368881 instructions that are emulated on the 68060.
4244
74291a4b
MM
4245@item -mfpa
4246Generate output containing Sun FPA instructions for floating point.
4247
4248@item -msoft-float
4249Generate output containing library calls for floating point.
4250@strong{Warning:} the requisite libraries are not available for all m68k
4251targets. Normally the facilities of the machine's usual C compiler are
4252used, but this can't be done directly in cross-compilation. You must
4253make your own arrangements to provide suitable library functions for
4254cross-compilation. The embedded targets @samp{m68k-*-aout} and
4255@samp{m68k-*-coff} do provide software floating point support.
4256
4257@item -mshort
4258Consider type @code{int} to be 16 bits wide, like @code{short int}.
4259
4260@item -mnobitfield
74cf1c6d
RK
4261Do not use the bit-field instructions. The @samp{-m68000}, @samp{-mcpu32}
4262and @samp{-m5200} options imply @w{@samp{-mnobitfield}}.
74291a4b
MM
4263
4264@item -mbitfield
4265Do use the bit-field instructions. The @samp{-m68020} option implies
4266@samp{-mbitfield}. This is the default if you use a configuration
4267designed for a 68020.
4268
4269@item -mrtd
4270Use a different function-calling convention, in which functions
4271that take a fixed number of arguments return with the @code{rtd}
4272instruction, which pops their arguments while returning. This
4273saves one instruction in the caller since there is no need to pop
4274the arguments there.
4275
4276This calling convention is incompatible with the one normally
4277used on Unix, so you cannot use it if you need to call libraries
4278compiled with the Unix compiler.
4279
4280Also, you must provide function prototypes for all functions that
4281take variable numbers of arguments (including @code{printf});
4282otherwise incorrect code will be generated for calls to those
4283functions.
4284
4285In addition, seriously incorrect code will result if you call a
4286function with too many arguments. (Normally, extra arguments are
4287harmlessly ignored.)
4288
4289The @code{rtd} instruction is supported by the 68010, 68020, 68030,
74cf1c6d 429068040, 68060 and CPU32 processors, but not by the 68000 or 5200.
861bb6c1
JL
4291
4292@item -malign-int
4293@itemx -mno-align-int
0c2d1a2a 4294Control whether GCC aligns @code{int}, @code{long}, @code{long long},
861bb6c1
JL
4295@code{float}, @code{double}, and @code{long double} variables on a 32-bit
4296boundary (@samp{-malign-int}) or a 16-bit boundary (@samp{-mno-align-int}).
4297Aligning variables on 32-bit boundaries produces code that runs somewhat
4298faster on processors with 32-bit busses at the expense of more memory.
4299
0c2d1a2a 4300@strong{Warning:} if you use the @samp{-malign-int} switch, GCC will
861bb6c1
JL
4301align structures containing the above types differently than
4302most published application binary interface specifications for the m68k.
4303
fb868474
DL
4304@item -mpcrel
4305Use the pc-relative addressing mode of the 68000 directly, instead of
4306using a global offset table. At present, this option implies -fpic,
4307allowing at most a 16-bit offset for pc-relative addressing. -fPIC is
4308not presently supported with -mpcrel, though this could be supported for
430968020 and higher processors.
4310
b71733d5
GM
4311@item -mno-strict-align
4312@itemx -mstrict-align
4313@kindex -mstrict-align
4314Do not (do) assume that unaligned memory references will be handled by
4315the system.
4316
74291a4b
MM
4317@end table
4318
2856c3e3
SC
4319@node M68hc1x Options
4320@subsection M68hc1x Options
4321@cindex M68hc1x options
4322
4323These are the @samp{-m} options defined for the 68hc11 and 68hc12
4324microcontrollers. The default values for these options depends on
4325which style of microcontroller was selected when the compiler was configured;
4326the defaults for the most common choices are given below.
4327
4328@table @code
4329@item -m6811
4330@itemx -m68hc11
4331Generate output for a 68HC11. This is the default
4332when the compiler is configured for 68HC11-based systems.
4333
4334@item -m6812
4335@itemx -m68hc12
4336Generate output for a 68HC12. This is the default
4337when the compiler is configured for 68HC12-based systems.
4338
4339@item -mauto-incdec
4340Enable the use of 68HC12 pre and post auto-increment and auto-decrement
4341addressing modes.
4342
4343@item -mshort
4344Consider type @code{int} to be 16 bits wide, like @code{short int}.
4345
4346@item -msoft-reg-count=@var{count}
4347Specify the number of pseudo-soft registers which are used for the
4348code generation. The maximum number is 32. Using more pseudo-soft
4349register may or may not result in better code depending on the program.
4350The default is 4 for 68HC11 and 2 for 68HC12.
4351
4352@end table
4353
74291a4b
MM
4354@node VAX Options
4355@subsection VAX Options
4356@cindex VAX options
4357
4358These @samp{-m} options are defined for the Vax:
4359
4360@table @code
4361@item -munix
4362Do not output certain jump instructions (@code{aobleq} and so on)
4363that the Unix assembler for the Vax cannot handle across long
4364ranges.
4365
4366@item -mgnu
4367Do output those jump instructions, on the assumption that you
4368will assemble with the GNU assembler.
4369
4370@item -mg
4371Output code for g-format floating point numbers instead of d-format.
4372@end table
4373
4374@node SPARC Options
4375@subsection SPARC Options
4376@cindex SPARC options
4377
4378These @samp{-m} switches are supported on the SPARC:
4379
4380@table @code
4381@item -mno-app-regs
4382@itemx -mapp-regs
4383Specify @samp{-mapp-regs} to generate output using the global registers
43842 through 4, which the SPARC SVR4 ABI reserves for applications. This
4385is the default.
4386
4387To be fully SVR4 ABI compliant at the cost of some performance loss,
4388specify @samp{-mno-app-regs}. You should compile libraries and system
4389software with this option.
4390
4391@item -mfpu
4392@itemx -mhard-float
4393Generate output containing floating point instructions. This is the
4394default.
4395
4396@item -mno-fpu
4397@itemx -msoft-float
4398Generate output containing library calls for floating point.
4399@strong{Warning:} the requisite libraries are not available for all SPARC
4400targets. Normally the facilities of the machine's usual C compiler are
4401used, but this cannot be done directly in cross-compilation. You must make
4402your own arrangements to provide suitable library functions for
4403cross-compilation. The embedded targets @samp{sparc-*-aout} and
4404@samp{sparclite-*-*} do provide software floating point support.
4405
4406@samp{-msoft-float} changes the calling convention in the output file;
4407therefore, it is only useful if you compile @emph{all} of a program with
4408this option. In particular, you need to compile @file{libgcc.a}, the
0c2d1a2a 4409library that comes with GCC, with @samp{-msoft-float} in order for
74291a4b
MM
4410this to work.
4411
4412@item -mhard-quad-float
4413Generate output containing quad-word (long double) floating point
4414instructions.
4415
4416@item -msoft-quad-float
4417Generate output containing library calls for quad-word (long double)
4418floating point instructions. The functions called are those specified
4419in the SPARC ABI. This is the default.
4420
4421As of this writing, there are no sparc implementations that have hardware
4422support for the quad-word floating point instructions. They all invoke
4423a trap handler for one of these instructions, and then the trap handler
4424emulates the effect of the instruction. Because of the trap handler overhead,
4425this is much slower than calling the ABI library routines. Thus the
4426@samp{-msoft-quad-float} option is the default.
4427
4428@item -mno-epilogue
4429@itemx -mepilogue
4430With @samp{-mepilogue} (the default), the compiler always emits code for
4431function exit at the end of each function. Any function exit in
4432the middle of the function (such as a return statement in C) will
4433generate a jump to the exit code at the end of the function.
4434
4435With @samp{-mno-epilogue}, the compiler tries to emit exit code inline
4436at every function exit.
4437
4438@item -mno-flat
4439@itemx -mflat
4440With @samp{-mflat}, the compiler does not generate save/restore instructions
4441and will use a "flat" or single register window calling convention.
4442This model uses %i7 as the frame pointer and is compatible with the normal
4443register window model. Code from either may be intermixed.
4444The local registers and the input registers (0-5) are still treated as
4445"call saved" registers and will be saved on the stack as necessary.
4446
4447With @samp{-mno-flat} (the default), the compiler emits save/restore
4448instructions (except for leaf functions) and is the normal mode of operation.
4449
4450@item -mno-unaligned-doubles
4451@itemx -munaligned-doubles
4452Assume that doubles have 8 byte alignment. This is the default.
4453
0c2d1a2a 4454With @samp{-munaligned-doubles}, GCC assumes that doubles have 8 byte
74291a4b
MM
4455alignment only if they are contained in another type, or if they have an
4456absolute address. Otherwise, it assumes they have 4 byte alignment.
4457Specifying this option avoids some rare compatibility problems with code
4458generated by other compilers. It is not the default because it results
4459in a performance loss, especially for floating point code.
4460
c219ddf7
BK
4461@item -mno-faster-structs
4462@itemx -mfaster-structs
4463With @samp{-mfaster-structs}, the compiler assumes that structures
4464should have 8 byte alignment. This enables the use of pairs of
4465@code{ldd} and @code{std} instructions for copies in structure
4466assignment, in place of twice as many @code{ld} and @code{st} pairs.
4467However, the use of this changed alignment directly violates the Sparc
4468ABI. Thus, it's intended only for use on targets where the developer
4469acknowledges that their resulting code will not be directly in line with
4470the rules of the ABI.
4471
74291a4b
MM
4472@item -mv8
4473@itemx -msparclite
4474These two options select variations on the SPARC architecture.
4475
4476By default (unless specifically configured for the Fujitsu SPARClite),
4477GCC generates code for the v7 variant of the SPARC architecture.
4478
4479@samp{-mv8} will give you SPARC v8 code. The only difference from v7
4480code is that the compiler emits the integer multiply and integer
4481divide instructions which exist in SPARC v8 but not in SPARC v7.
4482
4483@samp{-msparclite} will give you SPARClite code. This adds the integer
4484multiply, integer divide step and scan (@code{ffs}) instructions which
4485exist in SPARClite but not in SPARC v7.
4486
0c2d1a2a 4487These options are deprecated and will be deleted in a future GCC release.
74291a4b
MM
4488They have been replaced with @samp{-mcpu=xxx}.
4489
4490@item -mcypress
4491@itemx -msupersparc
4492These two options select the processor for which the code is optimised.
4493
4494With @samp{-mcypress} (the default), the compiler optimizes code for the
4495Cypress CY7C602 chip, as used in the SparcStation/SparcServer 3xx series.
4496This is also appropriate for the older SparcStation 1, 2, IPX etc.
4497
4498With @samp{-msupersparc} the compiler optimizes code for the SuperSparc cpu, as
4499used in the SparcStation 10, 1000 and 2000 series. This flag also enables use
4500of the full SPARC v8 instruction set.
4501
0c2d1a2a 4502These options are deprecated and will be deleted in a future GCC release.
74291a4b
MM
4503They have been replaced with @samp{-mcpu=xxx}.
4504
4505@item -mcpu=@var{cpu_type}
c0498f43
DE
4506Set the instruction set, register set, and instruction scheduling parameters
4507for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
4508@samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{sparclite},
ad6843d7
RH
4509@samp{hypersparc}, @samp{sparclite86x}, @samp{f930}, @samp{f934},
4510@samp{sparclet}, @samp{tsc701}, @samp{v9}, and @samp{ultrasparc}.
c0498f43
DE
4511
4512Default instruction scheduling parameters are used for values that select
4513an architecture and not an implementation. These are @samp{v7}, @samp{v8},
4514@samp{sparclite}, @samp{sparclet}, @samp{v9}.
4515
4516Here is a list of each supported architecture and their supported
4517implementations.
4518
4519@smallexample
4520 v7: cypress
ad6843d7
RH
4521 v8: supersparc, hypersparc
4522 sparclite: f930, f934, sparclite86x
c0498f43
DE
4523 sparclet: tsc701
4524 v9: ultrasparc
4525@end smallexample
74291a4b
MM
4526
4527@item -mtune=@var{cpu_type}
4528Set the instruction scheduling parameters for machine type
c0498f43
DE
4529@var{cpu_type}, but do not set the instruction set or register set that the
4530option @samp{-mcpu=}@var{cpu_type} would.
4531
4532The same values for @samp{-mcpu=}@var{cpu_type} are used for
e5e809f4 4533@samp{-mtune=}@*@var{cpu_type}, though the only useful values are those that
c0498f43 4534select a particular cpu implementation: @samp{cypress}, @samp{supersparc},
ad6843d7
RH
4535@samp{hypersparc}, @samp{f930}, @samp{f934}, @samp{sparclite86x},
4536@samp{tsc701}, @samp{ultrasparc}.
74291a4b
MM
4537
4538@end table
4539
4540These @samp{-m} switches are supported in addition to the above
4541on the SPARCLET processor.
4542
4543@table @code
4544@item -mlittle-endian
4545Generate code for a processor running in little-endian mode.
4546
4547@item -mlive-g0
4548Treat register @code{%g0} as a normal register.
4549GCC will continue to clobber it as necessary but will not assume
4550it always reads as 0.
4551
4552@item -mbroken-saverestore
4553Generate code that does not use non-trivial forms of the @code{save} and
4554@code{restore} instructions. Early versions of the SPARCLET processor do
4555not correctly handle @code{save} and @code{restore} instructions used with
4556arguments. They correctly handle them used without arguments. A @code{save}
4557instruction used without arguments increments the current window pointer
4558but does not allocate a new stack frame. It is assumed that the window
4559overflow trap handler will properly handle this case as will interrupt
4560handlers.
4561@end table
4562
4563These @samp{-m} switches are supported in addition to the above
4564on SPARC V9 processors in 64 bit environments.
4565
4566@table @code
4567@item -mlittle-endian
4568Generate code for a processor running in little-endian mode.
4569
ded17aad
DE
4570@item -m32
4571@itemx -m64
4572Generate code for a 32 bit or 64 bit environment.
4573The 32 bit environment sets int, long and pointer to 32 bits.
4574The 64 bit environment sets int to 32 bits and long and pointer
4575to 64 bits.
4576
4577@item -mcmodel=medlow
4578Generate code for the Medium/Low code model: the program must be linked
4579in the low 32 bits of the address space. Pointers are 64 bits.
4580Programs can be statically or dynamically linked.
4581
4582@item -mcmodel=medmid
4583Generate code for the Medium/Middle code model: the program must be linked
4584in the low 44 bits of the address space, the text segment must be less than
45852G bytes, and data segment must be within 2G of the text segment.
4586Pointers are 64 bits.
4587
4588@item -mcmodel=medany
4589Generate code for the Medium/Anywhere code model: the program may be linked
4590anywhere in the address space, the text segment must be less than
45912G bytes, and data segment must be within 2G of the text segment.
4592Pointers are 64 bits.
4593
4594@item -mcmodel=embmedany
4595Generate code for the Medium/Anywhere code model for embedded systems:
4596assume a 32 bit text and a 32 bit data segment, both starting anywhere
4597(determined at link time). Register %g4 points to the base of the
4598data segment. Pointers still 64 bits.
4599Programs are statically linked, PIC is not supported.
74291a4b
MM
4600
4601@item -mstack-bias
4602@itemx -mno-stack-bias
0c2d1a2a 4603With @samp{-mstack-bias}, GCC assumes that the stack pointer, and
74291a4b
MM
4604frame pointer if present, are offset by -2047 which must be added back
4605when making stack frame references.
4606Otherwise, assume no such offset is present.
4607@end table
4608
4609@node Convex Options
4610@subsection Convex Options
4611@cindex Convex options
4612
4613These @samp{-m} options are defined for Convex:
4614
4615@table @code
4616@item -mc1
4617Generate output for C1. The code will run on any Convex machine.
4618The preprocessor symbol @code{__convex__c1__} is defined.
4619
4620@item -mc2
4621Generate output for C2. Uses instructions not available on C1.
4622Scheduling and other optimizations are chosen for max performance on C2.
4623The preprocessor symbol @code{__convex_c2__} is defined.
4624
4625@item -mc32
4626Generate output for C32xx. Uses instructions not available on C1.
4627Scheduling and other optimizations are chosen for max performance on C32.
4628The preprocessor symbol @code{__convex_c32__} is defined.
4629
4630@item -mc34
4631Generate output for C34xx. Uses instructions not available on C1.
4632Scheduling and other optimizations are chosen for max performance on C34.
4633The preprocessor symbol @code{__convex_c34__} is defined.
4634
4635@item -mc38
4636Generate output for C38xx. Uses instructions not available on C1.
4637Scheduling and other optimizations are chosen for max performance on C38.
4638The preprocessor symbol @code{__convex_c38__} is defined.
4639
4640@item -margcount
4641Generate code which puts an argument count in the word preceding each
4642argument list. This is compatible with regular CC, and a few programs
4643may need the argument count word. GDB and other source-level debuggers
4644do not need it; this info is in the symbol table.
4645
4646@item -mnoargcount
4647Omit the argument count word. This is the default.
4648
4649@item -mvolatile-cache
4650Allow volatile references to be cached. This is the default.
4651
4652@item -mvolatile-nocache
4653Volatile references bypass the data cache, going all the way to memory.
4654This is only needed for multi-processor code that does not use standard
4655synchronization instructions. Making non-volatile references to volatile
4656locations will not necessarily work.
4657
4658@item -mlong32
4659Type long is 32 bits, the same as type int. This is the default.
4660
4661@item -mlong64
4662Type long is 64 bits, the same as type long long. This option is useless,
4663because no library support exists for it.
4664@end table
4665
4666@node AMD29K Options
4667@subsection AMD29K Options
4668@cindex AMD29K options
4669
4670These @samp{-m} options are defined for the AMD Am29000:
4671
4672@table @code
4673@item -mdw
4674@kindex -mdw
4675@cindex DW bit (29k)
4676Generate code that assumes the @code{DW} bit is set, i.e., that byte and
4677halfword operations are directly supported by the hardware. This is the
4678default.
4679
4680@item -mndw
4681@kindex -mndw
4682Generate code that assumes the @code{DW} bit is not set.
4683
4684@item -mbw
4685@kindex -mbw
4686@cindex byte writes (29k)
4687Generate code that assumes the system supports byte and halfword write
4688operations. This is the default.
4689
4690@item -mnbw
4691@kindex -mnbw
4692Generate code that assumes the systems does not support byte and
4693halfword write operations. @samp{-mnbw} implies @samp{-mndw}.
4694
4695@item -msmall
4696@kindex -msmall
4697@cindex memory model (29k)
4698Use a small memory model that assumes that all function addresses are
4699either within a single 256 KB segment or at an absolute address of less
4700than 256k. This allows the @code{call} instruction to be used instead
4701of a @code{const}, @code{consth}, @code{calli} sequence.
4702
4703@item -mnormal
4704@kindex -mnormal
4705Use the normal memory model: Generate @code{call} instructions only when
4706calling functions in the same file and @code{calli} instructions
4707otherwise. This works if each file occupies less than 256 KB but allows
4708the entire executable to be larger than 256 KB. This is the default.
4709
4710@item -mlarge
4711Always use @code{calli} instructions. Specify this option if you expect
4712a single file to compile into more than 256 KB of code.
4713
4714@item -m29050
4715@kindex -m29050
4716@cindex processor selection (29k)
4717Generate code for the Am29050.
4718
4719@item -m29000
4720@kindex -m29000
4721Generate code for the Am29000. This is the default.
4722
4723@item -mkernel-registers
4724@kindex -mkernel-registers
4725@cindex kernel and user registers (29k)
4726Generate references to registers @code{gr64-gr95} instead of to
4727registers @code{gr96-gr127}. This option can be used when compiling
4728kernel code that wants a set of global registers disjoint from that used
4729by user-mode code.
4730
4731Note that when this option is used, register names in @samp{-f} flags
4732must use the normal, user-mode, names.
4733
4734@item -muser-registers
4735@kindex -muser-registers
4736Use the normal set of global registers, @code{gr96-gr127}. This is the
4737default.
4738
4739@item -mstack-check
4740@itemx -mno-stack-check
4741@kindex -mstack-check
4742@cindex stack checks (29k)
4743Insert (or do not insert) a call to @code{__msp_check} after each stack
4744adjustment. This is often used for kernel code.
4745
4746@item -mstorem-bug
4747@itemx -mno-storem-bug
4748@kindex -mstorem-bug
4749@cindex storem bug (29k)
4750@samp{-mstorem-bug} handles 29k processors which cannot handle the
4751separation of a mtsrim insn and a storem instruction (most 29000 chips
4752to date, but not the 29050).
4753
4754@item -mno-reuse-arg-regs
4755@itemx -mreuse-arg-regs
4756@kindex -mreuse-arg-regs
4757@samp{-mno-reuse-arg-regs} tells the compiler to only use incoming argument
4758registers for copying out arguments. This helps detect calling a function
4759with fewer arguments than it was declared with.
4760
861bb6c1
JL
4761@item -mno-impure-text
4762@itemx -mimpure-text
4763@kindex -mimpure-text
4764@samp{-mimpure-text}, used in addition to @samp{-shared}, tells the compiler to
4765not pass @samp{-assert pure-text} to the linker when linking a shared object.
4766
74291a4b
MM
4767@item -msoft-float
4768@kindex -msoft-float
4769Generate output containing library calls for floating point.
0c2d1a2a 4770@strong{Warning:} the requisite libraries are not part of GCC.
74291a4b
MM
4771Normally the facilities of the machine's usual C compiler are used, but
4772this can't be done directly in cross-compilation. You must make your
4773own arrangements to provide suitable library functions for
4774cross-compilation.
4e8d7ddc
JW
4775
4776@item -mno-multm
4777@kindex -mno-multm
4778Do not generate multm or multmu instructions. This is useful for some embedded
4779systems which do not have trap handlers for these instructions.
74291a4b
MM
4780@end table
4781
4782@node ARM Options
4783@subsection ARM Options
4784@cindex ARM options
4785
4786These @samp{-m} options are defined for Advanced RISC Machines (ARM)
4787architectures:
4788
4789@table @code
4790@item -mapcs-frame
4791@kindex -mapcs-frame
4792Generate a stack frame that is compliant with the ARM Procedure Call
4793Standard for all functions, even if this is not strictly necessary for
157a620e
NC
4794correct execution of the code. Specifying @samp{-fomit-frame-pointer}
4795with this option will cause the stack frames not to be generated for
4796leaf functions. The default is @samp{-mno-apcs-frame}.
4797
4798@item -mapcs
4799@kindex -mapcs
4800This is a synonym for @samp{-mapcs-frame}.
74291a4b
MM
4801
4802@item -mapcs-26
4803@kindex -mapcs-26
4804Generate code for a processor running with a 26-bit program counter,
4805and conforming to the function calling standards for the APCS 26-bit
4806option. This option replaces the @samp{-m2} and @samp{-m3} options
4807of previous releases of the compiler.
4808
4809@item -mapcs-32
4810@kindex -mapcs-32
4811Generate code for a processor running with a 32-bit program counter,
4812and conforming to the function calling standards for the APCS 32-bit
4813option. This option replaces the @samp{-m6} option of previous releases
4814of the compiler.
4815
157a620e
NC
4816@item -mapcs-stack-check
4817@kindex -mapcs-stack-check
4818@kindex -mno-apcs-stack-check
4819Generate code to check the amount of stack space available upon entry to
4820every function (that actually uses some stack space). If there is
4821insufficient space available then either the function
4822@samp{__rt_stkovf_split_small} or @samp{__rt_stkovf_split_big} will be
4823called, depending upon the amount of stack space required. The run time
4824system is required to provide these functions. The default is
4825@samp{-mno-apcs-stack-check}, since this produces smaller code.
4826
4827@item -mapcs-float
4828@kindex -mapcs-float
4829@kindex -mno-apcs-float
4830Pass floating point arguments using the float point registers. This is
ed0e6530 4831one of the variants of the APCS. This option is recommended if the
157a620e
NC
4832target hardware has a floating point unit or if a lot of floating point
4833arithmetic is going to be performed by the code. The default is
4834@samp{-mno-apcs-float}, since integer only code is slightly increased in
4835size if @samp{-mapcs-float} is used.
4836
4837@item -mapcs-reentrant
4838@kindex -mapcs-reentrant
4839@kindex -mno-apcs-reentrant
4840Generate reentrant, position independent code. This is the equivalent
4841to specifying the @samp{-fpic} option. The default is
4842@samp{-mno-apcs-reentrant}.
4843
4844@item -mthumb-interwork
4845@kindex -mthumb-interwork
4846@kindex -mno-thumb-interwork
4847Generate code which supports calling between the ARM and THUMB
4848instruction sets. Without this option the two instruction sets cannot
4849be reliably used inside one program. The default is
4850@samp{-mno-thumb-interwork}, since slightly larger code is generated
4851when @samp{-mthumb-interwork} is specified.
4852
4853@item -mno-sched-prolog
4854@kindex -mno-sched-prolog
4855@kindex -msched-prolog
4856Prevent the reordering of instructions in the function prolog, or the
4857merging of those instruction with the instructions in the function's
ed0e6530
PB
4858body. This means that all functions will start with a recognizable set
4859of instructions (or in fact one of a choice from a small set of
157a620e
NC
4860different function prologues), and this information can be used to
4861locate the start if functions inside an executable piece of code. The
4862default is @samp{-msched-prolog}.
4863
74291a4b
MM
4864@item -mhard-float
4865Generate output containing floating point instructions. This is the
4866default.
4867
4868@item -msoft-float
4869Generate output containing library calls for floating point.
4870@strong{Warning:} the requisite libraries are not available for all ARM
4871targets. Normally the facilities of the machine's usual C compiler are
4872used, but this cannot be done directly in cross-compilation. You must make
4873your own arrangements to provide suitable library functions for
4874cross-compilation.
4875
4876@samp{-msoft-float} changes the calling convention in the output file;
4877therefore, it is only useful if you compile @emph{all} of a program with
4878this option. In particular, you need to compile @file{libgcc.a}, the
0c2d1a2a 4879library that comes with GCC, with @samp{-msoft-float} in order for
74291a4b
MM
4880this to work.
4881
4882@item -mlittle-endian
4883Generate code for a processor running in little-endian mode. This is
4884the default for all standard configurations.
4885
4886@item -mbig-endian
4887Generate code for a processor running in big-endian mode; the default is
4888to compile code for a little-endian processor.
4889
4890@item -mwords-little-endian
4891This option only applies when generating code for big-endian processors.
4892Generate code for a little-endian word order but a big-endian byte
4893order. That is, a byte order of the form @samp{32107654}. Note: this
4894option should only be used if you require compatibility with code for
4895big-endian ARM processors generated by versions of the compiler prior to
48962.8.
4897
5f1e6755
NC
4898@item -malignment-traps
4899@kindex -malignment-traps
4900Generate code that will not trap if the MMU has alignment traps enabled.
4901On ARM architectures prior to ARMv4, there were no instructions to
4902access half-word objects stored in memory. However, when reading from
4903memory a feature of the ARM architecture allows a word load to be used,
4904even if the address is unaligned, and the processor core will rotate the
4905data as it is being loaded. This option tells the compiler that such
4906misaligned accesses will cause a MMU trap and that it should instead
4907synthesise the access as a series of byte accesses. The compiler can
4908still use word accesses to load half-word data if it knows that the
4909address is aligned to a word boundary.
4910
4911This option is ignored when compiling for ARM architecture 4 or later,
4912since these processors have instructions to directly access half-word
4913objects in memory.
4914
4915@item -mno-alignment-traps
4916@kindex -mno-alignment-traps
4917Generate code that assumes that the MMU will not trap unaligned
4918accesses. This produces better code when the target instruction set
4919does not have half-word memory operations (implementations prior to
4920ARMv4).
4921
4922Note that you cannot use this option to access unaligned word objects,
4923since the processor will only fetch one 32-bit aligned object from
4924memory.
4925
4926The default setting for most targets is -mno-alignment-traps, since
4927this produces better code when there are no half-word memory
4928instructions available.
4929
74291a4b
MM
4930@item -mshort-load-bytes
4931@kindex -mshort-load-bytes
9e8fc4b8 4932This is a deprecated alias for @samp{-malignment-traps}.
74291a4b
MM
4933
4934@item -mno-short-load-bytes
4935@kindex -mno-short-load-bytes
9e8fc4b8 4936This is a deprecated alias for @samp{-mno-alignment-traps}.
74291a4b 4937
157a620e
NC
4938@item -mshort-load-words
4939@kindex -mshort-load-words
9e8fc4b8 4940This is a deprecated alias for @samp{-mno-alignment-traps}.
157a620e
NC
4941
4942@item -mno-short-load-words
4943@kindex -mno-short-load-words
9e8fc4b8 4944This is a deprecated alias for @samp{-malignment-traps}.
157a620e 4945
74291a4b
MM
4946@item -mbsd
4947@kindex -mbsd
4948This option only applies to RISC iX. Emulate the native BSD-mode
4949compiler. This is the default if @samp{-ansi} is not specified.
4950
4951@item -mxopen
4952@kindex -mxopen
4953This option only applies to RISC iX. Emulate the native X/Open-mode
4954compiler.
4955
4956@item -mno-symrename
4957@kindex -mno-symrename
4958This option only applies to RISC iX. Do not run the assembler
4959post-processor, @samp{symrename}, after code has been assembled.
4960Normally it is necessary to modify some of the standard symbols in
4961preparation for linking with the RISC iX C library; this option
4962suppresses this pass. The post-processor is never run when the
4963compiler is built for cross-compilation.
157a620e
NC
4964
4965@item -mcpu=<name>
4966@kindex -mcpu=
4967This specifies the name of the target ARM processor. GCC uses this name
4968to determine what kind of instructions it can use when generating
ed0e6530 4969assembly code. Permissible names are: arm2, arm250, arm3, arm6, arm60,
157a620e
NC
4970arm600, arm610, arm620, arm7, arm7m, arm7d, arm7dm, arm7di, arm7dmi,
4971arm70, arm700, arm700i, arm710, arm710c, arm7100, arm7500, arm7500fe,
f5a1b0d2 4972arm7tdmi, arm8, strongarm, strongarm110, strongarm1100, arm8, arm810,
62b10bbc
NC
4973arm9, arm920, arm920t, arm9tdmi.
4974
4975@itemx -mtune=<name>
4976@kindex -mtune=
4977This option is very similar to the @samp{-mcpu=} option, except that
4978instead of specifying the actual target processor type, and hence
4979restricting which instructions can be used, it specifies that GCC should
4980tune the performance of the code as if the target were of the type
4981specified in this option, but still choosing the instructions that it
4982will generate based on the cpu specified by a @samp{-mcpu=} option.
4983For some arm implementations better performance can be obtained by using
4984this option.
157a620e
NC
4985
4986@item -march=<name>
4987@kindex -march=
4988This specifies the name of the target ARM architecture. GCC uses this
4989name to determine what kind of instructions it can use when generating
4990assembly code. This option can be used in conjunction with or instead
ed0e6530 4991of the @samp{-mcpu=} option. Permissible names are: armv2, armv2a,
62b10bbc 4992armv3, armv3m, armv4, armv4t, armv5.
157a620e
NC
4993
4994@item -mfpe=<number>
59d40964 4995@itemx -mfp=<number>
157a620e 4996@kindex -mfpe=
f5a1b0d2 4997@kindex -mfp=
b192711e 4998This specifies the version of the floating point emulation available on
ed0e6530 4999the target. Permissible values are 2 and 3. @samp{-mfp=} is a synonym
f5a1b0d2 5000for @samp{-mfpe=} to support older versions of GCC.
157a620e
NC
5001
5002@item -mstructure-size-boundary=<n>
5003@kindex -mstructure-size-boundary
5004The size of all structures and unions will be rounded up to a multiple
ed0e6530 5005of the number of bits set by this option. Permissible values are 8 and
157a620e
NC
500632. The default value varies for different toolchains. For the COFF
5007targeted toolchain the default value is 8. Specifying the larger number
ed0e6530 5008can produce faster, more efficient code, but can also increase the size
157a620e
NC
5009of the program. The two values are potentially incompatible. Code
5010compiled with one value cannot necessarily expect to work with code or
5011libraries compiled with the other value, if they exchange information
5012using structures or unions. Programmers are encouraged to use the 32
5013value as future versions of the toolchain may default to this value.
5014
f5a1b0d2
NC
5015@item -mabort-on-noreturn
5016@kindex -mabort-on-noreturn
5017@kindex -mnoabort-on-noreturn
5018Generate a call to the function abort at the end of a noreturn function.
5019It will be executed if the function tries to return.
5020
c27ba912
DM
5021@item -mlong-calls
5022@itemx -mno-long-calls
5023Tells the compiler to perform function calls by first loading the
5024address of the function into a register and then performing a subroutine
5025call on this register. This switch is needed if the target function
5026will lie outside of the 64 megabyte addressing range of the offset based
5027version of subroutine call instruction.
5028
5029Even if this switch is enabled, not all function calls will be turned
5030into long calls. The heuristic is that static functions, functions
5031which have the @samp{short-call} attribute, functions that are inside
5032the scope of a @samp{#pragma no_long_calls} directive and functions whose
5033definitions have already been compiled within the current compilation
5034unit, will not be turned into long calls. The exception to this rule is
b192711e 5035that weak function definitions, functions with the @samp{long-call}
c27ba912
DM
5036attribute or the @samp{section} attribute, and functions that are within
5037the scope of a @samp{#pragma long_calls} directive, will always be
5038turned into long calls.
5039
5040This feature is not enabled by default. Specifying
5041@samp{--no-long-calls} will restore the default behaviour, as will
5042placing the function calls within the scope of a @samp{#pragma
5043long_calls_off} directive. Note these switches have no effect on how
5044the compiler generates code to handle function calls via function
5045pointers.
5046
62b10bbc
NC
5047@item -mnop-fun-dllimport
5048@kindex -mnop-fun-dllimport
5049Disable the support for the @emph{dllimport} attribute.
5050
ed0e6530
PB
5051@item -msingle-pic-base
5052@kindex -msingle-pic-base
5053Treat the register used for PIC addressing as read-only, rather than
5054loading it in the prologue for each function. The run-time system is
5055responsible for initialising this register with an appropriate value
5056before execution begins.
5057
5058@item -mpic-register=<reg>
5059@kindex -mpic-register=
5060Specify the register to be used for PIC addressing. The default is R10
5061unless stack-checking is enabled, when R9 is used.
5062
74291a4b
MM
5063@end table
5064
157a620e
NC
5065@node Thumb Options
5066@subsection Thumb Options
5067@cindex Thumb Options
5068
5069@table @code
5070
5071@item -mthumb-interwork
5072@kindex -mthumb-interwork
5073@kindex -mno-thumb-interwork
5074Generate code which supports calling between the THUMB and ARM
5075instruction sets. Without this option the two instruction sets cannot
5076be reliably used inside one program. The default is
5077@samp{-mno-thumb-interwork}, since slightly smaller code is generated
5078with this option.
5079
5080@item -mtpcs-frame
5081@kindex -mtpcs-frame
5082@kindex -mno-tpcs-frame
5083Generate a stack frame that is compliant with the Thumb Procedure Call
5084Standard for all non-leaf functions. (A leaf function is one that does
5085not call any other functions). The default is @samp{-mno-apcs-frame}.
5086
5087@item -mtpcs-leaf-frame
5088@kindex -mtpcs-leaf-frame
5089@kindex -mno-tpcs-leaf-frame
5090Generate a stack frame that is compliant with the Thumb Procedure Call
5091Standard for all leaf functions. (A leaf function is one that does
5092not call any other functions). The default is @samp{-mno-apcs-leaf-frame}.
5093
5094@item -mlittle-endian
5095@kindex -mlittle-endian
5096Generate code for a processor running in little-endian mode. This is
5097the default for all standard configurations.
5098
5099@item -mbig-endian
5100@kindex -mbig-endian
5101Generate code for a processor running in big-endian mode.
5102
5103@item -mstructure-size-boundary=<n>
5104@kindex -mstructure-size-boundary
5105The size of all structures and unions will be rounded up to a multiple
4bdc1ac7 5106of the number of bits set by this option. Permissible values are 8 and
157a620e
NC
510732. The default value varies for different toolchains. For the COFF
5108targeted toolchain the default value is 8. Specifying the larger number
5109can produced faster, more efficient code, but can also increase the size
5110of the program. The two values are potentially incompatible. Code
5111compiled with one value cannot necessarily expect to work with code or
5112libraries compiled with the other value, if they exchange information
5113using structures or unions. Programmers are encouraged to use the 32
5114value as future versions of the toolchain may default to this value.
5115
62b10bbc
NC
5116@item -mnop-fun-dllimport
5117@kindex -mnop-fun-dllimport
5118Disable the support for the @emph{dllimport} attribute.
5119
5120@item -mcallee-super-interworking
5121@kindex -mcallee-super-interworking
5122Gives all externally visible functions in the file being compiled an ARM
5123instruction set header which switches to Thumb mode before executing the
5124rest of the function. This allows these functions to be called from
5125non-interworking code.
5126
5127@item -mcaller-super-interworking
5128@kindex -mcaller-super-interworking
5129Allows calls via function pointers (including virtual functions) to
5130execute correctly regardless of whether the target code has been
5131compiled for interworking or not. There is a small overhead in the cost
4bdc1ac7
PB
5132of executing a function pointer if this option is enabled.
5133
5134@item -msingle-pic-base
5135@kindex -msingle-pic-base
5136Treat the register used for PIC addressing as read-only, rather than
5137loading it in the prologue for each function. The run-time system is
5138responsible for initialising this register with an appropriate value
5139before execution begins.
5140
5141@item -mpic-register=<reg>
5142@kindex -mpic-register=
5143Specify the register to be used for PIC addressing. The default is R10.
62b10bbc 5144
157a620e
NC
5145@end table
5146
ecff22ab
JL
5147@node MN10200 Options
5148@subsection MN10200 Options
5149@cindex MN10200 options
5150These @samp{-m} options are defined for Matsushita MN10200 architectures:
5151@table @code
5152
5153@item -mrelax
5154Indicate to the linker that it should perform a relaxation optimization pass
5155to shorten branches, calls and absolute memory addresses. This option only
5156has an effect when used on the command line for the final link step.
5157
5158This option makes symbolic debugging impossible.
5159@end table
157a620e 5160
6d6d0fa0
JL
5161@node MN10300 Options
5162@subsection MN10300 Options
5163@cindex MN10300 options
5164These @samp{-m} options are defined for Matsushita MN10300 architectures:
5165
5166@table @code
5167@item -mmult-bug
5168Generate code to avoid bugs in the multiply instructions for the MN10300
5169processors. This is the default.
5170
5171@item -mno-mult-bug
5172Do not generate code to avoid bugs in the multiply instructions for the
5173MN10300 processors.
ecff22ab 5174
705ac34f
JL
5175@item -mam33
5176Generate code which uses features specific to the AM33 processor.
5177
5178@item -mno-am33
5179Do not generate code which uses features specific to the AM33 processor. This
5180is the default.
5181
ecff22ab
JL
5182@item -mrelax
5183Indicate to the linker that it should perform a relaxation optimization pass
5184to shorten branches, calls and absolute memory addresses. This option only
5185has an effect when used on the command line for the final link step.
5186
5187This option makes symbolic debugging impossible.
6d6d0fa0
JL
5188@end table
5189
ecff22ab 5190
861bb6c1
JL
5191@node M32R/D Options
5192@subsection M32R/D Options
5193@cindex M32R/D options
5194
5195These @samp{-m} options are defined for Mitsubishi M32R/D architectures:
5196
5197@table @code
5198@item -mcode-model=small
5199Assume all objects live in the lower 16MB of memory (so that their addresses
5200can be loaded with the @code{ld24} instruction), and assume all subroutines
5201are reachable with the @code{bl} instruction.
5202This is the default.
5203
5204The addressability of a particular object can be set with the
5205@code{model} attribute.
5206
5207@item -mcode-model=medium
5208Assume objects may be anywhere in the 32 bit address space (the compiler
5209will generate @code{seth/add3} instructions to load their addresses), and
5210assume all subroutines are reachable with the @code{bl} instruction.
5211
5212@item -mcode-model=large
5213Assume objects may be anywhere in the 32 bit address space (the compiler
5214will generate @code{seth/add3} instructions to load their addresses), and
5215assume subroutines may not be reachable with the @code{bl} instruction
5216(the compiler will generate the much slower @code{seth/add3/jl}
5217instruction sequence).
5218
5219@item -msdata=none
5220Disable use of the small data area. Variables will be put into
5221one of @samp{.data}, @samp{bss}, or @samp{.rodata} (unless the
5222@code{section} attribute has been specified).
5223This is the default.
5224
5225The small data area consists of sections @samp{.sdata} and @samp{.sbss}.
5226Objects may be explicitly put in the small data area with the
5227@code{section} attribute using one of these sections.
5228
5229@item -msdata=sdata
5230Put small global and static data in the small data area, but do not
5231generate special code to reference them.
5232
5233@item -msdata=use
5234Put small global and static data in the small data area, and generate
5235special instructions to reference them.
5236
5237@item -G @var{num}
5238@cindex smaller data references
5239Put global and static objects less than or equal to @var{num} bytes
5240into the small data or bss sections instead of the normal data or bss
5241sections. The default value of @var{num} is 8.
5242The @samp{-msdata} option must be set to one of @samp{sdata} or @samp{use}
5243for this option to have any effect.
5244
5245All modules should be compiled with the same @samp{-G @var{num}} value.
5246Compiling with different values of @var{num} may or may not work; if it
5247doesn't the linker will give an error message - incorrect code will not be
5248generated.
5249
5250@end table
5251
74291a4b
MM
5252@node M88K Options
5253@subsection M88K Options
5254@cindex M88k options
5255
5256These @samp{-m} options are defined for Motorola 88k architectures:
5257
5258@table @code
5259@item -m88000
5260@kindex -m88000
5261Generate code that works well on both the m88100 and the
5262m88110.
5263
5264@item -m88100
5265@kindex -m88100
5266Generate code that works best for the m88100, but that also
5267runs on the m88110.
5268
5269@item -m88110
5270@kindex -m88110
5271Generate code that works best for the m88110, and may not run
5272on the m88100.
5273
5274@item -mbig-pic
5275@kindex -mbig-pic
5276Obsolete option to be removed from the next revision.
5277Use @samp{-fPIC}.
5278
5279@item -midentify-revision
5280@kindex -midentify-revision
5281@kindex ident
5282@cindex identifying source, compiler (88k)
5283Include an @code{ident} directive in the assembler output recording the
5284source file name, compiler name and version, timestamp, and compilation
5285flags used.
5286
5287@item -mno-underscores
5288@kindex -mno-underscores
5289@cindex underscores, avoiding (88k)
5290In assembler output, emit symbol names without adding an underscore
5291character at the beginning of each name. The default is to use an
5292underscore as prefix on each name.
5293
5294@item -mocs-debug-info
5295@itemx -mno-ocs-debug-info
5296@kindex -mocs-debug-info
5297@kindex -mno-ocs-debug-info
5298@cindex OCS (88k)
5299@cindex debugging, 88k OCS
5300Include (or omit) additional debugging information (about registers used
5301in each stack frame) as specified in the 88open Object Compatibility
5302Standard, ``OCS''. This extra information allows debugging of code that
5303has had the frame pointer eliminated. The default for DG/UX, SVr4, and
5304Delta 88 SVr3.2 is to include this information; other 88k configurations
5305omit this information by default.
5306
5307@item -mocs-frame-position
5308@kindex -mocs-frame-position
5309@cindex register positions in frame (88k)
5310When emitting COFF debugging information for automatic variables and
5311parameters stored on the stack, use the offset from the canonical frame
5312address, which is the stack pointer (register 31) on entry to the
5313function. The DG/UX, SVr4, Delta88 SVr3.2, and BCS configurations use
5314@samp{-mocs-frame-position}; other 88k configurations have the default
5315@samp{-mno-ocs-frame-position}.
5316
5317@item -mno-ocs-frame-position
5318@kindex -mno-ocs-frame-position
5319@cindex register positions in frame (88k)
5320When emitting COFF debugging information for automatic variables and
5321parameters stored on the stack, use the offset from the frame pointer
5322register (register 30). When this option is in effect, the frame
5323pointer is not eliminated when debugging information is selected by the
5324-g switch.
5325
5326@item -moptimize-arg-area
5327@itemx -mno-optimize-arg-area
5328@kindex -moptimize-arg-area
5329@kindex -mno-optimize-arg-area
5330@cindex arguments in frame (88k)
5331Control how function arguments are stored in stack frames.
5332@samp{-moptimize-arg-area} saves space by optimizing them, but this
5333conflicts with the 88open specifications. The opposite alternative,
5334@samp{-mno-optimize-arg-area}, agrees with 88open standards. By default
0c2d1a2a 5335GCC does not optimize the argument area.
74291a4b
MM
5336
5337@item -mshort-data-@var{num}
5338@kindex -mshort-data-@var{num}
5339@cindex smaller data references (88k)
5340@cindex r0-relative references (88k)
5341Generate smaller data references by making them relative to @code{r0},
5342which allows loading a value using a single instruction (rather than the
5343usual two). You control which data references are affected by
5344specifying @var{num} with this option. For example, if you specify
5345@samp{-mshort-data-512}, then the data references affected are those
5346involving displacements of less than 512 bytes.
5347@samp{-mshort-data-@var{num}} is not effective for @var{num} greater
5348than 64k.
5349
5350@item -mserialize-volatile
5351@kindex -mserialize-volatile
5352@itemx -mno-serialize-volatile
5353@kindex -mno-serialize-volatile
5354@cindex sequential consistency on 88k
5355Do, or don't, generate code to guarantee sequential consistency
5356of volatile memory references. By default, consistency is
5357guaranteed.
5358
5359The order of memory references made by the MC88110 processor does
5360not always match the order of the instructions requesting those
5361references. In particular, a load instruction may execute before
5362a preceding store instruction. Such reordering violates
5363sequential consistency of volatile memory references, when there
5364are multiple processors. When consistency must be guaranteed,
5365GNU C generates special instructions, as needed, to force
5366execution in the proper order.
5367
5368The MC88100 processor does not reorder memory references and so
5369always provides sequential consistency. However, by default, GNU
5370C generates the special instructions to guarantee consistency
5371even when you use @samp{-m88100}, so that the code may be run on an
5372MC88110 processor. If you intend to run your code only on the
5373MC88100 processor, you may use @samp{-mno-serialize-volatile}.
5374
5375The extra code generated to guarantee consistency may affect the
5376performance of your application. If you know that you can safely
5377forgo this guarantee, you may use @samp{-mno-serialize-volatile}.
5378
5379@item -msvr4
5380@itemx -msvr3
5381@kindex -msvr4
5382@kindex -msvr3
5383@cindex assembler syntax, 88k
5384@cindex SVr4
5385Turn on (@samp{-msvr4}) or off (@samp{-msvr3}) compiler extensions
5386related to System V release 4 (SVr4). This controls the following:
5387
5388@enumerate
5389@item
5390Which variant of the assembler syntax to emit.
5391@item
5392@samp{-msvr4} makes the C preprocessor recognize @samp{#pragma weak}
5393that is used on System V release 4.
5394@item
0c2d1a2a 5395@samp{-msvr4} makes GCC issue additional declaration directives used in
74291a4b
MM
5396SVr4.
5397@end enumerate
5398
5399@samp{-msvr4} is the default for the m88k-motorola-sysv4 and
5400m88k-dg-dgux m88k configurations. @samp{-msvr3} is the default for all
5401other m88k configurations.
5402
5403@item -mversion-03.00
5404@kindex -mversion-03.00
5405This option is obsolete, and is ignored.
5406@c ??? which asm syntax better for GAS? option there too?
5407
5408@item -mno-check-zero-division
5409@itemx -mcheck-zero-division
5410@kindex -mno-check-zero-division
5411@kindex -mcheck-zero-division
5412@cindex zero division on 88k
5413Do, or don't, generate code to guarantee that integer division by
5414zero will be detected. By default, detection is guaranteed.
5415
5416Some models of the MC88100 processor fail to trap upon integer
5417division by zero under certain conditions. By default, when
5418compiling code that might be run on such a processor, GNU C
5419generates code that explicitly checks for zero-valued divisors
5420and traps with exception number 503 when one is detected. Use of
5421mno-check-zero-division suppresses such checking for code
5422generated to run on an MC88100 processor.
5423
5424GNU C assumes that the MC88110 processor correctly detects all
5425instances of integer division by zero. When @samp{-m88110} is
5426specified, both @samp{-mcheck-zero-division} and
5427@samp{-mno-check-zero-division} are ignored, and no explicit checks for
5428zero-valued divisors are generated.
5429
5430@item -muse-div-instruction
5431@kindex -muse-div-instruction
5432@cindex divide instruction, 88k
5433Use the div instruction for signed integer division on the
5434MC88100 processor. By default, the div instruction is not used.
5435
5436On the MC88100 processor the signed integer division instruction
5437div) traps to the operating system on a negative operand. The
5438operating system transparently completes the operation, but at a
5439large cost in execution time. By default, when compiling code
5440that might be run on an MC88100 processor, GNU C emulates signed
5441integer division using the unsigned integer division instruction
5442divu), thereby avoiding the large penalty of a trap to the
5443operating system. Such emulation has its own, smaller, execution
5444cost in both time and space. To the extent that your code's
5445important signed integer division operations are performed on two
5446nonnegative operands, it may be desirable to use the div
5447instruction directly.
5448
5449On the MC88110 processor the div instruction (also known as the
5450divs instruction) processes negative operands without trapping to
5451the operating system. When @samp{-m88110} is specified,
5452@samp{-muse-div-instruction} is ignored, and the div instruction is used
5453for signed integer division.
5454
5455Note that the result of dividing INT_MIN by -1 is undefined. In
5456particular, the behavior of such a division with and without
5457@samp{-muse-div-instruction} may differ.
5458
5459@item -mtrap-large-shift
5460@itemx -mhandle-large-shift
5461@kindex -mtrap-large-shift
5462@kindex -mhandle-large-shift
5463@cindex bit shift overflow (88k)
5464@cindex large bit shifts (88k)
5465Include code to detect bit-shifts of more than 31 bits; respectively,
0c2d1a2a 5466trap such shifts or emit code to handle them properly. By default GCC
74291a4b
MM
5467makes no special provision for large bit shifts.
5468
5469@item -mwarn-passed-structs
5470@kindex -mwarn-passed-structs
5471@cindex structure passing (88k)
5472Warn when a function passes a struct as an argument or result.
5473Structure-passing conventions have changed during the evolution of the C
5474language, and are often the source of portability problems. By default,
0c2d1a2a 5475GCC issues no such warning.
74291a4b
MM
5476@end table
5477
5478@node RS/6000 and PowerPC Options
5479@subsection IBM RS/6000 and PowerPC Options
5480@cindex RS/6000 and PowerPC Options
5481@cindex IBM RS/6000 and PowerPC Options
5482
5483These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
5484@table @code
5485@item -mpower
5486@itemx -mno-power
5487@itemx -mpower2
5488@itemx -mno-power2
5489@itemx -mpowerpc
5490@itemx -mno-powerpc
5491@itemx -mpowerpc-gpopt
5492@itemx -mno-powerpc-gpopt
5493@itemx -mpowerpc-gfxopt
5494@itemx -mno-powerpc-gfxopt
7fe90e7b
DE
5495@itemx -mpowerpc64
5496@itemx -mno-powerpc64
74291a4b
MM
5497@kindex -mpower
5498@kindex -mpower2
5499@kindex -mpowerpc
5500@kindex -mpowerpc-gpopt
5501@kindex -mpowerpc-gfxopt
7fe90e7b 5502@kindex -mpowerpc64
0c2d1a2a 5503GCC supports two related instruction set architectures for the
74291a4b
MM
5504RS/6000 and PowerPC. The @dfn{POWER} instruction set are those
5505instructions supported by the @samp{rios} chip set used in the original
5506RS/6000 systems and the @dfn{PowerPC} instruction set is the
5507architecture of the Motorola MPC5xx, MPC6xx, MPC8xx microprocessors, and
861bb6c1 5508the IBM 4xx microprocessors.
74291a4b
MM
5509
5510Neither architecture is a subset of the other. However there is a
5511large common subset of instructions supported by both. An MQ
5512register is included in processors supporting the POWER architecture.
5513
5514You use these options to specify which instructions are available on the
5515processor you are using. The default value of these options is
0c2d1a2a 5516determined when configuring GCC. Specifying the
74291a4b
MM
5517@samp{-mcpu=@var{cpu_type}} overrides the specification of these
5518options. We recommend you use the @samp{-mcpu=@var{cpu_type}} option
5519rather than the options listed above.
5520
0c2d1a2a 5521The @samp{-mpower} option allows GCC to generate instructions that
74291a4b 5522are found only in the POWER architecture and to use the MQ register.
0c2d1a2a 5523Specifying @samp{-mpower2} implies @samp{-power} and also allows GCC
74291a4b
MM
5524to generate instructions that are present in the POWER2 architecture but
5525not the original POWER architecture.
5526
0c2d1a2a 5527The @samp{-mpowerpc} option allows GCC to generate instructions that
74291a4b
MM
5528are found only in the 32-bit subset of the PowerPC architecture.
5529Specifying @samp{-mpowerpc-gpopt} implies @samp{-mpowerpc} and also allows
0c2d1a2a 5530GCC to use the optional PowerPC architecture instructions in the
74291a4b 5531General Purpose group, including floating-point square root. Specifying
0c2d1a2a 5532@samp{-mpowerpc-gfxopt} implies @samp{-mpowerpc} and also allows GCC to
74291a4b
MM
5533use the optional PowerPC architecture instructions in the Graphics
5534group, including floating-point select.
5535
0c2d1a2a 5536The @samp{-mpowerpc64} option allows GCC to generate the additional
7fe90e7b 553764-bit instructions that are found in the full PowerPC64 architecture
0c2d1a2a 5538and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
7fe90e7b
DE
5539@samp{-mno-powerpc64}.
5540
0c2d1a2a 5541If you specify both @samp{-mno-power} and @samp{-mno-powerpc}, GCC
74291a4b
MM
5542will use only the instructions in the common subset of both
5543architectures plus some special AIX common-mode calls, and will not use
5544the MQ register. Specifying both @samp{-mpower} and @samp{-mpowerpc}
0c2d1a2a 5545permits GCC to use any instruction from either architecture and to
74291a4b
MM
5546allow use of the MQ register; specify this for the Motorola MPC601.
5547
5548@item -mnew-mnemonics
5549@itemx -mold-mnemonics
5550@kindex -mnew-mnemonics
5551@kindex -mold-mnemonics
5552Select which mnemonics to use in the generated assembler code.
5553@samp{-mnew-mnemonics} requests output that uses the assembler mnemonics
5554defined for the PowerPC architecture, while @samp{-mold-mnemonics}
5555requests the assembler mnemonics defined for the POWER architecture.
5556Instructions defined in only one architecture have only one mnemonic;
0c2d1a2a 5557GCC uses that mnemonic irrespective of which of these options is
74291a4b
MM
5558specified.
5559
0c2d1a2a 5560GCC defaults to the mnemonics appropriate for the architecture in
7fe90e7b
DE
5561use. Specifying @samp{-mcpu=@var{cpu_type}} sometimes overrides the
5562value of these option. Unless you are building a cross-compiler, you
5563should normally not specify either @samp{-mnew-mnemonics} or
74291a4b
MM
5564@samp{-mold-mnemonics}, but should instead accept the default.
5565
5566@item -mcpu=@var{cpu_type}
7fe90e7b 5567@kindex -mcpu
74291a4b
MM
5568Set architecture type, register usage, choice of mnemonics, and
5569instruction scheduling parameters for machine type @var{cpu_type}.
5f59ecb7
DE
5570Supported values for @var{cpu_type} are @samp{rios}, @samp{rios1},
5571@samp{rsc}, @samp{rios2}, @samp{rs64a}, @samp{601}, @samp{602},
5572@samp{603}, @samp{603e}, @samp{604}, @samp{604e}, @samp{620},
5573@samp{630}, @samp{740}, @samp{750}, @samp{power}, @samp{power2},
5574@samp{powerpc}, @samp{403}, @samp{505}, @samp{801}, @samp{821},
5575@samp{823}, and @samp{860} and @samp{common}. @samp{-mcpu=power},
5576@samp{-mcpu=power2}, @samp{-mcpu=powerpc}, and @samp{-mcpu=powerpc64}
5577specify generic POWER, POWER2, pure 32-bit PowerPC (i.e., not MPC601),
5578and 64-bit PowerPC architecture machine types, with an appropriate,
bef84347 5579generic processor model assumed for scheduling purposes.@refill
74291a4b 5580
74291a4b
MM
5581Specifying any of the following options:
5582@samp{-mcpu=rios1}, @samp{-mcpu=rios2}, @samp{-mcpu=rsc},
5583@samp{-mcpu=power}, or @samp{-mcpu=power2}
5584enables the @samp{-mpower} option and disables the @samp{-mpowerpc} option;
5585@samp{-mcpu=601} enables both the @samp{-mpower} and @samp{-mpowerpc} options.
5f59ecb7
DE
5586All of @samp{-mcpu=rs64a}, @samp{-mcpu=602}, @samp{-mcpu=603},
5587@samp{-mcpu=603e}, @samp{-mcpu=604}, @samp{-mcpu=620}, @samp{-mcpu=630},
5588@samp{-mcpu=740}, and @samp{-mcpu=750}
74291a4b
MM
5589enable the @samp{-mpowerpc} option and disable the @samp{-mpower} option.
5590Exactly similarly, all of @samp{-mcpu=403},
5591@samp{-mcpu=505}, @samp{-mcpu=821}, @samp{-mcpu=860} and @samp{-mcpu=powerpc}
5592enable the @samp{-mpowerpc} option and disable the @samp{-mpower} option.
5593@samp{-mcpu=common} disables both the
5594@samp{-mpower} and @samp{-mpowerpc} options.@refill
74291a4b
MM
5595
5596AIX versions 4 or greater selects @samp{-mcpu=common} by default, so
5f59ecb7 5597that code will operate on all members of the RS/6000 POWER and PowerPC
0c2d1a2a 5598families. In that case, GCC will use only the instructions in the
74291a4b 5599common subset of both architectures plus some special AIX common-mode
0c2d1a2a 5600calls, and will not use the MQ register. GCC assumes a generic
74291a4b
MM
5601processor model for scheduling purposes.
5602
5603Specifying any of the options @samp{-mcpu=rios1}, @samp{-mcpu=rios2},
5604@samp{-mcpu=rsc}, @samp{-mcpu=power}, or @samp{-mcpu=power2} also
5605disables the @samp{new-mnemonics} option. Specifying @samp{-mcpu=601},
5606@samp{-mcpu=602}, @samp{-mcpu=603}, @samp{-mcpu=603e}, @samp{-mcpu=604},
5f59ecb7
DE
5607@samp{-mcpu=620}, @samp{-mcpu=630}, @samp{-mcpu=403}, @samp{-mcpu=505},
5608@samp{-mcpu=821}, @samp{-mcpu=860} or @samp{-mcpu=powerpc} also enables
5609the @samp{new-mnemonics} option.@refill
74291a4b
MM
5610
5611Specifying @samp{-mcpu=403}, @samp{-mcpu=821}, or @samp{-mcpu=860} also
5612enables the @samp{-msoft-float} option.
5613
5614@item -mtune=@var{cpu_type}
5615Set the instruction scheduling parameters for machine type
5616@var{cpu_type}, but do not set the architecture type, register usage,
5617choice of mnemonics like @samp{-mcpu=}@var{cpu_type} would. The same
5618values for @var{cpu_type} are used for @samp{-mtune=}@var{cpu_type} as
5619for @samp{-mcpu=}@var{cpu_type}. The @samp{-mtune=}@var{cpu_type}
5620option overrides the @samp{-mcpu=}@var{cpu_type} option in terms of
5621instruction scheduling parameters.
5622
5623@item -mfull-toc
5624@itemx -mno-fp-in-toc
5625@itemx -mno-sum-in-toc
5626@itemx -mminimal-toc
7fe90e7b 5627@kindex -mminimal-toc
74291a4b
MM
5628Modify generation of the TOC (Table Of Contents), which is created for
5629every executable file. The @samp{-mfull-toc} option is selected by
0c2d1a2a
JB
5630default. In that case, GCC will allocate at least one TOC entry for
5631each unique non-automatic variable reference in your program. GCC
74291a4b
MM
5632will also place floating-point constants in the TOC. However, only
563316,384 entries are available in the TOC.
5634
5635If you receive a linker error message that saying you have overflowed
5636the available TOC space, you can reduce the amount of TOC space used
5637with the @samp{-mno-fp-in-toc} and @samp{-mno-sum-in-toc} options.
0c2d1a2a
JB
5638@samp{-mno-fp-in-toc} prevents GCC from putting floating-point
5639constants in the TOC and @samp{-mno-sum-in-toc} forces GCC to
74291a4b
MM
5640generate code to calculate the sum of an address and a constant at
5641run-time instead of putting that sum into the TOC. You may specify one
0c2d1a2a 5642or both of these options. Each causes GCC to produce very slightly
74291a4b
MM
5643slower and larger code at the expense of conserving TOC space.
5644
5645If you still run out of space in the TOC even when you specify both of
5646these options, specify @samp{-mminimal-toc} instead. This option causes
0c2d1a2a
JB
5647GCC to make only one TOC entry for every file. When you specify this
5648option, GCC will produce code that is slower and larger but which
74291a4b
MM
5649uses extremely little TOC space. You may wish to use this option
5650only on files that contain less frequently executed code. @refill
5651
fa06229f
GK
5652@item -maix64
5653@itemx -maix32
5654@kindex -maix64
5655@kindex -maix32
5656Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
7fe90e7b 5657@code{long} type, and the infrastructure needed to support them.
fa06229f
GK
5658Specifying @samp{-maix64} implies @samp{-mpowerpc64} and
5659@samp{-mpowerpc}, while @samp{-maix32} disables the 64-bit ABI and
5660implies @samp{-mno-powerpc64}. GCC defaults to @samp{-maix32}.
7fe90e7b 5661
74291a4b
MM
5662@item -mxl-call
5663@itemx -mno-xl-call
7fe90e7b 5664@kindex -mxl-call
74291a4b
MM
5665On AIX, pass floating-point arguments to prototyped functions beyond the
5666register save area (RSA) on the stack in addition to argument FPRs. The
5667AIX calling convention was extended but not initially documented to
5668handle an obscure K&R C case of calling a function that takes the
5669address of its arguments with fewer arguments than declared. AIX XL
7fe90e7b
DE
5670compilers access floating point arguments which do not fit in the
5671RSA from the stack when a subroutine is compiled without
74291a4b
MM
5672optimization. Because always storing floating-point arguments on the
5673stack is inefficient and rarely needed, this option is not enabled by
5674default and only is necessary when calling subroutines compiled by AIX
5675XL compilers without optimization.
5676
861bb6c1 5677@item -mthreads
7fe90e7b 5678@kindex -mthreads
861bb6c1
JL
5679Support @dfn{AIX Threads}. Link an application written to use
5680@dfn{pthreads} with special libraries and startup code to enable the
5681application to run.
5682
5683@item -mpe
7fe90e7b 5684@kindex -mpe
861bb6c1
JL
5685Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE). Link an
5686application written to use message passing with special startup code to
5687enable the application to run. The system must have PE installed in the
5688standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
5689must be overridden with the @samp{-specs=} option to specify the
5690appropriate directory location. The Parallel Environment does not
5691support threads, so the @samp{-mpe} option and the @samp{-mthreads}
5692option are incompatible.
5693
74291a4b
MM
5694@item -msoft-float
5695@itemx -mhard-float
7fe90e7b 5696@kindex -msoft-float
74291a4b
MM
5697Generate code that does not use (uses) the floating-point register set.
5698Software floating point emulation is provided if you use the
0c2d1a2a 5699@samp{-msoft-float} option, and pass the option to GCC when linking.
74291a4b
MM
5700
5701@item -mmultiple
5702@itemx -mno-multiple
5703Generate code that uses (does not use) the load multiple word
5704instructions and the store multiple word instructions. These
5705instructions are generated by default on POWER systems, and not
5706generated on PowerPC systems. Do not use @samp{-mmultiple} on little
5707endian PowerPC systems, since those instructions do not work when the
bef84347
VM
5708processor is in little endian mode. The exceptions are PPC740 and
5709PPC750 which permit the instructions usage in little endian mode.
74291a4b
MM
5710
5711@item -mstring
5712@itemx -mno-string
7fe90e7b 5713@kindex -mstring
bef84347
VM
5714Generate code that uses (does not use) the load string instructions
5715and the store string word instructions to save multiple registers and
5716do small block moves. These instructions are generated by default on
5717POWER systems, and not generated on PowerPC systems. Do not use
5718@samp{-mstring} on little endian PowerPC systems, since those
5719instructions do not work when the processor is in little endian mode.
5720The exceptions are PPC740 and PPC750 which permit the instructions
5721usage in little endian mode.
74291a4b 5722
861bb6c1
JL
5723@item -mupdate
5724@itemx -mno-update
7fe90e7b 5725@kindex -mupdate
861bb6c1
JL
5726Generate code that uses (does not use) the load or store instructions
5727that update the base register to the address of the calculated memory
5728location. These instructions are generated by default. If you use
5729@samp{-mno-update}, there is a small window between the time that the
5730stack pointer is updated and the address of the previous frame is
5731stored, which means code that walks the stack frame across interrupts or
5732signals may get corrupted data.
5733
5734@item -mfused-madd
5735@itemx -mno-fused-madd
7fe90e7b 5736@kindex -mfused-madd
861bb6c1
JL
5737Generate code that uses (does not use) the floating point multiply and
5738accumulate instructions. These instructions are generated by default if
5739hardware floating is used.
5740
74291a4b
MM
5741@item -mno-bit-align
5742@itemx -mbit-align
7fe90e7b 5743@kindex -mbit-align
74291a4b
MM
5744On System V.4 and embedded PowerPC systems do not (do) force structures
5745and unions that contain bit fields to be aligned to the base type of the
5746bit field.
5747
5748For example, by default a structure containing nothing but 8
5749@code{unsigned} bitfields of length 1 would be aligned to a 4 byte
5750boundary and have a size of 4 bytes. By using @samp{-mno-bit-align},
5751the structure would be aligned to a 1 byte boundary and be one byte in
5752size.
5753
5754@item -mno-strict-align
5755@itemx -mstrict-align
7fe90e7b 5756@kindex -mstrict-align
74291a4b
MM
5757On System V.4 and embedded PowerPC systems do not (do) assume that
5758unaligned memory references will be handled by the system.
5759
5760@item -mrelocatable
5761@itemx -mno-relocatable
7fe90e7b 5762@kindex -mrelocatable
74291a4b
MM
5763On embedded PowerPC systems generate code that allows (does not allow)
5764the program to be relocated to a different address at runtime. If you
5765use @samp{-mrelocatable} on any module, all objects linked together must
5766be compiled with @samp{-mrelocatable} or @samp{-mrelocatable-lib}.
5767
5768@item -mrelocatable-lib
5769@itemx -mno-relocatable-lib
5770On embedded PowerPC systems generate code that allows (does not allow)
5771the program to be relocated to a different address at runtime. Modules
956d6950 5772compiled with @samp{-mrelocatable-lib} can be linked with either modules
74291a4b
MM
5773compiled without @samp{-mrelocatable} and @samp{-mrelocatable-lib} or
5774with modules compiled with the @samp{-mrelocatable} options.
5775
5776@item -mno-toc
5777@itemx -mtoc
5778On System V.4 and embedded PowerPC systems do not (do) assume that
5779register 2 contains a pointer to a global area pointing to the addresses
5780used in the program.
5781
74291a4b
MM
5782@item -mlittle
5783@itemx -mlittle-endian
5784On System V.4 and embedded PowerPC systems compile code for the
5785processor in little endian mode. The @samp{-mlittle-endian} option is
5786the same as @samp{-mlittle}.
5787
5788@item -mbig
5789@itemx -mbig-endian
5790On System V.4 and embedded PowerPC systems compile code for the
5791processor in big endian mode. The @samp{-mbig-endian} option is
5792the same as @samp{-mbig}.
5793
5794@item -mcall-sysv
5795On System V.4 and embedded PowerPC systems compile code using calling
5796conventions that adheres to the March 1995 draft of the System V
5797Application Binary Interface, PowerPC processor supplement. This is the
5798default unless you configured GCC using @samp{powerpc-*-eabiaix}.
5799
5800@item -mcall-sysv-eabi
5801Specify both @samp{-mcall-sysv} and @samp{-meabi} options.
5802
5803@item -mcall-sysv-noeabi
5804Specify both @samp{-mcall-sysv} and @samp{-mno-eabi} options.
5805
5806@item -mcall-aix
5807On System V.4 and embedded PowerPC systems compile code using calling
5808conventions that are similar to those used on AIX. This is the
5809default if you configured GCC using @samp{powerpc-*-eabiaix}.
5810
5811@item -mcall-solaris
5812On System V.4 and embedded PowerPC systems compile code for the Solaris
5813operating system.
5814
5815@item -mcall-linux
861bb6c1
JL
5816On System V.4 and embedded PowerPC systems compile code for the
5817Linux-based GNU system.
74291a4b
MM
5818
5819@item -mprototype
e9a25f70 5820@itemx -mno-prototype
74291a4b
MM
5821On System V.4 and embedded PowerPC systems assume that all calls to
5822variable argument functions are properly prototyped. Otherwise, the
5823compiler must insert an instruction before every non prototyped call to
5824set or clear bit 6 of the condition code register (@var{CR}) to
5825indicate whether floating point values were passed in the floating point
5826registers in case the function takes a variable arguments. With
5827@samp{-mprototype}, only calls to prototyped variable argument functions
5828will set or clear the bit.
5829
5830@item -msim
5831On embedded PowerPC systems, assume that the startup module is called
5832@file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
5833@file{libc.a}. This is the default for @samp{powerpc-*-eabisim}.
5834configurations.
5835
5836@item -mmvme
5837On embedded PowerPC systems, assume that the startup module is called
e9a25f70
JL
5838@file{crt0.o} and the standard C libraries are @file{libmvme.a} and
5839@file{libc.a}.
5840
5841@item -mads
5842On embedded PowerPC systems, assume that the startup module is called
5843@file{crt0.o} and the standard C libraries are @file{libads.a} and
5844@file{libc.a}.
5845
5846@item -myellowknife
5847On embedded PowerPC systems, assume that the startup module is called
5848@file{crt0.o} and the standard C libraries are @file{libyk.a} and
74291a4b
MM
5849@file{libc.a}.
5850
bff46771
GK
5851@item -mvxworks
5852On System V.4 and embedded PowerPC systems, specify that you are
5853compiling for a VxWorks system.
5854
74291a4b
MM
5855@item -memb
5856On embedded PowerPC systems, set the @var{PPC_EMB} bit in the ELF flags
5857header to indicate that @samp{eabi} extended relocations are used.
5858
5859@item -meabi
5860@itemx -mno-eabi
5861On System V.4 and embedded PowerPC systems do (do not) adhere to the
5862Embedded Applications Binary Interface (eabi) which is a set of
5863modifications to the System V.4 specifications. Selecting @code{-meabi}
5864means that the stack is aligned to an 8 byte boundary, a function
5865@code{__eabi} is called to from @code{main} to set up the eabi
5866environment, and the @samp{-msdata} option can use both @code{r2} and
5867@code{r13} to point to two separate small data areas. Selecting
5868@code{-mno-eabi} means that the stack is aligned to a 16 byte boundary,
5869do not call an initialization function from @code{main}, and the
5870@samp{-msdata} option will only use @code{r13} to point to a single
5871small data area. The @samp{-meabi} option is on by default if you
5872configured GCC using one of the @samp{powerpc*-*-eabi*} options.
5873
5874@item -msdata=eabi
5875On System V.4 and embedded PowerPC systems, put small initialized
5876@code{const} global and static data in the @samp{.sdata2} section, which
5877is pointed to by register @code{r2}. Put small initialized
5878non-@code{const} global and static data in the @samp{.sdata} section,
5879which is pointed to by register @code{r13}. Put small uninitialized
5880global and static data in the @samp{.sbss} section, which is adjacent to
5881the @samp{.sdata} section. The @samp{-msdata=eabi} option is
5882incompatible with the @samp{-mrelocatable} option. The
5883@samp{-msdata=eabi} option also sets the @samp{-memb} option.
5884
5885@item -msdata=sysv
5886On System V.4 and embedded PowerPC systems, put small global and static
5887data in the @samp{.sdata} section, which is pointed to by register
5888@code{r13}. Put small uninitialized global and static data in the
5889@samp{.sbss} section, which is adjacent to the @samp{.sdata} section.
5890The @samp{-msdata=sysv} option is incompatible with the
5891@samp{-mrelocatable} option.
5892
5893@item -msdata=default
5894@itemx -msdata
5895On System V.4 and embedded PowerPC systems, if @samp{-meabi} is used,
5896compile code the same as @samp{-msdata=eabi}, otherwise compile code the
5897same as @samp{-msdata=sysv}.
5898
5899@item -msdata-data
5900On System V.4 and embedded PowerPC systems, put small global and static
5901data in the @samp{.sdata} section. Put small uninitialized global and
5902static data in the @samp{.sbss} section. Do not use register @code{r13}
5903to address small data however. This is the default behavior unless
5904other @samp{-msdata} options are used.
5905
5906@item -msdata=none
5907@itemx -mno-sdata
5908On embedded PowerPC systems, put all initialized global and static data
5909in the @samp{.data} section, and all uninitialized data in the
5910@samp{.bss} section.
5911
5912@item -G @var{num}
5913@cindex smaller data references (PowerPC)
5914@cindex .sdata/.sdata2 references (PowerPC)
956d6950 5915On embedded PowerPC systems, put global and static items less than or
74291a4b
MM
5916equal to @var{num} bytes into the small data or bss sections instead of
5917the normal data or bss section. By default, @var{num} is 8. The
5918@samp{-G @var{num}} switch is also passed to the linker.
5919All modules should be compiled with the same @samp{-G @var{num}} value.
5920
5921@item -mregnames
5922@itemx -mno-regnames
5923On System V.4 and embedded PowerPC systems do (do not) emit register
5924names in the assembly language output using symbolic forms.
f5a1b0d2 5925
74291a4b 5926@end table
f5a1b0d2 5927
74291a4b
MM
5928@node RT Options
5929@subsection IBM RT Options
5930@cindex RT options
5931@cindex IBM RT options
5932
5933These @samp{-m} options are defined for the IBM RT PC:
5934
5935@table @code
5936@item -min-line-mul
5937Use an in-line code sequence for integer multiplies. This is the
5938default.
5939
5940@item -mcall-lib-mul
5941Call @code{lmul$$} for integer multiples.
5942
5943@item -mfull-fp-blocks
5944Generate full-size floating point data blocks, including the minimum
5945amount of scratch space recommended by IBM. This is the default.
5946
5947@item -mminimum-fp-blocks
5948Do not include extra scratch space in floating point data blocks. This
5949results in smaller code, but slower execution, since scratch space must
5950be allocated dynamically.
5951
5952@cindex @file{varargs.h} and RT PC
5953@cindex @file{stdarg.h} and RT PC
5954@item -mfp-arg-in-fpregs
5955Use a calling sequence incompatible with the IBM calling convention in
5956which floating point arguments are passed in floating point registers.
5957Note that @code{varargs.h} and @code{stdargs.h} will not work with
5958floating point operands if this option is specified.
5959
5960@item -mfp-arg-in-gregs
5961Use the normal calling convention for floating point arguments. This is
5962the default.
5963
5964@item -mhc-struct-return
5965Return structures of more than one word in memory, rather than in a
5966register. This provides compatibility with the MetaWare HighC (hc)
5967compiler. Use the option @samp{-fpcc-struct-return} for compatibility
5968with the Portable C Compiler (pcc).
5969
5970@item -mnohc-struct-return
5971Return some structures of more than one word in registers, when
5972convenient. This is the default. For compatibility with the
5973IBM-supplied compilers, use the option @samp{-fpcc-struct-return} or the
5974option @samp{-mhc-struct-return}.
5975@end table
5976
5977@node MIPS Options
5978@subsection MIPS Options
5979@cindex MIPS options
5980
5981These @samp{-m} options are defined for the MIPS family of computers:
5982
5983@table @code
5984@item -mcpu=@var{cpu type}
5985Assume the defaults for the machine type @var{cpu type} when scheduling
5986instructions. The choices for @var{cpu type} are @samp{r2000}, @samp{r3000},
8b9243df
JJ
5987@samp{r3900}, @samp{r4000}, @samp{r4100}, @samp{r4300}, @samp{r4400},
5988@samp{r4600}, @samp{r4650}, @samp{r5000}, @samp{r6000}, @samp{r8000},
5989and @samp{orion}. Additionally, the @samp{r2000}, @samp{r3000},
5990@samp{r4000}, @samp{r5000}, and @samp{r6000} can be abbreviated as
5991@samp{r2k} (or @samp{r2K}), @samp{r3k}, etc. While picking a specific
5992@var{cpu type} will schedule things appropriately for that particular
5993chip, the compiler will not generate any code that does not meet level 1
5994of the MIPS ISA (instruction set architecture) without a @samp{-mipsX}
5995or @samp{-mabi} switch being used.
74291a4b
MM
5996
5997@item -mips1
5998Issue instructions from level 1 of the MIPS ISA. This is the default.
5999@samp{r3000} is the default @var{cpu type} at this ISA level.
6000
6001@item -mips2
6002Issue instructions from level 2 of the MIPS ISA (branch likely, square
6003root instructions). @samp{r6000} is the default @var{cpu type} at this
6004ISA level.
6005
6006@item -mips3
6007Issue instructions from level 3 of the MIPS ISA (64 bit instructions).
6008@samp{r4000} is the default @var{cpu type} at this ISA level.
74291a4b 6009
3398f47f 6010@item -mips4
8b9243df
JJ
6011Issue instructions from level 4 of the MIPS ISA (conditional move,
6012prefetch, enhanced FPU instructions). @samp{r8000} is the default
6013@var{cpu type} at this ISA level.
3398f47f 6014
74291a4b
MM
6015@item -mfp32
6016Assume that 32 32-bit floating point registers are available. This is
6017the default.
6018
6019@item -mfp64
6020Assume that 32 64-bit floating point registers are available. This is
6021the default when the @samp{-mips3} option is used.
6022
6023@item -mgp32
6024Assume that 32 32-bit general purpose registers are available. This is
6025the default.
6026
6027@item -mgp64
6028Assume that 32 64-bit general purpose registers are available. This is
6029the default when the @samp{-mips3} option is used.
6030
6031@item -mint64
3ce1ba83
GRK
6032Force int and long types to be 64 bits wide. See @samp{-mlong32} for an
6033explanation of the default, and the width of pointers.
74291a4b
MM
6034
6035@item -mlong64
3ce1ba83
GRK
6036Force long types to be 64 bits wide. See @samp{-mlong32} for an
6037explanation of the default, and the width of pointers.
fb1bf66d 6038
3ce1ba83
GRK
6039@item -mlong32
6040Force long, int, and pointer types to be 32 bits wide.
6041
6042If none of @samp{-mlong32}, @samp{-mlong64}, or @samp{-mint64} are set,
b192711e 6043the size of ints, longs, and pointers depends on the ABI and ISA chosen.
3ce1ba83
GRK
6044For @samp{-mabi=32}, and @samp{-mabi=n32}, ints and longs are 32 bits
6045wide. For @samp{-mabi=64}, ints are 32 bits, and longs are 64 bits wide.
6046For @samp{-mabi=eabi} and either @samp{-mips1} or @samp{-mips2}, ints
6047and longs are 32 bits wide. For @samp{-mabi=eabi} and higher ISAs, ints
6048are 32 bits, and longs are 64 bits wide. The width of pointer types is
6049the smaller of the width of longs or the width of general purpose
6050registers (which in turn depends on the ISA).
74291a4b 6051
62a1403d 6052@item -mabi=32
8b9243df 6053@itemx -mabi=o64
3398f47f
MM
6054@itemx -mabi=n32
6055@itemx -mabi=64
6056@itemx -mabi=eabi
8b9243df
JJ
6057Generate code for the indicated ABI. The default instruction level is
6058@samp{-mips1} for @samp{32}, @samp{-mips3} for @samp{n32}, and
6059@samp{-mips4} otherwise. Conversely, with @samp{-mips1} or
6060@samp{-mips2}, the default ABI is @samp{32}; otherwise, the default ABI
6061is @samp{64}.
3398f47f 6062
74291a4b
MM
6063@item -mmips-as
6064Generate code for the MIPS assembler, and invoke @file{mips-tfile} to
6065add normal debug information. This is the default for all
6066platforms except for the OSF/1 reference platform, using the OSF/rose
6067object format. If the either of the @samp{-gstabs} or @samp{-gstabs+}
6068switches are used, the @file{mips-tfile} program will encapsulate the
6069stabs within MIPS ECOFF.
6070
6071@item -mgas
6072Generate code for the GNU assembler. This is the default on the OSF/1
861bb6c1
JL
6073reference platform, using the OSF/rose object format. Also, this is
6074the default if the configure option @samp{--with-gnu-as} is used.
6075
6076@item -msplit-addresses
6077@itemx -mno-split-addresses
6078Generate code to load the high and low parts of address constants separately.
6079This allows @code{gcc} to optimize away redundant loads of the high order
6080bits of addresses. This optimization requires GNU as and GNU ld.
6081This optimization is enabled by default for some embedded targets where
6082GNU as and GNU ld are standard.
74291a4b
MM
6083
6084@item -mrnames
6085@itemx -mno-rnames
6086The @samp{-mrnames} switch says to output code using the MIPS software
6087names for the registers, instead of the hardware names (ie, @var{a0}
6088instead of @var{$4}). The only known assembler that supports this option
6089is the Algorithmics assembler.
6090
6091@item -mgpopt
6092@itemx -mno-gpopt
6093The @samp{-mgpopt} switch says to write all of the data declarations
6094before the instructions in the text section, this allows the MIPS
6095assembler to generate one word memory references instead of using two
6096words for short global or static data items. This is on by default if
6097optimization is selected.
6098
6099@item -mstats
6100@itemx -mno-stats
6101For each non-inline function processed, the @samp{-mstats} switch
6102causes the compiler to emit one line to the standard error file to
6103print statistics about the program (number of registers saved, stack
6104size, etc.).
6105
6106@item -mmemcpy
6107@itemx -mno-memcpy
6108The @samp{-mmemcpy} switch makes all block moves call the appropriate
6109string function (@samp{memcpy} or @samp{bcopy}) instead of possibly
6110generating inline code.
6111
6112@item -mmips-tfile
6113@itemx -mno-mips-tfile
6114The @samp{-mno-mips-tfile} switch causes the compiler not
6115postprocess the object file with the @file{mips-tfile} program,
6116after the MIPS assembler has generated it to add debug support. If
6117@file{mips-tfile} is not run, then no local variables will be
6118available to the debugger. In addition, @file{stage2} and
6119@file{stage3} objects will have the temporary file names passed to the
6120assembler embedded in the object file, which means the objects will
6121not compare the same. The @samp{-mno-mips-tfile} switch should only
6122be used when there are bugs in the @file{mips-tfile} program that
6123prevents compilation.
6124
6125@item -msoft-float
6126Generate output containing library calls for floating point.
0c2d1a2a 6127@strong{Warning:} the requisite libraries are not part of GCC.
74291a4b
MM
6128Normally the facilities of the machine's usual C compiler are used, but
6129this can't be done directly in cross-compilation. You must make your
6130own arrangements to provide suitable library functions for
6131cross-compilation.
6132
6133@item -mhard-float
6134Generate output containing floating point instructions. This is the
6135default if you use the unmodified sources.
6136
6137@item -mabicalls
6138@itemx -mno-abicalls
6139Emit (or do not emit) the pseudo operations @samp{.abicalls},
6140@samp{.cpload}, and @samp{.cprestore} that some System V.4 ports use for
6141position independent code.
6142
6143@item -mlong-calls
6144@itemx -mno-long-calls
6145Do all calls with the @samp{JALR} instruction, which requires
6146loading up a function's address into a register before the call.
6147You need to use this switch, if you call outside of the current
6148512 megabyte segment to functions that are not through pointers.
6149
6150@item -mhalf-pic
6151@itemx -mno-half-pic
6152Put pointers to extern references into the data section and load them
6153up, rather than put the references in the text section.
6154
6155@item -membedded-pic
6156@itemx -mno-embedded-pic
69fa83cf
JW
6157Generate PIC code suitable for some embedded systems. All calls are
6158made using PC relative address, and all data is addressed using the $gp
6159register. No more than 65536 bytes of global data may be used. This
6160requires GNU as and GNU ld which do most of the work. This currently
6161only works on targets which use ECOFF; it does not work with ELF.
74291a4b
MM
6162
6163@item -membedded-data
6164@itemx -mno-embedded-data
6165Allocate variables to the read-only data section first if possible, then
6166next in the small data section if possible, otherwise in data. This gives
6167slightly slower code than the default, but reduces the amount of RAM required
6168when executing, and thus may be preferred for some embedded systems.
6169
919509ce
DN
6170@item -muninit-const-in-rodata
6171@itemx -mno-uninit-const-in-rodata
6172When used together with -membedded-data, it will always store uninitialized
6173const variables in the read-only data section.
6174
74291a4b
MM
6175@item -msingle-float
6176@itemx -mdouble-float
6177The @samp{-msingle-float} switch tells gcc to assume that the floating
6178point coprocessor only supports single precision operations, as on the
6179@samp{r4650} chip. The @samp{-mdouble-float} switch permits gcc to use
6180double precision operations. This is the default.
6181
6182@item -mmad
6183@itemx -mno-mad
6184Permit use of the @samp{mad}, @samp{madu} and @samp{mul} instructions,
6185as on the @samp{r4650} chip.
6186
6187@item -m4650
6188Turns on @samp{-msingle-float}, @samp{-mmad}, and, at least for now,
6189@samp{-mcpu=r4650}.
6190
8b9243df
JJ
6191@item -mips16
6192@itemx -mno-mips16
6193Enable 16-bit instructions.
6194
6195@item -mentry
6196Use the entry and exit pseudo ops. This option can only be used with
6197@samp{-mips16}.
6198
74291a4b
MM
6199@item -EL
6200Compile code for the processor in little endian mode.
6201The requisite libraries are assumed to exist.
6202
6203@item -EB
6204Compile code for the processor in big endian mode.
6205The requisite libraries are assumed to exist.
6206
6207@item -G @var{num}
6208@cindex smaller data references (MIPS)
6209@cindex gp-relative references (MIPS)
6210Put global and static items less than or equal to @var{num} bytes into
6211the small data or bss sections instead of the normal data or bss
6212section. This allows the assembler to emit one word memory reference
6213instructions based on the global pointer (@var{gp} or @var{$28}),
6214instead of the normal two words used. By default, @var{num} is 8 when
6215the MIPS assembler is used, and 0 when the GNU assembler is used. The
6216@samp{-G @var{num}} switch is also passed to the assembler and linker.
6217All modules should be compiled with the same @samp{-G @var{num}}
6218value.
6219
6220@item -nocpp
9ec36da5 6221Tell the MIPS assembler to not run its preprocessor over user
74291a4b 6222assembler files (with a @samp{.s} suffix) when assembling them.
63357d93 6223
1e387156
CM
6224@item -mfix7000
6225Pass an option to gas which will cause nops to be inserted if
6226the read of the destination register of an mfhi or mflo instruction
6227occurs in the following two instructions.
6228
63357d93
GRK
6229@item -no-crt0
6230Do not include the default crt0.
74291a4b
MM
6231@end table
6232
6233@ifset INTERNALS
6234These options are defined by the macro
6235@code{TARGET_SWITCHES} in the machine description. The default for the
6236options is also defined by that macro, which enables you to change the
6237defaults.
6238@end ifset
6239
6240@node i386 Options
6241@subsection Intel 386 Options
6242@cindex i386 Options
6243@cindex Intel 386 Options
6244
6245These @samp{-m} options are defined for the i386 family of computers:
6246
f45ebe47 6247@table @code
a9f3e1a4
JL
6248@item -mcpu=@var{cpu type}
6249Assume the defaults for the machine type @var{cpu type} when scheduling
9d86bffc
JM
6250instructions. The choices for @var{cpu type} are @samp{i386},
6251@samp{i486}, @samp{i586}, @samp{i686}, @samp{pentium},
6252@samp{pentiumpro}, @samp{k6}, and @samp{athlon}
6f670fde
RH
6253
6254While picking a specific @var{cpu type} will schedule things appropriately
6255for that particular chip, the compiler will not generate any code that
6256does not run on the i386 without the @samp{-march=@var{cpu type}} option
7001ee2d
CB
6257being used. @samp{i586} is equivalent to @samp{pentium} and @samp{i686}
6258is equivalent to @samp{pentiumpro}. @samp{k6} is the AMD chip as
6259opposed to the Intel ones.
a9f3e1a4
JL
6260
6261@item -march=@var{cpu type}
6262Generate instructions for the machine type @var{cpu type}. The choices
6f670fde
RH
6263for @var{cpu type} are the same as for @samp{-mcpu}. Moreover,
6264specifying @samp{-march=@var{cpu type}} implies @samp{-mcpu=@var{cpu type}}.
a9f3e1a4
JL
6265
6266@item -m386
6267@itemx -m486
6268@itemx -mpentium
6269@itemx -mpentiumpro
6270Synonyms for -mcpu=i386, -mcpu=i486, -mcpu=pentium, and -mcpu=pentiumpro
7001ee2d 6271respectively. These synonyms are deprecated.
74291a4b 6272
04e149ab
KC
6273@item -mintel-syntax
6274Emit assembly using Intel syntax opcodes instead of AT&T syntax.
6275
74291a4b
MM
6276@item -mieee-fp
6277@itemx -mno-ieee-fp
6278Control whether or not the compiler uses IEEE floating point
6279comparisons. These handle correctly the case where the result of a
6280comparison is unordered.
6281
6282@item -msoft-float
6283Generate output containing library calls for floating point.
0c2d1a2a 6284@strong{Warning:} the requisite libraries are not part of GCC.
74291a4b
MM
6285Normally the facilities of the machine's usual C compiler are used, but
6286this can't be done directly in cross-compilation. You must make your
6287own arrangements to provide suitable library functions for
6288cross-compilation.
6289
6290On machines where a function returns floating point results in the 80387
6291register stack, some floating point opcodes may be emitted even if
6292@samp{-msoft-float} is used.
6293
6294@item -mno-fp-ret-in-387
6295Do not use the FPU registers for return values of functions.
6296
6297The usual calling convention has functions return values of types
6298@code{float} and @code{double} in an FPU register, even if there
6299is no FPU. The idea is that the operating system should emulate
6300an FPU.
6301
6302The option @samp{-mno-fp-ret-in-387} causes such values to be returned
6303in ordinary CPU registers instead.
6304
6305@item -mno-fancy-math-387
6306Some 387 emulators do not support the @code{sin}, @code{cos} and
6307@code{sqrt} instructions for the 387. Specify this option to avoid
6308generating those instructions. This option is the default on FreeBSD.
6309As of revision 2.6.1, these instructions are not generated unless you
6310also use the @samp{-ffast-math} switch.
6311
6312@item -malign-double
6313@itemx -mno-align-double
0c2d1a2a 6314Control whether GCC aligns @code{double}, @code{long double}, and
74291a4b
MM
6315@code{long long} variables on a two word boundary or a one word
6316boundary. Aligning @code{double} variables on a two word boundary will
6317produce code that runs somewhat faster on a @samp{Pentium} at the
6318expense of more memory.
6319
6320@strong{Warning:} if you use the @samp{-malign-double} switch,
6321structures containing the above types will be aligned differently than
6322the published application binary interface specifications for the 386.
6323
6324@item -msvr3-shlib
6325@itemx -mno-svr3-shlib
0c2d1a2a 6326Control whether GCC places uninitialized locals into @code{bss} or
74291a4b
MM
6327@code{data}. @samp{-msvr3-shlib} places these locals into @code{bss}.
6328These options are meaningful only on System V Release 3.
6329
6330@item -mno-wide-multiply
6331@itemx -mwide-multiply
0c2d1a2a 6332Control whether GCC uses the @code{mul} and @code{imul} that produce
74291a4b
MM
633364 bit results in @code{eax:edx} from 32 bit operands to do @code{long
6334long} multiplies and 32-bit division by constants.
6335
6336@item -mrtd
6337Use a different function-calling convention, in which functions that
6338take a fixed number of arguments return with the @code{ret} @var{num}
6339instruction, which pops their arguments while returning. This saves one
6340instruction in the caller since there is no need to pop the arguments
6341there.
6342
6343You can specify that an individual function is called with this calling
6344sequence with the function attribute @samp{stdcall}. You can also
6345override the @samp{-mrtd} option by using the function attribute
0b433de6 6346@samp{cdecl}. @xref{Function Attributes}.
74291a4b
MM
6347
6348@strong{Warning:} this calling convention is incompatible with the one
6349normally used on Unix, so you cannot use it if you need to call
6350libraries compiled with the Unix compiler.
6351
6352Also, you must provide function prototypes for all functions that
6353take variable numbers of arguments (including @code{printf});
6354otherwise incorrect code will be generated for calls to those
6355functions.
6356
6357In addition, seriously incorrect code will result if you call a
6358function with too many arguments. (Normally, extra arguments are
6359harmlessly ignored.)
6360
6361@item -mreg-alloc=@var{regs}
6362Control the default allocation order of integer registers. The
6363string @var{regs} is a series of letters specifying a register. The
6364supported letters are: @code{a} allocate EAX; @code{b} allocate EBX;
6365@code{c} allocate ECX; @code{d} allocate EDX; @code{S} allocate ESI;
6366@code{D} allocate EDI; @code{B} allocate EBP.
6367
6368@item -mregparm=@var{num}
6369Control how many registers are used to pass integer arguments. By
6370default, no registers are used to pass arguments, and at most 3
6371registers can be used. You can control this behavior for a specific
0b433de6
JL
6372function by using the function attribute @samp{regparm}.
6373@xref{Function Attributes}.
74291a4b
MM
6374
6375@strong{Warning:} if you use this switch, and
6376@var{num} is nonzero, then you must build all modules with the same
6377value, including any libraries. This includes the system libraries and
6378startup modules.
6379
6380@item -malign-loops=@var{num}
6381Align loops to a 2 raised to a @var{num} byte boundary. If
9e423e6d
JW
6382@samp{-malign-loops} is not specified, the default is 2 unless
6383gas 2.8 (or later) is being used in which case the default is
6384to align the loop on a 16 byte boundary if it is less than 8
6385bytes away.
74291a4b
MM
6386
6387@item -malign-jumps=@var{num}
6388Align instructions that are only jumped to to a 2 raised to a @var{num}
6389byte boundary. If @samp{-malign-jumps} is not specified, the default is
9e423e6d
JW
63902 if optimizing for a 386, and 4 if optimizing for a 486 unless
6391gas 2.8 (or later) is being used in which case the default is
6392to align the instruction on a 16 byte boundary if it is less
6393than 8 bytes away.
74291a4b
MM
6394
6395@item -malign-functions=@var{num}
6396Align the start of functions to a 2 raised to @var{num} byte boundary.
6d4312dd 6397If @samp{-malign-functions} is not specified, the default is 2 if optimizing
74291a4b 6398for a 386, and 4 if optimizing for a 486.
74291a4b 6399
3af4bd89
JH
6400@item -mpreferred-stack-boundary=@var{num}
6401Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
6402byte boundary. If @samp{-mpreferred-stack-boundary} is not specified,
6403the default is 4 (16 bytes or 128 bits).
6404
6405The stack is required to be aligned on a 4 byte boundary. On Pentium
6406and PentiumPro, @code{double} and @code{long double} values should be
6407aligned to an 8 byte boundary (see @samp{-malign-double}) or suffer
6408significant run time performance penalties. On Pentium III, the
b192711e 6409Streaming SIMD Extension (SSE) data type @code{__m128} suffers similar
3af4bd89
JH
6410penalties if it is not 16 byte aligned.
6411
6412To ensure proper alignment of this values on the stack, the stack boundary
6413must be as aligned as that required by any value stored on the stack.
6414Further, every function must be generated such that it keeps the stack
6415aligned. Thus calling a function compiled with a higher preferred
6416stack boundary from a function compiled with a lower preferred stack
6417boundary will most likely misalign the stack. It is recommended that
6418libraries that use callbacks always use the default setting.
6419
6420This extra alignment does consume extra stack space. Code that is sensitive
6421to stack space usage, such as embedded systems and operating system kernels,
6422may want to reduce the preferred alignment to
6423@samp{-mpreferred-stack-boundary=2}.
f22a97d2 6424
f73ad30e
JH
6425@item -mpush-args
6426@kindex -mpush-args
6427Use PUSH operations to store outgoing parameters. This method is shorter
6428and usually equally fast as method using SUB/MOV operations and is enabled
6429by default. In some cases disabling it may improve performance because of
6430improved scheduling and reduced dependencies.
6431
6432@item -maccumulate-outgoing-args
6433@kindex -maccumulate-outgoing-args
6434If enabled, the maximum amount of space required for outgoing arguments will be
6435computed in the function prologue. This in faster on most modern CPUs
b192711e 6436because of reduced dependencies, improved scheduling and reduced stack usage
f73ad30e
JH
6437when preferred stack boundary is not equal to 2. The drawback is a notable
6438increase in code size. This switch implies -mno-push-args.
6439
f22a97d2
MK
6440@item -mthreads
6441@kindex -mthreads
6442Support thread-safe exception handling on @samp{Mingw32}. Code that relies
6443on thread-safe exception handling must compile and link all code with the
6444@samp{-mthreads} option. When compiling, @samp{-mthreads} defines
6445@samp{-D_MT}; when linking, it links in a special thread helper library
6446@samp{-lmingwthrd} which cleans up per thread exception handling data.
79f05c19
JH
6447
6448@item -mno-align-stringops
6449@kindex -mno-align-stringops
6450Do not align destination of inlined string operations. This switch reduces
6451code size and improves performance in case the destination is already aligned,
6452but gcc don't know about it.
6453
6454@item -minline-all-stringops
6455@kindex -minline-all-stringops
6456By default GCC inlines string operations only when destination is known to be
6457aligned at least to 4 byte boundary. This enables more inlining, increase code
6458size, but may improve performance of code that depends on fast memcpy, strlen
6459and memset for short lengths.
3af4bd89
JH
6460@end table
6461
74291a4b
MM
6462@node HPPA Options
6463@subsection HPPA Options
6464@cindex HPPA Options
6465
6466These @samp{-m} options are defined for the HPPA family of computers:
6467
6468@table @code
ea3bfbfe
JQ
6469@item -march=@var{architecture type}
6470Generate code for the specified architecture. The choices for
6471@var{architecture type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
64721.1, and @samp{2.0} for PA 2.0 processors. Refer to
6473@file{/usr/lib/sched.models} on an HP-UX system to determine the proper
6474architecture option for your machine. Code compiled for lower numbered
6475architectures will run on higher numbered architectures, but not the
6476other way around.
6477
6478PA 2.0 support currently requires gas snapshot 19990413 or later. The
6479next release of binutils (current is 2.9.1) will probably contain PA 2.0
6480support.
74291a4b 6481
ea3bfbfe 6482@item -mpa-risc-1-0
62a1403d
AS
6483@itemx -mpa-risc-1-1
6484@itemx -mpa-risc-2-0
ea3bfbfe 6485Synonyms for -march=1.0, -march=1.1, and -march=2.0 respectively.
74291a4b 6486
861bb6c1
JL
6487@item -mbig-switch
6488Generate code suitable for big switch tables. Use this option only if
6489the assembler/linker complain about out of range branches within a switch
6490table.
6491
74291a4b
MM
6492@item -mjump-in-delay
6493Fill delay slots of function calls with unconditional jump instructions
6494by modifying the return pointer for the function call to be the target
6495of the conditional jump.
6496
6497@item -mdisable-fpregs
6498Prevent floating point registers from being used in any manner. This is
6499necessary for compiling kernels which perform lazy context switching of
6500floating point registers. If you use this option and attempt to perform
6501floating point operations, the compiler will abort.
6502
6503@item -mdisable-indexing
6504Prevent the compiler from using indexing address modes. This avoids some
6505rather obscure problems when compiling MIG generated code under MACH.
6506
6507@item -mno-space-regs
6508Generate code that assumes the target has no space registers. This allows
6509GCC to generate faster indirect calls and use unscaled index address modes.
6510
6511Such code is suitable for level 0 PA systems and kernels.
6512
6513@item -mfast-indirect-calls
6514Generate code that assumes calls never cross space boundaries. This
6515allows GCC to emit code which performs faster indirect calls.
6516
b192711e 6517This option will not work in the presence of shared libraries or nested
74291a4b
MM
6518functions.
6519
74291a4b
MM
6520@item -mlong-load-store
6521Generate 3-instruction load and store sequences as sometimes required by
6522the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
6523the HP compilers.
6524
6525@item -mportable-runtime
6526Use the portable calling conventions proposed by HP for ELF systems.
6527
6528@item -mgas
6529Enable the use of assembler directives only GAS understands.
6530
6531@item -mschedule=@var{cpu type}
6532Schedule code according to the constraints for the machine type
732135bf 6533@var{cpu type}. The choices for @var{cpu type} are @samp{700}
e14b50ce 6534@samp{7100}, @samp{7100LC}, @samp{7200}, and @samp{8000}. Refer to
732135bf
JL
6535@file{/usr/lib/sched.models} on an HP-UX system to determine the
6536proper scheduling option for your machine.
74291a4b
MM
6537
6538@item -mlinker-opt
6539Enable the optimization pass in the HPUX linker. Note this makes symbolic
6540debugging impossible. It also triggers a bug in the HPUX 8 and HPUX 9 linkers
6541in which they give bogus error messages when linking some programs.
6542
6543@item -msoft-float
6544Generate output containing library calls for floating point.
6545@strong{Warning:} the requisite libraries are not available for all HPPA
6546targets. Normally the facilities of the machine's usual C compiler are
6547used, but this cannot be done directly in cross-compilation. You must make
6548your own arrangements to provide suitable library functions for
6549cross-compilation. The embedded target @samp{hppa1.1-*-pro}
6550does provide software floating point support.
6551
6552@samp{-msoft-float} changes the calling convention in the output file;
6553therefore, it is only useful if you compile @emph{all} of a program with
6554this option. In particular, you need to compile @file{libgcc.a}, the
0c2d1a2a 6555library that comes with GCC, with @samp{-msoft-float} in order for
74291a4b
MM
6556this to work.
6557@end table
6558
6559@node Intel 960 Options
6560@subsection Intel 960 Options
6561
6562These @samp{-m} options are defined for the Intel 960 implementations:
6563
6564@table @code
6565@item -m@var{cpu type}
6566Assume the defaults for the machine type @var{cpu type} for some of
6567the other options, including instruction scheduling, floating point
6568support, and addressing modes. The choices for @var{cpu type} are
6569@samp{ka}, @samp{kb}, @samp{mc}, @samp{ca}, @samp{cf},
6570@samp{sa}, and @samp{sb}.
6571The default is
6572@samp{kb}.
6573
6574@item -mnumerics
6575@itemx -msoft-float
6576The @samp{-mnumerics} option indicates that the processor does support
6577floating-point instructions. The @samp{-msoft-float} option indicates
6578that floating-point support should not be assumed.
6579
6580@item -mleaf-procedures
6581@itemx -mno-leaf-procedures
6582Do (or do not) attempt to alter leaf procedures to be callable with the
6583@code{bal} instruction as well as @code{call}. This will result in more
6584efficient code for explicit calls when the @code{bal} instruction can be
6585substituted by the assembler or linker, but less efficient code in other
6586cases, such as calls via function pointers, or using a linker that doesn't
6587support this optimization.
6588
6589@item -mtail-call
6590@itemx -mno-tail-call
6591Do (or do not) make additional attempts (beyond those of the
6592machine-independent portions of the compiler) to optimize tail-recursive
6593calls into branches. You may not want to do this because the detection of
6594cases where this is not valid is not totally complete. The default is
6595@samp{-mno-tail-call}.
6596
6597@item -mcomplex-addr
6598@itemx -mno-complex-addr
6599Assume (or do not assume) that the use of a complex addressing mode is a
6600win on this implementation of the i960. Complex addressing modes may not
6601be worthwhile on the K-series, but they definitely are on the C-series.
6602The default is currently @samp{-mcomplex-addr} for all processors except
6603the CB and CC.
6604
6605@item -mcode-align
6606@itemx -mno-code-align
6607Align code to 8-byte boundaries for faster fetching (or don't bother).
6608Currently turned on by default for C-series implementations only.
6609
6610@ignore
6611@item -mclean-linkage
6612@itemx -mno-clean-linkage
6613These options are not fully implemented.
6614@end ignore
6615
6616@item -mic-compat
6617@itemx -mic2.0-compat
6618@itemx -mic3.0-compat
6619Enable compatibility with iC960 v2.0 or v3.0.
6620
6621@item -masm-compat
6622@itemx -mintel-asm
6623Enable compatibility with the iC960 assembler.
6624
6625@item -mstrict-align
6626@itemx -mno-strict-align
6627Do not permit (do permit) unaligned accesses.
6628
6629@item -mold-align
6630Enable structure-alignment compatibility with Intel's gcc release version
861bb6c1 66311.3 (based on gcc 1.37). This option implies @samp{-mstrict-align}.
eaa4b44c
VM
6632
6633@item -mlong-double-64
6634Implement type @samp{long double} as 64-bit floating point numbers.
6635Without the option @samp{long double} is implemented by 80-bit
6636floating point numbers. The only reason we have it because there is
6637no 128-bit @samp{long double} support in @samp{fp-bit.c} yet. So it
6638is only useful for people using soft-float targets. Otherwise, we
6639should recommend against use of it.
6640
74291a4b
MM
6641@end table
6642
6643@node DEC Alpha Options
6644@subsection DEC Alpha Options
6645
6646These @samp{-m} options are defined for the DEC Alpha implementations:
6647
6648@table @code
6649@item -mno-soft-float
6650@itemx -msoft-float
6651Use (do not use) the hardware floating-point instructions for
6652floating-point operations. When @code{-msoft-float} is specified,
6653functions in @file{libgcc1.c} will be used to perform floating-point
6654operations. Unless they are replaced by routines that emulate the
6655floating-point operations, or compiled in such a way as to call such
6656emulations routines, these routines will issue floating-point
6657operations. If you are compiling for an Alpha without floating-point
6658operations, you must ensure that the library is built so as not to call
6659them.
6660
6661Note that Alpha implementations without floating-point operations are
6662required to have floating-point registers.
6663
6664@item -mfp-reg
6665@itemx -mno-fp-regs
6666Generate code that uses (does not use) the floating-point register set.
6667@code{-mno-fp-regs} implies @code{-msoft-float}. If the floating-point
6668register set is not used, floating point operands are passed in integer
6669registers as if they were integers and floating-point results are passed
6670in $0 instead of $f0. This is a non-standard calling sequence, so any
6671function with a floating-point argument or return value called by code
6672compiled with @code{-mno-fp-regs} must also be compiled with that
6673option.
6674
6675A typical use of this option is building a kernel that does not use,
6676and hence need not save and restore, any floating-point registers.
6677
6678@item -mieee
6679The Alpha architecture implements floating-point hardware optimized for
6680maximum performance. It is mostly compliant with the IEEE floating
6681point standard. However, for full compliance, software assistance is
6682required. This option generates code fully IEEE compliant code
6683@emph{except} that the @var{inexact flag} is not maintained (see below).
6684If this option is turned on, the CPP macro @code{_IEEE_FP} is defined
6685during compilation. The option is a shorthand for: @samp{-D_IEEE_FP
6686-mfp-trap-mode=su -mtrap-precision=i -mieee-conformant}. The resulting
6687code is less efficient but is able to correctly support denormalized
6688numbers and exceptional IEEE values such as not-a-number and plus/minus
6689infinity. Other Alpha compilers call this option
6690@code{-ieee_with_no_inexact}.
6691
6692@item -mieee-with-inexact
6693@c overfull hbox here --bob 22 jul96
6694@c original text between ignore ... end ignore
6695@ignore
6696This is like @samp{-mieee} except the generated code also maintains the
6697IEEE @var{inexact flag}. Turning on this option causes the generated
6698code to implement fully-compliant IEEE math. The option is a shorthand
6699for @samp{-D_IEEE_FP -D_IEEE_FP_INEXACT} plus @samp{-mieee-conformant},
6700@samp{-mfp-trap-mode=sui}, and @samp{-mtrap-precision=i}. On some Alpha
6701implementations the resulting code may execute significantly slower than
6702the code generated by default. Since there is very little code that
6703depends on the @var{inexact flag}, you should normally not specify this
6704option. Other Alpha compilers call this option
6705@samp{-ieee_with_inexact}.
6706@end ignore
6707@c changed paragraph
6708This is like @samp{-mieee} except the generated code also maintains the
6709IEEE @var{inexact flag}. Turning on this option causes the generated
6710code to implement fully-compliant IEEE math. The option is a shorthand
6711for @samp{-D_IEEE_FP -D_IEEE_FP_INEXACT} plus the three following:
6712@samp{-mieee-conformant},
6713@samp{-mfp-trap-mode=sui},
6714and @samp{-mtrap-precision=i}.
6715On some Alpha implementations the resulting code may execute
6716significantly slower than the code generated by default. Since there
6717is very little code that depends on the @var{inexact flag}, you should
6718normally not specify this option. Other Alpha compilers call this
6719option @samp{-ieee_with_inexact}.
6720@c end changes to prevent overfull hboxes
6721
6722@item -mfp-trap-mode=@var{trap mode}
6723This option controls what floating-point related traps are enabled.
6724Other Alpha compilers call this option @samp{-fptm }@var{trap mode}.
6725The trap mode can be set to one of four values:
6726
6727@table @samp
6728@item n
6729This is the default (normal) setting. The only traps that are enabled
6730are the ones that cannot be disabled in software (e.g., division by zero
6731trap).
6732
6733@item u
6734In addition to the traps enabled by @samp{n}, underflow traps are enabled
6735as well.
6736
6737@item su
6738Like @samp{su}, but the instructions are marked to be safe for software
6739completion (see Alpha architecture manual for details).
6740
6741@item sui
6742Like @samp{su}, but inexact traps are enabled as well.
6743@end table
6744
6745@item -mfp-rounding-mode=@var{rounding mode}
6746Selects the IEEE rounding mode. Other Alpha compilers call this option
6747@samp{-fprm }@var{rounding mode}. The @var{rounding mode} can be one
6748of:
6749
6750@table @samp
6751@item n
6752Normal IEEE rounding mode. Floating point numbers are rounded towards
6753the nearest machine number or towards the even machine number in case
6754of a tie.
6755
6756@item m
6757Round towards minus infinity.
6758
6759@item c
6760Chopped rounding mode. Floating point numbers are rounded towards zero.
6761
6762@item d
6763Dynamic rounding mode. A field in the floating point control register
6764(@var{fpcr}, see Alpha architecture reference manual) controls the
6765rounding mode in effect. The C library initializes this register for
6766rounding towards plus infinity. Thus, unless your program modifies the
ec4b2ecb
CB
6767@var{fpcr}, @samp{d} corresponds to round towards plus infinity.
6768@end table
74291a4b
MM
6769
6770@item -mtrap-precision=@var{trap precision}
6771In the Alpha architecture, floating point traps are imprecise. This
6772means without software assistance it is impossible to recover from a
6773floating trap and program execution normally needs to be terminated.
0c2d1a2a 6774GCC can generate code that can assist operating system trap handlers
74291a4b
MM
6775in determining the exact location that caused a floating point trap.
6776Depending on the requirements of an application, different levels of
6777precisions can be selected:
6778
6779@table @samp
6780@item p
6781Program precision. This option is the default and means a trap handler
6782can only identify which program caused a floating point exception.
6783
6784@item f
6785Function precision. The trap handler can determine the function that
6786caused a floating point exception.
6787
6788@item i
6789Instruction precision. The trap handler can determine the exact
6790instruction that caused a floating point exception.
6791@end table
6792
6793Other Alpha compilers provide the equivalent options called
6794@samp{-scope_safe} and @samp{-resumption_safe}.
6795
6796@item -mieee-conformant
6797This option marks the generated code as IEEE conformant. You must not
6798use this option unless you also specify @samp{-mtrap-precision=i} and either
6799@samp{-mfp-trap-mode=su} or @samp{-mfp-trap-mode=sui}. Its only effect
6800is to emit the line @samp{.eflag 48} in the function prologue of the
6801generated assembly file. Under DEC Unix, this has the effect that
6802IEEE-conformant math library routines will be linked in.
6803
6804@item -mbuild-constants
0c2d1a2a 6805Normally GCC examines a 32- or 64-bit integer constant to
74291a4b
MM
6806see if it can construct it from smaller constants in two or three
6807instructions. If it cannot, it will output the constant as a literal and
956d6950 6808generate code to load it from the data segment at runtime.
74291a4b 6809
0c2d1a2a 6810Use this option to require GCC to construct @emph{all} integer constants
74291a4b
MM
6811using code, even if it takes more instructions (the maximum is six).
6812
6813You would typically use this option to build a shared library dynamic
6814loader. Itself a shared library, it must relocate itself in memory
6815before it can find the variables and constants in its own data segment.
956d6950
JL
6816
6817@item -malpha-as
6818@itemx -mgas
6819Select whether to generate code to be assembled by the vendor-supplied
6820assembler (@samp{-malpha-as}) or by the GNU assembler @samp{-mgas}.
6821
6822@item -mbwx
6823@itemx -mno-bwx
6824@itemx -mcix
6825@itemx -mno-cix
6826@itemx -mmax
6827@itemx -mno-max
0c2d1a2a 6828Indicate whether GCC should generate code to use the optional BWX,
956d6950
JL
6829CIX, and MAX instruction sets. The default is to use the instruction sets
6830supported by the CPU type specified via @samp{-mcpu=} option or that
0c2d1a2a 6831of the CPU on which GCC was built if none was specified.
956d6950 6832
956d6950
JL
6833@item -mcpu=@var{cpu_type}
6834Set the instruction set, register set, and instruction scheduling
6835parameters for machine type @var{cpu_type}. You can specify either the
0c2d1a2a 6836@samp{EV} style name or the corresponding chip number. GCC
956d6950
JL
6837supports scheduling parameters for the EV4 and EV5 family of processors
6838and will choose the default values for the instruction set from
6839the processor you specify. If you do not specify a processor type,
0c2d1a2a 6840GCC will default to the processor on which the compiler was built.
956d6950
JL
6841
6842Supported values for @var{cpu_type} are
6843
6844@table @samp
6845@item ev4
6846@itemx 21064
6847Schedules as an EV4 and has no instruction set extensions.
6848
6849@item ev5
6850@itemx 21164
6851Schedules as an EV5 and has no instruction set extensions.
6852
6853@item ev56
6854@itemx 21164a
6855Schedules as an EV5 and supports the BWX extension.
6856
6857@item pca56
4f69985c 6858@itemx 21164pc
956d6950
JL
6859@itemx 21164PC
6860Schedules as an EV5 and supports the BWX and MAX extensions.
6861
6862@item ev6
6863@itemx 21264
6864Schedules as an EV5 (until Digital releases the scheduling parameters
6865for the EV6) and supports the BWX, CIX, and MAX extensions.
4f69985c
RH
6866@end table
6867
6868@item -mmemory-latency=@var{time}
6869Sets the latency the scheduler should assume for typical memory
6870references as seen by the application. This number is highly
b192711e 6871dependent on the memory access patterns used by the application
4f69985c
RH
6872and the size of the external cache on the machine.
6873
6874Valid options for @var{time} are
6875
6876@table @samp
6877@item @var{number}
6878A decimal number representing clock cycles.
6879
6880@item L1
6881@itemx L2
6882@itemx L3
6883@itemx main
6884The compiler contains estimates of the number of clock cycles for
6885``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
6886(also called Dcache, Scache, and Bcache), as well as to main memory.
6887Note that L3 is only valid for EV5.
6888
956d6950 6889@end table
74291a4b
MM
6890@end table
6891
6892@node Clipper Options
6893@subsection Clipper Options
6894
6895These @samp{-m} options are defined for the Clipper implementations:
6896
6897@table @code
6898@item -mc300
6899Produce code for a C300 Clipper processor. This is the default.
6900
62a1403d 6901@item -mc400
74291a4b
MM
6902Produce code for a C400 Clipper processor i.e. use floating point
6903registers f8..f15.
6904@end table
6905
6906@node H8/300 Options
6907@subsection H8/300 Options
6908
6909These @samp{-m} options are defined for the H8/300 implementations:
6910
6911@table @code
6912@item -mrelax
6913Shorten some address references at link time, when possible; uses the
6914linker option @samp{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
6915ld.info, Using ld}, for a fuller description.
6916
6917@item -mh
6918Generate code for the H8/300H.
6919
dcb9d1f0
JL
6920@item -ms
6921Generate code for the H8/S.
6922
17f0f8fa
KH
6923@item -ms2600
6924Generate code for the H8/S2600. This switch must be used with -ms.
6925
74291a4b
MM
6926@item -mint32
6927Make @code{int} data 32 bits by default.
6928
6929@item -malign-300
2c54abce
KH
6930On the H8/300H and H8/S, use the same alignment rules as for the H8/300.
6931The default for the H8/300H and H8/S is to align longs and floats on 4
6932byte boundaries.
74291a4b 6933@samp{-malign-300} causes them to be aligned on 2 byte boundaries.
2c54abce 6934This option has no effect on the H8/300.
74291a4b
MM
6935@end table
6936
6937@node SH Options
6938@subsection SH Options
6939
6940These @samp{-m} options are defined for the SH implementations:
6941
6942@table @code
6943@item -m1
6944Generate code for the SH1.
6945
6946@item -m2
6947Generate code for the SH2.
6948
6949@item -m3
6950Generate code for the SH3.
6951
6952@item -m3e
6953Generate code for the SH3e.
6954
3cadd778
AO
6955@item -m4-nofpu
6956Generate code for the SH4 without a floating-point unit.
6957
6958@item -m4-single-only
6959Generate code for the SH4 with a floating-point unit that only
6960supports single-precision arithmentic.
6961
6962@item -m4-single
6963Generate code for the SH4 assuming the floating-point unit is in
6964single-precision mode by default.
6965
6966@item -m4
6967Generate code for the SH4.
6968
74291a4b
MM
6969@item -mb
6970Compile code for the processor in big endian mode.
6971
6972@item -ml
6973Compile code for the processor in little endian mode.
6974
3d5a0820
R
6975@item -mdalign
6976Align doubles at 64 bit boundaries. Note that this changes the calling
6977conventions, and thus some functions from the standard C library will
6978not work unless you recompile it first with -mdalign.
6979
74291a4b
MM
6980@item -mrelax
6981Shorten some address references at link time, when possible; uses the
6982linker option @samp{-relax}.
3cadd778
AO
6983
6984@item -mbigtable
6985Use 32-bit offsets in @code{switch} tables. The default is to use
698616-bit offsets.
6987
6988@item -mfmovd
6989Enable the use of the instruction @code{fmovd}.
6990
6991@item -mhitachi
6992Comply with the calling conventions defined by Hitachi.
6993
6994@item -mnomacsave
6995Mark the @code{MAC} register as call-clobbered, even if
6996@code{-mhitachi} is given.
6997
6998@item -misize
6999Dump instruction size and location in the assembly code.
7000
7001@item -mpadstruct
7002This option is deprecated. It pads structures to multiple of 4 bytes,
7003which is incompatible with the SH ABI.
7004
7005@item -mspace
7006Optimize for space instead of speed. Implied by @code{-Os}.
1a66cd67
AO
7007
7008@item -mprefergot
7009When generating position-independent code, emit function calls using
7010the Global Offset Table instead of the Procedure Linkage Table.
93ca1662
NY
7011
7012@item -musermode
7013Generate a library function call to invalidate instruction cache
7014entries, after fixing up a trampoline. This library function call
7015doesn't assume it can write to the whole memory address space. This
7016is the default when the target is @code{sh-*-linux*}.
74291a4b
MM
7017@end table
7018
7019@node System V Options
7020@subsection Options for System V
7021
7022These additional options are available on System V Release 4 for
7023compatibility with other compilers on those systems:
7024
7025@table @code
7026@item -G
7027Create a shared object.
7028It is recommended that @samp{-symbolic} or @samp{-shared} be used instead.
7029
7030@item -Qy
7031Identify the versions of each tool used by the compiler, in a
7032@code{.ident} assembler directive in the output.
7033
7034@item -Qn
7035Refrain from adding @code{.ident} directives to the output file (this is
7036the default).
7037
7038@item -YP,@var{dirs}
7039Search the directories @var{dirs}, and no others, for libraries
7040specified with @samp{-l}.
7041
7042@item -Ym,@var{dir}
7043Look in the directory @var{dir} to find the M4 preprocessor.
7044The assembler uses this option.
7045@c This is supposed to go with a -Yd for predefined M4 macro files, but
7046@c the generic assembler that comes with Solaris takes just -Ym.
7047@end table
7048
282a61e6
MH
7049@node TMS320C3x/C4x Options
7050@subsection TMS320C3x/C4x Options
7051@cindex TMS320C3x/C4x Options
7052
7053These @samp{-m} options are defined for TMS320C3x/C4x implementations:
7054
7055@table @code
7056
7057@item -mcpu=@var{cpu_type}
7058Set the instruction set, register set, and instruction scheduling
7059parameters for machine type @var{cpu_type}. Supported values for
7060@var{cpu_type} are @samp{c30}, @samp{c31}, @samp{c32}, @samp{c40}, and
7061@samp{c44}. The default is @samp{c40} to generate code for the
7062TMS320C40.
7063
7064@item -mbig-memory
7065@item -mbig
7066@itemx -msmall-memory
7067@itemx -msmall
7068Generates code for the big or small memory model. The small memory
7069model assumed that all data fits into one 64K word page. At run-time
7070the data page (DP) register must be set to point to the 64K page
7071containing the .bss and .data program sections. The big memory model is
7072the default and requires reloading of the DP register for every direct
7073memory access.
7074
7075@item -mbk
7076@itemx -mno-bk
7077Allow (disallow) allocation of general integer operands into the block
7078count register BK.
7079
7080@item -mdb
7081@itemx -mno-db
7082Enable (disable) generation of code using decrement and branch,
7083DBcond(D), instructions. This is enabled by default for the C4x. To be
7084on the safe side, this is disabled for the C3x, since the maximum
7085iteration count on the C3x is 2^23 + 1 (but who iterates loops more than
70862^23 times on the C3x?). Note that GCC will try to reverse a loop so
7087that it can utilise the decrement and branch instruction, but will give
7088up if there is more than one memory reference in the loop. Thus a loop
7089where the loop counter is decremented can generate slightly more
7090efficient code, in cases where the RPTB instruction cannot be utilised.
7091
7092@item -mdp-isr-reload
7093@itemx -mparanoid
7094Force the DP register to be saved on entry to an interrupt service
7095routine (ISR), reloaded to point to the data section, and restored on
7096exit from the ISR. This should not be required unless someone has
7097violated the small memory model by modifying the DP register, say within
7098an object library.
7099
7100@item -mmpyi
7101@itemx -mno-mpyi
7102For the C3x use the 24-bit MPYI instruction for integer multiplies
7103instead of a library call to guarantee 32-bit results. Note that if one
7104of the operands is a constant, then the multiplication will be performed
7105using shifts and adds. If the -mmpyi option is not specified for the C3x,
7106then squaring operations are performed inline instead of a library call.
7107
7108@item -mfast-fix
7109@itemx -mno-fast-fix
7110The C3x/C4x FIX instruction to convert a floating point value to an
7111integer value chooses the nearest integer less than or equal to the
7112floating point value rather than to the nearest integer. Thus if the
7113floating point number is negative, the result will be incorrectly
7114truncated an additional code is necessary to detect and correct this
7115case. This option can be used to disable generation of the additional
7116code required to correct the result.
7117
7118@item -mrptb
7119@itemx -mno-rptb
7120Enable (disable) generation of repeat block sequences using the RPTB
7121instruction for zero overhead looping. The RPTB construct is only used
7122for innermost loops that do not call functions or jump across the loop
7123boundaries. There is no advantage having nested RPTB loops due to the
7124overhead required to save and restore the RC, RS, and RE registers.
7125This is enabled by default with -O2.
7126
7127@item -mrpts=@var{count}
7128@itemx -mno-rpts
7129Enable (disable) the use of the single instruction repeat instruction
7130RPTS. If a repeat block contains a single instruction, and the loop
7131count can be guaranteed to be less than the value @var{count}, GCC will
7132emit a RPTS instruction instead of a RPTB. If no value is specified,
7133then a RPTS will be emitted even if the loop count cannot be determined
7134at compile time. Note that the repeated instruction following RPTS does
7135not have to be reloaded from memory each iteration, thus freeing up the
b192711e 7136CPU buses for operands. However, since interrupts are blocked by this
282a61e6
MH
7137instruction, it is disabled by default.
7138
7139@item -mloop-unsigned
7140@itemx -mno-loop-unsigned
7141The maximum iteration count when using RPTS and RPTB (and DB on the C40)
7142is 2^31 + 1 since these instructions test if the iteration count is
7143negative to terminate the loop. If the iteration count is unsigned
7144there is a possibility than the 2^31 + 1 maximum iteration count may be
7145exceeded. This switch allows an unsigned iteration count.
7146
7147@item -mti
7148Try to emit an assembler syntax that the TI assembler (asm30) is happy
7149with. This also enforces compatibility with the API employed by the TI
7150C3x C compiler. For example, long doubles are passed as structures
7151rather than in floating point registers.
7152
7153@item -mregparm
7154@itemx -mmemparm
7155Generate code that uses registers (stack) for passing arguments to functions.
7156By default, arguments are passed in registers where possible rather
7157than by pushing arguments on to the stack.
7158
7159@item -mparallel-insns
7160@itemx -mno-parallel-insns
7161Allow the generation of parallel instructions. This is enabled by
7162default with -O2.
7163
7164@item -mparallel-mpy
7165@itemx -mno-parallel-mpy
7166Allow the generation of MPY||ADD and MPY||SUB parallel instructions,
7167provided -mparallel-insns is also specified. These instructions have
7168tight register constraints which can pessimize the code generation
7169of large functions.
7170
7171@end table
7172
f84271d9
JL
7173@node V850 Options
7174@subsection V850 Options
7175@cindex V850 Options
7176
7177These @samp{-m} options are defined for V850 implementations:
7178
7179@table @code
7180@item -mlong-calls
7181@itemx -mno-long-calls
7182Treat all calls as being far away (near). If calls are assumed to be
7183far away, the compiler will always load the functions address up into a
7184register, and call indirect through the pointer.
7185
7186@item -mno-ep
bd762873 7187@itemx -mep
f84271d9
JL
7188Do not optimize (do optimize) basic blocks that use the same index
7189pointer 4 or more times to copy pointer into the @code{ep} register, and
7190use the shorter @code{sld} and @code{sst} instructions. The @samp{-mep}
7191option is on by default if you optimize.
7192
7193@item -mno-prolog-function
7194@itemx -mprolog-function
7195Do not use (do use) external functions to save and restore registers at
7196the prolog and epilog of a function. The external functions are slower,
7197but use less code space if more than one function saves the same number
7198of registers. The @samp{-mprolog-function} option is on by default if
7199you optimize.
7200
7201@item -mspace
7202Try to make the code as small as possible. At present, this just turns
7203on the @samp{-mep} and @samp{-mprolog-function} options.
7204
7205@item -mtda=@var{n}
7206Put static or global variables whose size is @var{n} bytes or less into
7207the tiny data area that register @code{ep} points to. The tiny data
7208area can hold up to 256 bytes in total (128 bytes for byte references).
7209
7210@item -msda=@var{n}
7211Put static or global variables whose size is @var{n} bytes or less into
7212the small data area that register @code{gp} points to. The small data
7213area can hold up to 64 kilobytes.
7214
7215@item -mzda=@var{n}
7216Put static or global variables whose size is @var{n} bytes or less into
7217the first 32 kilobytes of memory.
e9a25f70 7218
48f0be1b
SC
7219@item -mv850
7220Specify that the target processor is the V850.
7221
e9a25f70
JL
7222@item -mbig-switch
7223Generate code suitable for big switch tables. Use this option only if
7224the assembler/linker complain about out of range branches within a switch
7225table.
f84271d9
JL
7226@end table
7227
56b2d7a7
JL
7228@node ARC Options
7229@subsection ARC Options
7230@cindex ARC Options
7231
7232These options are defined for ARC implementations:
7233
7234@table @code
7235@item -EL
7236Compile code for little endian mode. This is the default.
7237
7238@item -EB
7239Compile code for big endian mode.
7240
7241@item -mmangle-cpu
7242Prepend the name of the cpu to all public symbol names.
7243In multiple-processor systems, there are many ARC variants with different
7244instruction and register set characteristics. This flag prevents code
7245compiled for one cpu to be linked with code compiled for another.
7246No facility exists for handling variants that are "almost identical".
7247This is an all or nothing option.
7248
7249@item -mcpu=@var{cpu}
7250Compile code for ARC variant @var{cpu}.
7251Which variants are supported depend on the configuration.
7252All variants support @samp{-mcpu=base}, this is the default.
7253
7254@item -mtext=@var{text section}
59d40964
AS
7255@itemx -mdata=@var{data section}
7256@itemx -mrodata=@var{readonly data section}
56b2d7a7
JL
7257Put functions, data, and readonly data in @var{text section},
7258@var{data section}, and @var{readonly data section} respectively
7259by default. This can be overridden with the @code{section} attribute.
0b433de6 7260@xref{Variable Attributes}.
56b2d7a7
JL
7261
7262@end table
7263
83575957
ID
7264@node NS32K Options
7265@subsection NS32K Options
7266@cindex NS32K options
7267
7268These are the @samp{-m} options defined for the 32000 series. The default
7269values for these options depends on which style of 32000 was selected when
7270the compiler was configured; the defaults for the most common choices are
7271given below.
7272
7273@table @code
7274@item -m32032
7275@itemx -m32032
7276Generate output for a 32032. This is the default
7277when the compiler is configured for 32032 and 32016 based systems.
7278
7279@item -m32332
7280@itemx -m32332
7281Generate output for a 32332. This is the default
7282when the compiler is configured for 32332-based systems.
7283
7284@item -m32532
7285@itemx -m32532
7286Generate output for a 32532. This is the default
7287when the compiler is configured for 32532-based systems.
7288
7289@item -m32081
7290Generate output containing 32081 instructions for floating point.
7291This is the default for all systems.
7292
7293@item -m32381
7294Generate output containing 32381 instructions for floating point. This
7295also implies @samp{-m32081}. The 32381 is only compatible with the 32332
7296and 32532 cpus. This is the default for the pc532-netbsd configuration.
7297
7298@item -mmulti-add
7299Try and generate multiply-add floating point instructions @code{polyF}
7300and @code{dotF}. This option is only available if the @samp{-m32381}
7301option is in effect. Using these instructions requires changes to to
7302register allocation which generally has a negative impact on
7303performance. This option should only be enabled when compiling code
7304particularly likely to make heavy use of multiply-add instructions.
7305
7306@item -mnomulti-add
7307Do not try and generate multiply-add floating point instructions
7308@code{polyF} and @code{dotF}. This is the default on all platforms.
7309
7310@item -msoft-float
7311Generate output containing library calls for floating point.
7312@strong{Warning:} the requisite libraries may not be available.
7313
7314@item -mnobitfield
7315Do not use the bit-field instructions. On some machines it is faster to
7316use shifting and masking operations. This is the default for the pc532.
7317
7318@item -mbitfield
7319Do use the bit-field instructions. This is the default for all platforms
7320except the pc532.
7321
7322@item -mrtd
7323Use a different function-calling convention, in which functions
7324that take a fixed number of arguments return pop their
7325arguments on return with the @code{ret} instruction.
7326
7327This calling convention is incompatible with the one normally
7328used on Unix, so you cannot use it if you need to call libraries
7329compiled with the Unix compiler.
7330
7331Also, you must provide function prototypes for all functions that
7332take variable numbers of arguments (including @code{printf});
7333otherwise incorrect code will be generated for calls to those
7334functions.
7335
7336In addition, seriously incorrect code will result if you call a
7337function with too many arguments. (Normally, extra arguments are
7338harmlessly ignored.)
7339
7340This option takes its name from the 680x0 @code{rtd} instruction.
7341
7342
7343@item -mregparam
7344Use a different function-calling convention where the first two arguments
7345are passed in registers.
7346
7347This calling convention is incompatible with the one normally
7348used on Unix, so you cannot use it if you need to call libraries
7349compiled with the Unix compiler.
7350
7351@item -mnoregparam
7352Do not pass any arguments in registers. This is the default for all
7353targets.
7354
7355@item -msb
7356It is OK to use the sb as an index register which is always loaded with
7357zero. This is the default for the pc532-netbsd target.
7358
7359@item -mnosb
7360The sb register is not available for use or has not been initialized to
7361zero by the run time system. This is the default for all targets except
7362the pc532-netbsd. It is also implied whenever @samp{-mhimem} or
7363@samp{-fpic} is set.
7364
7365@item -mhimem
7366Many ns32000 series addressing modes use displacements of up to 512MB.
7367If an address is above 512MB then displacements from zero can not be used.
7368This option causes code to be generated which can be loaded above 512MB.
7369This may be useful for operating systems or ROM code.
7370
7371@item -mnohimem
7372Assume code will be loaded in the first 512MB of virtual address space.
7373This is the default for all platforms.
7374
7375
7376@end table
7377
052a4b28
DC
7378@node AVR Options
7379@subsection AVR Options
7380@cindex AVR Options
7381
7382These options are defined for AVR implementations:
7383
7384@table @code
7385@item -mmcu=@var{mcu}
3a69a7d5
MM
7386Specify ATMEL AVR instruction set or MCU type.
7387
7388Instruction set avr1 is for the minimal AVR core, not supported by the C
7389compiler, only for assembler programs (MCU types: at90s1200, attiny10,
7390attiny11, attiny12, attiny15, attiny28).
7391
7392Instruction set avr2 (default) is for the classic AVR core with up to
73938K program memory space (MCU types: at90s2313, at90s2323, attiny22,
7394at90s2333, at90s2343, at90s4414, at90s4433, at90s4434, at90s8515,
7395at90c8534, at90s8535).
7396
7397Instruction set avr3 is for the classic AVR core with up to 128K program
7398memory space (MCU types: atmega103, atmega603).
7399
7400Instruction set avr4 is for the enhanced AVR core with up to 8K program
7401memory space (MCU types: atmega83, atmega85).
7402
7403Instruction set avr5 is for the enhanced AVR core with up to 128K program
7404memory space (MCU types: atmega161, atmega163, atmega32, at94k).
052a4b28
DC
7405
7406@item -msize
3a69a7d5 7407Output instruction sizes to the asm file.
052a4b28
DC
7408
7409@item -minit-stack=@var{N}
3a69a7d5
MM
7410Specify the initial stack address, which may be a symbol or numeric value,
7411__stack is the default.
052a4b28
DC
7412
7413@item -mno-interrupts
7414Generated code is not compatible with hardware interrupts.
7415Code size will be smaller.
7416
7417@item -mcall-prologues
7418Functions prologues/epilogues expanded as call to appropriate
7419subroutines. Code size will be smaller.
3a69a7d5
MM
7420
7421@item -mno-tablejump
7422Do not generate tablejump insns which sometimes increase code size.
7423
7424@item -mtiny-stack
7425Change only the low 8 bits of the stack pointer.
052a4b28
DC
7426@end table
7427
789a3090
NC
7428@node MCore Options
7429@subsection MCore Options
7430@cindex MCore options
7431
7432These are the @samp{-m} options defined for the Motorola M*Core
7433processors.
7434
7435@table @code
7436
7437@item -mhardlit
7438@itemx -mhardlit
7439@itemx -mno-hardlit
7440Inline constants into the code stream if it can be done in two
7441instructions or less.
7442
7443@item -mdiv
7444@itemx -mdiv
7445@itemx -mno-div
7446Use the divide instruction. (Enabled by default).
7447
7448@item -mrelax-immediate
7449@itemx -mrelax-immediate
7450@itemx -mno-relax-immediate
b192711e 7451Allow arbitrary sized immediates in bit operations.
789a3090
NC
7452
7453@item -mwide-bitfields
7454@itemx -mwide-bitfields
7455@itemx -mno-wide-bitfields
7456Always treat bitfields as int-sized.
7457
7458@item -m4byte-functions
7459@itemx -m4byte-functions
7460@itemx -mno-4byte-functions
b192711e 7461Force all functions to be aligned to a four byte boundary.
789a3090
NC
7462
7463@item -mcallgraph-data
7464@itemx -mcallgraph-data
7465@itemx -mno-callgraph-data
7466Emit callgraph information.
7467
7468@item -mslow-bytes
7469@itemx -mslow-bytes
7470@itemx -mno-slow-bytes
7471Prefer word access when reading byte quantities.
7472
7473@item -mlittle-endian
7474@itemx -mlittle-endian
7475@itemx -mbig-endian
b192711e 7476Generate code for a little endian target.
789a3090
NC
7477
7478@item -m210
7479@itemx -m210
7480@itemx -m340
7481Generate code for the 210 processor.
789a3090 7482@end table
83575957 7483
e8ad90e5
MM
7484@node D30V Options
7485@subsection D30V Options
7486@cindex D30V Options
7487
7488These @samp{-m} options are defined for D30V implementations:
7489
7490@table @code
7491@item -mextmem
7492Link the @samp{.text}, @samp{.data}, @samp{.bss}, @samp{.strings},
7493@samp{.rodata}, @samp{.rodata1}, @samp{.data1} sections into external
7494memory, which starts at location @code{0x80000000}.
7495
7496@item -mextmemory
7497Same as the @samp{-mextmem} switch.
7498
7499@item -monchip
7500Link the @samp{.text} section into onchip text memory, which starts at
7501location @code{0x0}. Also link @samp{.data}, @samp{.bss},
7502@samp{.strings}, @samp{.rodata}, @samp{.rodata1}, @samp{.data1} sections
7503into onchip data memory, which starts at location @code{0x20000000}.
7504
7505@item -mno-asm-optimize
7506@itemx -masm-optimize
7507Disable (enable) passing @samp{-O} to the assembler when optimizing.
7508The assembler uses the @samp{-O} option to automatically parallelize
7509adjacent short instructions where possible.
7510
7511@item -mbranch-cost=@var{n}
7512Increase the internal costs of branches to @var{n}. Higher costs means
7513that the compiler will issue more instructions to avoid doing a branch.
7514The default is 2.
7515
7516@item -mcond-exec=@var{n}
7517Specify the maximum number of conditionally executed instructions that
7518replace a branch. The default is 4.
7519@end table
56b2d7a7 7520
74291a4b
MM
7521@node Code Gen Options
7522@section Options for Code Generation Conventions
7523@cindex code generation conventions
7524@cindex options, code generation
7525@cindex run-time options
7526
7527These machine-independent options control the interface conventions
7528used in code generation.
7529
7530Most of them have both positive and negative forms; the negative form
7531of @samp{-ffoo} would be @samp{-fno-foo}. In the table below, only
7532one of the forms is listed---the one which is not the default. You
7533can figure out the other form by either removing @samp{no-} or adding
7534it.
7535
7536@table @code
956d6950 7537@item -fexceptions
89ed4e9d 7538Enable exception handling. Generates extra code needed to propagate
c5c76735
JL
7539exceptions. For some targets, this implies GNU CC will generate frame
7540unwind information for all functions, which can produce significant data
7541size overhead, although it does not affect execution. If you do not
7542specify this option, GNU CC will enable it by default for languages like
7543C++ which normally require exception handling, and disable itfor
7544languages like C that do not normally require it. However, you may need
7545to enable this option when compiling C code that needs to interoperate
7546properly with exception handlers written in C++. You may also wish to
7547disable this option if you are compiling older C++ programs that don't
7548use exception handling.
956d6950 7549
14a774a9
RK
7550@item -funwind-tables
7551Similar to @code{-fexceptions}, except that it will just generate any needed
7552static data, but will not affect the generated code in any other way.
7553You will normally not enable this option; instead, a language processor
7554that needs this handling would enable it on your behalf.
7555
74291a4b
MM
7556@item -fpcc-struct-return
7557Return ``short'' @code{struct} and @code{union} values in memory like
7558longer ones, rather than in registers. This convention is less
7559efficient, but it has the advantage of allowing intercallability between
0c2d1a2a 7560GCC-compiled files and files compiled with other compilers.
74291a4b
MM
7561
7562The precise convention for returning structures in memory depends
7563on the target configuration macros.
7564
7565Short structures and unions are those whose size and alignment match
7566that of some integer type.
7567
7568@item -freg-struct-return
7569Use the convention that @code{struct} and @code{union} values are
7570returned in registers when possible. This is more efficient for small
7571structures than @samp{-fpcc-struct-return}.
7572
7573If you specify neither @samp{-fpcc-struct-return} nor its contrary
0c2d1a2a
JB
7574@samp{-freg-struct-return}, GCC defaults to whichever convention is
7575standard for the target. If there is no standard convention, GCC
7576defaults to @samp{-fpcc-struct-return}, except on targets where GCC
74291a4b
MM
7577is the principal compiler. In those cases, we can choose the standard,
7578and we chose the more efficient register return alternative.
7579
7580@item -fshort-enums
7581Allocate to an @code{enum} type only as many bytes as it needs for the
7582declared range of possible values. Specifically, the @code{enum} type
7583will be equivalent to the smallest integer type which has enough room.
7584
7585@item -fshort-double
7586Use the same size for @code{double} as for @code{float}.
7587
7588@item -fshared-data
7589Requests that the data and non-@code{const} variables of this
7590compilation be shared data rather than private data. The distinction
7591makes sense only on certain operating systems, where shared data is
7592shared between processes running the same program, while private data
7593exists in one copy per process.
7594
7595@item -fno-common
c5c76735 7596Allocate even uninitialized global variables in the data section of the
74291a4b
MM
7597object file, rather than generating them as common blocks. This has the
7598effect that if the same variable is declared (without @code{extern}) in
7599two different compilations, you will get an error when you link them.
7600The only reason this might be useful is if you wish to verify that the
7601program will work on other systems which always work this way.
7602
7603@item -fno-ident
7604Ignore the @samp{#ident} directive.
7605
7606@item -fno-gnu-linker
7607Do not output global initializations (such as C++ constructors and
7608destructors) in the form used by the GNU linker (on systems where the GNU
7609linker is the standard method of handling them). Use this option when
7610you want to use a non-GNU linker, which also requires using the
7611@code{collect2} program to make sure the system linker includes
0c2d1a2a 7612constructors and destructors. (@code{collect2} is included in the GCC
74291a4b
MM
7613distribution.) For systems which @emph{must} use @code{collect2}, the
7614compiler driver @code{gcc} is configured to do this automatically.
7615
7616@item -finhibit-size-directive
7617Don't output a @code{.size} assembler directive, or anything else that
7618would cause trouble if the function is split in the middle, and the
7619two halves are placed at locations far apart in memory. This option is
7620used when compiling @file{crtstuff.c}; you should not need to use it
7621for anything else.
7622
7623@item -fverbose-asm
7624Put extra commentary information in the generated assembly code to
7625make it more readable. This option is generally only of use to those
7626who actually need to read the generated assembly code (perhaps while
7627debugging the compiler itself).
7628
c85f7c16 7629@samp{-fno-verbose-asm}, the default, causes the
74291a4b
MM
7630extra information to be omitted and is useful when comparing two assembler
7631files.
7632
7633@item -fvolatile
7634Consider all memory references through pointers to be volatile.
7635
7636@item -fvolatile-global
7637Consider all memory references to extern and global data items to
0c2d1a2a 7638be volatile. GCC does not consider static data items to be volatile
ab87f8c8
JL
7639because of this switch.
7640
7641@item -fvolatile-static
7642Consider all memory references to static data to be volatile.
74291a4b
MM
7643
7644@item -fpic
7645@cindex global offset table
7646@cindex PIC
7647Generate position-independent code (PIC) suitable for use in a shared
7648library, if supported for the target machine. Such code accesses all
861bb6c1
JL
7649constant addresses through a global offset table (GOT). The dynamic
7650loader resolves the GOT entries when the program starts (the dynamic
0c2d1a2a 7651loader is not part of GCC; it is part of the operating system). If
861bb6c1
JL
7652the GOT size for the linked executable exceeds a machine-specific
7653maximum size, you get an error message from the linker indicating that
7654@samp{-fpic} does not work; in that case, recompile with @samp{-fPIC}
7655instead. (These maximums are 16k on the m88k, 8k on the Sparc, and 32k
7656on the m68k and RS/6000. The 386 has no such limit.)
74291a4b
MM
7657
7658Position-independent code requires special support, and therefore works
0c2d1a2a 7659only on certain machines. For the 386, GCC supports PIC for System V
74291a4b
MM
7660but not for the Sun 386i. Code generated for the IBM RS/6000 is always
7661position-independent.
7662
74291a4b
MM
7663@item -fPIC
7664If supported for the target machine, emit position-independent code,
7665suitable for dynamic linking and avoiding any limit on the size of the
7666global offset table. This option makes a difference on the m68k, m88k,
7667and the Sparc.
7668
7669Position-independent code requires special support, and therefore works
7670only on certain machines.
7671
7672@item -ffixed-@var{reg}
7673Treat the register named @var{reg} as a fixed register; generated code
7674should never refer to it (except perhaps as a stack pointer, frame
7675pointer or in some other fixed role).
7676
7677@var{reg} must be the name of a register. The register names accepted
7678are machine-specific and are defined in the @code{REGISTER_NAMES}
7679macro in the machine description macro file.
7680
7681This flag does not have a negative form, because it specifies a
7682three-way choice.
7683
7684@item -fcall-used-@var{reg}
956d6950 7685Treat the register named @var{reg} as an allocable register that is
74291a4b
MM
7686clobbered by function calls. It may be allocated for temporaries or
7687variables that do not live across a call. Functions compiled this way
7688will not save and restore the register @var{reg}.
7689
cb2fdc84
GRK
7690It is an error to used this flag with the frame pointer or stack pointer.
7691Use of this flag for other registers that have fixed pervasive roles in
7692the machine's execution model will produce disastrous results.
74291a4b
MM
7693
7694This flag does not have a negative form, because it specifies a
7695three-way choice.
7696
7697@item -fcall-saved-@var{reg}
956d6950 7698Treat the register named @var{reg} as an allocable register saved by
74291a4b
MM
7699functions. It may be allocated even for temporaries or variables that
7700live across a call. Functions compiled this way will save and restore
7701the register @var{reg} if they use it.
7702
cb2fdc84
GRK
7703It is an error to used this flag with the frame pointer or stack pointer.
7704Use of this flag for other registers that have fixed pervasive roles in
7705the machine's execution model will produce disastrous results.
74291a4b
MM
7706
7707A different sort of disaster will result from the use of this flag for
7708a register in which function values may be returned.
7709
7710This flag does not have a negative form, because it specifies a
7711three-way choice.
7712
7713@item -fpack-struct
7714Pack all structure members together without holes. Usually you would
7715not want to use this option, since it makes the code suboptimal, and
7716the offsets of structure members won't agree with system libraries.
7717
861bb6c1 7718@item -fcheck-memory-usage
0c2d1a2a 7719Generate extra code to check each memory access. GCC will generate
861bb6c1 7720code that is suitable for a detector of bad memory accesses such as
7d384cc0 7721@file{Checker}.
861bb6c1 7722
d3111037
CB
7723Normally, you should compile all, or none, of your code with this option.
7724
7725If you do mix code compiled with and without this option,
7726you must ensure that all code that has side effects
7727and that is called by code compiled with this option
7728is, itself, compiled with this option.
7729If you do not, you might get erroneous messages from the detector.
7730
861bb6c1 7731If you use functions from a library that have side-effects (such as
d3111037 7732@code{read}), you might not be able to recompile the library and
861bb6c1 7733specify this option. In that case, you can enable the
0c2d1a2a 7734@samp{-fprefix-function-name} option, which requests GCC to encapsulate
861bb6c1
JL
7735your code and make other functions look as if they were compiled with
7736@samp{-fcheck-memory-usage}. This is done by calling ``stubs'',
7737which are provided by the detector. If you cannot find or build
d3111037 7738stubs for every function you call, you might have to specify
861bb6c1
JL
7739@samp{-fcheck-memory-usage} without @samp{-fprefix-function-name}.
7740
7d384cc0 7741If you specify this option, you can not use the @code{asm} or
c5c76735
JL
7742@code{__asm__} keywords in functions with memory checking enabled. GNU
7743CC cannot understand what the @code{asm} statement may do, and therefore
7744cannot generate the appropriate code, so it will reject it. However, if
7745you specify the function attribute @code{no_check_memory_usage} (see
7746@pxref{Function Attributes}, GNU CC will disable memory checking within a
7747function; you may use @code{asm} statements inside such functions. You
7748may have an inline expansion of a non-checked function within a checked
7749function; in that case GNU CC will not generate checks for the inlined
7750function's memory accesses.
7751
7752If you move your @code{asm} statements to non-checked inline functions
7753and they do access memory, you can add calls to the support code in your
7d384cc0
KR
7754inline function, to indicate any reads, writes, or copies being done.
7755These calls would be similar to those done in the stubs described above.
7756
861bb6c1 7757@item -fprefix-function-name
0c2d1a2a
JB
7758Request GCC to add a prefix to the symbols generated for function names.
7759GCC adds a prefix to the names of functions defined as well as
861bb6c1 7760functions called. Code compiled with this option and code compiled
d3111037 7761without the option can't be linked together, unless stubs are used.
861bb6c1
JL
7762
7763If you compile the following code with @samp{-fprefix-function-name}
7764@example
7765extern void bar (int);
7766void
7767foo (int a)
7768@{
7769 return bar (a + 5);
861bb6c1
JL
7770@}
7771@end example
7772
7773@noindent
0c2d1a2a 7774GCC will compile the code as if it was written:
861bb6c1
JL
7775@example
7776extern void prefix_bar (int);
7777void
7778prefix_foo (int a)
7779@{
7780 return prefix_bar (a + 5);
7781@}
7782@end example
7783This option is designed to be used with @samp{-fcheck-memory-usage}.
7784
07417085
KR
7785@item -finstrument-functions
7786Generate instrumentation calls for entry and exit to functions. Just
7787after function entry and just before function exit, the following
7788profiling functions will be called with the address of the current
7789function and its call site. (On some platforms,
7790@code{__builtin_return_address} does not work beyond the current
7791function, so the call site information may not be available to the
7792profiling functions otherwise.)
7793
7794@example
7795void __cyg_profile_func_enter (void *this_fn, void *call_site);
7796void __cyg_profile_func_exit (void *this_fn, void *call_site);
7797@end example
7798
7799The first argument is the address of the start of the current function,
7800which may be looked up exactly in the symbol table.
7801
7802This instrumentation is also done for functions expanded inline in other
7803functions. The profiling calls will indicate where, conceptually, the
7804inline function is entered and exited. This means that addressable
7805versions of such functions must be available. If all your uses of a
7806function are expanded inline, this may mean an additional expansion of
7807code size. If you use @samp{extern inline} in your C code, an
7808addressable version of such functions must be provided. (This is
7809normally the case anyways, but if you get lucky and the optimizer always
7810expands the functions inline, you might have gotten away without
7811providing static copies.)
7812
7813A function may be given the attribute @code{no_instrument_function}, in
7814which case this instrumentation will not be done. This can be used, for
7815example, for the profiling functions listed above, high-priority
7816interrupt routines, and any functions from which the profiling functions
7817cannot safely be called (perhaps signal handlers, if the profiling
7818routines generate output or allocate memory).
7819
861bb6c1
JL
7820@item -fstack-check
7821Generate code to verify that you do not go beyond the boundary of the
7822stack. You should specify this flag if you are running in an
7823environment with multiple threads, but only rarely need to specify it in
7824a single-threaded environment since stack overflow is automatically
7825detected on nearly all systems if there is only one stack.
7826
a157febd
GK
7827Note that this switch does not actually cause checking to be done; the
7828operating system must do that. The switch causes generation of code
7829to ensure that the operating system sees the stack being extended.
7830
7831@item -fstack-limit-register=@var{reg}
7832@itemx -fstack-limit-symbol=@var{sym}
7833@itemx -fno-stack-limit
7834Generate code to ensure that the stack does not grow beyond a certain value,
7835either the value of a register or the address of a symbol. If the stack
7836would grow beyond the value, a signal is raised. For most targets,
7837the signal is raised before the stack overruns the boundary, so
7838it is possible to catch the signal without taking special precautions.
7839
7840For instance, if the stack starts at address @samp{0x80000000} and grows
7841downwards you can use the flags
7842@samp{-fstack-limit-symbol=__stack_limit}
7843@samp{-Wl,--defsym,__stack_limit=0x7ffe0000} which will enforce a stack
7844limit of 128K.
7845
e5eb27e5
JL
7846@cindex aliasing of parameters
7847@cindex parameters, aliased
7848@item -fargument-alias
04afd9d6
JL
7849@itemx -fargument-noalias
7850@itemx -fargument-noalias-global
e5eb27e5
JL
7851Specify the possible relationships among parameters and between
7852parameters and global data.
7853
7854@samp{-fargument-alias} specifies that arguments (parameters) may
7855alias each other and may alias global storage.
7856@samp{-fargument-noalias} specifies that arguments do not alias
7857each other, but may alias global storage.
7858@samp{-fargument-noalias-global} specifies that arguments do not
7859alias each other and do not alias global storage.
7860
7861Each language will automatically use whatever option is required by
7862the language standard. You should not need to use these options yourself.
19283265
RH
7863
7864@item -fleading-underscore
7865This option and its counterpart, -fno-leading-underscore, forcibly
7866change the way C symbols are represented in the object file. One use
7867is to help link with legacy assembly code.
7868
7869Be warned that you should know what you are doing when invoking this
7870option, and that not all targets provide complete support for it.
74291a4b
MM
7871@end table
7872
7873@node Environment Variables
0c2d1a2a 7874@section Environment Variables Affecting GCC
74291a4b
MM
7875@cindex environment variables
7876
0c2d1a2a
JB
7877This section describes several environment variables that affect how GCC
7878operates. Some of them work by specifying directories or prefixes to use
56f48ce9 7879when searching for various kinds of files. Some are used to specify other
46103ab4 7880aspects of the compilation environment.
74291a4b
MM
7881
7882@ifclear INTERNALS
7883Note that you can also specify places to search using options such as
7884@samp{-B}, @samp{-I} and @samp{-L} (@pxref{Directory Options}). These
7885take precedence over places specified using environment variables, which
0c2d1a2a
JB
7886in turn take precedence over those specified by the configuration of GCC.
7887
74291a4b
MM
7888@end ifclear
7889@ifset INTERNALS
7890Note that you can also specify places to search using options such as
7891@samp{-B}, @samp{-I} and @samp{-L} (@pxref{Directory Options}). These
7892take precedence over places specified using environment variables, which
0c2d1a2a
JB
7893in turn take precedence over those specified by the configuration of GCC.
7894@xref{Driver}.
74291a4b
MM
7895@end ifset
7896
7897@table @code
ab87f8c8
JL
7898@item LANG
7899@itemx LC_CTYPE
7900@c @itemx LC_COLLATE
7901@itemx LC_MESSAGES
7902@c @itemx LC_MONETARY
7903@c @itemx LC_NUMERIC
7904@c @itemx LC_TIME
7905@itemx LC_ALL
7906@findex LANG
7907@findex LC_CTYPE
7908@c @findex LC_COLLATE
7909@findex LC_MESSAGES
7910@c @findex LC_MONETARY
7911@c @findex LC_NUMERIC
7912@c @findex LC_TIME
7913@findex LC_ALL
7914@cindex locale
0c2d1a2a
JB
7915These environment variables control the way that GCC uses
7916localization information that allow GCC to work with different
7917national conventions. GCC inspects the locale categories
ab87f8c8
JL
7918@code{LC_CTYPE} and @code{LC_MESSAGES} if it has been configured to do
7919so. These locale categories can be set to any value supported by your
7920installation. A typical value is @samp{en_UK} for English in the United
7921Kingdom.
7922
7923The @code{LC_CTYPE} environment variable specifies character
0c2d1a2a 7924classification. GCC uses it to determine the character boundaries in
ab87f8c8
JL
7925a string; this is needed for some multibyte encodings that contain quote
7926and escape characters that would otherwise be interpreted as a string
7927end or escape.
7928
7929The @code{LC_MESSAGES} environment variable specifies the language to
7930use in diagnostic messages.
7931
7932If the @code{LC_ALL} environment variable is set, it overrides the value
7933of @code{LC_CTYPE} and @code{LC_MESSAGES}; otherwise, @code{LC_CTYPE}
7934and @code{LC_MESSAGES} default to the value of the @code{LANG}
0c2d1a2a 7935environment variable. If none of these variables are set, GCC
ab87f8c8
JL
7936defaults to traditional C English behavior.
7937
74291a4b
MM
7938@item TMPDIR
7939@findex TMPDIR
7940If @code{TMPDIR} is set, it specifies the directory to use for temporary
0c2d1a2a 7941files. GCC uses temporary files to hold the output of one stage of
74291a4b
MM
7942compilation which is to be used as input to the next stage: for example,
7943the output of the preprocessor, which is the input to the compiler
7944proper.
7945
7946@item GCC_EXEC_PREFIX
7947@findex GCC_EXEC_PREFIX
7948If @code{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
7949names of the subprograms executed by the compiler. No slash is added
7950when this prefix is combined with the name of a subprogram, but you can
7951specify a prefix that ends with a slash if you wish.
7952
0deb20df
TT
7953If @code{GCC_EXEC_PREFIX} is not set, GNU CC will attempt to figure out
7954an appropriate prefix to use based on the pathname it was invoked with.
7955
0c2d1a2a 7956If GCC cannot find the subprogram using the specified prefix, it
74291a4b
MM
7957tries looking in the usual places for the subprogram.
7958
7959The default value of @code{GCC_EXEC_PREFIX} is
7960@file{@var{prefix}/lib/gcc-lib/} where @var{prefix} is the value
7961of @code{prefix} when you ran the @file{configure} script.
7962
7963Other prefixes specified with @samp{-B} take precedence over this prefix.
7964
7965This prefix is also used for finding files such as @file{crt0.o} that are
7966used for linking.
7967
7968In addition, the prefix is used in an unusual way in finding the
7969directories to search for header files. For each of the standard
7970directories whose name normally begins with @samp{/usr/local/lib/gcc-lib}
0c2d1a2a 7971(more precisely, with the value of @code{GCC_INCLUDE_DIR}), GCC tries
74291a4b 7972replacing that beginning with the specified prefix to produce an
0c2d1a2a 7973alternate directory name. Thus, with @samp{-Bfoo/}, GCC will search
74291a4b
MM
7974@file{foo/bar} where it would normally search @file{/usr/local/lib/bar}.
7975These alternate directories are searched first; the standard directories
7976come next.
7977
7978@item COMPILER_PATH
7979@findex COMPILER_PATH
7980The value of @code{COMPILER_PATH} is a colon-separated list of
0c2d1a2a 7981directories, much like @code{PATH}. GCC tries the directories thus
74291a4b
MM
7982specified when searching for subprograms, if it can't find the
7983subprograms using @code{GCC_EXEC_PREFIX}.
7984
7985@item LIBRARY_PATH
7986@findex LIBRARY_PATH
7987The value of @code{LIBRARY_PATH} is a colon-separated list of
7988directories, much like @code{PATH}. When configured as a native compiler,
0c2d1a2a 7989GCC tries the directories thus specified when searching for special
74291a4b 7990linker files, if it can't find them using @code{GCC_EXEC_PREFIX}. Linking
0c2d1a2a 7991using GCC also uses these directories when searching for ordinary
74291a4b
MM
7992libraries for the @samp{-l} option (but directories specified with
7993@samp{-L} come first).
7994
7995@item C_INCLUDE_PATH
7996@itemx CPLUS_INCLUDE_PATH
7997@itemx OBJC_INCLUDE_PATH
7998@findex C_INCLUDE_PATH
7999@findex CPLUS_INCLUDE_PATH
8000@findex OBJC_INCLUDE_PATH
8001@c @itemx OBJCPLUS_INCLUDE_PATH
8002These environment variables pertain to particular languages. Each
8003variable's value is a colon-separated list of directories, much like
0c2d1a2a 8004@code{PATH}. When GCC searches for header files, it tries the
74291a4b
MM
8005directories listed in the variable for the language you are using, after
8006the directories specified with @samp{-I} but before the standard header
8007file directories.
8008
8009@item DEPENDENCIES_OUTPUT
8010@findex DEPENDENCIES_OUTPUT
8011@cindex dependencies for make as output
8012If this variable is set, its value specifies how to output dependencies
8013for Make based on the header files processed by the compiler. This
8014output looks much like the output from the @samp{-M} option
8015(@pxref{Preprocessor Options}), but it goes to a separate file, and is
8016in addition to the usual results of compilation.
8017
8018The value of @code{DEPENDENCIES_OUTPUT} can be just a file name, in
8019which case the Make rules are written to that file, guessing the target
8020name from the source file name. Or the value can have the form
8021@samp{@var{file} @var{target}}, in which case the rules are written to
8022file @var{file} using @var{target} as the target name.
56f48ce9
DB
8023
8024@item LANG
8025@findex LANG
8026@cindex locale definition
8027This variable is used to pass locale information to the compiler. One way in
8028which this information is used is to determine the character set to be used
8029when character literals, string literals and comments are parsed in C and C++.
8030When the compiler is configured to allow multibyte characters,
8031the following values for @code{LANG} are recognized:
8032
8033@table @code
8034@item C-JIS
8035Recognize JIS characters.
8036@item C-SJIS
8037Recognize SJIS characters.
8038@item C-EUCJP
8039Recognize EUCJP characters.
8040@end table
8041
46103ab4 8042If @code{LANG} is not defined, or if it has some other value, then the
56f48ce9
DB
8043compiler will use mblen and mbtowc as defined by the default locale to
8044recognize and translate multibyte characters.
74291a4b
MM
8045@end table
8046
9d86bffc
JM
8047@c man end
8048
74291a4b
MM
8049@node Running Protoize
8050@section Running Protoize
8051
8052The program @code{protoize} is an optional part of GNU C. You can use
c1030c7c 8053it to add prototypes to a program, thus converting the program to ISO
74291a4b
MM
8054C in one respect. The companion program @code{unprotoize} does the
8055reverse: it removes argument types from any prototypes that are found.
8056
8057When you run these programs, you must specify a set of source files as
8058command line arguments. The conversion programs start out by compiling
8059these files to see what functions they define. The information gathered
8060about a file @var{foo} is saved in a file named @file{@var{foo}.X}.
8061
8062After scanning comes actual conversion. The specified files are all
8063eligible to be converted; any files they include (whether sources or
8064just headers) are eligible as well.
8065
8066But not all the eligible files are converted. By default,
8067@code{protoize} and @code{unprotoize} convert only source and header
8068files in the current directory. You can specify additional directories
8069whose files should be converted with the @samp{-d @var{directory}}
8070option. You can also specify particular files to exclude with the
8071@samp{-x @var{file}} option. A file is converted if it is eligible, its
8072directory name matches one of the specified directory names, and its
8073name within the directory has not been excluded.
8074
8075Basic conversion with @code{protoize} consists of rewriting most
8076function definitions and function declarations to specify the types of
8077the arguments. The only ones not rewritten are those for varargs
8078functions.
8079
8080@code{protoize} optionally inserts prototype declarations at the
8081beginning of the source file, to make them available for any calls that
8082precede the function's definition. Or it can insert prototype
8083declarations with block scope in the blocks where undeclared functions
8084are called.
8085
8086Basic conversion with @code{unprotoize} consists of rewriting most
8087function declarations to remove any argument types, and rewriting
c1030c7c 8088function definitions to the old-style pre-ISO form.
74291a4b
MM
8089
8090Both conversion programs print a warning for any function declaration or
8091definition that they can't convert. You can suppress these warnings
8092with @samp{-q}.
8093
8094The output from @code{protoize} or @code{unprotoize} replaces the
8095original source file. The original file is renamed to a name ending
a7db8bbb
MK
8096with @samp{.save} (for DOS, the saved filename ends in @samp{.sav}
8097without the original @samp{.c} suffix). If the @samp{.save} (@samp{.sav}
8098for DOS) file already exists, then the source file is simply discarded.
74291a4b 8099
0c2d1a2a 8100@code{protoize} and @code{unprotoize} both depend on GCC itself to
74291a4b 8101scan the program and collect information about the functions it uses.
0c2d1a2a 8102So neither of these programs will work until GCC is installed.
74291a4b
MM
8103
8104Here is a table of the options you can use with @code{protoize} and
8105@code{unprotoize}. Each option works with both programs unless
8106otherwise stated.
8107
8108@table @code
8109@item -B @var{directory}
8110Look for the file @file{SYSCALLS.c.X} in @var{directory}, instead of the
8111usual directory (normally @file{/usr/local/lib}). This file contains
8112prototype information about standard system functions. This option
8113applies only to @code{protoize}.
8114
8115@item -c @var{compilation-options}
8116Use @var{compilation-options} as the options when running @code{gcc} to
8117produce the @samp{.X} files. The special option @samp{-aux-info} is
8118always passed in addition, to tell @code{gcc} to write a @samp{.X} file.
8119
8120Note that the compilation options must be given as a single argument to
8121@code{protoize} or @code{unprotoize}. If you want to specify several
8122@code{gcc} options, you must quote the entire set of compilation options
8123to make them a single word in the shell.
8124
8125There are certain @code{gcc} arguments that you cannot use, because they
8126would produce the wrong kind of output. These include @samp{-g},
8127@samp{-O}, @samp{-c}, @samp{-S}, and @samp{-o} If you include these in
8128the @var{compilation-options}, they are ignored.
8129
8130@item -C
a7db8bbb
MK
8131Rename files to end in @samp{.C} (@samp{.cc} for DOS-based file
8132systems) instead of @samp{.c}. This is convenient if you are converting
ee77eda5 8133a C program to C++. This option applies only to @code{protoize}.
74291a4b
MM
8134
8135@item -g
8136Add explicit global declarations. This means inserting explicit
8137declarations at the beginning of each source file for each function
8138that is called in the file and was not declared. These declarations
8139precede the first function definition that contains a call to an
8140undeclared function. This option applies only to @code{protoize}.
8141
8142@item -i @var{string}
8143Indent old-style parameter declarations with the string @var{string}.
8144This option applies only to @code{protoize}.
8145
8146@code{unprotoize} converts prototyped function definitions to old-style
8147function definitions, where the arguments are declared between the
8148argument list and the initial @samp{@{}. By default, @code{unprotoize}
8149uses five spaces as the indentation. If you want to indent with just
8150one space instead, use @samp{-i " "}.
8151
8152@item -k
8153Keep the @samp{.X} files. Normally, they are deleted after conversion
8154is finished.
8155
8156@item -l
8157Add explicit local declarations. @code{protoize} with @samp{-l} inserts
8158a prototype declaration for each function in each block which calls the
8159function without any declaration. This option applies only to
8160@code{protoize}.
8161
8162@item -n
8163Make no real changes. This mode just prints information about the conversions
8164that would have been done without @samp{-n}.
8165
8166@item -N
8167Make no @samp{.save} files. The original files are simply deleted.
8168Use this option with caution.
8169
8170@item -p @var{program}
8171Use the program @var{program} as the compiler. Normally, the name
8172@file{gcc} is used.
8173
8174@item -q
8175Work quietly. Most warnings are suppressed.
8176
8177@item -v
8178Print the version number, just like @samp{-v} for @code{gcc}.
8179@end table
8180
8181If you need special compiler options to compile one of your program's
8182source files, then you should generate that file's @samp{.X} file
8183specially, by running @code{gcc} on that source file with the
8184appropriate options and the option @samp{-aux-info}. Then run
8185@code{protoize} on the entire set of files. @code{protoize} will use
8186the existing @samp{.X} file because it is newer than the source file.
8187For example:
8188
8189@example
8190gcc -Dfoo=bar file1.c -aux-info
8191protoize *.c
8192@end example
8193
8194@noindent
8195You need to include the special files along with the rest in the
8196@code{protoize} command, even though their @samp{.X} files already
8197exist, because otherwise they won't get converted.
8198
8199@xref{Protoize Caveats}, for more information on how to use
8200@code{protoize} successfully.
8201
This page took 1.752452 seconds and 5 git commands to generate.