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