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