]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/invoke.texi
ff1e34a3b34c9cb95e1c534c59d8526742f39c7e
[thirdparty/gcc.git] / gcc / doc / invoke.texi
1 @c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2 @c 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
5
6 @ignore
7 @c man begin COPYRIGHT
8 Copyright @copyright{} 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
9 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
10
11 Permission is granted to copy, distribute and/or modify this document
12 under the terms of the GNU Free Documentation License, Version 1.2 or
13 any later version published by the Free Software Foundation; with the
14 Invariant Sections being ``GNU General Public License'' and ``Funding
15 Free Software'', the Front-Cover texts being (a) (see below), and with
16 the Back-Cover Texts being (b) (see below). A copy of the license is
17 included in the gfdl(7) man page.
18
19 (a) The FSF's Front-Cover Text is:
20
21 A GNU Manual
22
23 (b) The FSF's Back-Cover Text is:
24
25 You have freedom to copy and modify this GNU Manual, like GNU
26 software. Copies published by the Free Software Foundation raise
27 funds for GNU development.
28 @c man end
29 @c Set file name and title for the man page.
30 @setfilename gcc
31 @settitle GNU project C and C++ compiler
32 @c man begin SYNOPSIS
33 gcc [@option{-c}|@option{-S}|@option{-E}] [@option{-std=}@var{standard}]
34 [@option{-g}] [@option{-pg}] [@option{-O}@var{level}]
35 [@option{-W}@var{warn}@dots{}] [@option{-pedantic}]
36 [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
37 [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
38 [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}]
39 [@option{-o} @var{outfile}] @var{infile}@dots{}
40
41 Only the most useful options are listed here; see below for the
42 remainder. @samp{g++} accepts mostly the same options as @samp{gcc}.
43 @c man end
44 @c man begin SEEALSO
45 gpl(7), gfdl(7), fsf-funding(7),
46 cpp(1), gcov(1), g77(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1)
47 and the Info entries for @file{gcc}, @file{cpp}, @file{g77}, @file{as},
48 @file{ld}, @file{binutils} and @file{gdb}.
49 @c man end
50 @c man begin BUGS
51 For instructions on reporting bugs, see
52 @w{@uref{http://gcc.gnu.org/bugs.html}}. Use of the @command{gccbug}
53 script to report bugs is recommended.
54 @c man end
55 @c man begin AUTHOR
56 See the Info entry for @command{gcc}, or
57 @w{@uref{http://gcc.gnu.org/onlinedocs/gcc/Contributors.html}},
58 for contributors to GCC@.
59 @c man end
60 @end ignore
61
62 @node Invoking GCC
63 @chapter GCC Command Options
64 @cindex GCC command options
65 @cindex command options
66 @cindex options, GCC command
67
68 @c man begin DESCRIPTION
69 When you invoke GCC, it normally does preprocessing, compilation,
70 assembly and linking. The ``overall options'' allow you to stop this
71 process at an intermediate stage. For example, the @option{-c} option
72 says not to run the linker. Then the output consists of object files
73 output by the assembler.
74
75 Other options are passed on to one stage of processing. Some options
76 control the preprocessor and others the compiler itself. Yet other
77 options control the assembler and linker; most of these are not
78 documented here, since you rarely need to use any of them.
79
80 @cindex C compilation options
81 Most of the command line options that you can use with GCC are useful
82 for C programs; when an option is only useful with another language
83 (usually C++), the explanation says so explicitly. If the description
84 for a particular option does not mention a source language, you can use
85 that option with all supported languages.
86
87 @cindex C++ compilation options
88 @xref{Invoking G++,,Compiling C++ Programs}, for a summary of special
89 options for compiling C++ programs.
90
91 @cindex grouping options
92 @cindex options, grouping
93 The @command{gcc} program accepts options and file names as operands. Many
94 options have multi-letter names; therefore multiple single-letter options
95 may @emph{not} be grouped: @option{-dr} is very different from @w{@samp{-d
96 -r}}.
97
98 @cindex order of options
99 @cindex options, order
100 You can mix options and other arguments. For the most part, the order
101 you use doesn't matter. Order does matter when you use several options
102 of the same kind; for example, if you specify @option{-L} more than once,
103 the directories are searched in the order specified.
104
105 Many options have long names starting with @samp{-f} or with
106 @samp{-W}---for example, @option{-fforce-mem},
107 @option{-fstrength-reduce}, @option{-Wformat} and so on. Most of
108 these have both positive and negative forms; the negative form of
109 @option{-ffoo} would be @option{-fno-foo}. This manual documents
110 only one of these two forms, whichever one is not the default.
111
112 @c man end
113
114 @xref{Option Index}, for an index to GCC's options.
115
116 @menu
117 * Option Summary:: Brief list of all options, without explanations.
118 * Overall Options:: Controlling the kind of output:
119 an executable, object files, assembler files,
120 or preprocessed source.
121 * Invoking G++:: Compiling C++ programs.
122 * C Dialect Options:: Controlling the variant of C language compiled.
123 * C++ Dialect Options:: Variations on C++.
124 * Objective-C Dialect Options:: Variations on Objective-C.
125 * Language Independent Options:: Controlling how diagnostics should be
126 formatted.
127 * Warning Options:: How picky should the compiler be?
128 * Debugging Options:: Symbol tables, measurements, and debugging dumps.
129 * Optimize Options:: How much optimization?
130 * Preprocessor Options:: Controlling header files and macro definitions.
131 Also, getting dependency information for Make.
132 * Assembler Options:: Passing options to the assembler.
133 * Link Options:: Specifying libraries and so on.
134 * Directory Options:: Where to find header files and libraries.
135 Where to find the compiler executable files.
136 * Spec Files:: How to pass switches to sub-processes.
137 * Target Options:: Running a cross-compiler, or an old version of GCC.
138 * Submodel Options:: Specifying minor hardware or convention variations,
139 such as 68010 vs 68020.
140 * Code Gen Options:: Specifying conventions for function calls, data layout
141 and register usage.
142 * Environment Variables:: Env vars that affect GCC.
143 * Precompiled Headers:: Compiling a header once, and using it many times.
144 * Running Protoize:: Automatically adding or removing function prototypes.
145 @end menu
146
147 @c man begin OPTIONS
148
149 @node Option Summary
150 @section Option Summary
151
152 Here is a summary of all the options, grouped by type. Explanations are
153 in the following sections.
154
155 @table @emph
156 @item Overall Options
157 @xref{Overall Options,,Options Controlling the Kind of Output}.
158 @gccoptlist{-c -S -E -o @var{file} -combine -pipe -pass-exit-codes @gol
159 -x @var{language} -v -### --help --target-help --version}
160
161 @item C Language Options
162 @xref{C Dialect Options,,Options Controlling C Dialect}.
163 @gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename} @gol
164 -fno-asm -fno-builtin -fno-builtin-@var{function} @gol
165 -fhosted -ffreestanding -fms-extensions @gol
166 -trigraphs -no-integrated-cpp -traditional -traditional-cpp @gol
167 -fallow-single-precision -fcond-mismatch @gol
168 -fsigned-bitfields -fsigned-char @gol
169 -funsigned-bitfields -funsigned-char}
170
171 @item C++ Language Options
172 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
173 @gccoptlist{-fabi-version=@var{n} -fno-access-control -fcheck-new @gol
174 -fconserve-space -fno-const-strings @gol
175 -fno-elide-constructors @gol
176 -fno-enforce-eh-specs @gol
177 -ffor-scope -fno-for-scope -fno-gnu-keywords @gol
178 -fno-implicit-templates @gol
179 -fno-implicit-inline-templates @gol
180 -fno-implement-inlines -fms-extensions @gol
181 -fno-nonansi-builtins -fno-operator-names @gol
182 -fno-optional-diags -fpermissive @gol
183 -frepo -fno-rtti -fstats -ftemplate-depth-@var{n} @gol
184 -fuse-cxa-atexit -fno-weak -nostdinc++ @gol
185 -fno-default-inline -Wabi -Wctor-dtor-privacy @gol
186 -Wnon-virtual-dtor -Wreorder @gol
187 -Weffc++ -Wno-deprecated @gol
188 -Wno-non-template-friend -Wold-style-cast @gol
189 -Woverloaded-virtual -Wno-pmf-conversions @gol
190 -Wsign-promo -Wsynth}
191
192 @item Objective-C Language Options
193 @xref{Objective-C Dialect Options,,Options Controlling Objective-C Dialect}.
194 @gccoptlist{
195 -fconstant-string-class=@var{class-name} @gol
196 -fgnu-runtime -fnext-runtime @gol
197 -fno-nil-receivers @gol
198 -fobjc-exceptions @gol
199 -freplace-objc-classes @gol
200 -fzero-link @gol
201 -gen-decls @gol
202 -Wno-protocol -Wselector -Wundeclared-selector}
203
204 @item Language Independent Options
205 @xref{Language Independent Options,,Options to Control Diagnostic Messages Formatting}.
206 @gccoptlist{-fmessage-length=@var{n} @gol
207 -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}}
208
209 @item Warning Options
210 @xref{Warning Options,,Options to Request or Suppress Warnings}.
211 @gccoptlist{-fsyntax-only -pedantic -pedantic-errors @gol
212 -w -Wextra -Wall -Waggregate-return @gol
213 -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
214 -Wconversion -Wno-deprecated-declarations @gol
215 -Wdisabled-optimization -Wno-div-by-zero -Wendif-labels @gol
216 -Werror -Werror-implicit-function-declaration @gol
217 -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
218 -Wno-format-extra-args -Wformat-nonliteral @gol
219 -Wformat-security -Wformat-y2k @gol
220 -Wimplicit -Wimplicit-function-declaration -Wimplicit-int @gol
221 -Wimport -Wno-import -Winit-self -Winline @gol
222 -Wno-invalid-offsetof -Winvalid-pch @gol
223 -Wlarger-than-@var{len} -Wlong-long @gol
224 -Wmain -Wmissing-braces @gol
225 -Wmissing-format-attribute -Wmissing-noreturn @gol
226 -Wno-multichar -Wnonnull -Wpacked -Wpadded @gol
227 -Wparentheses -Wpointer-arith -Wredundant-decls @gol
228 -Wreturn-type -Wsequence-point -Wshadow @gol
229 -Wsign-compare -Wstrict-aliasing -Wstrict-aliasing=2 @gol
230 -Wswitch -Wswitch-default -Wswitch-enum @gol
231 -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized @gol
232 -Wunknown-pragmas -Wunreachable-code @gol
233 -Wunused -Wunused-function -Wunused-label -Wunused-parameter @gol
234 -Wunused-value -Wunused-variable -Wwrite-strings @gol
235 -Wvariadic-macros}
236
237 @item C-only Warning Options
238 @gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol
239 -Wmissing-prototypes -Wnested-externs -Wold-style-definition @gol
240 -Wstrict-prototypes -Wtraditional @gol
241 -Wdeclaration-after-statement}
242
243 @item Debugging Options
244 @xref{Debugging Options,,Options for Debugging Your Program or GCC}.
245 @gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol
246 -fdump-unnumbered -fdump-translation-unit@r{[}-@var{n}@r{]} @gol
247 -fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
248 -fdump-tree-original@r{[}-@var{n}@r{]} @gol
249 -fdump-tree-optimized@r{[}-@var{n}@r{]} @gol
250 -fdump-tree-inlined@r{[}-@var{n}@r{]} @gol
251 -feliminate-dwarf2-dups -feliminate-unused-debug-types @gol
252 -feliminate-unused-debug-symbols -fmem-report -fprofile-arcs @gol
253 -frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
254 -ftest-coverage -ftime-report -fvar-tracking @gol
255 -g -g@var{level} -gcoff -gdwarf-2 @gol
256 -ggdb -gstabs -gstabs+ -gvms -gxcoff -gxcoff+ @gol
257 -p -pg -print-file-name=@var{library} -print-libgcc-file-name @gol
258 -print-multi-directory -print-multi-lib @gol
259 -print-prog-name=@var{program} -print-search-dirs -Q @gol
260 -save-temps -time}
261
262 @item Optimization Options
263 @xref{Optimize Options,,Options that Control Optimization}.
264 @gccoptlist{-falign-functions=@var{n} -falign-jumps=@var{n} @gol
265 -falign-labels=@var{n} -falign-loops=@var{n} @gol
266 -fbranch-probabilities -fprofile-values -fvpt -fbranch-target-load-optimize @gol
267 -fbranch-target-load-optimize2 -fbtr-bb-exclusive @gol
268 -fcaller-saves -fcprop-registers @gol
269 -fcse-follow-jumps -fcse-skip-blocks -fdata-sections @gol
270 -fdelayed-branch -fdelete-null-pointer-checks @gol
271 -fexpensive-optimizations -ffast-math -ffloat-store @gol
272 -fforce-addr -fforce-mem -ffunction-sections @gol
273 -fgcse -fgcse-lm -fgcse-sm -fgcse-las -fgcse-after-reload @gol
274 -floop-optimize -fcrossjumping -fif-conversion -fif-conversion2 @gol
275 -finline-functions -finline-limit=@var{n} -fkeep-inline-functions @gol
276 -fkeep-static-consts -fmerge-constants -fmerge-all-constants @gol
277 -fmove-all-movables -fnew-ra -fno-branch-count-reg @gol
278 -fno-default-inline -fno-defer-pop @gol
279 -fno-function-cse -fno-guess-branch-probability @gol
280 -fno-inline -fno-math-errno -fno-peephole -fno-peephole2 @gol
281 -funsafe-math-optimizations -ffinite-math-only @gol
282 -fno-trapping-math -fno-zero-initialized-in-bss @gol
283 -fomit-frame-pointer -foptimize-register-move @gol
284 -foptimize-sibling-calls -fprefetch-loop-arrays @gol
285 -fprofile-generate -fprofile-use @gol
286 -freduce-all-givs -fregmove -frename-registers @gol
287 -freorder-blocks -freorder-blocks-and-partition -freorder-functions @gol
288 -frerun-cse-after-loop -frerun-loop-opt @gol
289 -frounding-math -fschedule-insns -fschedule-insns2 @gol
290 -fno-sched-interblock -fno-sched-spec -fsched-spec-load @gol
291 -fsched-spec-load-dangerous @gol
292 -fsched-stalled-insns=@var{n} -sched-stalled-insns-dep=@var{n} @gol
293 -fsched2-use-superblocks @gol
294 -fsched2-use-traces -fsignaling-nans @gol
295 -fsingle-precision-constant @gol
296 -fstrength-reduce -fstrict-aliasing -ftracer -fthread-jumps @gol
297 -funroll-all-loops -funroll-loops -fpeel-loops @gol
298 -funswitch-loops -fold-unroll-loops -fold-unroll-all-loops @gol
299 --param @var{name}=@var{value}
300 -O -O0 -O1 -O2 -O3 -Os}
301
302 @item Preprocessor Options
303 @xref{Preprocessor Options,,Options Controlling the Preprocessor}.
304 @gccoptlist{-A@var{question}=@var{answer} @gol
305 -A-@var{question}@r{[}=@var{answer}@r{]} @gol
306 -C -dD -dI -dM -dN @gol
307 -D@var{macro}@r{[}=@var{defn}@r{]} -E -H @gol
308 -idirafter @var{dir} @gol
309 -include @var{file} -imacros @var{file} @gol
310 -iprefix @var{file} -iwithprefix @var{dir} @gol
311 -iwithprefixbefore @var{dir} -isystem @var{dir} @gol
312 -M -MM -MF -MG -MP -MQ -MT -nostdinc @gol
313 -P -fworking-directory -remap @gol
314 -trigraphs -undef -U@var{macro} -Wp,@var{option} @gol
315 -Xpreprocessor @var{option}}
316
317 @item Assembler Option
318 @xref{Assembler Options,,Passing Options to the Assembler}.
319 @gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
320
321 @item Linker Options
322 @xref{Link Options,,Options for Linking}.
323 @gccoptlist{@var{object-file-name} -l@var{library} @gol
324 -nostartfiles -nodefaultlibs -nostdlib -pie @gol
325 -s -static -static-libgcc -shared -shared-libgcc -symbolic @gol
326 -Wl,@var{option} -Xlinker @var{option} @gol
327 -u @var{symbol}}
328
329 @item Directory Options
330 @xref{Directory Options,,Options for Directory Search}.
331 @gccoptlist{-B@var{prefix} -I@var{dir} -iquote@var{dir} -L@var{dir} -specs=@var{file} -I-}
332
333 @item Target Options
334 @c I wrote this xref this way to avoid overfull hbox. -- rms
335 @xref{Target Options}.
336 @gccoptlist{-V @var{version} -b @var{machine}}
337
338 @item Machine Dependent Options
339 @xref{Submodel Options,,Hardware Models and Configurations}.
340
341 @emph{M680x0 Options}
342 @gccoptlist{-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol
343 -m68060 -mcpu32 -m5200 -m68881 -mbitfield -mc68000 -mc68020 @gol
344 -mnobitfield -mrtd -mshort -msoft-float -mpcrel @gol
345 -malign-int -mstrict-align -msep-data -mno-sep-data @gol
346 -mshared-library-id=n -mid-shared-library -mno-id-shared-library}
347
348 @emph{M68hc1x Options}
349 @gccoptlist{-m6811 -m6812 -m68hc11 -m68hc12 -m68hcs12 @gol
350 -mauto-incdec -minmax -mlong-calls -mshort @gol
351 -msoft-reg-count=@var{count}}
352
353 @emph{VAX Options}
354 @gccoptlist{-mg -mgnu -munix}
355
356 @emph{SPARC Options}
357 @gccoptlist{-mcpu=@var{cpu-type} @gol
358 -mtune=@var{cpu-type} @gol
359 -mcmodel=@var{code-model} @gol
360 -m32 -m64 -mapp-regs -mno-app-regs @gol
361 -mfaster-structs -mno-faster-structs @gol
362 -mfpu -mno-fpu -mhard-float -msoft-float @gol
363 -mhard-quad-float -msoft-quad-float @gol
364 -mimpure-text -mno-impure-text -mlittle-endian @gol
365 -mstack-bias -mno-stack-bias @gol
366 -munaligned-doubles -mno-unaligned-doubles @gol
367 -mv8plus -mno-v8plus -mvis -mno-vis}
368
369 @emph{ARM Options}
370 @gccoptlist{-mapcs-frame -mno-apcs-frame @gol
371 -mabi=@var{name} @gol
372 -mapcs-26 -mapcs-32 @gol
373 -mapcs-stack-check -mno-apcs-stack-check @gol
374 -mapcs-float -mno-apcs-float @gol
375 -mapcs-reentrant -mno-apcs-reentrant @gol
376 -msched-prolog -mno-sched-prolog @gol
377 -mlittle-endian -mbig-endian -mwords-little-endian @gol
378 -malignment-traps -mno-alignment-traps @gol
379 -mfloat-abi=@var{name} soft-float -mhard-float -mfpe @gol
380 -mthumb-interwork -mno-thumb-interwork @gol
381 -mcpu=@var{name} -march=@var{name} -mfpu=@var{name} @gol
382 -mstructure-size-boundary=@var{n} @gol
383 -mabort-on-noreturn @gol
384 -mlong-calls -mno-long-calls @gol
385 -msingle-pic-base -mno-single-pic-base @gol
386 -mpic-register=@var{reg} @gol
387 -mnop-fun-dllimport @gol
388 -mcirrus-fix-invalid-insns -mno-cirrus-fix-invalid-insns @gol
389 -mpoke-function-name @gol
390 -mthumb -marm @gol
391 -mtpcs-frame -mtpcs-leaf-frame @gol
392 -mcaller-super-interworking -mcallee-super-interworking}
393
394 @emph{MN10300 Options}
395 @gccoptlist{-mmult-bug -mno-mult-bug @gol
396 -mam33 -mno-am33 @gol
397 -mam33-2 -mno-am33-2 @gol
398 -mno-crt0 -mrelax}
399
400 @emph{M32R/D Options}
401 @gccoptlist{-m32r2 -m32rx -m32r @gol
402 -mdebug @gol
403 -malign-loops -mno-align-loops @gol
404 -missue-rate=@var{number} @gol
405 -mbranch-cost=@var{number} @gol
406 -mmodel=@var{code-size-model-type} @gol
407 -msdata=@var{sdata-type} @gol
408 -mno-flush-func -mflush-func=@var{name} @gol
409 -mno-flush-trap -mflush-trap=@var{number} @gol
410 -G @var{num}}
411
412 @emph{RS/6000 and PowerPC Options}
413 @gccoptlist{-mcpu=@var{cpu-type} @gol
414 -mtune=@var{cpu-type} @gol
415 -mpower -mno-power -mpower2 -mno-power2 @gol
416 -mpowerpc -mpowerpc64 -mno-powerpc @gol
417 -maltivec -mno-altivec @gol
418 -mpowerpc-gpopt -mno-powerpc-gpopt @gol
419 -mpowerpc-gfxopt -mno-powerpc-gfxopt @gol
420 -mnew-mnemonics -mold-mnemonics @gol
421 -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc @gol
422 -m64 -m32 -mxl-call -mno-xl-call -mpe @gol
423 -malign-power -malign-natural @gol
424 -msoft-float -mhard-float -mmultiple -mno-multiple @gol
425 -mstring -mno-string -mupdate -mno-update @gol
426 -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol
427 -mstrict-align -mno-strict-align -mrelocatable @gol
428 -mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol
429 -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol
430 -mdynamic-no-pic @gol
431 -mprioritize-restricted-insns=@var{priority} @gol
432 -msched-costly-dep=@var{dependence_type} @gol
433 -minsert-sched-nops=@var{scheme} @gol
434 -mcall-sysv -mcall-netbsd @gol
435 -maix-struct-return -msvr4-struct-return @gol
436 -mabi=altivec -mabi=no-altivec @gol
437 -mabi=spe -mabi=no-spe @gol
438 -misel=yes -misel=no @gol
439 -mspe=yes -mspe=no @gol
440 -mfloat-gprs=yes -mfloat-gprs=no @gol
441 -mprototype -mno-prototype @gol
442 -msim -mmvme -mads -myellowknife -memb -msdata @gol
443 -msdata=@var{opt} -mvxworks -mwindiss -G @var{num} -pthread}
444
445 @emph{Darwin Options}
446 @gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal @gol
447 -arch_only -bind_at_load -bundle -bundle_loader @gol
448 -client_name -compatibility_version -current_version @gol
449 -dependency-file -dylib_file -dylinker_install_name @gol
450 -dynamic -dynamiclib -exported_symbols_list @gol
451 -filelist -flat_namespace -force_cpusubtype_ALL @gol
452 -force_flat_namespace -headerpad_max_install_names @gol
453 -image_base -init -install_name -keep_private_externs @gol
454 -multi_module -multiply_defined -multiply_defined_unused @gol
455 -noall_load -nofixprebinding -nomultidefs -noprebind -noseglinkedit @gol
456 -pagezero_size -prebind -prebind_all_twolevel_modules @gol
457 -private_bundle -read_only_relocs -sectalign @gol
458 -sectobjectsymbols -whyload -seg1addr @gol
459 -sectcreate -sectobjectsymbols -sectorder @gol
460 -seg_addr_table -seg_addr_table_filename -seglinkedit @gol
461 -segprot -segs_read_only_addr -segs_read_write_addr @gol
462 -single_module -static -sub_library -sub_umbrella @gol
463 -twolevel_namespace -umbrella -undefined @gol
464 -unexported_symbols_list -weak_reference_mismatches @gol
465 -whatsloaded -F}
466
467 @emph{MIPS Options}
468 @gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} @gol
469 -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips64 @gol
470 -mips16 -mno-mips16 -mabi=@var{abi} -mabicalls -mno-abicalls @gol
471 -mxgot -mno-xgot -mgp32 -mgp64 -mfp32 -mfp64 @gol
472 -mhard-float -msoft-float -msingle-float -mdouble-float @gol
473 -mint64 -mlong64 -mlong32 @gol
474 -G@var{num} -membedded-data -mno-embedded-data @gol
475 -muninit-const-in-rodata -mno-uninit-const-in-rodata @gol
476 -msplit-addresses -mno-split-addresses @gol
477 -mexplicit-relocs -mno-explicit-relocs @gol
478 -mrnames -mno-rnames @gol
479 -mcheck-zero-division -mno-check-zero-division @gol
480 -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls @gol
481 -mmad -mno-mad -mfused-madd -mno-fused-madd -nocpp @gol
482 -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 @gol
483 -mfix-vr4120 -mno-fix-vr4120 -mfix-sb1 -mno-fix-sb1 @gol
484 -mflush-func=@var{func} -mno-flush-func @gol
485 -mbranch-likely -mno-branch-likely @gol
486 -mfp-exceptions -mno-fp-exceptions @gol
487 -mvr4130-align -mno-vr4130-align}
488
489 @emph{i386 and x86-64 Options}
490 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
491 -mfpmath=@var{unit} @gol
492 -masm=@var{dialect} -mno-fancy-math-387 @gol
493 -mno-fp-ret-in-387 -msoft-float -msvr3-shlib @gol
494 -mno-wide-multiply -mrtd -malign-double @gol
495 -mpreferred-stack-boundary=@var{num} @gol
496 -mmmx -msse -msse2 -msse3 -m3dnow @gol
497 -mthreads -mno-align-stringops -minline-all-stringops @gol
498 -mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
499 -m96bit-long-double -mregparm=@var{num} -momit-leaf-frame-pointer @gol
500 -mno-red-zone -mno-tls-direct-seg-refs @gol
501 -mcmodel=@var{code-model} @gol
502 -m32 -m64}
503
504 @emph{HPPA Options}
505 @gccoptlist{-march=@var{architecture-type} @gol
506 -mbig-switch -mdisable-fpregs -mdisable-indexing @gol
507 -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld @gol
508 -mjump-in-delay -mlinker-opt -mlong-calls @gol
509 -mlong-load-store -mno-big-switch -mno-disable-fpregs @gol
510 -mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol
511 -mno-jump-in-delay -mno-long-load-store @gol
512 -mno-portable-runtime -mno-soft-float @gol
513 -mno-space-regs -msoft-float -mpa-risc-1-0 @gol
514 -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol
515 -mschedule=@var{cpu-type} -mspace-regs -msio -mwsio @gol
516 -nolibdld -static -threads}
517
518 @emph{DEC Alpha Options}
519 @gccoptlist{-mno-fp-regs -msoft-float -malpha-as -mgas @gol
520 -mieee -mieee-with-inexact -mieee-conformant @gol
521 -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} @gol
522 -mtrap-precision=@var{mode} -mbuild-constants @gol
523 -mcpu=@var{cpu-type} -mtune=@var{cpu-type} @gol
524 -mbwx -mmax -mfix -mcix @gol
525 -mfloat-vax -mfloat-ieee @gol
526 -mexplicit-relocs -msmall-data -mlarge-data @gol
527 -msmall-text -mlarge-text @gol
528 -mmemory-latency=@var{time}}
529
530 @emph{DEC Alpha/VMS Options}
531 @gccoptlist{-mvms-return-codes}
532
533 @emph{H8/300 Options}
534 @gccoptlist{-mrelax -mh -ms -mn -mint32 -malign-300}
535
536 @emph{SH Options}
537 @gccoptlist{-m1 -m2 -m2e -m3 -m3e @gol
538 -m4-nofpu -m4-single-only -m4-single -m4 @gol
539 -m5-64media -m5-64media-nofpu @gol
540 -m5-32media -m5-32media-nofpu @gol
541 -m5-compact -m5-compact-nofpu @gol
542 -mb -ml -mdalign -mrelax @gol
543 -mbigtable -mfmovd -mhitachi -mnomacsave @gol
544 -mieee -misize -mpadstruct -mspace @gol
545 -mprefergot -musermode}
546
547 @emph{System V Options}
548 @gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
549
550 @emph{ARC Options}
551 @gccoptlist{-EB -EL @gol
552 -mmangle-cpu -mcpu=@var{cpu} -mtext=@var{text-section} @gol
553 -mdata=@var{data-section} -mrodata=@var{readonly-data-section}}
554
555 @emph{TMS320C3x/C4x Options}
556 @gccoptlist{-mcpu=@var{cpu} -mbig -msmall -mregparm -mmemparm @gol
557 -mfast-fix -mmpyi -mbk -mti -mdp-isr-reload @gol
558 -mrpts=@var{count} -mrptb -mdb -mloop-unsigned @gol
559 -mparallel-insns -mparallel-mpy -mpreserve-float}
560
561 @emph{V850 Options}
562 @gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep @gol
563 -mprolog-function -mno-prolog-function -mspace @gol
564 -mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol
565 -mapp-regs -mno-app-regs @gol
566 -mdisable-callt -mno-disable-callt @gol
567 -mv850e1 @gol
568 -mv850e @gol
569 -mv850 -mbig-switch}
570
571 @emph{NS32K Options}
572 @gccoptlist{-m32032 -m32332 -m32532 -m32081 -m32381 @gol
573 -mmult-add -mnomult-add -msoft-float -mrtd -mnortd @gol
574 -mregparam -mnoregparam -msb -mnosb @gol
575 -mbitfield -mnobitfield -mhimem -mnohimem}
576
577 @emph{AVR Options}
578 @gccoptlist{-mmcu=@var{mcu} -msize -minit-stack=@var{n} -mno-interrupts @gol
579 -mcall-prologues -mno-tablejump -mtiny-stack}
580
581 @emph{MCore Options}
582 @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol
583 -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol
584 -m4byte-functions -mno-4byte-functions -mcallgraph-data @gol
585 -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol
586 -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
587
588 @emph{MMIX Options}
589 @gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu @gol
590 -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols @gol
591 -melf -mbranch-predict -mno-branch-predict -mbase-addresses @gol
592 -mno-base-addresses -msingle-exit -mno-single-exit}
593
594 @emph{IA-64 Options}
595 @gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol
596 -mvolatile-asm-stop -mb-step -mregister-names -mno-sdata @gol
597 -mconstant-gp -mauto-pic -minline-float-divide-min-latency @gol
598 -minline-float-divide-max-throughput @gol
599 -minline-int-divide-min-latency @gol
600 -minline-int-divide-max-throughput -mno-dwarf2-asm @gol
601 -mfixed-range=@var{register-range}}
602
603 @emph{S/390 and zSeries Options}
604 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
605 -mhard-float -msoft-float -mbackchain -mno-backchain @gol
606 -msmall-exec -mno-small-exec -mmvcle -mno-mvcle @gol
607 -m64 -m31 -mdebug -mno-debug -mesa -mzarch -mfused-madd -mno-fused-madd}
608
609 @emph{CRIS Options}
610 @gccoptlist{-mcpu=@var{cpu} -march=@var{cpu} -mtune=@var{cpu} @gol
611 -mmax-stack-frame=@var{n} -melinux-stacksize=@var{n} @gol
612 -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects @gol
613 -mstack-align -mdata-align -mconst-align @gol
614 -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue -mno-gotplt @gol
615 -melf -maout -melinux -mlinux -sim -sim2 @gol
616 -mmul-bug-workaround -mno-mul-bug-workaround}
617
618 @emph{PDP-11 Options}
619 @gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 @gol
620 -mbcopy -mbcopy-builtin -mint32 -mno-int16 @gol
621 -mint16 -mno-int32 -mfloat32 -mno-float64 @gol
622 -mfloat64 -mno-float32 -mabshi -mno-abshi @gol
623 -mbranch-expensive -mbranch-cheap @gol
624 -msplit -mno-split -munix-asm -mdec-asm}
625
626 @emph{Xstormy16 Options}
627 @gccoptlist{-msim}
628
629 @emph{Xtensa Options}
630 @gccoptlist{-mconst16 -mno-const16 @gol
631 -mfused-madd -mno-fused-madd @gol
632 -mtext-section-literals -mno-text-section-literals @gol
633 -mtarget-align -mno-target-align @gol
634 -mlongcalls -mno-longcalls}
635
636 @emph{FRV Options}
637 @gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 @gol
638 -mhard-float -msoft-float @gol
639 -malloc-cc -mfixed-cc -mdword -mno-dword @gol
640 -mdouble -mno-double @gol
641 -mmedia -mno-media -mmuladd -mno-muladd @gol
642 -mfdpic -minline-plt -mgprel-ro -multilib-library-pic -mlinked-fp @gol
643 -mlibrary-pic -macc-4 -macc-8 @gol
644 -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move @gol
645 -mscc -mno-scc -mcond-exec -mno-cond-exec @gol
646 -mvliw-branch -mno-vliw-branch @gol
647 -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec @gol
648 -mno-nested-cond-exec -mtomcat-stats @gol
649 -mcpu=@var{cpu}}
650
651 @item Code Generation Options
652 @xref{Code Gen Options,,Options for Code Generation Conventions}.
653 @gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} @gol
654 -ffixed-@var{reg} -fexceptions @gol
655 -fnon-call-exceptions -funwind-tables @gol
656 -fasynchronous-unwind-tables @gol
657 -finhibit-size-directive -finstrument-functions @gol
658 -fno-common -fno-ident @gol
659 -fpcc-struct-return -fpic -fPIC -fpie -fPIE @gol
660 -freg-struct-return -fshared-data -fshort-enums @gol
661 -fshort-double -fshort-wchar @gol
662 -fverbose-asm -fpack-struct -fstack-check @gol
663 -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol
664 -fargument-alias -fargument-noalias @gol
665 -fargument-noalias-global -fleading-underscore @gol
666 -ftls-model=@var{model} @gol
667 -ftrapv -fwrapv -fbounds-check}
668 @end table
669
670 @menu
671 * Overall Options:: Controlling the kind of output:
672 an executable, object files, assembler files,
673 or preprocessed source.
674 * C Dialect Options:: Controlling the variant of C language compiled.
675 * C++ Dialect Options:: Variations on C++.
676 * Objective-C Dialect Options:: Variations on Objective-C.
677 * Language Independent Options:: Controlling how diagnostics should be
678 formatted.
679 * Warning Options:: How picky should the compiler be?
680 * Debugging Options:: Symbol tables, measurements, and debugging dumps.
681 * Optimize Options:: How much optimization?
682 * Preprocessor Options:: Controlling header files and macro definitions.
683 Also, getting dependency information for Make.
684 * Assembler Options:: Passing options to the assembler.
685 * Link Options:: Specifying libraries and so on.
686 * Directory Options:: Where to find header files and libraries.
687 Where to find the compiler executable files.
688 * Spec Files:: How to pass switches to sub-processes.
689 * Target Options:: Running a cross-compiler, or an old version of GCC.
690 @end menu
691
692 @node Overall Options
693 @section Options Controlling the Kind of Output
694
695 Compilation can involve up to four stages: preprocessing, compilation
696 proper, assembly and linking, always in that order. GCC is capable of
697 preprocessing and compiling several files either into several
698 assembler input files, or into one assembler input file; then each
699 assembler input file produces an object file, and linking combines all
700 the object files (those newly compiled, and those specified as input)
701 into an executable file.
702
703 @cindex file name suffix
704 For any given input file, the file name suffix determines what kind of
705 compilation is done:
706
707 @table @gcctabopt
708 @item @var{file}.c
709 C source code which must be preprocessed.
710
711 @item @var{file}.i
712 C source code which should not be preprocessed.
713
714 @item @var{file}.ii
715 C++ source code which should not be preprocessed.
716
717 @item @var{file}.m
718 Objective-C source code. Note that you must link with the library
719 @file{libobjc.a} to make an Objective-C program work.
720
721 @item @var{file}.mi
722 Objective-C source code which should not be preprocessed.
723
724 @item @var{file}.h
725 C or C++ header file to be turned into a precompiled header.
726
727 @item @var{file}.cc
728 @itemx @var{file}.cp
729 @itemx @var{file}.cxx
730 @itemx @var{file}.cpp
731 @itemx @var{file}.CPP
732 @itemx @var{file}.c++
733 @itemx @var{file}.C
734 C++ source code which must be preprocessed. Note that in @samp{.cxx},
735 the last two letters must both be literally @samp{x}. Likewise,
736 @samp{.C} refers to a literal capital C@.
737
738 @item @var{file}.hh
739 @itemx @var{file}.H
740 C++ header file to be turned into a precompiled header.
741
742 @item @var{file}.f
743 @itemx @var{file}.for
744 @itemx @var{file}.FOR
745 Fortran source code which should not be preprocessed.
746
747 @item @var{file}.F
748 @itemx @var{file}.fpp
749 @itemx @var{file}.FPP
750 Fortran source code which must be preprocessed (with the traditional
751 preprocessor).
752
753 @item @var{file}.r
754 Fortran source code which must be preprocessed with a RATFOR
755 preprocessor (not included with GCC)@.
756
757 @xref{Overall Options,,Options Controlling the Kind of Output, g77,
758 Using and Porting GNU Fortran}, for more details of the handling of
759 Fortran input files.
760
761 @c FIXME: Descriptions of Java file types.
762 @c @var{file}.java
763 @c @var{file}.class
764 @c @var{file}.zip
765 @c @var{file}.jar
766
767 @item @var{file}.ads
768 Ada source code file which contains a library unit declaration (a
769 declaration of a package, subprogram, or generic, or a generic
770 instantiation), or a library unit renaming declaration (a package,
771 generic, or subprogram renaming declaration). Such files are also
772 called @dfn{specs}.
773
774 @itemx @var{file}.adb
775 Ada source code file containing a library unit body (a subprogram or
776 package body). Such files are also called @dfn{bodies}.
777
778 @c GCC also knows about some suffixes for languages not yet included:
779 @c Pascal:
780 @c @var{file}.p
781 @c @var{file}.pas
782
783 @item @var{file}.s
784 Assembler code.
785
786 @item @var{file}.S
787 Assembler code which must be preprocessed.
788
789 @item @var{other}
790 An object file to be fed straight into linking.
791 Any file name with no recognized suffix is treated this way.
792 @end table
793
794 @opindex x
795 You can specify the input language explicitly with the @option{-x} option:
796
797 @table @gcctabopt
798 @item -x @var{language}
799 Specify explicitly the @var{language} for the following input files
800 (rather than letting the compiler choose a default based on the file
801 name suffix). This option applies to all following input files until
802 the next @option{-x} option. Possible values for @var{language} are:
803 @smallexample
804 c c-header cpp-output
805 c++ c++-header c++-cpp-output
806 objective-c objective-c-header objc-cpp-output
807 assembler assembler-with-cpp
808 ada
809 f77 f77-cpp-input ratfor
810 java
811 treelang
812 @end smallexample
813
814 @item -x none
815 Turn off any specification of a language, so that subsequent files are
816 handled according to their file name suffixes (as they are if @option{-x}
817 has not been used at all).
818
819 @item -pass-exit-codes
820 @opindex pass-exit-codes
821 Normally the @command{gcc} program will exit with the code of 1 if any
822 phase of the compiler returns a non-success return code. If you specify
823 @option{-pass-exit-codes}, the @command{gcc} program will instead return with
824 numerically highest error produced by any phase that returned an error
825 indication.
826 @end table
827
828 If you only want some of the stages of compilation, you can use
829 @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
830 one of the options @option{-c}, @option{-S}, or @option{-E} to say where
831 @command{gcc} is to stop. Note that some combinations (for example,
832 @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
833
834 @table @gcctabopt
835 @item -c
836 @opindex c
837 Compile or assemble the source files, but do not link. The linking
838 stage simply is not done. The ultimate output is in the form of an
839 object file for each source file.
840
841 By default, the object file name for a source file is made by replacing
842 the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
843
844 Unrecognized input files, not requiring compilation or assembly, are
845 ignored.
846
847 @item -S
848 @opindex S
849 Stop after the stage of compilation proper; do not assemble. The output
850 is in the form of an assembler code file for each non-assembler input
851 file specified.
852
853 By default, the assembler file name for a source file is made by
854 replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
855
856 Input files that don't require compilation are ignored.
857
858 @item -E
859 @opindex E
860 Stop after the preprocessing stage; do not run the compiler proper. The
861 output is in the form of preprocessed source code, which is sent to the
862 standard output.
863
864 Input files which don't require preprocessing are ignored.
865
866 @cindex output file option
867 @item -o @var{file}
868 @opindex o
869 Place output in file @var{file}. This applies regardless to whatever
870 sort of output is being produced, whether it be an executable file,
871 an object file, an assembler file or preprocessed C code.
872
873 If @option{-o} is not specified, the default is to put an executable
874 file in @file{a.out}, the object file for
875 @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
876 assembler file in @file{@var{source}.s}, a precompiled header file in
877 @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
878 standard output.
879
880 @item -v
881 @opindex v
882 Print (on standard error output) the commands executed to run the stages
883 of compilation. Also print the version number of the compiler driver
884 program and of the preprocessor and the compiler proper.
885
886 @item -###
887 @opindex ###
888 Like @option{-v} except the commands are not executed and all command
889 arguments are quoted. This is useful for shell scripts to capture the
890 driver-generated command lines.
891
892 @item -pipe
893 @opindex pipe
894 Use pipes rather than temporary files for communication between the
895 various stages of compilation. This fails to work on some systems where
896 the assembler is unable to read from a pipe; but the GNU assembler has
897 no trouble.
898
899 @item -combine
900 @opindex combine
901 If you are compiling multiple source files, this option tells the driver
902 to pass all the source files to the compiler at once (for those
903 languages for which the compiler can handle this). This will allow
904 intermodule analysis (IMA) to be performed by the compiler. Currently the only
905 language for which this is supported is C. If you pass source files for
906 multiple languages to the driver, using this option, the driver will invoke
907 the compiler(s) that support IMA once each, passing each compiler all the
908 source files appropriate for it. For those languages that do not support
909 IMA this option will be ignored, and the compiler will be invoked once for
910 each source file in that language. If you use this option in conjunction
911 with -save-temps, the compiler will generate multiple pre-processed files
912 (one for each source file), but only one (combined) .o or .s file.
913
914 @item --help
915 @opindex help
916 Print (on the standard output) a description of the command line options
917 understood by @command{gcc}. If the @option{-v} option is also specified
918 then @option{--help} will also be passed on to the various processes
919 invoked by @command{gcc}, so that they can display the command line options
920 they accept. If the @option{-Wextra} option is also specified then command
921 line options which have no documentation associated with them will also
922 be displayed.
923
924 @item --target-help
925 @opindex target-help
926 Print (on the standard output) a description of target specific command
927 line options for each tool.
928
929 @item --version
930 @opindex version
931 Display the version number and copyrights of the invoked GCC.
932 @end table
933
934 @node Invoking G++
935 @section Compiling C++ Programs
936
937 @cindex suffixes for C++ source
938 @cindex C++ source file suffixes
939 C++ source files conventionally use one of the suffixes @samp{.C},
940 @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
941 @samp{.cxx}; C++ header files often use @samp{.hh} or @samp{.H}; and
942 preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
943 files with these names and compiles them as C++ programs even if you
944 call the compiler the same way as for compiling C programs (usually
945 with the name @command{gcc}).
946
947 @findex g++
948 @findex c++
949 However, C++ programs often require class libraries as well as a
950 compiler that understands the C++ language---and under some
951 circumstances, you might want to compile programs or header files from
952 standard input, or otherwise without a suffix that flags them as C++
953 programs. You might also like to precompile a C header file with a
954 @samp{.h} extension to be used in C++ compilations. @command{g++} is a
955 program that calls GCC with the default language set to C++, and
956 automatically specifies linking against the C++ library. On many
957 systems, @command{g++} is also installed with the name @command{c++}.
958
959 @cindex invoking @command{g++}
960 When you compile C++ programs, you may specify many of the same
961 command-line options that you use for compiling programs in any
962 language; or command-line options meaningful for C and related
963 languages; or options that are meaningful only for C++ programs.
964 @xref{C Dialect Options,,Options Controlling C Dialect}, for
965 explanations of options for languages related to C@.
966 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
967 explanations of options that are meaningful only for C++ programs.
968
969 @node C Dialect Options
970 @section Options Controlling C Dialect
971 @cindex dialect options
972 @cindex language dialect options
973 @cindex options, dialect
974
975 The following options control the dialect of C (or languages derived
976 from C, such as C++ and Objective-C) that the compiler accepts:
977
978 @table @gcctabopt
979 @cindex ANSI support
980 @cindex ISO support
981 @item -ansi
982 @opindex ansi
983 In C mode, support all ISO C90 programs. In C++ mode,
984 remove GNU extensions that conflict with ISO C++.
985
986 This turns off certain features of GCC that are incompatible with ISO
987 C90 (when compiling C code), or of standard C++ (when compiling C++ code),
988 such as the @code{asm} and @code{typeof} keywords, and
989 predefined macros such as @code{unix} and @code{vax} that identify the
990 type of system you are using. It also enables the undesirable and
991 rarely used ISO trigraph feature. For the C compiler,
992 it disables recognition of C++ style @samp{//} comments as well as
993 the @code{inline} keyword.
994
995 The alternate keywords @code{__asm__}, @code{__extension__},
996 @code{__inline__} and @code{__typeof__} continue to work despite
997 @option{-ansi}. You would not want to use them in an ISO C program, of
998 course, but it is useful to put them in header files that might be included
999 in compilations done with @option{-ansi}. Alternate predefined macros
1000 such as @code{__unix__} and @code{__vax__} are also available, with or
1001 without @option{-ansi}.
1002
1003 The @option{-ansi} option does not cause non-ISO programs to be
1004 rejected gratuitously. For that, @option{-pedantic} is required in
1005 addition to @option{-ansi}. @xref{Warning Options}.
1006
1007 The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
1008 option is used. Some header files may notice this macro and refrain
1009 from declaring certain functions or defining certain macros that the
1010 ISO standard doesn't call for; this is to avoid interfering with any
1011 programs that might use these names for other things.
1012
1013 Functions which would normally be built in but do not have semantics
1014 defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
1015 functions with @option{-ansi} is used. @xref{Other Builtins,,Other
1016 built-in functions provided by GCC}, for details of the functions
1017 affected.
1018
1019 @item -std=
1020 @opindex std
1021 Determine the language standard. This option is currently only
1022 supported when compiling C or C++. A value for this option must be
1023 provided; possible values are
1024
1025 @table @samp
1026 @item c89
1027 @itemx iso9899:1990
1028 ISO C90 (same as @option{-ansi}).
1029
1030 @item iso9899:199409
1031 ISO C90 as modified in amendment 1.
1032
1033 @item c99
1034 @itemx c9x
1035 @itemx iso9899:1999
1036 @itemx iso9899:199x
1037 ISO C99. Note that this standard is not yet fully supported; see
1038 @w{@uref{http://gcc.gnu.org/c99status.html}} for more information. The
1039 names @samp{c9x} and @samp{iso9899:199x} are deprecated.
1040
1041 @item gnu89
1042 Default, ISO C90 plus GNU extensions (including some C99 features).
1043
1044 @item gnu99
1045 @itemx gnu9x
1046 ISO C99 plus GNU extensions. When ISO C99 is fully implemented in GCC,
1047 this will become the default. The name @samp{gnu9x} is deprecated.
1048
1049 @item c++98
1050 The 1998 ISO C++ standard plus amendments.
1051
1052 @item gnu++98
1053 The same as @option{-std=c++98} plus GNU extensions. This is the
1054 default for C++ code.
1055 @end table
1056
1057 Even when this option is not specified, you can still use some of the
1058 features of newer standards in so far as they do not conflict with
1059 previous C standards. For example, you may use @code{__restrict__} even
1060 when @option{-std=c99} is not specified.
1061
1062 The @option{-std} options specifying some version of ISO C have the same
1063 effects as @option{-ansi}, except that features that were not in ISO C90
1064 but are in the specified version (for example, @samp{//} comments and
1065 the @code{inline} keyword in ISO C99) are not disabled.
1066
1067 @xref{Standards,,Language Standards Supported by GCC}, for details of
1068 these standard versions.
1069
1070 @item -aux-info @var{filename}
1071 @opindex aux-info
1072 Output to the given filename prototyped declarations for all functions
1073 declared and/or defined in a translation unit, including those in header
1074 files. This option is silently ignored in any language other than C@.
1075
1076 Besides declarations, the file indicates, in comments, the origin of
1077 each declaration (source file and line), whether the declaration was
1078 implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
1079 @samp{O} for old, respectively, in the first character after the line
1080 number and the colon), and whether it came from a declaration or a
1081 definition (@samp{C} or @samp{F}, respectively, in the following
1082 character). In the case of function definitions, a K&R-style list of
1083 arguments followed by their declarations is also provided, inside
1084 comments, after the declaration.
1085
1086 @item -fno-asm
1087 @opindex fno-asm
1088 Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
1089 keyword, so that code can use these words as identifiers. You can use
1090 the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
1091 instead. @option{-ansi} implies @option{-fno-asm}.
1092
1093 In C++, this switch only affects the @code{typeof} keyword, since
1094 @code{asm} and @code{inline} are standard keywords. You may want to
1095 use the @option{-fno-gnu-keywords} flag instead, which has the same
1096 effect. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), this
1097 switch only affects the @code{asm} and @code{typeof} keywords, since
1098 @code{inline} is a standard keyword in ISO C99.
1099
1100 @item -fno-builtin
1101 @itemx -fno-builtin-@var{function}
1102 @opindex fno-builtin
1103 @cindex built-in functions
1104 Don't recognize built-in functions that do not begin with
1105 @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
1106 functions provided by GCC}, for details of the functions affected,
1107 including those which are not built-in functions when @option{-ansi} or
1108 @option{-std} options for strict ISO C conformance are used because they
1109 do not have an ISO standard meaning.
1110
1111 GCC normally generates special code to handle certain built-in functions
1112 more efficiently; for instance, calls to @code{alloca} may become single
1113 instructions that adjust the stack directly, and calls to @code{memcpy}
1114 may become inline copy loops. The resulting code is often both smaller
1115 and faster, but since the function calls no longer appear as such, you
1116 cannot set a breakpoint on those calls, nor can you change the behavior
1117 of the functions by linking with a different library.
1118
1119 With the @option{-fno-builtin-@var{function}} option
1120 only the built-in function @var{function} is
1121 disabled. @var{function} must not begin with @samp{__builtin_}. If a
1122 function is named this is not built-in in this version of GCC, this
1123 option is ignored. There is no corresponding
1124 @option{-fbuiltin-@var{function}} option; if you wish to enable
1125 built-in functions selectively when using @option{-fno-builtin} or
1126 @option{-ffreestanding}, you may define macros such as:
1127
1128 @smallexample
1129 #define abs(n) __builtin_abs ((n))
1130 #define strcpy(d, s) __builtin_strcpy ((d), (s))
1131 @end smallexample
1132
1133 @item -fhosted
1134 @opindex fhosted
1135 @cindex hosted environment
1136
1137 Assert that compilation takes place in a hosted environment. This implies
1138 @option{-fbuiltin}. A hosted environment is one in which the
1139 entire standard library is available, and in which @code{main} has a return
1140 type of @code{int}. Examples are nearly everything except a kernel.
1141 This is equivalent to @option{-fno-freestanding}.
1142
1143 @item -ffreestanding
1144 @opindex ffreestanding
1145 @cindex hosted environment
1146
1147 Assert that compilation takes place in a freestanding environment. This
1148 implies @option{-fno-builtin}. A freestanding environment
1149 is one in which the standard library may not exist, and program startup may
1150 not necessarily be at @code{main}. The most obvious example is an OS kernel.
1151 This is equivalent to @option{-fno-hosted}.
1152
1153 @xref{Standards,,Language Standards Supported by GCC}, for details of
1154 freestanding and hosted environments.
1155
1156 @item -fms-extensions
1157 @opindex fms-extensions
1158 Accept some non-standard constructs used in Microsoft header files.
1159
1160 @item -trigraphs
1161 @opindex trigraphs
1162 Support ISO C trigraphs. The @option{-ansi} option (and @option{-std}
1163 options for strict ISO C conformance) implies @option{-trigraphs}.
1164
1165 @item -no-integrated-cpp
1166 @opindex no-integrated-cpp
1167 Performs a compilation in two passes: preprocessing and compiling. This
1168 option allows a user supplied "cc1", "cc1plus", or "cc1obj" via the
1169 @option{-B} option. The user supplied compilation step can then add in
1170 an additional preprocessing step after normal preprocessing but before
1171 compiling. The default is to use the integrated cpp (internal cpp)
1172
1173 The semantics of this option will change if "cc1", "cc1plus", and
1174 "cc1obj" are merged.
1175
1176 @cindex traditional C language
1177 @cindex C language, traditional
1178 @item -traditional
1179 @itemx -traditional-cpp
1180 @opindex traditional-cpp
1181 @opindex traditional
1182 Formerly, these options caused GCC to attempt to emulate a pre-standard
1183 C compiler. They are now only supported with the @option{-E} switch.
1184 The preprocessor continues to support a pre-standard mode. See the GNU
1185 CPP manual for details.
1186
1187 @item -fcond-mismatch
1188 @opindex fcond-mismatch
1189 Allow conditional expressions with mismatched types in the second and
1190 third arguments. The value of such an expression is void. This option
1191 is not supported for C++.
1192
1193 @item -funsigned-char
1194 @opindex funsigned-char
1195 Let the type @code{char} be unsigned, like @code{unsigned char}.
1196
1197 Each kind of machine has a default for what @code{char} should
1198 be. It is either like @code{unsigned char} by default or like
1199 @code{signed char} by default.
1200
1201 Ideally, a portable program should always use @code{signed char} or
1202 @code{unsigned char} when it depends on the signedness of an object.
1203 But many programs have been written to use plain @code{char} and
1204 expect it to be signed, or expect it to be unsigned, depending on the
1205 machines they were written for. This option, and its inverse, let you
1206 make such a program work with the opposite default.
1207
1208 The type @code{char} is always a distinct type from each of
1209 @code{signed char} or @code{unsigned char}, even though its behavior
1210 is always just like one of those two.
1211
1212 @item -fsigned-char
1213 @opindex fsigned-char
1214 Let the type @code{char} be signed, like @code{signed char}.
1215
1216 Note that this is equivalent to @option{-fno-unsigned-char}, which is
1217 the negative form of @option{-funsigned-char}. Likewise, the option
1218 @option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
1219
1220 @item -fsigned-bitfields
1221 @itemx -funsigned-bitfields
1222 @itemx -fno-signed-bitfields
1223 @itemx -fno-unsigned-bitfields
1224 @opindex fsigned-bitfields
1225 @opindex funsigned-bitfields
1226 @opindex fno-signed-bitfields
1227 @opindex fno-unsigned-bitfields
1228 These options control whether a bit-field is signed or unsigned, when the
1229 declaration does not use either @code{signed} or @code{unsigned}. By
1230 default, such a bit-field is signed, because this is consistent: the
1231 basic integer types such as @code{int} are signed types.
1232 @end table
1233
1234 @node C++ Dialect Options
1235 @section Options Controlling C++ Dialect
1236
1237 @cindex compiler options, C++
1238 @cindex C++ options, command line
1239 @cindex options, C++
1240 This section describes the command-line options that are only meaningful
1241 for C++ programs; but you can also use most of the GNU compiler options
1242 regardless of what language your program is in. For example, you
1243 might compile a file @code{firstClass.C} like this:
1244
1245 @smallexample
1246 g++ -g -frepo -O -c firstClass.C
1247 @end smallexample
1248
1249 @noindent
1250 In this example, only @option{-frepo} is an option meant
1251 only for C++ programs; you can use the other options with any
1252 language supported by GCC@.
1253
1254 Here is a list of options that are @emph{only} for compiling C++ programs:
1255
1256 @table @gcctabopt
1257
1258 @item -fabi-version=@var{n}
1259 @opindex fabi-version
1260 Use version @var{n} of the C++ ABI. Version 2 is the version of the
1261 C++ ABI that first appeared in G++ 3.4. Version 1 is the version of
1262 the C++ ABI that first appeared in G++ 3.2. Version 0 will always be
1263 the version that conforms most closely to the C++ ABI specification.
1264 Therefore, the ABI obtained using version 0 will change as ABI bugs
1265 are fixed.
1266
1267 The default is version 2.
1268
1269 @item -fno-access-control
1270 @opindex fno-access-control
1271 Turn off all access checking. This switch is mainly useful for working
1272 around bugs in the access control code.
1273
1274 @item -fcheck-new
1275 @opindex fcheck-new
1276 Check that the pointer returned by @code{operator new} is non-null
1277 before attempting to modify the storage allocated. This check is
1278 normally unnecessary because the C++ standard specifies that
1279 @code{operator new} will only return @code{0} if it is declared
1280 @samp{throw()}, in which case the compiler will always check the
1281 return value even without this option. In all other cases, when
1282 @code{operator new} has a non-empty exception specification, memory
1283 exhaustion is signalled by throwing @code{std::bad_alloc}. See also
1284 @samp{new (nothrow)}.
1285
1286 @item -fconserve-space
1287 @opindex fconserve-space
1288 Put uninitialized or runtime-initialized global variables into the
1289 common segment, as C does. This saves space in the executable at the
1290 cost of not diagnosing duplicate definitions. If you compile with this
1291 flag and your program mysteriously crashes after @code{main()} has
1292 completed, you may have an object that is being destroyed twice because
1293 two definitions were merged.
1294
1295 This option is no longer useful on most targets, now that support has
1296 been added for putting variables into BSS without making them common.
1297
1298 @item -fno-const-strings
1299 @opindex fno-const-strings
1300 Give string constants type @code{char *} instead of type @code{const
1301 char *}. By default, G++ uses type @code{const char *} as required by
1302 the standard. Even if you use @option{-fno-const-strings}, you cannot
1303 actually modify the value of a string constant.
1304
1305 This option might be removed in a future release of G++. For maximum
1306 portability, you should structure your code so that it works with
1307 string constants that have type @code{const char *}.
1308
1309 @item -fno-elide-constructors
1310 @opindex fno-elide-constructors
1311 The C++ standard allows an implementation to omit creating a temporary
1312 which is only used to initialize another object of the same type.
1313 Specifying this option disables that optimization, and forces G++ to
1314 call the copy constructor in all cases.
1315
1316 @item -fno-enforce-eh-specs
1317 @opindex fno-enforce-eh-specs
1318 Don't check for violation of exception specifications at runtime. This
1319 option violates the C++ standard, but may be useful for reducing code
1320 size in production builds, much like defining @samp{NDEBUG}. The compiler
1321 will still optimize based on the exception specifications.
1322
1323 @item -ffor-scope
1324 @itemx -fno-for-scope
1325 @opindex ffor-scope
1326 @opindex fno-for-scope
1327 If @option{-ffor-scope} is specified, the scope of variables declared in
1328 a @i{for-init-statement} is limited to the @samp{for} loop itself,
1329 as specified by the C++ standard.
1330 If @option{-fno-for-scope} is specified, the scope of variables declared in
1331 a @i{for-init-statement} extends to the end of the enclosing scope,
1332 as was the case in old versions of G++, and other (traditional)
1333 implementations of C++.
1334
1335 The default if neither flag is given to follow the standard,
1336 but to allow and give a warning for old-style code that would
1337 otherwise be invalid, or have different behavior.
1338
1339 @item -fno-gnu-keywords
1340 @opindex fno-gnu-keywords
1341 Do not recognize @code{typeof} as a keyword, so that code can use this
1342 word as an identifier. You can use the keyword @code{__typeof__} instead.
1343 @option{-ansi} implies @option{-fno-gnu-keywords}.
1344
1345 @item -fno-implicit-templates
1346 @opindex fno-implicit-templates
1347 Never emit code for non-inline templates which are instantiated
1348 implicitly (i.e.@: by use); only emit code for explicit instantiations.
1349 @xref{Template Instantiation}, for more information.
1350
1351 @item -fno-implicit-inline-templates
1352 @opindex fno-implicit-inline-templates
1353 Don't emit code for implicit instantiations of inline templates, either.
1354 The default is to handle inlines differently so that compiles with and
1355 without optimization will need the same set of explicit instantiations.
1356
1357 @item -fno-implement-inlines
1358 @opindex fno-implement-inlines
1359 To save space, do not emit out-of-line copies of inline functions
1360 controlled by @samp{#pragma implementation}. This will cause linker
1361 errors if these functions are not inlined everywhere they are called.
1362
1363 @item -fms-extensions
1364 @opindex fms-extensions
1365 Disable pedantic warnings about constructs used in MFC, such as implicit
1366 int and getting a pointer to member function via non-standard syntax.
1367
1368 @item -fno-nonansi-builtins
1369 @opindex fno-nonansi-builtins
1370 Disable built-in declarations of functions that are not mandated by
1371 ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
1372 @code{index}, @code{bzero}, @code{conjf}, and other related functions.
1373
1374 @item -fno-operator-names
1375 @opindex fno-operator-names
1376 Do not treat the operator name keywords @code{and}, @code{bitand},
1377 @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
1378 synonyms as keywords.
1379
1380 @item -fno-optional-diags
1381 @opindex fno-optional-diags
1382 Disable diagnostics that the standard says a compiler does not need to
1383 issue. Currently, the only such diagnostic issued by G++ is the one for
1384 a name having multiple meanings within a class.
1385
1386 @item -fpermissive
1387 @opindex fpermissive
1388 Downgrade some diagnostics about nonconformant code from errors to
1389 warnings. Thus, using @option{-fpermissive} will allow some
1390 nonconforming code to compile.
1391
1392 @item -frepo
1393 @opindex frepo
1394 Enable automatic template instantiation at link time. This option also
1395 implies @option{-fno-implicit-templates}. @xref{Template
1396 Instantiation}, for more information.
1397
1398 @item -fno-rtti
1399 @opindex fno-rtti
1400 Disable generation of information about every class with virtual
1401 functions for use by the C++ runtime type identification features
1402 (@samp{dynamic_cast} and @samp{typeid}). If you don't use those parts
1403 of the language, you can save some space by using this flag. Note that
1404 exception handling uses the same information, but it will generate it as
1405 needed.
1406
1407 @item -fstats
1408 @opindex fstats
1409 Emit statistics about front-end processing at the end of the compilation.
1410 This information is generally only useful to the G++ development team.
1411
1412 @item -ftemplate-depth-@var{n}
1413 @opindex ftemplate-depth
1414 Set the maximum instantiation depth for template classes to @var{n}.
1415 A limit on the template instantiation depth is needed to detect
1416 endless recursions during template class instantiation. ANSI/ISO C++
1417 conforming programs must not rely on a maximum depth greater than 17.
1418
1419 @item -fuse-cxa-atexit
1420 @opindex fuse-cxa-atexit
1421 Register destructors for objects with static storage duration with the
1422 @code{__cxa_atexit} function rather than the @code{atexit} function.
1423 This option is required for fully standards-compliant handling of static
1424 destructors, but will only work if your C library supports
1425 @code{__cxa_atexit}.
1426
1427 @item -fno-weak
1428 @opindex fno-weak
1429 Do not use weak symbol support, even if it is provided by the linker.
1430 By default, G++ will use weak symbols if they are available. This
1431 option exists only for testing, and should not be used by end-users;
1432 it will result in inferior code and has no benefits. This option may
1433 be removed in a future release of G++.
1434
1435 @item -nostdinc++
1436 @opindex nostdinc++
1437 Do not search for header files in the standard directories specific to
1438 C++, but do still search the other standard directories. (This option
1439 is used when building the C++ library.)
1440 @end table
1441
1442 In addition, these optimization, warning, and code generation options
1443 have meanings only for C++ programs:
1444
1445 @table @gcctabopt
1446 @item -fno-default-inline
1447 @opindex fno-default-inline
1448 Do not assume @samp{inline} for functions defined inside a class scope.
1449 @xref{Optimize Options,,Options That Control Optimization}. Note that these
1450 functions will have linkage like inline functions; they just won't be
1451 inlined by default.
1452
1453 @item -Wabi @r{(C++ only)}
1454 @opindex Wabi
1455 Warn when G++ generates code that is probably not compatible with the
1456 vendor-neutral C++ ABI. Although an effort has been made to warn about
1457 all such cases, there are probably some cases that are not warned about,
1458 even though G++ is generating incompatible code. There may also be
1459 cases where warnings are emitted even though the code that is generated
1460 will be compatible.
1461
1462 You should rewrite your code to avoid these warnings if you are
1463 concerned about the fact that code generated by G++ may not be binary
1464 compatible with code generated by other compilers.
1465
1466 The known incompatibilities at this point include:
1467
1468 @itemize @bullet
1469
1470 @item
1471 Incorrect handling of tail-padding for bit-fields. G++ may attempt to
1472 pack data into the same byte as a base class. For example:
1473
1474 @smallexample
1475 struct A @{ virtual void f(); int f1 : 1; @};
1476 struct B : public A @{ int f2 : 1; @};
1477 @end smallexample
1478
1479 @noindent
1480 In this case, G++ will place @code{B::f2} into the same byte
1481 as@code{A::f1}; other compilers will not. You can avoid this problem
1482 by explicitly padding @code{A} so that its size is a multiple of the
1483 byte size on your platform; that will cause G++ and other compilers to
1484 layout @code{B} identically.
1485
1486 @item
1487 Incorrect handling of tail-padding for virtual bases. G++ does not use
1488 tail padding when laying out virtual bases. For example:
1489
1490 @smallexample
1491 struct A @{ virtual void f(); char c1; @};
1492 struct B @{ B(); char c2; @};
1493 struct C : public A, public virtual B @{@};
1494 @end smallexample
1495
1496 @noindent
1497 In this case, G++ will not place @code{B} into the tail-padding for
1498 @code{A}; other compilers will. You can avoid this problem by
1499 explicitly padding @code{A} so that its size is a multiple of its
1500 alignment (ignoring virtual base classes); that will cause G++ and other
1501 compilers to layout @code{C} identically.
1502
1503 @item
1504 Incorrect handling of bit-fields with declared widths greater than that
1505 of their underlying types, when the bit-fields appear in a union. For
1506 example:
1507
1508 @smallexample
1509 union U @{ int i : 4096; @};
1510 @end smallexample
1511
1512 @noindent
1513 Assuming that an @code{int} does not have 4096 bits, G++ will make the
1514 union too small by the number of bits in an @code{int}.
1515
1516 @item
1517 Empty classes can be placed at incorrect offsets. For example:
1518
1519 @smallexample
1520 struct A @{@};
1521
1522 struct B @{
1523 A a;
1524 virtual void f ();
1525 @};
1526
1527 struct C : public B, public A @{@};
1528 @end smallexample
1529
1530 @noindent
1531 G++ will place the @code{A} base class of @code{C} at a nonzero offset;
1532 it should be placed at offset zero. G++ mistakenly believes that the
1533 @code{A} data member of @code{B} is already at offset zero.
1534
1535 @item
1536 Names of template functions whose types involve @code{typename} or
1537 template template parameters can be mangled incorrectly.
1538
1539 @smallexample
1540 template <typename Q>
1541 void f(typename Q::X) @{@}
1542
1543 template <template <typename> class Q>
1544 void f(typename Q<int>::X) @{@}
1545 @end smallexample
1546
1547 @noindent
1548 Instantiations of these templates may be mangled incorrectly.
1549
1550 @end itemize
1551
1552 @item -Wctor-dtor-privacy @r{(C++ only)}
1553 @opindex Wctor-dtor-privacy
1554 Warn when a class seems unusable because all the constructors or
1555 destructors in that class are private, and it has neither friends nor
1556 public static member functions.
1557
1558 @item -Wnon-virtual-dtor @r{(C++ only)}
1559 @opindex Wnon-virtual-dtor
1560 Warn when a class appears to be polymorphic, thereby requiring a virtual
1561 destructor, yet it declares a non-virtual one.
1562 This warning is enabled by @option{-Wall}.
1563
1564 @item -Wreorder @r{(C++ only)}
1565 @opindex Wreorder
1566 @cindex reordering, warning
1567 @cindex warning for reordering of member initializers
1568 Warn when the order of member initializers given in the code does not
1569 match the order in which they must be executed. For instance:
1570
1571 @smallexample
1572 struct A @{
1573 int i;
1574 int j;
1575 A(): j (0), i (1) @{ @}
1576 @};
1577 @end smallexample
1578
1579 The compiler will rearrange the member initializers for @samp{i}
1580 and @samp{j} to match the declaration order of the members, emitting
1581 a warning to that effect. This warning is enabled by @option{-Wall}.
1582 @end table
1583
1584 The following @option{-W@dots{}} options are not affected by @option{-Wall}.
1585
1586 @table @gcctabopt
1587 @item -Weffc++ @r{(C++ only)}
1588 @opindex Weffc++
1589 Warn about violations of the following style guidelines from Scott Meyers'
1590 @cite{Effective C++} book:
1591
1592 @itemize @bullet
1593 @item
1594 Item 11: Define a copy constructor and an assignment operator for classes
1595 with dynamically allocated memory.
1596
1597 @item
1598 Item 12: Prefer initialization to assignment in constructors.
1599
1600 @item
1601 Item 14: Make destructors virtual in base classes.
1602
1603 @item
1604 Item 15: Have @code{operator=} return a reference to @code{*this}.
1605
1606 @item
1607 Item 23: Don't try to return a reference when you must return an object.
1608
1609 @end itemize
1610
1611 Also warn about violations of the following style guidelines from
1612 Scott Meyers' @cite{More Effective C++} book:
1613
1614 @itemize @bullet
1615 @item
1616 Item 6: Distinguish between prefix and postfix forms of increment and
1617 decrement operators.
1618
1619 @item
1620 Item 7: Never overload @code{&&}, @code{||}, or @code{,}.
1621
1622 @end itemize
1623
1624 When selecting this option, be aware that the standard library
1625 headers do not obey all of these guidelines; use @samp{grep -v}
1626 to filter out those warnings.
1627
1628 @item -Wno-deprecated @r{(C++ only)}
1629 @opindex Wno-deprecated
1630 Do not warn about usage of deprecated features. @xref{Deprecated Features}.
1631
1632 @item -Wno-non-template-friend @r{(C++ only)}
1633 @opindex Wno-non-template-friend
1634 Disable warnings when non-templatized friend functions are declared
1635 within a template. Since the advent of explicit template specification
1636 support in G++, if the name of the friend is an unqualified-id (i.e.,
1637 @samp{friend foo(int)}), the C++ language specification demands that the
1638 friend declare or define an ordinary, nontemplate function. (Section
1639 14.5.3). Before G++ implemented explicit specification, unqualified-ids
1640 could be interpreted as a particular specialization of a templatized
1641 function. Because this non-conforming behavior is no longer the default
1642 behavior for G++, @option{-Wnon-template-friend} allows the compiler to
1643 check existing code for potential trouble spots and is on by default.
1644 This new compiler behavior can be turned off with
1645 @option{-Wno-non-template-friend} which keeps the conformant compiler code
1646 but disables the helpful warning.
1647
1648 @item -Wold-style-cast @r{(C++ only)}
1649 @opindex Wold-style-cast
1650 Warn if an old-style (C-style) cast to a non-void type is used within
1651 a C++ program. The new-style casts (@samp{static_cast},
1652 @samp{reinterpret_cast}, and @samp{const_cast}) are less vulnerable to
1653 unintended effects and much easier to search for.
1654
1655 @item -Woverloaded-virtual @r{(C++ only)}
1656 @opindex Woverloaded-virtual
1657 @cindex overloaded virtual fn, warning
1658 @cindex warning for overloaded virtual fn
1659 Warn when a function declaration hides virtual functions from a
1660 base class. For example, in:
1661
1662 @smallexample
1663 struct A @{
1664 virtual void f();
1665 @};
1666
1667 struct B: public A @{
1668 void f(int);
1669 @};
1670 @end smallexample
1671
1672 the @code{A} class version of @code{f} is hidden in @code{B}, and code
1673 like:
1674
1675 @smallexample
1676 B* b;
1677 b->f();
1678 @end smallexample
1679
1680 will fail to compile.
1681
1682 @item -Wno-pmf-conversions @r{(C++ only)}
1683 @opindex Wno-pmf-conversions
1684 Disable the diagnostic for converting a bound pointer to member function
1685 to a plain pointer.
1686
1687 @item -Wsign-promo @r{(C++ only)}
1688 @opindex Wsign-promo
1689 Warn when overload resolution chooses a promotion from unsigned or
1690 enumeral type to a signed type, over a conversion to an unsigned type of
1691 the same size. Previous versions of G++ would try to preserve
1692 unsignedness, but the standard mandates the current behavior.
1693
1694 @item -Wsynth @r{(C++ only)}
1695 @opindex Wsynth
1696 @cindex warning for synthesized methods
1697 @cindex synthesized methods, warning
1698 Warn when G++'s synthesis behavior does not match that of cfront. For
1699 instance:
1700
1701 @smallexample
1702 struct A @{
1703 operator int ();
1704 A& operator = (int);
1705 @};
1706
1707 main ()
1708 @{
1709 A a,b;
1710 a = b;
1711 @}
1712 @end smallexample
1713
1714 In this example, G++ will synthesize a default @samp{A& operator =
1715 (const A&);}, while cfront will use the user-defined @samp{operator =}.
1716 @end table
1717
1718 @node Objective-C Dialect Options
1719 @section Options Controlling Objective-C Dialect
1720
1721 @cindex compiler options, Objective-C
1722 @cindex Objective-C options, command line
1723 @cindex options, Objective-C
1724 (NOTE: This manual does not describe the Objective-C language itself. See
1725 @w{@uref{http://gcc.gnu.org/readings.html}} for references.)
1726
1727 This section describes the command-line options that are only meaningful
1728 for Objective-C programs, but you can also use most of the GNU compiler
1729 options regardless of what language your program is in. For example,
1730 you might compile a file @code{some_class.m} like this:
1731
1732 @smallexample
1733 gcc -g -fgnu-runtime -O -c some_class.m
1734 @end smallexample
1735
1736 @noindent
1737 In this example, @option{-fgnu-runtime} is an option meant only for
1738 Objective-C programs; you can use the other options with any language
1739 supported by GCC@.
1740
1741 Here is a list of options that are @emph{only} for compiling Objective-C
1742 programs:
1743
1744 @table @gcctabopt
1745 @item -fconstant-string-class=@var{class-name}
1746 @opindex fconstant-string-class
1747 Use @var{class-name} as the name of the class to instantiate for each
1748 literal string specified with the syntax @code{@@"@dots{}"}. The default
1749 class name is @code{NXConstantString} if the GNU runtime is being used, and
1750 @code{NSConstantString} if the NeXT runtime is being used (see below). The
1751 @option{-fconstant-cfstrings} option, if also present, will override the
1752 @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals
1753 to be laid out as constant CoreFoundation strings.
1754
1755 @item -fgnu-runtime
1756 @opindex fgnu-runtime
1757 Generate object code compatible with the standard GNU Objective-C
1758 runtime. This is the default for most types of systems.
1759
1760 @item -fnext-runtime
1761 @opindex fnext-runtime
1762 Generate output compatible with the NeXT runtime. This is the default
1763 for NeXT-based systems, including Darwin and Mac OS X@. The macro
1764 @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
1765 used.
1766
1767 @item -fno-nil-receivers
1768 @opindex fno-nil-receivers
1769 Assume that all Objective-C message dispatches (e.g.,
1770 @code{[receiver message:arg]}) in this translation unit ensure that the receiver
1771 is not @code{nil}. This allows for more efficient entry points in the runtime to be
1772 used. Currently, this option is only available in conjunction with
1773 the NeXT runtime on Mac OS X 10.3 and later.
1774
1775 @item -fobjc-exceptions
1776 @opindex fobjc-exceptions
1777 Enable syntactic support for structured exception handling in Objective-C,
1778 similar to what is offered by C++ and Java. Currently, this option is only
1779 available in conjunction with the NeXT runtime on Mac OS X 10.3 and later.
1780
1781 @smallexample
1782 @@try @{
1783 @dots{}
1784 @@throw expr;
1785 @dots{}
1786 @}
1787 @@catch (AnObjCClass *exc) @{
1788 @dots{}
1789 @@throw expr;
1790 @dots{}
1791 @@throw;
1792 @dots{}
1793 @}
1794 @@catch (AnotherClass *exc) @{
1795 @dots{}
1796 @}
1797 @@catch (id allOthers) @{
1798 @dots{}
1799 @}
1800 @@finally @{
1801 @dots{}
1802 @@throw expr;
1803 @dots{}
1804 @}
1805 @end smallexample
1806
1807 The @code{@@throw} statement may appear anywhere in an Objective-C or
1808 Objective-C++ program; when used inside of a @code{@@catch} block, the
1809 @code{@@throw} may appear without an argument (as shown above), in which case
1810 the object caught by the @code{@@catch} will be rethrown.
1811
1812 Note that only (pointers to) Objective-C objects may be thrown and
1813 caught using this scheme. When an object is thrown, it will be caught
1814 by the nearest @code{@@catch} clause capable of handling objects of that type,
1815 analogously to how @code{catch} blocks work in C++ and Java. A
1816 @code{@@catch(id @dots{})} clause (as shown above) may also be provided to catch
1817 any and all Objective-C exceptions not caught by previous @code{@@catch}
1818 clauses (if any).
1819
1820 The @code{@@finally} clause, if present, will be executed upon exit from the
1821 immediately preceding @code{@@try @dots{} @@catch} section. This will happen
1822 regardless of whether any exceptions are thrown, caught or rethrown
1823 inside the @code{@@try @dots{} @@catch} section, analogously to the behavior
1824 of the @code{finally} clause in Java.
1825
1826 There are several caveats to using the new exception mechanism:
1827
1828 @itemize @bullet
1829 @item
1830 Although currently designed to be binary compatible with @code{NS_HANDLER}-style
1831 idioms provided by the @code{NSException} class, the new
1832 exceptions can only be used on Mac OS X 10.3 (Panther) and later
1833 systems, due to additional functionality needed in the (NeXT) Objective-C
1834 runtime.
1835
1836 @item
1837 As mentioned above, the new exceptions do not support handling
1838 types other than Objective-C objects. Furthermore, when used from
1839 Objective-C++, the Objective-C exception model does not interoperate with C++
1840 exceptions at this time. This means you cannot @code{@@throw} an exception
1841 from Objective-C and @code{catch} it in C++, or vice versa
1842 (i.e., @code{throw @dots{} @@catch}).
1843 @end itemize
1844
1845 The @option{-fobjc-exceptions} switch also enables the use of synchronization
1846 blocks for thread-safe execution:
1847
1848 @smallexample
1849 @@synchronized (ObjCClass *guard) @{
1850 @dots{}
1851 @}
1852 @end smallexample
1853
1854 Upon entering the @code{@@synchronized} block, a thread of execution shall
1855 first check whether a lock has been placed on the corresponding @code{guard}
1856 object by another thread. If it has, the current thread shall wait until
1857 the other thread relinquishes its lock. Once @code{guard} becomes available,
1858 the current thread will place its own lock on it, execute the code contained in
1859 the @code{@@synchronized} block, and finally relinquish the lock (thereby
1860 making @code{guard} available to other threads).
1861
1862 Unlike Java, Objective-C does not allow for entire methods to be marked
1863 @code{@@synchronized}. Note that throwing exceptions out of
1864 @code{@@synchronized} blocks is allowed, and will cause the guarding object
1865 to be unlocked properly.
1866
1867 @item -freplace-objc-classes
1868 @opindex freplace-objc-classes
1869 Emit a special marker instructing @command{ld(1)} not to statically link in
1870 the resulting object file, and allow @command{dyld(1)} to load it in at
1871 run time instead. This is used in conjunction with the Fix-and-Continue
1872 debugging mode, where the object file in question may be recompiled and
1873 dynamically reloaded in the course of program execution, without the need
1874 to restart the program itself. Currently, Fix-and-Continue functionality
1875 is only available in conjunction with the NeXT runtime on Mac OS X 10.3
1876 and later.
1877
1878 @item -fzero-link
1879 @opindex fzero-link
1880 When compiling for the NeXT runtime, the compiler ordinarily replaces calls
1881 to @code{objc_getClass("@dots{}")} (when the name of the class is known at
1882 compile time) with static class references that get initialized at load time,
1883 which improves run-time performance. Specifying the @option{-fzero-link} flag
1884 suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
1885 to be retained. This is useful in Zero-Link debugging mode, since it allows
1886 for individual class implementations to be modified during program execution.
1887
1888 @item -gen-decls
1889 @opindex gen-decls
1890 Dump interface declarations for all classes seen in the source file to a
1891 file named @file{@var{sourcename}.decl}.
1892
1893 @item -Wno-protocol
1894 @opindex Wno-protocol
1895 If a class is declared to implement a protocol, a warning is issued for
1896 every method in the protocol that is not implemented by the class. The
1897 default behavior is to issue a warning for every method not explicitly
1898 implemented in the class, even if a method implementation is inherited
1899 from the superclass. If you use the @code{-Wno-protocol} option, then
1900 methods inherited from the superclass are considered to be implemented,
1901 and no warning is issued for them.
1902
1903 @item -Wselector
1904 @opindex Wselector
1905 Warn if multiple methods of different types for the same selector are
1906 found during compilation. The check is performed on the list of methods
1907 in the final stage of compilation. Additionally, a check is performed
1908 for each selector appearing in a @code{@@selector(@dots{})}
1909 expression, and a corresponding method for that selector has been found
1910 during compilation. Because these checks scan the method table only at
1911 the end of compilation, these warnings are not produced if the final
1912 stage of compilation is not reached, for example because an error is
1913 found during compilation, or because the @code{-fsyntax-only} option is
1914 being used.
1915
1916 @item -Wundeclared-selector
1917 @opindex Wundeclared-selector
1918 Warn if a @code{@@selector(@dots{})} expression referring to an
1919 undeclared selector is found. A selector is considered undeclared if no
1920 method with that name has been declared before the
1921 @code{@@selector(@dots{})} expression, either explicitly in an
1922 @code{@@interface} or @code{@@protocol} declaration, or implicitly in
1923 an @code{@@implementation} section. This option always performs its
1924 checks as soon as a @code{@@selector(@dots{})} expression is found,
1925 while @code{-Wselector} only performs its checks in the final stage of
1926 compilation. This also enforces the coding style convention
1927 that methods and selectors must be declared before being used.
1928
1929 @item -print-objc-runtime-info
1930 @opindex print-objc-runtime-info
1931 Generate C header describing the largest structure that is passed by
1932 value, if any.
1933
1934 @end table
1935
1936 @node Language Independent Options
1937 @section Options to Control Diagnostic Messages Formatting
1938 @cindex options to control diagnostics formatting
1939 @cindex diagnostic messages
1940 @cindex message formatting
1941
1942 Traditionally, diagnostic messages have been formatted irrespective of
1943 the output device's aspect (e.g.@: its width, @dots{}). The options described
1944 below can be used to control the diagnostic messages formatting
1945 algorithm, e.g.@: how many characters per line, how often source location
1946 information should be reported. Right now, only the C++ front end can
1947 honor these options. However it is expected, in the near future, that
1948 the remaining front ends would be able to digest them correctly.
1949
1950 @table @gcctabopt
1951 @item -fmessage-length=@var{n}
1952 @opindex fmessage-length
1953 Try to format error messages so that they fit on lines of about @var{n}
1954 characters. The default is 72 characters for @command{g++} and 0 for the rest of
1955 the front ends supported by GCC@. If @var{n} is zero, then no
1956 line-wrapping will be done; each error message will appear on a single
1957 line.
1958
1959 @opindex fdiagnostics-show-location
1960 @item -fdiagnostics-show-location=once
1961 Only meaningful in line-wrapping mode. Instructs the diagnostic messages
1962 reporter to emit @emph{once} source location information; that is, in
1963 case the message is too long to fit on a single physical line and has to
1964 be wrapped, the source location won't be emitted (as prefix) again,
1965 over and over, in subsequent continuation lines. This is the default
1966 behavior.
1967
1968 @item -fdiagnostics-show-location=every-line
1969 Only meaningful in line-wrapping mode. Instructs the diagnostic
1970 messages reporter to emit the same source location information (as
1971 prefix) for physical lines that result from the process of breaking
1972 a message which is too long to fit on a single line.
1973
1974 @end table
1975
1976 @node Warning Options
1977 @section Options to Request or Suppress Warnings
1978 @cindex options to control warnings
1979 @cindex warning messages
1980 @cindex messages, warning
1981 @cindex suppressing warnings
1982
1983 Warnings are diagnostic messages that report constructions which
1984 are not inherently erroneous but which are risky or suggest there
1985 may have been an error.
1986
1987 You can request many specific warnings with options beginning @samp{-W},
1988 for example @option{-Wimplicit} to request warnings on implicit
1989 declarations. Each of these specific warning options also has a
1990 negative form beginning @samp{-Wno-} to turn off warnings;
1991 for example, @option{-Wno-implicit}. This manual lists only one of the
1992 two forms, whichever is not the default.
1993
1994 The following options control the amount and kinds of warnings produced
1995 by GCC; for further, language-specific options also refer to
1996 @ref{C++ Dialect Options} and @ref{Objective-C Dialect Options}.
1997
1998 @table @gcctabopt
1999 @cindex syntax checking
2000 @item -fsyntax-only
2001 @opindex fsyntax-only
2002 Check the code for syntax errors, but don't do anything beyond that.
2003
2004 @item -pedantic
2005 @opindex pedantic
2006 Issue all the warnings demanded by strict ISO C and ISO C++;
2007 reject all programs that use forbidden extensions, and some other
2008 programs that do not follow ISO C and ISO C++. For ISO C, follows the
2009 version of the ISO C standard specified by any @option{-std} option used.
2010
2011 Valid ISO C and ISO C++ programs should compile properly with or without
2012 this option (though a rare few will require @option{-ansi} or a
2013 @option{-std} option specifying the required version of ISO C)@. However,
2014 without this option, certain GNU extensions and traditional C and C++
2015 features are supported as well. With this option, they are rejected.
2016
2017 @option{-pedantic} does not cause warning messages for use of the
2018 alternate keywords whose names begin and end with @samp{__}. Pedantic
2019 warnings are also disabled in the expression that follows
2020 @code{__extension__}. However, only system header files should use
2021 these escape routes; application programs should avoid them.
2022 @xref{Alternate Keywords}.
2023
2024 Some users try to use @option{-pedantic} to check programs for strict ISO
2025 C conformance. They soon find that it does not do quite what they want:
2026 it finds some non-ISO practices, but not all---only those for which
2027 ISO C @emph{requires} a diagnostic, and some others for which
2028 diagnostics have been added.
2029
2030 A feature to report any failure to conform to ISO C might be useful in
2031 some instances, but would require considerable additional work and would
2032 be quite different from @option{-pedantic}. We don't have plans to
2033 support such a feature in the near future.
2034
2035 Where the standard specified with @option{-std} represents a GNU
2036 extended dialect of C, such as @samp{gnu89} or @samp{gnu99}, there is a
2037 corresponding @dfn{base standard}, the version of ISO C on which the GNU
2038 extended dialect is based. Warnings from @option{-pedantic} are given
2039 where they are required by the base standard. (It would not make sense
2040 for such warnings to be given only for features not in the specified GNU
2041 C dialect, since by definition the GNU dialects of C include all
2042 features the compiler supports with the given option, and there would be
2043 nothing to warn about.)
2044
2045 @item -pedantic-errors
2046 @opindex pedantic-errors
2047 Like @option{-pedantic}, except that errors are produced rather than
2048 warnings.
2049
2050 @item -w
2051 @opindex w
2052 Inhibit all warning messages.
2053
2054 @item -Wno-import
2055 @opindex Wno-import
2056 Inhibit warning messages about the use of @samp{#import}.
2057
2058 @item -Wchar-subscripts
2059 @opindex Wchar-subscripts
2060 Warn if an array subscript has type @code{char}. This is a common cause
2061 of error, as programmers often forget that this type is signed on some
2062 machines.
2063
2064 @item -Wcomment
2065 @opindex Wcomment
2066 Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*}
2067 comment, or whenever a Backslash-Newline appears in a @samp{//} comment.
2068
2069 @item -Wfatal-errors
2070 @opindex Wfatal-errors
2071 This option causes the compiler to abort compilation on the first error
2072 occurred rather than trying to keep going and printing further error
2073 messages.
2074
2075 @item -Wformat
2076 @opindex Wformat
2077 Check calls to @code{printf} and @code{scanf}, etc., to make sure that
2078 the arguments supplied have types appropriate to the format string
2079 specified, and that the conversions specified in the format string make
2080 sense. This includes standard functions, and others specified by format
2081 attributes (@pxref{Function Attributes}), in the @code{printf},
2082 @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
2083 not in the C standard) families.
2084
2085 The formats are checked against the format features supported by GNU
2086 libc version 2.2. These include all ISO C90 and C99 features, as well
2087 as features from the Single Unix Specification and some BSD and GNU
2088 extensions. Other library implementations may not support all these
2089 features; GCC does not support warning about features that go beyond a
2090 particular library's limitations. However, if @option{-pedantic} is used
2091 with @option{-Wformat}, warnings will be given about format features not
2092 in the selected standard version (but not for @code{strfmon} formats,
2093 since those are not in any version of the C standard). @xref{C Dialect
2094 Options,,Options Controlling C Dialect}.
2095
2096 Since @option{-Wformat} also checks for null format arguments for
2097 several functions, @option{-Wformat} also implies @option{-Wnonnull}.
2098
2099 @option{-Wformat} is included in @option{-Wall}. For more control over some
2100 aspects of format checking, the options @option{-Wformat-y2k},
2101 @option{-Wno-format-extra-args}, @option{-Wno-format-zero-length},
2102 @option{-Wformat-nonliteral}, @option{-Wformat-security}, and
2103 @option{-Wformat=2} are available, but are not included in @option{-Wall}.
2104
2105 @item -Wformat-y2k
2106 @opindex Wformat-y2k
2107 If @option{-Wformat} is specified, also warn about @code{strftime}
2108 formats which may yield only a two-digit year.
2109
2110 @item -Wno-format-extra-args
2111 @opindex Wno-format-extra-args
2112 If @option{-Wformat} is specified, do not warn about excess arguments to a
2113 @code{printf} or @code{scanf} format function. The C standard specifies
2114 that such arguments are ignored.
2115
2116 Where the unused arguments lie between used arguments that are
2117 specified with @samp{$} operand number specifications, normally
2118 warnings are still given, since the implementation could not know what
2119 type to pass to @code{va_arg} to skip the unused arguments. However,
2120 in the case of @code{scanf} formats, this option will suppress the
2121 warning if the unused arguments are all pointers, since the Single
2122 Unix Specification says that such unused arguments are allowed.
2123
2124 @item -Wno-format-zero-length
2125 @opindex Wno-format-zero-length
2126 If @option{-Wformat} is specified, do not warn about zero-length formats.
2127 The C standard specifies that zero-length formats are allowed.
2128
2129 @item -Wformat-nonliteral
2130 @opindex Wformat-nonliteral
2131 If @option{-Wformat} is specified, also warn if the format string is not a
2132 string literal and so cannot be checked, unless the format function
2133 takes its format arguments as a @code{va_list}.
2134
2135 @item -Wformat-security
2136 @opindex Wformat-security
2137 If @option{-Wformat} is specified, also warn about uses of format
2138 functions that represent possible security problems. At present, this
2139 warns about calls to @code{printf} and @code{scanf} functions where the
2140 format string is not a string literal and there are no format arguments,
2141 as in @code{printf (foo);}. This may be a security hole if the format
2142 string came from untrusted input and contains @samp{%n}. (This is
2143 currently a subset of what @option{-Wformat-nonliteral} warns about, but
2144 in future warnings may be added to @option{-Wformat-security} that are not
2145 included in @option{-Wformat-nonliteral}.)
2146
2147 @item -Wformat=2
2148 @opindex Wformat=2
2149 Enable @option{-Wformat} plus format checks not included in
2150 @option{-Wformat}. Currently equivalent to @samp{-Wformat
2151 -Wformat-nonliteral -Wformat-security -Wformat-y2k}.
2152
2153 @item -Wnonnull
2154 @opindex Wnonnull
2155 Warn about passing a null pointer for arguments marked as
2156 requiring a non-null value by the @code{nonnull} function attribute.
2157
2158 @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
2159 can be disabled with the @option{-Wno-nonnull} option.
2160
2161 @item -Winit-self @r{(C, C++, and Objective-C only)}
2162 @opindex Winit-self
2163 Warn about uninitialized variables which are initialized with themselves.
2164 Note this option can only be used with the @option{-Wuninitialized} option,
2165 which in turn only works with @option{-O1} and above.
2166
2167 For example, GCC will warn about @code{i} being uninitialized in the
2168 following snippet only when @option{-Winit-self} has been specified:
2169 @smallexample
2170 @group
2171 int f()
2172 @{
2173 int i = i;
2174 return i;
2175 @}
2176 @end group
2177 @end smallexample
2178
2179 @item -Wimplicit-int
2180 @opindex Wimplicit-int
2181 Warn when a declaration does not specify a type.
2182
2183 @item -Wimplicit-function-declaration
2184 @itemx -Werror-implicit-function-declaration
2185 @opindex Wimplicit-function-declaration
2186 @opindex Werror-implicit-function-declaration
2187 Give a warning (or error) whenever a function is used before being
2188 declared.
2189
2190 @item -Wimplicit
2191 @opindex Wimplicit
2192 Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
2193
2194 @item -Wmain
2195 @opindex Wmain
2196 Warn if the type of @samp{main} is suspicious. @samp{main} should be a
2197 function with external linkage, returning int, taking either zero
2198 arguments, two, or three arguments of appropriate types.
2199
2200 @item -Wmissing-braces
2201 @opindex Wmissing-braces
2202 Warn if an aggregate or union initializer is not fully bracketed. In
2203 the following example, the initializer for @samp{a} is not fully
2204 bracketed, but that for @samp{b} is fully bracketed.
2205
2206 @smallexample
2207 int a[2][2] = @{ 0, 1, 2, 3 @};
2208 int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
2209 @end smallexample
2210
2211 @item -Wparentheses
2212 @opindex Wparentheses
2213 Warn if parentheses are omitted in certain contexts, such
2214 as when there is an assignment in a context where a truth value
2215 is expected, or when operators are nested whose precedence people
2216 often get confused about.
2217
2218 Also warn about constructions where there may be confusion to which
2219 @code{if} statement an @code{else} branch belongs. Here is an example of
2220 such a case:
2221
2222 @smallexample
2223 @group
2224 @{
2225 if (a)
2226 if (b)
2227 foo ();
2228 else
2229 bar ();
2230 @}
2231 @end group
2232 @end smallexample
2233
2234 In C, every @code{else} branch belongs to the innermost possible @code{if}
2235 statement, which in this example is @code{if (b)}. This is often not
2236 what the programmer expected, as illustrated in the above example by
2237 indentation the programmer chose. When there is the potential for this
2238 confusion, GCC will issue a warning when this flag is specified.
2239 To eliminate the warning, add explicit braces around the innermost
2240 @code{if} statement so there is no way the @code{else} could belong to
2241 the enclosing @code{if}. The resulting code would look like this:
2242
2243 @smallexample
2244 @group
2245 @{
2246 if (a)
2247 @{
2248 if (b)
2249 foo ();
2250 else
2251 bar ();
2252 @}
2253 @}
2254 @end group
2255 @end smallexample
2256
2257 @item -Wsequence-point
2258 @opindex Wsequence-point
2259 Warn about code that may have undefined semantics because of violations
2260 of sequence point rules in the C standard.
2261
2262 The C standard defines the order in which expressions in a C program are
2263 evaluated in terms of @dfn{sequence points}, which represent a partial
2264 ordering between the execution of parts of the program: those executed
2265 before the sequence point, and those executed after it. These occur
2266 after the evaluation of a full expression (one which is not part of a
2267 larger expression), after the evaluation of the first operand of a
2268 @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
2269 function is called (but after the evaluation of its arguments and the
2270 expression denoting the called function), and in certain other places.
2271 Other than as expressed by the sequence point rules, the order of
2272 evaluation of subexpressions of an expression is not specified. All
2273 these rules describe only a partial order rather than a total order,
2274 since, for example, if two functions are called within one expression
2275 with no sequence point between them, the order in which the functions
2276 are called is not specified. However, the standards committee have
2277 ruled that function calls do not overlap.
2278
2279 It is not specified when between sequence points modifications to the
2280 values of objects take effect. Programs whose behavior depends on this
2281 have undefined behavior; the C standard specifies that ``Between the
2282 previous and next sequence point an object shall have its stored value
2283 modified at most once by the evaluation of an expression. Furthermore,
2284 the prior value shall be read only to determine the value to be
2285 stored.''. If a program breaks these rules, the results on any
2286 particular implementation are entirely unpredictable.
2287
2288 Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
2289 = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
2290 diagnosed by this option, and it may give an occasional false positive
2291 result, but in general it has been found fairly effective at detecting
2292 this sort of problem in programs.
2293
2294 The present implementation of this option only works for C programs. A
2295 future implementation may also work for C++ programs.
2296
2297 The C standard is worded confusingly, therefore there is some debate
2298 over the precise meaning of the sequence point rules in subtle cases.
2299 Links to discussions of the problem, including proposed formal
2300 definitions, may be found on our readings page, at
2301 @w{@uref{http://gcc.gnu.org/readings.html}}.
2302
2303 @item -Wreturn-type
2304 @opindex Wreturn-type
2305 Warn whenever a function is defined with a return-type that defaults to
2306 @code{int}. Also warn about any @code{return} statement with no
2307 return-value in a function whose return-type is not @code{void}.
2308
2309 For C++, a function without return type always produces a diagnostic
2310 message, even when @option{-Wno-return-type} is specified. The only
2311 exceptions are @samp{main} and functions defined in system headers.
2312
2313 @item -Wswitch
2314 @opindex Wswitch
2315 Warn whenever a @code{switch} statement has an index of enumeral type
2316 and lacks a @code{case} for one or more of the named codes of that
2317 enumeration. (The presence of a @code{default} label prevents this
2318 warning.) @code{case} labels outside the enumeration range also
2319 provoke warnings when this option is used.
2320
2321 @item -Wswitch-default
2322 @opindex Wswitch-switch
2323 Warn whenever a @code{switch} statement does not have a @code{default}
2324 case.
2325
2326 @item -Wswitch-enum
2327 @opindex Wswitch-enum
2328 Warn whenever a @code{switch} statement has an index of enumeral type
2329 and lacks a @code{case} for one or more of the named codes of that
2330 enumeration. @code{case} labels outside the enumeration range also
2331 provoke warnings when this option is used.
2332
2333 @item -Wtrigraphs
2334 @opindex Wtrigraphs
2335 Warn if any trigraphs are encountered that might change the meaning of
2336 the program (trigraphs within comments are not warned about).
2337
2338 @item -Wunused-function
2339 @opindex Wunused-function
2340 Warn whenever a static function is declared but not defined or a
2341 non\-inline static function is unused.
2342
2343 @item -Wunused-label
2344 @opindex Wunused-label
2345 Warn whenever a label is declared but not used.
2346
2347 To suppress this warning use the @samp{unused} attribute
2348 (@pxref{Variable Attributes}).
2349
2350 @item -Wunused-parameter
2351 @opindex Wunused-parameter
2352 Warn whenever a function parameter is unused aside from its declaration.
2353
2354 To suppress this warning use the @samp{unused} attribute
2355 (@pxref{Variable Attributes}).
2356
2357 @item -Wunused-variable
2358 @opindex Wunused-variable
2359 Warn whenever a local variable or non-constant static variable is unused
2360 aside from its declaration
2361
2362 To suppress this warning use the @samp{unused} attribute
2363 (@pxref{Variable Attributes}).
2364
2365 @item -Wunused-value
2366 @opindex Wunused-value
2367 Warn whenever a statement computes a result that is explicitly not used.
2368
2369 To suppress this warning cast the expression to @samp{void}.
2370
2371 @item -Wunused
2372 @opindex Wunused
2373 All the above @option{-Wunused} options combined.
2374
2375 In order to get a warning about an unused function parameter, you must
2376 either specify @samp{-Wextra -Wunused} (note that @samp{-Wall} implies
2377 @samp{-Wunused}), or separately specify @option{-Wunused-parameter}.
2378
2379 @item -Wuninitialized
2380 @opindex Wuninitialized
2381 Warn if an automatic variable is used without first being initialized or
2382 if a variable may be clobbered by a @code{setjmp} call.
2383
2384 These warnings are possible only in optimizing compilation,
2385 because they require data flow information that is computed only
2386 when optimizing. If you don't specify @option{-O}, you simply won't
2387 get these warnings.
2388
2389 If you want to warn about code which uses the uninitialized value of the
2390 variable in its own initializer, use the @option{-Winit-self} option.
2391
2392 These warnings occur only for variables that are candidates for
2393 register allocation. Therefore, they do not occur for a variable that
2394 is declared @code{volatile}, or whose address is taken, or whose size
2395 is other than 1, 2, 4 or 8 bytes. Also, they do not occur for
2396 structures, unions or arrays, even when they are in registers.
2397
2398 Note that there may be no warning about a variable that is used only
2399 to compute a value that itself is never used, because such
2400 computations may be deleted by data flow analysis before the warnings
2401 are printed.
2402
2403 These warnings are made optional because GCC is not smart
2404 enough to see all the reasons why the code might be correct
2405 despite appearing to have an error. Here is one example of how
2406 this can happen:
2407
2408 @smallexample
2409 @group
2410 @{
2411 int x;
2412 switch (y)
2413 @{
2414 case 1: x = 1;
2415 break;
2416 case 2: x = 4;
2417 break;
2418 case 3: x = 5;
2419 @}
2420 foo (x);
2421 @}
2422 @end group
2423 @end smallexample
2424
2425 @noindent
2426 If the value of @code{y} is always 1, 2 or 3, then @code{x} is
2427 always initialized, but GCC doesn't know this. Here is
2428 another common case:
2429
2430 @smallexample
2431 @{
2432 int save_y;
2433 if (change_y) save_y = y, y = new_y;
2434 @dots{}
2435 if (change_y) y = save_y;
2436 @}
2437 @end smallexample
2438
2439 @noindent
2440 This has no bug because @code{save_y} is used only if it is set.
2441
2442 @cindex @code{longjmp} warnings
2443 This option also warns when a non-volatile automatic variable might be
2444 changed by a call to @code{longjmp}. These warnings as well are possible
2445 only in optimizing compilation.
2446
2447 The compiler sees only the calls to @code{setjmp}. It cannot know
2448 where @code{longjmp} will be called; in fact, a signal handler could
2449 call it at any point in the code. As a result, you may get a warning
2450 even when there is in fact no problem because @code{longjmp} cannot
2451 in fact be called at the place which would cause a problem.
2452
2453 Some spurious warnings can be avoided if you declare all the functions
2454 you use that never return as @code{noreturn}. @xref{Function
2455 Attributes}.
2456
2457 @item -Wunknown-pragmas
2458 @opindex Wunknown-pragmas
2459 @cindex warning for unknown pragmas
2460 @cindex unknown pragmas, warning
2461 @cindex pragmas, warning of unknown
2462 Warn when a #pragma directive is encountered which is not understood by
2463 GCC@. If this command line option is used, warnings will even be issued
2464 for unknown pragmas in system header files. This is not the case if
2465 the warnings were only enabled by the @option{-Wall} command line option.
2466
2467 @item -Wstrict-aliasing
2468 @opindex Wstrict-aliasing
2469 This option is only active when @option{-fstrict-aliasing} is active.
2470 It warns about code which might break the strict aliasing rules that the
2471 compiler is using for optimization. The warning does not catch all
2472 cases, but does attempt to catch the more common pitfalls. It is
2473 included in @option{-Wall}.
2474
2475 @item -Wstrict-aliasing=2
2476 @opindex Wstrict-aliasing=2
2477 This option is only active when @option{-fstrict-aliasing} is active.
2478 It warns about all code which might break the strict aliasing rules that the
2479 compiler is using for optimization. This warning catches all cases, but
2480 it will also give a warning for some ambiguous cases that are safe.
2481
2482 @item -Wall
2483 @opindex Wall
2484 All of the above @samp{-W} options combined. This enables all the
2485 warnings about constructions that some users consider questionable, and
2486 that are easy to avoid (or modify to prevent the warning), even in
2487 conjunction with macros. This also enables some language-specific
2488 warnings described in @ref{C++ Dialect Options} and
2489 @ref{Objective-C Dialect Options}.
2490 @end table
2491
2492 The following @option{-W@dots{}} options are not implied by @option{-Wall}.
2493 Some of them warn about constructions that users generally do not
2494 consider questionable, but which occasionally you might wish to check
2495 for; others warn about constructions that are necessary or hard to avoid
2496 in some cases, and there is no simple way to modify the code to suppress
2497 the warning.
2498
2499 @table @gcctabopt
2500 @item -Wextra
2501 @opindex W
2502 @opindex Wextra
2503 (This option used to be called @option{-W}. The older name is still
2504 supported, but the newer name is more descriptive.) Print extra warning
2505 messages for these events:
2506
2507 @itemize @bullet
2508 @item
2509 A function can return either with or without a value. (Falling
2510 off the end of the function body is considered returning without
2511 a value.) For example, this function would evoke such a
2512 warning:
2513
2514 @smallexample
2515 @group
2516 foo (a)
2517 @{
2518 if (a > 0)
2519 return a;
2520 @}
2521 @end group
2522 @end smallexample
2523
2524 @item
2525 An expression-statement or the left-hand side of a comma expression
2526 contains no side effects.
2527 To suppress the warning, cast the unused expression to void.
2528 For example, an expression such as @samp{x[i,j]} will cause a warning,
2529 but @samp{x[(void)i,j]} will not.
2530
2531 @item
2532 An unsigned value is compared against zero with @samp{<} or @samp{>=}.
2533
2534 @item
2535 A comparison like @samp{x<=y<=z} appears; this is equivalent to
2536 @samp{(x<=y ? 1 : 0) <= z}, which is a different interpretation from
2537 that of ordinary mathematical notation.
2538
2539 @item
2540 Storage-class specifiers like @code{static} are not the first things in
2541 a declaration. According to the C Standard, this usage is obsolescent.
2542
2543 @item
2544 The return type of a function has a type qualifier such as @code{const}.
2545 Such a type qualifier has no effect, since the value returned by a
2546 function is not an lvalue. (But don't warn about the GNU extension of
2547 @code{volatile void} return types. That extension will be warned about
2548 if @option{-pedantic} is specified.)
2549
2550 @item
2551 If @option{-Wall} or @option{-Wunused} is also specified, warn about unused
2552 arguments.
2553
2554 @item
2555 A comparison between signed and unsigned values could produce an
2556 incorrect result when the signed value is converted to unsigned.
2557 (But don't warn if @option{-Wno-sign-compare} is also specified.)
2558
2559 @item
2560 An aggregate has an initializer which does not initialize all members.
2561 For example, the following code would cause such a warning, because
2562 @code{x.h} would be implicitly initialized to zero:
2563
2564 @smallexample
2565 struct s @{ int f, g, h; @};
2566 struct s x = @{ 3, 4 @};
2567 @end smallexample
2568
2569 @item
2570 A function parameter is declared without a type specifier in K&R-style
2571 functions:
2572
2573 @smallexample
2574 void foo(bar) @{ @}
2575 @end smallexample
2576
2577 @item
2578 An empty body occurs in an @samp{if} or @samp{else} statement.
2579
2580 @item
2581 A pointer is compared against integer zero with @samp{<}, @samp{<=},
2582 @samp{>}, or @samp{>=}.
2583
2584 @item
2585 A variable might be changed by @samp{longjmp} or @samp{vfork}.
2586
2587 @item
2588 Any of several floating-point events that often indicate errors, such as
2589 overflow, underflow, loss of precision, etc.
2590
2591 @item @r{(C++ only)}
2592 An enumerator and a non-enumerator both appear in a conditional expression.
2593
2594 @item @r{(C++ only)}
2595 A non-static reference or non-static @samp{const} member appears in a
2596 class without constructors.
2597
2598 @item @r{(C++ only)}
2599 Ambiguous virtual bases.
2600
2601 @item @r{(C++ only)}
2602 Subscripting an array which has been declared @samp{register}.
2603
2604 @item @r{(C++ only)}
2605 Taking the address of a variable which has been declared @samp{register}.
2606
2607 @item @r{(C++ only)}
2608 A base class is not initialized in a derived class' copy constructor.
2609 @end itemize
2610
2611 @item -Wno-div-by-zero
2612 @opindex Wno-div-by-zero
2613 @opindex Wdiv-by-zero
2614 Do not warn about compile-time integer division by zero. Floating point
2615 division by zero is not warned about, as it can be a legitimate way of
2616 obtaining infinities and NaNs.
2617
2618 @item -Wsystem-headers
2619 @opindex Wsystem-headers
2620 @cindex warnings from system headers
2621 @cindex system headers, warnings from
2622 Print warning messages for constructs found in system header files.
2623 Warnings from system headers are normally suppressed, on the assumption
2624 that they usually do not indicate real problems and would only make the
2625 compiler output harder to read. Using this command line option tells
2626 GCC to emit warnings from system headers as if they occurred in user
2627 code. However, note that using @option{-Wall} in conjunction with this
2628 option will @emph{not} warn about unknown pragmas in system
2629 headers---for that, @option{-Wunknown-pragmas} must also be used.
2630
2631 @item -Wfloat-equal
2632 @opindex Wfloat-equal
2633 Warn if floating point values are used in equality comparisons.
2634
2635 The idea behind this is that sometimes it is convenient (for the
2636 programmer) to consider floating-point values as approximations to
2637 infinitely precise real numbers. If you are doing this, then you need
2638 to compute (by analyzing the code, or in some other way) the maximum or
2639 likely maximum error that the computation introduces, and allow for it
2640 when performing comparisons (and when producing output, but that's a
2641 different problem). In particular, instead of testing for equality, you
2642 would check to see whether the two values have ranges that overlap; and
2643 this is done with the relational operators, so equality comparisons are
2644 probably mistaken.
2645
2646 @item -Wtraditional @r{(C only)}
2647 @opindex Wtraditional
2648 Warn about certain constructs that behave differently in traditional and
2649 ISO C@. Also warn about ISO C constructs that have no traditional C
2650 equivalent, and/or problematic constructs which should be avoided.
2651
2652 @itemize @bullet
2653 @item
2654 Macro parameters that appear within string literals in the macro body.
2655 In traditional C macro replacement takes place within string literals,
2656 but does not in ISO C@.
2657
2658 @item
2659 In traditional C, some preprocessor directives did not exist.
2660 Traditional preprocessors would only consider a line to be a directive
2661 if the @samp{#} appeared in column 1 on the line. Therefore
2662 @option{-Wtraditional} warns about directives that traditional C
2663 understands but would ignore because the @samp{#} does not appear as the
2664 first character on the line. It also suggests you hide directives like
2665 @samp{#pragma} not understood by traditional C by indenting them. Some
2666 traditional implementations would not recognize @samp{#elif}, so it
2667 suggests avoiding it altogether.
2668
2669 @item
2670 A function-like macro that appears without arguments.
2671
2672 @item
2673 The unary plus operator.
2674
2675 @item
2676 The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating point
2677 constant suffixes. (Traditional C does support the @samp{L} suffix on integer
2678 constants.) Note, these suffixes appear in macros defined in the system
2679 headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
2680 Use of these macros in user code might normally lead to spurious
2681 warnings, however GCC's integrated preprocessor has enough context to
2682 avoid warning in these cases.
2683
2684 @item
2685 A function declared external in one block and then used after the end of
2686 the block.
2687
2688 @item
2689 A @code{switch} statement has an operand of type @code{long}.
2690
2691 @item
2692 A non-@code{static} function declaration follows a @code{static} one.
2693 This construct is not accepted by some traditional C compilers.
2694
2695 @item
2696 The ISO type of an integer constant has a different width or
2697 signedness from its traditional type. This warning is only issued if
2698 the base of the constant is ten. I.e.@: hexadecimal or octal values, which
2699 typically represent bit patterns, are not warned about.
2700
2701 @item
2702 Usage of ISO string concatenation is detected.
2703
2704 @item
2705 Initialization of automatic aggregates.
2706
2707 @item
2708 Identifier conflicts with labels. Traditional C lacks a separate
2709 namespace for labels.
2710
2711 @item
2712 Initialization of unions. If the initializer is zero, the warning is
2713 omitted. This is done under the assumption that the zero initializer in
2714 user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
2715 initializer warnings and relies on default initialization to zero in the
2716 traditional C case.
2717
2718 @item
2719 Conversions by prototypes between fixed/floating point values and vice
2720 versa. The absence of these prototypes when compiling with traditional
2721 C would cause serious problems. This is a subset of the possible
2722 conversion warnings, for the full set use @option{-Wconversion}.
2723
2724 @item
2725 Use of ISO C style function definitions. This warning intentionally is
2726 @emph{not} issued for prototype declarations or variadic functions
2727 because these ISO C features will appear in your code when using
2728 libiberty's traditional C compatibility macros, @code{PARAMS} and
2729 @code{VPARAMS}. This warning is also bypassed for nested functions
2730 because that feature is already a GCC extension and thus not relevant to
2731 traditional C compatibility.
2732 @end itemize
2733
2734 @item -Wdeclaration-after-statement @r{(C only)}
2735 @opindex Wdeclaration-after-statement
2736 Warn when a declaration is found after a statement in a block. This
2737 construct, known from C++, was introduced with ISO C99 and is by default
2738 allowed in GCC@. It is not supported by ISO C90 and was not supported by
2739 GCC versions before GCC 3.0. @xref{Mixed Declarations}.
2740
2741 @item -Wundef
2742 @opindex Wundef
2743 Warn if an undefined identifier is evaluated in an @samp{#if} directive.
2744
2745 @item -Wendif-labels
2746 @opindex Wendif-labels
2747 Warn whenever an @samp{#else} or an @samp{#endif} are followed by text.
2748
2749 @item -Wshadow
2750 @opindex Wshadow
2751 Warn whenever a local variable shadows another local variable, parameter or
2752 global variable or whenever a built-in function is shadowed.
2753
2754 @item -Wlarger-than-@var{len}
2755 @opindex Wlarger-than
2756 Warn whenever an object of larger than @var{len} bytes is defined.
2757
2758 @item -Wpointer-arith
2759 @opindex Wpointer-arith
2760 Warn about anything that depends on the ``size of'' a function type or
2761 of @code{void}. GNU C assigns these types a size of 1, for
2762 convenience in calculations with @code{void *} pointers and pointers
2763 to functions.
2764
2765 @item -Wbad-function-cast @r{(C only)}
2766 @opindex Wbad-function-cast
2767 Warn whenever a function call is cast to a non-matching type.
2768 For example, warn if @code{int malloc()} is cast to @code{anything *}.
2769
2770 @item -Wcast-qual
2771 @opindex Wcast-qual
2772 Warn whenever a pointer is cast so as to remove a type qualifier from
2773 the target type. For example, warn if a @code{const char *} is cast
2774 to an ordinary @code{char *}.
2775
2776 @item -Wcast-align
2777 @opindex Wcast-align
2778 Warn whenever a pointer is cast such that the required alignment of the
2779 target is increased. For example, warn if a @code{char *} is cast to
2780 an @code{int *} on machines where integers can only be accessed at
2781 two- or four-byte boundaries.
2782
2783 @item -Wwrite-strings
2784 @opindex Wwrite-strings
2785 When compiling C, give string constants the type @code{const
2786 char[@var{length}]} so that
2787 copying the address of one into a non-@code{const} @code{char *}
2788 pointer will get a warning; when compiling C++, warn about the
2789 deprecated conversion from string constants to @code{char *}.
2790 These warnings will help you find at
2791 compile time code that can try to write into a string constant, but
2792 only if you have been very careful about using @code{const} in
2793 declarations and prototypes. Otherwise, it will just be a nuisance;
2794 this is why we did not make @option{-Wall} request these warnings.
2795
2796 @item -Wconversion
2797 @opindex Wconversion
2798 Warn if a prototype causes a type conversion that is different from what
2799 would happen to the same argument in the absence of a prototype. This
2800 includes conversions of fixed point to floating and vice versa, and
2801 conversions changing the width or signedness of a fixed point argument
2802 except when the same as the default promotion.
2803
2804 Also, warn if a negative integer constant expression is implicitly
2805 converted to an unsigned type. For example, warn about the assignment
2806 @code{x = -1} if @code{x} is unsigned. But do not warn about explicit
2807 casts like @code{(unsigned) -1}.
2808
2809 @item -Wsign-compare
2810 @opindex Wsign-compare
2811 @cindex warning for comparison of signed and unsigned values
2812 @cindex comparison of signed and unsigned values, warning
2813 @cindex signed and unsigned values, comparison warning
2814 Warn when a comparison between signed and unsigned values could produce
2815 an incorrect result when the signed value is converted to unsigned.
2816 This warning is also enabled by @option{-Wextra}; to get the other warnings
2817 of @option{-Wextra} without this warning, use @samp{-Wextra -Wno-sign-compare}.
2818
2819 @item -Waggregate-return
2820 @opindex Waggregate-return
2821 Warn if any functions that return structures or unions are defined or
2822 called. (In languages where you can return an array, this also elicits
2823 a warning.)
2824
2825 @item -Wstrict-prototypes @r{(C only)}
2826 @opindex Wstrict-prototypes
2827 Warn if a function is declared or defined without specifying the
2828 argument types. (An old-style function definition is permitted without
2829 a warning if preceded by a declaration which specifies the argument
2830 types.)
2831
2832 @item -Wold-style-definition @r{(C only)}
2833 @opindex Wold-style-definition
2834 Warn if an old-style function definition is used. A warning is given
2835 even if there is a previous prototype.
2836
2837 @item -Wmissing-prototypes @r{(C only)}
2838 @opindex Wmissing-prototypes
2839 Warn if a global function is defined without a previous prototype
2840 declaration. This warning is issued even if the definition itself
2841 provides a prototype. The aim is to detect global functions that fail
2842 to be declared in header files.
2843
2844 @item -Wmissing-declarations @r{(C only)}
2845 @opindex Wmissing-declarations
2846 Warn if a global function is defined without a previous declaration.
2847 Do so even if the definition itself provides a prototype.
2848 Use this option to detect global functions that are not declared in
2849 header files.
2850
2851 @item -Wmissing-noreturn
2852 @opindex Wmissing-noreturn
2853 Warn about functions which might be candidates for attribute @code{noreturn}.
2854 Note these are only possible candidates, not absolute ones. Care should
2855 be taken to manually verify functions actually do not ever return before
2856 adding the @code{noreturn} attribute, otherwise subtle code generation
2857 bugs could be introduced. You will not get a warning for @code{main} in
2858 hosted C environments.
2859
2860 @item -Wmissing-format-attribute
2861 @opindex Wmissing-format-attribute
2862 @opindex Wformat
2863 If @option{-Wformat} is enabled, also warn about functions which might be
2864 candidates for @code{format} attributes. Note these are only possible
2865 candidates, not absolute ones. GCC will guess that @code{format}
2866 attributes might be appropriate for any function that calls a function
2867 like @code{vprintf} or @code{vscanf}, but this might not always be the
2868 case, and some functions for which @code{format} attributes are
2869 appropriate may not be detected. This option has no effect unless
2870 @option{-Wformat} is enabled (possibly by @option{-Wall}).
2871
2872 @item -Wno-multichar
2873 @opindex Wno-multichar
2874 @opindex Wmultichar
2875 Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
2876 Usually they indicate a typo in the user's code, as they have
2877 implementation-defined values, and should not be used in portable code.
2878
2879 @item -Wno-deprecated-declarations
2880 @opindex Wno-deprecated-declarations
2881 Do not warn about uses of functions, variables, and types marked as
2882 deprecated by using the @code{deprecated} attribute.
2883 (@pxref{Function Attributes}, @pxref{Variable Attributes},
2884 @pxref{Type Attributes}.)
2885
2886 @item -Wpacked
2887 @opindex Wpacked
2888 Warn if a structure is given the packed attribute, but the packed
2889 attribute has no effect on the layout or size of the structure.
2890 Such structures may be mis-aligned for little benefit. For
2891 instance, in this code, the variable @code{f.x} in @code{struct bar}
2892 will be misaligned even though @code{struct bar} does not itself
2893 have the packed attribute:
2894
2895 @smallexample
2896 @group
2897 struct foo @{
2898 int x;
2899 char a, b, c, d;
2900 @} __attribute__((packed));
2901 struct bar @{
2902 char z;
2903 struct foo f;
2904 @};
2905 @end group
2906 @end smallexample
2907
2908 @item -Wpadded
2909 @opindex Wpadded
2910 Warn if padding is included in a structure, either to align an element
2911 of the structure or to align the whole structure. Sometimes when this
2912 happens it is possible to rearrange the fields of the structure to
2913 reduce the padding and so make the structure smaller.
2914
2915 @item -Wredundant-decls
2916 @opindex Wredundant-decls
2917 Warn if anything is declared more than once in the same scope, even in
2918 cases where multiple declaration is valid and changes nothing.
2919
2920 @item -Wnested-externs @r{(C only)}
2921 @opindex Wnested-externs
2922 Warn if an @code{extern} declaration is encountered within a function.
2923
2924 @item -Wunreachable-code
2925 @opindex Wunreachable-code
2926 Warn if the compiler detects that code will never be executed.
2927
2928 This option is intended to warn when the compiler detects that at
2929 least a whole line of source code will never be executed, because
2930 some condition is never satisfied or because it is after a
2931 procedure that never returns.
2932
2933 It is possible for this option to produce a warning even though there
2934 are circumstances under which part of the affected line can be executed,
2935 so care should be taken when removing apparently-unreachable code.
2936
2937 For instance, when a function is inlined, a warning may mean that the
2938 line is unreachable in only one inlined copy of the function.
2939
2940 This option is not made part of @option{-Wall} because in a debugging
2941 version of a program there is often substantial code which checks
2942 correct functioning of the program and is, hopefully, unreachable
2943 because the program does work. Another common use of unreachable
2944 code is to provide behavior which is selectable at compile-time.
2945
2946 @item -Winline
2947 @opindex Winline
2948 Warn if a function can not be inlined and it was declared as inline.
2949 Even with this option, the compiler will not warn about failures to
2950 inline functions declared in system headers.
2951
2952 The compiler uses a variety of heuristics to determine whether or not
2953 to inline a function. For example, the compiler takes into account
2954 the size of the function being inlined and the the amount of inlining
2955 that has already been done in the current function. Therefore,
2956 seemingly insignificant changes in the source program can cause the
2957 warnings produced by @option{-Winline} to appear or disappear.
2958
2959 @item -Wno-invalid-offsetof @r{(C++ only)}
2960 @opindex Wno-invalid-offsetof
2961 Suppress warnings from applying the @samp{offsetof} macro to a non-POD
2962 type. According to the 1998 ISO C++ standard, applying @samp{offsetof}
2963 to a non-POD type is undefined. In existing C++ implementations,
2964 however, @samp{offsetof} typically gives meaningful results even when
2965 applied to certain kinds of non-POD types. (Such as a simple
2966 @samp{struct} that fails to be a POD type only by virtue of having a
2967 constructor.) This flag is for users who are aware that they are
2968 writing nonportable code and who have deliberately chosen to ignore the
2969 warning about it.
2970
2971 The restrictions on @samp{offsetof} may be relaxed in a future version
2972 of the C++ standard.
2973
2974 @item -Winvalid-pch
2975 @opindex Winvalid-pch
2976 Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
2977 the search path but can't be used.
2978
2979 @item -Wlong-long
2980 @opindex Wlong-long
2981 @opindex Wno-long-long
2982 Warn if @samp{long long} type is used. This is default. To inhibit
2983 the warning messages, use @option{-Wno-long-long}. Flags
2984 @option{-Wlong-long} and @option{-Wno-long-long} are taken into account
2985 only when @option{-pedantic} flag is used.
2986
2987 @item -Wvariadic-macros
2988 @opindex Wvariadic-macros
2989 @opindex Wno-variadic-macros
2990 Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU
2991 alternate syntax when in pedantic ISO C99 mode. This is default.
2992 To inhibit the warning messages, use @option{-Wno-variadic-macros}.
2993
2994 @item -Wdisabled-optimization
2995 @opindex Wdisabled-optimization
2996 Warn if a requested optimization pass is disabled. This warning does
2997 not generally indicate that there is anything wrong with your code; it
2998 merely indicates that GCC's optimizers were unable to handle the code
2999 effectively. Often, the problem is that your code is too big or too
3000 complex; GCC will refuse to optimize programs when the optimization
3001 itself is likely to take inordinate amounts of time.
3002
3003 @item -Werror
3004 @opindex Werror
3005 Make all warnings into errors.
3006 @end table
3007
3008 @node Debugging Options
3009 @section Options for Debugging Your Program or GCC
3010 @cindex options, debugging
3011 @cindex debugging information options
3012
3013 GCC has various special options that are used for debugging
3014 either your program or GCC:
3015
3016 @table @gcctabopt
3017 @item -g
3018 @opindex g
3019 Produce debugging information in the operating system's native format
3020 (stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
3021 information.
3022
3023 On most systems that use stabs format, @option{-g} enables use of extra
3024 debugging information that only GDB can use; this extra information
3025 makes debugging work better in GDB but will probably make other debuggers
3026 crash or
3027 refuse to read the program. If you want to control for certain whether
3028 to generate the extra information, use @option{-gstabs+}, @option{-gstabs},
3029 @option{-gxcoff+}, @option{-gxcoff}, or @option{-gvms} (see below).
3030
3031 Unlike most other C compilers, GCC allows you to use @option{-g} with
3032 @option{-O}. The shortcuts taken by optimized code may occasionally
3033 produce surprising results: some variables you declared may not exist
3034 at all; flow of control may briefly move where you did not expect it;
3035 some statements may not be executed because they compute constant
3036 results or their values were already at hand; some statements may
3037 execute in different places because they were moved out of loops.
3038
3039 Nevertheless it proves possible to debug optimized output. This makes
3040 it reasonable to use the optimizer for programs that might have bugs.
3041
3042 The following options are useful when GCC is generated with the
3043 capability for more than one debugging format.
3044
3045 @item -ggdb
3046 @opindex ggdb
3047 Produce debugging information for use by GDB@. This means to use the
3048 most expressive format available (DWARF 2, stabs, or the native format
3049 if neither of those are supported), including GDB extensions if at all
3050 possible.
3051
3052 @item -gstabs
3053 @opindex gstabs
3054 Produce debugging information in stabs format (if that is supported),
3055 without GDB extensions. This is the format used by DBX on most BSD
3056 systems. On MIPS, Alpha and System V Release 4 systems this option
3057 produces stabs debugging output which is not understood by DBX or SDB@.
3058 On System V Release 4 systems this option requires the GNU assembler.
3059
3060 @item -feliminate-unused-debug-symbols
3061 @opindex feliminate-unused-debug-symbols
3062 Produce debugging information in stabs format (if that is supported),
3063 for only symbols that are actually used.
3064
3065 @item -gstabs+
3066 @opindex gstabs+
3067 Produce debugging information in stabs format (if that is supported),
3068 using GNU extensions understood only by the GNU debugger (GDB)@. The
3069 use of these extensions is likely to make other debuggers crash or
3070 refuse to read the program.
3071
3072 @item -gcoff
3073 @opindex gcoff
3074 Produce debugging information in COFF format (if that is supported).
3075 This is the format used by SDB on most System V systems prior to
3076 System V Release 4.
3077
3078 @item -gxcoff
3079 @opindex gxcoff
3080 Produce debugging information in XCOFF format (if that is supported).
3081 This is the format used by the DBX debugger on IBM RS/6000 systems.
3082
3083 @item -gxcoff+
3084 @opindex gxcoff+
3085 Produce debugging information in XCOFF format (if that is supported),
3086 using GNU extensions understood only by the GNU debugger (GDB)@. The
3087 use of these extensions is likely to make other debuggers crash or
3088 refuse to read the program, and may cause assemblers other than the GNU
3089 assembler (GAS) to fail with an error.
3090
3091 @item -gdwarf-2
3092 @opindex gdwarf-2
3093 Produce debugging information in DWARF version 2 format (if that is
3094 supported). This is the format used by DBX on IRIX 6.
3095
3096 @item -gvms
3097 @opindex gvms
3098 Produce debugging information in VMS debug format (if that is
3099 supported). This is the format used by DEBUG on VMS systems.
3100
3101 @item -g@var{level}
3102 @itemx -ggdb@var{level}
3103 @itemx -gstabs@var{level}
3104 @itemx -gcoff@var{level}
3105 @itemx -gxcoff@var{level}
3106 @itemx -gvms@var{level}
3107 Request debugging information and also use @var{level} to specify how
3108 much information. The default level is 2.
3109
3110 Level 1 produces minimal information, enough for making backtraces in
3111 parts of the program that you don't plan to debug. This includes
3112 descriptions of functions and external variables, but no information
3113 about local variables and no line numbers.
3114
3115 Level 3 includes extra information, such as all the macro definitions
3116 present in the program. Some debuggers support macro expansion when
3117 you use @option{-g3}.
3118
3119 Note that in order to avoid confusion between DWARF1 debug level 2,
3120 and DWARF2 @option{-gdwarf-2} does not accept a concatenated debug
3121 level. Instead use an additional @option{-g@var{level}} option to
3122 change the debug level for DWARF2.
3123
3124 @item -feliminate-dwarf2-dups
3125 @opindex feliminate-dwarf2-dups
3126 Compress DWARF2 debugging information by eliminating duplicated
3127 information about each symbol. This option only makes sense when
3128 generating DWARF2 debugging information with @option{-gdwarf-2}.
3129
3130 @cindex @command{prof}
3131 @item -p
3132 @opindex p
3133 Generate extra code to write profile information suitable for the
3134 analysis program @command{prof}. You must use this option when compiling
3135 the source files you want data about, and you must also use it when
3136 linking.
3137
3138 @cindex @command{gprof}
3139 @item -pg
3140 @opindex pg
3141 Generate extra code to write profile information suitable for the
3142 analysis program @command{gprof}. You must use this option when compiling
3143 the source files you want data about, and you must also use it when
3144 linking.
3145
3146 @item -Q
3147 @opindex Q
3148 Makes the compiler print out each function name as it is compiled, and
3149 print some statistics about each pass when it finishes.
3150
3151 @item -ftime-report
3152 @opindex ftime-report
3153 Makes the compiler print some statistics about the time consumed by each
3154 pass when it finishes.
3155
3156 @item -fmem-report
3157 @opindex fmem-report
3158 Makes the compiler print some statistics about permanent memory
3159 allocation when it finishes.
3160
3161 @item -fprofile-arcs
3162 @opindex fprofile-arcs
3163 Add code so that program flow @dfn{arcs} are instrumented. During
3164 execution the program records how many times each branch and call is
3165 executed and how many times it is taken or returns. When the compiled
3166 program exits it saves this data to a file called
3167 @file{@var{auxname}.gcda} for each source file. The data may be used for
3168 profile-directed optimizations (@option{-fbranch-probabilities}), or for
3169 test coverage analysis (@option{-ftest-coverage}). Each object file's
3170 @var{auxname} is generated from the name of the output file, if
3171 explicitly specified and it is not the final executable, otherwise it is
3172 the basename of the source file. In both cases any suffix is removed
3173 (e.g. @file{foo.gcda} for input file @file{dir/foo.c}, or
3174 @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
3175
3176 @itemize
3177
3178 @item
3179 Compile the source files with @option{-fprofile-arcs} plus optimization
3180 and code generation options. For test coverage analysis, use the
3181 additional @option{-ftest-coverage} option. You do not need to profile
3182 every source file in a program.
3183
3184 @item
3185 Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
3186 (the latter implies the former).
3187
3188 @item
3189 Run the program on a representative workload to generate the arc profile
3190 information. This may be repeated any number of times. You can run
3191 concurrent instances of your program, and provided that the file system
3192 supports locking, the data files will be correctly updated. Also
3193 @code{fork} calls are detected and correctly handled (double counting
3194 will not happen).
3195
3196 @item
3197 For profile-directed optimizations, compile the source files again with
3198 the same optimization and code generation options plus
3199 @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
3200 Control Optimization}).
3201
3202 @item
3203 For test coverage analysis, use @command{gcov} to produce human readable
3204 information from the @file{.gcno} and @file{.gcda} files. Refer to the
3205 @command{gcov} documentation for further information.
3206
3207 @end itemize
3208
3209 With @option{-fprofile-arcs}, for each function of your program GCC
3210 creates a program flow graph, then finds a spanning tree for the graph.
3211 Only arcs that are not on the spanning tree have to be instrumented: the
3212 compiler adds code to count the number of times that these arcs are
3213 executed. When an arc is the only exit or only entrance to a block, the
3214 instrumentation code can be added to the block; otherwise, a new basic
3215 block must be created to hold the instrumentation code.
3216
3217 @need 2000
3218 @item -ftest-coverage
3219 @opindex ftest-coverage
3220 Produce a notes file that the @command{gcov} code-coverage utility
3221 (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
3222 show program coverage. Each source file's note file is called
3223 @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
3224 above for a description of @var{auxname} and instructions on how to
3225 generate test coverage data. Coverage data will match the source files
3226 more closely, if you do not optimize.
3227
3228 @item -d@var{letters}
3229 @opindex d
3230 Says to make debugging dumps during compilation at times specified by
3231 @var{letters}. This is used for debugging the compiler. The file names
3232 for most of the dumps are made by appending a pass number and a word to
3233 the @var{dumpname}. @var{dumpname} is generated from the name of the
3234 output file, if explicitly specified and it is not an executable,
3235 otherwise it is the basename of the source file. In both cases any
3236 suffix is removed (e.g. @file{foo.01.rtl} or @file{foo.02.sibling}).
3237 Here are the possible letters for use in @var{letters}, and their
3238 meanings:
3239
3240 @table @samp
3241 @item A
3242 @opindex dA
3243 Annotate the assembler output with miscellaneous debugging information.
3244 @item b
3245 @opindex db
3246 Dump after computing branch probabilities, to @file{@var{file}.12.bp}.
3247 @item B
3248 @opindex dB
3249 Dump after block reordering, to @file{@var{file}.31.bbro}.
3250 @item c
3251 @opindex dc
3252 Dump after instruction combination, to the file @file{@var{file}.20.combine}.
3253 @item C
3254 @opindex dC
3255 Dump after the first if conversion, to the file @file{@var{file}.14.ce1}.
3256 Also dump after the second if conversion, to the file @file{@var{file}.21.ce2}.
3257 @item d
3258 @opindex dd
3259 Dump after branch target load optimization, to to @file{@var{file}.32.btl}.
3260 Also dump after delayed branch scheduling, to @file{@var{file}.36.dbr}.
3261 @item D
3262 @opindex dD
3263 Dump all macro definitions, at the end of preprocessing, in addition to
3264 normal output.
3265 @item E
3266 @opindex dE
3267 Dump after the third if conversion, to @file{@var{file}.30.ce3}.
3268 @item f
3269 @opindex df
3270 Dump after control and data flow analysis, to @file{@var{file}.11.cfg}.
3271 Also dump after life analysis, to @file{@var{file}.19.life}.
3272 @item F
3273 @opindex dF
3274 Dump after purging @code{ADDRESSOF} codes, to @file{@var{file}.07.addressof}.
3275 @item g
3276 @opindex dg
3277 Dump after global register allocation, to @file{@var{file}.25.greg}.
3278 @item G
3279 @opindex dG
3280 Dump after GCSE, to @file{@var{file}.08.gcse}.
3281 Also dump after jump bypassing and control flow optimizations, to
3282 @file{@var{file}.10.bypass}.
3283 @item h
3284 @opindex dh
3285 Dump after finalization of EH handling code, to @file{@var{file}.03.eh}.
3286 @item i
3287 @opindex di
3288 Dump after sibling call optimizations, to @file{@var{file}.02.sibling}.
3289 @item j
3290 @opindex dj
3291 Dump after the first jump optimization, to @file{@var{file}.04.jump}.
3292 @item k
3293 @opindex dk
3294 Dump after conversion from registers to stack, to @file{@var{file}.34.stack}.
3295 @item l
3296 @opindex dl
3297 Dump after local register allocation, to @file{@var{file}.24.lreg}.
3298 @item L
3299 @opindex dL
3300 Dump after loop optimization passes, to @file{@var{file}.09.loop} and
3301 @file{@var{file}.16.loop2}.
3302 @item M
3303 @opindex dM
3304 Dump after performing the machine dependent reorganization pass, to
3305 @file{@var{file}.35.mach}.
3306 @item n
3307 @opindex dn
3308 Dump after register renumbering, to @file{@var{file}.29.rnreg}.
3309 @item N
3310 @opindex dN
3311 Dump after the register move pass, to @file{@var{file}.22.regmove}.
3312 @item o
3313 @opindex do
3314 Dump after post-reload optimizations, to @file{@var{file}.26.postreload}.
3315 @item r
3316 @opindex dr
3317 Dump after RTL generation, to @file{@var{file}.01.rtl}.
3318 @item R
3319 @opindex dR
3320 Dump after the second scheduling pass, to @file{@var{file}.33.sched2}.
3321 @item s
3322 @opindex ds
3323 Dump after CSE (including the jump optimization that sometimes follows
3324 CSE), to @file{@var{file}.06.cse}.
3325 @item S
3326 @opindex dS
3327 Dump after the first scheduling pass, to @file{@var{file}.23.sched}.
3328 @item t
3329 @opindex dt
3330 Dump after the second CSE pass (including the jump optimization that
3331 sometimes follows CSE), to @file{@var{file}.18.cse2}.
3332 @item T
3333 @opindex dT
3334 Dump after running tracer, to @file{@var{file}.15.tracer}.
3335 @item u
3336 @opindex du
3337 Dump after null pointer elimination pass to @file{@var{file}.05.null}.
3338 @item U
3339 @opindex dU
3340 Dump callgraph and unit-at-a-time optimization @file{@var{file}.00.unit}.
3341 @item V
3342 @opindex dV
3343 Dump after the value profile transformations, to @file{@var{file}.13.vpt}.
3344 Also dump after variable tracking, to @file{@var{file}.35.vartrack}.
3345 @item w
3346 @opindex dw
3347 Dump after the second flow pass, to @file{@var{file}.27.flow2}.
3348 @item z
3349 @opindex dz
3350 Dump after the peephole pass, to @file{@var{file}.28.peephole2}.
3351 @item Z
3352 @opindex dZ
3353 Dump after constructing the web, to @file{@var{file}.17.web}.
3354 @item a
3355 @opindex da
3356 Produce all the dumps listed above.
3357 @item H
3358 @opindex dH
3359 Produce a core dump whenever an error occurs.
3360 @item m
3361 @opindex dm
3362 Print statistics on memory usage, at the end of the run, to
3363 standard error.
3364 @item p
3365 @opindex dp
3366 Annotate the assembler output with a comment indicating which
3367 pattern and alternative was used. The length of each instruction is
3368 also printed.
3369 @item P
3370 @opindex dP
3371 Dump the RTL in the assembler output as a comment before each instruction.
3372 Also turns on @option{-dp} annotation.
3373 @item v
3374 @opindex dv
3375 For each of the other indicated dump files (except for
3376 @file{@var{file}.01.rtl}), dump a representation of the control flow graph
3377 suitable for viewing with VCG to @file{@var{file}.@var{pass}.vcg}.
3378 @item x
3379 @opindex dx
3380 Just generate RTL for a function instead of compiling it. Usually used
3381 with @samp{r}.
3382 @item y
3383 @opindex dy
3384 Dump debugging information during parsing, to standard error.
3385 @end table
3386
3387 @item -fdump-unnumbered
3388 @opindex fdump-unnumbered
3389 When doing debugging dumps (see @option{-d} option above), suppress instruction
3390 numbers and line number note output. This makes it more feasible to
3391 use diff on debugging dumps for compiler invocations with different
3392 options, in particular with and without @option{-g}.
3393
3394 @item -fdump-translation-unit @r{(C and C++ only)}
3395 @itemx -fdump-translation-unit-@var{options} @r{(C and C++ only)}
3396 @opindex fdump-translation-unit
3397 Dump a representation of the tree structure for the entire translation
3398 unit to a file. The file name is made by appending @file{.tu} to the
3399 source file name. If the @samp{-@var{options}} form is used, @var{options}
3400 controls the details of the dump as described for the
3401 @option{-fdump-tree} options.
3402
3403 @item -fdump-class-hierarchy @r{(C++ only)}
3404 @itemx -fdump-class-hierarchy-@var{options} @r{(C++ only)}
3405 @opindex fdump-class-hierarchy
3406 Dump a representation of each class's hierarchy and virtual function
3407 table layout to a file. The file name is made by appending @file{.class}
3408 to the source file name. If the @samp{-@var{options}} form is used,
3409 @var{options} controls the details of the dump as described for the
3410 @option{-fdump-tree} options.
3411
3412 @item -fdump-tree-@var{switch} @r{(C++ only)}
3413 @itemx -fdump-tree-@var{switch}-@var{options} @r{(C++ only)}
3414 @opindex fdump-tree
3415 Control the dumping at various stages of processing the intermediate
3416 language tree to a file. The file name is generated by appending a switch
3417 specific suffix to the source file name. If the @samp{-@var{options}}
3418 form is used, @var{options} is a list of @samp{-} separated options that
3419 control the details of the dump. Not all options are applicable to all
3420 dumps, those which are not meaningful will be ignored. The following
3421 options are available
3422
3423 @table @samp
3424 @item address
3425 Print the address of each node. Usually this is not meaningful as it
3426 changes according to the environment and source file. Its primary use
3427 is for tying up a dump file with a debug environment.
3428 @item slim
3429 Inhibit dumping of members of a scope or body of a function merely
3430 because that scope has been reached. Only dump such items when they
3431 are directly reachable by some other path.
3432 @item all
3433 Turn on all options.
3434 @end table
3435
3436 The following tree dumps are possible:
3437 @table @samp
3438 @item original
3439 Dump before any tree based optimization, to @file{@var{file}.original}.
3440 @item optimized
3441 Dump after all tree based optimization, to @file{@var{file}.optimized}.
3442 @item inlined
3443 Dump after function inlining, to @file{@var{file}.inlined}.
3444 @end table
3445
3446 @item -frandom-seed=@var{string}
3447 @opindex frandom-string
3448 This option provides a seed that GCC uses when it would otherwise use
3449 random numbers. It is used to generate certain symbol names
3450 that have to be different in every compiled file. It is also used to
3451 place unique stamps in coverage data files and the object files that
3452 produce them. You can use the @option{-frandom-seed} option to produce
3453 reproducibly identical object files.
3454
3455 The @var{string} should be different for every file you compile.
3456
3457 @item -fsched-verbose=@var{n}
3458 @opindex fsched-verbose
3459 On targets that use instruction scheduling, this option controls the
3460 amount of debugging output the scheduler prints. This information is
3461 written to standard error, unless @option{-dS} or @option{-dR} is
3462 specified, in which case it is output to the usual dump
3463 listing file, @file{.sched} or @file{.sched2} respectively. However
3464 for @var{n} greater than nine, the output is always printed to standard
3465 error.
3466
3467 For @var{n} greater than zero, @option{-fsched-verbose} outputs the
3468 same information as @option{-dRS}. For @var{n} greater than one, it
3469 also output basic block probabilities, detailed ready list information
3470 and unit/insn info. For @var{n} greater than two, it includes RTL
3471 at abort point, control-flow and regions info. And for @var{n} over
3472 four, @option{-fsched-verbose} also includes dependence info.
3473
3474 @item -save-temps
3475 @opindex save-temps
3476 Store the usual ``temporary'' intermediate files permanently; place them
3477 in the current directory and name them based on the source file. Thus,
3478 compiling @file{foo.c} with @samp{-c -save-temps} would produce files
3479 @file{foo.i} and @file{foo.s}, as well as @file{foo.o}. This creates a
3480 preprocessed @file{foo.i} output file even though the compiler now
3481 normally uses an integrated preprocessor.
3482
3483 @item -time
3484 @opindex time
3485 Report the CPU time taken by each subprocess in the compilation
3486 sequence. For C source files, this is the compiler proper and assembler
3487 (plus the linker if linking is done). The output looks like this:
3488
3489 @smallexample
3490 # cc1 0.12 0.01
3491 # as 0.00 0.01
3492 @end smallexample
3493
3494 The first number on each line is the ``user time,'' that is time spent
3495 executing the program itself. The second number is ``system time,''
3496 time spent executing operating system routines on behalf of the program.
3497 Both numbers are in seconds.
3498
3499 @item -fvar-tracking
3500 @opindex fvar-tracking
3501 Run variable tracking pass. It computes where variables are stored at each
3502 position in code. Better debugging information is then generated
3503 (if the debugging information format supports this information).
3504
3505 It is enabled by default when compiling with optimization (@option{-Os},
3506 @option{-O}, @option{-O2}, ...), debugging information (@option{-g}) and
3507 the debug info format supports it.
3508
3509 @item -print-file-name=@var{library}
3510 @opindex print-file-name
3511 Print the full absolute name of the library file @var{library} that
3512 would be used when linking---and don't do anything else. With this
3513 option, GCC does not compile or link anything; it just prints the
3514 file name.
3515
3516 @item -print-multi-directory
3517 @opindex print-multi-directory
3518 Print the directory name corresponding to the multilib selected by any
3519 other switches present in the command line. This directory is supposed
3520 to exist in @env{GCC_EXEC_PREFIX}.
3521
3522 @item -print-multi-lib
3523 @opindex print-multi-lib
3524 Print the mapping from multilib directory names to compiler switches
3525 that enable them. The directory name is separated from the switches by
3526 @samp{;}, and each switch starts with an @samp{@@} instead of the
3527 @samp{-}, without spaces between multiple switches. This is supposed to
3528 ease shell-processing.
3529
3530 @item -print-prog-name=@var{program}
3531 @opindex print-prog-name
3532 Like @option{-print-file-name}, but searches for a program such as @samp{cpp}.
3533
3534 @item -print-libgcc-file-name
3535 @opindex print-libgcc-file-name
3536 Same as @option{-print-file-name=libgcc.a}.
3537
3538 This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
3539 but you do want to link with @file{libgcc.a}. You can do
3540
3541 @smallexample
3542 gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
3543 @end smallexample
3544
3545 @item -print-search-dirs
3546 @opindex print-search-dirs
3547 Print the name of the configured installation directory and a list of
3548 program and library directories @command{gcc} will search---and don't do anything else.
3549
3550 This is useful when @command{gcc} prints the error message
3551 @samp{installation problem, cannot exec cpp0: No such file or directory}.
3552 To resolve this you either need to put @file{cpp0} and the other compiler
3553 components where @command{gcc} expects to find them, or you can set the environment
3554 variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
3555 Don't forget the trailing '/'.
3556 @xref{Environment Variables}.
3557
3558 @item -dumpmachine
3559 @opindex dumpmachine
3560 Print the compiler's target machine (for example,
3561 @samp{i686-pc-linux-gnu})---and don't do anything else.
3562
3563 @item -dumpversion
3564 @opindex dumpversion
3565 Print the compiler version (for example, @samp{3.0})---and don't do
3566 anything else.
3567
3568 @item -dumpspecs
3569 @opindex dumpspecs
3570 Print the compiler's built-in specs---and don't do anything else. (This
3571 is used when GCC itself is being built.) @xref{Spec Files}.
3572
3573 @item -feliminate-unused-debug-types
3574 @opindex feliminate-unused-debug-types
3575 Normally, when producing DWARF2 output, GCC will emit debugging
3576 information for all types declared in a compilation
3577 unit, regardless of whether or not they are actually used
3578 in that compilation unit. Sometimes this is useful, such as
3579 if, in the debugger, you want to cast a value to a type that is
3580 not actually used in your program (but is declared). More often,
3581 however, this results in a significant amount of wasted space.
3582 With this option, GCC will avoid producing debug symbol output
3583 for types that are nowhere used in the source file being compiled.
3584 @end table
3585
3586 @node Optimize Options
3587 @section Options That Control Optimization
3588 @cindex optimize options
3589 @cindex options, optimization
3590
3591 These options control various sorts of optimizations.
3592
3593 Without any optimization option, the compiler's goal is to reduce the
3594 cost of compilation and to make debugging produce the expected
3595 results. Statements are independent: if you stop the program with a
3596 breakpoint between statements, you can then assign a new value to any
3597 variable or change the program counter to any other statement in the
3598 function and get exactly the results you would expect from the source
3599 code.
3600
3601 Turning on optimization flags makes the compiler attempt to improve
3602 the performance and/or code size at the expense of compilation time
3603 and possibly the ability to debug the program.
3604
3605 The compiler performs optimization based on the knowledge it has of
3606 the program. Optimization levels @option{-O2} and above, in
3607 particular, enable @emph{unit-at-a-time} mode, which allows the
3608 compiler to consider information gained from later functions in
3609 the file when compiling a function. Compiling multiple files at
3610 once to a single output file in @emph{unit-at-a-time} mode allows
3611 the compiler to use information gained from all of the files when
3612 compiling each of them.
3613
3614 Not all optimizations are controlled directly by a flag. Only
3615 optimizations that have a flag are listed.
3616
3617 @table @gcctabopt
3618 @item -O
3619 @itemx -O1
3620 @opindex O
3621 @opindex O1
3622 Optimize. Optimizing compilation takes somewhat more time, and a lot
3623 more memory for a large function.
3624
3625 With @option{-O}, the compiler tries to reduce code size and execution
3626 time, without performing any optimizations that take a great deal of
3627 compilation time.
3628
3629 @option{-O} turns on the following optimization flags:
3630 @gccoptlist{-fdefer-pop @gol
3631 -fmerge-constants @gol
3632 -fthread-jumps @gol
3633 -floop-optimize @gol
3634 -fif-conversion @gol
3635 -fif-conversion2 @gol
3636 -fdelayed-branch @gol
3637 -fguess-branch-probability @gol
3638 -fcprop-registers}
3639
3640 @option{-O} also turns on @option{-fomit-frame-pointer} on machines
3641 where doing so does not interfere with debugging.
3642
3643 @item -O2
3644 @opindex O2
3645 Optimize even more. GCC performs nearly all supported optimizations
3646 that do not involve a space-speed tradeoff. The compiler does not
3647 perform loop unrolling or function inlining when you specify @option{-O2}.
3648 As compared to @option{-O}, this option increases both compilation time
3649 and the performance of the generated code.
3650
3651 @option{-O2} turns on all optimization flags specified by @option{-O}. It
3652 also turns on the following optimization flags:
3653 @gccoptlist{-fforce-mem @gol
3654 -foptimize-sibling-calls @gol
3655 -fstrength-reduce @gol
3656 -fcse-follow-jumps -fcse-skip-blocks @gol
3657 -frerun-cse-after-loop -frerun-loop-opt @gol
3658 -fgcse -fgcse-lm -fgcse-sm -fgcse-las @gol
3659 -fdelete-null-pointer-checks @gol
3660 -fexpensive-optimizations @gol
3661 -fregmove @gol
3662 -fschedule-insns -fschedule-insns2 @gol
3663 -fsched-interblock -fsched-spec @gol
3664 -fcaller-saves @gol
3665 -fpeephole2 @gol
3666 -freorder-blocks -freorder-functions @gol
3667 -fstrict-aliasing @gol
3668 -funit-at-a-time @gol
3669 -falign-functions -falign-jumps @gol
3670 -falign-loops -falign-labels @gol
3671 -fcrossjumping}
3672
3673 Please note the warning under @option{-fgcse} about
3674 invoking @option{-O2} on programs that use computed gotos.
3675
3676 @item -O3
3677 @opindex O3
3678 Optimize yet more. @option{-O3} turns on all optimizations specified by
3679 @option{-O2} and also turns on the @option{-finline-functions},
3680 @option{-fweb}, @option{-frename-registers}
3681 and @option{-fgcse-after-reload} options.
3682
3683 @item -O0
3684 @opindex O0
3685 Do not optimize. This is the default.
3686
3687 @item -Os
3688 @opindex Os
3689 Optimize for size. @option{-Os} enables all @option{-O2} optimizations that
3690 do not typically increase code size. It also performs further
3691 optimizations designed to reduce code size.
3692
3693 @option{-Os} disables the following optimization flags:
3694 @gccoptlist{-falign-functions -falign-jumps -falign-loops @gol
3695 -falign-labels -freorder-blocks -freorder-blocks-and-partition -fprefetch-loop-arrays}
3696
3697 If you use multiple @option{-O} options, with or without level numbers,
3698 the last such option is the one that is effective.
3699 @end table
3700
3701 Options of the form @option{-f@var{flag}} specify machine-independent
3702 flags. Most flags have both positive and negative forms; the negative
3703 form of @option{-ffoo} would be @option{-fno-foo}. In the table
3704 below, only one of the forms is listed---the one you typically will
3705 use. You can figure out the other form by either removing @samp{no-}
3706 or adding it.
3707
3708 The following options control specific optimizations. They are either
3709 activated by @option{-O} options or are related to ones that are. You
3710 can use the following flags in the rare cases when ``fine-tuning'' of
3711 optimizations to be performed is desired.
3712
3713 @table @gcctabopt
3714 @item -fno-default-inline
3715 @opindex fno-default-inline
3716 Do not make member functions inline by default merely because they are
3717 defined inside the class scope (C++ only). Otherwise, when you specify
3718 @w{@option{-O}}, member functions defined inside class scope are compiled
3719 inline by default; i.e., you don't need to add @samp{inline} in front of
3720 the member function name.
3721
3722 @item -fno-defer-pop
3723 @opindex fno-defer-pop
3724 Always pop the arguments to each function call as soon as that function
3725 returns. For machines which must pop arguments after a function call,
3726 the compiler normally lets arguments accumulate on the stack for several
3727 function calls and pops them all at once.
3728
3729 Disabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
3730
3731 @item -fforce-mem
3732 @opindex fforce-mem
3733 Force memory operands to be copied into registers before doing
3734 arithmetic on them. This produces better code by making all memory
3735 references potential common subexpressions. When they are not common
3736 subexpressions, instruction combination should eliminate the separate
3737 register-load.
3738
3739 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3740
3741 @item -fforce-addr
3742 @opindex fforce-addr
3743 Force memory address constants to be copied into registers before
3744 doing arithmetic on them. This may produce better code just as
3745 @option{-fforce-mem} may.
3746
3747 @item -fomit-frame-pointer
3748 @opindex fomit-frame-pointer
3749 Don't keep the frame pointer in a register for functions that
3750 don't need one. This avoids the instructions to save, set up and
3751 restore frame pointers; it also makes an extra register available
3752 in many functions. @strong{It also makes debugging impossible on
3753 some machines.}
3754
3755 On some machines, such as the VAX, this flag has no effect, because
3756 the standard calling sequence automatically handles the frame pointer
3757 and nothing is saved by pretending it doesn't exist. The
3758 machine-description macro @code{FRAME_POINTER_REQUIRED} controls
3759 whether a target machine supports this flag. @xref{Registers,,Register
3760 Usage, gccint, GNU Compiler Collection (GCC) Internals}.
3761
3762 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
3763
3764 @item -foptimize-sibling-calls
3765 @opindex foptimize-sibling-calls
3766 Optimize sibling and tail recursive calls.
3767
3768 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3769
3770 @item -fno-inline
3771 @opindex fno-inline
3772 Don't pay attention to the @code{inline} keyword. Normally this option
3773 is used to keep the compiler from expanding any functions inline.
3774 Note that if you are not optimizing, no functions can be expanded inline.
3775
3776 @item -finline-functions
3777 @opindex finline-functions
3778 Integrate all simple functions into their callers. The compiler
3779 heuristically decides which functions are simple enough to be worth
3780 integrating in this way.
3781
3782 If all calls to a given function are integrated, and the function is
3783 declared @code{static}, then the function is normally not output as
3784 assembler code in its own right.
3785
3786 Enabled at level @option{-O3}.
3787
3788 @item -finline-limit=@var{n}
3789 @opindex finline-limit
3790 By default, GCC limits the size of functions that can be inlined. This flag
3791 allows the control of this limit for functions that are explicitly marked as
3792 inline (i.e., marked with the inline keyword or defined within the class
3793 definition in c++). @var{n} is the size of functions that can be inlined in
3794 number of pseudo instructions (not counting parameter handling). The default
3795 value of @var{n} is 600.
3796 Increasing this value can result in more inlined code at
3797 the cost of compilation time and memory consumption. Decreasing usually makes
3798 the compilation faster and less code will be inlined (which presumably
3799 means slower programs). This option is particularly useful for programs that
3800 use inlining heavily such as those based on recursive templates with C++.
3801
3802 Inlining is actually controlled by a number of parameters, which may be
3803 specified individually by using @option{--param @var{name}=@var{value}}.
3804 The @option{-finline-limit=@var{n}} option sets some of these parameters
3805 as follows:
3806
3807 @table @gcctabopt
3808 @item max-inline-insns-single
3809 is set to @var{n}/2.
3810 @item max-inline-insns-auto
3811 is set to @var{n}/2.
3812 @item min-inline-insns
3813 is set to 130 or @var{n}/4, whichever is smaller.
3814 @item max-inline-insns-rtl
3815 is set to @var{n}.
3816 @end table
3817
3818 See below for a documentation of the individual
3819 parameters controlling inlining.
3820
3821 @emph{Note:} pseudo instruction represents, in this particular context, an
3822 abstract measurement of function's size. In no way, it represents a count
3823 of assembly instructions and as such its exact meaning might change from one
3824 release to an another.
3825
3826 @item -fkeep-inline-functions
3827 @opindex fkeep-inline-functions
3828 Even if all calls to a given function are integrated, and the function
3829 is declared @code{static}, nevertheless output a separate run-time
3830 callable version of the function. This switch does not affect
3831 @code{extern inline} functions.
3832
3833 @item -fkeep-static-consts
3834 @opindex fkeep-static-consts
3835 Emit variables declared @code{static const} when optimization isn't turned
3836 on, even if the variables aren't referenced.
3837
3838 GCC enables this option by default. If you want to force the compiler to
3839 check if the variable was referenced, regardless of whether or not
3840 optimization is turned on, use the @option{-fno-keep-static-consts} option.
3841
3842 @item -fmerge-constants
3843 Attempt to merge identical constants (string constants and floating point
3844 constants) across compilation units.
3845
3846 This option is the default for optimized compilation if the assembler and
3847 linker support it. Use @option{-fno-merge-constants} to inhibit this
3848 behavior.
3849
3850 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
3851
3852 @item -fmerge-all-constants
3853 Attempt to merge identical constants and identical variables.
3854
3855 This option implies @option{-fmerge-constants}. In addition to
3856 @option{-fmerge-constants} this considers e.g. even constant initialized
3857 arrays or initialized constant variables with integral or floating point
3858 types. Languages like C or C++ require each non-automatic variable to
3859 have distinct location, so using this option will result in non-conforming
3860 behavior.
3861
3862 @item -fnew-ra
3863 @opindex fnew-ra
3864 Use a graph coloring register allocator. Currently this option is meant
3865 only for testing. Users should not specify this option, since it is not
3866 yet ready for production use.
3867
3868 @item -fno-branch-count-reg
3869 @opindex fno-branch-count-reg
3870 Do not use ``decrement and branch'' instructions on a count register,
3871 but instead generate a sequence of instructions that decrement a
3872 register, compare it against zero, then branch based upon the result.
3873 This option is only meaningful on architectures that support such
3874 instructions, which include x86, PowerPC, IA-64 and S/390.
3875
3876 The default is @option{-fbranch-count-reg}, enabled when
3877 @option{-fstrength-reduce} is enabled.
3878
3879 @item -fno-function-cse
3880 @opindex fno-function-cse
3881 Do not put function addresses in registers; make each instruction that
3882 calls a constant function contain the function's address explicitly.
3883
3884 This option results in less efficient code, but some strange hacks
3885 that alter the assembler output may be confused by the optimizations
3886 performed when this option is not used.
3887
3888 The default is @option{-ffunction-cse}
3889
3890 @item -fno-zero-initialized-in-bss
3891 @opindex fno-zero-initialized-in-bss
3892 If the target supports a BSS section, GCC by default puts variables that
3893 are initialized to zero into BSS@. This can save space in the resulting
3894 code.
3895
3896 This option turns off this behavior because some programs explicitly
3897 rely on variables going to the data section. E.g., so that the
3898 resulting executable can find the beginning of that section and/or make
3899 assumptions based on that.
3900
3901 The default is @option{-fzero-initialized-in-bss}.
3902
3903 @item -fstrength-reduce
3904 @opindex fstrength-reduce
3905 Perform the optimizations of loop strength reduction and
3906 elimination of iteration variables.
3907
3908 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3909
3910 @item -fthread-jumps
3911 @opindex fthread-jumps
3912 Perform optimizations where we check to see if a jump branches to a
3913 location where another comparison subsumed by the first is found. If
3914 so, the first branch is redirected to either the destination of the
3915 second branch or a point immediately following it, depending on whether
3916 the condition is known to be true or false.
3917
3918 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
3919
3920 @item -fcse-follow-jumps
3921 @opindex fcse-follow-jumps
3922 In common subexpression elimination, scan through jump instructions
3923 when the target of the jump is not reached by any other path. For
3924 example, when CSE encounters an @code{if} statement with an
3925 @code{else} clause, CSE will follow the jump when the condition
3926 tested is false.
3927
3928 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3929
3930 @item -fcse-skip-blocks
3931 @opindex fcse-skip-blocks
3932 This is similar to @option{-fcse-follow-jumps}, but causes CSE to
3933 follow jumps which conditionally skip over blocks. When CSE
3934 encounters a simple @code{if} statement with no else clause,
3935 @option{-fcse-skip-blocks} causes CSE to follow the jump around the
3936 body of the @code{if}.
3937
3938 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3939
3940 @item -frerun-cse-after-loop
3941 @opindex frerun-cse-after-loop
3942 Re-run common subexpression elimination after loop optimizations has been
3943 performed.
3944
3945 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3946
3947 @item -frerun-loop-opt
3948 @opindex frerun-loop-opt
3949 Run the loop optimizer twice.
3950
3951 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3952
3953 @item -fgcse
3954 @opindex fgcse
3955 Perform a global common subexpression elimination pass.
3956 This pass also performs global constant and copy propagation.
3957
3958 @emph{Note:} When compiling a program using computed gotos, a GCC
3959 extension, you may get better runtime performance if you disable
3960 the global common subexpression elimination pass by adding
3961 @option{-fno-gcse} to the command line.
3962
3963 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3964
3965 @item -fgcse-lm
3966 @opindex fgcse-lm
3967 When @option{-fgcse-lm} is enabled, global common subexpression elimination will
3968 attempt to move loads which are only killed by stores into themselves. This
3969 allows a loop containing a load/store sequence to be changed to a load outside
3970 the loop, and a copy/store within the loop.
3971
3972 Enabled by default when gcse is enabled.
3973
3974 @item -fgcse-sm
3975 @opindex fgcse-sm
3976 When @option{-fgcse-sm} is enabled, a store motion pass is run after
3977 global common subexpression elimination. This pass will attempt to move
3978 stores out of loops. When used in conjunction with @option{-fgcse-lm},
3979 loops containing a load/store sequence can be changed to a load before
3980 the loop and a store after the loop.
3981
3982 Enabled by default when gcse is enabled.
3983
3984 @item -fgcse-las
3985 @opindex fgcse-las
3986 When @option{-fgcse-las} is enabled, the global common subexpression
3987 elimination pass eliminates redundant loads that come after stores to the
3988 same memory location (both partial and full redundancies).
3989
3990 Enabled by default when gcse is enabled.
3991
3992 @item -fgcse-after-reload
3993 @opindex fgcse-after-reload
3994 When @option{-fgcse-after-reload} is enabled, a redundant load elimination
3995 pass is performed after reload. The purpose of this pass is to cleanup
3996 redundant spilling.
3997
3998 @item -floop-optimize
3999 @opindex floop-optimize
4000 Perform loop optimizations: move constant expressions out of loops, simplify
4001 exit test conditions and optionally do strength-reduction and loop unrolling as
4002 well.
4003
4004 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4005
4006 @item -fcrossjumping
4007 @opindex crossjumping
4008 Perform cross-jumping transformation. This transformation unifies equivalent code and save code size. The
4009 resulting code may or may not perform better than without cross-jumping.
4010
4011 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4012
4013 @item -fif-conversion
4014 @opindex if-conversion
4015 Attempt to transform conditional jumps into branch-less equivalents. This
4016 include use of conditional moves, min, max, set flags and abs instructions, and
4017 some tricks doable by standard arithmetics. The use of conditional execution
4018 on chips where it is available is controlled by @code{if-conversion2}.
4019
4020 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4021
4022 @item -fif-conversion2
4023 @opindex if-conversion2
4024 Use conditional execution (where available) to transform conditional jumps into
4025 branch-less equivalents.
4026
4027 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4028
4029 @item -fdelete-null-pointer-checks
4030 @opindex fdelete-null-pointer-checks
4031 Use global dataflow analysis to identify and eliminate useless checks
4032 for null pointers. The compiler assumes that dereferencing a null
4033 pointer would have halted the program. If a pointer is checked after
4034 it has already been dereferenced, it cannot be null.
4035
4036 In some environments, this assumption is not true, and programs can
4037 safely dereference null pointers. Use
4038 @option{-fno-delete-null-pointer-checks} to disable this optimization
4039 for programs which depend on that behavior.
4040
4041 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4042
4043 @item -fexpensive-optimizations
4044 @opindex fexpensive-optimizations
4045 Perform a number of minor optimizations that are relatively expensive.
4046
4047 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4048
4049 @item -foptimize-register-move
4050 @itemx -fregmove
4051 @opindex foptimize-register-move
4052 @opindex fregmove
4053 Attempt to reassign register numbers in move instructions and as
4054 operands of other simple instructions in order to maximize the amount of
4055 register tying. This is especially helpful on machines with two-operand
4056 instructions.
4057
4058 Note @option{-fregmove} and @option{-foptimize-register-move} are the same
4059 optimization.
4060
4061 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4062
4063 @item -fdelayed-branch
4064 @opindex fdelayed-branch
4065 If supported for the target machine, attempt to reorder instructions
4066 to exploit instruction slots available after delayed branch
4067 instructions.
4068
4069 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4070
4071 @item -fschedule-insns
4072 @opindex fschedule-insns
4073 If supported for the target machine, attempt to reorder instructions to
4074 eliminate execution stalls due to required data being unavailable. This
4075 helps machines that have slow floating point or memory load instructions
4076 by allowing other instructions to be issued until the result of the load
4077 or floating point instruction is required.
4078
4079 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4080
4081 @item -fschedule-insns2
4082 @opindex fschedule-insns2
4083 Similar to @option{-fschedule-insns}, but requests an additional pass of
4084 instruction scheduling after register allocation has been done. This is
4085 especially useful on machines with a relatively small number of
4086 registers and where memory load instructions take more than one cycle.
4087
4088 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4089
4090 @item -fno-sched-interblock
4091 @opindex fno-sched-interblock
4092 Don't schedule instructions across basic blocks. This is normally
4093 enabled by default when scheduling before register allocation, i.e.@:
4094 with @option{-fschedule-insns} or at @option{-O2} or higher.
4095
4096 @item -fno-sched-spec
4097 @opindex fno-sched-spec
4098 Don't allow speculative motion of non-load instructions. This is normally
4099 enabled by default when scheduling before register allocation, i.e.@:
4100 with @option{-fschedule-insns} or at @option{-O2} or higher.
4101
4102 @item -fsched-spec-load
4103 @opindex fsched-spec-load
4104 Allow speculative motion of some load instructions. This only makes
4105 sense when scheduling before register allocation, i.e.@: with
4106 @option{-fschedule-insns} or at @option{-O2} or higher.
4107
4108 @item -fsched-spec-load-dangerous
4109 @opindex fsched-spec-load-dangerous
4110 Allow speculative motion of more load instructions. This only makes
4111 sense when scheduling before register allocation, i.e.@: with
4112 @option{-fschedule-insns} or at @option{-O2} or higher.
4113
4114 @item -fsched-stalled-insns=@var{n}
4115 @opindex fsched-stalled-insns
4116 Define how many insns (if any) can be moved prematurely from the queue
4117 of stalled insns into the ready list, during the second scheduling pass.
4118
4119 @item -fsched-stalled-insns-dep=@var{n}
4120 @opindex fsched-stalled-insns-dep
4121 Define how many insn groups (cycles) will be examined for a dependency
4122 on a stalled insn that is candidate for premature removal from the queue
4123 of stalled insns. Has an effect only during the second scheduling pass,
4124 and only if @option{-fsched-stalled-insns} is used and its value is not zero.
4125
4126 @item -fsched2-use-superblocks
4127 @opindex fsched2-use-superblocks
4128 When scheduling after register allocation, do use superblock scheduling
4129 algorithm. Superblock scheduling allows motion across basic block boundaries
4130 resulting on faster schedules. This option is experimental, as not all machine
4131 descriptions used by GCC model the CPU closely enough to avoid unreliable
4132 results from the algorithm.
4133
4134 This only makes sense when scheduling after register allocation, i.e.@: with
4135 @option{-fschedule-insns2} or at @option{-O2} or higher.
4136
4137 @item -fsched2-use-traces
4138 @opindex fsched2-use-traces
4139 Use @option{-fsched2-use-superblocks} algorithm when scheduling after register
4140 allocation and additionally perform code duplication in order to increase the
4141 size of superblocks using tracer pass. See @option{-ftracer} for details on
4142 trace formation.
4143
4144 This mode should produce faster but significantly longer programs. Also
4145 without @code{-fbranch-probabilities} the traces constructed may not match the
4146 reality and hurt the performance. This only makes
4147 sense when scheduling after register allocation, i.e.@: with
4148 @option{-fschedule-insns2} or at @option{-O2} or higher.
4149
4150 @item -fcaller-saves
4151 @opindex fcaller-saves
4152 Enable values to be allocated in registers that will be clobbered by
4153 function calls, by emitting extra instructions to save and restore the
4154 registers around such calls. Such allocation is done only when it
4155 seems to result in better code than would otherwise be produced.
4156
4157 This option is always enabled by default on certain machines, usually
4158 those which have no call-preserved registers to use instead.
4159
4160 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4161
4162 @item -fmove-all-movables
4163 @opindex fmove-all-movables
4164 Forces all invariant computations in loops to be moved
4165 outside the loop.
4166
4167 @item -freduce-all-givs
4168 @opindex freduce-all-givs
4169 Forces all general-induction variables in loops to be
4170 strength-reduced.
4171
4172 @emph{Note:} When compiling programs written in Fortran,
4173 @option{-fmove-all-movables} and @option{-freduce-all-givs} are enabled
4174 by default when you use the optimizer.
4175
4176 These options may generate better or worse code; results are highly
4177 dependent on the structure of loops within the source code.
4178
4179 These two options are intended to be removed someday, once
4180 they have helped determine the efficacy of various
4181 approaches to improving loop optimizations.
4182
4183 Please let us (@w{@email{gcc@@gcc.gnu.org}} and @w{@email{fortran@@gnu.org}})
4184 know how use of these options affects
4185 the performance of your production code.
4186 We're very interested in code that runs @emph{slower}
4187 when these options are @emph{enabled}.
4188
4189 @item -fno-peephole
4190 @itemx -fno-peephole2
4191 @opindex fno-peephole
4192 @opindex fno-peephole2
4193 Disable any machine-specific peephole optimizations. The difference
4194 between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
4195 are implemented in the compiler; some targets use one, some use the
4196 other, a few use both.
4197
4198 @option{-fpeephole} is enabled by default.
4199 @option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4200
4201 @item -fno-guess-branch-probability
4202 @opindex fno-guess-branch-probability
4203 Do not guess branch probabilities using a randomized model.
4204
4205 Sometimes GCC will opt to use a randomized model to guess branch
4206 probabilities, when none are available from either profiling feedback
4207 (@option{-fprofile-arcs}) or @samp{__builtin_expect}. This means that
4208 different runs of the compiler on the same program may produce different
4209 object code.
4210
4211 In a hard real-time system, people don't want different runs of the
4212 compiler to produce code that has different behavior; minimizing
4213 non-determinism is of paramount import. This switch allows users to
4214 reduce non-determinism, possibly at the expense of inferior
4215 optimization.
4216
4217 The default is @option{-fguess-branch-probability} at levels
4218 @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4219
4220 @item -freorder-blocks
4221 @opindex freorder-blocks
4222 Reorder basic blocks in the compiled function in order to reduce number of
4223 taken branches and improve code locality.
4224
4225 Enabled at levels @option{-O2}, @option{-O3}.
4226
4227 @item -freorder-blocks-and-partition
4228 @opindex freorder-blocks-and-partition
4229 In addition to reordering basic blocks in the compiled function, in order
4230 to reduce number of taken branches, partitions hot and cold basic blocks
4231 into separate sections of the assembly and .o files, to improve
4232 paging and cache locality performance.
4233
4234 @item -freorder-functions
4235 @opindex freorder-functions
4236 Reorder basic blocks in the compiled function in order to reduce number of
4237 taken branches and improve code locality. This is implemented by using special
4238 subsections @code{.text.hot} for most frequently executed functions and
4239 @code{.text.unlikely} for unlikely executed functions. Reordering is done by
4240 the linker so object file format must support named sections and linker must
4241 place them in a reasonable way.
4242
4243 Also profile feedback must be available in to make this option effective. See
4244 @option{-fprofile-arcs} for details.
4245
4246 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4247
4248 @item -fstrict-aliasing
4249 @opindex fstrict-aliasing
4250 Allows the compiler to assume the strictest aliasing rules applicable to
4251 the language being compiled. For C (and C++), this activates
4252 optimizations based on the type of expressions. In particular, an
4253 object of one type is assumed never to reside at the same address as an
4254 object of a different type, unless the types are almost the same. For
4255 example, an @code{unsigned int} can alias an @code{int}, but not a
4256 @code{void*} or a @code{double}. A character type may alias any other
4257 type.
4258
4259 Pay special attention to code like this:
4260 @smallexample
4261 union a_union @{
4262 int i;
4263 double d;
4264 @};
4265
4266 int f() @{
4267 a_union t;
4268 t.d = 3.0;
4269 return t.i;
4270 @}
4271 @end smallexample
4272 The practice of reading from a different union member than the one most
4273 recently written to (called ``type-punning'') is common. Even with
4274 @option{-fstrict-aliasing}, type-punning is allowed, provided the memory
4275 is accessed through the union type. So, the code above will work as
4276 expected. However, this code might not:
4277 @smallexample
4278 int f() @{
4279 a_union t;
4280 int* ip;
4281 t.d = 3.0;
4282 ip = &t.i;
4283 return *ip;
4284 @}
4285 @end smallexample
4286
4287 Every language that wishes to perform language-specific alias analysis
4288 should define a function that computes, given an @code{tree}
4289 node, an alias set for the node. Nodes in different alias sets are not
4290 allowed to alias. For an example, see the C front-end function
4291 @code{c_get_alias_set}.
4292
4293 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4294
4295 @item -falign-functions
4296 @itemx -falign-functions=@var{n}
4297 @opindex falign-functions
4298 Align the start of functions to the next power-of-two greater than
4299 @var{n}, skipping up to @var{n} bytes. For instance,
4300 @option{-falign-functions=32} aligns functions to the next 32-byte
4301 boundary, but @option{-falign-functions=24} would align to the next
4302 32-byte boundary only if this can be done by skipping 23 bytes or less.
4303
4304 @option{-fno-align-functions} and @option{-falign-functions=1} are
4305 equivalent and mean that functions will not be aligned.
4306
4307 Some assemblers only support this flag when @var{n} is a power of two;
4308 in that case, it is rounded up.
4309
4310 If @var{n} is not specified or is zero, use a machine-dependent default.
4311
4312 Enabled at levels @option{-O2}, @option{-O3}.
4313
4314 @item -falign-labels
4315 @itemx -falign-labels=@var{n}
4316 @opindex falign-labels
4317 Align all branch targets to a power-of-two boundary, skipping up to
4318 @var{n} bytes like @option{-falign-functions}. This option can easily
4319 make code slower, because it must insert dummy operations for when the
4320 branch target is reached in the usual flow of the code.
4321
4322 @option{-fno-align-labels} and @option{-falign-labels=1} are
4323 equivalent and mean that labels will not be aligned.
4324
4325 If @option{-falign-loops} or @option{-falign-jumps} are applicable and
4326 are greater than this value, then their values are used instead.
4327
4328 If @var{n} is not specified or is zero, use a machine-dependent default
4329 which is very likely to be @samp{1}, meaning no alignment.
4330
4331 Enabled at levels @option{-O2}, @option{-O3}.
4332
4333 @item -falign-loops
4334 @itemx -falign-loops=@var{n}
4335 @opindex falign-loops
4336 Align loops to a power-of-two boundary, skipping up to @var{n} bytes
4337 like @option{-falign-functions}. The hope is that the loop will be
4338 executed many times, which will make up for any execution of the dummy
4339 operations.
4340
4341 @option{-fno-align-loops} and @option{-falign-loops=1} are
4342 equivalent and mean that loops will not be aligned.
4343
4344 If @var{n} is not specified or is zero, use a machine-dependent default.
4345
4346 Enabled at levels @option{-O2}, @option{-O3}.
4347
4348 @item -falign-jumps
4349 @itemx -falign-jumps=@var{n}
4350 @opindex falign-jumps
4351 Align branch targets to a power-of-two boundary, for branch targets
4352 where the targets can only be reached by jumping, skipping up to @var{n}
4353 bytes like @option{-falign-functions}. In this case, no dummy operations
4354 need be executed.
4355
4356 @option{-fno-align-jumps} and @option{-falign-jumps=1} are
4357 equivalent and mean that loops will not be aligned.
4358
4359 If @var{n} is not specified or is zero, use a machine-dependent default.
4360
4361 Enabled at levels @option{-O2}, @option{-O3}.
4362
4363 @item -funit-at-a-time
4364 @opindex funit-at-a-time
4365 Parse the whole compilation unit before starting to produce code.
4366 This allows some extra optimizations to take place but consumes
4367 more memory (in general). There are some compatibility issues
4368 with @emph{unit-at-at-time} mode:
4369 @itemize @bullet
4370 @item
4371 enabling @emph{unit-at-a-time} mode may change the order
4372 in which functions, variables, and top-level @code{asm} statements
4373 are emitted, and will likely break code relying on some particular
4374 ordering. The majority of such top-level @code{asm} statements,
4375 though, can be replaced by @code{section} attributes.
4376
4377 @item
4378 @emph{unit-at-a-time} mode removes unreferenced static variables
4379 and functions are removed. This may result in undefined references
4380 when an @code{asm} statement refers directly to variables or functions
4381 that are otherwise unused. In that case either the variable/function
4382 shall be listed as an operand of the @code{asm} statement operand or,
4383 in the case of top-level @code{asm} statements the attribute @code{used}
4384 shall be used on the declaration.
4385
4386 @item
4387 Static functions now can use non-standard passing conventions that
4388 may break @code{asm} statements calling functions directly. Again,
4389 attribute @code{used} will prevent this behavior.
4390 @end itemize
4391
4392 As a temporary workaround, @option{-fno-unit-at-a-time} can be used,
4393 but this scheme may not be supported by future releases of GCC.
4394
4395 Enabled at levels @option{-O2}, @option{-O3}.
4396
4397 @item -fweb
4398 @opindex fweb
4399 Constructs webs as commonly used for register allocation purposes and assign
4400 each web individual pseudo register. This allows our register allocation pass
4401 to operate on pseudos directly, but also strengthens several other optimization
4402 passes, such as CSE, loop optimizer and trivial dead code remover. It can,
4403 however, make debugging impossible, since variables will no longer stay in a
4404 ``home register''.
4405
4406 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os},
4407 on targets where the default format for debugging information supports
4408 variable tracking.
4409
4410 @item -fno-cprop-registers
4411 @opindex fno-cprop-registers
4412 After register allocation and post-register allocation instruction splitting,
4413 we perform a copy-propagation pass to try to reduce scheduling dependencies
4414 and occasionally eliminate the copy.
4415
4416 Disabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4417
4418 @item -fprofile-generate
4419 @opindex fprofile-generate
4420
4421 Enable options usually used for instrumenting application to produce
4422 profile useful for later recompilation with profile feedback based
4423 optimization. You must use @code{-fprofile-generate} both when
4424 compiling and when linking your program.
4425
4426 The following options are enabled: @code{-fprofile-arcs}, @code{-fprofile-values}, @code{-fvpt}.
4427
4428 @item -fprofile-use
4429 @opindex fprofile-use
4430 Enable profile feedback directed optimizations, and optimizations
4431 generally profitable only with profile feedback available.
4432
4433 The following options are enabled: @code{-fbranch-probabilities},
4434 @code{-fvpt}, @code{-funroll-loops}, @code{-fpeel-loops}, @code{-ftracer}.
4435
4436 @end table
4437
4438 The following options control compiler behavior regarding floating
4439 point arithmetic. These options trade off between speed and
4440 correctness. All must be specifically enabled.
4441
4442 @table @gcctabopt
4443 @item -ffloat-store
4444 @opindex ffloat-store
4445 Do not store floating point variables in registers, and inhibit other
4446 options that might change whether a floating point value is taken from a
4447 register or memory.
4448
4449 @cindex floating point precision
4450 This option prevents undesirable excess precision on machines such as
4451 the 68000 where the floating registers (of the 68881) keep more
4452 precision than a @code{double} is supposed to have. Similarly for the
4453 x86 architecture. For most programs, the excess precision does only
4454 good, but a few programs rely on the precise definition of IEEE floating
4455 point. Use @option{-ffloat-store} for such programs, after modifying
4456 them to store all pertinent intermediate computations into variables.
4457
4458 @item -ffast-math
4459 @opindex ffast-math
4460 Sets @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, @*
4461 @option{-fno-trapping-math}, @option{-ffinite-math-only},
4462 @option{-fno-rounding-math} and @option{-fno-signaling-nans}.
4463
4464 This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
4465
4466 This option should never be turned on by any @option{-O} option since
4467 it can result in incorrect output for programs which depend on
4468 an exact implementation of IEEE or ISO rules/specifications for
4469 math functions.
4470
4471 @item -fno-math-errno
4472 @opindex fno-math-errno
4473 Do not set ERRNO after calling math functions that are executed
4474 with a single instruction, e.g., sqrt. A program that relies on
4475 IEEE exceptions for math error handling may want to use this flag
4476 for speed while maintaining IEEE arithmetic compatibility.
4477
4478 This option should never be turned on by any @option{-O} option since
4479 it can result in incorrect output for programs which depend on
4480 an exact implementation of IEEE or ISO rules/specifications for
4481 math functions.
4482
4483 The default is @option{-fmath-errno}.
4484
4485 @item -funsafe-math-optimizations
4486 @opindex funsafe-math-optimizations
4487 Allow optimizations for floating-point arithmetic that (a) assume
4488 that arguments and results are valid and (b) may violate IEEE or
4489 ANSI standards. When used at link-time, it may include libraries
4490 or startup files that change the default FPU control word or other
4491 similar optimizations.
4492
4493 This option should never be turned on by any @option{-O} option since
4494 it can result in incorrect output for programs which depend on
4495 an exact implementation of IEEE or ISO rules/specifications for
4496 math functions.
4497
4498 The default is @option{-fno-unsafe-math-optimizations}.
4499
4500 @item -ffinite-math-only
4501 @opindex ffinite-math-only
4502 Allow optimizations for floating-point arithmetic that assume
4503 that arguments and results are not NaNs or +-Infs.
4504
4505 This option should never be turned on by any @option{-O} option since
4506 it can result in incorrect output for programs which depend on
4507 an exact implementation of IEEE or ISO rules/specifications.
4508
4509 The default is @option{-fno-finite-math-only}.
4510
4511 @item -fno-trapping-math
4512 @opindex fno-trapping-math
4513 Compile code assuming that floating-point operations cannot generate
4514 user-visible traps. These traps include division by zero, overflow,
4515 underflow, inexact result and invalid operation. This option implies
4516 @option{-fno-signaling-nans}. Setting this option may allow faster
4517 code if one relies on ``non-stop'' IEEE arithmetic, for example.
4518
4519 This option should never be turned on by any @option{-O} option since
4520 it can result in incorrect output for programs which depend on
4521 an exact implementation of IEEE or ISO rules/specifications for
4522 math functions.
4523
4524 The default is @option{-ftrapping-math}.
4525
4526 @item -frounding-math
4527 @opindex frounding-math
4528 Disable transformations and optimizations that assume default floating
4529 point rounding behavior. This is round-to-zero for all floating point
4530 to integer conversions, and round-to-nearest for all other arithmetic
4531 truncations. This option should be specified for programs that change
4532 the FP rounding mode dynamically, or that may be executed with a
4533 non-default rounding mode. This option disables constant folding of
4534 floating point expressions at compile-time (which may be affected by
4535 rounding mode) and arithmetic transformations that are unsafe in the
4536 presence of sign-dependent rounding modes.
4537
4538 The default is @option{-fno-rounding-math}.
4539
4540 This option is experimental and does not currently guarantee to
4541 disable all GCC optimizations that are affected by rounding mode.
4542 Future versions of GCC may provide finer control of this setting
4543 using C99's @code{FENV_ACCESS} pragma. This command line option
4544 will be used to specify the default state for @code{FENV_ACCESS}.
4545
4546 @item -fsignaling-nans
4547 @opindex fsignaling-nans
4548 Compile code assuming that IEEE signaling NaNs may generate user-visible
4549 traps during floating-point operations. Setting this option disables
4550 optimizations that may change the number of exceptions visible with
4551 signaling NaNs. This option implies @option{-ftrapping-math}.
4552
4553 This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
4554 be defined.
4555
4556 The default is @option{-fno-signaling-nans}.
4557
4558 This option is experimental and does not currently guarantee to
4559 disable all GCC optimizations that affect signaling NaN behavior.
4560
4561 @item -fsingle-precision-constant
4562 @opindex fsingle-precision-constant
4563 Treat floating point constant as single precision constant instead of
4564 implicitly converting it to double precision constant.
4565
4566
4567 @end table
4568
4569 The following options control optimizations that may improve
4570 performance, but are not enabled by any @option{-O} options. This
4571 section includes experimental options that may produce broken code.
4572
4573 @table @gcctabopt
4574 @item -fbranch-probabilities
4575 @opindex fbranch-probabilities
4576 After running a program compiled with @option{-fprofile-arcs}
4577 (@pxref{Debugging Options,, Options for Debugging Your Program or
4578 @command{gcc}}), you can compile it a second time using
4579 @option{-fbranch-probabilities}, to improve optimizations based on
4580 the number of times each branch was taken. When the program
4581 compiled with @option{-fprofile-arcs} exits it saves arc execution
4582 counts to a file called @file{@var{sourcename}.gcda} for each source
4583 file The information in this data file is very dependent on the
4584 structure of the generated code, so you must use the same source code
4585 and the same optimization options for both compilations.
4586
4587 With @option{-fbranch-probabilities}, GCC puts a
4588 @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
4589 These can be used to improve optimization. Currently, they are only
4590 used in one place: in @file{reorg.c}, instead of guessing which path a
4591 branch is mostly to take, the @samp{REG_BR_PROB} values are used to
4592 exactly determine which path is taken more often.
4593
4594 @item -fprofile-values
4595 @opindex fprofile-values
4596 If combined with @option{-fprofile-arcs}, it adds code so that some
4597 data about values of expressions in the program is gathered.
4598
4599 With @option{-fbranch-probabilities}, it reads back the data gathered
4600 from profiling values of expressions and adds @samp{REG_VALUE_PROFILE}
4601 notes to instructions for their later usage in optimizations.
4602
4603 Enabled with @option{-fprofile-generate} and @option{-fprofile-use}.
4604
4605 @item -fvpt
4606 @opindex fvpt
4607 If combined with @option{-fprofile-arcs}, it instructs the compiler to add
4608 a code to gather information about values of expressions.
4609
4610 With @option{-fbranch-probabilities}, it reads back the data gathered
4611 and actually performs the optimizations based on them.
4612 Currently the optimizations include specialization of division operation
4613 using the knowledge about the value of the denominator.
4614
4615 Enabled with @option{-fprofile-generate} and @option{-fprofile-use}.
4616
4617 @item -frename-registers
4618 @opindex frename-registers
4619 Attempt to avoid false dependencies in scheduled code by making use
4620 of registers left over after register allocation. This optimization
4621 will most benefit processors with lots of registers. Depending on the
4622 debug information format adopted by the target, however, it can
4623 make debugging impossible, since variables will no longer stay in
4624 a ``home register''.
4625
4626 Not enabled by default at any level because it has known bugs.
4627
4628 @item -fnew-ra
4629 @opindex fnew-ra
4630 Use a graph coloring register allocator. Currently this option is meant
4631 for testing, so we are interested to hear about miscompilations with
4632 @option{-fnew-ra}.
4633
4634 @item -ftracer
4635 @opindex ftracer
4636 Perform tail duplication to enlarge superblock size. This transformation
4637 simplifies the control flow of the function allowing other optimizations to do
4638 better job.
4639
4640 Enabled with @option{-fprofile-use}.
4641
4642 @item -funroll-loops
4643 @opindex funroll-loops
4644 Unroll loops whose number of iterations can be determined at compile time or
4645 upon entry to the loop. @option{-funroll-loops} implies
4646 @option{-frerun-cse-after-loop}. It also turns on complete loop peeling
4647 (i.e. complete removal of loops with small constant number of iterations).
4648 This option makes code larger, and may or may not make it run faster.
4649
4650 Enabled with @option{-fprofile-use}.
4651
4652 @item -funroll-all-loops
4653 @opindex funroll-all-loops
4654 Unroll all loops, even if their number of iterations is uncertain when
4655 the loop is entered. This usually makes programs run more slowly.
4656 @option{-funroll-all-loops} implies the same options as
4657 @option{-funroll-loops}.
4658
4659 @item -fpeel-loops
4660 @opindex fpeel-loops
4661 Peels the loops for that there is enough information that they do not
4662 roll much (from profile feedback). It also turns on complete loop peeling
4663 (i.e. complete removal of loops with small constant number of iterations).
4664
4665 Enabled with @option{-fprofile-use}.
4666
4667 @item -funswitch-loops
4668 @opindex funswitch-loops
4669 Move branches with loop invariant conditions out of the loop, with duplicates
4670 of the loop on both branches (modified according to result of the condition).
4671
4672 @item -fold-unroll-loops
4673 @opindex fold-unroll-loops
4674 Unroll loops whose number of iterations can be determined at compile
4675 time or upon entry to the loop, using the old loop unroller whose loop
4676 recognition is based on notes from frontend. @option{-fold-unroll-loops} implies
4677 both @option{-fstrength-reduce} and @option{-frerun-cse-after-loop}. This
4678 option makes code larger, and may or may not make it run faster.
4679
4680 @item -fold-unroll-all-loops
4681 @opindex fold-unroll-all-loops
4682 Unroll all loops, even if their number of iterations is uncertain when
4683 the loop is entered. This is done using the old loop unroller whose loop
4684 recognition is based on notes from frontend. This usually makes programs run more slowly.
4685 @option{-fold-unroll-all-loops} implies the same options as
4686 @option{-fold-unroll-loops}.
4687
4688 @item -fprefetch-loop-arrays
4689 @opindex fprefetch-loop-arrays
4690 If supported by the target machine, generate instructions to prefetch
4691 memory to improve the performance of loops that access large arrays.
4692
4693 Disabled at level @option{-Os}.
4694
4695 @item -ffunction-sections
4696 @itemx -fdata-sections
4697 @opindex ffunction-sections
4698 @opindex fdata-sections
4699 Place each function or data item into its own section in the output
4700 file if the target supports arbitrary sections. The name of the
4701 function or the name of the data item determines the section's name
4702 in the output file.
4703
4704 Use these options on systems where the linker can perform optimizations
4705 to improve locality of reference in the instruction space. Most systems
4706 using the ELF object format and SPARC processors running Solaris 2 have
4707 linkers with such optimizations. AIX may have these optimizations in
4708 the future.
4709
4710 Only use these options when there are significant benefits from doing
4711 so. When you specify these options, the assembler and linker will
4712 create larger object and executable files and will also be slower.
4713 You will not be able to use @code{gprof} on all systems if you
4714 specify this option and you may have problems with debugging if
4715 you specify both this option and @option{-g}.
4716
4717 @item -fbranch-target-load-optimize
4718 @opindex fbranch-target-load-optimize
4719 Perform branch target register load optimization before prologue / epilogue
4720 threading.
4721 The use of target registers can typically be exposed only during reload,
4722 thus hoisting loads out of loops and doing inter-block scheduling needs
4723 a separate optimization pass.
4724
4725 @item -fbranch-target-load-optimize2
4726 @opindex fbranch-target-load-optimize2
4727 Perform branch target register load optimization after prologue / epilogue
4728 threading.
4729
4730 @item -fbtr-bb-exclusive
4731 @opindex fbtr-bb-exclusive
4732 When performing branch target register load optimization, don't reuse
4733 branch target registers in within any basic block.
4734
4735 @item --param @var{name}=@var{value}
4736 @opindex param
4737 In some places, GCC uses various constants to control the amount of
4738 optimization that is done. For example, GCC will not inline functions
4739 that contain more that a certain number of instructions. You can
4740 control some of these constants on the command-line using the
4741 @option{--param} option.
4742
4743 The names of specific parameters, and the meaning of the values, are
4744 tied to the internals of the compiler, and are subject to change
4745 without notice in future releases.
4746
4747 In each case, the @var{value} is an integer. The allowable choices for
4748 @var{name} are given in the following table:
4749
4750 @table @gcctabopt
4751 @item max-crossjump-edges
4752 The maximum number of incoming edges to consider for crossjumping.
4753 The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
4754 the number of edges incoming to each block. Increasing values mean
4755 more aggressive optimization, making the compile time increase with
4756 probably small improvement in executable size.
4757
4758 @item max-delay-slot-insn-search
4759 The maximum number of instructions to consider when looking for an
4760 instruction to fill a delay slot. If more than this arbitrary number of
4761 instructions is searched, the time savings from filling the delay slot
4762 will be minimal so stop searching. Increasing values mean more
4763 aggressive optimization, making the compile time increase with probably
4764 small improvement in executable run time.
4765
4766 @item max-delay-slot-live-search
4767 When trying to fill delay slots, the maximum number of instructions to
4768 consider when searching for a block with valid live register
4769 information. Increasing this arbitrarily chosen value means more
4770 aggressive optimization, increasing the compile time. This parameter
4771 should be removed when the delay slot code is rewritten to maintain the
4772 control-flow graph.
4773
4774 @item max-gcse-memory
4775 The approximate maximum amount of memory that will be allocated in
4776 order to perform the global common subexpression elimination
4777 optimization. If more memory than specified is required, the
4778 optimization will not be done.
4779
4780 @item max-gcse-passes
4781 The maximum number of passes of GCSE to run. The default is 1.
4782
4783 @item max-pending-list-length
4784 The maximum number of pending dependencies scheduling will allow
4785 before flushing the current state and starting over. Large functions
4786 with few branches or calls can create excessively large lists which
4787 needlessly consume memory and resources.
4788
4789 @item max-inline-insns-single
4790 Several parameters control the tree inliner used in gcc.
4791 This number sets the maximum number of instructions (counted in GCC's
4792 internal representation) in a single function that the tree inliner
4793 will consider for inlining. This only affects functions declared
4794 inline and methods implemented in a class declaration (C++).
4795 The default value is 500.
4796
4797 @item max-inline-insns-auto
4798 When you use @option{-finline-functions} (included in @option{-O3}),
4799 a lot of functions that would otherwise not be considered for inlining
4800 by the compiler will be investigated. To those functions, a different
4801 (more restrictive) limit compared to functions declared inline can
4802 be applied.
4803 The default value is 120.
4804
4805 @item large-function-insns
4806 The limit specifying really large functions. For functions greater than this
4807 limit inlining is constrained by @option{--param large-function-growth}.
4808 This parameter is useful primarily to avoid extreme compilation time caused by non-linear
4809 algorithms used by the backend.
4810 This parameter is ignored when @option{-funit-at-a-time} is not used.
4811 The default value is 3000.
4812
4813 @item large-function-growth
4814 Specifies maximal growth of large function caused by inlining in percents.
4815 This parameter is ignored when @option{-funit-at-a-time} is not used.
4816 The default value is 200.
4817
4818 @item inline-unit-growth
4819 Specifies maximal overall growth of the compilation unit caused by inlining.
4820 This parameter is ignored when @option{-funit-at-a-time} is not used.
4821 The default value is 150.
4822
4823 @item max-inline-insns-rtl
4824 For languages that use the RTL inliner (this happens at a later stage
4825 than tree inlining), you can set the maximum allowable size (counted
4826 in RTL instructions) for the RTL inliner with this parameter.
4827 The default value is 600.
4828
4829 @item max-unrolled-insns
4830 The maximum number of instructions that a loop should have if that loop
4831 is unrolled, and if the loop is unrolled, it determines how many times
4832 the loop code is unrolled.
4833
4834 @item max-average-unrolled-insns
4835 The maximum number of instructions biased by probabilities of their execution
4836 that a loop should have if that loop is unrolled, and if the loop is unrolled,
4837 it determines how many times the loop code is unrolled.
4838
4839 @item max-unroll-times
4840 The maximum number of unrollings of a single loop.
4841
4842 @item max-peeled-insns
4843 The maximum number of instructions that a loop should have if that loop
4844 is peeled, and if the loop is peeled, it determines how many times
4845 the loop code is peeled.
4846
4847 @item max-peel-times
4848 The maximum number of peelings of a single loop.
4849
4850 @item max-completely-peeled-insns
4851 The maximum number of insns of a completely peeled loop.
4852
4853 @item max-completely-peel-times
4854 The maximum number of iterations of a loop to be suitable for complete peeling.
4855
4856 @item max-unswitch-insns
4857 The maximum number of insns of an unswitched loop.
4858
4859 @item max-unswitch-level
4860 The maximum number of branches unswitched in a single loop.
4861
4862 @item hot-bb-count-fraction
4863 Select fraction of the maximal count of repetitions of basic block in program
4864 given basic block needs to have to be considered hot.
4865
4866 @item hot-bb-frequency-fraction
4867 Select fraction of the maximal frequency of executions of basic block in
4868 function given basic block needs to have to be considered hot
4869
4870 @item tracer-dynamic-coverage
4871 @itemx tracer-dynamic-coverage-feedback
4872
4873 This value is used to limit superblock formation once the given percentage of
4874 executed instructions is covered. This limits unnecessary code size
4875 expansion.
4876
4877 The @option{tracer-dynamic-coverage-feedback} is used only when profile
4878 feedback is available. The real profiles (as opposed to statically estimated
4879 ones) are much less balanced allowing the threshold to be larger value.
4880
4881 @item tracer-max-code-growth
4882 Stop tail duplication once code growth has reached given percentage. This is
4883 rather hokey argument, as most of the duplicates will be eliminated later in
4884 cross jumping, so it may be set to much higher values than is the desired code
4885 growth.
4886
4887 @item tracer-min-branch-ratio
4888
4889 Stop reverse growth when the reverse probability of best edge is less than this
4890 threshold (in percent).
4891
4892 @item tracer-min-branch-ratio
4893 @itemx tracer-min-branch-ratio-feedback
4894
4895 Stop forward growth if the best edge do have probability lower than this
4896 threshold.
4897
4898 Similarly to @option{tracer-dynamic-coverage} two values are present, one for
4899 compilation for profile feedback and one for compilation without. The value
4900 for compilation with profile feedback needs to be more conservative (higher) in
4901 order to make tracer effective.
4902
4903 @item max-cse-path-length
4904
4905 Maximum number of basic blocks on path that cse considers. The default is 10.
4906
4907 @item ggc-min-expand
4908
4909 GCC uses a garbage collector to manage its own memory allocation. This
4910 parameter specifies the minimum percentage by which the garbage
4911 collector's heap should be allowed to expand between collections.
4912 Tuning this may improve compilation speed; it has no effect on code
4913 generation.
4914
4915 The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
4916 RAM >= 1GB. If @code{getrlimit} is available, the notion of "RAM" is
4917 the smallest of actual RAM, RLIMIT_RSS, RLIMIT_DATA and RLIMIT_AS. If
4918 GCC is not able to calculate RAM on a particular platform, the lower
4919 bound of 30% is used. Setting this parameter and
4920 @option{ggc-min-heapsize} to zero causes a full collection to occur at
4921 every opportunity. This is extremely slow, but can be useful for
4922 debugging.
4923
4924 @item ggc-min-heapsize
4925
4926 Minimum size of the garbage collector's heap before it begins bothering
4927 to collect garbage. The first collection occurs after the heap expands
4928 by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
4929 tuning this may improve compilation speed, and has no effect on code
4930 generation.
4931
4932 The default is RAM/8, with a lower bound of 4096 (four megabytes) and an
4933 upper bound of 131072 (128 megabytes). If @code{getrlimit} is
4934 available, the notion of "RAM" is the smallest of actual RAM,
4935 RLIMIT_RSS, RLIMIT_DATA and RLIMIT_AS. If GCC is not able to calculate
4936 RAM on a particular platform, the lower bound is used. Setting this
4937 parameter very large effectively disables garbage collection. Setting
4938 this parameter and @option{ggc-min-expand} to zero causes a full
4939 collection to occur at every opportunity.
4940
4941 @item max-reload-search-insns
4942 The maximum number of instruction reload should look backward for equivalent
4943 register. Increasing values mean more aggressive optimization, making the
4944 compile time increase with probably slightly better performance. The default
4945 value is 100.
4946
4947 @item max-cselib-memory-location
4948 The maximum number of memory locations cselib should take into acount.
4949 Increasing values mean more aggressive optimization, making the compile time
4950 increase with probably slightly better performance. The default value is 500.
4951
4952 @item reorder-blocks-duplicate
4953 @itemx reorder-blocks-duplicate-feedback
4954
4955 Used by basic block reordering pass to decide whether to use unconditional
4956 branch or duplicate the code on its destination. Code is duplicated when its
4957 estimated size is smaller than this value multiplied by the estimated size of
4958 unconditional jump in the hot spots of the program.
4959
4960 The @option{reorder-block-duplicate-feedback} is used only when profile
4961 feedback is available and may be set to higher values than
4962 @option{reorder-block-duplicate} since information about the hot spots is more
4963 accurate.
4964
4965 @item max-sched-region-blocks
4966 The maximum number of blocks in a region to be considered for
4967 interblock scheduling. The default value is 10.
4968
4969 @item max-sched-region-insns
4970 The maximum number of insns in a region to be considered for
4971 interblock scheduling. The default value is 100.
4972 @end table
4973 @end table
4974
4975 @node Preprocessor Options
4976 @section Options Controlling the Preprocessor
4977 @cindex preprocessor options
4978 @cindex options, preprocessor
4979
4980 These options control the C preprocessor, which is run on each C source
4981 file before actual compilation.
4982
4983 If you use the @option{-E} option, nothing is done except preprocessing.
4984 Some of these options make sense only together with @option{-E} because
4985 they cause the preprocessor output to be unsuitable for actual
4986 compilation.
4987
4988 @table @gcctabopt
4989 @opindex Wp
4990 You can use @option{-Wp,@var{option}} to bypass the compiler driver
4991 and pass @var{option} directly through to the preprocessor. If
4992 @var{option} contains commas, it is split into multiple options at the
4993 commas. However, many options are modified, translated or interpreted
4994 by the compiler driver before being passed to the preprocessor, and
4995 @option{-Wp} forcibly bypasses this phase. The preprocessor's direct
4996 interface is undocumented and subject to change, so whenever possible
4997 you should avoid using @option{-Wp} and let the driver handle the
4998 options instead.
4999
5000 @item -Xpreprocessor @var{option}
5001 @opindex preprocessor
5002 Pass @var{option} as an option to the preprocessor. You can use this to
5003 supply system-specific preprocessor options which GCC does not know how to
5004 recognize.
5005
5006 If you want to pass an option that takes an argument, you must use
5007 @option{-Xpreprocessor} twice, once for the option and once for the argument.
5008 @end table
5009
5010 @include cppopts.texi
5011
5012 @node Assembler Options
5013 @section Passing Options to the Assembler
5014
5015 @c prevent bad page break with this line
5016 You can pass options to the assembler.
5017
5018 @table @gcctabopt
5019 @item -Wa,@var{option}
5020 @opindex Wa
5021 Pass @var{option} as an option to the assembler. If @var{option}
5022 contains commas, it is split into multiple options at the commas.
5023
5024 @item -Xassembler @var{option}
5025 @opindex Xassembler
5026 Pass @var{option} as an option to the assembler. You can use this to
5027 supply system-specific assembler options which GCC does not know how to
5028 recognize.
5029
5030 If you want to pass an option that takes an argument, you must use
5031 @option{-Xassembler} twice, once for the option and once for the argument.
5032
5033 @end table
5034
5035 @node Link Options
5036 @section Options for Linking
5037 @cindex link options
5038 @cindex options, linking
5039
5040 These options come into play when the compiler links object files into
5041 an executable output file. They are meaningless if the compiler is
5042 not doing a link step.
5043
5044 @table @gcctabopt
5045 @cindex file names
5046 @item @var{object-file-name}
5047 A file name that does not end in a special recognized suffix is
5048 considered to name an object file or library. (Object files are
5049 distinguished from libraries by the linker according to the file
5050 contents.) If linking is done, these object files are used as input
5051 to the linker.
5052
5053 @item -c
5054 @itemx -S
5055 @itemx -E
5056 @opindex c
5057 @opindex S
5058 @opindex E
5059 If any of these options is used, then the linker is not run, and
5060 object file names should not be used as arguments. @xref{Overall
5061 Options}.
5062
5063 @cindex Libraries
5064 @item -l@var{library}
5065 @itemx -l @var{library}
5066 @opindex l
5067 Search the library named @var{library} when linking. (The second
5068 alternative with the library as a separate argument is only for
5069 POSIX compliance and is not recommended.)
5070
5071 It makes a difference where in the command you write this option; the
5072 linker searches and processes libraries and object files in the order they
5073 are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
5074 after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
5075 to functions in @samp{z}, those functions may not be loaded.
5076
5077 The linker searches a standard list of directories for the library,
5078 which is actually a file named @file{lib@var{library}.a}. The linker
5079 then uses this file as if it had been specified precisely by name.
5080
5081 The directories searched include several standard system directories
5082 plus any that you specify with @option{-L}.
5083
5084 Normally the files found this way are library files---archive files
5085 whose members are object files. The linker handles an archive file by
5086 scanning through it for members which define symbols that have so far
5087 been referenced but not defined. But if the file that is found is an
5088 ordinary object file, it is linked in the usual fashion. The only
5089 difference between using an @option{-l} option and specifying a file name
5090 is that @option{-l} surrounds @var{library} with @samp{lib} and @samp{.a}
5091 and searches several directories.
5092
5093 @item -lobjc
5094 @opindex lobjc
5095 You need this special case of the @option{-l} option in order to
5096 link an Objective-C program.
5097
5098 @item -nostartfiles
5099 @opindex nostartfiles
5100 Do not use the standard system startup files when linking.
5101 The standard system libraries are used normally, unless @option{-nostdlib}
5102 or @option{-nodefaultlibs} is used.
5103
5104 @item -nodefaultlibs
5105 @opindex nodefaultlibs
5106 Do not use the standard system libraries when linking.
5107 Only the libraries you specify will be passed to the linker.
5108 The standard startup files are used normally, unless @option{-nostartfiles}
5109 is used. The compiler may generate calls to memcmp, memset, and memcpy
5110 for System V (and ISO C) environments or to bcopy and bzero for
5111 BSD environments. These entries are usually resolved by entries in
5112 libc. These entry points should be supplied through some other
5113 mechanism when this option is specified.
5114
5115 @item -nostdlib
5116 @opindex nostdlib
5117 Do not use the standard system startup files or libraries when linking.
5118 No startup files and only the libraries you specify will be passed to
5119 the linker. The compiler may generate calls to memcmp, memset, and memcpy
5120 for System V (and ISO C) environments or to bcopy and bzero for
5121 BSD environments. These entries are usually resolved by entries in
5122 libc. These entry points should be supplied through some other
5123 mechanism when this option is specified.
5124
5125 @cindex @option{-lgcc}, use with @option{-nostdlib}
5126 @cindex @option{-nostdlib} and unresolved references
5127 @cindex unresolved references and @option{-nostdlib}
5128 @cindex @option{-lgcc}, use with @option{-nodefaultlibs}
5129 @cindex @option{-nodefaultlibs} and unresolved references
5130 @cindex unresolved references and @option{-nodefaultlibs}
5131 One of the standard libraries bypassed by @option{-nostdlib} and
5132 @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
5133 that GCC uses to overcome shortcomings of particular machines, or special
5134 needs for some languages.
5135 (@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
5136 Collection (GCC) Internals},
5137 for more discussion of @file{libgcc.a}.)
5138 In most cases, you need @file{libgcc.a} even when you want to avoid
5139 other standard libraries. In other words, when you specify @option{-nostdlib}
5140 or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
5141 This ensures that you have no unresolved references to internal GCC
5142 library subroutines. (For example, @samp{__main}, used to ensure C++
5143 constructors will be called; @pxref{Collect2,,@code{collect2}, gccint,
5144 GNU Compiler Collection (GCC) Internals}.)
5145
5146 @item -pie
5147 @opindex pie
5148 Produce a position independent executable on targets which support it.
5149 For predictable results, you must also specify the same set of options
5150 that were used to generate code (@option{-fpie}, @option{-fPIE},
5151 or model suboptions) when you specify this option.
5152
5153 @item -s
5154 @opindex s
5155 Remove all symbol table and relocation information from the executable.
5156
5157 @item -static
5158 @opindex static
5159 On systems that support dynamic linking, this prevents linking with the shared
5160 libraries. On other systems, this option has no effect.
5161
5162 @item -shared
5163 @opindex shared
5164 Produce a shared object which can then be linked with other objects to
5165 form an executable. Not all systems support this option. For predictable
5166 results, you must also specify the same set of options that were used to
5167 generate code (@option{-fpic}, @option{-fPIC}, or model suboptions)
5168 when you specify this option.@footnote{On some systems, @samp{gcc -shared}
5169 needs to build supplementary stub code for constructors to work. On
5170 multi-libbed systems, @samp{gcc -shared} must select the correct support
5171 libraries to link against. Failing to supply the correct flags may lead
5172 to subtle defects. Supplying them in cases where they are not necessary
5173 is innocuous.}
5174
5175 @item -shared-libgcc
5176 @itemx -static-libgcc
5177 @opindex shared-libgcc
5178 @opindex static-libgcc
5179 On systems that provide @file{libgcc} as a shared library, these options
5180 force the use of either the shared or static version respectively.
5181 If no shared version of @file{libgcc} was built when the compiler was
5182 configured, these options have no effect.
5183
5184 There are several situations in which an application should use the
5185 shared @file{libgcc} instead of the static version. The most common
5186 of these is when the application wishes to throw and catch exceptions
5187 across different shared libraries. In that case, each of the libraries
5188 as well as the application itself should use the shared @file{libgcc}.
5189
5190 Therefore, the G++ and GCJ drivers automatically add
5191 @option{-shared-libgcc} whenever you build a shared library or a main
5192 executable, because C++ and Java programs typically use exceptions, so
5193 this is the right thing to do.
5194
5195 If, instead, you use the GCC driver to create shared libraries, you may
5196 find that they will not always be linked with the shared @file{libgcc}.
5197 If GCC finds, at its configuration time, that you have a GNU linker that
5198 does not support option @option{--eh-frame-hdr}, it will link the shared
5199 version of @file{libgcc} into shared libraries by default. Otherwise,
5200 it will take advantage of the linker and optimize away the linking with
5201 the shared version of @file{libgcc}, linking with the static version of
5202 libgcc by default. This allows exceptions to propagate through such
5203 shared libraries, without incurring relocation costs at library load
5204 time.
5205
5206 However, if a library or main executable is supposed to throw or catch
5207 exceptions, you must link it using the G++ or GCJ driver, as appropriate
5208 for the languages used in the program, or using the option
5209 @option{-shared-libgcc}, such that it is linked with the shared
5210 @file{libgcc}.
5211
5212 @item -symbolic
5213 @opindex symbolic
5214 Bind references to global symbols when building a shared object. Warn
5215 about any unresolved references (unless overridden by the link editor
5216 option @samp{-Xlinker -z -Xlinker defs}). Only a few systems support
5217 this option.
5218
5219 @item -Xlinker @var{option}
5220 @opindex Xlinker
5221 Pass @var{option} as an option to the linker. You can use this to
5222 supply system-specific linker options which GCC does not know how to
5223 recognize.
5224
5225 If you want to pass an option that takes an argument, you must use
5226 @option{-Xlinker} twice, once for the option and once for the argument.
5227 For example, to pass @option{-assert definitions}, you must write
5228 @samp{-Xlinker -assert -Xlinker definitions}. It does not work to write
5229 @option{-Xlinker "-assert definitions"}, because this passes the entire
5230 string as a single argument, which is not what the linker expects.
5231
5232 @item -Wl,@var{option}
5233 @opindex Wl
5234 Pass @var{option} as an option to the linker. If @var{option} contains
5235 commas, it is split into multiple options at the commas.
5236
5237 @item -u @var{symbol}
5238 @opindex u
5239 Pretend the symbol @var{symbol} is undefined, to force linking of
5240 library modules to define it. You can use @option{-u} multiple times with
5241 different symbols to force loading of additional library modules.
5242 @end table
5243
5244 @node Directory Options
5245 @section Options for Directory Search
5246 @cindex directory options
5247 @cindex options, directory search
5248 @cindex search path
5249
5250 These options specify directories to search for header files, for
5251 libraries and for parts of the compiler:
5252
5253 @table @gcctabopt
5254 @item -I@var{dir}
5255 @opindex I
5256 Add the directory @var{dir} to the head of the list of directories to be
5257 searched for header files. This can be used to override a system header
5258 file, substituting your own version, since these directories are
5259 searched before the system header file directories. However, you should
5260 not use this option to add directories that contain vendor-supplied
5261 system header files (use @option{-isystem} for that). If you use more than
5262 one @option{-I} option, the directories are scanned in left-to-right
5263 order; the standard system directories come after.
5264
5265 If a standard system include directory, or a directory specified with
5266 @option{-isystem}, is also specified with @option{-I}, the @option{-I}
5267 option will be ignored. The directory will still be searched but as a
5268 system directory at its normal position in the system include chain.
5269 This is to ensure that GCC's procedure to fix buggy system headers and
5270 the ordering for the include_next directive are not inadvertently changed.
5271 If you really need to change the search order for system directories,
5272 use the @option{-nostdinc} and/or @option{-isystem} options.
5273
5274 @item -iquote@var{dir}
5275 @opindex iquote
5276 Add the directory @var{dir} to the head of the list of directories to
5277 be searched for header files only for the case of @samp{#include
5278 "@var{file}"}; they are not searched for @samp{#include <@var{file}>},
5279 otherwise just like @option{-I}.
5280
5281 @item -L@var{dir}
5282 @opindex L
5283 Add directory @var{dir} to the list of directories to be searched
5284 for @option{-l}.
5285
5286 @item -B@var{prefix}
5287 @opindex B
5288 This option specifies where to find the executables, libraries,
5289 include files, and data files of the compiler itself.
5290
5291 The compiler driver program runs one or more of the subprograms
5292 @file{cpp}, @file{cc1}, @file{as} and @file{ld}. It tries
5293 @var{prefix} as a prefix for each program it tries to run, both with and
5294 without @samp{@var{machine}/@var{version}/} (@pxref{Target Options}).
5295
5296 For each subprogram to be run, the compiler driver first tries the
5297 @option{-B} prefix, if any. If that name is not found, or if @option{-B}
5298 was not specified, the driver tries two standard prefixes, which are
5299 @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
5300 those results in a file name that is found, the unmodified program
5301 name is searched for using the directories specified in your
5302 @env{PATH} environment variable.
5303
5304 The compiler will check to see if the path provided by the @option{-B}
5305 refers to a directory, and if necessary it will add a directory
5306 separator character at the end of the path.
5307
5308 @option{-B} prefixes that effectively specify directory names also apply
5309 to libraries in the linker, because the compiler translates these
5310 options into @option{-L} options for the linker. They also apply to
5311 includes files in the preprocessor, because the compiler translates these
5312 options into @option{-isystem} options for the preprocessor. In this case,
5313 the compiler appends @samp{include} to the prefix.
5314
5315 The run-time support file @file{libgcc.a} can also be searched for using
5316 the @option{-B} prefix, if needed. If it is not found there, the two
5317 standard prefixes above are tried, and that is all. The file is left
5318 out of the link if it is not found by those means.
5319
5320 Another way to specify a prefix much like the @option{-B} prefix is to use
5321 the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
5322 Variables}.
5323
5324 As a special kludge, if the path provided by @option{-B} is
5325 @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
5326 9, then it will be replaced by @file{[dir/]include}. This is to help
5327 with boot-strapping the compiler.
5328
5329 @item -specs=@var{file}
5330 @opindex specs
5331 Process @var{file} after the compiler reads in the standard @file{specs}
5332 file, in order to override the defaults that the @file{gcc} driver
5333 program uses when determining what switches to pass to @file{cc1},
5334 @file{cc1plus}, @file{as}, @file{ld}, etc. More than one
5335 @option{-specs=@var{file}} can be specified on the command line, and they
5336 are processed in order, from left to right.
5337
5338 @item -I-
5339 @opindex I-
5340 This option has been deprecated. Please use @option{-iquote} instead for
5341 @option{-I} directories before the @option{-I-} and remove the @option{-I-}.
5342 Any directories you specify with @option{-I} options before the @option{-I-}
5343 option are searched only for the case of @samp{#include "@var{file}"};
5344 they are not searched for @samp{#include <@var{file}>}.
5345
5346 If additional directories are specified with @option{-I} options after
5347 the @option{-I-}, these directories are searched for all @samp{#include}
5348 directives. (Ordinarily @emph{all} @option{-I} directories are used
5349 this way.)
5350
5351 In addition, the @option{-I-} option inhibits the use of the current
5352 directory (where the current input file came from) as the first search
5353 directory for @samp{#include "@var{file}"}. There is no way to
5354 override this effect of @option{-I-}. With @option{-I.} you can specify
5355 searching the directory which was current when the compiler was
5356 invoked. That is not exactly the same as what the preprocessor does
5357 by default, but it is often satisfactory.
5358
5359 @option{-I-} does not inhibit the use of the standard system directories
5360 for header files. Thus, @option{-I-} and @option{-nostdinc} are
5361 independent.
5362 @end table
5363
5364 @c man end
5365
5366 @node Spec Files
5367 @section Specifying subprocesses and the switches to pass to them
5368 @cindex Spec Files
5369
5370 @command{gcc} is a driver program. It performs its job by invoking a
5371 sequence of other programs to do the work of compiling, assembling and
5372 linking. GCC interprets its command-line parameters and uses these to
5373 deduce which programs it should invoke, and which command-line options
5374 it ought to place on their command lines. This behavior is controlled
5375 by @dfn{spec strings}. In most cases there is one spec string for each
5376 program that GCC can invoke, but a few programs have multiple spec
5377 strings to control their behavior. The spec strings built into GCC can
5378 be overridden by using the @option{-specs=} command-line switch to specify
5379 a spec file.
5380
5381 @dfn{Spec files} are plaintext files that are used to construct spec
5382 strings. They consist of a sequence of directives separated by blank
5383 lines. The type of directive is determined by the first non-whitespace
5384 character on the line and it can be one of the following:
5385
5386 @table @code
5387 @item %@var{command}
5388 Issues a @var{command} to the spec file processor. The commands that can
5389 appear here are:
5390
5391 @table @code
5392 @item %include <@var{file}>
5393 @cindex %include
5394 Search for @var{file} and insert its text at the current point in the
5395 specs file.
5396
5397 @item %include_noerr <@var{file}>
5398 @cindex %include_noerr
5399 Just like @samp{%include}, but do not generate an error message if the include
5400 file cannot be found.
5401
5402 @item %rename @var{old_name} @var{new_name}
5403 @cindex %rename
5404 Rename the spec string @var{old_name} to @var{new_name}.
5405
5406 @end table
5407
5408 @item *[@var{spec_name}]:
5409 This tells the compiler to create, override or delete the named spec
5410 string. All lines after this directive up to the next directive or
5411 blank line are considered to be the text for the spec string. If this
5412 results in an empty string then the spec will be deleted. (Or, if the
5413 spec did not exist, then nothing will happened.) Otherwise, if the spec
5414 does not currently exist a new spec will be created. If the spec does
5415 exist then its contents will be overridden by the text of this
5416 directive, unless the first character of that text is the @samp{+}
5417 character, in which case the text will be appended to the spec.
5418
5419 @item [@var{suffix}]:
5420 Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
5421 and up to the next directive or blank line are considered to make up the
5422 spec string for the indicated suffix. When the compiler encounters an
5423 input file with the named suffix, it will processes the spec string in
5424 order to work out how to compile that file. For example:
5425
5426 @smallexample
5427 .ZZ:
5428 z-compile -input %i
5429 @end smallexample
5430
5431 This says that any input file whose name ends in @samp{.ZZ} should be
5432 passed to the program @samp{z-compile}, which should be invoked with the
5433 command-line switch @option{-input} and with the result of performing the
5434 @samp{%i} substitution. (See below.)
5435
5436 As an alternative to providing a spec string, the text that follows a
5437 suffix directive can be one of the following:
5438
5439 @table @code
5440 @item @@@var{language}
5441 This says that the suffix is an alias for a known @var{language}. This is
5442 similar to using the @option{-x} command-line switch to GCC to specify a
5443 language explicitly. For example:
5444
5445 @smallexample
5446 .ZZ:
5447 @@c++
5448 @end smallexample
5449
5450 Says that .ZZ files are, in fact, C++ source files.
5451
5452 @item #@var{name}
5453 This causes an error messages saying:
5454
5455 @smallexample
5456 @var{name} compiler not installed on this system.
5457 @end smallexample
5458 @end table
5459
5460 GCC already has an extensive list of suffixes built into it.
5461 This directive will add an entry to the end of the list of suffixes, but
5462 since the list is searched from the end backwards, it is effectively
5463 possible to override earlier entries using this technique.
5464
5465 @end table
5466
5467 GCC has the following spec strings built into it. Spec files can
5468 override these strings or create their own. Note that individual
5469 targets can also add their own spec strings to this list.
5470
5471 @smallexample
5472 asm Options to pass to the assembler
5473 asm_final Options to pass to the assembler post-processor
5474 cpp Options to pass to the C preprocessor
5475 cc1 Options to pass to the C compiler
5476 cc1plus Options to pass to the C++ compiler
5477 endfile Object files to include at the end of the link
5478 link Options to pass to the linker
5479 lib Libraries to include on the command line to the linker
5480 libgcc Decides which GCC support library to pass to the linker
5481 linker Sets the name of the linker
5482 predefines Defines to be passed to the C preprocessor
5483 signed_char Defines to pass to CPP to say whether @code{char} is signed
5484 by default
5485 startfile Object files to include at the start of the link
5486 @end smallexample
5487
5488 Here is a small example of a spec file:
5489
5490 @smallexample
5491 %rename lib old_lib
5492
5493 *lib:
5494 --start-group -lgcc -lc -leval1 --end-group %(old_lib)
5495 @end smallexample
5496
5497 This example renames the spec called @samp{lib} to @samp{old_lib} and
5498 then overrides the previous definition of @samp{lib} with a new one.
5499 The new definition adds in some extra command-line options before
5500 including the text of the old definition.
5501
5502 @dfn{Spec strings} are a list of command-line options to be passed to their
5503 corresponding program. In addition, the spec strings can contain
5504 @samp{%}-prefixed sequences to substitute variable text or to
5505 conditionally insert text into the command line. Using these constructs
5506 it is possible to generate quite complex command lines.
5507
5508 Here is a table of all defined @samp{%}-sequences for spec
5509 strings. Note that spaces are not generated automatically around the
5510 results of expanding these sequences. Therefore you can concatenate them
5511 together or combine them with constant text in a single argument.
5512
5513 @table @code
5514 @item %%
5515 Substitute one @samp{%} into the program name or argument.
5516
5517 @item %i
5518 Substitute the name of the input file being processed.
5519
5520 @item %b
5521 Substitute the basename of the input file being processed.
5522 This is the substring up to (and not including) the last period
5523 and not including the directory.
5524
5525 @item %B
5526 This is the same as @samp{%b}, but include the file suffix (text after
5527 the last period).
5528
5529 @item %d
5530 Marks the argument containing or following the @samp{%d} as a
5531 temporary file name, so that that file will be deleted if GCC exits
5532 successfully. Unlike @samp{%g}, this contributes no text to the
5533 argument.
5534
5535 @item %g@var{suffix}
5536 Substitute a file name that has suffix @var{suffix} and is chosen
5537 once per compilation, and mark the argument in the same way as
5538 @samp{%d}. To reduce exposure to denial-of-service attacks, the file
5539 name is now chosen in a way that is hard to predict even when previously
5540 chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
5541 might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
5542 the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
5543 treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
5544 was simply substituted with a file name chosen once per compilation,
5545 without regard to any appended suffix (which was therefore treated
5546 just like ordinary text), making such attacks more likely to succeed.
5547
5548 @item %u@var{suffix}
5549 Like @samp{%g}, but generates a new temporary file name even if
5550 @samp{%u@var{suffix}} was already seen.
5551
5552 @item %U@var{suffix}
5553 Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
5554 new one if there is no such last file name. In the absence of any
5555 @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
5556 the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
5557 would involve the generation of two distinct file names, one
5558 for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
5559 simply substituted with a file name chosen for the previous @samp{%u},
5560 without regard to any appended suffix.
5561
5562 @item %j@var{suffix}
5563 Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
5564 writable, and if save-temps is off; otherwise, substitute the name
5565 of a temporary file, just like @samp{%u}. This temporary file is not
5566 meant for communication between processes, but rather as a junk
5567 disposal mechanism.
5568
5569 @item %|@var{suffix}
5570 @itemx %m@var{suffix}
5571 Like @samp{%g}, except if @option{-pipe} is in effect. In that case
5572 @samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
5573 all. These are the two most common ways to instruct a program that it
5574 should read from standard input or write to standard output. If you
5575 need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
5576 construct: see for example @file{f/lang-specs.h}.
5577
5578 @item %.@var{SUFFIX}
5579 Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
5580 when it is subsequently output with @samp{%*}. @var{SUFFIX} is
5581 terminated by the next space or %.
5582
5583 @item %w
5584 Marks the argument containing or following the @samp{%w} as the
5585 designated output file of this compilation. This puts the argument
5586 into the sequence of arguments that @samp{%o} will substitute later.
5587
5588 @item %o
5589 Substitutes the names of all the output files, with spaces
5590 automatically placed around them. You should write spaces
5591 around the @samp{%o} as well or the results are undefined.
5592 @samp{%o} is for use in the specs for running the linker.
5593 Input files whose names have no recognized suffix are not compiled
5594 at all, but they are included among the output files, so they will
5595 be linked.
5596
5597 @item %O
5598 Substitutes the suffix for object files. Note that this is
5599 handled specially when it immediately follows @samp{%g, %u, or %U},
5600 because of the need for those to form complete file names. The
5601 handling is such that @samp{%O} is treated exactly as if it had already
5602 been substituted, except that @samp{%g, %u, and %U} do not currently
5603 support additional @var{suffix} characters following @samp{%O} as they would
5604 following, for example, @samp{.o}.
5605
5606 @item %p
5607 Substitutes the standard macro predefinitions for the
5608 current target machine. Use this when running @code{cpp}.
5609
5610 @item %P
5611 Like @samp{%p}, but puts @samp{__} before and after the name of each
5612 predefined macro, except for macros that start with @samp{__} or with
5613 @samp{_@var{L}}, where @var{L} is an uppercase letter. This is for ISO
5614 C@.
5615
5616 @item %I
5617 Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
5618 @option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}), and
5619 @option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
5620 as necessary.
5621
5622 @item %s
5623 Current argument is the name of a library or startup file of some sort.
5624 Search for that file in a standard list of directories and substitute
5625 the full name found.
5626
5627 @item %e@var{str}
5628 Print @var{str} as an error message. @var{str} is terminated by a newline.
5629 Use this when inconsistent options are detected.
5630
5631 @item %(@var{name})
5632 Substitute the contents of spec string @var{name} at this point.
5633
5634 @item %[@var{name}]
5635 Like @samp{%(@dots{})} but put @samp{__} around @option{-D} arguments.
5636
5637 @item %x@{@var{option}@}
5638 Accumulate an option for @samp{%X}.
5639
5640 @item %X
5641 Output the accumulated linker options specified by @option{-Wl} or a @samp{%x}
5642 spec string.
5643
5644 @item %Y
5645 Output the accumulated assembler options specified by @option{-Wa}.
5646
5647 @item %Z
5648 Output the accumulated preprocessor options specified by @option{-Wp}.
5649
5650 @item %a
5651 Process the @code{asm} spec. This is used to compute the
5652 switches to be passed to the assembler.
5653
5654 @item %A
5655 Process the @code{asm_final} spec. This is a spec string for
5656 passing switches to an assembler post-processor, if such a program is
5657 needed.
5658
5659 @item %l
5660 Process the @code{link} spec. This is the spec for computing the
5661 command line passed to the linker. Typically it will make use of the
5662 @samp{%L %G %S %D and %E} sequences.
5663
5664 @item %D
5665 Dump out a @option{-L} option for each directory that GCC believes might
5666 contain startup files. If the target supports multilibs then the
5667 current multilib directory will be prepended to each of these paths.
5668
5669 @item %M
5670 Output the multilib directory with directory separators replaced with
5671 @samp{_}. If multilib directories are not set, or the multilib directory is
5672 @file{.} then this option emits nothing.
5673
5674 @item %L
5675 Process the @code{lib} spec. This is a spec string for deciding which
5676 libraries should be included on the command line to the linker.
5677
5678 @item %G
5679 Process the @code{libgcc} spec. This is a spec string for deciding
5680 which GCC support library should be included on the command line to the linker.
5681
5682 @item %S
5683 Process the @code{startfile} spec. This is a spec for deciding which
5684 object files should be the first ones passed to the linker. Typically
5685 this might be a file named @file{crt0.o}.
5686
5687 @item %E
5688 Process the @code{endfile} spec. This is a spec string that specifies
5689 the last object files that will be passed to the linker.
5690
5691 @item %C
5692 Process the @code{cpp} spec. This is used to construct the arguments
5693 to be passed to the C preprocessor.
5694
5695 @item %1
5696 Process the @code{cc1} spec. This is used to construct the options to be
5697 passed to the actual C compiler (@samp{cc1}).
5698
5699 @item %2
5700 Process the @code{cc1plus} spec. This is used to construct the options to be
5701 passed to the actual C++ compiler (@samp{cc1plus}).
5702
5703 @item %*
5704 Substitute the variable part of a matched option. See below.
5705 Note that each comma in the substituted string is replaced by
5706 a single space.
5707
5708 @item %<@code{S}
5709 Remove all occurrences of @code{-S} from the command line. Note---this
5710 command is position dependent. @samp{%} commands in the spec string
5711 before this one will see @code{-S}, @samp{%} commands in the spec string
5712 after this one will not.
5713
5714 @item %:@var{function}(@var{args})
5715 Call the named function @var{function}, passing it @var{args}.
5716 @var{args} is first processed as a nested spec string, then split
5717 into an argument vector in the usual fashion. The function returns
5718 a string which is processed as if it had appeared literally as part
5719 of the current spec.
5720
5721 The following built-in spec functions are provided:
5722
5723 @table @code
5724 @item @code{if-exists}
5725 The @code{if-exists} spec function takes one argument, an absolute
5726 pathname to a file. If the file exists, @code{if-exists} returns the
5727 pathname. Here is a small example of its usage:
5728
5729 @smallexample
5730 *startfile:
5731 crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
5732 @end smallexample
5733
5734 @item @code{if-exists-else}
5735 The @code{if-exists-else} spec function is similar to the @code{if-exists}
5736 spec function, except that it takes two arguments. The first argument is
5737 an absolute pathname to a file. If the file exists, @code{if-exists-else}
5738 returns the pathname. If it does not exist, it returns the second argument.
5739 This way, @code{if-exists-else} can be used to select one file or another,
5740 based on the existence of the first. Here is a small example of its usage:
5741
5742 @smallexample
5743 *startfile:
5744 crt0%O%s %:if-exists(crti%O%s) \
5745 %:if-exists-else(crtbeginT%O%s crtbegin%O%s)
5746 @end smallexample
5747 @end table
5748
5749 @item %@{@code{S}@}
5750 Substitutes the @code{-S} switch, if that switch was given to GCC@.
5751 If that switch was not specified, this substitutes nothing. Note that
5752 the leading dash is omitted when specifying this option, and it is
5753 automatically inserted if the substitution is performed. Thus the spec
5754 string @samp{%@{foo@}} would match the command-line option @option{-foo}
5755 and would output the command line option @option{-foo}.
5756
5757 @item %W@{@code{S}@}
5758 Like %@{@code{S}@} but mark last argument supplied within as a file to be
5759 deleted on failure.
5760
5761 @item %@{@code{S}*@}
5762 Substitutes all the switches specified to GCC whose names start
5763 with @code{-S}, but which also take an argument. This is used for
5764 switches like @option{-o}, @option{-D}, @option{-I}, etc.
5765 GCC considers @option{-o foo} as being
5766 one switch whose names starts with @samp{o}. %@{o*@} would substitute this
5767 text, including the space. Thus two arguments would be generated.
5768
5769 @item %@{@code{S}*&@code{T}*@}
5770 Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
5771 (the order of @code{S} and @code{T} in the spec is not significant).
5772 There can be any number of ampersand-separated variables; for each the
5773 wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
5774
5775 @item %@{@code{S}:@code{X}@}
5776 Substitutes @code{X}, if the @samp{-S} switch was given to GCC@.
5777
5778 @item %@{!@code{S}:@code{X}@}
5779 Substitutes @code{X}, if the @samp{-S} switch was @emph{not} given to GCC@.
5780
5781 @item %@{@code{S}*:@code{X}@}
5782 Substitutes @code{X} if one or more switches whose names start with
5783 @code{-S} are specified to GCC@. Normally @code{X} is substituted only
5784 once, no matter how many such switches appeared. However, if @code{%*}
5785 appears somewhere in @code{X}, then @code{X} will be substituted once
5786 for each matching switch, with the @code{%*} replaced by the part of
5787 that switch that matched the @code{*}.
5788
5789 @item %@{.@code{S}:@code{X}@}
5790 Substitutes @code{X}, if processing a file with suffix @code{S}.
5791
5792 @item %@{!.@code{S}:@code{X}@}
5793 Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
5794
5795 @item %@{@code{S}|@code{P}:@code{X}@}
5796 Substitutes @code{X} if either @code{-S} or @code{-P} was given to GCC@.
5797 This may be combined with @samp{!}, @samp{.}, and @code{*} sequences as well,
5798 although they have a stronger binding than the @samp{|}. If @code{%*}
5799 appears in @code{X}, all of the alternatives must be starred, and only
5800 the first matching alternative is substituted.
5801
5802 For example, a spec string like this:
5803
5804 @smallexample
5805 %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
5806 @end smallexample
5807
5808 will output the following command-line options from the following input
5809 command-line options:
5810
5811 @smallexample
5812 fred.c -foo -baz
5813 jim.d -bar -boggle
5814 -d fred.c -foo -baz -boggle
5815 -d jim.d -bar -baz -boggle
5816 @end smallexample
5817
5818 @item %@{S:X; T:Y; :D@}
5819
5820 If @code{S} was given to GCC, substitutes @code{X}; else if @code{T} was
5821 given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
5822 be as many clauses as you need. This may be combined with @code{.},
5823 @code{!}, @code{|}, and @code{*} as needed.
5824
5825
5826 @end table
5827
5828 The conditional text @code{X} in a %@{@code{S}:@code{X}@} or similar
5829 construct may contain other nested @samp{%} constructs or spaces, or
5830 even newlines. They are processed as usual, as described above.
5831 Trailing white space in @code{X} is ignored. White space may also
5832 appear anywhere on the left side of the colon in these constructs,
5833 except between @code{.} or @code{*} and the corresponding word.
5834
5835 The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
5836 handled specifically in these constructs. If another value of
5837 @option{-O} or the negated form of a @option{-f}, @option{-m}, or
5838 @option{-W} switch is found later in the command line, the earlier
5839 switch value is ignored, except with @{@code{S}*@} where @code{S} is
5840 just one letter, which passes all matching options.
5841
5842 The character @samp{|} at the beginning of the predicate text is used to
5843 indicate that a command should be piped to the following command, but
5844 only if @option{-pipe} is specified.
5845
5846 It is built into GCC which switches take arguments and which do not.
5847 (You might think it would be useful to generalize this to allow each
5848 compiler's spec to say which switches take arguments. But this cannot
5849 be done in a consistent fashion. GCC cannot even decide which input
5850 files have been specified without knowing which switches take arguments,
5851 and it must know which input files to compile in order to tell which
5852 compilers to run).
5853
5854 GCC also knows implicitly that arguments starting in @option{-l} are to be
5855 treated as compiler output files, and passed to the linker in their
5856 proper position among the other output files.
5857
5858 @c man begin OPTIONS
5859
5860 @node Target Options
5861 @section Specifying Target Machine and Compiler Version
5862 @cindex target options
5863 @cindex cross compiling
5864 @cindex specifying machine version
5865 @cindex specifying compiler version and target machine
5866 @cindex compiler version, specifying
5867 @cindex target machine, specifying
5868
5869 The usual way to run GCC is to run the executable called @file{gcc}, or
5870 @file{<machine>-gcc} when cross-compiling, or
5871 @file{<machine>-gcc-<version>} to run a version other than the one that
5872 was installed last. Sometimes this is inconvenient, so GCC provides
5873 options that will switch to another cross-compiler or version.
5874
5875 @table @gcctabopt
5876 @item -b @var{machine}
5877 @opindex b
5878 The argument @var{machine} specifies the target machine for compilation.
5879
5880 The value to use for @var{machine} is the same as was specified as the
5881 machine type when configuring GCC as a cross-compiler. For
5882 example, if a cross-compiler was configured with @samp{configure
5883 i386v}, meaning to compile for an 80386 running System V, then you
5884 would specify @option{-b i386v} to run that cross compiler.
5885
5886 @item -V @var{version}
5887 @opindex V
5888 The argument @var{version} specifies which version of GCC to run.
5889 This is useful when multiple versions are installed. For example,
5890 @var{version} might be @samp{2.0}, meaning to run GCC version 2.0.
5891 @end table
5892
5893 The @option{-V} and @option{-b} options work by running the
5894 @file{<machine>-gcc-<version>} executable, so there's no real reason to
5895 use them if you can just run that directly.
5896
5897 @node Submodel Options
5898 @section Hardware Models and Configurations
5899 @cindex submodel options
5900 @cindex specifying hardware config
5901 @cindex hardware models and configurations, specifying
5902 @cindex machine dependent options
5903
5904 Earlier we discussed the standard option @option{-b} which chooses among
5905 different installed compilers for completely different target
5906 machines, such as VAX vs.@: 68000 vs.@: 80386.
5907
5908 In addition, each of these target machine types can have its own
5909 special options, starting with @samp{-m}, to choose among various
5910 hardware models or configurations---for example, 68010 vs 68020,
5911 floating coprocessor or none. A single installed version of the
5912 compiler can compile for any model or configuration, according to the
5913 options specified.
5914
5915 Some configurations of the compiler also support additional special
5916 options, usually for compatibility with other compilers on the same
5917 platform.
5918
5919 These options are defined by the macro @code{TARGET_SWITCHES} in the
5920 machine description. The default for the options is also defined by
5921 that macro, which enables you to change the defaults.
5922
5923 @menu
5924 * M680x0 Options::
5925 * M68hc1x Options::
5926 * VAX Options::
5927 * SPARC Options::
5928 * ARM Options::
5929 * MN10300 Options::
5930 * M32R/D Options::
5931 * RS/6000 and PowerPC Options::
5932 * Darwin Options::
5933 * MIPS Options::
5934 * i386 and x86-64 Options::
5935 * HPPA Options::
5936 * DEC Alpha Options::
5937 * DEC Alpha/VMS Options::
5938 * H8/300 Options::
5939 * SH Options::
5940 * System V Options::
5941 * TMS320C3x/C4x Options::
5942 * V850 Options::
5943 * ARC Options::
5944 * NS32K Options::
5945 * AVR Options::
5946 * MCore Options::
5947 * IA-64 Options::
5948 * S/390 and zSeries Options::
5949 * CRIS Options::
5950 * MMIX Options::
5951 * PDP-11 Options::
5952 * Xstormy16 Options::
5953 * Xtensa Options::
5954 * FRV Options::
5955 @end menu
5956
5957 @node M680x0 Options
5958 @subsection M680x0 Options
5959 @cindex M680x0 options
5960
5961 These are the @samp{-m} options defined for the 68000 series. The default
5962 values for these options depends on which style of 68000 was selected when
5963 the compiler was configured; the defaults for the most common choices are
5964 given below.
5965
5966 @table @gcctabopt
5967 @item -m68000
5968 @itemx -mc68000
5969 @opindex m68000
5970 @opindex mc68000
5971 Generate output for a 68000. This is the default
5972 when the compiler is configured for 68000-based systems.
5973
5974 Use this option for microcontrollers with a 68000 or EC000 core,
5975 including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
5976
5977 @item -m68020
5978 @itemx -mc68020
5979 @opindex m68020
5980 @opindex mc68020
5981 Generate output for a 68020. This is the default
5982 when the compiler is configured for 68020-based systems.
5983
5984 @item -m68881
5985 @opindex m68881
5986 Generate output containing 68881 instructions for floating point.
5987 This is the default for most 68020 systems unless @option{--nfp} was
5988 specified when the compiler was configured.
5989
5990 @item -m68030
5991 @opindex m68030
5992 Generate output for a 68030. This is the default when the compiler is
5993 configured for 68030-based systems.
5994
5995 @item -m68040
5996 @opindex m68040
5997 Generate output for a 68040. This is the default when the compiler is
5998 configured for 68040-based systems.
5999
6000 This option inhibits the use of 68881/68882 instructions that have to be
6001 emulated by software on the 68040. Use this option if your 68040 does not
6002 have code to emulate those instructions.
6003
6004 @item -m68060
6005 @opindex m68060
6006 Generate output for a 68060. This is the default when the compiler is
6007 configured for 68060-based systems.
6008
6009 This option inhibits the use of 68020 and 68881/68882 instructions that
6010 have to be emulated by software on the 68060. Use this option if your 68060
6011 does not have code to emulate those instructions.
6012
6013 @item -mcpu32
6014 @opindex mcpu32
6015 Generate output for a CPU32. This is the default
6016 when the compiler is configured for CPU32-based systems.
6017
6018 Use this option for microcontrollers with a
6019 CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
6020 68336, 68340, 68341, 68349 and 68360.
6021
6022 @item -m5200
6023 @opindex m5200
6024 Generate output for a 520X ``coldfire'' family cpu. This is the default
6025 when the compiler is configured for 520X-based systems.
6026
6027 Use this option for microcontroller with a 5200 core, including
6028 the MCF5202, MCF5203, MCF5204 and MCF5202.
6029
6030
6031 @item -m68020-40
6032 @opindex m68020-40
6033 Generate output for a 68040, without using any of the new instructions.
6034 This results in code which can run relatively efficiently on either a
6035 68020/68881 or a 68030 or a 68040. The generated code does use the
6036 68881 instructions that are emulated on the 68040.
6037
6038 @item -m68020-60
6039 @opindex m68020-60
6040 Generate output for a 68060, without using any of the new instructions.
6041 This results in code which can run relatively efficiently on either a
6042 68020/68881 or a 68030 or a 68040. The generated code does use the
6043 68881 instructions that are emulated on the 68060.
6044
6045 @item -msoft-float
6046 @opindex msoft-float
6047 Generate output containing library calls for floating point.
6048 @strong{Warning:} the requisite libraries are not available for all m68k
6049 targets. Normally the facilities of the machine's usual C compiler are
6050 used, but this can't be done directly in cross-compilation. You must
6051 make your own arrangements to provide suitable library functions for
6052 cross-compilation. The embedded targets @samp{m68k-*-aout} and
6053 @samp{m68k-*-coff} do provide software floating point support.
6054
6055 @item -mshort
6056 @opindex mshort
6057 Consider type @code{int} to be 16 bits wide, like @code{short int}.
6058
6059 @item -mnobitfield
6060 @opindex mnobitfield
6061 Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
6062 and @option{-m5200} options imply @w{@option{-mnobitfield}}.
6063
6064 @item -mbitfield
6065 @opindex mbitfield
6066 Do use the bit-field instructions. The @option{-m68020} option implies
6067 @option{-mbitfield}. This is the default if you use a configuration
6068 designed for a 68020.
6069
6070 @item -mrtd
6071 @opindex mrtd
6072 Use a different function-calling convention, in which functions
6073 that take a fixed number of arguments return with the @code{rtd}
6074 instruction, which pops their arguments while returning. This
6075 saves one instruction in the caller since there is no need to pop
6076 the arguments there.
6077
6078 This calling convention is incompatible with the one normally
6079 used on Unix, so you cannot use it if you need to call libraries
6080 compiled with the Unix compiler.
6081
6082 Also, you must provide function prototypes for all functions that
6083 take variable numbers of arguments (including @code{printf});
6084 otherwise incorrect code will be generated for calls to those
6085 functions.
6086
6087 In addition, seriously incorrect code will result if you call a
6088 function with too many arguments. (Normally, extra arguments are
6089 harmlessly ignored.)
6090
6091 The @code{rtd} instruction is supported by the 68010, 68020, 68030,
6092 68040, 68060 and CPU32 processors, but not by the 68000 or 5200.
6093
6094 @item -malign-int
6095 @itemx -mno-align-int
6096 @opindex malign-int
6097 @opindex mno-align-int
6098 Control whether GCC aligns @code{int}, @code{long}, @code{long long},
6099 @code{float}, @code{double}, and @code{long double} variables on a 32-bit
6100 boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
6101 Aligning variables on 32-bit boundaries produces code that runs somewhat
6102 faster on processors with 32-bit busses at the expense of more memory.
6103
6104 @strong{Warning:} if you use the @option{-malign-int} switch, GCC will
6105 align structures containing the above types differently than
6106 most published application binary interface specifications for the m68k.
6107
6108 @item -mpcrel
6109 @opindex mpcrel
6110 Use the pc-relative addressing mode of the 68000 directly, instead of
6111 using a global offset table. At present, this option implies @option{-fpic},
6112 allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
6113 not presently supported with @option{-mpcrel}, though this could be supported for
6114 68020 and higher processors.
6115
6116 @item -mno-strict-align
6117 @itemx -mstrict-align
6118 @opindex mno-strict-align
6119 @opindex mstrict-align
6120 Do not (do) assume that unaligned memory references will be handled by
6121 the system.
6122
6123 @item -msep-data
6124 Generate code that allows the data segment to be located in a different
6125 area of memory from the text segment. This allows for execute in place in
6126 an environment without virtual memory management. This option implies -fPIC.
6127
6128 @item -mno-sep-data
6129 Generate code that assumes that the data segment follows the text segment.
6130 This is the default.
6131
6132 @item -mid-shared-library
6133 Generate code that supports shared libraries via the library ID method.
6134 This allows for execute in place and shared libraries in an environment
6135 without virtual memory management. This option implies -fPIC.
6136
6137 @item -mno-id-shared-library
6138 Generate code that doesn't assume ID based shared libraries are being used.
6139 This is the default.
6140
6141 @item -mshared-library-id=n
6142 Specified the identification number of the ID based shared library being
6143 compiled. Specifying a value of 0 will generate more compact code, specifying
6144 other values will force the allocation of that number to the current
6145 library but is no more space or time efficient than omitting this option.
6146
6147 @end table
6148
6149 @node M68hc1x Options
6150 @subsection M68hc1x Options
6151 @cindex M68hc1x options
6152
6153 These are the @samp{-m} options defined for the 68hc11 and 68hc12
6154 microcontrollers. The default values for these options depends on
6155 which style of microcontroller was selected when the compiler was configured;
6156 the defaults for the most common choices are given below.
6157
6158 @table @gcctabopt
6159 @item -m6811
6160 @itemx -m68hc11
6161 @opindex m6811
6162 @opindex m68hc11
6163 Generate output for a 68HC11. This is the default
6164 when the compiler is configured for 68HC11-based systems.
6165
6166 @item -m6812
6167 @itemx -m68hc12
6168 @opindex m6812
6169 @opindex m68hc12
6170 Generate output for a 68HC12. This is the default
6171 when the compiler is configured for 68HC12-based systems.
6172
6173 @item -m68S12
6174 @itemx -m68hcs12
6175 @opindex m68S12
6176 @opindex m68hcs12
6177 Generate output for a 68HCS12.
6178
6179 @item -mauto-incdec
6180 @opindex mauto-incdec
6181 Enable the use of 68HC12 pre and post auto-increment and auto-decrement
6182 addressing modes.
6183
6184 @item -minmax
6185 @itemx -nominmax
6186 @opindex minmax
6187 @opindex mnominmax
6188 Enable the use of 68HC12 min and max instructions.
6189
6190 @item -mlong-calls
6191 @itemx -mno-long-calls
6192 @opindex mlong-calls
6193 @opindex mno-long-calls
6194 Treat all calls as being far away (near). If calls are assumed to be
6195 far away, the compiler will use the @code{call} instruction to
6196 call a function and the @code{rtc} instruction for returning.
6197
6198 @item -mshort
6199 @opindex mshort
6200 Consider type @code{int} to be 16 bits wide, like @code{short int}.
6201
6202 @item -msoft-reg-count=@var{count}
6203 @opindex msoft-reg-count
6204 Specify the number of pseudo-soft registers which are used for the
6205 code generation. The maximum number is 32. Using more pseudo-soft
6206 register may or may not result in better code depending on the program.
6207 The default is 4 for 68HC11 and 2 for 68HC12.
6208
6209 @end table
6210
6211 @node VAX Options
6212 @subsection VAX Options
6213 @cindex VAX options
6214
6215 These @samp{-m} options are defined for the VAX:
6216
6217 @table @gcctabopt
6218 @item -munix
6219 @opindex munix
6220 Do not output certain jump instructions (@code{aobleq} and so on)
6221 that the Unix assembler for the VAX cannot handle across long
6222 ranges.
6223
6224 @item -mgnu
6225 @opindex mgnu
6226 Do output those jump instructions, on the assumption that you
6227 will assemble with the GNU assembler.
6228
6229 @item -mg
6230 @opindex mg
6231 Output code for g-format floating point numbers instead of d-format.
6232 @end table
6233
6234 @node SPARC Options
6235 @subsection SPARC Options
6236 @cindex SPARC options
6237
6238 These @samp{-m} options are supported on the SPARC:
6239
6240 @table @gcctabopt
6241 @item -mno-app-regs
6242 @itemx -mapp-regs
6243 @opindex mno-app-regs
6244 @opindex mapp-regs
6245 Specify @option{-mapp-regs} to generate output using the global registers
6246 2 through 4, which the SPARC SVR4 ABI reserves for applications. This
6247 is the default.
6248
6249 To be fully SVR4 ABI compliant at the cost of some performance loss,
6250 specify @option{-mno-app-regs}. You should compile libraries and system
6251 software with this option.
6252
6253 @item -mfpu
6254 @itemx -mhard-float
6255 @opindex mfpu
6256 @opindex mhard-float
6257 Generate output containing floating point instructions. This is the
6258 default.
6259
6260 @item -mno-fpu
6261 @itemx -msoft-float
6262 @opindex mno-fpu
6263 @opindex msoft-float
6264 Generate output containing library calls for floating point.
6265 @strong{Warning:} the requisite libraries are not available for all SPARC
6266 targets. Normally the facilities of the machine's usual C compiler are
6267 used, but this cannot be done directly in cross-compilation. You must make
6268 your own arrangements to provide suitable library functions for
6269 cross-compilation. The embedded targets @samp{sparc-*-aout} and
6270 @samp{sparclite-*-*} do provide software floating point support.
6271
6272 @option{-msoft-float} changes the calling convention in the output file;
6273 therefore, it is only useful if you compile @emph{all} of a program with
6274 this option. In particular, you need to compile @file{libgcc.a}, the
6275 library that comes with GCC, with @option{-msoft-float} in order for
6276 this to work.
6277
6278 @item -mhard-quad-float
6279 @opindex mhard-quad-float
6280 Generate output containing quad-word (long double) floating point
6281 instructions.
6282
6283 @item -msoft-quad-float
6284 @opindex msoft-quad-float
6285 Generate output containing library calls for quad-word (long double)
6286 floating point instructions. The functions called are those specified
6287 in the SPARC ABI@. This is the default.
6288
6289 As of this writing, there are no SPARC implementations that have hardware
6290 support for the quad-word floating point instructions. They all invoke
6291 a trap handler for one of these instructions, and then the trap handler
6292 emulates the effect of the instruction. Because of the trap handler overhead,
6293 this is much slower than calling the ABI library routines. Thus the
6294 @option{-msoft-quad-float} option is the default.
6295
6296 @item -mno-unaligned-doubles
6297 @itemx -munaligned-doubles
6298 @opindex mno-unaligned-doubles
6299 @opindex munaligned-doubles
6300 Assume that doubles have 8 byte alignment. This is the default.
6301
6302 With @option{-munaligned-doubles}, GCC assumes that doubles have 8 byte
6303 alignment only if they are contained in another type, or if they have an
6304 absolute address. Otherwise, it assumes they have 4 byte alignment.
6305 Specifying this option avoids some rare compatibility problems with code
6306 generated by other compilers. It is not the default because it results
6307 in a performance loss, especially for floating point code.
6308
6309 @item -mno-faster-structs
6310 @itemx -mfaster-structs
6311 @opindex mno-faster-structs
6312 @opindex mfaster-structs
6313 With @option{-mfaster-structs}, the compiler assumes that structures
6314 should have 8 byte alignment. This enables the use of pairs of
6315 @code{ldd} and @code{std} instructions for copies in structure
6316 assignment, in place of twice as many @code{ld} and @code{st} pairs.
6317 However, the use of this changed alignment directly violates the SPARC
6318 ABI@. Thus, it's intended only for use on targets where the developer
6319 acknowledges that their resulting code will not be directly in line with
6320 the rules of the ABI@.
6321
6322 @item -mimpure-text
6323 @opindex mimpure-text
6324 @option{-mimpure-text}, used in addition to @option{-shared}, tells
6325 the compiler to not pass @option{-z text} to the linker when linking a
6326 shared object. Using this option, you can link position-dependent
6327 code into a shared object.
6328
6329 @option{-mimpure-text} suppresses the ``relocations remain against
6330 allocatable but non-writable sections'' linker error message.
6331 However, the necessary relocations will trigger copy-on-write, and the
6332 shared object is not actually shared across processes. Instead of
6333 using @option{-mimpure-text}, you should compile all source code with
6334 @option{-fpic} or @option{-fPIC}.
6335
6336 This option is only available on SunOS and Solaris.
6337
6338 @item -mcpu=@var{cpu_type}
6339 @opindex mcpu
6340 Set the instruction set, register set, and instruction scheduling parameters
6341 for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
6342 @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{sparclite},
6343 @samp{f930}, @samp{f934}, @samp{hypersparc}, @samp{sparclite86x},
6344 @samp{sparclet}, @samp{tsc701}, @samp{v9}, @samp{ultrasparc}, and
6345 @samp{ultrasparc3}.
6346
6347 Default instruction scheduling parameters are used for values that select
6348 an architecture and not an implementation. These are @samp{v7}, @samp{v8},
6349 @samp{sparclite}, @samp{sparclet}, @samp{v9}.
6350
6351 Here is a list of each supported architecture and their supported
6352 implementations.
6353
6354 @smallexample
6355 v7: cypress
6356 v8: supersparc, hypersparc
6357 sparclite: f930, f934, sparclite86x
6358 sparclet: tsc701
6359 v9: ultrasparc, ultrasparc3
6360 @end smallexample
6361
6362 By default (unless configured otherwise), GCC generates code for the V7
6363 variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
6364 additionally optimizes it for the Cypress CY7C602 chip, as used in the
6365 SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
6366 SPARCStation 1, 2, IPX etc.
6367
6368 With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
6369 architecture. The only difference from V7 code is that the compiler emits
6370 the integer multiply and integer divide instructions which exist in SPARC-V8
6371 but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
6372 optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
6373 2000 series.
6374
6375 With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
6376 the SPARC architecture. This adds the integer multiply, integer divide step
6377 and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
6378 With @option{-mcpu=f930}, the compiler additionally optimizes it for the
6379 Fujitsu MB86930 chip, which is the original SPARClite, with no FPU. With
6380 @option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
6381 MB86934 chip, which is the more recent SPARClite with FPU.
6382
6383 With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
6384 the SPARC architecture. This adds the integer multiply, multiply/accumulate,
6385 integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
6386 but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
6387 optimizes it for the TEMIC SPARClet chip.
6388
6389 With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
6390 architecture. This adds 64-bit integer and floating-point move instructions,
6391 3 additional floating-point condition code registers and conditional move
6392 instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
6393 optimizes it for the Sun UltraSPARC I/II chips. With
6394 @option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
6395 Sun UltraSPARC III chip.
6396
6397 @item -mtune=@var{cpu_type}
6398 @opindex mtune
6399 Set the instruction scheduling parameters for machine type
6400 @var{cpu_type}, but do not set the instruction set or register set that the
6401 option @option{-mcpu=@var{cpu_type}} would.
6402
6403 The same values for @option{-mcpu=@var{cpu_type}} can be used for
6404 @option{-mtune=@var{cpu_type}}, but the only useful values are those
6405 that select a particular cpu implementation. Those are @samp{cypress},
6406 @samp{supersparc}, @samp{hypersparc}, @samp{f930}, @samp{f934},
6407 @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc}, and
6408 @samp{ultrasparc3}.
6409
6410 @item -mv8plus
6411 @itemx -mno-v8plus
6412 @opindex mv8plus
6413 @opindex mno-v8plus
6414 With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI. The
6415 difference from the V8 ABI is that the global and out registers are
6416 considered 64-bit wide. This is enabled by default on Solaris in 32-bit
6417 mode for all SPARC-V9 processors.
6418
6419 @item -mvis
6420 @itemx -mno-vis
6421 @opindex mvis
6422 @opindex mno-vis
6423 With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
6424 Visual Instruction Set extensions. The default is @option{-mno-vis}.
6425 @end table
6426
6427 These @samp{-m} options are supported in addition to the above
6428 on SPARC-V9 processors in 64-bit environments:
6429
6430 @table @gcctabopt
6431 @item -mlittle-endian
6432 @opindex mlittle-endian
6433 Generate code for a processor running in little-endian mode. It is only
6434 available for a few configurations and most notably not on Solaris.
6435
6436 @item -m32
6437 @itemx -m64
6438 @opindex m32
6439 @opindex m64
6440 Generate code for a 32-bit or 64-bit environment.
6441 The 32-bit environment sets int, long and pointer to 32 bits.
6442 The 64-bit environment sets int to 32 bits and long and pointer
6443 to 64 bits.
6444
6445 @item -mcmodel=medlow
6446 @opindex mcmodel=medlow
6447 Generate code for the Medium/Low code model: 64-bit addresses, programs
6448 must be linked in the low 32 bits of memory. Programs can be statically
6449 or dynamically linked.
6450
6451 @item -mcmodel=medmid
6452 @opindex mcmodel=medmid
6453 Generate code for the Medium/Middle code model: 64-bit addresses, programs
6454 must be linked in the low 44 bits of memory, the text and data segments must
6455 be less than 2GB in size and the data segment must be located within 2GB of
6456 the text segment.
6457
6458 @item -mcmodel=medany
6459 @opindex mcmodel=medany
6460 Generate code for the Medium/Anywhere code model: 64-bit addresses, programs
6461 may be linked anywhere in memory, the text and data segments must be less
6462 than 2GB in size and the data segment must be located within 2GB of the
6463 text segment.
6464
6465 @item -mcmodel=embmedany
6466 @opindex mcmodel=embmedany
6467 Generate code for the Medium/Anywhere code model for embedded systems:
6468 64-bit addresses, the text and data segments must be less than 2GB in
6469 size, both starting anywhere in memory (determined at link time). The
6470 global register %g4 points to the base of the data segment. Programs
6471 are statically linked and PIC is not supported.
6472
6473 @item -mstack-bias
6474 @itemx -mno-stack-bias
6475 @opindex mstack-bias
6476 @opindex mno-stack-bias
6477 With @option{-mstack-bias}, GCC assumes that the stack pointer, and
6478 frame pointer if present, are offset by @minus{}2047 which must be added back
6479 when making stack frame references. This is the default in 64-bit mode.
6480 Otherwise, assume no such offset is present.
6481 @end table
6482
6483 @node ARM Options
6484 @subsection ARM Options
6485 @cindex ARM options
6486
6487 These @samp{-m} options are defined for Advanced RISC Machines (ARM)
6488 architectures:
6489
6490 @table @gcctabopt
6491 @item -mabi=@var{name}
6492 @opindex mabi
6493 Generate code for the specified ABI. Permissible values are: @samp{apcs-gnu},
6494 @samp{atpcs}, @samp{aapcs} and @samp{iwmmxt}.
6495
6496 @item -mapcs-frame
6497 @opindex mapcs-frame
6498 Generate a stack frame that is compliant with the ARM Procedure Call
6499 Standard for all functions, even if this is not strictly necessary for
6500 correct execution of the code. Specifying @option{-fomit-frame-pointer}
6501 with this option will cause the stack frames not to be generated for
6502 leaf functions. The default is @option{-mno-apcs-frame}.
6503
6504 @item -mapcs
6505 @opindex mapcs
6506 This is a synonym for @option{-mapcs-frame}.
6507
6508 @item -mapcs-26
6509 @opindex mapcs-26
6510 Generate code for a processor running with a 26-bit program counter,
6511 and conforming to the function calling standards for the APCS 26-bit
6512 option. This option replaces the @option{-m2} and @option{-m3} options
6513 of previous releases of the compiler.
6514
6515 @item -mapcs-32
6516 @opindex mapcs-32
6517 Generate code for a processor running with a 32-bit program counter,
6518 and conforming to the function calling standards for the APCS 32-bit
6519 option. This option replaces the @option{-m6} option of previous releases
6520 of the compiler.
6521
6522 @ignore
6523 @c not currently implemented
6524 @item -mapcs-stack-check
6525 @opindex mapcs-stack-check
6526 Generate code to check the amount of stack space available upon entry to
6527 every function (that actually uses some stack space). If there is
6528 insufficient space available then either the function
6529 @samp{__rt_stkovf_split_small} or @samp{__rt_stkovf_split_big} will be
6530 called, depending upon the amount of stack space required. The run time
6531 system is required to provide these functions. The default is
6532 @option{-mno-apcs-stack-check}, since this produces smaller code.
6533
6534 @c not currently implemented
6535 @item -mapcs-float
6536 @opindex mapcs-float
6537 Pass floating point arguments using the float point registers. This is
6538 one of the variants of the APCS@. This option is recommended if the
6539 target hardware has a floating point unit or if a lot of floating point
6540 arithmetic is going to be performed by the code. The default is
6541 @option{-mno-apcs-float}, since integer only code is slightly increased in
6542 size if @option{-mapcs-float} is used.
6543
6544 @c not currently implemented
6545 @item -mapcs-reentrant
6546 @opindex mapcs-reentrant
6547 Generate reentrant, position independent code. The default is
6548 @option{-mno-apcs-reentrant}.
6549 @end ignore
6550
6551 @item -mthumb-interwork
6552 @opindex mthumb-interwork
6553 Generate code which supports calling between the ARM and Thumb
6554 instruction sets. Without this option the two instruction sets cannot
6555 be reliably used inside one program. The default is
6556 @option{-mno-thumb-interwork}, since slightly larger code is generated
6557 when @option{-mthumb-interwork} is specified.
6558
6559 @item -mno-sched-prolog
6560 @opindex mno-sched-prolog
6561 Prevent the reordering of instructions in the function prolog, or the
6562 merging of those instruction with the instructions in the function's
6563 body. This means that all functions will start with a recognizable set
6564 of instructions (or in fact one of a choice from a small set of
6565 different function prologues), and this information can be used to
6566 locate the start if functions inside an executable piece of code. The
6567 default is @option{-msched-prolog}.
6568
6569 @item -mhard-float
6570 @opindex mhard-float
6571 Generate output containing floating point instructions. This is the
6572 default.
6573
6574 @item -msoft-float
6575 @opindex msoft-float
6576 Generate output containing library calls for floating point.
6577 @strong{Warning:} the requisite libraries are not available for all ARM
6578 targets. Normally the facilities of the machine's usual C compiler are
6579 used, but this cannot be done directly in cross-compilation. You must make
6580 your own arrangements to provide suitable library functions for
6581 cross-compilation.
6582
6583 @option{-msoft-float} changes the calling convention in the output file;
6584 therefore, it is only useful if you compile @emph{all} of a program with
6585 this option. In particular, you need to compile @file{libgcc.a}, the
6586 library that comes with GCC, with @option{-msoft-float} in order for
6587 this to work.
6588
6589 @item -mfloat-abi=@var{name}
6590 @opindex mfloat-abi
6591 Specifies which ABI to use for floating point values. Permissible values
6592 are: @samp{soft}, @samp{softfp} and @samp{hard}.
6593
6594 @samp{soft} and @samp{hard} are equivalent to @option{-msoft-float}
6595 and @option{-mhard-float} respectively. @samp{softfp} allows the generation
6596 of floating point instructions, but still uses the soft-float calling
6597 conventions.
6598
6599 @item -mlittle-endian
6600 @opindex mlittle-endian
6601 Generate code for a processor running in little-endian mode. This is
6602 the default for all standard configurations.
6603
6604 @item -mbig-endian
6605 @opindex mbig-endian
6606 Generate code for a processor running in big-endian mode; the default is
6607 to compile code for a little-endian processor.
6608
6609 @item -mwords-little-endian
6610 @opindex mwords-little-endian
6611 This option only applies when generating code for big-endian processors.
6612 Generate code for a little-endian word order but a big-endian byte
6613 order. That is, a byte order of the form @samp{32107654}. Note: this
6614 option should only be used if you require compatibility with code for
6615 big-endian ARM processors generated by versions of the compiler prior to
6616 2.8.
6617
6618 @item -malignment-traps
6619 @opindex malignment-traps
6620 Generate code that will not trap if the MMU has alignment traps enabled.
6621 On ARM architectures prior to ARMv4, there were no instructions to
6622 access half-word objects stored in memory. However, when reading from
6623 memory a feature of the ARM architecture allows a word load to be used,
6624 even if the address is unaligned, and the processor core will rotate the
6625 data as it is being loaded. This option tells the compiler that such
6626 misaligned accesses will cause a MMU trap and that it should instead
6627 synthesize the access as a series of byte accesses. The compiler can
6628 still use word accesses to load half-word data if it knows that the
6629 address is aligned to a word boundary.
6630
6631 This option is ignored when compiling for ARM architecture 4 or later,
6632 since these processors have instructions to directly access half-word
6633 objects in memory.
6634
6635 @item -mno-alignment-traps
6636 @opindex mno-alignment-traps
6637 Generate code that assumes that the MMU will not trap unaligned
6638 accesses. This produces better code when the target instruction set
6639 does not have half-word memory operations (i.e.@: implementations prior to
6640 ARMv4).
6641
6642 Note that you cannot use this option to access unaligned word objects,
6643 since the processor will only fetch one 32-bit aligned object from
6644 memory.
6645
6646 The default setting for most targets is @option{-mno-alignment-traps}, since
6647 this produces better code when there are no half-word memory
6648 instructions available.
6649
6650 @item -mshort-load-bytes
6651 @itemx -mno-short-load-words
6652 @opindex mshort-load-bytes
6653 @opindex mno-short-load-words
6654 These are deprecated aliases for @option{-malignment-traps}.
6655
6656 @item -mno-short-load-bytes
6657 @itemx -mshort-load-words
6658 @opindex mno-short-load-bytes
6659 @opindex mshort-load-words
6660 This are deprecated aliases for @option{-mno-alignment-traps}.
6661
6662 @item -mcpu=@var{name}
6663 @opindex mcpu
6664 This specifies the name of the target ARM processor. GCC uses this name
6665 to determine what kind of instructions it can emit when generating
6666 assembly code. Permissible names are: @samp{arm2}, @samp{arm250},
6667 @samp{arm3}, @samp{arm6}, @samp{arm60}, @samp{arm600}, @samp{arm610},
6668 @samp{arm620}, @samp{arm7}, @samp{arm7m}, @samp{arm7d}, @samp{arm7dm},
6669 @samp{arm7di}, @samp{arm7dmi}, @samp{arm70}, @samp{arm700},
6670 @samp{arm700i}, @samp{arm710}, @samp{arm710c}, @samp{arm7100},
6671 @samp{arm7500}, @samp{arm7500fe}, @samp{arm7tdmi}, @samp{arm8},
6672 @samp{strongarm}, @samp{strongarm110}, @samp{strongarm1100},
6673 @samp{arm8}, @samp{arm810}, @samp{arm9}, @samp{arm9e}, @samp{arm920},
6674 @samp{arm920t}, @samp{arm926ejs}, @samp{arm940t}, @samp{arm9tdmi},
6675 @samp{arm10tdmi}, @samp{arm1020t}, @samp{arm1026ejs},
6676 @samp{arm1136js}, @samp{arm1136jfs} ,@samp{xscale}, @samp{iwmmxt},
6677 @samp{ep9312}.
6678
6679 @itemx -mtune=@var{name}
6680 @opindex mtune
6681 This option is very similar to the @option{-mcpu=} option, except that
6682 instead of specifying the actual target processor type, and hence
6683 restricting which instructions can be used, it specifies that GCC should
6684 tune the performance of the code as if the target were of the type
6685 specified in this option, but still choosing the instructions that it
6686 will generate based on the cpu specified by a @option{-mcpu=} option.
6687 For some ARM implementations better performance can be obtained by using
6688 this option.
6689
6690 @item -march=@var{name}
6691 @opindex march
6692 This specifies the name of the target ARM architecture. GCC uses this
6693 name to determine what kind of instructions it can emit when generating
6694 assembly code. This option can be used in conjunction with or instead
6695 of the @option{-mcpu=} option. Permissible names are: @samp{armv2},
6696 @samp{armv2a}, @samp{armv3}, @samp{armv3m}, @samp{armv4}, @samp{armv4t},
6697 @samp{armv5}, @samp{armv5t}, @samp{armv5te}, @samp{armv6}, @samp{armv6j},
6698 @samp{iwmmxt}, @samp{ep9312}.
6699
6700 @item -mfpu=@var{name}
6701 @itemx -mfpe=@var{number}
6702 @itemx -mfp=@var{number}
6703 @opindex mfpu
6704 @opindex mfpe
6705 @opindex mfp
6706 This specifies what floating point hardware (or hardware emulation) is
6707 available on the target. Permissible names are: @samp{fpa}, @samp{fpe2},
6708 @samp{fpe3}, @samp{maverick}, @samp{vfp}. @option{-mfp} and @option{-mfpe}
6709 are synonyms for @option{-mfpu}=@samp{fpe}@var{number}, for compatibility
6710 with older versions of GCC@.
6711
6712 If @option{-msoft-float} is specified this specifies the format of
6713 floating point values.
6714
6715 @item -mstructure-size-boundary=@var{n}
6716 @opindex mstructure-size-boundary
6717 The size of all structures and unions will be rounded up to a multiple
6718 of the number of bits set by this option. Permissible values are 8, 32
6719 and 64. The default value varies for different toolchains. For the COFF
6720 targeted toolchain the default value is 8. A value of 64 is only allowed
6721 if the underlying ABI supports it.
6722
6723 Specifying the larger number can produce faster, more efficient code, but
6724 can also increase the size of the program. Different values are potentially
6725 incompatible. Code compiled with one value cannot necessarily expect to
6726 work with code or libraries compiled with another value, if they exchange
6727 information using structures or unions.
6728
6729 @item -mabort-on-noreturn
6730 @opindex mabort-on-noreturn
6731 Generate a call to the function @code{abort} at the end of a
6732 @code{noreturn} function. It will be executed if the function tries to
6733 return.
6734
6735 @item -mlong-calls
6736 @itemx -mno-long-calls
6737 @opindex mlong-calls
6738 @opindex mno-long-calls
6739 Tells the compiler to perform function calls by first loading the
6740 address of the function into a register and then performing a subroutine
6741 call on this register. This switch is needed if the target function
6742 will lie outside of the 64 megabyte addressing range of the offset based
6743 version of subroutine call instruction.
6744
6745 Even if this switch is enabled, not all function calls will be turned
6746 into long calls. The heuristic is that static functions, functions
6747 which have the @samp{short-call} attribute, functions that are inside
6748 the scope of a @samp{#pragma no_long_calls} directive and functions whose
6749 definitions have already been compiled within the current compilation
6750 unit, will not be turned into long calls. The exception to this rule is
6751 that weak function definitions, functions with the @samp{long-call}
6752 attribute or the @samp{section} attribute, and functions that are within
6753 the scope of a @samp{#pragma long_calls} directive, will always be
6754 turned into long calls.
6755
6756 This feature is not enabled by default. Specifying
6757 @option{-mno-long-calls} will restore the default behavior, as will
6758 placing the function calls within the scope of a @samp{#pragma
6759 long_calls_off} directive. Note these switches have no effect on how
6760 the compiler generates code to handle function calls via function
6761 pointers.
6762
6763 @item -mnop-fun-dllimport
6764 @opindex mnop-fun-dllimport
6765 Disable support for the @code{dllimport} attribute.
6766
6767 @item -msingle-pic-base
6768 @opindex msingle-pic-base
6769 Treat the register used for PIC addressing as read-only, rather than
6770 loading it in the prologue for each function. The run-time system is
6771 responsible for initializing this register with an appropriate value
6772 before execution begins.
6773
6774 @item -mpic-register=@var{reg}
6775 @opindex mpic-register
6776 Specify the register to be used for PIC addressing. The default is R10
6777 unless stack-checking is enabled, when R9 is used.
6778
6779 @item -mcirrus-fix-invalid-insns
6780 @opindex mcirrus-fix-invalid-insns
6781 @opindex mno-cirrus-fix-invalid-insns
6782 Insert NOPs into the instruction stream to in order to work around
6783 problems with invalid Maverick instruction combinations. This option
6784 is only valid if the @option{-mcpu=ep9312} option has been used to
6785 enable generation of instructions for the Cirrus Maverick floating
6786 point co-processor. This option is not enabled by default, since the
6787 problem is only present in older Maverick implementations. The default
6788 can be re-enabled by use of the @option{-mno-cirrus-fix-invalid-insns}
6789 switch.
6790
6791 @item -mpoke-function-name
6792 @opindex mpoke-function-name
6793 Write the name of each function into the text section, directly
6794 preceding the function prologue. The generated code is similar to this:
6795
6796 @smallexample
6797 t0
6798 .ascii "arm_poke_function_name", 0
6799 .align
6800 t1
6801 .word 0xff000000 + (t1 - t0)
6802 arm_poke_function_name
6803 mov ip, sp
6804 stmfd sp!, @{fp, ip, lr, pc@}
6805 sub fp, ip, #4
6806 @end smallexample
6807
6808 When performing a stack backtrace, code can inspect the value of
6809 @code{pc} stored at @code{fp + 0}. If the trace function then looks at
6810 location @code{pc - 12} and the top 8 bits are set, then we know that
6811 there is a function name embedded immediately preceding this location
6812 and has length @code{((pc[-3]) & 0xff000000)}.
6813
6814 @item -mthumb
6815 @opindex mthumb
6816 Generate code for the 16-bit Thumb instruction set. The default is to
6817 use the 32-bit ARM instruction set.
6818
6819 @item -mtpcs-frame
6820 @opindex mtpcs-frame
6821 Generate a stack frame that is compliant with the Thumb Procedure Call
6822 Standard for all non-leaf functions. (A leaf function is one that does
6823 not call any other functions.) The default is @option{-mno-tpcs-frame}.
6824
6825 @item -mtpcs-leaf-frame
6826 @opindex mtpcs-leaf-frame
6827 Generate a stack frame that is compliant with the Thumb Procedure Call
6828 Standard for all leaf functions. (A leaf function is one that does
6829 not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
6830
6831 @item -mcallee-super-interworking
6832 @opindex mcallee-super-interworking
6833 Gives all externally visible functions in the file being compiled an ARM
6834 instruction set header which switches to Thumb mode before executing the
6835 rest of the function. This allows these functions to be called from
6836 non-interworking code.
6837
6838 @item -mcaller-super-interworking
6839 @opindex mcaller-super-interworking
6840 Allows calls via function pointers (including virtual functions) to
6841 execute correctly regardless of whether the target code has been
6842 compiled for interworking or not. There is a small overhead in the cost
6843 of executing a function pointer if this option is enabled.
6844
6845 @end table
6846
6847 @node MN10300 Options
6848 @subsection MN10300 Options
6849 @cindex MN10300 options
6850
6851 These @option{-m} options are defined for Matsushita MN10300 architectures:
6852
6853 @table @gcctabopt
6854 @item -mmult-bug
6855 @opindex mmult-bug
6856 Generate code to avoid bugs in the multiply instructions for the MN10300
6857 processors. This is the default.
6858
6859 @item -mno-mult-bug
6860 @opindex mno-mult-bug
6861 Do not generate code to avoid bugs in the multiply instructions for the
6862 MN10300 processors.
6863
6864 @item -mam33
6865 @opindex mam33
6866 Generate code which uses features specific to the AM33 processor.
6867
6868 @item -mno-am33
6869 @opindex mno-am33
6870 Do not generate code which uses features specific to the AM33 processor. This
6871 is the default.
6872
6873 @item -mno-crt0
6874 @opindex mno-crt0
6875 Do not link in the C run-time initialization object file.
6876
6877 @item -mrelax
6878 @opindex mrelax
6879 Indicate to the linker that it should perform a relaxation optimization pass
6880 to shorten branches, calls and absolute memory addresses. This option only
6881 has an effect when used on the command line for the final link step.
6882
6883 This option makes symbolic debugging impossible.
6884 @end table
6885
6886
6887 @node M32R/D Options
6888 @subsection M32R/D Options
6889 @cindex M32R/D options
6890
6891 These @option{-m} options are defined for Renesas M32R/D architectures:
6892
6893 @table @gcctabopt
6894 @item -m32r2
6895 @opindex m32r2
6896 Generate code for the M32R/2@.
6897
6898 @item -m32rx
6899 @opindex m32rx
6900 Generate code for the M32R/X@.
6901
6902 @item -m32r
6903 @opindex m32r
6904 Generate code for the M32R@. This is the default.
6905
6906 @item -mmodel=small
6907 @opindex mmodel=small
6908 Assume all objects live in the lower 16MB of memory (so that their addresses
6909 can be loaded with the @code{ld24} instruction), and assume all subroutines
6910 are reachable with the @code{bl} instruction.
6911 This is the default.
6912
6913 The addressability of a particular object can be set with the
6914 @code{model} attribute.
6915
6916 @item -mmodel=medium
6917 @opindex mmodel=medium
6918 Assume objects may be anywhere in the 32-bit address space (the compiler
6919 will generate @code{seth/add3} instructions to load their addresses), and
6920 assume all subroutines are reachable with the @code{bl} instruction.
6921
6922 @item -mmodel=large
6923 @opindex mmodel=large
6924 Assume objects may be anywhere in the 32-bit address space (the compiler
6925 will generate @code{seth/add3} instructions to load their addresses), and
6926 assume subroutines may not be reachable with the @code{bl} instruction
6927 (the compiler will generate the much slower @code{seth/add3/jl}
6928 instruction sequence).
6929
6930 @item -msdata=none
6931 @opindex msdata=none
6932 Disable use of the small data area. Variables will be put into
6933 one of @samp{.data}, @samp{bss}, or @samp{.rodata} (unless the
6934 @code{section} attribute has been specified).
6935 This is the default.
6936
6937 The small data area consists of sections @samp{.sdata} and @samp{.sbss}.
6938 Objects may be explicitly put in the small data area with the
6939 @code{section} attribute using one of these sections.
6940
6941 @item -msdata=sdata
6942 @opindex msdata=sdata
6943 Put small global and static data in the small data area, but do not
6944 generate special code to reference them.
6945
6946 @item -msdata=use
6947 @opindex msdata=use
6948 Put small global and static data in the small data area, and generate
6949 special instructions to reference them.
6950
6951 @item -G @var{num}
6952 @opindex G
6953 @cindex smaller data references
6954 Put global and static objects less than or equal to @var{num} bytes
6955 into the small data or bss sections instead of the normal data or bss
6956 sections. The default value of @var{num} is 8.
6957 The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
6958 for this option to have any effect.
6959
6960 All modules should be compiled with the same @option{-G @var{num}} value.
6961 Compiling with different values of @var{num} may or may not work; if it
6962 doesn't the linker will give an error message---incorrect code will not be
6963 generated.
6964
6965 @item -mdebug
6966 @opindex mdebug
6967 Makes the M32R specific code in the compiler display some statistics
6968 that might help in debugging programs.
6969
6970 @item -malign-loops
6971 @opindex malign-loops
6972 Align all loops to a 32-byte boundary.
6973
6974 @item -mno-align-loops
6975 @opindex mno-align-loops
6976 Do not enforce a 32-byte alignment for loops. This is the default.
6977
6978 @item -missue-rate=@var{number}
6979 @opindex missue-rate=@var{number}
6980 Issue @var{number} instructions per cycle. @var{number} can only be 1
6981 or 2.
6982
6983 @item -mbranch-cost=@var{number}
6984 @opindex mbranch-cost=@var{number}
6985 @var{number} can only be 1 or 2. If it is 1 then branches will be
6986 preferred over conditional code, if it is 2, then the opposite will
6987 apply.
6988
6989 @item -mflush-trap=@var{number}
6990 @opindex mflush-trap=@var{number}
6991 Specifies the trap number to use to flush the cache. The default is
6992 12. Valid numbers are between 0 and 15 inclusive.
6993
6994 @item -mno-flush-trap
6995 @opindex mno-flush-trap
6996 Specifies that the cache cannot be flushed by using a trap.
6997
6998 @item -mflush-func=@var{name}
6999 @opindex mflush-func=@var{name}
7000 Specifies the name of the operating system function to call to flush
7001 the cache. The default is @emph{_flush_cache}, but a function call
7002 will only be used if a trap is not available.
7003
7004 @item -mno-flush-func
7005 @opindex mno-flush-func
7006 Indicates that there is no OS function for flushing the cache.
7007
7008 @end table
7009
7010 @node RS/6000 and PowerPC Options
7011 @subsection IBM RS/6000 and PowerPC Options
7012 @cindex RS/6000 and PowerPC Options
7013 @cindex IBM RS/6000 and PowerPC Options
7014
7015 These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
7016 @table @gcctabopt
7017 @item -mpower
7018 @itemx -mno-power
7019 @itemx -mpower2
7020 @itemx -mno-power2
7021 @itemx -mpowerpc
7022 @itemx -mno-powerpc
7023 @itemx -mpowerpc-gpopt
7024 @itemx -mno-powerpc-gpopt
7025 @itemx -mpowerpc-gfxopt
7026 @itemx -mno-powerpc-gfxopt
7027 @itemx -mpowerpc64
7028 @itemx -mno-powerpc64
7029 @opindex mpower
7030 @opindex mno-power
7031 @opindex mpower2
7032 @opindex mno-power2
7033 @opindex mpowerpc
7034 @opindex mno-powerpc
7035 @opindex mpowerpc-gpopt
7036 @opindex mno-powerpc-gpopt
7037 @opindex mpowerpc-gfxopt
7038 @opindex mno-powerpc-gfxopt
7039 @opindex mpowerpc64
7040 @opindex mno-powerpc64
7041 GCC supports two related instruction set architectures for the
7042 RS/6000 and PowerPC@. The @dfn{POWER} instruction set are those
7043 instructions supported by the @samp{rios} chip set used in the original
7044 RS/6000 systems and the @dfn{PowerPC} instruction set is the
7045 architecture of the Motorola MPC5xx, MPC6xx, MPC8xx microprocessors, and
7046 the IBM 4xx microprocessors.
7047
7048 Neither architecture is a subset of the other. However there is a
7049 large common subset of instructions supported by both. An MQ
7050 register is included in processors supporting the POWER architecture.
7051
7052 You use these options to specify which instructions are available on the
7053 processor you are using. The default value of these options is
7054 determined when configuring GCC@. Specifying the
7055 @option{-mcpu=@var{cpu_type}} overrides the specification of these
7056 options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
7057 rather than the options listed above.
7058
7059 The @option{-mpower} option allows GCC to generate instructions that
7060 are found only in the POWER architecture and to use the MQ register.
7061 Specifying @option{-mpower2} implies @option{-power} and also allows GCC
7062 to generate instructions that are present in the POWER2 architecture but
7063 not the original POWER architecture.
7064
7065 The @option{-mpowerpc} option allows GCC to generate instructions that
7066 are found only in the 32-bit subset of the PowerPC architecture.
7067 Specifying @option{-mpowerpc-gpopt} implies @option{-mpowerpc} and also allows
7068 GCC to use the optional PowerPC architecture instructions in the
7069 General Purpose group, including floating-point square root. Specifying
7070 @option{-mpowerpc-gfxopt} implies @option{-mpowerpc} and also allows GCC to
7071 use the optional PowerPC architecture instructions in the Graphics
7072 group, including floating-point select.
7073
7074 The @option{-mpowerpc64} option allows GCC to generate the additional
7075 64-bit instructions that are found in the full PowerPC64 architecture
7076 and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
7077 @option{-mno-powerpc64}.
7078
7079 If you specify both @option{-mno-power} and @option{-mno-powerpc}, GCC
7080 will use only the instructions in the common subset of both
7081 architectures plus some special AIX common-mode calls, and will not use
7082 the MQ register. Specifying both @option{-mpower} and @option{-mpowerpc}
7083 permits GCC to use any instruction from either architecture and to
7084 allow use of the MQ register; specify this for the Motorola MPC601.
7085
7086 @item -mnew-mnemonics
7087 @itemx -mold-mnemonics
7088 @opindex mnew-mnemonics
7089 @opindex mold-mnemonics
7090 Select which mnemonics to use in the generated assembler code. With
7091 @option{-mnew-mnemonics}, GCC uses the assembler mnemonics defined for
7092 the PowerPC architecture. With @option{-mold-mnemonics} it uses the
7093 assembler mnemonics defined for the POWER architecture. Instructions
7094 defined in only one architecture have only one mnemonic; GCC uses that
7095 mnemonic irrespective of which of these options is specified.
7096
7097 GCC defaults to the mnemonics appropriate for the architecture in
7098 use. Specifying @option{-mcpu=@var{cpu_type}} sometimes overrides the
7099 value of these option. Unless you are building a cross-compiler, you
7100 should normally not specify either @option{-mnew-mnemonics} or
7101 @option{-mold-mnemonics}, but should instead accept the default.
7102
7103 @item -mcpu=@var{cpu_type}
7104 @opindex mcpu
7105 Set architecture type, register usage, choice of mnemonics, and
7106 instruction scheduling parameters for machine type @var{cpu_type}.
7107 Supported values for @var{cpu_type} are @samp{401}, @samp{403},
7108 @samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{505},
7109 @samp{601}, @samp{602}, @samp{603}, @samp{603e}, @samp{604},
7110 @samp{604e}, @samp{620}, @samp{630}, @samp{740}, @samp{7400},
7111 @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
7112 @samp{860}, @samp{970}, @samp{common}, @samp{ec603e}, @samp{G3},
7113 @samp{G4}, @samp{G5}, @samp{power}, @samp{power2}, @samp{power3},
7114 @samp{power4}, @samp{power5}, @samp{powerpc}, @samp{powerpc64},
7115 @samp{rios}, @samp{rios1}, @samp{rios2}, @samp{rsc}, and @samp{rs64a}.
7116
7117 @option{-mcpu=common} selects a completely generic processor. Code
7118 generated under this option will run on any POWER or PowerPC processor.
7119 GCC will use only the instructions in the common subset of both
7120 architectures, and will not use the MQ register. GCC assumes a generic
7121 processor model for scheduling purposes.
7122
7123 @option{-mcpu=power}, @option{-mcpu=power2}, @option{-mcpu=powerpc}, and
7124 @option{-mcpu=powerpc64} specify generic POWER, POWER2, pure 32-bit
7125 PowerPC (i.e., not MPC601), and 64-bit PowerPC architecture machine
7126 types, with an appropriate, generic processor model assumed for
7127 scheduling purposes.
7128
7129 The other options specify a specific processor. Code generated under
7130 those options will run best on that processor, and may not run at all on
7131 others.
7132
7133 The @option{-mcpu} options automatically enable or disable the
7134 following options: @option{-maltivec}, @option{-mhard-float},
7135 @option{-mmfcrf}, @option{-mmultiple}, @option{-mnew-mnemonics},
7136 @option{-mpower}, @option{-mpower2}, @option{-mpowerpc64},
7137 @option{-mpowerpc-gpopt}, @option{-mpowerpc-gfxopt},
7138 @option{-mstring}. The particular options set for any particular CPU
7139 will vary between compiler versions, depending on what setting seems
7140 to produce optimal code for that CPU; it doesn't necessarily reflect
7141 the actual hardware's capabilities. If you wish to set an individual
7142 option to a particular value, you may specify it after the
7143 @option{-mcpu} option, like @samp{-mcpu=970 -mno-altivec}.
7144
7145 On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
7146 not enabled or disabled by the @option{-mcpu} option at present, since
7147 AIX does not have full support for these options. You may still
7148 enable or disable them individually if you're sure it'll work in your
7149 environment.
7150
7151 @item -mtune=@var{cpu_type}
7152 @opindex mtune
7153 Set the instruction scheduling parameters for machine type
7154 @var{cpu_type}, but do not set the architecture type, register usage, or
7155 choice of mnemonics, as @option{-mcpu=@var{cpu_type}} would. The same
7156 values for @var{cpu_type} are used for @option{-mtune} as for
7157 @option{-mcpu}. If both are specified, the code generated will use the
7158 architecture, registers, and mnemonics set by @option{-mcpu}, but the
7159 scheduling parameters set by @option{-mtune}.
7160
7161 @item -maltivec
7162 @itemx -mno-altivec
7163 @opindex maltivec
7164 @opindex mno-altivec
7165 These switches enable or disable the use of built-in functions that
7166 allow access to the AltiVec instruction set. You may also need to set
7167 @option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
7168 enhancements.
7169
7170 @item -mabi=spe
7171 @opindex mabi=spe
7172 Extend the current ABI with SPE ABI extensions. This does not change
7173 the default ABI, instead it adds the SPE ABI extensions to the current
7174 ABI@.
7175
7176 @item -mabi=no-spe
7177 @opindex mabi=no-spe
7178 Disable Booke SPE ABI extensions for the current ABI.
7179
7180 @item -misel=@var{yes/no}
7181 @itemx -misel
7182 @opindex misel
7183 This switch enables or disables the generation of ISEL instructions.
7184
7185 @item -mspe=@var{yes/no}
7186 @itemx -mspe
7187 @opindex mspe
7188 This switch enables or disables the generation of SPE simd
7189 instructions.
7190
7191 @item -mfloat-gprs=@var{yes/no}
7192 @itemx -mfloat-gprs
7193 @opindex mfloat-gprs
7194 This switch enables or disables the generation of floating point
7195 operations on the general purpose registers for architectures that
7196 support it. This option is currently only available on the MPC8540.
7197
7198 @item -mfull-toc
7199 @itemx -mno-fp-in-toc
7200 @itemx -mno-sum-in-toc
7201 @itemx -mminimal-toc
7202 @opindex mfull-toc
7203 @opindex mno-fp-in-toc
7204 @opindex mno-sum-in-toc
7205 @opindex mminimal-toc
7206 Modify generation of the TOC (Table Of Contents), which is created for
7207 every executable file. The @option{-mfull-toc} option is selected by
7208 default. In that case, GCC will allocate at least one TOC entry for
7209 each unique non-automatic variable reference in your program. GCC
7210 will also place floating-point constants in the TOC@. However, only
7211 16,384 entries are available in the TOC@.
7212
7213 If you receive a linker error message that saying you have overflowed
7214 the available TOC space, you can reduce the amount of TOC space used
7215 with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
7216 @option{-mno-fp-in-toc} prevents GCC from putting floating-point
7217 constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
7218 generate code to calculate the sum of an address and a constant at
7219 run-time instead of putting that sum into the TOC@. You may specify one
7220 or both of these options. Each causes GCC to produce very slightly
7221 slower and larger code at the expense of conserving TOC space.
7222
7223 If you still run out of space in the TOC even when you specify both of
7224 these options, specify @option{-mminimal-toc} instead. This option causes
7225 GCC to make only one TOC entry for every file. When you specify this
7226 option, GCC will produce code that is slower and larger but which
7227 uses extremely little TOC space. You may wish to use this option
7228 only on files that contain less frequently executed code.
7229
7230 @item -maix64
7231 @itemx -maix32
7232 @opindex maix64
7233 @opindex maix32
7234 Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
7235 @code{long} type, and the infrastructure needed to support them.
7236 Specifying @option{-maix64} implies @option{-mpowerpc64} and
7237 @option{-mpowerpc}, while @option{-maix32} disables the 64-bit ABI and
7238 implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
7239
7240 @item -mxl-call
7241 @itemx -mno-xl-call
7242 @opindex mxl-call
7243 @opindex mno-xl-call
7244 On AIX, pass floating-point arguments to prototyped functions beyond the
7245 register save area (RSA) on the stack in addition to argument FPRs. The
7246 AIX calling convention was extended but not initially documented to
7247 handle an obscure K&R C case of calling a function that takes the
7248 address of its arguments with fewer arguments than declared. AIX XL
7249 compilers access floating point arguments which do not fit in the
7250 RSA from the stack when a subroutine is compiled without
7251 optimization. Because always storing floating-point arguments on the
7252 stack is inefficient and rarely needed, this option is not enabled by
7253 default and only is necessary when calling subroutines compiled by AIX
7254 XL compilers without optimization.
7255
7256 @item -mpe
7257 @opindex mpe
7258 Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
7259 application written to use message passing with special startup code to
7260 enable the application to run. The system must have PE installed in the
7261 standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
7262 must be overridden with the @option{-specs=} option to specify the
7263 appropriate directory location. The Parallel Environment does not
7264 support threads, so the @option{-mpe} option and the @option{-pthread}
7265 option are incompatible.
7266
7267 @item -malign-natural
7268 @itemx -malign-power
7269 @opindex malign-natural
7270 @opindex malign-power
7271 On AIX, Darwin, and 64-bit PowerPC GNU/Linux, the option
7272 @option{-malign-natural} overrides the ABI-defined alignment of larger
7273 types, such as floating-point doubles, on their natural size-based boundary.
7274 The option @option{-malign-power} instructs GCC to follow the ABI-specified
7275 alignment rules. GCC defaults to the standard alignment defined in the ABI.
7276
7277 @item -msoft-float
7278 @itemx -mhard-float
7279 @opindex msoft-float
7280 @opindex mhard-float
7281 Generate code that does not use (uses) the floating-point register set.
7282 Software floating point emulation is provided if you use the
7283 @option{-msoft-float} option, and pass the option to GCC when linking.
7284
7285 @item -mmultiple
7286 @itemx -mno-multiple
7287 @opindex mmultiple
7288 @opindex mno-multiple
7289 Generate code that uses (does not use) the load multiple word
7290 instructions and the store multiple word instructions. These
7291 instructions are generated by default on POWER systems, and not
7292 generated on PowerPC systems. Do not use @option{-mmultiple} on little
7293 endian PowerPC systems, since those instructions do not work when the
7294 processor is in little endian mode. The exceptions are PPC740 and
7295 PPC750 which permit the instructions usage in little endian mode.
7296
7297 @item -mstring
7298 @itemx -mno-string
7299 @opindex mstring
7300 @opindex mno-string
7301 Generate code that uses (does not use) the load string instructions
7302 and the store string word instructions to save multiple registers and
7303 do small block moves. These instructions are generated by default on
7304 POWER systems, and not generated on PowerPC systems. Do not use
7305 @option{-mstring} on little endian PowerPC systems, since those
7306 instructions do not work when the processor is in little endian mode.
7307 The exceptions are PPC740 and PPC750 which permit the instructions
7308 usage in little endian mode.
7309
7310 @item -mupdate
7311 @itemx -mno-update
7312 @opindex mupdate
7313 @opindex mno-update
7314 Generate code that uses (does not use) the load or store instructions
7315 that update the base register to the address of the calculated memory
7316 location. These instructions are generated by default. If you use
7317 @option{-mno-update}, there is a small window between the time that the
7318 stack pointer is updated and the address of the previous frame is
7319 stored, which means code that walks the stack frame across interrupts or
7320 signals may get corrupted data.
7321
7322 @item -mfused-madd
7323 @itemx -mno-fused-madd
7324 @opindex mfused-madd
7325 @opindex mno-fused-madd
7326 Generate code that uses (does not use) the floating point multiply and
7327 accumulate instructions. These instructions are generated by default if
7328 hardware floating is used.
7329
7330 @item -mno-bit-align
7331 @itemx -mbit-align
7332 @opindex mno-bit-align
7333 @opindex mbit-align
7334 On System V.4 and embedded PowerPC systems do not (do) force structures
7335 and unions that contain bit-fields to be aligned to the base type of the
7336 bit-field.
7337
7338 For example, by default a structure containing nothing but 8
7339 @code{unsigned} bit-fields of length 1 would be aligned to a 4 byte
7340 boundary and have a size of 4 bytes. By using @option{-mno-bit-align},
7341 the structure would be aligned to a 1 byte boundary and be one byte in
7342 size.
7343
7344 @item -mno-strict-align
7345 @itemx -mstrict-align
7346 @opindex mno-strict-align
7347 @opindex mstrict-align
7348 On System V.4 and embedded PowerPC systems do not (do) assume that
7349 unaligned memory references will be handled by the system.
7350
7351 @item -mrelocatable
7352 @itemx -mno-relocatable
7353 @opindex mrelocatable
7354 @opindex mno-relocatable
7355 On embedded PowerPC systems generate code that allows (does not allow)
7356 the program to be relocated to a different address at runtime. If you
7357 use @option{-mrelocatable} on any module, all objects linked together must
7358 be compiled with @option{-mrelocatable} or @option{-mrelocatable-lib}.
7359
7360 @item -mrelocatable-lib
7361 @itemx -mno-relocatable-lib
7362 @opindex mrelocatable-lib
7363 @opindex mno-relocatable-lib
7364 On embedded PowerPC systems generate code that allows (does not allow)
7365 the program to be relocated to a different address at runtime. Modules
7366 compiled with @option{-mrelocatable-lib} can be linked with either modules
7367 compiled without @option{-mrelocatable} and @option{-mrelocatable-lib} or
7368 with modules compiled with the @option{-mrelocatable} options.
7369
7370 @item -mno-toc
7371 @itemx -mtoc
7372 @opindex mno-toc
7373 @opindex mtoc
7374 On System V.4 and embedded PowerPC systems do not (do) assume that
7375 register 2 contains a pointer to a global area pointing to the addresses
7376 used in the program.
7377
7378 @item -mlittle
7379 @itemx -mlittle-endian
7380 @opindex mlittle
7381 @opindex mlittle-endian
7382 On System V.4 and embedded PowerPC systems compile code for the
7383 processor in little endian mode. The @option{-mlittle-endian} option is
7384 the same as @option{-mlittle}.
7385
7386 @item -mbig
7387 @itemx -mbig-endian
7388 @opindex mbig
7389 @opindex mbig-endian
7390 On System V.4 and embedded PowerPC systems compile code for the
7391 processor in big endian mode. The @option{-mbig-endian} option is
7392 the same as @option{-mbig}.
7393
7394 @item -mdynamic-no-pic
7395 @opindex mdynamic-no-pic
7396 On Darwin and Mac OS X systems, compile code so that it is not
7397 relocatable, but that its external references are relocatable. The
7398 resulting code is suitable for applications, but not shared
7399 libraries.
7400
7401 @item -mprioritize-restricted-insns=@var{priority}
7402 @opindex mprioritize-restricted-insns
7403 This option controls the priority that is assigned to
7404 dispatch-slot restricted instructions during the second scheduling
7405 pass. The argument @var{priority} takes the value @var{0/1/2} to assign
7406 @var{no/highest/second-highest} priority to dispatch slot restricted
7407 instructions.
7408
7409 @item -msched-costly-dep=@var{dependence_type}
7410 @opindex msched-costly-dep
7411 This option controls which dependences are considered costly
7412 by the target during instruction scheduling. The argument
7413 @var{dependence_type} takes one of the following values:
7414 @var{no}: no dependence is costly,
7415 @var{all}: all dependences are costly,
7416 @var{true_store_to_load}: a true dependence from store to load is costly,
7417 @var{store_to_load}: any dependence from store to load is costly,
7418 @var{number}: any dependence which latency >= @var{number} is costly.
7419
7420 @item -minsert-sched-nops=@var{scheme}
7421 @opindex minsert-sched-nops
7422 This option controls which nop insertion scheme will be used during
7423 the second scheduling pass. The argument @var{scheme} takes one of the
7424 following values:
7425 @var{no}: Don't insert nops.
7426 @var{pad}: Pad with nops any dispatch group which has vacant issue slots,
7427 according to the scheduler's grouping.
7428 @var{regroup_exact}: Insert nops to force costly dependent insns into
7429 separate groups. Insert exactly as many nops as needed to force an insn
7430 to a new group, according to the estimated processor grouping.
7431 @var{number}: Insert nops to force costly dependent insns into
7432 separate groups. Insert @var{number} nops to force an insn to a new group.
7433
7434 @item -mcall-sysv
7435 @opindex mcall-sysv
7436 On System V.4 and embedded PowerPC systems compile code using calling
7437 conventions that adheres to the March 1995 draft of the System V
7438 Application Binary Interface, PowerPC processor supplement. This is the
7439 default unless you configured GCC using @samp{powerpc-*-eabiaix}.
7440
7441 @item -mcall-sysv-eabi
7442 @opindex mcall-sysv-eabi
7443 Specify both @option{-mcall-sysv} and @option{-meabi} options.
7444
7445 @item -mcall-sysv-noeabi
7446 @opindex mcall-sysv-noeabi
7447 Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
7448
7449 @item -mcall-solaris
7450 @opindex mcall-solaris
7451 On System V.4 and embedded PowerPC systems compile code for the Solaris
7452 operating system.
7453
7454 @item -mcall-linux
7455 @opindex mcall-linux
7456 On System V.4 and embedded PowerPC systems compile code for the
7457 Linux-based GNU system.
7458
7459 @item -mcall-gnu
7460 @opindex mcall-gnu
7461 On System V.4 and embedded PowerPC systems compile code for the
7462 Hurd-based GNU system.
7463
7464 @item -mcall-netbsd
7465 @opindex mcall-netbsd
7466 On System V.4 and embedded PowerPC systems compile code for the
7467 NetBSD operating system.
7468
7469 @item -maix-struct-return
7470 @opindex maix-struct-return
7471 Return all structures in memory (as specified by the AIX ABI)@.
7472
7473 @item -msvr4-struct-return
7474 @opindex msvr4-struct-return
7475 Return structures smaller than 8 bytes in registers (as specified by the
7476 SVR4 ABI)@.
7477
7478 @item -mabi=altivec
7479 @opindex mabi=altivec
7480 Extend the current ABI with AltiVec ABI extensions. This does not
7481 change the default ABI, instead it adds the AltiVec ABI extensions to
7482 the current ABI@.
7483
7484 @item -mabi=no-altivec
7485 @opindex mabi=no-altivec
7486 Disable AltiVec ABI extensions for the current ABI.
7487
7488 @item -mprototype
7489 @itemx -mno-prototype
7490 @opindex mprototype
7491 @opindex mno-prototype
7492 On System V.4 and embedded PowerPC systems assume that all calls to
7493 variable argument functions are properly prototyped. Otherwise, the
7494 compiler must insert an instruction before every non prototyped call to
7495 set or clear bit 6 of the condition code register (@var{CR}) to
7496 indicate whether floating point values were passed in the floating point
7497 registers in case the function takes a variable arguments. With
7498 @option{-mprototype}, only calls to prototyped variable argument functions
7499 will set or clear the bit.
7500
7501 @item -msim
7502 @opindex msim
7503 On embedded PowerPC systems, assume that the startup module is called
7504 @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
7505 @file{libc.a}. This is the default for @samp{powerpc-*-eabisim}.
7506 configurations.
7507
7508 @item -mmvme
7509 @opindex mmvme
7510 On embedded PowerPC systems, assume that the startup module is called
7511 @file{crt0.o} and the standard C libraries are @file{libmvme.a} and
7512 @file{libc.a}.
7513
7514 @item -mads
7515 @opindex mads
7516 On embedded PowerPC systems, assume that the startup module is called
7517 @file{crt0.o} and the standard C libraries are @file{libads.a} and
7518 @file{libc.a}.
7519
7520 @item -myellowknife
7521 @opindex myellowknife
7522 On embedded PowerPC systems, assume that the startup module is called
7523 @file{crt0.o} and the standard C libraries are @file{libyk.a} and
7524 @file{libc.a}.
7525
7526 @item -mvxworks
7527 @opindex mvxworks
7528 On System V.4 and embedded PowerPC systems, specify that you are
7529 compiling for a VxWorks system.
7530
7531 @item -mwindiss
7532 @opindex mwindiss
7533 Specify that you are compiling for the WindISS simulation environment.
7534
7535 @item -memb
7536 @opindex memb
7537 On embedded PowerPC systems, set the @var{PPC_EMB} bit in the ELF flags
7538 header to indicate that @samp{eabi} extended relocations are used.
7539
7540 @item -meabi
7541 @itemx -mno-eabi
7542 @opindex meabi
7543 @opindex mno-eabi
7544 On System V.4 and embedded PowerPC systems do (do not) adhere to the
7545 Embedded Applications Binary Interface (eabi) which is a set of
7546 modifications to the System V.4 specifications. Selecting @option{-meabi}
7547 means that the stack is aligned to an 8 byte boundary, a function
7548 @code{__eabi} is called to from @code{main} to set up the eabi
7549 environment, and the @option{-msdata} option can use both @code{r2} and
7550 @code{r13} to point to two separate small data areas. Selecting
7551 @option{-mno-eabi} means that the stack is aligned to a 16 byte boundary,
7552 do not call an initialization function from @code{main}, and the
7553 @option{-msdata} option will only use @code{r13} to point to a single
7554 small data area. The @option{-meabi} option is on by default if you
7555 configured GCC using one of the @samp{powerpc*-*-eabi*} options.
7556
7557 @item -msdata=eabi
7558 @opindex msdata=eabi
7559 On System V.4 and embedded PowerPC systems, put small initialized
7560 @code{const} global and static data in the @samp{.sdata2} section, which
7561 is pointed to by register @code{r2}. Put small initialized
7562 non-@code{const} global and static data in the @samp{.sdata} section,
7563 which is pointed to by register @code{r13}. Put small uninitialized
7564 global and static data in the @samp{.sbss} section, which is adjacent to
7565 the @samp{.sdata} section. The @option{-msdata=eabi} option is
7566 incompatible with the @option{-mrelocatable} option. The
7567 @option{-msdata=eabi} option also sets the @option{-memb} option.
7568
7569 @item -msdata=sysv
7570 @opindex msdata=sysv
7571 On System V.4 and embedded PowerPC systems, put small global and static
7572 data in the @samp{.sdata} section, which is pointed to by register
7573 @code{r13}. Put small uninitialized global and static data in the
7574 @samp{.sbss} section, which is adjacent to the @samp{.sdata} section.
7575 The @option{-msdata=sysv} option is incompatible with the
7576 @option{-mrelocatable} option.
7577
7578 @item -msdata=default
7579 @itemx -msdata
7580 @opindex msdata=default
7581 @opindex msdata
7582 On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
7583 compile code the same as @option{-msdata=eabi}, otherwise compile code the
7584 same as @option{-msdata=sysv}.
7585
7586 @item -msdata-data
7587 @opindex msdata-data
7588 On System V.4 and embedded PowerPC systems, put small global and static
7589 data in the @samp{.sdata} section. Put small uninitialized global and
7590 static data in the @samp{.sbss} section. Do not use register @code{r13}
7591 to address small data however. This is the default behavior unless
7592 other @option{-msdata} options are used.
7593
7594 @item -msdata=none
7595 @itemx -mno-sdata
7596 @opindex msdata=none
7597 @opindex mno-sdata
7598 On embedded PowerPC systems, put all initialized global and static data
7599 in the @samp{.data} section, and all uninitialized data in the
7600 @samp{.bss} section.
7601
7602 @item -G @var{num}
7603 @opindex G
7604 @cindex smaller data references (PowerPC)
7605 @cindex .sdata/.sdata2 references (PowerPC)
7606 On embedded PowerPC systems, put global and static items less than or
7607 equal to @var{num} bytes into the small data or bss sections instead of
7608 the normal data or bss section. By default, @var{num} is 8. The
7609 @option{-G @var{num}} switch is also passed to the linker.
7610 All modules should be compiled with the same @option{-G @var{num}} value.
7611
7612 @item -mregnames
7613 @itemx -mno-regnames
7614 @opindex mregnames
7615 @opindex mno-regnames
7616 On System V.4 and embedded PowerPC systems do (do not) emit register
7617 names in the assembly language output using symbolic forms.
7618
7619 @item -mlongcall
7620 @itemx -mno-longcall
7621 @opindex mlongcall
7622 @opindex mno-longcall
7623 Default to making all function calls indirectly, using a register, so
7624 that functions which reside further than 32 megabytes (33,554,432
7625 bytes) from the current location can be called. This setting can be
7626 overridden by the @code{shortcall} function attribute, or by
7627 @code{#pragma longcall(0)}.
7628
7629 Some linkers are capable of detecting out-of-range calls and generating
7630 glue code on the fly. On these systems, long calls are unnecessary and
7631 generate slower code. As of this writing, the AIX linker can do this,
7632 as can the GNU linker for PowerPC/64. It is planned to add this feature
7633 to the GNU linker for 32-bit PowerPC systems as well.
7634
7635 On Darwin/PPC systems, @code{#pragma longcall} will generate ``jbsr
7636 callee, L42'', plus a ``branch island'' (glue code). The two target
7637 addresses represent the callee and the ``branch island.'' The
7638 Darwin/PPC linker will prefer the first address and generate a ``bl
7639 callee'' if the PPC ``bl'' instruction will reach the callee directly;
7640 otherwise, the linker will generate ``bl L42'' to call the ``branch
7641 island.'' The ``branch island'' is appended to the body of the
7642 calling function; it computes the full 32-bit address of the callee
7643 and jumps to it.
7644
7645 On Mach-O (Darwin) systems, this option directs the compiler emit to
7646 the glue for every direct call, and the Darwin linker decides whether
7647 to use or discard it.
7648
7649 In the future, we may cause GCC to ignore all longcall specifications
7650 when the linker is known to generate glue.
7651
7652 @item -pthread
7653 @opindex pthread
7654 Adds support for multithreading with the @dfn{pthreads} library.
7655 This option sets flags for both the preprocessor and linker.
7656
7657 @end table
7658
7659 @node Darwin Options
7660 @subsection Darwin Options
7661 @cindex Darwin options
7662
7663 These options are defined for all architectures running the Darwin operating
7664 system. They are useful for compatibility with other Mac OS compilers.
7665
7666 @table @gcctabopt
7667 @item -F@var{dir}
7668 @opindex F
7669 Add the framework directory @var{dir} to the head of the list of
7670 directories to be searched for header files. These directories are
7671 interleaved with those specified by @option{-I} options and are
7672 scanned in a left-to-right order.
7673
7674 A framework directory is a directory with frameworks in it. A
7675 framework is a directory with a @samp{"Headers"} and/or
7676 @samp{"PrivateHeaders"} directory contained directly in it that ends
7677 in @samp{".framework"}. The name of a framework is the name of this
7678 directory excluding the @samp{".framework"}. Headers associated with
7679 the framework are found in one of those two directories, with
7680 @samp{"Headers"} being searched first. A subframework is a framework
7681 directory that is in a framework's @samp{"Frameworks"} directory.
7682 Includes of subframework headers can only appear in a header of a
7683 framework that contains the subframework, or in a sibling subframework
7684 header. Two subframeworks are siblings if they occur in the same
7685 framework. A subframework should not have the same name as a
7686 framework, a warning will be issued if this is violated. Currently a
7687 subframework cannot have subframeworks, in the future, the mechanism
7688 may be extended to support this. The standard frameworks can be found
7689 in @samp{"/System/Library/Frameworks"}, @samp{"/Library/Frameworks"}
7690 and @samp{"/Local/Library/Frameworks"}. An example include looks like
7691 @code{#include <Framework/header.h>}, where @samp{Framework} denotes
7692 the name of the framework and header.h is found in the
7693 @samp{"PrivateHeaders"} or @samp{"Headers"} directory.
7694
7695 @item -all_load
7696 @opindex all_load
7697 Loads all members of static archive libraries.
7698 See man ld(1) for more information.
7699
7700 @item -arch_errors_fatal
7701 @opindex arch_errors_fatal
7702 Cause the errors having to do with files that have the wrong architecture
7703 to be fatal.
7704
7705 @item -bind_at_load
7706 @opindex bind_at_load
7707 Causes the output file to be marked such that the dynamic linker will
7708 bind all undefined references when the file is loaded or launched.
7709
7710 @item -bundle
7711 @opindex bundle
7712 Produce a Mach-o bundle format file.
7713 See man ld(1) for more information.
7714
7715 @item -bundle_loader @var{executable}
7716 @opindex bundle_loader
7717 This specifies the @var{executable} that will be loading the build
7718 output file being linked. See man ld(1) for more information.
7719
7720 @item -allowable_client @var{client_name}
7721 @itemx -arch_only
7722
7723 @itemx -client_name
7724 @itemx -compatibility_version
7725 @itemx -current_version
7726 @itemx -dependency-file
7727 @itemx -dylib_file
7728 @itemx -dylinker_install_name
7729 @itemx -dynamic
7730 @itemx -dynamiclib
7731 @itemx -exported_symbols_list
7732 @itemx -filelist
7733 @itemx -flat_namespace
7734 @itemx -force_cpusubtype_ALL
7735 @itemx -force_flat_namespace
7736 @itemx -headerpad_max_install_names
7737 @itemx -image_base
7738 @itemx -init
7739 @itemx -install_name
7740 @itemx -keep_private_externs
7741 @itemx -multi_module
7742 @itemx -multiply_defined
7743 @itemx -multiply_defined_unused
7744 @itemx -noall_load
7745 @itemx -nofixprebinding
7746 @itemx -nomultidefs
7747 @itemx -noprebind
7748 @itemx -noseglinkedit
7749 @itemx -pagezero_size
7750 @itemx -prebind
7751 @itemx -prebind_all_twolevel_modules
7752 @itemx -private_bundle
7753 @itemx -read_only_relocs
7754 @itemx -sectalign
7755 @itemx -sectobjectsymbols
7756 @itemx -whyload
7757 @itemx -seg1addr
7758 @itemx -sectcreate
7759 @itemx -sectobjectsymbols
7760 @itemx -sectorder
7761 @itemx -seg_addr_table
7762 @itemx -seg_addr_table_filename
7763 @itemx -seglinkedit
7764 @itemx -segprot
7765 @itemx -segs_read_only_addr
7766 @itemx -segs_read_write_addr
7767 @itemx -single_module
7768 @itemx -static
7769 @itemx -sub_library
7770 @itemx -sub_umbrella
7771 @itemx -twolevel_namespace
7772 @itemx -umbrella
7773 @itemx -undefined
7774 @itemx -unexported_symbols_list
7775 @itemx -weak_reference_mismatches
7776 @itemx -whatsloaded
7777
7778 @opindex allowable_client
7779 @opindex arch_only
7780 @opindex client_name
7781 @opindex compatibility_version
7782 @opindex current_version
7783 @opindex dependency-file
7784 @opindex dylib_file
7785 @opindex dylinker_install_name
7786 @opindex dynamic
7787 @opindex dynamiclib
7788 @opindex exported_symbols_list
7789 @opindex filelist
7790 @opindex flat_namespace
7791 @opindex force_cpusubtype_ALL
7792 @opindex force_flat_namespace
7793 @opindex headerpad_max_install_names
7794 @opindex image_base
7795 @opindex init
7796 @opindex install_name
7797 @opindex keep_private_externs
7798 @opindex multi_module
7799 @opindex multiply_defined
7800 @opindex multiply_defined_unused
7801 @opindex noall_load
7802 @opindex nofixprebinding
7803 @opindex nomultidefs
7804 @opindex noprebind
7805 @opindex noseglinkedit
7806 @opindex pagezero_size
7807 @opindex prebind
7808 @opindex prebind_all_twolevel_modules
7809 @opindex private_bundle
7810 @opindex read_only_relocs
7811 @opindex sectalign
7812 @opindex sectobjectsymbols
7813 @opindex whyload
7814 @opindex seg1addr
7815 @opindex sectcreate
7816 @opindex sectobjectsymbols
7817 @opindex sectorder
7818 @opindex seg_addr_table
7819 @opindex seg_addr_table_filename
7820 @opindex seglinkedit
7821 @opindex segprot
7822 @opindex segs_read_only_addr
7823 @opindex segs_read_write_addr
7824 @opindex single_module
7825 @opindex static
7826 @opindex sub_library
7827 @opindex sub_umbrella
7828 @opindex twolevel_namespace
7829 @opindex umbrella
7830 @opindex undefined
7831 @opindex unexported_symbols_list
7832 @opindex weak_reference_mismatches
7833 @opindex whatsloaded
7834
7835 These options are available for Darwin linker. Darwin linker man page
7836 describes them in detail.
7837 @end table
7838
7839
7840 @node MIPS Options
7841 @subsection MIPS Options
7842 @cindex MIPS options
7843
7844 @table @gcctabopt
7845
7846 @item -EB
7847 @opindex EB
7848 Generate big-endian code.
7849
7850 @item -EL
7851 @opindex EL
7852 Generate little-endian code. This is the default for @samp{mips*el-*-*}
7853 configurations.
7854
7855 @item -march=@var{arch}
7856 @opindex march
7857 Generate code that will run on @var{arch}, which can be the name of a
7858 generic MIPS ISA, or the name of a particular processor.
7859 The ISA names are:
7860 @samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
7861 @samp{mips32}, @samp{mips32r2}, and @samp{mips64}.
7862 The processor names are:
7863 @samp{4kc}, @samp{4kp}, @samp{5kc}, @samp{20kc},
7864 @samp{m4k},
7865 @samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
7866 @samp{r4600}, @samp{r4650}, @samp{r6000}, @samp{r8000}, @samp{rm7000},
7867 @samp{rm9000},
7868 @samp{orion},
7869 @samp{sb1},
7870 @samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
7871 @samp{vr5000}, @samp{vr5400} and @samp{vr5500}.
7872 The special value @samp{from-abi} selects the
7873 most compatible architecture for the selected ABI (that is,
7874 @samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
7875
7876 In processor names, a final @samp{000} can be abbreviated as @samp{k}
7877 (for example, @samp{-march=r2k}). Prefixes are optional, and
7878 @samp{vr} may be written @samp{r}.
7879
7880 GCC defines two macros based on the value of this option. The first
7881 is @samp{_MIPS_ARCH}, which gives the name of target architecture, as
7882 a string. The second has the form @samp{_MIPS_ARCH_@var{foo}},
7883 where @var{foo} is the capitalized value of @samp{_MIPS_ARCH}@.
7884 For example, @samp{-march=r2000} will set @samp{_MIPS_ARCH}
7885 to @samp{"r2000"} and define the macro @samp{_MIPS_ARCH_R2000}.
7886
7887 Note that the @samp{_MIPS_ARCH} macro uses the processor names given
7888 above. In other words, it will have the full prefix and will not
7889 abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
7890 the macro names the resolved architecture (either @samp{"mips1"} or
7891 @samp{"mips3"}). It names the default architecture when no
7892 @option{-march} option is given.
7893
7894 @item -mtune=@var{arch}
7895 @opindex mtune
7896 Optimize for @var{arch}. Among other things, this option controls
7897 the way instructions are scheduled, and the perceived cost of arithmetic
7898 operations. The list of @var{arch} values is the same as for
7899 @option{-march}.
7900
7901 When this option is not used, GCC will optimize for the processor
7902 specified by @option{-march}. By using @option{-march} and
7903 @option{-mtune} together, it is possible to generate code that will
7904 run on a family of processors, but optimize the code for one
7905 particular member of that family.
7906
7907 @samp{-mtune} defines the macros @samp{_MIPS_TUNE} and
7908 @samp{_MIPS_TUNE_@var{foo}}, which work in the same way as the
7909 @samp{-march} ones described above.
7910
7911 @item -mips1
7912 @opindex mips1
7913 Equivalent to @samp{-march=mips1}.
7914
7915 @item -mips2
7916 @opindex mips2
7917 Equivalent to @samp{-march=mips2}.
7918
7919 @item -mips3
7920 @opindex mips3
7921 Equivalent to @samp{-march=mips3}.
7922
7923 @item -mips4
7924 @opindex mips4
7925 Equivalent to @samp{-march=mips4}.
7926
7927 @item -mips32
7928 @opindex mips32
7929 Equivalent to @samp{-march=mips32}.
7930
7931 @item -mips32r2
7932 @opindex mips32r2
7933 Equivalent to @samp{-march=mips32r2}.
7934
7935 @item -mips64
7936 @opindex mips64
7937 Equivalent to @samp{-march=mips64}.
7938
7939 @item -mips16
7940 @itemx -mno-mips16
7941 @opindex mips16
7942 @opindex mno-mips16
7943 Use (do not use) the MIPS16 ISA.
7944
7945 @item -mabi=32
7946 @itemx -mabi=o64
7947 @itemx -mabi=n32
7948 @itemx -mabi=64
7949 @itemx -mabi=eabi
7950 @opindex mabi=32
7951 @opindex mabi=o64
7952 @opindex mabi=n32
7953 @opindex mabi=64
7954 @opindex mabi=eabi
7955 Generate code for the given ABI@.
7956
7957 Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
7958 generates 64-bit code when you select a 64-bit architecture, but you
7959 can use @option{-mgp32} to get 32-bit code instead.
7960
7961 For information about the O64 ABI, see
7962 @w{@uref{http://gcc.gnu.org/projects/mipso64-abi.html}}.
7963
7964 @item -mabicalls
7965 @itemx -mno-abicalls
7966 @opindex mabicalls
7967 @opindex mno-abicalls
7968 Generate (do not generate) SVR4-style position-independent code.
7969 @option{-mabicalls} is the default for SVR4-based systems.
7970
7971 @item -mxgot
7972 @itemx -mno-xgot
7973 @opindex mxgot
7974 @opindex mno-xgot
7975 Lift (do not lift) the usual restrictions on the size of the global
7976 offset table.
7977
7978 GCC normally uses a single instruction to load values from the GOT.
7979 While this is relatively efficient, it will only work if the GOT
7980 is smaller than about 64k. Anything larger will cause the linker
7981 to report an error such as:
7982
7983 @cindex relocation truncated to fit (MIPS)
7984 @smallexample
7985 relocation truncated to fit: R_MIPS_GOT16 foobar
7986 @end smallexample
7987
7988 If this happens, you should recompile your code with @option{-mxgot}.
7989 It should then work with very large GOTs, although it will also be
7990 less efficient, since it will take three instructions to fetch the
7991 value of a global symbol.
7992
7993 Note that some linkers can create multiple GOTs. If you have such a
7994 linker, you should only need to use @option{-mxgot} when a single object
7995 file accesses more than 64k's worth of GOT entries. Very few do.
7996
7997 These options have no effect unless GCC is generating position
7998 independent code.
7999
8000 @item -mgp32
8001 @opindex mgp32
8002 Assume that general-purpose registers are 32 bits wide.
8003
8004 @item -mgp64
8005 @opindex mgp64
8006 Assume that general-purpose registers are 64 bits wide.
8007
8008 @item -mfp32
8009 @opindex mfp32
8010 Assume that floating-point registers are 32 bits wide.
8011
8012 @item -mfp64
8013 @opindex mfp64
8014 Assume that floating-point registers are 64 bits wide.
8015
8016 @item -mhard-float
8017 @opindex mhard-float
8018 Use floating-point coprocessor instructions.
8019
8020 @item -msoft-float
8021 @opindex msoft-float
8022 Do not use floating-point coprocessor instructions. Implement
8023 floating-point calculations using library calls instead.
8024
8025 @item -msingle-float
8026 @opindex msingle-float
8027 Assume that the floating-point coprocessor only supports single-precision
8028 operations.
8029
8030 @itemx -mdouble-float
8031 @opindex mdouble-float
8032 Assume that the floating-point coprocessor supports double-precision
8033 operations. This is the default.
8034
8035 @item -mint64
8036 @opindex mint64
8037 Force @code{int} and @code{long} types to be 64 bits wide. See
8038 @option{-mlong32} for an explanation of the default and the way
8039 that the pointer size is determined.
8040
8041 @item -mlong64
8042 @opindex mlong64
8043 Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
8044 an explanation of the default and the way that the pointer size is
8045 determined.
8046
8047 @item -mlong32
8048 @opindex mlong32
8049 Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
8050
8051 The default size of @code{int}s, @code{long}s and pointers depends on
8052 the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
8053 uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
8054 32-bit @code{long}s. Pointers are the same size as @code{long}s,
8055 or the same size as integer registers, whichever is smaller.
8056
8057 @item -G @var{num}
8058 @opindex G
8059 @cindex smaller data references (MIPS)
8060 @cindex gp-relative references (MIPS)
8061 Put global and static items less than or equal to @var{num} bytes into
8062 the small data or bss section instead of the normal data or bss section.
8063 This allows the data to be accessed using a single instruction.
8064
8065 All modules should be compiled with the same @option{-G @var{num}}
8066 value.
8067
8068 @item -membedded-data
8069 @itemx -mno-embedded-data
8070 @opindex membedded-data
8071 @opindex mno-embedded-data
8072 Allocate variables to the read-only data section first if possible, then
8073 next in the small data section if possible, otherwise in data. This gives
8074 slightly slower code than the default, but reduces the amount of RAM required
8075 when executing, and thus may be preferred for some embedded systems.
8076
8077 @item -muninit-const-in-rodata
8078 @itemx -mno-uninit-const-in-rodata
8079 @opindex muninit-const-in-rodata
8080 @opindex mno-uninit-const-in-rodata
8081 Put uninitialized @code{const} variables in the read-only data section.
8082 This option is only meaningful in conjunction with @option{-membedded-data}.
8083
8084 @item -msplit-addresses
8085 @itemx -mno-split-addresses
8086 @opindex msplit-addresses
8087 @opindex mno-split-addresses
8088 Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
8089 relocation operators. This option has been superceded by
8090 @option{-mexplicit-relocs} but is retained for backwards compatibility.
8091
8092 @item -mexplicit-relocs
8093 @itemx -mno-explicit-relocs
8094 @opindex mexplicit-relocs
8095 @opindex mno-explicit-relocs
8096 Use (do not use) assembler relocation operators when dealing with symbolic
8097 addresses. The alternative, selected by @option{-mno-explicit-relocs},
8098 is to use assembler macros instead.
8099
8100 @option{-mexplicit-relocs} is usually the default if GCC was configured
8101 to use an assembler that supports relocation operators. However, the
8102 combination of @option{-mabicalls} and @option{-fno-unit-at-a-time}
8103 implies @option{-mno-explicit-relocs} unless explicitly overridden.
8104 This is because, when generating abicalls, the choice of relocation
8105 depends on whether a symbol is local or global. In some rare cases,
8106 GCC will not be able to decide this until the whole compilation unit
8107 has been read.
8108
8109 @item -mrnames
8110 @itemx -mno-rnames
8111 @opindex mrnames
8112 @opindex mno-rnames
8113 Generate (do not generate) code that refers to registers using their
8114 software names. The default is @option{-mno-rnames}, which tells GCC
8115 to use hardware names like @samp{$4} instead of software names like
8116 @samp{a0}. The only assembler known to support @option{-rnames} is
8117 the Algorithmics assembler.
8118
8119 @item -mcheck-zero-division
8120 @itemx -mno-check-zero-division
8121 @opindex mcheck-zero-division
8122 @opindex mno-check-zero-division
8123 Trap (do not trap) on integer division by zero. The default is
8124 @option{-mcheck-zero-division}.
8125
8126 @item -mmemcpy
8127 @itemx -mno-memcpy
8128 @opindex mmemcpy
8129 @opindex mno-memcpy
8130 Force (do not force) the use of @code{memcpy()} for non-trivial block
8131 moves. The default is @option{-mno-memcpy}, which allows GCC to inline
8132 most constant-sized copies.
8133
8134 @item -mlong-calls
8135 @itemx -mno-long-calls
8136 @opindex mlong-calls
8137 @opindex mno-long-calls
8138 Disable (do not disable) use of the @code{jal} instruction. Calling
8139 functions using @code{jal} is more efficient but requires the caller
8140 and callee to be in the same 256 megabyte segment.
8141
8142 This option has no effect on abicalls code. The default is
8143 @option{-mno-long-calls}.
8144
8145 @item -mmad
8146 @itemx -mno-mad
8147 @opindex mmad
8148 @opindex mno-mad
8149 Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
8150 instructions, as provided by the R4650 ISA.
8151
8152 @item -mfused-madd
8153 @itemx -mno-fused-madd
8154 @opindex mfused-madd
8155 @opindex mno-fused-madd
8156 Enable (disable) use of the floating point multiply-accumulate
8157 instructions, when they are available. The default is
8158 @option{-mfused-madd}.
8159
8160 When multiply-accumulate instructions are used, the intermediate
8161 product is calculated to infinite precision and is not subject to
8162 the FCSR Flush to Zero bit. This may be undesirable in some
8163 circumstances.
8164
8165 @item -nocpp
8166 @opindex nocpp
8167 Tell the MIPS assembler to not run its preprocessor over user
8168 assembler files (with a @samp{.s} suffix) when assembling them.
8169
8170 @item -mfix-r4000
8171 @itemx -mno-fix-r4000
8172 @opindex mfix-r4000
8173 @opindex mno-fix-r4000
8174 Work around certain R4000 CPU errata:
8175 @itemize @minus
8176 @item
8177 A double-word or a variable shift may give an incorrect result if executed
8178 immediately after starting an integer division.
8179 @item
8180 A double-word or a variable shift may give an incorrect result if executed
8181 while an integer multiplication is in progress.
8182 @item
8183 An integer division may give an incorrect result if started in a delay slot
8184 of a taken branch or a jump.
8185 @end itemize
8186
8187 @item -mfix-r4400
8188 @itemx -mno-fix-r4400
8189 @opindex mfix-r4400
8190 @opindex mno-fix-r4400
8191 Work around certain R4400 CPU errata:
8192 @itemize @minus
8193 @item
8194 A double-word or a variable shift may give an incorrect result if executed
8195 immediately after starting an integer division.
8196 @end itemize
8197
8198 @item -mfix-vr4120
8199 @itemx -mno-fix-vr4120
8200 @opindex mfix-vr4120
8201 Work around certain VR4120 errata:
8202 @itemize @minus
8203 @item
8204 @code{dmultu} does not always produce the correct result.
8205 @item
8206 @code{div} and @code{ddiv} do not always produce the correct result if one
8207 of the operands is negative.
8208 @end itemize
8209 The workarounds for the division errata rely on special functions in
8210 @file{libgcc.a}. At present, these functions are only provided by
8211 the @code{mips64vr*-elf} configurations.
8212
8213 Other VR4120 errata require a nop to be inserted between certain pairs of
8214 instructions. These errata are handled by the assembler, not by GCC itself.
8215
8216 @item -mfix-sb1
8217 @itemx -mno-fix-sb1
8218 @opindex mfix-sb1
8219 Work around certain SB-1 CPU core errata.
8220 (This flag currently works around the SB-1 revision 2
8221 ``F1'' and ``F2'' floating point errata.)
8222
8223 @item -mflush-func=@var{func}
8224 @itemx -mno-flush-func
8225 @opindex mflush-func
8226 Specifies the function to call to flush the I and D caches, or to not
8227 call any such function. If called, the function must take the same
8228 arguments as the common @code{_flush_func()}, that is, the address of the
8229 memory range for which the cache is being flushed, the size of the
8230 memory range, and the number 3 (to flush both caches). The default
8231 depends on the target GCC was configured for, but commonly is either
8232 @samp{_flush_func} or @samp{__cpu_flush}.
8233
8234 @item -mbranch-likely
8235 @itemx -mno-branch-likely
8236 @opindex mbranch-likely
8237 @opindex mno-branch-likely
8238 Enable or disable use of Branch Likely instructions, regardless of the
8239 default for the selected architecture. By default, Branch Likely
8240 instructions may be generated if they are supported by the selected
8241 architecture. An exception is for the MIPS32 and MIPS64 architectures
8242 and processors which implement those architectures; for those, Branch
8243 Likely instructions will not be generated by default because the MIPS32
8244 and MIPS64 architectures specifically deprecate their use.
8245
8246 @item -mfp-exceptions
8247 @itemx -mno-fp-exceptions
8248 @opindex mfp-exceptions
8249 Specifies whether FP exceptions are enabled. This affects how we schedule
8250 FP instructions for some processors. The default is that FP exceptions are
8251 enabled.
8252
8253 For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
8254 64-bit code, then we can use both FP pipes. Otherwise, we can only use one
8255 FP pipe.
8256
8257 @item -mvr4130-align
8258 @itemx -mno-vr4130-align
8259 @opindex mvr4130-align
8260 The VR4130 pipeline is two-way superscalar, but can only issue two
8261 instructions together if the first one is 8-byte aligned. When this
8262 option is enabled, GCC will align pairs of instructions that it
8263 thinks should execute in parallel.
8264
8265 This option only has an effect when optimizing for the VR4130.
8266 It normally makes code faster, but at the expense of making it bigger.
8267 It is enabled by default at optimization level @option{-O3}.
8268 @end table
8269
8270 @node i386 and x86-64 Options
8271 @subsection Intel 386 and AMD x86-64 Options
8272 @cindex i386 Options
8273 @cindex x86-64 Options
8274 @cindex Intel 386 Options
8275 @cindex AMD x86-64 Options
8276
8277 These @samp{-m} options are defined for the i386 and x86-64 family of
8278 computers:
8279
8280 @table @gcctabopt
8281 @item -mtune=@var{cpu-type}
8282 @opindex mtune
8283 Tune to @var{cpu-type} everything applicable about the generated code, except
8284 for the ABI and the set of available instructions. The choices for
8285 @var{cpu-type} are:
8286 @table @emph
8287 @item i386
8288 Original Intel's i386 CPU.
8289 @item i486
8290 Intel's i486 CPU. (No scheduling is implemented for this chip.)
8291 @item i586, pentium
8292 Intel Pentium CPU with no MMX support.
8293 @item pentium-mmx
8294 Intel PentiumMMX CPU based on Pentium core with MMX instruction set support.
8295 @item i686, pentiumpro
8296 Intel PentiumPro CPU.
8297 @item pentium2
8298 Intel Pentium2 CPU based on PentiumPro core with MMX instruction set support.
8299 @item pentium3, pentium3m
8300 Intel Pentium3 CPU based on PentiumPro core with MMX and SSE instruction set
8301 support.
8302 @item pentium-m
8303 Low power version of Intel Pentium3 CPU with MMX, SSE and SSE2 instruction set
8304 support. Used by Centrino notebooks.
8305 @item pentium4, pentium4m
8306 Intel Pentium4 CPU with MMX, SSE and SSE2 instruction set support.
8307 @item prescott
8308 Improved version of Intel Pentium4 CPU with MMX, SSE, SSE2 and SSE3 instruction
8309 set support.
8310 @item nocona
8311 Improved version of Intel Pentium4 CPU with 64-bit extensions, MMX, SSE,
8312 SSE2 and SSE3 instruction set support.
8313 @item k6
8314 AMD K6 CPU with MMX instruction set support.
8315 @item k6-2, k6-3
8316 Improved versions of AMD K6 CPU with MMX and 3dNOW! instruction set support.
8317 @item athlon, athlon-tbird
8318 AMD Athlon CPU with MMX, 3dNOW!, enhanced 3dNOW! and SSE prefetch instructions
8319 support.
8320 @item athlon-4, athlon-xp, athlon-mp
8321 Improved AMD Athlon CPU with MMX, 3dNOW!, enhanced 3dNOW! and full SSE
8322 instruction set support.
8323 @item k8, opteron, athlon64, athlon-fx
8324 AMD K8 core based CPUs with x86-64 instruction set support. (This supersets
8325 MMX, SSE, SSE2, 3dNOW!, enhanced 3dNOW! and 64-bit instruction set extensions.)
8326 @item winchip-c6
8327 IDT Winchip C6 CPU, dealt in same way as i486 with additional MMX instruction
8328 set support.
8329 @item winchip2
8330 IDT Winchip2 CPU, dealt in same way as i486 with additional MMX and 3dNOW!
8331 instruction set support.
8332 @item c3
8333 Via C3 CPU with MMX and 3dNOW! instruction set support. (No scheduling is
8334 implemented for this chip.)
8335 @item c3-2
8336 Via C3-2 CPU with MMX and SSE instruction set support. (No scheduling is
8337 implemented for this chip.)
8338 @end table
8339
8340 While picking a specific @var{cpu-type} will schedule things appropriately
8341 for that particular chip, the compiler will not generate any code that
8342 does not run on the i386 without the @option{-march=@var{cpu-type}} option
8343 being used.
8344
8345 @item -march=@var{cpu-type}
8346 @opindex march
8347 Generate instructions for the machine type @var{cpu-type}. The choices
8348 for @var{cpu-type} are the same as for @option{-mtune}. Moreover,
8349 specifying @option{-march=@var{cpu-type}} implies @option{-mtune=@var{cpu-type}}.
8350
8351 @item -mcpu=@var{cpu-type}
8352 @opindex mcpu
8353 A deprecated synonym for @option{-mtune}.
8354
8355 @item -m386
8356 @itemx -m486
8357 @itemx -mpentium
8358 @itemx -mpentiumpro
8359 @opindex m386
8360 @opindex m486
8361 @opindex mpentium
8362 @opindex mpentiumpro
8363 These options are synonyms for @option{-mtune=i386}, @option{-mtune=i486},
8364 @option{-mtune=pentium}, and @option{-mtune=pentiumpro} respectively.
8365 These synonyms are deprecated.
8366
8367 @item -mfpmath=@var{unit}
8368 @opindex march
8369 Generate floating point arithmetics for selected unit @var{unit}. The choices
8370 for @var{unit} are:
8371
8372 @table @samp
8373 @item 387
8374 Use the standard 387 floating point coprocessor present majority of chips and
8375 emulated otherwise. Code compiled with this option will run almost everywhere.
8376 The temporary results are computed in 80bit precision instead of precision
8377 specified by the type resulting in slightly different results compared to most
8378 of other chips. See @option{-ffloat-store} for more detailed description.
8379
8380 This is the default choice for i386 compiler.
8381
8382 @item sse
8383 Use scalar floating point instructions present in the SSE instruction set.
8384 This instruction set is supported by Pentium3 and newer chips, in the AMD line
8385 by Athlon-4, Athlon-xp and Athlon-mp chips. The earlier version of SSE
8386 instruction set supports only single precision arithmetics, thus the double and
8387 extended precision arithmetics is still done using 387. Later version, present
8388 only in Pentium4 and the future AMD x86-64 chips supports double precision
8389 arithmetics too.
8390
8391 For i387 you need to use @option{-march=@var{cpu-type}}, @option{-msse} or
8392 @option{-msse2} switches to enable SSE extensions and make this option
8393 effective. For x86-64 compiler, these extensions are enabled by default.
8394
8395 The resulting code should be considerably faster in the majority of cases and avoid
8396 the numerical instability problems of 387 code, but may break some existing
8397 code that expects temporaries to be 80bit.
8398
8399 This is the default choice for the x86-64 compiler.
8400
8401 @item sse,387
8402 Attempt to utilize both instruction sets at once. This effectively double the
8403 amount of available registers and on chips with separate execution units for
8404 387 and SSE the execution resources too. Use this option with care, as it is
8405 still experimental, because the GCC register allocator does not model separate
8406 functional units well resulting in instable performance.
8407 @end table
8408
8409 @item -masm=@var{dialect}
8410 @opindex masm=@var{dialect}
8411 Output asm instructions using selected @var{dialect}. Supported choices are
8412 @samp{intel} or @samp{att} (the default one).
8413
8414 @item -mieee-fp
8415 @itemx -mno-ieee-fp
8416 @opindex mieee-fp
8417 @opindex mno-ieee-fp
8418 Control whether or not the compiler uses IEEE floating point
8419 comparisons. These handle correctly the case where the result of a
8420 comparison is unordered.
8421
8422 @item -msoft-float
8423 @opindex msoft-float
8424 Generate output containing library calls for floating point.
8425 @strong{Warning:} the requisite libraries are not part of GCC@.
8426 Normally the facilities of the machine's usual C compiler are used, but
8427 this can't be done directly in cross-compilation. You must make your
8428 own arrangements to provide suitable library functions for
8429 cross-compilation.
8430
8431 On machines where a function returns floating point results in the 80387
8432 register stack, some floating point opcodes may be emitted even if
8433 @option{-msoft-float} is used.
8434
8435 @item -mno-fp-ret-in-387
8436 @opindex mno-fp-ret-in-387
8437 Do not use the FPU registers for return values of functions.
8438
8439 The usual calling convention has functions return values of types
8440 @code{float} and @code{double} in an FPU register, even if there
8441 is no FPU@. The idea is that the operating system should emulate
8442 an FPU@.
8443
8444 The option @option{-mno-fp-ret-in-387} causes such values to be returned
8445 in ordinary CPU registers instead.
8446
8447 @item -mno-fancy-math-387
8448 @opindex mno-fancy-math-387
8449 Some 387 emulators do not support the @code{sin}, @code{cos} and
8450 @code{sqrt} instructions for the 387. Specify this option to avoid
8451 generating those instructions. This option is the default on FreeBSD,
8452 OpenBSD and NetBSD@. This option is overridden when @option{-march}
8453 indicates that the target cpu will always have an FPU and so the
8454 instruction will not need emulation. As of revision 2.6.1, these
8455 instructions are not generated unless you also use the
8456 @option{-funsafe-math-optimizations} switch.
8457
8458 @item -malign-double
8459 @itemx -mno-align-double
8460 @opindex malign-double
8461 @opindex mno-align-double
8462 Control whether GCC aligns @code{double}, @code{long double}, and
8463 @code{long long} variables on a two word boundary or a one word
8464 boundary. Aligning @code{double} variables on a two word boundary will
8465 produce code that runs somewhat faster on a @samp{Pentium} at the
8466 expense of more memory.
8467
8468 @strong{Warning:} if you use the @option{-malign-double} switch,
8469 structures containing the above types will be aligned differently than
8470 the published application binary interface specifications for the 386
8471 and will not be binary compatible with structures in code compiled
8472 without that switch.
8473
8474 @item -m96bit-long-double
8475 @itemx -m128bit-long-double
8476 @opindex m96bit-long-double
8477 @opindex m128bit-long-double
8478 These switches control the size of @code{long double} type. The i386
8479 application binary interface specifies the size to be 96 bits,
8480 so @option{-m96bit-long-double} is the default in 32 bit mode.
8481
8482 Modern architectures (Pentium and newer) would prefer @code{long double}
8483 to be aligned to an 8 or 16 byte boundary. In arrays or structures
8484 conforming to the ABI, this would not be possible. So specifying a
8485 @option{-m128bit-long-double} will align @code{long double}
8486 to a 16 byte boundary by padding the @code{long double} with an additional
8487 32 bit zero.
8488
8489 In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
8490 its ABI specifies that @code{long double} is to be aligned on 16 byte boundary.
8491
8492 Notice that neither of these options enable any extra precision over the x87
8493 standard of 80 bits for a @code{long double}.
8494
8495 @strong{Warning:} if you override the default value for your target ABI, the
8496 structures and arrays containing @code{long double} variables will change
8497 their size as well as function calling convention for function taking
8498 @code{long double} will be modified. Hence they will not be binary
8499 compatible with arrays or structures in code compiled without that switch.
8500
8501
8502 @item -msvr3-shlib
8503 @itemx -mno-svr3-shlib
8504 @opindex msvr3-shlib
8505 @opindex mno-svr3-shlib
8506 Control whether GCC places uninitialized local variables into the
8507 @code{bss} or @code{data} segments. @option{-msvr3-shlib} places them
8508 into @code{bss}. These options are meaningful only on System V Release 3.
8509
8510 @item -mrtd
8511 @opindex mrtd
8512 Use a different function-calling convention, in which functions that
8513 take a fixed number of arguments return with the @code{ret} @var{num}
8514 instruction, which pops their arguments while returning. This saves one
8515 instruction in the caller since there is no need to pop the arguments
8516 there.
8517
8518 You can specify that an individual function is called with this calling
8519 sequence with the function attribute @samp{stdcall}. You can also
8520 override the @option{-mrtd} option by using the function attribute
8521 @samp{cdecl}. @xref{Function Attributes}.
8522
8523 @strong{Warning:} this calling convention is incompatible with the one
8524 normally used on Unix, so you cannot use it if you need to call
8525 libraries compiled with the Unix compiler.
8526
8527 Also, you must provide function prototypes for all functions that
8528 take variable numbers of arguments (including @code{printf});
8529 otherwise incorrect code will be generated for calls to those
8530 functions.
8531
8532 In addition, seriously incorrect code will result if you call a
8533 function with too many arguments. (Normally, extra arguments are
8534 harmlessly ignored.)
8535
8536 @item -mregparm=@var{num}
8537 @opindex mregparm
8538 Control how many registers are used to pass integer arguments. By
8539 default, no registers are used to pass arguments, and at most 3
8540 registers can be used. You can control this behavior for a specific
8541 function by using the function attribute @samp{regparm}.
8542 @xref{Function Attributes}.
8543
8544 @strong{Warning:} if you use this switch, and
8545 @var{num} is nonzero, then you must build all modules with the same
8546 value, including any libraries. This includes the system libraries and
8547 startup modules.
8548
8549 @item -mpreferred-stack-boundary=@var{num}
8550 @opindex mpreferred-stack-boundary
8551 Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
8552 byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
8553 the default is 4 (16 bytes or 128 bits), except when optimizing for code
8554 size (@option{-Os}), in which case the default is the minimum correct
8555 alignment (4 bytes for x86, and 8 bytes for x86-64).
8556
8557 On Pentium and PentiumPro, @code{double} and @code{long double} values
8558 should be aligned to an 8 byte boundary (see @option{-malign-double}) or
8559 suffer significant run time performance penalties. On Pentium III, the
8560 Streaming SIMD Extension (SSE) data type @code{__m128} suffers similar
8561 penalties if it is not 16 byte aligned.
8562
8563 To ensure proper alignment of this values on the stack, the stack boundary
8564 must be as aligned as that required by any value stored on the stack.
8565 Further, every function must be generated such that it keeps the stack
8566 aligned. Thus calling a function compiled with a higher preferred
8567 stack boundary from a function compiled with a lower preferred stack
8568 boundary will most likely misalign the stack. It is recommended that
8569 libraries that use callbacks always use the default setting.
8570
8571 This extra alignment does consume extra stack space, and generally
8572 increases code size. Code that is sensitive to stack space usage, such
8573 as embedded systems and operating system kernels, may want to reduce the
8574 preferred alignment to @option{-mpreferred-stack-boundary=2}.
8575
8576 @item -mmmx
8577 @itemx -mno-mmx
8578 @item -msse
8579 @itemx -mno-sse
8580 @item -msse2
8581 @itemx -mno-sse2
8582 @item -msse3
8583 @itemx -mno-sse3
8584 @item -m3dnow
8585 @itemx -mno-3dnow
8586 @opindex mmmx
8587 @opindex mno-mmx
8588 @opindex msse
8589 @opindex mno-sse
8590 @opindex m3dnow
8591 @opindex mno-3dnow
8592 These switches enable or disable the use of built-in functions that allow
8593 direct access to the MMX, SSE, SSE2, SSE3 and 3Dnow extensions of the
8594 instruction set.
8595
8596 @xref{X86 Built-in Functions}, for details of the functions enabled
8597 and disabled by these switches.
8598
8599 To have SSE/SSE2 instructions generated automatically from floating-point
8600 code, see @option{-mfpmath=sse}.
8601
8602 @item -mpush-args
8603 @itemx -mno-push-args
8604 @opindex mpush-args
8605 @opindex mno-push-args
8606 Use PUSH operations to store outgoing parameters. This method is shorter
8607 and usually equally fast as method using SUB/MOV operations and is enabled
8608 by default. In some cases disabling it may improve performance because of
8609 improved scheduling and reduced dependencies.
8610
8611 @item -maccumulate-outgoing-args
8612 @opindex maccumulate-outgoing-args
8613 If enabled, the maximum amount of space required for outgoing arguments will be
8614 computed in the function prologue. This is faster on most modern CPUs
8615 because of reduced dependencies, improved scheduling and reduced stack usage
8616 when preferred stack boundary is not equal to 2. The drawback is a notable
8617 increase in code size. This switch implies @option{-mno-push-args}.
8618
8619 @item -mthreads
8620 @opindex mthreads
8621 Support thread-safe exception handling on @samp{Mingw32}. Code that relies
8622 on thread-safe exception handling must compile and link all code with the
8623 @option{-mthreads} option. When compiling, @option{-mthreads} defines
8624 @option{-D_MT}; when linking, it links in a special thread helper library
8625 @option{-lmingwthrd} which cleans up per thread exception handling data.
8626
8627 @item -mno-align-stringops
8628 @opindex mno-align-stringops
8629 Do not align destination of inlined string operations. This switch reduces
8630 code size and improves performance in case the destination is already aligned,
8631 but GCC doesn't know about it.
8632
8633 @item -minline-all-stringops
8634 @opindex minline-all-stringops
8635 By default GCC inlines string operations only when destination is known to be
8636 aligned at least to 4 byte boundary. This enables more inlining, increase code
8637 size, but may improve performance of code that depends on fast memcpy, strlen
8638 and memset for short lengths.
8639
8640 @item -momit-leaf-frame-pointer
8641 @opindex momit-leaf-frame-pointer
8642 Don't keep the frame pointer in a register for leaf functions. This
8643 avoids the instructions to save, set up and restore frame pointers and
8644 makes an extra register available in leaf functions. The option
8645 @option{-fomit-frame-pointer} removes the frame pointer for all functions
8646 which might make debugging harder.
8647
8648 @item -mtls-direct-seg-refs
8649 @itemx -mno-tls-direct-seg-refs
8650 @opindex mtls-direct-seg-refs
8651 Controls whether TLS variables may be accessed with offsets from the
8652 TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
8653 or whether the thread base pointer must be added. Whether or not this
8654 is legal depends on the operating system, and whether it maps the
8655 segment to cover the entire TLS area.
8656
8657 For systems that use GNU libc, the default is on.
8658 @end table
8659
8660 These @samp{-m} switches are supported in addition to the above
8661 on AMD x86-64 processors in 64-bit environments.
8662
8663 @table @gcctabopt
8664 @item -m32
8665 @itemx -m64
8666 @opindex m32
8667 @opindex m64
8668 Generate code for a 32-bit or 64-bit environment.
8669 The 32-bit environment sets int, long and pointer to 32 bits and
8670 generates code that runs on any i386 system.
8671 The 64-bit environment sets int to 32 bits and long and pointer
8672 to 64 bits and generates code for AMD's x86-64 architecture.
8673
8674 @item -mno-red-zone
8675 @opindex no-red-zone
8676 Do not use a so called red zone for x86-64 code. The red zone is mandated
8677 by the x86-64 ABI, it is a 128-byte area beyond the location of the
8678 stack pointer that will not be modified by signal or interrupt handlers
8679 and therefore can be used for temporary data without adjusting the stack
8680 pointer. The flag @option{-mno-red-zone} disables this red zone.
8681
8682 @item -mcmodel=small
8683 @opindex mcmodel=small
8684 Generate code for the small code model: the program and its symbols must
8685 be linked in the lower 2 GB of the address space. Pointers are 64 bits.
8686 Programs can be statically or dynamically linked. This is the default
8687 code model.
8688
8689 @item -mcmodel=kernel
8690 @opindex mcmodel=kernel
8691 Generate code for the kernel code model. The kernel runs in the
8692 negative 2 GB of the address space.
8693 This model has to be used for Linux kernel code.
8694
8695 @item -mcmodel=medium
8696 @opindex mcmodel=medium
8697 Generate code for the medium model: The program is linked in the lower 2
8698 GB of the address space but symbols can be located anywhere in the
8699 address space. Programs can be statically or dynamically linked, but
8700 building of shared libraries are not supported with the medium model.
8701
8702 @item -mcmodel=large
8703 @opindex mcmodel=large
8704 Generate code for the large model: This model makes no assumptions
8705 about addresses and sizes of sections. Currently GCC does not implement
8706 this model.
8707 @end table
8708
8709 @node HPPA Options
8710 @subsection HPPA Options
8711 @cindex HPPA Options
8712
8713 These @samp{-m} options are defined for the HPPA family of computers:
8714
8715 @table @gcctabopt
8716 @item -march=@var{architecture-type}
8717 @opindex march
8718 Generate code for the specified architecture. The choices for
8719 @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
8720 1.1, and @samp{2.0} for PA 2.0 processors. Refer to
8721 @file{/usr/lib/sched.models} on an HP-UX system to determine the proper
8722 architecture option for your machine. Code compiled for lower numbered
8723 architectures will run on higher numbered architectures, but not the
8724 other way around.
8725
8726 PA 2.0 support currently requires gas snapshot 19990413 or later. The
8727 next release of binutils (current is 2.9.1) will probably contain PA 2.0
8728 support.
8729
8730 @item -mpa-risc-1-0
8731 @itemx -mpa-risc-1-1
8732 @itemx -mpa-risc-2-0
8733 @opindex mpa-risc-1-0
8734 @opindex mpa-risc-1-1
8735 @opindex mpa-risc-2-0
8736 Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
8737
8738 @item -mbig-switch
8739 @opindex mbig-switch
8740 Generate code suitable for big switch tables. Use this option only if
8741 the assembler/linker complain about out of range branches within a switch
8742 table.
8743
8744 @item -mjump-in-delay
8745 @opindex mjump-in-delay
8746 Fill delay slots of function calls with unconditional jump instructions
8747 by modifying the return pointer for the function call to be the target
8748 of the conditional jump.
8749
8750 @item -mdisable-fpregs
8751 @opindex mdisable-fpregs
8752 Prevent floating point registers from being used in any manner. This is
8753 necessary for compiling kernels which perform lazy context switching of
8754 floating point registers. If you use this option and attempt to perform
8755 floating point operations, the compiler will abort.
8756
8757 @item -mdisable-indexing
8758 @opindex mdisable-indexing
8759 Prevent the compiler from using indexing address modes. This avoids some
8760 rather obscure problems when compiling MIG generated code under MACH@.
8761
8762 @item -mno-space-regs
8763 @opindex mno-space-regs
8764 Generate code that assumes the target has no space registers. This allows
8765 GCC to generate faster indirect calls and use unscaled index address modes.
8766
8767 Such code is suitable for level 0 PA systems and kernels.
8768
8769 @item -mfast-indirect-calls
8770 @opindex mfast-indirect-calls
8771 Generate code that assumes calls never cross space boundaries. This
8772 allows GCC to emit code which performs faster indirect calls.
8773
8774 This option will not work in the presence of shared libraries or nested
8775 functions.
8776
8777 @item -mlong-load-store
8778 @opindex mlong-load-store
8779 Generate 3-instruction load and store sequences as sometimes required by
8780 the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
8781 the HP compilers.
8782
8783 @item -mportable-runtime
8784 @opindex mportable-runtime
8785 Use the portable calling conventions proposed by HP for ELF systems.
8786
8787 @item -mgas
8788 @opindex mgas
8789 Enable the use of assembler directives only GAS understands.
8790
8791 @item -mschedule=@var{cpu-type}
8792 @opindex mschedule
8793 Schedule code according to the constraints for the machine type
8794 @var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
8795 @samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
8796 to @file{/usr/lib/sched.models} on an HP-UX system to determine the
8797 proper scheduling option for your machine. The default scheduling is
8798 @samp{8000}.
8799
8800 @item -mlinker-opt
8801 @opindex mlinker-opt
8802 Enable the optimization pass in the HP-UX linker. Note this makes symbolic
8803 debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
8804 linkers in which they give bogus error messages when linking some programs.
8805
8806 @item -msoft-float
8807 @opindex msoft-float
8808 Generate output containing library calls for floating point.
8809 @strong{Warning:} the requisite libraries are not available for all HPPA
8810 targets. Normally the facilities of the machine's usual C compiler are
8811 used, but this cannot be done directly in cross-compilation. You must make
8812 your own arrangements to provide suitable library functions for
8813 cross-compilation. The embedded target @samp{hppa1.1-*-pro}
8814 does provide software floating point support.
8815
8816 @option{-msoft-float} changes the calling convention in the output file;
8817 therefore, it is only useful if you compile @emph{all} of a program with
8818 this option. In particular, you need to compile @file{libgcc.a}, the
8819 library that comes with GCC, with @option{-msoft-float} in order for
8820 this to work.
8821
8822 @item -msio
8823 @opindex msio
8824 Generate the predefine, @code{_SIO}, for server IO. The default is
8825 @option{-mwsio}. This generates the predefines, @code{__hp9000s700},
8826 @code{__hp9000s700__} and @code{_WSIO}, for workstation IO. These
8827 options are available under HP-UX and HI-UX.
8828
8829 @item -mgnu-ld
8830 @opindex gnu-ld
8831 Use GNU ld specific options. This passes @option{-shared} to ld when
8832 building a shared library. It is the default when GCC is configured,
8833 explicitly or implicitly, with the GNU linker. This option does not
8834 have any affect on which ld is called, it only changes what parameters
8835 are passed to that ld. The ld that is called is determined by the
8836 @option{--with-ld} configure option, GCC's program search path, and
8837 finally by the user's @env{PATH}. The linker used by GCC can be printed
8838 using @samp{which `gcc -print-prog-name=ld`}.
8839
8840 @item -mhp-ld
8841 @opindex hp-ld
8842 Use HP ld specific options. This passes @option{-b} to ld when building
8843 a shared library and passes @option{+Accept TypeMismatch} to ld on all
8844 links. It is the default when GCC is configured, explicitly or
8845 implicitly, with the HP linker. This option does not have any affect on
8846 which ld is called, it only changes what parameters are passed to that
8847 ld. The ld that is called is determined by the @option{--with-ld}
8848 configure option, GCC's program search path, and finally by the user's
8849 @env{PATH}. The linker used by GCC can be printed using @samp{which
8850 `gcc -print-prog-name=ld`}.
8851
8852 @item -mfdpic
8853 @opindex mfdpic
8854
8855 Select the FDPIC ABI, that uses function descriptors to represent
8856 pointers to functions. Without any PIC/PIE-related options, it
8857 implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
8858 assumes GOT entries and small data are within a 12-bit range from the
8859 GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
8860 are computed with 32 bits.
8861
8862 @item -minline-plt
8863 @opindex minline-plt
8864
8865 Enable inlining of PLT entries in function calls to functions that are
8866 not known to bind locally. It has no effect without @option{-mfdpic}.
8867 It's enabled by default if optimizing for speed and compiling for
8868 shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
8869 optimization option such as @option{-O3} or above is present in the
8870 command line.
8871
8872 @item -mgprel-ro
8873 @opindex mgprel-ro
8874
8875 Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
8876 that is known to be in read-only sections. It's enabled by default,
8877 except for @option{-fpic} or @option{-fpie}: even though it may help
8878 make the global offset table smaller, it trades 1 instruction for 4.
8879 With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
8880 one of which may be shared by multiple symbols, and it avoids the need
8881 for a GOT entry for the referenced symbol, so it's more likely to be a
8882 win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
8883
8884 @item -multilib-library-pic
8885 @opindex multilib-library-pic
8886
8887 Link with the (library, not FD) pic libraries. It's implied by
8888 @option{-mlibrary-pic}, as well as by @option{-fPIC} and
8889 @option{-fpic} without @option{-mfdpic}. You should never have to use
8890 it explicitly.
8891
8892 @item -mlinked-fp
8893 @opindex mlinked-fp
8894
8895 Follow the EABI requirement of always creating a frame pointer whenever
8896 a stack frame is allocated. This option is enabled by default and can
8897 be disabled with @option{-mno-linked-fp}.
8898
8899 @item -mlong-calls
8900 @opindex mno-long-calls
8901 Generate code that uses long call sequences. This ensures that a call
8902 is always able to reach linker generated stubs. The default is to generate
8903 long calls only when the distance from the call site to the beginning
8904 of the function or translation unit, as the case may be, exceeds a
8905 predefined limit set by the branch type being used. The limits for
8906 normal calls are 7,600,000 and 240,000 bytes, respectively for the
8907 PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
8908 240,000 bytes.
8909
8910 Distances are measured from the beginning of functions when using the
8911 @option{-ffunction-sections} option, or when using the @option{-mgas}
8912 and @option{-mno-portable-runtime} options together under HP-UX with
8913 the SOM linker.
8914
8915 It is normally not desirable to use this option as it will degrade
8916 performance. However, it may be useful in large applications,
8917 particularly when partial linking is used to build the application.
8918
8919 The types of long calls used depends on the capabilities of the
8920 assembler and linker, and the type of code being generated. The
8921 impact on systems that support long absolute calls, and long pic
8922 symbol-difference or pc-relative calls should be relatively small.
8923 However, an indirect call is used on 32-bit ELF systems in pic code
8924 and it is quite long.
8925
8926 @item -nolibdld
8927 @opindex nolibdld
8928 Suppress the generation of link options to search libdld.sl when the
8929 @option{-static} option is specified on HP-UX 10 and later.
8930
8931 @item -static
8932 @opindex static
8933 The HP-UX implementation of setlocale in libc has a dependency on
8934 libdld.sl. There isn't an archive version of libdld.sl. Thus,
8935 when the @option{-static} option is specified, special link options
8936 are needed to resolve this dependency.
8937
8938 On HP-UX 10 and later, the GCC driver adds the necessary options to
8939 link with libdld.sl when the @option{-static} option is specified.
8940 This causes the resulting binary to be dynamic. On the 64-bit port,
8941 the linkers generate dynamic binaries by default in any case. The
8942 @option{-nolibdld} option can be used to prevent the GCC driver from
8943 adding these link options.
8944
8945 @item -threads
8946 @opindex threads
8947 Add support for multithreading with the @dfn{dce thread} library
8948 under HP-UX. This option sets flags for both the preprocessor and
8949 linker.
8950 @end table
8951
8952 @node DEC Alpha Options
8953 @subsection DEC Alpha Options
8954
8955 These @samp{-m} options are defined for the DEC Alpha implementations:
8956
8957 @table @gcctabopt
8958 @item -mno-soft-float
8959 @itemx -msoft-float
8960 @opindex mno-soft-float
8961 @opindex msoft-float
8962 Use (do not use) the hardware floating-point instructions for
8963 floating-point operations. When @option{-msoft-float} is specified,
8964 functions in @file{libgcc.a} will be used to perform floating-point
8965 operations. Unless they are replaced by routines that emulate the
8966 floating-point operations, or compiled in such a way as to call such
8967 emulations routines, these routines will issue floating-point
8968 operations. If you are compiling for an Alpha without floating-point
8969 operations, you must ensure that the library is built so as not to call
8970 them.
8971
8972 Note that Alpha implementations without floating-point operations are
8973 required to have floating-point registers.
8974
8975 @item -mfp-reg
8976 @itemx -mno-fp-regs
8977 @opindex mfp-reg
8978 @opindex mno-fp-regs
8979 Generate code that uses (does not use) the floating-point register set.
8980 @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
8981 register set is not used, floating point operands are passed in integer
8982 registers as if they were integers and floating-point results are passed
8983 in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
8984 so any function with a floating-point argument or return value called by code
8985 compiled with @option{-mno-fp-regs} must also be compiled with that
8986 option.
8987
8988 A typical use of this option is building a kernel that does not use,
8989 and hence need not save and restore, any floating-point registers.
8990
8991 @item -mieee
8992 @opindex mieee
8993 The Alpha architecture implements floating-point hardware optimized for
8994 maximum performance. It is mostly compliant with the IEEE floating
8995 point standard. However, for full compliance, software assistance is
8996 required. This option generates code fully IEEE compliant code
8997 @emph{except} that the @var{inexact-flag} is not maintained (see below).
8998 If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
8999 defined during compilation. The resulting code is less efficient but is
9000 able to correctly support denormalized numbers and exceptional IEEE
9001 values such as not-a-number and plus/minus infinity. Other Alpha
9002 compilers call this option @option{-ieee_with_no_inexact}.
9003
9004 @item -mieee-with-inexact
9005 @opindex mieee-with-inexact
9006 This is like @option{-mieee} except the generated code also maintains
9007 the IEEE @var{inexact-flag}. Turning on this option causes the
9008 generated code to implement fully-compliant IEEE math. In addition to
9009 @code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
9010 macro. On some Alpha implementations the resulting code may execute
9011 significantly slower than the code generated by default. Since there is
9012 very little code that depends on the @var{inexact-flag}, you should
9013 normally not specify this option. Other Alpha compilers call this
9014 option @option{-ieee_with_inexact}.
9015
9016 @item -mfp-trap-mode=@var{trap-mode}
9017 @opindex mfp-trap-mode
9018 This option controls what floating-point related traps are enabled.
9019 Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
9020 The trap mode can be set to one of four values:
9021
9022 @table @samp
9023 @item n
9024 This is the default (normal) setting. The only traps that are enabled
9025 are the ones that cannot be disabled in software (e.g., division by zero
9026 trap).
9027
9028 @item u
9029 In addition to the traps enabled by @samp{n}, underflow traps are enabled
9030 as well.
9031
9032 @item su
9033 Like @samp{su}, but the instructions are marked to be safe for software
9034 completion (see Alpha architecture manual for details).
9035
9036 @item sui
9037 Like @samp{su}, but inexact traps are enabled as well.
9038 @end table
9039
9040 @item -mfp-rounding-mode=@var{rounding-mode}
9041 @opindex mfp-rounding-mode
9042 Selects the IEEE rounding mode. Other Alpha compilers call this option
9043 @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
9044 of:
9045
9046 @table @samp
9047 @item n
9048 Normal IEEE rounding mode. Floating point numbers are rounded towards
9049 the nearest machine number or towards the even machine number in case
9050 of a tie.
9051
9052 @item m
9053 Round towards minus infinity.
9054
9055 @item c
9056 Chopped rounding mode. Floating point numbers are rounded towards zero.
9057
9058 @item d
9059 Dynamic rounding mode. A field in the floating point control register
9060 (@var{fpcr}, see Alpha architecture reference manual) controls the
9061 rounding mode in effect. The C library initializes this register for
9062 rounding towards plus infinity. Thus, unless your program modifies the
9063 @var{fpcr}, @samp{d} corresponds to round towards plus infinity.
9064 @end table
9065
9066 @item -mtrap-precision=@var{trap-precision}
9067 @opindex mtrap-precision
9068 In the Alpha architecture, floating point traps are imprecise. This
9069 means without software assistance it is impossible to recover from a
9070 floating trap and program execution normally needs to be terminated.
9071 GCC can generate code that can assist operating system trap handlers
9072 in determining the exact location that caused a floating point trap.
9073 Depending on the requirements of an application, different levels of
9074 precisions can be selected:
9075
9076 @table @samp
9077 @item p
9078 Program precision. This option is the default and means a trap handler
9079 can only identify which program caused a floating point exception.
9080
9081 @item f
9082 Function precision. The trap handler can determine the function that
9083 caused a floating point exception.
9084
9085 @item i
9086 Instruction precision. The trap handler can determine the exact
9087 instruction that caused a floating point exception.
9088 @end table
9089
9090 Other Alpha compilers provide the equivalent options called
9091 @option{-scope_safe} and @option{-resumption_safe}.
9092
9093 @item -mieee-conformant
9094 @opindex mieee-conformant
9095 This option marks the generated code as IEEE conformant. You must not
9096 use this option unless you also specify @option{-mtrap-precision=i} and either
9097 @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
9098 is to emit the line @samp{.eflag 48} in the function prologue of the
9099 generated assembly file. Under DEC Unix, this has the effect that
9100 IEEE-conformant math library routines will be linked in.
9101
9102 @item -mbuild-constants
9103 @opindex mbuild-constants
9104 Normally GCC examines a 32- or 64-bit integer constant to
9105 see if it can construct it from smaller constants in two or three
9106 instructions. If it cannot, it will output the constant as a literal and
9107 generate code to load it from the data segment at runtime.
9108
9109 Use this option to require GCC to construct @emph{all} integer constants
9110 using code, even if it takes more instructions (the maximum is six).
9111
9112 You would typically use this option to build a shared library dynamic
9113 loader. Itself a shared library, it must relocate itself in memory
9114 before it can find the variables and constants in its own data segment.
9115
9116 @item -malpha-as
9117 @itemx -mgas
9118 @opindex malpha-as
9119 @opindex mgas
9120 Select whether to generate code to be assembled by the vendor-supplied
9121 assembler (@option{-malpha-as}) or by the GNU assembler @option{-mgas}.
9122
9123 @item -mbwx
9124 @itemx -mno-bwx
9125 @itemx -mcix
9126 @itemx -mno-cix
9127 @itemx -mfix
9128 @itemx -mno-fix
9129 @itemx -mmax
9130 @itemx -mno-max
9131 @opindex mbwx
9132 @opindex mno-bwx
9133 @opindex mcix
9134 @opindex mno-cix
9135 @opindex mfix
9136 @opindex mno-fix
9137 @opindex mmax
9138 @opindex mno-max
9139 Indicate whether GCC should generate code to use the optional BWX,
9140 CIX, FIX and MAX instruction sets. The default is to use the instruction
9141 sets supported by the CPU type specified via @option{-mcpu=} option or that
9142 of the CPU on which GCC was built if none was specified.
9143
9144 @item -mfloat-vax
9145 @itemx -mfloat-ieee
9146 @opindex mfloat-vax
9147 @opindex mfloat-ieee
9148 Generate code that uses (does not use) VAX F and G floating point
9149 arithmetic instead of IEEE single and double precision.
9150
9151 @item -mexplicit-relocs
9152 @itemx -mno-explicit-relocs
9153 @opindex mexplicit-relocs
9154 @opindex mno-explicit-relocs
9155 Older Alpha assemblers provided no way to generate symbol relocations
9156 except via assembler macros. Use of these macros does not allow
9157 optimal instruction scheduling. GNU binutils as of version 2.12
9158 supports a new syntax that allows the compiler to explicitly mark
9159 which relocations should apply to which instructions. This option
9160 is mostly useful for debugging, as GCC detects the capabilities of
9161 the assembler when it is built and sets the default accordingly.
9162
9163 @item -msmall-data
9164 @itemx -mlarge-data
9165 @opindex msmall-data
9166 @opindex mlarge-data
9167 When @option{-mexplicit-relocs} is in effect, static data is
9168 accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
9169 is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
9170 (the @code{.sdata} and @code{.sbss} sections) and are accessed via
9171 16-bit relocations off of the @code{$gp} register. This limits the
9172 size of the small data area to 64KB, but allows the variables to be
9173 directly accessed via a single instruction.
9174
9175 The default is @option{-mlarge-data}. With this option the data area
9176 is limited to just below 2GB. Programs that require more than 2GB of
9177 data must use @code{malloc} or @code{mmap} to allocate the data in the
9178 heap instead of in the program's data segment.
9179
9180 When generating code for shared libraries, @option{-fpic} implies
9181 @option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
9182
9183 @item -msmall-text
9184 @itemx -mlarge-text
9185 @opindex msmall-text
9186 @opindex mlarge-text
9187 When @option{-msmall-text} is used, the compiler assumes that the
9188 code of the entire program (or shared library) fits in 4MB, and is
9189 thus reachable with a branch instruction. When @option{-msmall-data}
9190 is used, the compiler can assume that all local symbols share the
9191 same @code{$gp} value, and thus reduce the number of instructions
9192 required for a function call from 4 to 1.
9193
9194 The default is @option{-mlarge-text}.
9195
9196 @item -mcpu=@var{cpu_type}
9197 @opindex mcpu
9198 Set the instruction set and instruction scheduling parameters for
9199 machine type @var{cpu_type}. You can specify either the @samp{EV}
9200 style name or the corresponding chip number. GCC supports scheduling
9201 parameters for the EV4, EV5 and EV6 family of processors and will
9202 choose the default values for the instruction set from the processor
9203 you specify. If you do not specify a processor type, GCC will default
9204 to the processor on which the compiler was built.
9205
9206 Supported values for @var{cpu_type} are
9207
9208 @table @samp
9209 @item ev4
9210 @itemx ev45
9211 @itemx 21064
9212 Schedules as an EV4 and has no instruction set extensions.
9213
9214 @item ev5
9215 @itemx 21164
9216 Schedules as an EV5 and has no instruction set extensions.
9217
9218 @item ev56
9219 @itemx 21164a
9220 Schedules as an EV5 and supports the BWX extension.
9221
9222 @item pca56
9223 @itemx 21164pc
9224 @itemx 21164PC
9225 Schedules as an EV5 and supports the BWX and MAX extensions.
9226
9227 @item ev6
9228 @itemx 21264
9229 Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
9230
9231 @item ev67
9232 @itemx 21264a
9233 Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
9234 @end table
9235
9236 @item -mtune=@var{cpu_type}
9237 @opindex mtune
9238 Set only the instruction scheduling parameters for machine type
9239 @var{cpu_type}. The instruction set is not changed.
9240
9241 @item -mmemory-latency=@var{time}
9242 @opindex mmemory-latency
9243 Sets the latency the scheduler should assume for typical memory
9244 references as seen by the application. This number is highly
9245 dependent on the memory access patterns used by the application
9246 and the size of the external cache on the machine.
9247
9248 Valid options for @var{time} are
9249
9250 @table @samp
9251 @item @var{number}
9252 A decimal number representing clock cycles.
9253
9254 @item L1
9255 @itemx L2
9256 @itemx L3
9257 @itemx main
9258 The compiler contains estimates of the number of clock cycles for
9259 ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
9260 (also called Dcache, Scache, and Bcache), as well as to main memory.
9261 Note that L3 is only valid for EV5.
9262
9263 @end table
9264 @end table
9265
9266 @node DEC Alpha/VMS Options
9267 @subsection DEC Alpha/VMS Options
9268
9269 These @samp{-m} options are defined for the DEC Alpha/VMS implementations:
9270
9271 @table @gcctabopt
9272 @item -mvms-return-codes
9273 @opindex mvms-return-codes
9274 Return VMS condition codes from main. The default is to return POSIX
9275 style condition (e.g.@ error) codes.
9276 @end table
9277
9278 @node H8/300 Options
9279 @subsection H8/300 Options
9280
9281 These @samp{-m} options are defined for the H8/300 implementations:
9282
9283 @table @gcctabopt
9284 @item -mrelax
9285 @opindex mrelax
9286 Shorten some address references at link time, when possible; uses the
9287 linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
9288 ld, Using ld}, for a fuller description.
9289
9290 @item -mh
9291 @opindex mh
9292 Generate code for the H8/300H@.
9293
9294 @item -ms
9295 @opindex ms
9296 Generate code for the H8S@.
9297
9298 @item -mn
9299 @opindex mn
9300 Generate code for the H8S and H8/300H in the normal mode. This switch
9301 must be used either with -mh or -ms.
9302
9303 @item -ms2600
9304 @opindex ms2600
9305 Generate code for the H8S/2600. This switch must be used with @option{-ms}.
9306
9307 @item -mint32
9308 @opindex mint32
9309 Make @code{int} data 32 bits by default.
9310
9311 @item -malign-300
9312 @opindex malign-300
9313 On the H8/300H and H8S, use the same alignment rules as for the H8/300.
9314 The default for the H8/300H and H8S is to align longs and floats on 4
9315 byte boundaries.
9316 @option{-malign-300} causes them to be aligned on 2 byte boundaries.
9317 This option has no effect on the H8/300.
9318 @end table
9319
9320 @node SH Options
9321 @subsection SH Options
9322
9323 These @samp{-m} options are defined for the SH implementations:
9324
9325 @table @gcctabopt
9326 @item -m1
9327 @opindex m1
9328 Generate code for the SH1.
9329
9330 @item -m2
9331 @opindex m2
9332 Generate code for the SH2.
9333
9334 @item -m2e
9335 Generate code for the SH2e.
9336
9337 @item -m3
9338 @opindex m3
9339 Generate code for the SH3.
9340
9341 @item -m3e
9342 @opindex m3e
9343 Generate code for the SH3e.
9344
9345 @item -m4-nofpu
9346 @opindex m4-nofpu
9347 Generate code for the SH4 without a floating-point unit.
9348
9349 @item -m4-single-only
9350 @opindex m4-single-only
9351 Generate code for the SH4 with a floating-point unit that only
9352 supports single-precision arithmetic.
9353
9354 @item -m4-single
9355 @opindex m4-single
9356 Generate code for the SH4 assuming the floating-point unit is in
9357 single-precision mode by default.
9358
9359 @item -m4
9360 @opindex m4
9361 Generate code for the SH4.
9362
9363 @item -mb
9364 @opindex mb
9365 Compile code for the processor in big endian mode.
9366
9367 @item -ml
9368 @opindex ml
9369 Compile code for the processor in little endian mode.
9370
9371 @item -mdalign
9372 @opindex mdalign
9373 Align doubles at 64-bit boundaries. Note that this changes the calling
9374 conventions, and thus some functions from the standard C library will
9375 not work unless you recompile it first with @option{-mdalign}.
9376
9377 @item -mrelax
9378 @opindex mrelax
9379 Shorten some address references at link time, when possible; uses the
9380 linker option @option{-relax}.
9381
9382 @item -mbigtable
9383 @opindex mbigtable
9384 Use 32-bit offsets in @code{switch} tables. The default is to use
9385 16-bit offsets.
9386
9387 @item -mfmovd
9388 @opindex mfmovd
9389 Enable the use of the instruction @code{fmovd}.
9390
9391 @item -mhitachi
9392 @opindex mhitachi
9393 Comply with the calling conventions defined by Renesas.
9394
9395 @item -mnomacsave
9396 @opindex mnomacsave
9397 Mark the @code{MAC} register as call-clobbered, even if
9398 @option{-mhitachi} is given.
9399
9400 @item -mieee
9401 @opindex mieee
9402 Increase IEEE-compliance of floating-point code.
9403
9404 @item -misize
9405 @opindex misize
9406 Dump instruction size and location in the assembly code.
9407
9408 @item -mpadstruct
9409 @opindex mpadstruct
9410 This option is deprecated. It pads structures to multiple of 4 bytes,
9411 which is incompatible with the SH ABI@.
9412
9413 @item -mspace
9414 @opindex mspace
9415 Optimize for space instead of speed. Implied by @option{-Os}.
9416
9417 @item -mprefergot
9418 @opindex mprefergot
9419 When generating position-independent code, emit function calls using
9420 the Global Offset Table instead of the Procedure Linkage Table.
9421
9422 @item -musermode
9423 @opindex musermode
9424 Generate a library function call to invalidate instruction cache
9425 entries, after fixing up a trampoline. This library function call
9426 doesn't assume it can write to the whole memory address space. This
9427 is the default when the target is @code{sh-*-linux*}.
9428 @end table
9429
9430 @node System V Options
9431 @subsection Options for System V
9432
9433 These additional options are available on System V Release 4 for
9434 compatibility with other compilers on those systems:
9435
9436 @table @gcctabopt
9437 @item -G
9438 @opindex G
9439 Create a shared object.
9440 It is recommended that @option{-symbolic} or @option{-shared} be used instead.
9441
9442 @item -Qy
9443 @opindex Qy
9444 Identify the versions of each tool used by the compiler, in a
9445 @code{.ident} assembler directive in the output.
9446
9447 @item -Qn
9448 @opindex Qn
9449 Refrain from adding @code{.ident} directives to the output file (this is
9450 the default).
9451
9452 @item -YP,@var{dirs}
9453 @opindex YP
9454 Search the directories @var{dirs}, and no others, for libraries
9455 specified with @option{-l}.
9456
9457 @item -Ym,@var{dir}
9458 @opindex Ym
9459 Look in the directory @var{dir} to find the M4 preprocessor.
9460 The assembler uses this option.
9461 @c This is supposed to go with a -Yd for predefined M4 macro files, but
9462 @c the generic assembler that comes with Solaris takes just -Ym.
9463 @end table
9464
9465 @node TMS320C3x/C4x Options
9466 @subsection TMS320C3x/C4x Options
9467 @cindex TMS320C3x/C4x Options
9468
9469 These @samp{-m} options are defined for TMS320C3x/C4x implementations:
9470
9471 @table @gcctabopt
9472
9473 @item -mcpu=@var{cpu_type}
9474 @opindex mcpu
9475 Set the instruction set, register set, and instruction scheduling
9476 parameters for machine type @var{cpu_type}. Supported values for
9477 @var{cpu_type} are @samp{c30}, @samp{c31}, @samp{c32}, @samp{c40}, and
9478 @samp{c44}. The default is @samp{c40} to generate code for the
9479 TMS320C40.
9480
9481 @item -mbig-memory
9482 @itemx -mbig
9483 @itemx -msmall-memory
9484 @itemx -msmall
9485 @opindex mbig-memory
9486 @opindex mbig
9487 @opindex msmall-memory
9488 @opindex msmall
9489 Generates code for the big or small memory model. The small memory
9490 model assumed that all data fits into one 64K word page. At run-time
9491 the data page (DP) register must be set to point to the 64K page
9492 containing the .bss and .data program sections. The big memory model is
9493 the default and requires reloading of the DP register for every direct
9494 memory access.
9495
9496 @item -mbk
9497 @itemx -mno-bk
9498 @opindex mbk
9499 @opindex mno-bk
9500 Allow (disallow) allocation of general integer operands into the block
9501 count register BK@.
9502
9503 @item -mdb
9504 @itemx -mno-db
9505 @opindex mdb
9506 @opindex mno-db
9507 Enable (disable) generation of code using decrement and branch,
9508 DBcond(D), instructions. This is enabled by default for the C4x. To be
9509 on the safe side, this is disabled for the C3x, since the maximum
9510 iteration count on the C3x is @math{2^{23} + 1} (but who iterates loops more than
9511 @math{2^{23}} times on the C3x?). Note that GCC will try to reverse a loop so
9512 that it can utilize the decrement and branch instruction, but will give
9513 up if there is more than one memory reference in the loop. Thus a loop
9514 where the loop counter is decremented can generate slightly more
9515 efficient code, in cases where the RPTB instruction cannot be utilized.
9516
9517 @item -mdp-isr-reload
9518 @itemx -mparanoid
9519 @opindex mdp-isr-reload
9520 @opindex mparanoid
9521 Force the DP register to be saved on entry to an interrupt service
9522 routine (ISR), reloaded to point to the data section, and restored on
9523 exit from the ISR@. This should not be required unless someone has
9524 violated the small memory model by modifying the DP register, say within
9525 an object library.
9526
9527 @item -mmpyi
9528 @itemx -mno-mpyi
9529 @opindex mmpyi
9530 @opindex mno-mpyi
9531 For the C3x use the 24-bit MPYI instruction for integer multiplies
9532 instead of a library call to guarantee 32-bit results. Note that if one
9533 of the operands is a constant, then the multiplication will be performed
9534 using shifts and adds. If the @option{-mmpyi} option is not specified for the C3x,
9535 then squaring operations are performed inline instead of a library call.
9536
9537 @item -mfast-fix
9538 @itemx -mno-fast-fix
9539 @opindex mfast-fix
9540 @opindex mno-fast-fix
9541 The C3x/C4x FIX instruction to convert a floating point value to an
9542 integer value chooses the nearest integer less than or equal to the
9543 floating point value rather than to the nearest integer. Thus if the
9544 floating point number is negative, the result will be incorrectly
9545 truncated an additional code is necessary to detect and correct this
9546 case. This option can be used to disable generation of the additional
9547 code required to correct the result.
9548
9549 @item -mrptb
9550 @itemx -mno-rptb
9551 @opindex mrptb
9552 @opindex mno-rptb
9553 Enable (disable) generation of repeat block sequences using the RPTB
9554 instruction for zero overhead looping. The RPTB construct is only used
9555 for innermost loops that do not call functions or jump across the loop
9556 boundaries. There is no advantage having nested RPTB loops due to the
9557 overhead required to save and restore the RC, RS, and RE registers.
9558 This is enabled by default with @option{-O2}.
9559
9560 @item -mrpts=@var{count}
9561 @itemx -mno-rpts
9562 @opindex mrpts
9563 @opindex mno-rpts
9564 Enable (disable) the use of the single instruction repeat instruction
9565 RPTS@. If a repeat block contains a single instruction, and the loop
9566 count can be guaranteed to be less than the value @var{count}, GCC will
9567 emit a RPTS instruction instead of a RPTB@. If no value is specified,
9568 then a RPTS will be emitted even if the loop count cannot be determined
9569 at compile time. Note that the repeated instruction following RPTS does
9570 not have to be reloaded from memory each iteration, thus freeing up the
9571 CPU buses for operands. However, since interrupts are blocked by this
9572 instruction, it is disabled by default.
9573
9574 @item -mloop-unsigned
9575 @itemx -mno-loop-unsigned
9576 @opindex mloop-unsigned
9577 @opindex mno-loop-unsigned
9578 The maximum iteration count when using RPTS and RPTB (and DB on the C40)
9579 is @math{2^{31} + 1} since these instructions test if the iteration count is
9580 negative to terminate the loop. If the iteration count is unsigned
9581 there is a possibility than the @math{2^{31} + 1} maximum iteration count may be
9582 exceeded. This switch allows an unsigned iteration count.
9583
9584 @item -mti
9585 @opindex mti
9586 Try to emit an assembler syntax that the TI assembler (asm30) is happy
9587 with. This also enforces compatibility with the API employed by the TI
9588 C3x C compiler. For example, long doubles are passed as structures
9589 rather than in floating point registers.
9590
9591 @item -mregparm
9592 @itemx -mmemparm
9593 @opindex mregparm
9594 @opindex mmemparm
9595 Generate code that uses registers (stack) for passing arguments to functions.
9596 By default, arguments are passed in registers where possible rather
9597 than by pushing arguments on to the stack.
9598
9599 @item -mparallel-insns
9600 @itemx -mno-parallel-insns
9601 @opindex mparallel-insns
9602 @opindex mno-parallel-insns
9603 Allow the generation of parallel instructions. This is enabled by
9604 default with @option{-O2}.
9605
9606 @item -mparallel-mpy
9607 @itemx -mno-parallel-mpy
9608 @opindex mparallel-mpy
9609 @opindex mno-parallel-mpy
9610 Allow the generation of MPY||ADD and MPY||SUB parallel instructions,
9611 provided @option{-mparallel-insns} is also specified. These instructions have
9612 tight register constraints which can pessimize the code generation
9613 of large functions.
9614
9615 @end table
9616
9617 @node V850 Options
9618 @subsection V850 Options
9619 @cindex V850 Options
9620
9621 These @samp{-m} options are defined for V850 implementations:
9622
9623 @table @gcctabopt
9624 @item -mlong-calls
9625 @itemx -mno-long-calls
9626 @opindex mlong-calls
9627 @opindex mno-long-calls
9628 Treat all calls as being far away (near). If calls are assumed to be
9629 far away, the compiler will always load the functions address up into a
9630 register, and call indirect through the pointer.
9631
9632 @item -mno-ep
9633 @itemx -mep
9634 @opindex mno-ep
9635 @opindex mep
9636 Do not optimize (do optimize) basic blocks that use the same index
9637 pointer 4 or more times to copy pointer into the @code{ep} register, and
9638 use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
9639 option is on by default if you optimize.
9640
9641 @item -mno-prolog-function
9642 @itemx -mprolog-function
9643 @opindex mno-prolog-function
9644 @opindex mprolog-function
9645 Do not use (do use) external functions to save and restore registers
9646 at the prologue and epilogue of a function. The external functions
9647 are slower, but use less code space if more than one function saves
9648 the same number of registers. The @option{-mprolog-function} option
9649 is on by default if you optimize.
9650
9651 @item -mspace
9652 @opindex mspace
9653 Try to make the code as small as possible. At present, this just turns
9654 on the @option{-mep} and @option{-mprolog-function} options.
9655
9656 @item -mtda=@var{n}
9657 @opindex mtda
9658 Put static or global variables whose size is @var{n} bytes or less into
9659 the tiny data area that register @code{ep} points to. The tiny data
9660 area can hold up to 256 bytes in total (128 bytes for byte references).
9661
9662 @item -msda=@var{n}
9663 @opindex msda
9664 Put static or global variables whose size is @var{n} bytes or less into
9665 the small data area that register @code{gp} points to. The small data
9666 area can hold up to 64 kilobytes.
9667
9668 @item -mzda=@var{n}
9669 @opindex mzda
9670 Put static or global variables whose size is @var{n} bytes or less into
9671 the first 32 kilobytes of memory.
9672
9673 @item -mv850
9674 @opindex mv850
9675 Specify that the target processor is the V850.
9676
9677 @item -mbig-switch
9678 @opindex mbig-switch
9679 Generate code suitable for big switch tables. Use this option only if
9680 the assembler/linker complain about out of range branches within a switch
9681 table.
9682
9683 @item -mapp-regs
9684 @opindex mapp-regs
9685 This option will cause r2 and r5 to be used in the code generated by
9686 the compiler. This setting is the default.
9687
9688 @item -mno-app-regs
9689 @opindex mno-app-regs
9690 This option will cause r2 and r5 to be treated as fixed registers.
9691
9692 @item -mv850e1
9693 @opindex mv850e1
9694 Specify that the target processor is the V850E1. The preprocessor
9695 constants @samp{__v850e1__} and @samp{__v850e__} will be defined if
9696 this option is used.
9697
9698 @item -mv850e
9699 @opindex mv850e
9700 Specify that the target processor is the V850E. The preprocessor
9701 constant @samp{__v850e__} will be defined if this option is used.
9702
9703 If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
9704 are defined then a default target processor will be chosen and the
9705 relevant @samp{__v850*__} preprocessor constant will be defined.
9706
9707 The preprocessor constants @samp{__v850} and @samp{__v851__} are always
9708 defined, regardless of which processor variant is the target.
9709
9710 @item -mdisable-callt
9711 @opindex mdisable-callt
9712 This option will suppress generation of the CALLT instruction for the
9713 v850e and v850e1 flavors of the v850 architecture. The default is
9714 @option{-mno-disable-callt} which allows the CALLT instruction to be used.
9715
9716 @end table
9717
9718 @node ARC Options
9719 @subsection ARC Options
9720 @cindex ARC Options
9721
9722 These options are defined for ARC implementations:
9723
9724 @table @gcctabopt
9725 @item -EL
9726 @opindex EL
9727 Compile code for little endian mode. This is the default.
9728
9729 @item -EB
9730 @opindex EB
9731 Compile code for big endian mode.
9732
9733 @item -mmangle-cpu
9734 @opindex mmangle-cpu
9735 Prepend the name of the cpu to all public symbol names.
9736 In multiple-processor systems, there are many ARC variants with different
9737 instruction and register set characteristics. This flag prevents code
9738 compiled for one cpu to be linked with code compiled for another.
9739 No facility exists for handling variants that are ``almost identical''.
9740 This is an all or nothing option.
9741
9742 @item -mcpu=@var{cpu}
9743 @opindex mcpu
9744 Compile code for ARC variant @var{cpu}.
9745 Which variants are supported depend on the configuration.
9746 All variants support @option{-mcpu=base}, this is the default.
9747
9748 @item -mtext=@var{text-section}
9749 @itemx -mdata=@var{data-section}
9750 @itemx -mrodata=@var{readonly-data-section}
9751 @opindex mtext
9752 @opindex mdata
9753 @opindex mrodata
9754 Put functions, data, and readonly data in @var{text-section},
9755 @var{data-section}, and @var{readonly-data-section} respectively
9756 by default. This can be overridden with the @code{section} attribute.
9757 @xref{Variable Attributes}.
9758
9759 @end table
9760
9761 @node NS32K Options
9762 @subsection NS32K Options
9763 @cindex NS32K options
9764
9765 These are the @samp{-m} options defined for the 32000 series. The default
9766 values for these options depends on which style of 32000 was selected when
9767 the compiler was configured; the defaults for the most common choices are
9768 given below.
9769
9770 @table @gcctabopt
9771 @item -m32032
9772 @itemx -m32032
9773 @opindex m32032
9774 @opindex m32032
9775 Generate output for a 32032. This is the default
9776 when the compiler is configured for 32032 and 32016 based systems.
9777
9778 @item -m32332
9779 @itemx -m32332
9780 @opindex m32332
9781 @opindex m32332
9782 Generate output for a 32332. This is the default
9783 when the compiler is configured for 32332-based systems.
9784
9785 @item -m32532
9786 @itemx -m32532
9787 @opindex m32532
9788 @opindex m32532
9789 Generate output for a 32532. This is the default
9790 when the compiler is configured for 32532-based systems.
9791
9792 @item -m32081
9793 @opindex m32081
9794 Generate output containing 32081 instructions for floating point.
9795 This is the default for all systems.
9796
9797 @item -m32381
9798 @opindex m32381
9799 Generate output containing 32381 instructions for floating point. This
9800 also implies @option{-m32081}. The 32381 is only compatible with the 32332
9801 and 32532 cpus. This is the default for the pc532-netbsd configuration.
9802
9803 @item -mmulti-add
9804 @opindex mmulti-add
9805 Try and generate multiply-add floating point instructions @code{polyF}
9806 and @code{dotF}. This option is only available if the @option{-m32381}
9807 option is in effect. Using these instructions requires changes to
9808 register allocation which generally has a negative impact on
9809 performance. This option should only be enabled when compiling code
9810 particularly likely to make heavy use of multiply-add instructions.
9811
9812 @item -mnomulti-add
9813 @opindex mnomulti-add
9814 Do not try and generate multiply-add floating point instructions
9815 @code{polyF} and @code{dotF}. This is the default on all platforms.
9816
9817 @item -msoft-float
9818 @opindex msoft-float
9819 Generate output containing library calls for floating point.
9820 @strong{Warning:} the requisite libraries may not be available.
9821
9822 @item -mieee-compare
9823 @itemx -mno-ieee-compare
9824 @opindex mieee-compare
9825 @opindex mno-ieee-compare
9826 Control whether or not the compiler uses IEEE floating point
9827 comparisons. These handle correctly the case where the result of a
9828 comparison is unordered.
9829 @strong{Warning:} the requisite kernel support may not be available.
9830
9831 @item -mnobitfield
9832 @opindex mnobitfield
9833 Do not use the bit-field instructions. On some machines it is faster to
9834 use shifting and masking operations. This is the default for the pc532.
9835
9836 @item -mbitfield
9837 @opindex mbitfield
9838 Do use the bit-field instructions. This is the default for all platforms
9839 except the pc532.
9840
9841 @item -mrtd
9842 @opindex mrtd
9843 Use a different function-calling convention, in which functions
9844 that take a fixed number of arguments return pop their
9845 arguments on return with the @code{ret} instruction.
9846
9847 This calling convention is incompatible with the one normally
9848 used on Unix, so you cannot use it if you need to call libraries
9849 compiled with the Unix compiler.
9850
9851 Also, you must provide function prototypes for all functions that
9852 take variable numbers of arguments (including @code{printf});
9853 otherwise incorrect code will be generated for calls to those
9854 functions.
9855
9856 In addition, seriously incorrect code will result if you call a
9857 function with too many arguments. (Normally, extra arguments are
9858 harmlessly ignored.)
9859
9860 This option takes its name from the 680x0 @code{rtd} instruction.
9861
9862
9863 @item -mregparam
9864 @opindex mregparam
9865 Use a different function-calling convention where the first two arguments
9866 are passed in registers.
9867
9868 This calling convention is incompatible with the one normally
9869 used on Unix, so you cannot use it if you need to call libraries
9870 compiled with the Unix compiler.
9871
9872 @item -mnoregparam
9873 @opindex mnoregparam
9874 Do not pass any arguments in registers. This is the default for all
9875 targets.
9876
9877 @item -msb
9878 @opindex msb
9879 It is OK to use the sb as an index register which is always loaded with
9880 zero. This is the default for the pc532-netbsd target.
9881
9882 @item -mnosb
9883 @opindex mnosb
9884 The sb register is not available for use or has not been initialized to
9885 zero by the run time system. This is the default for all targets except
9886 the pc532-netbsd. It is also implied whenever @option{-mhimem} or
9887 @option{-fpic} is set.
9888
9889 @item -mhimem
9890 @opindex mhimem
9891 Many ns32000 series addressing modes use displacements of up to 512MB@.
9892 If an address is above 512MB then displacements from zero can not be used.
9893 This option causes code to be generated which can be loaded above 512MB@.
9894 This may be useful for operating systems or ROM code.
9895
9896 @item -mnohimem
9897 @opindex mnohimem
9898 Assume code will be loaded in the first 512MB of virtual address space.
9899 This is the default for all platforms.
9900
9901
9902 @end table
9903
9904 @node AVR Options
9905 @subsection AVR Options
9906 @cindex AVR Options
9907
9908 These options are defined for AVR implementations:
9909
9910 @table @gcctabopt
9911 @item -mmcu=@var{mcu}
9912 @opindex mmcu
9913 Specify ATMEL AVR instruction set or MCU type.
9914
9915 Instruction set avr1 is for the minimal AVR core, not supported by the C
9916 compiler, only for assembler programs (MCU types: at90s1200, attiny10,
9917 attiny11, attiny12, attiny15, attiny28).
9918
9919 Instruction set avr2 (default) is for the classic AVR core with up to
9920 8K program memory space (MCU types: at90s2313, at90s2323, attiny22,
9921 at90s2333, at90s2343, at90s4414, at90s4433, at90s4434, at90s8515,
9922 at90c8534, at90s8535).
9923
9924 Instruction set avr3 is for the classic AVR core with up to 128K program
9925 memory space (MCU types: atmega103, atmega603, at43usb320, at76c711).
9926
9927 Instruction set avr4 is for the enhanced AVR core with up to 8K program
9928 memory space (MCU types: atmega8, atmega83, atmega85).
9929
9930 Instruction set avr5 is for the enhanced AVR core with up to 128K program
9931 memory space (MCU types: atmega16, atmega161, atmega163, atmega32, atmega323,
9932 atmega64, atmega128, at43usb355, at94k).
9933
9934 @item -msize
9935 @opindex msize
9936 Output instruction sizes to the asm file.
9937
9938 @item -minit-stack=@var{N}
9939 @opindex minit-stack
9940 Specify the initial stack address, which may be a symbol or numeric value,
9941 @samp{__stack} is the default.
9942
9943 @item -mno-interrupts
9944 @opindex mno-interrupts
9945 Generated code is not compatible with hardware interrupts.
9946 Code size will be smaller.
9947
9948 @item -mcall-prologues
9949 @opindex mcall-prologues
9950 Functions prologues/epilogues expanded as call to appropriate
9951 subroutines. Code size will be smaller.
9952
9953 @item -mno-tablejump
9954 @opindex mno-tablejump
9955 Do not generate tablejump insns which sometimes increase code size.
9956
9957 @item -mtiny-stack
9958 @opindex mtiny-stack
9959 Change only the low 8 bits of the stack pointer.
9960 @end table
9961
9962 @node MCore Options
9963 @subsection MCore Options
9964 @cindex MCore options
9965
9966 These are the @samp{-m} options defined for the Motorola M*Core
9967 processors.
9968
9969 @table @gcctabopt
9970
9971 @item -mhardlit
9972 @itemx -mno-hardlit
9973 @opindex mhardlit
9974 @opindex mno-hardlit
9975 Inline constants into the code stream if it can be done in two
9976 instructions or less.
9977
9978 @item -mdiv
9979 @itemx -mno-div
9980 @opindex mdiv
9981 @opindex mno-div
9982 Use the divide instruction. (Enabled by default).
9983
9984 @item -mrelax-immediate
9985 @itemx -mno-relax-immediate
9986 @opindex mrelax-immediate
9987 @opindex mno-relax-immediate
9988 Allow arbitrary sized immediates in bit operations.
9989
9990 @item -mwide-bitfields
9991 @itemx -mno-wide-bitfields
9992 @opindex mwide-bitfields
9993 @opindex mno-wide-bitfields
9994 Always treat bit-fields as int-sized.
9995
9996 @item -m4byte-functions
9997 @itemx -mno-4byte-functions
9998 @opindex m4byte-functions
9999 @opindex mno-4byte-functions
10000 Force all functions to be aligned to a four byte boundary.
10001
10002 @item -mcallgraph-data
10003 @itemx -mno-callgraph-data
10004 @opindex mcallgraph-data
10005 @opindex mno-callgraph-data
10006 Emit callgraph information.
10007
10008 @item -mslow-bytes
10009 @itemx -mno-slow-bytes
10010 @opindex mslow-bytes
10011 @opindex mno-slow-bytes
10012 Prefer word access when reading byte quantities.
10013
10014 @item -mlittle-endian
10015 @itemx -mbig-endian
10016 @opindex mlittle-endian
10017 @opindex mbig-endian
10018 Generate code for a little endian target.
10019
10020 @item -m210
10021 @itemx -m340
10022 @opindex m210
10023 @opindex m340
10024 Generate code for the 210 processor.
10025 @end table
10026
10027 @node IA-64 Options
10028 @subsection IA-64 Options
10029 @cindex IA-64 Options
10030
10031 These are the @samp{-m} options defined for the Intel IA-64 architecture.
10032
10033 @table @gcctabopt
10034 @item -mbig-endian
10035 @opindex mbig-endian
10036 Generate code for a big endian target. This is the default for HP-UX@.
10037
10038 @item -mlittle-endian
10039 @opindex mlittle-endian
10040 Generate code for a little endian target. This is the default for AIX5
10041 and GNU/Linux.
10042
10043 @item -mgnu-as
10044 @itemx -mno-gnu-as
10045 @opindex mgnu-as
10046 @opindex mno-gnu-as
10047 Generate (or don't) code for the GNU assembler. This is the default.
10048 @c Also, this is the default if the configure option @option{--with-gnu-as}
10049 @c is used.
10050
10051 @item -mgnu-ld
10052 @itemx -mno-gnu-ld
10053 @opindex mgnu-ld
10054 @opindex mno-gnu-ld
10055 Generate (or don't) code for the GNU linker. This is the default.
10056 @c Also, this is the default if the configure option @option{--with-gnu-ld}
10057 @c is used.
10058
10059 @item -mno-pic
10060 @opindex mno-pic
10061 Generate code that does not use a global pointer register. The result
10062 is not position independent code, and violates the IA-64 ABI@.
10063
10064 @item -mvolatile-asm-stop
10065 @itemx -mno-volatile-asm-stop
10066 @opindex mvolatile-asm-stop
10067 @opindex mno-volatile-asm-stop
10068 Generate (or don't) a stop bit immediately before and after volatile asm
10069 statements.
10070
10071 @item -mb-step
10072 @opindex mb-step
10073 Generate code that works around Itanium B step errata.
10074
10075 @item -mregister-names
10076 @itemx -mno-register-names
10077 @opindex mregister-names
10078 @opindex mno-register-names
10079 Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
10080 the stacked registers. This may make assembler output more readable.
10081
10082 @item -mno-sdata
10083 @itemx -msdata
10084 @opindex mno-sdata
10085 @opindex msdata
10086 Disable (or enable) optimizations that use the small data section. This may
10087 be useful for working around optimizer bugs.
10088
10089 @item -mconstant-gp
10090 @opindex mconstant-gp
10091 Generate code that uses a single constant global pointer value. This is
10092 useful when compiling kernel code.
10093
10094 @item -mauto-pic
10095 @opindex mauto-pic
10096 Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
10097 This is useful when compiling firmware code.
10098
10099 @item -minline-float-divide-min-latency
10100 @opindex minline-float-divide-min-latency
10101 Generate code for inline divides of floating point values
10102 using the minimum latency algorithm.
10103
10104 @item -minline-float-divide-max-throughput
10105 @opindex minline-float-divide-max-throughput
10106 Generate code for inline divides of floating point values
10107 using the maximum throughput algorithm.
10108
10109 @item -minline-int-divide-min-latency
10110 @opindex minline-int-divide-min-latency
10111 Generate code for inline divides of integer values
10112 using the minimum latency algorithm.
10113
10114 @item -minline-int-divide-max-throughput
10115 @opindex minline-int-divide-max-throughput
10116 Generate code for inline divides of integer values
10117 using the maximum throughput algorithm.
10118
10119 @item -mno-dwarf2-asm
10120 @itemx -mdwarf2-asm
10121 @opindex mno-dwarf2-asm
10122 @opindex mdwarf2-asm
10123 Don't (or do) generate assembler code for the DWARF2 line number debugging
10124 info. This may be useful when not using the GNU assembler.
10125
10126 @item -mfixed-range=@var{register-range}
10127 @opindex mfixed-range
10128 Generate code treating the given register range as fixed registers.
10129 A fixed register is one that the register allocator can not use. This is
10130 useful when compiling kernel code. A register range is specified as
10131 two registers separated by a dash. Multiple register ranges can be
10132 specified separated by a comma.
10133
10134 @item -mearly-stop-bits
10135 @itemx -mno-early-stop-bits
10136 @opindex mearly-stop-bits
10137 @opindex mno-early-stop-bits
10138 Allow stop bits to be placed earlier than immediately preceding the
10139 instruction that triggered the stop bit. This can improve instruction
10140 scheduling, but does not always do so.
10141 @end table
10142
10143 @node S/390 and zSeries Options
10144 @subsection S/390 and zSeries Options
10145 @cindex S/390 and zSeries Options
10146
10147 These are the @samp{-m} options defined for the S/390 and zSeries architecture.
10148
10149 @table @gcctabopt
10150 @item -mhard-float
10151 @itemx -msoft-float
10152 @opindex mhard-float
10153 @opindex msoft-float
10154 Use (do not use) the hardware floating-point instructions and registers
10155 for floating-point operations. When @option{-msoft-float} is specified,
10156 functions in @file{libgcc.a} will be used to perform floating-point
10157 operations. When @option{-mhard-float} is specified, the compiler
10158 generates IEEE floating-point instructions. This is the default.
10159
10160 @item -mbackchain
10161 @itemx -mno-backchain
10162 @opindex mbackchain
10163 @opindex mno-backchain
10164 Generate (or do not generate) code which maintains an explicit
10165 backchain within the stack frame that points to the caller's frame.
10166 This may be needed to allow debugging using tools that do not understand
10167 DWARF-2 call frame information. The default is not to generate the
10168 backchain.
10169
10170 @item -msmall-exec
10171 @itemx -mno-small-exec
10172 @opindex msmall-exec
10173 @opindex mno-small-exec
10174 Generate (or do not generate) code using the @code{bras} instruction
10175 to do subroutine calls.
10176 This only works reliably if the total executable size does not
10177 exceed 64k. The default is to use the @code{basr} instruction instead,
10178 which does not have this limitation.
10179
10180 @item -m64
10181 @itemx -m31
10182 @opindex m64
10183 @opindex m31
10184 When @option{-m31} is specified, generate code compliant to the
10185 GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
10186 code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
10187 particular to generate 64-bit instructions. For the @samp{s390}
10188 targets, the default is @option{-m31}, while the @samp{s390x}
10189 targets default to @option{-m64}.
10190
10191 @item -mzarch
10192 @itemx -mesa
10193 @opindex mzarch
10194 @opindex mesa
10195 When @option{-mzarch} is specified, generate code using the
10196 instructions available on z/Architecture.
10197 When @option{-mesa} is specified, generate code using the
10198 instructions available on ESA/390. Note that @option{-mesa} is
10199 not possible with @option{-m64}.
10200 When generating code compliant to the GNU/Linux for S/390 ABI,
10201 the default is @option{-mesa}. When generating code compliant
10202 to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
10203
10204 @item -mmvcle
10205 @itemx -mno-mvcle
10206 @opindex mmvcle
10207 @opindex mno-mvcle
10208 Generate (or do not generate) code using the @code{mvcle} instruction
10209 to perform block moves. When @option{-mno-mvcle} is specified,
10210 use a @code{mvc} loop instead. This is the default.
10211
10212 @item -mdebug
10213 @itemx -mno-debug
10214 @opindex mdebug
10215 @opindex mno-debug
10216 Print (or do not print) additional debug information when compiling.
10217 The default is to not print debug information.
10218
10219 @item -march=@var{cpu-type}
10220 @opindex march
10221 Generate code that will run on @var{cpu-type}, which is the name of a system
10222 representing a certain processor type. Possible values for
10223 @var{cpu-type} are @samp{g5}, @samp{g6}, @samp{z900}, and @samp{z990}.
10224 When generating code using the instructions available on z/Architecture,
10225 the default is @option{-march=z900}. Otherwise, the default is
10226 @option{-march=g5}.
10227
10228 @item -mtune=@var{cpu-type}
10229 @opindex mtune
10230 Tune to @var{cpu-type} everything applicable about the generated code,
10231 except for the ABI and the set of available instructions.
10232 The list of @var{cpu-type} values is the same as for @option{-march}.
10233 The default is the value used for @option{-march}.
10234
10235 @item -mfused-madd
10236 @itemx -mno-fused-madd
10237 @opindex mfused-madd
10238 @opindex mno-fused-madd
10239 Generate code that uses (does not use) the floating point multiply and
10240 accumulate instructions. These instructions are generated by default if
10241 hardware floating point is used.
10242 @end table
10243
10244 @node CRIS Options
10245 @subsection CRIS Options
10246 @cindex CRIS Options
10247
10248 These options are defined specifically for the CRIS ports.
10249
10250 @table @gcctabopt
10251 @item -march=@var{architecture-type}
10252 @itemx -mcpu=@var{architecture-type}
10253 @opindex march
10254 @opindex mcpu
10255 Generate code for the specified architecture. The choices for
10256 @var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
10257 respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX.
10258 Default is @samp{v0} except for cris-axis-linux-gnu, where the default is
10259 @samp{v10}.
10260
10261 @item -mtune=@var{architecture-type}
10262 @opindex mtune
10263 Tune to @var{architecture-type} everything applicable about the generated
10264 code, except for the ABI and the set of available instructions. The
10265 choices for @var{architecture-type} are the same as for
10266 @option{-march=@var{architecture-type}}.
10267
10268 @item -mmax-stack-frame=@var{n}
10269 @opindex mmax-stack-frame
10270 Warn when the stack frame of a function exceeds @var{n} bytes.
10271
10272 @item -melinux-stacksize=@var{n}
10273 @opindex melinux-stacksize
10274 Only available with the @samp{cris-axis-aout} target. Arranges for
10275 indications in the program to the kernel loader that the stack of the
10276 program should be set to @var{n} bytes.
10277
10278 @item -metrax4
10279 @itemx -metrax100
10280 @opindex metrax4
10281 @opindex metrax100
10282 The options @option{-metrax4} and @option{-metrax100} are synonyms for
10283 @option{-march=v3} and @option{-march=v8} respectively.
10284
10285 @item -mmul-bug-workaround
10286 @itemx -mno-mul-bug-workaround
10287 @opindex mmul-bug-workaround
10288 @opindex mno-mul-bug-workaround
10289 Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
10290 models where it applies. This option is active by default.
10291
10292 @item -mpdebug
10293 @opindex mpdebug
10294 Enable CRIS-specific verbose debug-related information in the assembly
10295 code. This option also has the effect to turn off the @samp{#NO_APP}
10296 formatted-code indicator to the assembler at the beginning of the
10297 assembly file.
10298
10299 @item -mcc-init
10300 @opindex mcc-init
10301 Do not use condition-code results from previous instruction; always emit
10302 compare and test instructions before use of condition codes.
10303
10304 @item -mno-side-effects
10305 @opindex mno-side-effects
10306 Do not emit instructions with side-effects in addressing modes other than
10307 post-increment.
10308
10309 @item -mstack-align
10310 @itemx -mno-stack-align
10311 @itemx -mdata-align
10312 @itemx -mno-data-align
10313 @itemx -mconst-align
10314 @itemx -mno-const-align
10315 @opindex mstack-align
10316 @opindex mno-stack-align
10317 @opindex mdata-align
10318 @opindex mno-data-align
10319 @opindex mconst-align
10320 @opindex mno-const-align
10321 These options (no-options) arranges (eliminate arrangements) for the
10322 stack-frame, individual data and constants to be aligned for the maximum
10323 single data access size for the chosen CPU model. The default is to
10324 arrange for 32-bit alignment. ABI details such as structure layout are
10325 not affected by these options.
10326
10327 @item -m32-bit
10328 @itemx -m16-bit
10329 @itemx -m8-bit
10330 @opindex m32-bit
10331 @opindex m16-bit
10332 @opindex m8-bit
10333 Similar to the stack- data- and const-align options above, these options
10334 arrange for stack-frame, writable data and constants to all be 32-bit,
10335 16-bit or 8-bit aligned. The default is 32-bit alignment.
10336
10337 @item -mno-prologue-epilogue
10338 @itemx -mprologue-epilogue
10339 @opindex mno-prologue-epilogue
10340 @opindex mprologue-epilogue
10341 With @option{-mno-prologue-epilogue}, the normal function prologue and
10342 epilogue that sets up the stack-frame are omitted and no return
10343 instructions or return sequences are generated in the code. Use this
10344 option only together with visual inspection of the compiled code: no
10345 warnings or errors are generated when call-saved registers must be saved,
10346 or storage for local variable needs to be allocated.
10347
10348 @item -mno-gotplt
10349 @itemx -mgotplt
10350 @opindex mno-gotplt
10351 @opindex mgotplt
10352 With @option{-fpic} and @option{-fPIC}, don't generate (do generate)
10353 instruction sequences that load addresses for functions from the PLT part
10354 of the GOT rather than (traditional on other architectures) calls to the
10355 PLT. The default is @option{-mgotplt}.
10356
10357 @item -maout
10358 @opindex maout
10359 Legacy no-op option only recognized with the cris-axis-aout target.
10360
10361 @item -melf
10362 @opindex melf
10363 Legacy no-op option only recognized with the cris-axis-elf and
10364 cris-axis-linux-gnu targets.
10365
10366 @item -melinux
10367 @opindex melinux
10368 Only recognized with the cris-axis-aout target, where it selects a
10369 GNU/linux-like multilib, include files and instruction set for
10370 @option{-march=v8}.
10371
10372 @item -mlinux
10373 @opindex mlinux
10374 Legacy no-op option only recognized with the cris-axis-linux-gnu target.
10375
10376 @item -sim
10377 @opindex sim
10378 This option, recognized for the cris-axis-aout and cris-axis-elf arranges
10379 to link with input-output functions from a simulator library. Code,
10380 initialized data and zero-initialized data are allocated consecutively.
10381
10382 @item -sim2
10383 @opindex sim2
10384 Like @option{-sim}, but pass linker options to locate initialized data at
10385 0x40000000 and zero-initialized data at 0x80000000.
10386 @end table
10387
10388 @node MMIX Options
10389 @subsection MMIX Options
10390 @cindex MMIX Options
10391
10392 These options are defined for the MMIX:
10393
10394 @table @gcctabopt
10395 @item -mlibfuncs
10396 @itemx -mno-libfuncs
10397 @opindex mlibfuncs
10398 @opindex mno-libfuncs
10399 Specify that intrinsic library functions are being compiled, passing all
10400 values in registers, no matter the size.
10401
10402 @item -mepsilon
10403 @itemx -mno-epsilon
10404 @opindex mepsilon
10405 @opindex mno-epsilon
10406 Generate floating-point comparison instructions that compare with respect
10407 to the @code{rE} epsilon register.
10408
10409 @item -mabi=mmixware
10410 @itemx -mabi=gnu
10411 @opindex mabi-mmixware
10412 @opindex mabi=gnu
10413 Generate code that passes function parameters and return values that (in
10414 the called function) are seen as registers @code{$0} and up, as opposed to
10415 the GNU ABI which uses global registers @code{$231} and up.
10416
10417 @item -mzero-extend
10418 @itemx -mno-zero-extend
10419 @opindex mzero-extend
10420 @opindex mno-zero-extend
10421 When reading data from memory in sizes shorter than 64 bits, use (do not
10422 use) zero-extending load instructions by default, rather than
10423 sign-extending ones.
10424
10425 @item -mknuthdiv
10426 @itemx -mno-knuthdiv
10427 @opindex mknuthdiv
10428 @opindex mno-knuthdiv
10429 Make the result of a division yielding a remainder have the same sign as
10430 the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
10431 remainder follows the sign of the dividend. Both methods are
10432 arithmetically valid, the latter being almost exclusively used.
10433
10434 @item -mtoplevel-symbols
10435 @itemx -mno-toplevel-symbols
10436 @opindex mtoplevel-symbols
10437 @opindex mno-toplevel-symbols
10438 Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
10439 code can be used with the @code{PREFIX} assembly directive.
10440
10441 @item -melf
10442 @opindex melf
10443 Generate an executable in the ELF format, rather than the default
10444 @samp{mmo} format used by the @command{mmix} simulator.
10445
10446 @item -mbranch-predict
10447 @itemx -mno-branch-predict
10448 @opindex mbranch-predict
10449 @opindex mno-branch-predict
10450 Use (do not use) the probable-branch instructions, when static branch
10451 prediction indicates a probable branch.
10452
10453 @item -mbase-addresses
10454 @itemx -mno-base-addresses
10455 @opindex mbase-addresses
10456 @opindex mno-base-addresses
10457 Generate (do not generate) code that uses @emph{base addresses}. Using a
10458 base address automatically generates a request (handled by the assembler
10459 and the linker) for a constant to be set up in a global register. The
10460 register is used for one or more base address requests within the range 0
10461 to 255 from the value held in the register. The generally leads to short
10462 and fast code, but the number of different data items that can be
10463 addressed is limited. This means that a program that uses lots of static
10464 data may require @option{-mno-base-addresses}.
10465
10466 @item -msingle-exit
10467 @itemx -mno-single-exit
10468 @opindex msingle-exit
10469 @opindex mno-single-exit
10470 Force (do not force) generated code to have a single exit point in each
10471 function.
10472 @end table
10473
10474 @node PDP-11 Options
10475 @subsection PDP-11 Options
10476 @cindex PDP-11 Options
10477
10478 These options are defined for the PDP-11:
10479
10480 @table @gcctabopt
10481 @item -mfpu
10482 @opindex mfpu
10483 Use hardware FPP floating point. This is the default. (FIS floating
10484 point on the PDP-11/40 is not supported.)
10485
10486 @item -msoft-float
10487 @opindex msoft-float
10488 Do not use hardware floating point.
10489
10490 @item -mac0
10491 @opindex mac0
10492 Return floating-point results in ac0 (fr0 in Unix assembler syntax).
10493
10494 @item -mno-ac0
10495 @opindex mno-ac0
10496 Return floating-point results in memory. This is the default.
10497
10498 @item -m40
10499 @opindex m40
10500 Generate code for a PDP-11/40.
10501
10502 @item -m45
10503 @opindex m45
10504 Generate code for a PDP-11/45. This is the default.
10505
10506 @item -m10
10507 @opindex m10
10508 Generate code for a PDP-11/10.
10509
10510 @item -mbcopy-builtin
10511 @opindex bcopy-builtin
10512 Use inline @code{movstrhi} patterns for copying memory. This is the
10513 default.
10514
10515 @item -mbcopy
10516 @opindex mbcopy
10517 Do not use inline @code{movstrhi} patterns for copying memory.
10518
10519 @item -mint16
10520 @itemx -mno-int32
10521 @opindex mint16
10522 @opindex mno-int32
10523 Use 16-bit @code{int}. This is the default.
10524
10525 @item -mint32
10526 @itemx -mno-int16
10527 @opindex mint32
10528 @opindex mno-int16
10529 Use 32-bit @code{int}.
10530
10531 @item -mfloat64
10532 @itemx -mno-float32
10533 @opindex mfloat64
10534 @opindex mno-float32
10535 Use 64-bit @code{float}. This is the default.
10536
10537 @item -mfloat32
10538 @itemx -mno-float64
10539 @opindex mfloat32
10540 @opindex mno-float64
10541 Use 32-bit @code{float}.
10542
10543 @item -mabshi
10544 @opindex mabshi
10545 Use @code{abshi2} pattern. This is the default.
10546
10547 @item -mno-abshi
10548 @opindex mno-abshi
10549 Do not use @code{abshi2} pattern.
10550
10551 @item -mbranch-expensive
10552 @opindex mbranch-expensive
10553 Pretend that branches are expensive. This is for experimenting with
10554 code generation only.
10555
10556 @item -mbranch-cheap
10557 @opindex mbranch-cheap
10558 Do not pretend that branches are expensive. This is the default.
10559
10560 @item -msplit
10561 @opindex msplit
10562 Generate code for a system with split I&D.
10563
10564 @item -mno-split
10565 @opindex mno-split
10566 Generate code for a system without split I&D. This is the default.
10567
10568 @item -munix-asm
10569 @opindex munix-asm
10570 Use Unix assembler syntax. This is the default when configured for
10571 @samp{pdp11-*-bsd}.
10572
10573 @item -mdec-asm
10574 @opindex mdec-asm
10575 Use DEC assembler syntax. This is the default when configured for any
10576 PDP-11 target other than @samp{pdp11-*-bsd}.
10577 @end table
10578
10579 @node Xstormy16 Options
10580 @subsection Xstormy16 Options
10581 @cindex Xstormy16 Options
10582
10583 These options are defined for Xstormy16:
10584
10585 @table @gcctabopt
10586 @item -msim
10587 @opindex msim
10588 Choose startup files and linker script suitable for the simulator.
10589 @end table
10590
10591 @node FRV Options
10592 @subsection FRV Options
10593 @cindex FRV Options
10594
10595 @table @gcctabopt
10596 @item -mgpr-32
10597 @opindex mgpr-32
10598
10599 Only use the first 32 general purpose registers.
10600
10601 @item -mgpr-64
10602 @opindex mgpr-64
10603
10604 Use all 64 general purpose registers.
10605
10606 @item -mfpr-32
10607 @opindex mfpr-32
10608
10609 Use only the first 32 floating point registers.
10610
10611 @item -mfpr-64
10612 @opindex mfpr-64
10613
10614 Use all 64 floating point registers
10615
10616 @item -mhard-float
10617 @opindex mhard-float
10618
10619 Use hardware instructions for floating point operations.
10620
10621 @item -msoft-float
10622 @opindex msoft-float
10623
10624 Use library routines for floating point operations.
10625
10626 @item -malloc-cc
10627 @opindex malloc-cc
10628
10629 Dynamically allocate condition code registers.
10630
10631 @item -mfixed-cc
10632 @opindex mfixed-cc
10633
10634 Do not try to dynamically allocate condition code registers, only
10635 use @code{icc0} and @code{fcc0}.
10636
10637 @item -mdword
10638 @opindex mdword
10639
10640 Change ABI to use double word insns.
10641
10642 @item -mno-dword
10643 @opindex mno-dword
10644
10645 Do not use double word instructions.
10646
10647 @item -mdouble
10648 @opindex mdouble
10649
10650 Use floating point double instructions.
10651
10652 @item -mno-double
10653 @opindex mno-double
10654
10655 Do not use floating point double instructions.
10656
10657 @item -mmedia
10658 @opindex mmedia
10659
10660 Use media instructions.
10661
10662 @item -mno-media
10663 @opindex mno-media
10664
10665 Do not use media instructions.
10666
10667 @item -mmuladd
10668 @opindex mmuladd
10669
10670 Use multiply and add/subtract instructions.
10671
10672 @item -mno-muladd
10673 @opindex mno-muladd
10674
10675 Do not use multiply and add/subtract instructions.
10676
10677 @item -mlibrary-pic
10678 @opindex mlibrary-pic
10679
10680 Generate position-independent EABI code.
10681
10682 @item -macc-4
10683 @opindex macc-4
10684
10685 Use only the first four media accumulator registers.
10686
10687 @item -macc-8
10688 @opindex macc-8
10689
10690 Use all eight media accumulator registers.
10691
10692 @item -mpack
10693 @opindex mpack
10694
10695 Pack VLIW instructions.
10696
10697 @item -mno-pack
10698 @opindex mno-pack
10699
10700 Do not pack VLIW instructions.
10701
10702 @item -mno-eflags
10703 @opindex mno-eflags
10704
10705 Do not mark ABI switches in e_flags.
10706
10707 @item -mcond-move
10708 @opindex mcond-move
10709
10710 Enable the use of conditional-move instructions (default).
10711
10712 This switch is mainly for debugging the compiler and will likely be removed
10713 in a future version.
10714
10715 @item -mno-cond-move
10716 @opindex mno-cond-move
10717
10718 Disable the use of conditional-move instructions.
10719
10720 This switch is mainly for debugging the compiler and will likely be removed
10721 in a future version.
10722
10723 @item -mscc
10724 @opindex mscc
10725
10726 Enable the use of conditional set instructions (default).
10727
10728 This switch is mainly for debugging the compiler and will likely be removed
10729 in a future version.
10730
10731 @item -mno-scc
10732 @opindex mno-scc
10733
10734 Disable the use of conditional set instructions.
10735
10736 This switch is mainly for debugging the compiler and will likely be removed
10737 in a future version.
10738
10739 @item -mcond-exec
10740 @opindex mcond-exec
10741
10742 Enable the use of conditional execution (default).
10743
10744 This switch is mainly for debugging the compiler and will likely be removed
10745 in a future version.
10746
10747 @item -mno-cond-exec
10748 @opindex mno-cond-exec
10749
10750 Disable the use of conditional execution.
10751
10752 This switch is mainly for debugging the compiler and will likely be removed
10753 in a future version.
10754
10755 @item -mvliw-branch
10756 @opindex mvliw-branch
10757
10758 Run a pass to pack branches into VLIW instructions (default).
10759
10760 This switch is mainly for debugging the compiler and will likely be removed
10761 in a future version.
10762
10763 @item -mno-vliw-branch
10764 @opindex mno-vliw-branch
10765
10766 Do not run a pass to pack branches into VLIW instructions.
10767
10768 This switch is mainly for debugging the compiler and will likely be removed
10769 in a future version.
10770
10771 @item -mmulti-cond-exec
10772 @opindex mmulti-cond-exec
10773
10774 Enable optimization of @code{&&} and @code{||} in conditional execution
10775 (default).
10776
10777 This switch is mainly for debugging the compiler and will likely be removed
10778 in a future version.
10779
10780 @item -mno-multi-cond-exec
10781 @opindex mno-multi-cond-exec
10782
10783 Disable optimization of @code{&&} and @code{||} in conditional execution.
10784
10785 This switch is mainly for debugging the compiler and will likely be removed
10786 in a future version.
10787
10788 @item -mnested-cond-exec
10789 @opindex mnested-cond-exec
10790
10791 Enable nested conditional execution optimizations (default).
10792
10793 This switch is mainly for debugging the compiler and will likely be removed
10794 in a future version.
10795
10796 @item -mno-nested-cond-exec
10797 @opindex mno-nested-cond-exec
10798
10799 Disable nested conditional execution optimizations.
10800
10801 This switch is mainly for debugging the compiler and will likely be removed
10802 in a future version.
10803
10804 @item -mtomcat-stats
10805 @opindex mtomcat-stats
10806
10807 Cause gas to print out tomcat statistics.
10808
10809 @item -mcpu=@var{cpu}
10810 @opindex mcpu
10811
10812 Select the processor type for which to generate code. Possible values are
10813 @samp{simple}, @samp{tomcat}, @samp{fr500}, @samp{fr400}, @samp{fr300},
10814 @samp{frv}.
10815
10816 @end table
10817
10818 @node Xtensa Options
10819 @subsection Xtensa Options
10820 @cindex Xtensa Options
10821
10822 These options are supported for Xtensa targets:
10823
10824 @table @gcctabopt
10825 @item -mconst16
10826 @itemx -mno-const16
10827 @opindex mconst16
10828 @opindex mno-const16
10829 Enable or disable use of @code{CONST16} instructions for loading
10830 constant values. The @code{CONST16} instruction is currently not a
10831 standard option from Tensilica. When enabled, @code{CONST16}
10832 instructions are always used in place of the standard @code{L32R}
10833 instructions. The use of @code{CONST16} is enabled by default only if
10834 the @code{L32R} instruction is not available.
10835
10836 @item -mfused-madd
10837 @itemx -mno-fused-madd
10838 @opindex mfused-madd
10839 @opindex mno-fused-madd
10840 Enable or disable use of fused multiply/add and multiply/subtract
10841 instructions in the floating-point option. This has no effect if the
10842 floating-point option is not also enabled. Disabling fused multiply/add
10843 and multiply/subtract instructions forces the compiler to use separate
10844 instructions for the multiply and add/subtract operations. This may be
10845 desirable in some cases where strict IEEE 754-compliant results are
10846 required: the fused multiply add/subtract instructions do not round the
10847 intermediate result, thereby producing results with @emph{more} bits of
10848 precision than specified by the IEEE standard. Disabling fused multiply
10849 add/subtract instructions also ensures that the program output is not
10850 sensitive to the compiler's ability to combine multiply and add/subtract
10851 operations.
10852
10853 @item -mtext-section-literals
10854 @itemx -mno-text-section-literals
10855 @opindex mtext-section-literals
10856 @opindex mno-text-section-literals
10857 Control the treatment of literal pools. The default is
10858 @option{-mno-text-section-literals}, which places literals in a separate
10859 section in the output file. This allows the literal pool to be placed
10860 in a data RAM/ROM, and it also allows the linker to combine literal
10861 pools from separate object files to remove redundant literals and
10862 improve code size. With @option{-mtext-section-literals}, the literals
10863 are interspersed in the text section in order to keep them as close as
10864 possible to their references. This may be necessary for large assembly
10865 files.
10866
10867 @item -mtarget-align
10868 @itemx -mno-target-align
10869 @opindex mtarget-align
10870 @opindex mno-target-align
10871 When this option is enabled, GCC instructs the assembler to
10872 automatically align instructions to reduce branch penalties at the
10873 expense of some code density. The assembler attempts to widen density
10874 instructions to align branch targets and the instructions following call
10875 instructions. If there are not enough preceding safe density
10876 instructions to align a target, no widening will be performed. The
10877 default is @option{-mtarget-align}. These options do not affect the
10878 treatment of auto-aligned instructions like @code{LOOP}, which the
10879 assembler will always align, either by widening density instructions or
10880 by inserting no-op instructions.
10881
10882 @item -mlongcalls
10883 @itemx -mno-longcalls
10884 @opindex mlongcalls
10885 @opindex mno-longcalls
10886 When this option is enabled, GCC instructs the assembler to translate
10887 direct calls to indirect calls unless it can determine that the target
10888 of a direct call is in the range allowed by the call instruction. This
10889 translation typically occurs for calls to functions in other source
10890 files. Specifically, the assembler translates a direct @code{CALL}
10891 instruction into an @code{L32R} followed by a @code{CALLX} instruction.
10892 The default is @option{-mno-longcalls}. This option should be used in
10893 programs where the call target can potentially be out of range. This
10894 option is implemented in the assembler, not the compiler, so the
10895 assembly code generated by GCC will still show direct call
10896 instructions---look at the disassembled object code to see the actual
10897 instructions. Note that the assembler will use an indirect call for
10898 every cross-file call, not just those that really will be out of range.
10899 @end table
10900
10901 @node Code Gen Options
10902 @section Options for Code Generation Conventions
10903 @cindex code generation conventions
10904 @cindex options, code generation
10905 @cindex run-time options
10906
10907 These machine-independent options control the interface conventions
10908 used in code generation.
10909
10910 Most of them have both positive and negative forms; the negative form
10911 of @option{-ffoo} would be @option{-fno-foo}. In the table below, only
10912 one of the forms is listed---the one which is not the default. You
10913 can figure out the other form by either removing @samp{no-} or adding
10914 it.
10915
10916 @table @gcctabopt
10917 @item -fbounds-check
10918 @opindex fbounds-check
10919 For front-ends that support it, generate additional code to check that
10920 indices used to access arrays are within the declared range. This is
10921 currently only supported by the Java and Fortran 77 front-ends, where
10922 this option defaults to true and false respectively.
10923
10924 @item -ftrapv
10925 @opindex ftrapv
10926 This option generates traps for signed overflow on addition, subtraction,
10927 multiplication operations.
10928
10929 @item -fwrapv
10930 @opindex fwrapv
10931 This option instructs the compiler to assume that signed arithmetic
10932 overflow of addition, subtraction and multiplication wraps around
10933 using twos-complement representation. This flag enables some optimizations
10934 and disables other. This option is enabled by default for the Java
10935 front-end, as required by the Java language specification.
10936
10937 @item -fexceptions
10938 @opindex fexceptions
10939 Enable exception handling. Generates extra code needed to propagate
10940 exceptions. For some targets, this implies GCC will generate frame
10941 unwind information for all functions, which can produce significant data
10942 size overhead, although it does not affect execution. If you do not
10943 specify this option, GCC will enable it by default for languages like
10944 C++ which normally require exception handling, and disable it for
10945 languages like C that do not normally require it. However, you may need
10946 to enable this option when compiling C code that needs to interoperate
10947 properly with exception handlers written in C++. You may also wish to
10948 disable this option if you are compiling older C++ programs that don't
10949 use exception handling.
10950
10951 @item -fnon-call-exceptions
10952 @opindex fnon-call-exceptions
10953 Generate code that allows trapping instructions to throw exceptions.
10954 Note that this requires platform-specific runtime support that does
10955 not exist everywhere. Moreover, it only allows @emph{trapping}
10956 instructions to throw exceptions, i.e.@: memory references or floating
10957 point instructions. It does not allow exceptions to be thrown from
10958 arbitrary signal handlers such as @code{SIGALRM}.
10959
10960 @item -funwind-tables
10961 @opindex funwind-tables
10962 Similar to @option{-fexceptions}, except that it will just generate any needed
10963 static data, but will not affect the generated code in any other way.
10964 You will normally not enable this option; instead, a language processor
10965 that needs this handling would enable it on your behalf.
10966
10967 @item -fasynchronous-unwind-tables
10968 @opindex funwind-tables
10969 Generate unwind table in dwarf2 format, if supported by target machine. The
10970 table is exact at each instruction boundary, so it can be used for stack
10971 unwinding from asynchronous events (such as debugger or garbage collector).
10972
10973 @item -fpcc-struct-return
10974 @opindex fpcc-struct-return
10975 Return ``short'' @code{struct} and @code{union} values in memory like
10976 longer ones, rather than in registers. This convention is less
10977 efficient, but it has the advantage of allowing intercallability between
10978 GCC-compiled files and files compiled with other compilers, particularly
10979 the Portable C Compiler (pcc).
10980
10981 The precise convention for returning structures in memory depends
10982 on the target configuration macros.
10983
10984 Short structures and unions are those whose size and alignment match
10985 that of some integer type.
10986
10987 @strong{Warning:} code compiled with the @option{-fpcc-struct-return}
10988 switch is not binary compatible with code compiled with the
10989 @option{-freg-struct-return} switch.
10990 Use it to conform to a non-default application binary interface.
10991
10992 @item -freg-struct-return
10993 @opindex freg-struct-return
10994 Return @code{struct} and @code{union} values in registers when possible.
10995 This is more efficient for small structures than
10996 @option{-fpcc-struct-return}.
10997
10998 If you specify neither @option{-fpcc-struct-return} nor
10999 @option{-freg-struct-return}, GCC defaults to whichever convention is
11000 standard for the target. If there is no standard convention, GCC
11001 defaults to @option{-fpcc-struct-return}, except on targets where GCC is
11002 the principal compiler. In those cases, we can choose the standard, and
11003 we chose the more efficient register return alternative.
11004
11005 @strong{Warning:} code compiled with the @option{-freg-struct-return}
11006 switch is not binary compatible with code compiled with the
11007 @option{-fpcc-struct-return} switch.
11008 Use it to conform to a non-default application binary interface.
11009
11010 @item -fshort-enums
11011 @opindex fshort-enums
11012 Allocate to an @code{enum} type only as many bytes as it needs for the
11013 declared range of possible values. Specifically, the @code{enum} type
11014 will be equivalent to the smallest integer type which has enough room.
11015
11016 @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
11017 code that is not binary compatible with code generated without that switch.
11018 Use it to conform to a non-default application binary interface.
11019
11020 @item -fshort-double
11021 @opindex fshort-double
11022 Use the same size for @code{double} as for @code{float}.
11023
11024 @strong{Warning:} the @option{-fshort-double} switch causes GCC to generate
11025 code that is not binary compatible with code generated without that switch.
11026 Use it to conform to a non-default application binary interface.
11027
11028 @item -fshort-wchar
11029 @opindex fshort-wchar
11030 Override the underlying type for @samp{wchar_t} to be @samp{short
11031 unsigned int} instead of the default for the target. This option is
11032 useful for building programs to run under WINE@.
11033
11034 @strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
11035 code that is not binary compatible with code generated without that switch.
11036 Use it to conform to a non-default application binary interface.
11037
11038 @item -fshared-data
11039 @opindex fshared-data
11040 Requests that the data and non-@code{const} variables of this
11041 compilation be shared data rather than private data. The distinction
11042 makes sense only on certain operating systems, where shared data is
11043 shared between processes running the same program, while private data
11044 exists in one copy per process.
11045
11046 @item -fno-common
11047 @opindex fno-common
11048 In C, allocate even uninitialized global variables in the data section of the
11049 object file, rather than generating them as common blocks. This has the
11050 effect that if the same variable is declared (without @code{extern}) in
11051 two different compilations, you will get an error when you link them.
11052 The only reason this might be useful is if you wish to verify that the
11053 program will work on other systems which always work this way.
11054
11055 @item -fno-ident
11056 @opindex fno-ident
11057 Ignore the @samp{#ident} directive.
11058
11059 @item -finhibit-size-directive
11060 @opindex finhibit-size-directive
11061 Don't output a @code{.size} assembler directive, or anything else that
11062 would cause trouble if the function is split in the middle, and the
11063 two halves are placed at locations far apart in memory. This option is
11064 used when compiling @file{crtstuff.c}; you should not need to use it
11065 for anything else.
11066
11067 @item -fverbose-asm
11068 @opindex fverbose-asm
11069 Put extra commentary information in the generated assembly code to
11070 make it more readable. This option is generally only of use to those
11071 who actually need to read the generated assembly code (perhaps while
11072 debugging the compiler itself).
11073
11074 @option{-fno-verbose-asm}, the default, causes the
11075 extra information to be omitted and is useful when comparing two assembler
11076 files.
11077
11078 @item -fpic
11079 @opindex fpic
11080 @cindex global offset table
11081 @cindex PIC
11082 Generate position-independent code (PIC) suitable for use in a shared
11083 library, if supported for the target machine. Such code accesses all
11084 constant addresses through a global offset table (GOT)@. The dynamic
11085 loader resolves the GOT entries when the program starts (the dynamic
11086 loader is not part of GCC; it is part of the operating system). If
11087 the GOT size for the linked executable exceeds a machine-specific
11088 maximum size, you get an error message from the linker indicating that
11089 @option{-fpic} does not work; in that case, recompile with @option{-fPIC}
11090 instead. (These maximums are 8k on the SPARC and 32k
11091 on the m68k and RS/6000. The 386 has no such limit.)
11092
11093 Position-independent code requires special support, and therefore works
11094 only on certain machines. For the 386, GCC supports PIC for System V
11095 but not for the Sun 386i. Code generated for the IBM RS/6000 is always
11096 position-independent.
11097
11098 @item -fPIC
11099 @opindex fPIC
11100 If supported for the target machine, emit position-independent code,
11101 suitable for dynamic linking and avoiding any limit on the size of the
11102 global offset table. This option makes a difference on the m68k
11103 and the SPARC.
11104
11105 Position-independent code requires special support, and therefore works
11106 only on certain machines.
11107
11108 @item -fpie
11109 @itemx -fPIE
11110 @opindex fpie
11111 @opindex fPIE
11112 These options are similar to @option{-fpic} and @option{-fPIC}, but
11113 generated position independent code can be only linked into executables.
11114 Usually these options are used when @option{-pie} GCC option will be
11115 used during linking.
11116
11117 @item -ffixed-@var{reg}
11118 @opindex ffixed
11119 Treat the register named @var{reg} as a fixed register; generated code
11120 should never refer to it (except perhaps as a stack pointer, frame
11121 pointer or in some other fixed role).
11122
11123 @var{reg} must be the name of a register. The register names accepted
11124 are machine-specific and are defined in the @code{REGISTER_NAMES}
11125 macro in the machine description macro file.
11126
11127 This flag does not have a negative form, because it specifies a
11128 three-way choice.
11129
11130 @item -fcall-used-@var{reg}
11131 @opindex fcall-used
11132 Treat the register named @var{reg} as an allocable register that is
11133 clobbered by function calls. It may be allocated for temporaries or
11134 variables that do not live across a call. Functions compiled this way
11135 will not save and restore the register @var{reg}.
11136
11137 It is an error to used this flag with the frame pointer or stack pointer.
11138 Use of this flag for other registers that have fixed pervasive roles in
11139 the machine's execution model will produce disastrous results.
11140
11141 This flag does not have a negative form, because it specifies a
11142 three-way choice.
11143
11144 @item -fcall-saved-@var{reg}
11145 @opindex fcall-saved
11146 Treat the register named @var{reg} as an allocable register saved by
11147 functions. It may be allocated even for temporaries or variables that
11148 live across a call. Functions compiled this way will save and restore
11149 the register @var{reg} if they use it.
11150
11151 It is an error to used this flag with the frame pointer or stack pointer.
11152 Use of this flag for other registers that have fixed pervasive roles in
11153 the machine's execution model will produce disastrous results.
11154
11155 A different sort of disaster will result from the use of this flag for
11156 a register in which function values may be returned.
11157
11158 This flag does not have a negative form, because it specifies a
11159 three-way choice.
11160
11161 @item -fpack-struct
11162 @opindex fpack-struct
11163 Pack all structure members together without holes.
11164
11165 @strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
11166 code that is not binary compatible with code generated without that switch.
11167 Additionally, it makes the code suboptimal.
11168 Use it to conform to a non-default application binary interface.
11169
11170 @item -finstrument-functions
11171 @opindex finstrument-functions
11172 Generate instrumentation calls for entry and exit to functions. Just
11173 after function entry and just before function exit, the following
11174 profiling functions will be called with the address of the current
11175 function and its call site. (On some platforms,
11176 @code{__builtin_return_address} does not work beyond the current
11177 function, so the call site information may not be available to the
11178 profiling functions otherwise.)
11179
11180 @smallexample
11181 void __cyg_profile_func_enter (void *this_fn,
11182 void *call_site);
11183 void __cyg_profile_func_exit (void *this_fn,
11184 void *call_site);
11185 @end smallexample
11186
11187 The first argument is the address of the start of the current function,
11188 which may be looked up exactly in the symbol table.
11189
11190 This instrumentation is also done for functions expanded inline in other
11191 functions. The profiling calls will indicate where, conceptually, the
11192 inline function is entered and exited. This means that addressable
11193 versions of such functions must be available. If all your uses of a
11194 function are expanded inline, this may mean an additional expansion of
11195 code size. If you use @samp{extern inline} in your C code, an
11196 addressable version of such functions must be provided. (This is
11197 normally the case anyways, but if you get lucky and the optimizer always
11198 expands the functions inline, you might have gotten away without
11199 providing static copies.)
11200
11201 A function may be given the attribute @code{no_instrument_function}, in
11202 which case this instrumentation will not be done. This can be used, for
11203 example, for the profiling functions listed above, high-priority
11204 interrupt routines, and any functions from which the profiling functions
11205 cannot safely be called (perhaps signal handlers, if the profiling
11206 routines generate output or allocate memory).
11207
11208 @item -fstack-check
11209 @opindex fstack-check
11210 Generate code to verify that you do not go beyond the boundary of the
11211 stack. You should specify this flag if you are running in an
11212 environment with multiple threads, but only rarely need to specify it in
11213 a single-threaded environment since stack overflow is automatically
11214 detected on nearly all systems if there is only one stack.
11215
11216 Note that this switch does not actually cause checking to be done; the
11217 operating system must do that. The switch causes generation of code
11218 to ensure that the operating system sees the stack being extended.
11219
11220 @item -fstack-limit-register=@var{reg}
11221 @itemx -fstack-limit-symbol=@var{sym}
11222 @itemx -fno-stack-limit
11223 @opindex fstack-limit-register
11224 @opindex fstack-limit-symbol
11225 @opindex fno-stack-limit
11226 Generate code to ensure that the stack does not grow beyond a certain value,
11227 either the value of a register or the address of a symbol. If the stack
11228 would grow beyond the value, a signal is raised. For most targets,
11229 the signal is raised before the stack overruns the boundary, so
11230 it is possible to catch the signal without taking special precautions.
11231
11232 For instance, if the stack starts at absolute address @samp{0x80000000}
11233 and grows downwards, you can use the flags
11234 @option{-fstack-limit-symbol=__stack_limit} and
11235 @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
11236 of 128KB@. Note that this may only work with the GNU linker.
11237
11238 @cindex aliasing of parameters
11239 @cindex parameters, aliased
11240 @item -fargument-alias
11241 @itemx -fargument-noalias
11242 @itemx -fargument-noalias-global
11243 @opindex fargument-alias
11244 @opindex fargument-noalias
11245 @opindex fargument-noalias-global
11246 Specify the possible relationships among parameters and between
11247 parameters and global data.
11248
11249 @option{-fargument-alias} specifies that arguments (parameters) may
11250 alias each other and may alias global storage.@*
11251 @option{-fargument-noalias} specifies that arguments do not alias
11252 each other, but may alias global storage.@*
11253 @option{-fargument-noalias-global} specifies that arguments do not
11254 alias each other and do not alias global storage.
11255
11256 Each language will automatically use whatever option is required by
11257 the language standard. You should not need to use these options yourself.
11258
11259 @item -fleading-underscore
11260 @opindex fleading-underscore
11261 This option and its counterpart, @option{-fno-leading-underscore}, forcibly
11262 change the way C symbols are represented in the object file. One use
11263 is to help link with legacy assembly code.
11264
11265 @strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
11266 generate code that is not binary compatible with code generated without that
11267 switch. Use it to conform to a non-default application binary interface.
11268 Not all targets provide complete support for this switch.
11269
11270 @item -ftls-model=@var{model}
11271 Alter the thread-local storage model to be used (@pxref{Thread-Local}).
11272 The @var{model} argument should be one of @code{global-dynamic},
11273 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
11274
11275 The default without @option{-fpic} is @code{initial-exec}; with
11276 @option{-fpic} the default is @code{global-dynamic}.
11277 @end table
11278
11279 @c man end
11280
11281 @node Environment Variables
11282 @section Environment Variables Affecting GCC
11283 @cindex environment variables
11284
11285 @c man begin ENVIRONMENT
11286 This section describes several environment variables that affect how GCC
11287 operates. Some of them work by specifying directories or prefixes to use
11288 when searching for various kinds of files. Some are used to specify other
11289 aspects of the compilation environment.
11290
11291 Note that you can also specify places to search using options such as
11292 @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
11293 take precedence over places specified using environment variables, which
11294 in turn take precedence over those specified by the configuration of GCC@.
11295 @xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
11296 GNU Compiler Collection (GCC) Internals}.
11297
11298 @table @env
11299 @item LANG
11300 @itemx LC_CTYPE
11301 @c @itemx LC_COLLATE
11302 @itemx LC_MESSAGES
11303 @c @itemx LC_MONETARY
11304 @c @itemx LC_NUMERIC
11305 @c @itemx LC_TIME
11306 @itemx LC_ALL
11307 @findex LANG
11308 @findex LC_CTYPE
11309 @c @findex LC_COLLATE
11310 @findex LC_MESSAGES
11311 @c @findex LC_MONETARY
11312 @c @findex LC_NUMERIC
11313 @c @findex LC_TIME
11314 @findex LC_ALL
11315 @cindex locale
11316 These environment variables control the way that GCC uses
11317 localization information that allow GCC to work with different
11318 national conventions. GCC inspects the locale categories
11319 @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
11320 so. These locale categories can be set to any value supported by your
11321 installation. A typical value is @samp{en_UK} for English in the United
11322 Kingdom.
11323
11324 The @env{LC_CTYPE} environment variable specifies character
11325 classification. GCC uses it to determine the character boundaries in
11326 a string; this is needed for some multibyte encodings that contain quote
11327 and escape characters that would otherwise be interpreted as a string
11328 end or escape.
11329
11330 The @env{LC_MESSAGES} environment variable specifies the language to
11331 use in diagnostic messages.
11332
11333 If the @env{LC_ALL} environment variable is set, it overrides the value
11334 of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
11335 and @env{LC_MESSAGES} default to the value of the @env{LANG}
11336 environment variable. If none of these variables are set, GCC
11337 defaults to traditional C English behavior.
11338
11339 @item TMPDIR
11340 @findex TMPDIR
11341 If @env{TMPDIR} is set, it specifies the directory to use for temporary
11342 files. GCC uses temporary files to hold the output of one stage of
11343 compilation which is to be used as input to the next stage: for example,
11344 the output of the preprocessor, which is the input to the compiler
11345 proper.
11346
11347 @item GCC_EXEC_PREFIX
11348 @findex GCC_EXEC_PREFIX
11349 If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
11350 names of the subprograms executed by the compiler. No slash is added
11351 when this prefix is combined with the name of a subprogram, but you can
11352 specify a prefix that ends with a slash if you wish.
11353
11354 If @env{GCC_EXEC_PREFIX} is not set, GCC will attempt to figure out
11355 an appropriate prefix to use based on the pathname it was invoked with.
11356
11357 If GCC cannot find the subprogram using the specified prefix, it
11358 tries looking in the usual places for the subprogram.
11359
11360 The default value of @env{GCC_EXEC_PREFIX} is
11361 @file{@var{prefix}/lib/gcc/} where @var{prefix} is the value
11362 of @code{prefix} when you ran the @file{configure} script.
11363
11364 Other prefixes specified with @option{-B} take precedence over this prefix.
11365
11366 This prefix is also used for finding files such as @file{crt0.o} that are
11367 used for linking.
11368
11369 In addition, the prefix is used in an unusual way in finding the
11370 directories to search for header files. For each of the standard
11371 directories whose name normally begins with @samp{/usr/local/lib/gcc}
11372 (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
11373 replacing that beginning with the specified prefix to produce an
11374 alternate directory name. Thus, with @option{-Bfoo/}, GCC will search
11375 @file{foo/bar} where it would normally search @file{/usr/local/lib/bar}.
11376 These alternate directories are searched first; the standard directories
11377 come next.
11378
11379 @item COMPILER_PATH
11380 @findex COMPILER_PATH
11381 The value of @env{COMPILER_PATH} is a colon-separated list of
11382 directories, much like @env{PATH}. GCC tries the directories thus
11383 specified when searching for subprograms, if it can't find the
11384 subprograms using @env{GCC_EXEC_PREFIX}.
11385
11386 @item LIBRARY_PATH
11387 @findex LIBRARY_PATH
11388 The value of @env{LIBRARY_PATH} is a colon-separated list of
11389 directories, much like @env{PATH}. When configured as a native compiler,
11390 GCC tries the directories thus specified when searching for special
11391 linker files, if it can't find them using @env{GCC_EXEC_PREFIX}. Linking
11392 using GCC also uses these directories when searching for ordinary
11393 libraries for the @option{-l} option (but directories specified with
11394 @option{-L} come first).
11395
11396 @item LANG
11397 @findex LANG
11398 @cindex locale definition
11399 This variable is used to pass locale information to the compiler. One way in
11400 which this information is used is to determine the character set to be used
11401 when character literals, string literals and comments are parsed in C and C++.
11402 When the compiler is configured to allow multibyte characters,
11403 the following values for @env{LANG} are recognized:
11404
11405 @table @samp
11406 @item C-JIS
11407 Recognize JIS characters.
11408 @item C-SJIS
11409 Recognize SJIS characters.
11410 @item C-EUCJP
11411 Recognize EUCJP characters.
11412 @end table
11413
11414 If @env{LANG} is not defined, or if it has some other value, then the
11415 compiler will use mblen and mbtowc as defined by the default locale to
11416 recognize and translate multibyte characters.
11417 @end table
11418
11419 @noindent
11420 Some additional environments variables affect the behavior of the
11421 preprocessor.
11422
11423 @include cppenv.texi
11424
11425 @c man end
11426
11427 @node Precompiled Headers
11428 @section Using Precompiled Headers
11429 @cindex precompiled headers
11430 @cindex speed of compilation
11431
11432 Often large projects have many header files that are included in every
11433 source file. The time the compiler takes to process these header files
11434 over and over again can account for nearly all of the time required to
11435 build the project. To make builds faster, GCC allows users to
11436 `precompile' a header file; then, if builds can use the precompiled
11437 header file they will be much faster.
11438
11439 @strong{Caution:} There are a few known situations where GCC will
11440 crash when trying to use a precompiled header. If you have trouble
11441 with a precompiled header, you should remove the precompiled header
11442 and compile without it. In addition, please use GCC's on-line
11443 defect-tracking system to report any problems you encounter with
11444 precompiled headers. @xref{Bugs}.
11445
11446 To create a precompiled header file, simply compile it as you would any
11447 other file, if necessary using the @option{-x} option to make the driver
11448 treat it as a C or C++ header file. You will probably want to use a
11449 tool like @command{make} to keep the precompiled header up-to-date when
11450 the headers it contains change.
11451
11452 A precompiled header file will be searched for when @code{#include} is
11453 seen in the compilation. As it searches for the included file
11454 (@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
11455 compiler looks for a precompiled header in each directory just before it
11456 looks for the include file in that directory. The name searched for is
11457 the name specified in the @code{#include} with @samp{.gch} appended. If
11458 the precompiled header file can't be used, it is ignored.
11459
11460 For instance, if you have @code{#include "all.h"}, and you have
11461 @file{all.h.gch} in the same directory as @file{all.h}, then the
11462 precompiled header file will be used if possible, and the original
11463 header will be used otherwise.
11464
11465 Alternatively, you might decide to put the precompiled header file in a
11466 directory and use @option{-I} to ensure that directory is searched
11467 before (or instead of) the directory containing the original header.
11468 Then, if you want to check that the precompiled header file is always
11469 used, you can put a file of the same name as the original header in this
11470 directory containing an @code{#error} command.
11471
11472 This also works with @option{-include}. So yet another way to use
11473 precompiled headers, good for projects not designed with precompiled
11474 header files in mind, is to simply take most of the header files used by
11475 a project, include them from another header file, precompile that header
11476 file, and @option{-include} the precompiled header. If the header files
11477 have guards against multiple inclusion, they will be skipped because
11478 they've already been included (in the precompiled header).
11479
11480 If you need to precompile the same header file for different
11481 languages, targets, or compiler options, you can instead make a
11482 @emph{directory} named like @file{all.h.gch}, and put each precompiled
11483 header in the directory, perhaps using @option{-o}. It doesn't matter
11484 what you call the files in the directory, every precompiled header in
11485 the directory will be considered. The first precompiled header
11486 encountered in the directory that is valid for this compilation will
11487 be used; they're searched in no particular order.
11488
11489 There are many other possibilities, limited only by your imagination,
11490 good sense, and the constraints of your build system.
11491
11492 A precompiled header file can be used only when these conditions apply:
11493
11494 @itemize
11495 @item
11496 Only one precompiled header can be used in a particular compilation.
11497
11498 @item
11499 A precompiled header can't be used once the first C token is seen. You
11500 can have preprocessor directives before a precompiled header; you can
11501 even include a precompiled header from inside another header, so long as
11502 there are no C tokens before the @code{#include}.
11503
11504 @item
11505 The precompiled header file must be produced for the same language as
11506 the current compilation. You can't use a C precompiled header for a C++
11507 compilation.
11508
11509 @item
11510 The precompiled header file must be produced by the same compiler
11511 version and configuration as the current compilation is using.
11512 The easiest way to guarantee this is to use the same compiler binary
11513 for creating and using precompiled headers.
11514
11515 @item
11516 Any macros defined before the precompiled header is included must
11517 either be defined in the same way as when the precompiled header was
11518 generated, or must not affect the precompiled header, which usually
11519 means that the they don't appear in the precompiled header at all.
11520
11521 The @option{-D} option is one way to define a macro before a
11522 precompiled header is included; using a @code{#define} can also do it.
11523 There are also some options that define macros implicitly, like
11524 @option{-O} and @option{-Wdeprecated}; the same rule applies to macros
11525 defined this way.
11526
11527 @item If debugging information is output when using the precompiled
11528 header, using @option{-g} or similar, the same kind of debugging information
11529 must have been output when building the precompiled header. However,
11530 a precompiled header built using @option{-g} can be used in a compilation
11531 when no debugging information is being output.
11532
11533 @item The same @option{-m} options must generally be used when building
11534 and using the precompiled header. @xref{Submodel Options},
11535 for any cases where this rule is relaxed.
11536
11537 @item Each of the following options must be the same when building and using
11538 the precompiled header:
11539
11540 @gccoptlist{-fexceptions -funit-at-a-time}
11541
11542 @item
11543 Some other command-line options starting with @option{-f},
11544 @option{-p}, or @option{-O} must be defined in the same way as when
11545 the precompiled header was generated. At present, it's not clear
11546 which options are safe to change and which are not; the safest choice
11547 is to use exactly the same options when generating and using the
11548 precompiled header. The following are known to be safe:
11549
11550 @gccoptlist{-pedantic-errors}
11551
11552 @end itemize
11553
11554 For all of these except the last, the compiler will automatically
11555 ignore the precompiled header if the conditions aren't met. If you
11556 find an option combination that doesn't work and doesn't cause the
11557 precompiled header to be ignored, please consider filing a bug report,
11558 see @ref{Bugs}.
11559
11560 @node Running Protoize
11561 @section Running Protoize
11562
11563 The program @code{protoize} is an optional part of GCC@. You can use
11564 it to add prototypes to a program, thus converting the program to ISO
11565 C in one respect. The companion program @code{unprotoize} does the
11566 reverse: it removes argument types from any prototypes that are found.
11567
11568 When you run these programs, you must specify a set of source files as
11569 command line arguments. The conversion programs start out by compiling
11570 these files to see what functions they define. The information gathered
11571 about a file @var{foo} is saved in a file named @file{@var{foo}.X}.
11572
11573 After scanning comes actual conversion. The specified files are all
11574 eligible to be converted; any files they include (whether sources or
11575 just headers) are eligible as well.
11576
11577 But not all the eligible files are converted. By default,
11578 @code{protoize} and @code{unprotoize} convert only source and header
11579 files in the current directory. You can specify additional directories
11580 whose files should be converted with the @option{-d @var{directory}}
11581 option. You can also specify particular files to exclude with the
11582 @option{-x @var{file}} option. A file is converted if it is eligible, its
11583 directory name matches one of the specified directory names, and its
11584 name within the directory has not been excluded.
11585
11586 Basic conversion with @code{protoize} consists of rewriting most
11587 function definitions and function declarations to specify the types of
11588 the arguments. The only ones not rewritten are those for varargs
11589 functions.
11590
11591 @code{protoize} optionally inserts prototype declarations at the
11592 beginning of the source file, to make them available for any calls that
11593 precede the function's definition. Or it can insert prototype
11594 declarations with block scope in the blocks where undeclared functions
11595 are called.
11596
11597 Basic conversion with @code{unprotoize} consists of rewriting most
11598 function declarations to remove any argument types, and rewriting
11599 function definitions to the old-style pre-ISO form.
11600
11601 Both conversion programs print a warning for any function declaration or
11602 definition that they can't convert. You can suppress these warnings
11603 with @option{-q}.
11604
11605 The output from @code{protoize} or @code{unprotoize} replaces the
11606 original source file. The original file is renamed to a name ending
11607 with @samp{.save} (for DOS, the saved filename ends in @samp{.sav}
11608 without the original @samp{.c} suffix). If the @samp{.save} (@samp{.sav}
11609 for DOS) file already exists, then the source file is simply discarded.
11610
11611 @code{protoize} and @code{unprotoize} both depend on GCC itself to
11612 scan the program and collect information about the functions it uses.
11613 So neither of these programs will work until GCC is installed.
11614
11615 Here is a table of the options you can use with @code{protoize} and
11616 @code{unprotoize}. Each option works with both programs unless
11617 otherwise stated.
11618
11619 @table @code
11620 @item -B @var{directory}
11621 Look for the file @file{SYSCALLS.c.X} in @var{directory}, instead of the
11622 usual directory (normally @file{/usr/local/lib}). This file contains
11623 prototype information about standard system functions. This option
11624 applies only to @code{protoize}.
11625
11626 @item -c @var{compilation-options}
11627 Use @var{compilation-options} as the options when running @command{gcc} to
11628 produce the @samp{.X} files. The special option @option{-aux-info} is
11629 always passed in addition, to tell @command{gcc} to write a @samp{.X} file.
11630
11631 Note that the compilation options must be given as a single argument to
11632 @code{protoize} or @code{unprotoize}. If you want to specify several
11633 @command{gcc} options, you must quote the entire set of compilation options
11634 to make them a single word in the shell.
11635
11636 There are certain @command{gcc} arguments that you cannot use, because they
11637 would produce the wrong kind of output. These include @option{-g},
11638 @option{-O}, @option{-c}, @option{-S}, and @option{-o} If you include these in
11639 the @var{compilation-options}, they are ignored.
11640
11641 @item -C
11642 Rename files to end in @samp{.C} (@samp{.cc} for DOS-based file
11643 systems) instead of @samp{.c}. This is convenient if you are converting
11644 a C program to C++. This option applies only to @code{protoize}.
11645
11646 @item -g
11647 Add explicit global declarations. This means inserting explicit
11648 declarations at the beginning of each source file for each function
11649 that is called in the file and was not declared. These declarations
11650 precede the first function definition that contains a call to an
11651 undeclared function. This option applies only to @code{protoize}.
11652
11653 @item -i @var{string}
11654 Indent old-style parameter declarations with the string @var{string}.
11655 This option applies only to @code{protoize}.
11656
11657 @code{unprotoize} converts prototyped function definitions to old-style
11658 function definitions, where the arguments are declared between the
11659 argument list and the initial @samp{@{}. By default, @code{unprotoize}
11660 uses five spaces as the indentation. If you want to indent with just
11661 one space instead, use @option{-i " "}.
11662
11663 @item -k
11664 Keep the @samp{.X} files. Normally, they are deleted after conversion
11665 is finished.
11666
11667 @item -l
11668 Add explicit local declarations. @code{protoize} with @option{-l} inserts
11669 a prototype declaration for each function in each block which calls the
11670 function without any declaration. This option applies only to
11671 @code{protoize}.
11672
11673 @item -n
11674 Make no real changes. This mode just prints information about the conversions
11675 that would have been done without @option{-n}.
11676
11677 @item -N
11678 Make no @samp{.save} files. The original files are simply deleted.
11679 Use this option with caution.
11680
11681 @item -p @var{program}
11682 Use the program @var{program} as the compiler. Normally, the name
11683 @file{gcc} is used.
11684
11685 @item -q
11686 Work quietly. Most warnings are suppressed.
11687
11688 @item -v
11689 Print the version number, just like @option{-v} for @command{gcc}.
11690 @end table
11691
11692 If you need special compiler options to compile one of your program's
11693 source files, then you should generate that file's @samp{.X} file
11694 specially, by running @command{gcc} on that source file with the
11695 appropriate options and the option @option{-aux-info}. Then run
11696 @code{protoize} on the entire set of files. @code{protoize} will use
11697 the existing @samp{.X} file because it is newer than the source file.
11698 For example:
11699
11700 @smallexample
11701 gcc -Dfoo=bar file1.c -aux-info file1.X
11702 protoize *.c
11703 @end smallexample
11704
11705 @noindent
11706 You need to include the special files along with the rest in the
11707 @code{protoize} command, even though their @samp{.X} files already
11708 exist, because otherwise they won't get converted.
11709
11710 @xref{Protoize Caveats}, for more information on how to use
11711 @code{protoize} successfully.