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