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