mips-protos.h (enum mips_symbol_type): Move from mips.h.
[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} -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 -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 @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 -floop-optimize @gol
274 -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-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} -I- -L@var{dir} -specs=@var{file}}
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 -mapcs-26 -mapcs-32 @gol
372 -mapcs-stack-check -mno-apcs-stack-check @gol
373 -mapcs-float -mno-apcs-float @gol
374 -mapcs-reentrant -mno-apcs-reentrant @gol
375 -msched-prolog -mno-sched-prolog @gol
376 -mlittle-endian -mbig-endian -mwords-little-endian @gol
377 -malignment-traps -mno-alignment-traps @gol
378 -mfloat-abi=@var{name} soft-float -mhard-float -mfpe @gol
379 -mthumb-interwork -mno-thumb-interwork @gol
380 -mcpu=@var{name} -march=@var{name} -mfpu=@var{name} @gol
381 -mstructure-size-boundary=@var{n} @gol
382 -mabort-on-noreturn @gol
383 -mlong-calls -mno-long-calls @gol
384 -msingle-pic-base -mno-single-pic-base @gol
385 -mpic-register=@var{reg} @gol
386 -mnop-fun-dllimport @gol
387 -mcirrus-fix-invalid-insns -mno-cirrus-fix-invalid-insns @gol
388 -mpoke-function-name @gol
389 -mthumb -marm @gol
390 -mtpcs-frame -mtpcs-leaf-frame @gol
391 -mcaller-super-interworking -mcallee-super-interworking}
392
393 @emph{MN10300 Options}
394 @gccoptlist{-mmult-bug -mno-mult-bug @gol
395 -mam33 -mno-am33 @gol
396 -mam33-2 -mno-am33-2 @gol
397 -mno-crt0 -mrelax}
398
399 @emph{M32R/D Options}
400 @gccoptlist{-m32r2 -m32rx -m32r @gol
401 -mdebug @gol
402 -malign-loops -mno-align-loops @gol
403 -missue-rate=@var{number} @gol
404 -mbranch-cost=@var{number} @gol
405 -mmodel=@var{code-size-model-type} @gol
406 -msdata=@var{sdata-type} @gol
407 -mno-flush-func -mflush-func=@var{name} @gol
408 -mno-flush-trap -mflush-trap=@var{number} @gol
409 -G @var{num}}
410
411 @emph{RS/6000 and PowerPC Options}
412 @gccoptlist{-mcpu=@var{cpu-type} @gol
413 -mtune=@var{cpu-type} @gol
414 -mpower -mno-power -mpower2 -mno-power2 @gol
415 -mpowerpc -mpowerpc64 -mno-powerpc @gol
416 -maltivec -mno-altivec @gol
417 -mpowerpc-gpopt -mno-powerpc-gpopt @gol
418 -mpowerpc-gfxopt -mno-powerpc-gfxopt @gol
419 -mnew-mnemonics -mold-mnemonics @gol
420 -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc @gol
421 -m64 -m32 -mxl-call -mno-xl-call -mpe @gol
422 -malign-power -malign-natural @gol
423 -msoft-float -mhard-float -mmultiple -mno-multiple @gol
424 -mstring -mno-string -mupdate -mno-update @gol
425 -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol
426 -mstrict-align -mno-strict-align -mrelocatable @gol
427 -mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol
428 -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol
429 -mdynamic-no-pic @gol
430 -mprioritize-restricted-insns=@var{priority} @gol
431 -msched-costly-dep=@var{dependence_type} @gol
432 -minsert-sched-nops=@var{scheme} @gol
433 -mcall-sysv -mcall-netbsd @gol
434 -maix-struct-return -msvr4-struct-return @gol
435 -mabi=altivec -mabi=no-altivec @gol
436 -mabi=spe -mabi=no-spe @gol
437 -misel=yes -misel=no @gol
438 -mspe=yes -mspe=no @gol
439 -mfloat-gprs=yes -mfloat-gprs=no @gol
440 -mprototype -mno-prototype @gol
441 -msim -mmvme -mads -myellowknife -memb -msdata @gol
442 -msdata=@var{opt} -mvxworks -mwindiss -G @var{num} -pthread}
443
444 @emph{Darwin Options}
445 @gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal @gol
446 -arch_only -bind_at_load -bundle -bundle_loader @gol
447 -client_name -compatibility_version -current_version @gol
448 -dependency-file -dylib_file -dylinker_install_name @gol
449 -dynamic -dynamiclib -exported_symbols_list @gol
450 -filelist -flat_namespace -force_cpusubtype_ALL @gol
451 -force_flat_namespace -headerpad_max_install_names @gol
452 -image_base -init -install_name -keep_private_externs @gol
453 -multi_module -multiply_defined -multiply_defined_unused @gol
454 -noall_load -nofixprebinding -nomultidefs -noprebind -noseglinkedit @gol
455 -pagezero_size -prebind -prebind_all_twolevel_modules @gol
456 -private_bundle -read_only_relocs -sectalign @gol
457 -sectobjectsymbols -whyload -seg1addr @gol
458 -sectcreate -sectobjectsymbols -sectorder @gol
459 -seg_addr_table -seg_addr_table_filename -seglinkedit @gol
460 -segprot -segs_read_only_addr -segs_read_write_addr @gol
461 -single_module -static -sub_library -sub_umbrella @gol
462 -twolevel_namespace -umbrella -undefined @gol
463 -unexported_symbols_list -weak_reference_mismatches @gol
464 -whatsloaded}
465
466 @emph{MIPS Options}
467 @gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} @gol
468 -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips64 @gol
469 -mips16 -mno-mips16 -mabi=@var{abi} -mabicalls -mno-abicalls @gol
470 -mxgot -mno-xgot -membedded-pic -mno-embedded-pic @gol
471 -mgp32 -mgp64 -mfp32 -mfp64 -mhard-float -msoft-float @gol
472 -msingle-float -mdouble-float -mint64 -mlong64 -mlong32 @gol
473 -G@var{num} -membedded-data -mno-embedded-data @gol
474 -muninit-const-in-rodata -mno-uninit-const-in-rodata @gol
475 -msplit-addresses -mno-split-addresses @gol
476 -mexplicit-relocs -mno-explicit-relocs @gol
477 -mrnames -mno-rnames @gol
478 -mcheck-zero-division -mno-check-zero-division @gol
479 -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls @gol
480 -mmad -mno-mad -mfused-madd -mno-fused-madd -nocpp @gol
481 -mfix-r4000 -mno-fix-r4000 -mfix-sb1 -mno-fix-sb1 @gol
482 -mflush-func=@var{func} -mno-flush-func @gol
483 -mbranch-likely -mno-branch-likely}
484
485 @emph{i386 and x86-64 Options}
486 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
487 -mfpmath=@var{unit} @gol
488 -masm=@var{dialect} -mno-fancy-math-387 @gol
489 -mno-fp-ret-in-387 -msoft-float -msvr3-shlib @gol
490 -mno-wide-multiply -mrtd -malign-double @gol
491 -mpreferred-stack-boundary=@var{num} @gol
492 -mmmx -msse -msse2 -msse3 -m3dnow @gol
493 -mthreads -mno-align-stringops -minline-all-stringops @gol
494 -mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
495 -m96bit-long-double -mregparm=@var{num} -momit-leaf-frame-pointer @gol
496 -mno-red-zone -mno-tls-direct-seg-refs @gol
497 -mcmodel=@var{code-model} @gol
498 -m32 -m64}
499
500 @emph{HPPA Options}
501 @gccoptlist{-march=@var{architecture-type} @gol
502 -mbig-switch -mdisable-fpregs -mdisable-indexing @gol
503 -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld @gol
504 -mjump-in-delay -mlinker-opt -mlong-calls @gol
505 -mlong-load-store -mno-big-switch -mno-disable-fpregs @gol
506 -mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol
507 -mno-jump-in-delay -mno-long-load-store @gol
508 -mno-portable-runtime -mno-soft-float @gol
509 -mno-space-regs -msoft-float -mpa-risc-1-0 @gol
510 -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol
511 -mschedule=@var{cpu-type} -mspace-regs -msio -mwsio @gol
512 -nolibdld -static -threads}
513
514 @emph{DEC Alpha Options}
515 @gccoptlist{-mno-fp-regs -msoft-float -malpha-as -mgas @gol
516 -mieee -mieee-with-inexact -mieee-conformant @gol
517 -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} @gol
518 -mtrap-precision=@var{mode} -mbuild-constants @gol
519 -mcpu=@var{cpu-type} -mtune=@var{cpu-type} @gol
520 -mbwx -mmax -mfix -mcix @gol
521 -mfloat-vax -mfloat-ieee @gol
522 -mexplicit-relocs -msmall-data -mlarge-data @gol
523 -msmall-text -mlarge-text @gol
524 -mmemory-latency=@var{time}}
525
526 @emph{DEC Alpha/VMS Options}
527 @gccoptlist{-mvms-return-codes}
528
529 @emph{H8/300 Options}
530 @gccoptlist{-mrelax -mh -ms -mn -mint32 -malign-300}
531
532 @emph{SH Options}
533 @gccoptlist{-m1 -m2 -m2e -m3 -m3e @gol
534 -m4-nofpu -m4-single-only -m4-single -m4 @gol
535 -m5-64media -m5-64media-nofpu @gol
536 -m5-32media -m5-32media-nofpu @gol
537 -m5-compact -m5-compact-nofpu @gol
538 -mb -ml -mdalign -mrelax @gol
539 -mbigtable -mfmovd -mhitachi -mnomacsave @gol
540 -mieee -misize -mpadstruct -mspace @gol
541 -mprefergot -musermode}
542
543 @emph{System V Options}
544 @gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
545
546 @emph{ARC Options}
547 @gccoptlist{-EB -EL @gol
548 -mmangle-cpu -mcpu=@var{cpu} -mtext=@var{text-section} @gol
549 -mdata=@var{data-section} -mrodata=@var{readonly-data-section}}
550
551 @emph{TMS320C3x/C4x Options}
552 @gccoptlist{-mcpu=@var{cpu} -mbig -msmall -mregparm -mmemparm @gol
553 -mfast-fix -mmpyi -mbk -mti -mdp-isr-reload @gol
554 -mrpts=@var{count} -mrptb -mdb -mloop-unsigned @gol
555 -mparallel-insns -mparallel-mpy -mpreserve-float}
556
557 @emph{V850 Options}
558 @gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep @gol
559 -mprolog-function -mno-prolog-function -mspace @gol
560 -mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol
561 -mapp-regs -mno-app-regs @gol
562 -mdisable-callt -mno-disable-callt @gol
563 -mv850e1 @gol
564 -mv850e @gol
565 -mv850 -mbig-switch}
566
567 @emph{NS32K Options}
568 @gccoptlist{-m32032 -m32332 -m32532 -m32081 -m32381 @gol
569 -mmult-add -mnomult-add -msoft-float -mrtd -mnortd @gol
570 -mregparam -mnoregparam -msb -mnosb @gol
571 -mbitfield -mnobitfield -mhimem -mnohimem}
572
573 @emph{AVR Options}
574 @gccoptlist{-mmcu=@var{mcu} -msize -minit-stack=@var{n} -mno-interrupts @gol
575 -mcall-prologues -mno-tablejump -mtiny-stack}
576
577 @emph{MCore Options}
578 @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol
579 -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol
580 -m4byte-functions -mno-4byte-functions -mcallgraph-data @gol
581 -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol
582 -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
583
584 @emph{MMIX Options}
585 @gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu @gol
586 -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols @gol
587 -melf -mbranch-predict -mno-branch-predict -mbase-addresses @gol
588 -mno-base-addresses -msingle-exit -mno-single-exit}
589
590 @emph{IA-64 Options}
591 @gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol
592 -mvolatile-asm-stop -mb-step -mregister-names -mno-sdata @gol
593 -mconstant-gp -mauto-pic -minline-float-divide-min-latency @gol
594 -minline-float-divide-max-throughput @gol
595 -minline-int-divide-min-latency @gol
596 -minline-int-divide-max-throughput -mno-dwarf2-asm @gol
597 -mfixed-range=@var{register-range}}
598
599 @emph{S/390 and zSeries Options}
600 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
601 -mhard-float -msoft-float -mbackchain -mno-backchain @gol
602 -msmall-exec -mno-small-exec -mmvcle -mno-mvcle @gol
603 -m64 -m31 -mdebug -mno-debug -mesa -mzarch -mfused-madd -mno-fused-madd}
604
605 @emph{CRIS Options}
606 @gccoptlist{-mcpu=@var{cpu} -march=@var{cpu} -mtune=@var{cpu} @gol
607 -mmax-stack-frame=@var{n} -melinux-stacksize=@var{n} @gol
608 -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects @gol
609 -mstack-align -mdata-align -mconst-align @gol
610 -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue -mno-gotplt @gol
611 -melf -maout -melinux -mlinux -sim -sim2}
612
613 @emph{PDP-11 Options}
614 @gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 @gol
615 -mbcopy -mbcopy-builtin -mint32 -mno-int16 @gol
616 -mint16 -mno-int32 -mfloat32 -mno-float64 @gol
617 -mfloat64 -mno-float32 -mabshi -mno-abshi @gol
618 -mbranch-expensive -mbranch-cheap @gol
619 -msplit -mno-split -munix-asm -mdec-asm}
620
621 @emph{Xstormy16 Options}
622 @gccoptlist{-msim}
623
624 @emph{Xtensa Options}
625 @gccoptlist{-mconst16 -mno-const16 @gol
626 -mfused-madd -mno-fused-madd @gol
627 -mtext-section-literals -mno-text-section-literals @gol
628 -mtarget-align -mno-target-align @gol
629 -mlongcalls -mno-longcalls}
630
631 @emph{FRV Options}
632 @gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 @gol
633 -mhard-float -msoft-float @gol
634 -malloc-cc -mfixed-cc -mdword -mno-dword @gol
635 -mdouble -mno-double @gol
636 -mmedia -mno-media -mmuladd -mno-muladd @gol
637 -mfdpic -minline-plt -mgprel-ro -multilib-library-pic -mlinked-fp @gol
638 -mlibrary-pic -macc-4 -macc-8 @gol
639 -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move @gol
640 -mscc -mno-scc -mcond-exec -mno-cond-exec @gol
641 -mvliw-branch -mno-vliw-branch @gol
642 -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec @gol
643 -mno-nested-cond-exec -mtomcat-stats @gol
644 -mcpu=@var{cpu}}
645
646 @item Code Generation Options
647 @xref{Code Gen Options,,Options for Code Generation Conventions}.
648 @gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} @gol
649 -ffixed-@var{reg} -fexceptions @gol
650 -fnon-call-exceptions -funwind-tables @gol
651 -fasynchronous-unwind-tables @gol
652 -finhibit-size-directive -finstrument-functions @gol
653 -fno-common -fno-ident @gol
654 -fpcc-struct-return -fpic -fPIC -fpie -fPIE @gol
655 -freg-struct-return -fshared-data -fshort-enums @gol
656 -fshort-double -fshort-wchar @gol
657 -fverbose-asm -fpack-struct -fstack-check @gol
658 -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol
659 -fargument-alias -fargument-noalias @gol
660 -fargument-noalias-global -fleading-underscore @gol
661 -ftls-model=@var{model} @gol
662 -ftrapv -fwrapv -fbounds-check}
663 @end table
664
665 @menu
666 * Overall Options:: Controlling the kind of output:
667 an executable, object files, assembler files,
668 or preprocessed source.
669 * C Dialect Options:: Controlling the variant of C language compiled.
670 * C++ Dialect Options:: Variations on C++.
671 * Objective-C Dialect Options:: Variations on Objective-C.
672 * Language Independent Options:: Controlling how diagnostics should be
673 formatted.
674 * Warning Options:: How picky should the compiler be?
675 * Debugging Options:: Symbol tables, measurements, and debugging dumps.
676 * Optimize Options:: How much optimization?
677 * Preprocessor Options:: Controlling header files and macro definitions.
678 Also, getting dependency information for Make.
679 * Assembler Options:: Passing options to the assembler.
680 * Link Options:: Specifying libraries and so on.
681 * Directory Options:: Where to find header files and libraries.
682 Where to find the compiler executable files.
683 * Spec Files:: How to pass switches to sub-processes.
684 * Target Options:: Running a cross-compiler, or an old version of GCC.
685 @end menu
686
687 @node Overall Options
688 @section Options Controlling the Kind of Output
689
690 Compilation can involve up to four stages: preprocessing, compilation
691 proper, assembly and linking, always in that order. GCC is capable of
692 preprocessing and compiling several files either into several
693 assembler input files, or into one assembler input file; then each
694 assembler input file produces an object file, and linking combines all
695 the object files (those newly compiled, and those specified as input)
696 into an executable file.
697
698 @cindex file name suffix
699 For any given input file, the file name suffix determines what kind of
700 compilation is done:
701
702 @table @gcctabopt
703 @item @var{file}.c
704 C source code which must be preprocessed.
705
706 @item @var{file}.i
707 C source code which should not be preprocessed.
708
709 @item @var{file}.ii
710 C++ source code which should not be preprocessed.
711
712 @item @var{file}.m
713 Objective-C source code. Note that you must link with the library
714 @file{libobjc.a} to make an Objective-C program work.
715
716 @item @var{file}.mi
717 Objective-C source code which should not be preprocessed.
718
719 @item @var{file}.h
720 C or C++ header file to be turned into a precompiled header.
721
722 @item @var{file}.cc
723 @itemx @var{file}.cp
724 @itemx @var{file}.cxx
725 @itemx @var{file}.cpp
726 @itemx @var{file}.CPP
727 @itemx @var{file}.c++
728 @itemx @var{file}.C
729 C++ source code which must be preprocessed. Note that in @samp{.cxx},
730 the last two letters must both be literally @samp{x}. Likewise,
731 @samp{.C} refers to a literal capital C@.
732
733 @item @var{file}.hh
734 @itemx @var{file}.H
735 C++ header file to be turned into a precompiled header.
736
737 @item @var{file}.f
738 @itemx @var{file}.for
739 @itemx @var{file}.FOR
740 Fortran source code which should not be preprocessed.
741
742 @item @var{file}.F
743 @itemx @var{file}.fpp
744 @itemx @var{file}.FPP
745 Fortran source code which must be preprocessed (with the traditional
746 preprocessor).
747
748 @item @var{file}.r
749 Fortran source code which must be preprocessed with a RATFOR
750 preprocessor (not included with GCC)@.
751
752 @xref{Overall Options,,Options Controlling the Kind of Output, g77,
753 Using and Porting GNU Fortran}, for more details of the handling of
754 Fortran input files.
755
756 @c FIXME: Descriptions of Java file types.
757 @c @var{file}.java
758 @c @var{file}.class
759 @c @var{file}.zip
760 @c @var{file}.jar
761
762 @item @var{file}.ads
763 Ada source code file which contains a library unit declaration (a
764 declaration of a package, subprogram, or generic, or a generic
765 instantiation), or a library unit renaming declaration (a package,
766 generic, or subprogram renaming declaration). Such files are also
767 called @dfn{specs}.
768
769 @itemx @var{file}.adb
770 Ada source code file containing a library unit body (a subprogram or
771 package body). Such files are also called @dfn{bodies}.
772
773 @c GCC also knows about some suffixes for languages not yet included:
774 @c Pascal:
775 @c @var{file}.p
776 @c @var{file}.pas
777
778 @item @var{file}.s
779 Assembler code.
780
781 @item @var{file}.S
782 Assembler code which must be preprocessed.
783
784 @item @var{other}
785 An object file to be fed straight into linking.
786 Any file name with no recognized suffix is treated this way.
787 @end table
788
789 @opindex x
790 You can specify the input language explicitly with the @option{-x} option:
791
792 @table @gcctabopt
793 @item -x @var{language}
794 Specify explicitly the @var{language} for the following input files
795 (rather than letting the compiler choose a default based on the file
796 name suffix). This option applies to all following input files until
797 the next @option{-x} option. Possible values for @var{language} are:
798 @smallexample
799 c c-header cpp-output
800 c++ c++-header c++-cpp-output
801 objective-c objective-c-header objc-cpp-output
802 assembler assembler-with-cpp
803 ada
804 f77 f77-cpp-input ratfor
805 java
806 treelang
807 @end smallexample
808
809 @item -x none
810 Turn off any specification of a language, so that subsequent files are
811 handled according to their file name suffixes (as they are if @option{-x}
812 has not been used at all).
813
814 @item -pass-exit-codes
815 @opindex pass-exit-codes
816 Normally the @command{gcc} program will exit with the code of 1 if any
817 phase of the compiler returns a non-success return code. If you specify
818 @option{-pass-exit-codes}, the @command{gcc} program will instead return with
819 numerically highest error produced by any phase that returned an error
820 indication.
821 @end table
822
823 If you only want some of the stages of compilation, you can use
824 @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
825 one of the options @option{-c}, @option{-S}, or @option{-E} to say where
826 @command{gcc} is to stop. Note that some combinations (for example,
827 @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
828
829 @table @gcctabopt
830 @item -c
831 @opindex c
832 Compile or assemble the source files, but do not link. The linking
833 stage simply is not done. The ultimate output is in the form of an
834 object file for each source file.
835
836 By default, the object file name for a source file is made by replacing
837 the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
838
839 Unrecognized input files, not requiring compilation or assembly, are
840 ignored.
841
842 @item -S
843 @opindex S
844 Stop after the stage of compilation proper; do not assemble. The output
845 is in the form of an assembler code file for each non-assembler input
846 file specified.
847
848 By default, the assembler file name for a source file is made by
849 replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
850
851 Input files that don't require compilation are ignored.
852
853 @item -E
854 @opindex E
855 Stop after the preprocessing stage; do not run the compiler proper. The
856 output is in the form of preprocessed source code, which is sent to the
857 standard output.
858
859 Input files which don't require preprocessing are ignored.
860
861 @cindex output file option
862 @item -o @var{file}
863 @opindex o
864 Place output in file @var{file}. This applies regardless to whatever
865 sort of output is being produced, whether it be an executable file,
866 an object file, an assembler file or preprocessed C code.
867
868 If you specify @option{-o} when compiling more than one input file, or
869 you are producing an executable file as output, all the source files
870 on the command line will be compiled at once.
871
872 If @option{-o} is not specified, the default is to put an executable file
873 in @file{a.out}, the object file for @file{@var{source}.@var{suffix}} in
874 @file{@var{source}.o}, its assembler file in @file{@var{source}.s}, and
875 all preprocessed C source on standard output.
876
877 @item -v
878 @opindex v
879 Print (on standard error output) the commands executed to run the stages
880 of compilation. Also print the version number of the compiler driver
881 program and of the preprocessor and the compiler proper.
882
883 @item -###
884 @opindex ###
885 Like @option{-v} except the commands are not executed and all command
886 arguments are quoted. This is useful for shell scripts to capture the
887 driver-generated command lines.
888
889 @item -pipe
890 @opindex pipe
891 Use pipes rather than temporary files for communication between the
892 various stages of compilation. This fails to work on some systems where
893 the assembler is unable to read from a pipe; but the GNU assembler has
894 no trouble.
895
896 @item --help
897 @opindex help
898 Print (on the standard output) a description of the command line options
899 understood by @command{gcc}. If the @option{-v} option is also specified
900 then @option{--help} will also be passed on to the various processes
901 invoked by @command{gcc}, so that they can display the command line options
902 they accept. If the @option{-Wextra} option is also specified then command
903 line options which have no documentation associated with them will also
904 be displayed.
905
906 @item --target-help
907 @opindex target-help
908 Print (on the standard output) a description of target specific command
909 line options for each tool.
910
911 @item --version
912 @opindex version
913 Display the version number and copyrights of the invoked GCC.
914 @end table
915
916 @node Invoking G++
917 @section Compiling C++ Programs
918
919 @cindex suffixes for C++ source
920 @cindex C++ source file suffixes
921 C++ source files conventionally use one of the suffixes @samp{.C},
922 @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
923 @samp{.cxx}; C++ header files often use @samp{.hh} or @samp{.H}; and
924 preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
925 files with these names and compiles them as C++ programs even if you
926 call the compiler the same way as for compiling C programs (usually
927 with the name @command{gcc}).
928
929 @findex g++
930 @findex c++
931 However, C++ programs often require class libraries as well as a
932 compiler that understands the C++ language---and under some
933 circumstances, you might want to compile programs or header files from
934 standard input, or otherwise without a suffix that flags them as C++
935 programs. You might also like to precompile a C header file with a
936 @samp{.h} extension to be used in C++ compilations. @command{g++} is a
937 program that calls GCC with the default language set to C++, and
938 automatically specifies linking against the C++ library. On many
939 systems, @command{g++} is also installed with the name @command{c++}.
940
941 @cindex invoking @command{g++}
942 When you compile C++ programs, you may specify many of the same
943 command-line options that you use for compiling programs in any
944 language; or command-line options meaningful for C and related
945 languages; or options that are meaningful only for C++ programs.
946 @xref{C Dialect Options,,Options Controlling C Dialect}, for
947 explanations of options for languages related to C@.
948 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
949 explanations of options that are meaningful only for C++ programs.
950
951 @node C Dialect Options
952 @section Options Controlling C Dialect
953 @cindex dialect options
954 @cindex language dialect options
955 @cindex options, dialect
956
957 The following options control the dialect of C (or languages derived
958 from C, such as C++ and Objective-C) that the compiler accepts:
959
960 @table @gcctabopt
961 @cindex ANSI support
962 @cindex ISO support
963 @item -ansi
964 @opindex ansi
965 In C mode, support all ISO C90 programs. In C++ mode,
966 remove GNU extensions that conflict with ISO C++.
967
968 This turns off certain features of GCC that are incompatible with ISO
969 C90 (when compiling C code), or of standard C++ (when compiling C++ code),
970 such as the @code{asm} and @code{typeof} keywords, and
971 predefined macros such as @code{unix} and @code{vax} that identify the
972 type of system you are using. It also enables the undesirable and
973 rarely used ISO trigraph feature. For the C compiler,
974 it disables recognition of C++ style @samp{//} comments as well as
975 the @code{inline} keyword.
976
977 The alternate keywords @code{__asm__}, @code{__extension__},
978 @code{__inline__} and @code{__typeof__} continue to work despite
979 @option{-ansi}. You would not want to use them in an ISO C program, of
980 course, but it is useful to put them in header files that might be included
981 in compilations done with @option{-ansi}. Alternate predefined macros
982 such as @code{__unix__} and @code{__vax__} are also available, with or
983 without @option{-ansi}.
984
985 The @option{-ansi} option does not cause non-ISO programs to be
986 rejected gratuitously. For that, @option{-pedantic} is required in
987 addition to @option{-ansi}. @xref{Warning Options}.
988
989 The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
990 option is used. Some header files may notice this macro and refrain
991 from declaring certain functions or defining certain macros that the
992 ISO standard doesn't call for; this is to avoid interfering with any
993 programs that might use these names for other things.
994
995 Functions which would normally be built in but do not have semantics
996 defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
997 functions with @option{-ansi} is used. @xref{Other Builtins,,Other
998 built-in functions provided by GCC}, for details of the functions
999 affected.
1000
1001 @item -std=
1002 @opindex std
1003 Determine the language standard. This option is currently only
1004 supported when compiling C or C++. A value for this option must be
1005 provided; possible values are
1006
1007 @table @samp
1008 @item c89
1009 @itemx iso9899:1990
1010 ISO C90 (same as @option{-ansi}).
1011
1012 @item iso9899:199409
1013 ISO C90 as modified in amendment 1.
1014
1015 @item c99
1016 @itemx c9x
1017 @itemx iso9899:1999
1018 @itemx iso9899:199x
1019 ISO C99. Note that this standard is not yet fully supported; see
1020 @w{@uref{http://gcc.gnu.org/c99status.html}} for more information. The
1021 names @samp{c9x} and @samp{iso9899:199x} are deprecated.
1022
1023 @item gnu89
1024 Default, ISO C90 plus GNU extensions (including some C99 features).
1025
1026 @item gnu99
1027 @itemx gnu9x
1028 ISO C99 plus GNU extensions. When ISO C99 is fully implemented in GCC,
1029 this will become the default. The name @samp{gnu9x} is deprecated.
1030
1031 @item c++98
1032 The 1998 ISO C++ standard plus amendments.
1033
1034 @item gnu++98
1035 The same as @option{-std=c++98} plus GNU extensions. This is the
1036 default for C++ code.
1037 @end table
1038
1039 Even when this option is not specified, you can still use some of the
1040 features of newer standards in so far as they do not conflict with
1041 previous C standards. For example, you may use @code{__restrict__} even
1042 when @option{-std=c99} is not specified.
1043
1044 The @option{-std} options specifying some version of ISO C have the same
1045 effects as @option{-ansi}, except that features that were not in ISO C90
1046 but are in the specified version (for example, @samp{//} comments and
1047 the @code{inline} keyword in ISO C99) are not disabled.
1048
1049 @xref{Standards,,Language Standards Supported by GCC}, for details of
1050 these standard versions.
1051
1052 @item -aux-info @var{filename}
1053 @opindex aux-info
1054 Output to the given filename prototyped declarations for all functions
1055 declared and/or defined in a translation unit, including those in header
1056 files. This option is silently ignored in any language other than C@.
1057
1058 Besides declarations, the file indicates, in comments, the origin of
1059 each declaration (source file and line), whether the declaration was
1060 implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
1061 @samp{O} for old, respectively, in the first character after the line
1062 number and the colon), and whether it came from a declaration or a
1063 definition (@samp{C} or @samp{F}, respectively, in the following
1064 character). In the case of function definitions, a K&R-style list of
1065 arguments followed by their declarations is also provided, inside
1066 comments, after the declaration.
1067
1068 @item -fno-asm
1069 @opindex fno-asm
1070 Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
1071 keyword, so that code can use these words as identifiers. You can use
1072 the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
1073 instead. @option{-ansi} implies @option{-fno-asm}.
1074
1075 In C++, this switch only affects the @code{typeof} keyword, since
1076 @code{asm} and @code{inline} are standard keywords. You may want to
1077 use the @option{-fno-gnu-keywords} flag instead, which has the same
1078 effect. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), this
1079 switch only affects the @code{asm} and @code{typeof} keywords, since
1080 @code{inline} is a standard keyword in ISO C99.
1081
1082 @item -fno-builtin
1083 @itemx -fno-builtin-@var{function}
1084 @opindex fno-builtin
1085 @cindex built-in functions
1086 Don't recognize built-in functions that do not begin with
1087 @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
1088 functions provided by GCC}, for details of the functions affected,
1089 including those which are not built-in functions when @option{-ansi} or
1090 @option{-std} options for strict ISO C conformance are used because they
1091 do not have an ISO standard meaning.
1092
1093 GCC normally generates special code to handle certain built-in functions
1094 more efficiently; for instance, calls to @code{alloca} may become single
1095 instructions that adjust the stack directly, and calls to @code{memcpy}
1096 may become inline copy loops. The resulting code is often both smaller
1097 and faster, but since the function calls no longer appear as such, you
1098 cannot set a breakpoint on those calls, nor can you change the behavior
1099 of the functions by linking with a different library.
1100
1101 With the @option{-fno-builtin-@var{function}} option
1102 only the built-in function @var{function} is
1103 disabled. @var{function} must not begin with @samp{__builtin_}. If a
1104 function is named this is not built-in in this version of GCC, this
1105 option is ignored. There is no corresponding
1106 @option{-fbuiltin-@var{function}} option; if you wish to enable
1107 built-in functions selectively when using @option{-fno-builtin} or
1108 @option{-ffreestanding}, you may define macros such as:
1109
1110 @smallexample
1111 #define abs(n) __builtin_abs ((n))
1112 #define strcpy(d, s) __builtin_strcpy ((d), (s))
1113 @end smallexample
1114
1115 @item -fhosted
1116 @opindex fhosted
1117 @cindex hosted environment
1118
1119 Assert that compilation takes place in a hosted environment. This implies
1120 @option{-fbuiltin}. A hosted environment is one in which the
1121 entire standard library is available, and in which @code{main} has a return
1122 type of @code{int}. Examples are nearly everything except a kernel.
1123 This is equivalent to @option{-fno-freestanding}.
1124
1125 @item -ffreestanding
1126 @opindex ffreestanding
1127 @cindex hosted environment
1128
1129 Assert that compilation takes place in a freestanding environment. This
1130 implies @option{-fno-builtin}. A freestanding environment
1131 is one in which the standard library may not exist, and program startup may
1132 not necessarily be at @code{main}. The most obvious example is an OS kernel.
1133 This is equivalent to @option{-fno-hosted}.
1134
1135 @xref{Standards,,Language Standards Supported by GCC}, for details of
1136 freestanding and hosted environments.
1137
1138 @item -fms-extensions
1139 @opindex fms-extensions
1140 Accept some non-standard constructs used in Microsoft header files.
1141
1142 @item -trigraphs
1143 @opindex trigraphs
1144 Support ISO C trigraphs. The @option{-ansi} option (and @option{-std}
1145 options for strict ISO C conformance) implies @option{-trigraphs}.
1146
1147 @item -no-integrated-cpp
1148 @opindex no-integrated-cpp
1149 Performs a compilation in two passes: preprocessing and compiling. This
1150 option allows a user supplied "cc1", "cc1plus", or "cc1obj" via the
1151 @option{-B} option. The user supplied compilation step can then add in
1152 an additional preprocessing step after normal preprocessing but before
1153 compiling. The default is to use the integrated cpp (internal cpp)
1154
1155 The semantics of this option will change if "cc1", "cc1plus", and
1156 "cc1obj" are merged.
1157
1158 @cindex traditional C language
1159 @cindex C language, traditional
1160 @item -traditional
1161 @itemx -traditional-cpp
1162 @opindex traditional-cpp
1163 @opindex traditional
1164 Formerly, these options caused GCC to attempt to emulate a pre-standard
1165 C compiler. They are now only supported with the @option{-E} switch.
1166 The preprocessor continues to support a pre-standard mode. See the GNU
1167 CPP manual for details.
1168
1169 @item -fcond-mismatch
1170 @opindex fcond-mismatch
1171 Allow conditional expressions with mismatched types in the second and
1172 third arguments. The value of such an expression is void. This option
1173 is not supported for C++.
1174
1175 @item -funsigned-char
1176 @opindex funsigned-char
1177 Let the type @code{char} be unsigned, like @code{unsigned char}.
1178
1179 Each kind of machine has a default for what @code{char} should
1180 be. It is either like @code{unsigned char} by default or like
1181 @code{signed char} by default.
1182
1183 Ideally, a portable program should always use @code{signed char} or
1184 @code{unsigned char} when it depends on the signedness of an object.
1185 But many programs have been written to use plain @code{char} and
1186 expect it to be signed, or expect it to be unsigned, depending on the
1187 machines they were written for. This option, and its inverse, let you
1188 make such a program work with the opposite default.
1189
1190 The type @code{char} is always a distinct type from each of
1191 @code{signed char} or @code{unsigned char}, even though its behavior
1192 is always just like one of those two.
1193
1194 @item -fsigned-char
1195 @opindex fsigned-char
1196 Let the type @code{char} be signed, like @code{signed char}.
1197
1198 Note that this is equivalent to @option{-fno-unsigned-char}, which is
1199 the negative form of @option{-funsigned-char}. Likewise, the option
1200 @option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
1201
1202 @item -fsigned-bitfields
1203 @itemx -funsigned-bitfields
1204 @itemx -fno-signed-bitfields
1205 @itemx -fno-unsigned-bitfields
1206 @opindex fsigned-bitfields
1207 @opindex funsigned-bitfields
1208 @opindex fno-signed-bitfields
1209 @opindex fno-unsigned-bitfields
1210 These options control whether a bit-field is signed or unsigned, when the
1211 declaration does not use either @code{signed} or @code{unsigned}. By
1212 default, such a bit-field is signed, because this is consistent: the
1213 basic integer types such as @code{int} are signed types.
1214 @end table
1215
1216 @node C++ Dialect Options
1217 @section Options Controlling C++ Dialect
1218
1219 @cindex compiler options, C++
1220 @cindex C++ options, command line
1221 @cindex options, C++
1222 This section describes the command-line options that are only meaningful
1223 for C++ programs; but you can also use most of the GNU compiler options
1224 regardless of what language your program is in. For example, you
1225 might compile a file @code{firstClass.C} like this:
1226
1227 @smallexample
1228 g++ -g -frepo -O -c firstClass.C
1229 @end smallexample
1230
1231 @noindent
1232 In this example, only @option{-frepo} is an option meant
1233 only for C++ programs; you can use the other options with any
1234 language supported by GCC@.
1235
1236 Here is a list of options that are @emph{only} for compiling C++ programs:
1237
1238 @table @gcctabopt
1239
1240 @item -fabi-version=@var{n}
1241 @opindex fabi-version
1242 Use version @var{n} of the C++ ABI. Version 2 is the version of the
1243 C++ ABI that first appeared in G++ 3.4. Version 1 is the version of
1244 the C++ ABI that first appeared in G++ 3.2. Version 0 will always be
1245 the version that conforms most closely to the C++ ABI specification.
1246 Therefore, the ABI obtained using version 0 will change as ABI bugs
1247 are fixed.
1248
1249 The default is version 2.
1250
1251 @item -fno-access-control
1252 @opindex fno-access-control
1253 Turn off all access checking. This switch is mainly useful for working
1254 around bugs in the access control code.
1255
1256 @item -fcheck-new
1257 @opindex fcheck-new
1258 Check that the pointer returned by @code{operator new} is non-null
1259 before attempting to modify the storage allocated. This check is
1260 normally unnecessary because the C++ standard specifies that
1261 @code{operator new} will only return @code{0} if it is declared
1262 @samp{throw()}, in which case the compiler will always check the
1263 return value even without this option. In all other cases, when
1264 @code{operator new} has a non-empty exception specification, memory
1265 exhaustion is signalled by throwing @code{std::bad_alloc}. See also
1266 @samp{new (nothrow)}.
1267
1268 @item -fconserve-space
1269 @opindex fconserve-space
1270 Put uninitialized or runtime-initialized global variables into the
1271 common segment, as C does. This saves space in the executable at the
1272 cost of not diagnosing duplicate definitions. If you compile with this
1273 flag and your program mysteriously crashes after @code{main()} has
1274 completed, you may have an object that is being destroyed twice because
1275 two definitions were merged.
1276
1277 This option is no longer useful on most targets, now that support has
1278 been added for putting variables into BSS without making them common.
1279
1280 @item -fno-const-strings
1281 @opindex fno-const-strings
1282 Give string constants type @code{char *} instead of type @code{const
1283 char *}. By default, G++ uses type @code{const char *} as required by
1284 the standard. Even if you use @option{-fno-const-strings}, you cannot
1285 actually modify the value of a string constant.
1286
1287 This option might be removed in a future release of G++. For maximum
1288 portability, you should structure your code so that it works with
1289 string constants that have type @code{const char *}.
1290
1291 @item -fno-elide-constructors
1292 @opindex fno-elide-constructors
1293 The C++ standard allows an implementation to omit creating a temporary
1294 which is only used to initialize another object of the same type.
1295 Specifying this option disables that optimization, and forces G++ to
1296 call the copy constructor in all cases.
1297
1298 @item -fno-enforce-eh-specs
1299 @opindex fno-enforce-eh-specs
1300 Don't check for violation of exception specifications at runtime. This
1301 option violates the C++ standard, but may be useful for reducing code
1302 size in production builds, much like defining @samp{NDEBUG}. The compiler
1303 will still optimize based on the exception specifications.
1304
1305 @item -ffor-scope
1306 @itemx -fno-for-scope
1307 @opindex ffor-scope
1308 @opindex fno-for-scope
1309 If @option{-ffor-scope} is specified, the scope of variables declared in
1310 a @i{for-init-statement} is limited to the @samp{for} loop itself,
1311 as specified by the C++ standard.
1312 If @option{-fno-for-scope} is specified, the scope of variables declared in
1313 a @i{for-init-statement} extends to the end of the enclosing scope,
1314 as was the case in old versions of G++, and other (traditional)
1315 implementations of C++.
1316
1317 The default if neither flag is given to follow the standard,
1318 but to allow and give a warning for old-style code that would
1319 otherwise be invalid, or have different behavior.
1320
1321 @item -fno-gnu-keywords
1322 @opindex fno-gnu-keywords
1323 Do not recognize @code{typeof} as a keyword, so that code can use this
1324 word as an identifier. You can use the keyword @code{__typeof__} instead.
1325 @option{-ansi} implies @option{-fno-gnu-keywords}.
1326
1327 @item -fno-implicit-templates
1328 @opindex fno-implicit-templates
1329 Never emit code for non-inline templates which are instantiated
1330 implicitly (i.e.@: by use); only emit code for explicit instantiations.
1331 @xref{Template Instantiation}, for more information.
1332
1333 @item -fno-implicit-inline-templates
1334 @opindex fno-implicit-inline-templates
1335 Don't emit code for implicit instantiations of inline templates, either.
1336 The default is to handle inlines differently so that compiles with and
1337 without optimization will need the same set of explicit instantiations.
1338
1339 @item -fno-implement-inlines
1340 @opindex fno-implement-inlines
1341 To save space, do not emit out-of-line copies of inline functions
1342 controlled by @samp{#pragma implementation}. This will cause linker
1343 errors if these functions are not inlined everywhere they are called.
1344
1345 @item -fms-extensions
1346 @opindex fms-extensions
1347 Disable pedantic warnings about constructs used in MFC, such as implicit
1348 int and getting a pointer to member function via non-standard syntax.
1349
1350 @item -fno-nonansi-builtins
1351 @opindex fno-nonansi-builtins
1352 Disable built-in declarations of functions that are not mandated by
1353 ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
1354 @code{index}, @code{bzero}, @code{conjf}, and other related functions.
1355
1356 @item -fno-operator-names
1357 @opindex fno-operator-names
1358 Do not treat the operator name keywords @code{and}, @code{bitand},
1359 @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
1360 synonyms as keywords.
1361
1362 @item -fno-optional-diags
1363 @opindex fno-optional-diags
1364 Disable diagnostics that the standard says a compiler does not need to
1365 issue. Currently, the only such diagnostic issued by G++ is the one for
1366 a name having multiple meanings within a class.
1367
1368 @item -fpermissive
1369 @opindex fpermissive
1370 Downgrade some diagnostics about nonconformant code from errors to
1371 warnings. Thus, using @option{-fpermissive} will allow some
1372 nonconforming code to compile.
1373
1374 @item -frepo
1375 @opindex frepo
1376 Enable automatic template instantiation at link time. This option also
1377 implies @option{-fno-implicit-templates}. @xref{Template
1378 Instantiation}, for more information.
1379
1380 @item -fno-rtti
1381 @opindex fno-rtti
1382 Disable generation of information about every class with virtual
1383 functions for use by the C++ runtime type identification features
1384 (@samp{dynamic_cast} and @samp{typeid}). If you don't use those parts
1385 of the language, you can save some space by using this flag. Note that
1386 exception handling uses the same information, but it will generate it as
1387 needed.
1388
1389 @item -fstats
1390 @opindex fstats
1391 Emit statistics about front-end processing at the end of the compilation.
1392 This information is generally only useful to the G++ development team.
1393
1394 @item -ftemplate-depth-@var{n}
1395 @opindex ftemplate-depth
1396 Set the maximum instantiation depth for template classes to @var{n}.
1397 A limit on the template instantiation depth is needed to detect
1398 endless recursions during template class instantiation. ANSI/ISO C++
1399 conforming programs must not rely on a maximum depth greater than 17.
1400
1401 @item -fuse-cxa-atexit
1402 @opindex fuse-cxa-atexit
1403 Register destructors for objects with static storage duration with the
1404 @code{__cxa_atexit} function rather than the @code{atexit} function.
1405 This option is required for fully standards-compliant handling of static
1406 destructors, but will only work if your C library supports
1407 @code{__cxa_atexit}.
1408
1409 @item -fno-weak
1410 @opindex fno-weak
1411 Do not use weak symbol support, even if it is provided by the linker.
1412 By default, G++ will use weak symbols if they are available. This
1413 option exists only for testing, and should not be used by end-users;
1414 it will result in inferior code and has no benefits. This option may
1415 be removed in a future release of G++.
1416
1417 @item -nostdinc++
1418 @opindex nostdinc++
1419 Do not search for header files in the standard directories specific to
1420 C++, but do still search the other standard directories. (This option
1421 is used when building the C++ library.)
1422 @end table
1423
1424 In addition, these optimization, warning, and code generation options
1425 have meanings only for C++ programs:
1426
1427 @table @gcctabopt
1428 @item -fno-default-inline
1429 @opindex fno-default-inline
1430 Do not assume @samp{inline} for functions defined inside a class scope.
1431 @xref{Optimize Options,,Options That Control Optimization}. Note that these
1432 functions will have linkage like inline functions; they just won't be
1433 inlined by default.
1434
1435 @item -Wabi @r{(C++ only)}
1436 @opindex Wabi
1437 Warn when G++ generates code that is probably not compatible with the
1438 vendor-neutral C++ ABI. Although an effort has been made to warn about
1439 all such cases, there are probably some cases that are not warned about,
1440 even though G++ is generating incompatible code. There may also be
1441 cases where warnings are emitted even though the code that is generated
1442 will be compatible.
1443
1444 You should rewrite your code to avoid these warnings if you are
1445 concerned about the fact that code generated by G++ may not be binary
1446 compatible with code generated by other compilers.
1447
1448 The known incompatibilities at this point include:
1449
1450 @itemize @bullet
1451
1452 @item
1453 Incorrect handling of tail-padding for bit-fields. G++ may attempt to
1454 pack data into the same byte as a base class. For example:
1455
1456 @smallexample
1457 struct A @{ virtual void f(); int f1 : 1; @};
1458 struct B : public A @{ int f2 : 1; @};
1459 @end smallexample
1460
1461 @noindent
1462 In this case, G++ will place @code{B::f2} into the same byte
1463 as@code{A::f1}; other compilers will not. You can avoid this problem
1464 by explicitly padding @code{A} so that its size is a multiple of the
1465 byte size on your platform; that will cause G++ and other compilers to
1466 layout @code{B} identically.
1467
1468 @item
1469 Incorrect handling of tail-padding for virtual bases. G++ does not use
1470 tail padding when laying out virtual bases. For example:
1471
1472 @smallexample
1473 struct A @{ virtual void f(); char c1; @};
1474 struct B @{ B(); char c2; @};
1475 struct C : public A, public virtual B @{@};
1476 @end smallexample
1477
1478 @noindent
1479 In this case, G++ will not place @code{B} into the tail-padding for
1480 @code{A}; other compilers will. You can avoid this problem by
1481 explicitly padding @code{A} so that its size is a multiple of its
1482 alignment (ignoring virtual base classes); that will cause G++ and other
1483 compilers to layout @code{C} identically.
1484
1485 @item
1486 Incorrect handling of bit-fields with declared widths greater than that
1487 of their underlying types, when the bit-fields appear in a union. For
1488 example:
1489
1490 @smallexample
1491 union U @{ int i : 4096; @};
1492 @end smallexample
1493
1494 @noindent
1495 Assuming that an @code{int} does not have 4096 bits, G++ will make the
1496 union too small by the number of bits in an @code{int}.
1497
1498 @item
1499 Empty classes can be placed at incorrect offsets. For example:
1500
1501 @smallexample
1502 struct A @{@};
1503
1504 struct B @{
1505 A a;
1506 virtual void f ();
1507 @};
1508
1509 struct C : public B, public A @{@};
1510 @end smallexample
1511
1512 @noindent
1513 G++ will place the @code{A} base class of @code{C} at a nonzero offset;
1514 it should be placed at offset zero. G++ mistakenly believes that the
1515 @code{A} data member of @code{B} is already at offset zero.
1516
1517 @item
1518 Names of template functions whose types involve @code{typename} or
1519 template template parameters can be mangled incorrectly.
1520
1521 @smallexample
1522 template <typename Q>
1523 void f(typename Q::X) @{@}
1524
1525 template <template <typename> class Q>
1526 void f(typename Q<int>::X) @{@}
1527 @end smallexample
1528
1529 @noindent
1530 Instantiations of these templates may be mangled incorrectly.
1531
1532 @end itemize
1533
1534 @item -Wctor-dtor-privacy @r{(C++ only)}
1535 @opindex Wctor-dtor-privacy
1536 Warn when a class seems unusable because all the constructors or
1537 destructors in that class are private, and it has neither friends nor
1538 public static member functions.
1539
1540 @item -Wnon-virtual-dtor @r{(C++ only)}
1541 @opindex Wnon-virtual-dtor
1542 Warn when a class appears to be polymorphic, thereby requiring a virtual
1543 destructor, yet it declares a non-virtual one.
1544 This warning is enabled by @option{-Wall}.
1545
1546 @item -Wreorder @r{(C++ only)}
1547 @opindex Wreorder
1548 @cindex reordering, warning
1549 @cindex warning for reordering of member initializers
1550 Warn when the order of member initializers given in the code does not
1551 match the order in which they must be executed. For instance:
1552
1553 @smallexample
1554 struct A @{
1555 int i;
1556 int j;
1557 A(): j (0), i (1) @{ @}
1558 @};
1559 @end smallexample
1560
1561 The compiler will rearrange the member initializers for @samp{i}
1562 and @samp{j} to match the declaration order of the members, emitting
1563 a warning to that effect. This warning is enabled by @option{-Wall}.
1564 @end table
1565
1566 The following @option{-W@dots{}} options are not affected by @option{-Wall}.
1567
1568 @table @gcctabopt
1569 @item -Weffc++ @r{(C++ only)}
1570 @opindex Weffc++
1571 Warn about violations of the following style guidelines from Scott Meyers'
1572 @cite{Effective C++} book:
1573
1574 @itemize @bullet
1575 @item
1576 Item 11: Define a copy constructor and an assignment operator for classes
1577 with dynamically allocated memory.
1578
1579 @item
1580 Item 12: Prefer initialization to assignment in constructors.
1581
1582 @item
1583 Item 14: Make destructors virtual in base classes.
1584
1585 @item
1586 Item 15: Have @code{operator=} return a reference to @code{*this}.
1587
1588 @item
1589 Item 23: Don't try to return a reference when you must return an object.
1590
1591 @end itemize
1592
1593 Also warn about violations of the following style guidelines from
1594 Scott Meyers' @cite{More Effective C++} book:
1595
1596 @itemize @bullet
1597 @item
1598 Item 6: Distinguish between prefix and postfix forms of increment and
1599 decrement operators.
1600
1601 @item
1602 Item 7: Never overload @code{&&}, @code{||}, or @code{,}.
1603
1604 @end itemize
1605
1606 When selecting this option, be aware that the standard library
1607 headers do not obey all of these guidelines; use @samp{grep -v}
1608 to filter out those warnings.
1609
1610 @item -Wno-deprecated @r{(C++ only)}
1611 @opindex Wno-deprecated
1612 Do not warn about usage of deprecated features. @xref{Deprecated Features}.
1613
1614 @item -Wno-non-template-friend @r{(C++ only)}
1615 @opindex Wno-non-template-friend
1616 Disable warnings when non-templatized friend functions are declared
1617 within a template. Since the advent of explicit template specification
1618 support in G++, if the name of the friend is an unqualified-id (i.e.,
1619 @samp{friend foo(int)}), the C++ language specification demands that the
1620 friend declare or define an ordinary, nontemplate function. (Section
1621 14.5.3). Before G++ implemented explicit specification, unqualified-ids
1622 could be interpreted as a particular specialization of a templatized
1623 function. Because this non-conforming behavior is no longer the default
1624 behavior for G++, @option{-Wnon-template-friend} allows the compiler to
1625 check existing code for potential trouble spots and is on by default.
1626 This new compiler behavior can be turned off with
1627 @option{-Wno-non-template-friend} which keeps the conformant compiler code
1628 but disables the helpful warning.
1629
1630 @item -Wold-style-cast @r{(C++ only)}
1631 @opindex Wold-style-cast
1632 Warn if an old-style (C-style) cast to a non-void type is used within
1633 a C++ program. The new-style casts (@samp{static_cast},
1634 @samp{reinterpret_cast}, and @samp{const_cast}) are less vulnerable to
1635 unintended effects and much easier to search for.
1636
1637 @item -Woverloaded-virtual @r{(C++ only)}
1638 @opindex Woverloaded-virtual
1639 @cindex overloaded virtual fn, warning
1640 @cindex warning for overloaded virtual fn
1641 Warn when a function declaration hides virtual functions from a
1642 base class. For example, in:
1643
1644 @smallexample
1645 struct A @{
1646 virtual void f();
1647 @};
1648
1649 struct B: public A @{
1650 void f(int);
1651 @};
1652 @end smallexample
1653
1654 the @code{A} class version of @code{f} is hidden in @code{B}, and code
1655 like:
1656
1657 @smallexample
1658 B* b;
1659 b->f();
1660 @end smallexample
1661
1662 will fail to compile.
1663
1664 @item -Wno-pmf-conversions @r{(C++ only)}
1665 @opindex Wno-pmf-conversions
1666 Disable the diagnostic for converting a bound pointer to member function
1667 to a plain pointer.
1668
1669 @item -Wsign-promo @r{(C++ only)}
1670 @opindex Wsign-promo
1671 Warn when overload resolution chooses a promotion from unsigned or
1672 enumeral type to a signed type, over a conversion to an unsigned type of
1673 the same size. Previous versions of G++ would try to preserve
1674 unsignedness, but the standard mandates the current behavior.
1675
1676 @item -Wsynth @r{(C++ only)}
1677 @opindex Wsynth
1678 @cindex warning for synthesized methods
1679 @cindex synthesized methods, warning
1680 Warn when G++'s synthesis behavior does not match that of cfront. For
1681 instance:
1682
1683 @smallexample
1684 struct A @{
1685 operator int ();
1686 A& operator = (int);
1687 @};
1688
1689 main ()
1690 @{
1691 A a,b;
1692 a = b;
1693 @}
1694 @end smallexample
1695
1696 In this example, G++ will synthesize a default @samp{A& operator =
1697 (const A&);}, while cfront will use the user-defined @samp{operator =}.
1698 @end table
1699
1700 @node Objective-C Dialect Options
1701 @section Options Controlling Objective-C Dialect
1702
1703 @cindex compiler options, Objective-C
1704 @cindex Objective-C options, command line
1705 @cindex options, Objective-C
1706 (NOTE: This manual does not describe the Objective-C language itself. See
1707 @w{@uref{http://gcc.gnu.org/readings.html}} for references.)
1708
1709 This section describes the command-line options that are only meaningful
1710 for Objective-C programs, but you can also use most of the GNU compiler
1711 options regardless of what language your program is in. For example,
1712 you might compile a file @code{some_class.m} like this:
1713
1714 @smallexample
1715 gcc -g -fgnu-runtime -O -c some_class.m
1716 @end smallexample
1717
1718 @noindent
1719 In this example, @option{-fgnu-runtime} is an option meant only for
1720 Objective-C programs; you can use the other options with any language
1721 supported by GCC@.
1722
1723 Here is a list of options that are @emph{only} for compiling Objective-C
1724 programs:
1725
1726 @table @gcctabopt
1727 @item -fconstant-string-class=@var{class-name}
1728 @opindex fconstant-string-class
1729 Use @var{class-name} as the name of the class to instantiate for each
1730 literal string specified with the syntax @code{@@"@dots{}"}. The default
1731 class name is @code{NXConstantString} if the GNU runtime is being used, and
1732 @code{NSConstantString} if the NeXT runtime is being used (see below). The
1733 @option{-fconstant-cfstrings} option, if also present, will override the
1734 @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals
1735 to be laid out as constant CoreFoundation strings.
1736
1737 @item -fgnu-runtime
1738 @opindex fgnu-runtime
1739 Generate object code compatible with the standard GNU Objective-C
1740 runtime. This is the default for most types of systems.
1741
1742 @item -fnext-runtime
1743 @opindex fnext-runtime
1744 Generate output compatible with the NeXT runtime. This is the default
1745 for NeXT-based systems, including Darwin and Mac OS X@. The macro
1746 @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
1747 used.
1748
1749 @item -fno-nil-receivers
1750 @opindex -fno-nil-receivers
1751 Assume that all Objective-C message dispatches (e.g.,
1752 @code{[receiver message:arg]}) in this translation unit ensure that the receiver
1753 is not @code{nil}. This allows for more efficient entry points in the runtime to be
1754 used. Currently, this option is only available in conjunction with
1755 the NeXT runtime on Mac OS X 10.3 and later.
1756
1757 @item -fobjc-exceptions
1758 @opindex -fobjc-exceptions
1759 Enable syntactic support for structured exception handling in Objective-C,
1760 similar to what is offered by C++ and Java. Currently, this option is only
1761 available in conjunction with the NeXT runtime on Mac OS X 10.3 and later.
1762
1763 @smallexample
1764 @@try @{
1765 @dots{}
1766 @@throw expr;
1767 @dots{}
1768 @}
1769 @@catch (AnObjCClass *exc) @{
1770 @dots{}
1771 @@throw expr;
1772 @dots{}
1773 @@throw;
1774 @dots{}
1775 @}
1776 @@catch (AnotherClass *exc) @{
1777 @dots{}
1778 @}
1779 @@catch (id allOthers) @{
1780 @dots{}
1781 @}
1782 @@finally @{
1783 @dots{}
1784 @@throw expr;
1785 @dots{}
1786 @}
1787 @end smallexample
1788
1789 The @code{@@throw} statement may appear anywhere in an Objective-C or
1790 Objective-C++ program; when used inside of a @code{@@catch} block, the
1791 @code{@@throw} may appear without an argument (as shown above), in which case
1792 the object caught by the @code{@@catch} will be rethrown.
1793
1794 Note that only (pointers to) Objective-C objects may be thrown and
1795 caught using this scheme. When an object is thrown, it will be caught
1796 by the nearest @code{@@catch} clause capable of handling objects of that type,
1797 analogously to how @code{catch} blocks work in C++ and Java. A
1798 @code{@@catch(id @dots{})} clause (as shown above) may also be provided to catch
1799 any and all Objective-C exceptions not caught by previous @code{@@catch}
1800 clauses (if any).
1801
1802 The @code{@@finally} clause, if present, will be executed upon exit from the
1803 immediately preceding @code{@@try @dots{} @@catch} section. This will happen
1804 regardless of whether any exceptions are thrown, caught or rethrown
1805 inside the @code{@@try @dots{} @@catch} section, analogously to the behavior
1806 of the @code{finally} clause in Java.
1807
1808 There are several caveats to using the new exception mechanism:
1809
1810 @itemize @bullet
1811 @item
1812 Although currently designed to be binary compatible with @code{NS_HANDLER}-style
1813 idioms provided by the @code{NSException} class, the new
1814 exceptions can only be used on Mac OS X 10.3 (Panther) and later
1815 systems, due to additional functionality needed in the (NeXT) Objective-C
1816 runtime.
1817
1818 @item
1819 As mentioned above, the new exceptions do not support handling
1820 types other than Objective-C objects. Furthermore, when used from
1821 Objective-C++, the Objective-C exception model does not interoperate with C++
1822 exceptions at this time. This means you cannot @code{@@throw} an exception
1823 from Objective-C and @code{catch} it in C++, or vice versa
1824 (i.e., @code{throw @dots{} @@catch}).
1825 @end itemize
1826
1827 The @option{-fobjc-exceptions} switch also enables the use of synchronization
1828 blocks for thread-safe execution:
1829
1830 @smallexample
1831 @@synchronized (ObjCClass *guard) @{
1832 @dots{}
1833 @}
1834 @end smallexample
1835
1836 Upon entering the @code{@@synchronized} block, a thread of execution shall
1837 first check whether a lock has been placed on the corresponding @code{guard}
1838 object by another thread. If it has, the current thread shall wait until
1839 the other thread relinquishes its lock. Once @code{guard} becomes available,
1840 the current thread will place its own lock on it, execute the code contained in
1841 the @code{@@synchronized} block, and finally relinquish the lock (thereby
1842 making @code{guard} available to other threads).
1843
1844 Unlike Java, Objective-C does not allow for entire methods to be marked
1845 @code{@@synchronized}. Note that throwing exceptions out of
1846 @code{@@synchronized} blocks is allowed, and will cause the guarding object
1847 to be unlocked properly.
1848
1849 @item -freplace-objc-classes
1850 @opindex -freplace-objc-classes
1851 Emit a special marker instructing @command{ld(1)} not to statically link in
1852 the resulting object file, and allow @command{dyld(1)} to load it in at
1853 run time instead. This is used in conjunction with the Fix-and-Continue
1854 debugging mode, where the object file in question may be recompiled and
1855 dynamically reloaded in the course of program execution, without the need
1856 to restart the program itself. Currently, Fix-and-Continue functionality
1857 is only available in conjunction with the NeXT runtime on Mac OS X 10.3
1858 and later.
1859
1860 @item -fzero-link
1861 @opindex -fzero-link
1862 When compiling for the NeXT runtime, the compiler ordinarily replaces calls
1863 to @code{objc_getClass("@dots{}")} (when the name of the class is known at
1864 compile time) with static class references that get initialized at load time,
1865 which improves run-time performance. Specifying the @option{-fzero-link} flag
1866 suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
1867 to be retained. This is useful in Zero-Link debugging mode, since it allows
1868 for individual class implementations to be modified during program execution.
1869
1870 @item -gen-decls
1871 @opindex gen-decls
1872 Dump interface declarations for all classes seen in the source file to a
1873 file named @file{@var{sourcename}.decl}.
1874
1875 @item -Wno-protocol
1876 @opindex Wno-protocol
1877 If a class is declared to implement a protocol, a warning is issued for
1878 every method in the protocol that is not implemented by the class. The
1879 default behavior is to issue a warning for every method not explicitly
1880 implemented in the class, even if a method implementation is inherited
1881 from the superclass. If you use the @code{-Wno-protocol} option, then
1882 methods inherited from the superclass are considered to be implemented,
1883 and no warning is issued for them.
1884
1885 @item -Wselector
1886 @opindex Wselector
1887 Warn if multiple methods of different types for the same selector are
1888 found during compilation. The check is performed on the list of methods
1889 in the final stage of compilation. Additionally, a check is performed
1890 for each selector appearing in a @code{@@selector(@dots{})}
1891 expression, and a corresponding method for that selector has been found
1892 during compilation. Because these checks scan the method table only at
1893 the end of compilation, these warnings are not produced if the final
1894 stage of compilation is not reached, for example because an error is
1895 found during compilation, or because the @code{-fsyntax-only} option is
1896 being used.
1897
1898 @item -Wundeclared-selector
1899 @opindex Wundeclared-selector
1900 Warn if a @code{@@selector(@dots{})} expression referring to an
1901 undeclared selector is found. A selector is considered undeclared if no
1902 method with that name has been declared before the
1903 @code{@@selector(@dots{})} expression, either explicitly in an
1904 @code{@@interface} or @code{@@protocol} declaration, or implicitly in
1905 an @code{@@implementation} section. This option always performs its
1906 checks as soon as a @code{@@selector(@dots{})} expression is found,
1907 while @code{-Wselector} only performs its checks in the final stage of
1908 compilation. This also enforces the coding style convention
1909 that methods and selectors must be declared before being used.
1910
1911 @item -print-objc-runtime-info
1912 @opindex -print-objc-runtime-info
1913 Generate C header describing the largest structure that is passed by
1914 value, if any.
1915
1916 @end table
1917
1918 @node Language Independent Options
1919 @section Options to Control Diagnostic Messages Formatting
1920 @cindex options to control diagnostics formatting
1921 @cindex diagnostic messages
1922 @cindex message formatting
1923
1924 Traditionally, diagnostic messages have been formatted irrespective of
1925 the output device's aspect (e.g.@: its width, @dots{}). The options described
1926 below can be used to control the diagnostic messages formatting
1927 algorithm, e.g.@: how many characters per line, how often source location
1928 information should be reported. Right now, only the C++ front end can
1929 honor these options. However it is expected, in the near future, that
1930 the remaining front ends would be able to digest them correctly.
1931
1932 @table @gcctabopt
1933 @item -fmessage-length=@var{n}
1934 @opindex fmessage-length
1935 Try to format error messages so that they fit on lines of about @var{n}
1936 characters. The default is 72 characters for @command{g++} and 0 for the rest of
1937 the front ends supported by GCC@. If @var{n} is zero, then no
1938 line-wrapping will be done; each error message will appear on a single
1939 line.
1940
1941 @opindex fdiagnostics-show-location
1942 @item -fdiagnostics-show-location=once
1943 Only meaningful in line-wrapping mode. Instructs the diagnostic messages
1944 reporter to emit @emph{once} source location information; that is, in
1945 case the message is too long to fit on a single physical line and has to
1946 be wrapped, the source location won't be emitted (as prefix) again,
1947 over and over, in subsequent continuation lines. This is the default
1948 behavior.
1949
1950 @item -fdiagnostics-show-location=every-line
1951 Only meaningful in line-wrapping mode. Instructs the diagnostic
1952 messages reporter to emit the same source location information (as
1953 prefix) for physical lines that result from the process of breaking
1954 a message which is too long to fit on a single line.
1955
1956 @end table
1957
1958 @node Warning Options
1959 @section Options to Request or Suppress Warnings
1960 @cindex options to control warnings
1961 @cindex warning messages
1962 @cindex messages, warning
1963 @cindex suppressing warnings
1964
1965 Warnings are diagnostic messages that report constructions which
1966 are not inherently erroneous but which are risky or suggest there
1967 may have been an error.
1968
1969 You can request many specific warnings with options beginning @samp{-W},
1970 for example @option{-Wimplicit} to request warnings on implicit
1971 declarations. Each of these specific warning options also has a
1972 negative form beginning @samp{-Wno-} to turn off warnings;
1973 for example, @option{-Wno-implicit}. This manual lists only one of the
1974 two forms, whichever is not the default.
1975
1976 The following options control the amount and kinds of warnings produced
1977 by GCC; for further, language-specific options also refer to
1978 @ref{C++ Dialect Options} and @ref{Objective-C Dialect Options}.
1979
1980 @table @gcctabopt
1981 @cindex syntax checking
1982 @item -fsyntax-only
1983 @opindex fsyntax-only
1984 Check the code for syntax errors, but don't do anything beyond that.
1985
1986 @item -pedantic
1987 @opindex pedantic
1988 Issue all the warnings demanded by strict ISO C and ISO C++;
1989 reject all programs that use forbidden extensions, and some other
1990 programs that do not follow ISO C and ISO C++. For ISO C, follows the
1991 version of the ISO C standard specified by any @option{-std} option used.
1992
1993 Valid ISO C and ISO C++ programs should compile properly with or without
1994 this option (though a rare few will require @option{-ansi} or a
1995 @option{-std} option specifying the required version of ISO C)@. However,
1996 without this option, certain GNU extensions and traditional C and C++
1997 features are supported as well. With this option, they are rejected.
1998
1999 @option{-pedantic} does not cause warning messages for use of the
2000 alternate keywords whose names begin and end with @samp{__}. Pedantic
2001 warnings are also disabled in the expression that follows
2002 @code{__extension__}. However, only system header files should use
2003 these escape routes; application programs should avoid them.
2004 @xref{Alternate Keywords}.
2005
2006 Some users try to use @option{-pedantic} to check programs for strict ISO
2007 C conformance. They soon find that it does not do quite what they want:
2008 it finds some non-ISO practices, but not all---only those for which
2009 ISO C @emph{requires} a diagnostic, and some others for which
2010 diagnostics have been added.
2011
2012 A feature to report any failure to conform to ISO C might be useful in
2013 some instances, but would require considerable additional work and would
2014 be quite different from @option{-pedantic}. We don't have plans to
2015 support such a feature in the near future.
2016
2017 Where the standard specified with @option{-std} represents a GNU
2018 extended dialect of C, such as @samp{gnu89} or @samp{gnu99}, there is a
2019 corresponding @dfn{base standard}, the version of ISO C on which the GNU
2020 extended dialect is based. Warnings from @option{-pedantic} are given
2021 where they are required by the base standard. (It would not make sense
2022 for such warnings to be given only for features not in the specified GNU
2023 C dialect, since by definition the GNU dialects of C include all
2024 features the compiler supports with the given option, and there would be
2025 nothing to warn about.)
2026
2027 @item -pedantic-errors
2028 @opindex pedantic-errors
2029 Like @option{-pedantic}, except that errors are produced rather than
2030 warnings.
2031
2032 @item -w
2033 @opindex w
2034 Inhibit all warning messages.
2035
2036 @item -Wno-import
2037 @opindex Wno-import
2038 Inhibit warning messages about the use of @samp{#import}.
2039
2040 @item -Wchar-subscripts
2041 @opindex Wchar-subscripts
2042 Warn if an array subscript has type @code{char}. This is a common cause
2043 of error, as programmers often forget that this type is signed on some
2044 machines.
2045
2046 @item -Wcomment
2047 @opindex Wcomment
2048 Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*}
2049 comment, or whenever a Backslash-Newline appears in a @samp{//} comment.
2050
2051 @item -Wformat
2052 @opindex Wformat
2053 Check calls to @code{printf} and @code{scanf}, etc., to make sure that
2054 the arguments supplied have types appropriate to the format string
2055 specified, and that the conversions specified in the format string make
2056 sense. This includes standard functions, and others specified by format
2057 attributes (@pxref{Function Attributes}), in the @code{printf},
2058 @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
2059 not in the C standard) families.
2060
2061 The formats are checked against the format features supported by GNU
2062 libc version 2.2. These include all ISO C90 and C99 features, as well
2063 as features from the Single Unix Specification and some BSD and GNU
2064 extensions. Other library implementations may not support all these
2065 features; GCC does not support warning about features that go beyond a
2066 particular library's limitations. However, if @option{-pedantic} is used
2067 with @option{-Wformat}, warnings will be given about format features not
2068 in the selected standard version (but not for @code{strfmon} formats,
2069 since those are not in any version of the C standard). @xref{C Dialect
2070 Options,,Options Controlling C Dialect}.
2071
2072 Since @option{-Wformat} also checks for null format arguments for
2073 several functions, @option{-Wformat} also implies @option{-Wnonnull}.
2074
2075 @option{-Wformat} is included in @option{-Wall}. For more control over some
2076 aspects of format checking, the options @option{-Wformat-y2k},
2077 @option{-Wno-format-extra-args}, @option{-Wno-format-zero-length},
2078 @option{-Wformat-nonliteral}, @option{-Wformat-security}, and
2079 @option{-Wformat=2} are available, but are not included in @option{-Wall}.
2080
2081 @item -Wformat-y2k
2082 @opindex Wformat-y2k
2083 If @option{-Wformat} is specified, also warn about @code{strftime}
2084 formats which may yield only a two-digit year.
2085
2086 @item -Wno-format-extra-args
2087 @opindex Wno-format-extra-args
2088 If @option{-Wformat} is specified, do not warn about excess arguments to a
2089 @code{printf} or @code{scanf} format function. The C standard specifies
2090 that such arguments are ignored.
2091
2092 Where the unused arguments lie between used arguments that are
2093 specified with @samp{$} operand number specifications, normally
2094 warnings are still given, since the implementation could not know what
2095 type to pass to @code{va_arg} to skip the unused arguments. However,
2096 in the case of @code{scanf} formats, this option will suppress the
2097 warning if the unused arguments are all pointers, since the Single
2098 Unix Specification says that such unused arguments are allowed.
2099
2100 @item -Wno-format-zero-length
2101 @opindex Wno-format-zero-length
2102 If @option{-Wformat} is specified, do not warn about zero-length formats.
2103 The C standard specifies that zero-length formats are allowed.
2104
2105 @item -Wformat-nonliteral
2106 @opindex Wformat-nonliteral
2107 If @option{-Wformat} is specified, also warn if the format string is not a
2108 string literal and so cannot be checked, unless the format function
2109 takes its format arguments as a @code{va_list}.
2110
2111 @item -Wformat-security
2112 @opindex Wformat-security
2113 If @option{-Wformat} is specified, also warn about uses of format
2114 functions that represent possible security problems. At present, this
2115 warns about calls to @code{printf} and @code{scanf} functions where the
2116 format string is not a string literal and there are no format arguments,
2117 as in @code{printf (foo);}. This may be a security hole if the format
2118 string came from untrusted input and contains @samp{%n}. (This is
2119 currently a subset of what @option{-Wformat-nonliteral} warns about, but
2120 in future warnings may be added to @option{-Wformat-security} that are not
2121 included in @option{-Wformat-nonliteral}.)
2122
2123 @item -Wformat=2
2124 @opindex Wformat=2
2125 Enable @option{-Wformat} plus format checks not included in
2126 @option{-Wformat}. Currently equivalent to @samp{-Wformat
2127 -Wformat-nonliteral -Wformat-security -Wformat-y2k}.
2128
2129 @item -Wnonnull
2130 @opindex Wnonnull
2131 Warn about passing a null pointer for arguments marked as
2132 requiring a non-null value by the @code{nonnull} function attribute.
2133
2134 @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
2135 can be disabled with the @option{-Wno-nonnull} option.
2136
2137 @item -Winit-self @r{(C, C++, and Objective-C only)}
2138 @opindex Winit-self
2139 Warn about uninitialized variables which are initialized with themselves.
2140 Note this option can only be used with the @option{-Wuninitialized} option,
2141 which in turn only works with @option{-O1} and above.
2142
2143 For example, GCC will warn about @code{i} being uninitialized in the
2144 following snippet only when @option{-Winit-self} has been specified:
2145 @smallexample
2146 @group
2147 int f()
2148 @{
2149 int i = i;
2150 return i;
2151 @}
2152 @end group
2153 @end smallexample
2154
2155 @item -Wimplicit-int
2156 @opindex Wimplicit-int
2157 Warn when a declaration does not specify a type.
2158
2159 @item -Wimplicit-function-declaration
2160 @itemx -Werror-implicit-function-declaration
2161 @opindex Wimplicit-function-declaration
2162 @opindex Werror-implicit-function-declaration
2163 Give a warning (or error) whenever a function is used before being
2164 declared.
2165
2166 @item -Wimplicit
2167 @opindex Wimplicit
2168 Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
2169
2170 @item -Wmain
2171 @opindex Wmain
2172 Warn if the type of @samp{main} is suspicious. @samp{main} should be a
2173 function with external linkage, returning int, taking either zero
2174 arguments, two, or three arguments of appropriate types.
2175
2176 @item -Wmissing-braces
2177 @opindex Wmissing-braces
2178 Warn if an aggregate or union initializer is not fully bracketed. In
2179 the following example, the initializer for @samp{a} is not fully
2180 bracketed, but that for @samp{b} is fully bracketed.
2181
2182 @smallexample
2183 int a[2][2] = @{ 0, 1, 2, 3 @};
2184 int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
2185 @end smallexample
2186
2187 @item -Wparentheses
2188 @opindex Wparentheses
2189 Warn if parentheses are omitted in certain contexts, such
2190 as when there is an assignment in a context where a truth value
2191 is expected, or when operators are nested whose precedence people
2192 often get confused about.
2193
2194 Also warn about constructions where there may be confusion to which
2195 @code{if} statement an @code{else} branch belongs. Here is an example of
2196 such a case:
2197
2198 @smallexample
2199 @group
2200 @{
2201 if (a)
2202 if (b)
2203 foo ();
2204 else
2205 bar ();
2206 @}
2207 @end group
2208 @end smallexample
2209
2210 In C, every @code{else} branch belongs to the innermost possible @code{if}
2211 statement, which in this example is @code{if (b)}. This is often not
2212 what the programmer expected, as illustrated in the above example by
2213 indentation the programmer chose. When there is the potential for this
2214 confusion, GCC will issue a warning when this flag is specified.
2215 To eliminate the warning, add explicit braces around the innermost
2216 @code{if} statement so there is no way the @code{else} could belong to
2217 the enclosing @code{if}. The resulting code would look like this:
2218
2219 @smallexample
2220 @group
2221 @{
2222 if (a)
2223 @{
2224 if (b)
2225 foo ();
2226 else
2227 bar ();
2228 @}
2229 @}
2230 @end group
2231 @end smallexample
2232
2233 @item -Wsequence-point
2234 @opindex Wsequence-point
2235 Warn about code that may have undefined semantics because of violations
2236 of sequence point rules in the C standard.
2237
2238 The C standard defines the order in which expressions in a C program are
2239 evaluated in terms of @dfn{sequence points}, which represent a partial
2240 ordering between the execution of parts of the program: those executed
2241 before the sequence point, and those executed after it. These occur
2242 after the evaluation of a full expression (one which is not part of a
2243 larger expression), after the evaluation of the first operand of a
2244 @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
2245 function is called (but after the evaluation of its arguments and the
2246 expression denoting the called function), and in certain other places.
2247 Other than as expressed by the sequence point rules, the order of
2248 evaluation of subexpressions of an expression is not specified. All
2249 these rules describe only a partial order rather than a total order,
2250 since, for example, if two functions are called within one expression
2251 with no sequence point between them, the order in which the functions
2252 are called is not specified. However, the standards committee have
2253 ruled that function calls do not overlap.
2254
2255 It is not specified when between sequence points modifications to the
2256 values of objects take effect. Programs whose behavior depends on this
2257 have undefined behavior; the C standard specifies that ``Between the
2258 previous and next sequence point an object shall have its stored value
2259 modified at most once by the evaluation of an expression. Furthermore,
2260 the prior value shall be read only to determine the value to be
2261 stored.''. If a program breaks these rules, the results on any
2262 particular implementation are entirely unpredictable.
2263
2264 Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
2265 = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
2266 diagnosed by this option, and it may give an occasional false positive
2267 result, but in general it has been found fairly effective at detecting
2268 this sort of problem in programs.
2269
2270 The present implementation of this option only works for C programs. A
2271 future implementation may also work for C++ programs.
2272
2273 The C standard is worded confusingly, therefore there is some debate
2274 over the precise meaning of the sequence point rules in subtle cases.
2275 Links to discussions of the problem, including proposed formal
2276 definitions, may be found on our readings page, at
2277 @w{@uref{http://gcc.gnu.org/readings.html}}.
2278
2279 @item -Wreturn-type
2280 @opindex Wreturn-type
2281 Warn whenever a function is defined with a return-type that defaults to
2282 @code{int}. Also warn about any @code{return} statement with no
2283 return-value in a function whose return-type is not @code{void}.
2284
2285 For C++, a function without return type always produces a diagnostic
2286 message, even when @option{-Wno-return-type} is specified. The only
2287 exceptions are @samp{main} and functions defined in system headers.
2288
2289 @item -Wswitch
2290 @opindex Wswitch
2291 Warn whenever a @code{switch} statement has an index of enumeral type
2292 and lacks a @code{case} for one or more of the named codes of that
2293 enumeration. (The presence of a @code{default} label prevents this
2294 warning.) @code{case} labels outside the enumeration range also
2295 provoke warnings when this option is used.
2296
2297 @item -Wswitch-default
2298 @opindex Wswitch-switch
2299 Warn whenever a @code{switch} statement does not have a @code{default}
2300 case.
2301
2302 @item -Wswitch-enum
2303 @opindex Wswitch-enum
2304 Warn whenever a @code{switch} statement has an index of enumeral type
2305 and lacks a @code{case} for one or more of the named codes of that
2306 enumeration. @code{case} labels outside the enumeration range also
2307 provoke warnings when this option is used.
2308
2309 @item -Wtrigraphs
2310 @opindex Wtrigraphs
2311 Warn if any trigraphs are encountered that might change the meaning of
2312 the program (trigraphs within comments are not warned about).
2313
2314 @item -Wunused-function
2315 @opindex Wunused-function
2316 Warn whenever a static function is declared but not defined or a
2317 non\-inline static function is unused.
2318
2319 @item -Wunused-label
2320 @opindex Wunused-label
2321 Warn whenever a label is declared but not used.
2322
2323 To suppress this warning use the @samp{unused} attribute
2324 (@pxref{Variable Attributes}).
2325
2326 @item -Wunused-parameter
2327 @opindex Wunused-parameter
2328 Warn whenever a function parameter is unused aside from its declaration.
2329
2330 To suppress this warning use the @samp{unused} attribute
2331 (@pxref{Variable Attributes}).
2332
2333 @item -Wunused-variable
2334 @opindex Wunused-variable
2335 Warn whenever a local variable or non-constant static variable is unused
2336 aside from its declaration
2337
2338 To suppress this warning use the @samp{unused} attribute
2339 (@pxref{Variable Attributes}).
2340
2341 @item -Wunused-value
2342 @opindex Wunused-value
2343 Warn whenever a statement computes a result that is explicitly not used.
2344
2345 To suppress this warning cast the expression to @samp{void}.
2346
2347 @item -Wunused
2348 @opindex Wunused
2349 All the above @option{-Wunused} options combined.
2350
2351 In order to get a warning about an unused function parameter, you must
2352 either specify @samp{-Wextra -Wunused} (note that @samp{-Wall} implies
2353 @samp{-Wunused}), or separately specify @option{-Wunused-parameter}.
2354
2355 @item -Wuninitialized
2356 @opindex Wuninitialized
2357 Warn if an automatic variable is used without first being initialized or
2358 if a variable may be clobbered by a @code{setjmp} call.
2359
2360 These warnings are possible only in optimizing compilation,
2361 because they require data flow information that is computed only
2362 when optimizing. If you don't specify @option{-O}, you simply won't
2363 get these warnings.
2364
2365 If you want to warn about code which uses the uninitialized value of the
2366 variable in its own initializer, use the @option{-Winit-self} option.
2367
2368 These warnings occur only for variables that are candidates for
2369 register allocation. Therefore, they do not occur for a variable that
2370 is declared @code{volatile}, or whose address is taken, or whose size
2371 is other than 1, 2, 4 or 8 bytes. Also, they do not occur for
2372 structures, unions or arrays, even when they are in registers.
2373
2374 Note that there may be no warning about a variable that is used only
2375 to compute a value that itself is never used, because such
2376 computations may be deleted by data flow analysis before the warnings
2377 are printed.
2378
2379 These warnings are made optional because GCC is not smart
2380 enough to see all the reasons why the code might be correct
2381 despite appearing to have an error. Here is one example of how
2382 this can happen:
2383
2384 @smallexample
2385 @group
2386 @{
2387 int x;
2388 switch (y)
2389 @{
2390 case 1: x = 1;
2391 break;
2392 case 2: x = 4;
2393 break;
2394 case 3: x = 5;
2395 @}
2396 foo (x);
2397 @}
2398 @end group
2399 @end smallexample
2400
2401 @noindent
2402 If the value of @code{y} is always 1, 2 or 3, then @code{x} is
2403 always initialized, but GCC doesn't know this. Here is
2404 another common case:
2405
2406 @smallexample
2407 @{
2408 int save_y;
2409 if (change_y) save_y = y, y = new_y;
2410 @dots{}
2411 if (change_y) y = save_y;
2412 @}
2413 @end smallexample
2414
2415 @noindent
2416 This has no bug because @code{save_y} is used only if it is set.
2417
2418 @cindex @code{longjmp} warnings
2419 This option also warns when a non-volatile automatic variable might be
2420 changed by a call to @code{longjmp}. These warnings as well are possible
2421 only in optimizing compilation.
2422
2423 The compiler sees only the calls to @code{setjmp}. It cannot know
2424 where @code{longjmp} will be called; in fact, a signal handler could
2425 call it at any point in the code. As a result, you may get a warning
2426 even when there is in fact no problem because @code{longjmp} cannot
2427 in fact be called at the place which would cause a problem.
2428
2429 Some spurious warnings can be avoided if you declare all the functions
2430 you use that never return as @code{noreturn}. @xref{Function
2431 Attributes}.
2432
2433 @item -Wunknown-pragmas
2434 @opindex Wunknown-pragmas
2435 @cindex warning for unknown pragmas
2436 @cindex unknown pragmas, warning
2437 @cindex pragmas, warning of unknown
2438 Warn when a #pragma directive is encountered which is not understood by
2439 GCC@. If this command line option is used, warnings will even be issued
2440 for unknown pragmas in system header files. This is not the case if
2441 the warnings were only enabled by the @option{-Wall} command line option.
2442
2443 @item -Wstrict-aliasing
2444 @opindex Wstrict-aliasing
2445 This option is only active when @option{-fstrict-aliasing} is active.
2446 It warns about code which might break the strict aliasing rules that the
2447 compiler is using for optimization. The warning does not catch all
2448 cases, but does attempt to catch the more common pitfalls. It is
2449 included in @option{-Wall}.
2450
2451 @item -Wall
2452 @opindex Wall
2453 All of the above @samp{-W} options combined. This enables all the
2454 warnings about constructions that some users consider questionable, and
2455 that are easy to avoid (or modify to prevent the warning), even in
2456 conjunction with macros. This also enables some language-specific
2457 warnings described in @ref{C++ Dialect Options} and
2458 @ref{Objective-C Dialect Options}.
2459 @end table
2460
2461 The following @option{-W@dots{}} options are not implied by @option{-Wall}.
2462 Some of them warn about constructions that users generally do not
2463 consider questionable, but which occasionally you might wish to check
2464 for; others warn about constructions that are necessary or hard to avoid
2465 in some cases, and there is no simple way to modify the code to suppress
2466 the warning.
2467
2468 @table @gcctabopt
2469 @item -Wextra
2470 @opindex W
2471 @opindex Wextra
2472 (This option used to be called @option{-W}. The older name is still
2473 supported, but the newer name is more descriptive.) Print extra warning
2474 messages for these events:
2475
2476 @itemize @bullet
2477 @item
2478 A function can return either with or without a value. (Falling
2479 off the end of the function body is considered returning without
2480 a value.) For example, this function would evoke such a
2481 warning:
2482
2483 @smallexample
2484 @group
2485 foo (a)
2486 @{
2487 if (a > 0)
2488 return a;
2489 @}
2490 @end group
2491 @end smallexample
2492
2493 @item
2494 An expression-statement or the left-hand side of a comma expression
2495 contains no side effects.
2496 To suppress the warning, cast the unused expression to void.
2497 For example, an expression such as @samp{x[i,j]} will cause a warning,
2498 but @samp{x[(void)i,j]} will not.
2499
2500 @item
2501 An unsigned value is compared against zero with @samp{<} or @samp{>=}.
2502
2503 @item
2504 A comparison like @samp{x<=y<=z} appears; this is equivalent to
2505 @samp{(x<=y ? 1 : 0) <= z}, which is a different interpretation from
2506 that of ordinary mathematical notation.
2507
2508 @item
2509 Storage-class specifiers like @code{static} are not the first things in
2510 a declaration. According to the C Standard, this usage is obsolescent.
2511
2512 @item
2513 The return type of a function has a type qualifier such as @code{const}.
2514 Such a type qualifier has no effect, since the value returned by a
2515 function is not an lvalue. (But don't warn about the GNU extension of
2516 @code{volatile void} return types. That extension will be warned about
2517 if @option{-pedantic} is specified.)
2518
2519 @item
2520 If @option{-Wall} or @option{-Wunused} is also specified, warn about unused
2521 arguments.
2522
2523 @item
2524 A comparison between signed and unsigned values could produce an
2525 incorrect result when the signed value is converted to unsigned.
2526 (But don't warn if @option{-Wno-sign-compare} is also specified.)
2527
2528 @item
2529 An aggregate has an initializer which does not initialize all members.
2530 For example, the following code would cause such a warning, because
2531 @code{x.h} would be implicitly initialized to zero:
2532
2533 @smallexample
2534 struct s @{ int f, g, h; @};
2535 struct s x = @{ 3, 4 @};
2536 @end smallexample
2537
2538 @item
2539 A function parameter is declared without a type specifier in K&R-style
2540 functions:
2541
2542 @smallexample
2543 void foo(bar) @{ @}
2544 @end smallexample
2545
2546 @item
2547 An empty body occurs in an @samp{if} or @samp{else} statement.
2548
2549 @item
2550 A pointer is compared against integer zero with @samp{<}, @samp{<=},
2551 @samp{>}, or @samp{>=}.
2552
2553 @item
2554 A variable might be changed by @samp{longjmp} or @samp{vfork}.
2555
2556 @item
2557 Any of several floating-point events that often indicate errors, such as
2558 overflow, underflow, loss of precision, etc.
2559
2560 @item @r{(C++ only)}
2561 An enumerator and a non-enumerator both appear in a conditional expression.
2562
2563 @item @r{(C++ only)}
2564 A non-static reference or non-static @samp{const} member appears in a
2565 class without constructors.
2566
2567 @item @r{(C++ only)}
2568 Ambiguous virtual bases.
2569
2570 @item @r{(C++ only)}
2571 Subscripting an array which has been declared @samp{register}.
2572
2573 @item @r{(C++ only)}
2574 Taking the address of a variable which has been declared @samp{register}.
2575
2576 @item @r{(C++ only)}
2577 A base class is not initialized in a derived class' copy constructor.
2578 @end itemize
2579
2580 @item -Wno-div-by-zero
2581 @opindex Wno-div-by-zero
2582 @opindex Wdiv-by-zero
2583 Do not warn about compile-time integer division by zero. Floating point
2584 division by zero is not warned about, as it can be a legitimate way of
2585 obtaining infinities and NaNs.
2586
2587 @item -Wsystem-headers
2588 @opindex Wsystem-headers
2589 @cindex warnings from system headers
2590 @cindex system headers, warnings from
2591 Print warning messages for constructs found in system header files.
2592 Warnings from system headers are normally suppressed, on the assumption
2593 that they usually do not indicate real problems and would only make the
2594 compiler output harder to read. Using this command line option tells
2595 GCC to emit warnings from system headers as if they occurred in user
2596 code. However, note that using @option{-Wall} in conjunction with this
2597 option will @emph{not} warn about unknown pragmas in system
2598 headers---for that, @option{-Wunknown-pragmas} must also be used.
2599
2600 @item -Wfloat-equal
2601 @opindex Wfloat-equal
2602 Warn if floating point values are used in equality comparisons.
2603
2604 The idea behind this is that sometimes it is convenient (for the
2605 programmer) to consider floating-point values as approximations to
2606 infinitely precise real numbers. If you are doing this, then you need
2607 to compute (by analyzing the code, or in some other way) the maximum or
2608 likely maximum error that the computation introduces, and allow for it
2609 when performing comparisons (and when producing output, but that's a
2610 different problem). In particular, instead of testing for equality, you
2611 would check to see whether the two values have ranges that overlap; and
2612 this is done with the relational operators, so equality comparisons are
2613 probably mistaken.
2614
2615 @item -Wtraditional @r{(C only)}
2616 @opindex Wtraditional
2617 Warn about certain constructs that behave differently in traditional and
2618 ISO C@. Also warn about ISO C constructs that have no traditional C
2619 equivalent, and/or problematic constructs which should be avoided.
2620
2621 @itemize @bullet
2622 @item
2623 Macro parameters that appear within string literals in the macro body.
2624 In traditional C macro replacement takes place within string literals,
2625 but does not in ISO C@.
2626
2627 @item
2628 In traditional C, some preprocessor directives did not exist.
2629 Traditional preprocessors would only consider a line to be a directive
2630 if the @samp{#} appeared in column 1 on the line. Therefore
2631 @option{-Wtraditional} warns about directives that traditional C
2632 understands but would ignore because the @samp{#} does not appear as the
2633 first character on the line. It also suggests you hide directives like
2634 @samp{#pragma} not understood by traditional C by indenting them. Some
2635 traditional implementations would not recognize @samp{#elif}, so it
2636 suggests avoiding it altogether.
2637
2638 @item
2639 A function-like macro that appears without arguments.
2640
2641 @item
2642 The unary plus operator.
2643
2644 @item
2645 The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating point
2646 constant suffixes. (Traditional C does support the @samp{L} suffix on integer
2647 constants.) Note, these suffixes appear in macros defined in the system
2648 headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
2649 Use of these macros in user code might normally lead to spurious
2650 warnings, however gcc's integrated preprocessor has enough context to
2651 avoid warning in these cases.
2652
2653 @item
2654 A function declared external in one block and then used after the end of
2655 the block.
2656
2657 @item
2658 A @code{switch} statement has an operand of type @code{long}.
2659
2660 @item
2661 A non-@code{static} function declaration follows a @code{static} one.
2662 This construct is not accepted by some traditional C compilers.
2663
2664 @item
2665 The ISO type of an integer constant has a different width or
2666 signedness from its traditional type. This warning is only issued if
2667 the base of the constant is ten. I.e.@: hexadecimal or octal values, which
2668 typically represent bit patterns, are not warned about.
2669
2670 @item
2671 Usage of ISO string concatenation is detected.
2672
2673 @item
2674 Initialization of automatic aggregates.
2675
2676 @item
2677 Identifier conflicts with labels. Traditional C lacks a separate
2678 namespace for labels.
2679
2680 @item
2681 Initialization of unions. If the initializer is zero, the warning is
2682 omitted. This is done under the assumption that the zero initializer in
2683 user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
2684 initializer warnings and relies on default initialization to zero in the
2685 traditional C case.
2686
2687 @item
2688 Conversions by prototypes between fixed/floating point values and vice
2689 versa. The absence of these prototypes when compiling with traditional
2690 C would cause serious problems. This is a subset of the possible
2691 conversion warnings, for the full set use @option{-Wconversion}.
2692
2693 @item
2694 Use of ISO C style function definitions. This warning intentionally is
2695 @emph{not} issued for prototype declarations or variadic functions
2696 because these ISO C features will appear in your code when using
2697 libiberty's traditional C compatibility macros, @code{PARAMS} and
2698 @code{VPARAMS}. This warning is also bypassed for nested functions
2699 because that feature is already a gcc extension and thus not relevant to
2700 traditional C compatibility.
2701 @end itemize
2702
2703 @item -Wdeclaration-after-statement @r{(C only)}
2704 @opindex Wdeclaration-after-statement
2705 Warn when a declaration is found after a statement in a block. This
2706 construct, known from C++, was introduced with ISO C99 and is by default
2707 allowed in GCC@. It is not supported by ISO C90 and was not supported by
2708 GCC versions before GCC 3.0. @xref{Mixed Declarations}.
2709
2710 @item -Wundef
2711 @opindex Wundef
2712 Warn if an undefined identifier is evaluated in an @samp{#if} directive.
2713
2714 @item -Wendif-labels
2715 @opindex Wendif-labels
2716 Warn whenever an @samp{#else} or an @samp{#endif} are followed by text.
2717
2718 @item -Wshadow
2719 @opindex Wshadow
2720 Warn whenever a local variable shadows another local variable, parameter or
2721 global variable or whenever a built-in function is shadowed.
2722
2723 @item -Wlarger-than-@var{len}
2724 @opindex Wlarger-than
2725 Warn whenever an object of larger than @var{len} bytes is defined.
2726
2727 @item -Wpointer-arith
2728 @opindex Wpointer-arith
2729 Warn about anything that depends on the ``size of'' a function type or
2730 of @code{void}. GNU C assigns these types a size of 1, for
2731 convenience in calculations with @code{void *} pointers and pointers
2732 to functions.
2733
2734 @item -Wbad-function-cast @r{(C only)}
2735 @opindex Wbad-function-cast
2736 Warn whenever a function call is cast to a non-matching type.
2737 For example, warn if @code{int malloc()} is cast to @code{anything *}.
2738
2739 @item -Wcast-qual
2740 @opindex Wcast-qual
2741 Warn whenever a pointer is cast so as to remove a type qualifier from
2742 the target type. For example, warn if a @code{const char *} is cast
2743 to an ordinary @code{char *}.
2744
2745 @item -Wcast-align
2746 @opindex Wcast-align
2747 Warn whenever a pointer is cast such that the required alignment of the
2748 target is increased. For example, warn if a @code{char *} is cast to
2749 an @code{int *} on machines where integers can only be accessed at
2750 two- or four-byte boundaries.
2751
2752 @item -Wwrite-strings
2753 @opindex Wwrite-strings
2754 When compiling C, give string constants the type @code{const
2755 char[@var{length}]} so that
2756 copying the address of one into a non-@code{const} @code{char *}
2757 pointer will get a warning; when compiling C++, warn about the
2758 deprecated conversion from string constants to @code{char *}.
2759 These warnings will help you find at
2760 compile time code that can try to write into a string constant, but
2761 only if you have been very careful about using @code{const} in
2762 declarations and prototypes. Otherwise, it will just be a nuisance;
2763 this is why we did not make @option{-Wall} request these warnings.
2764
2765 @item -Wconversion
2766 @opindex Wconversion
2767 Warn if a prototype causes a type conversion that is different from what
2768 would happen to the same argument in the absence of a prototype. This
2769 includes conversions of fixed point to floating and vice versa, and
2770 conversions changing the width or signedness of a fixed point argument
2771 except when the same as the default promotion.
2772
2773 Also, warn if a negative integer constant expression is implicitly
2774 converted to an unsigned type. For example, warn about the assignment
2775 @code{x = -1} if @code{x} is unsigned. But do not warn about explicit
2776 casts like @code{(unsigned) -1}.
2777
2778 @item -Wsign-compare
2779 @opindex Wsign-compare
2780 @cindex warning for comparison of signed and unsigned values
2781 @cindex comparison of signed and unsigned values, warning
2782 @cindex signed and unsigned values, comparison warning
2783 Warn when a comparison between signed and unsigned values could produce
2784 an incorrect result when the signed value is converted to unsigned.
2785 This warning is also enabled by @option{-Wextra}; to get the other warnings
2786 of @option{-Wextra} without this warning, use @samp{-Wextra -Wno-sign-compare}.
2787
2788 @item -Waggregate-return
2789 @opindex Waggregate-return
2790 Warn if any functions that return structures or unions are defined or
2791 called. (In languages where you can return an array, this also elicits
2792 a warning.)
2793
2794 @item -Wstrict-prototypes @r{(C only)}
2795 @opindex Wstrict-prototypes
2796 Warn if a function is declared or defined without specifying the
2797 argument types. (An old-style function definition is permitted without
2798 a warning if preceded by a declaration which specifies the argument
2799 types.)
2800
2801 @item -Wold-style-definition @r{(C only)}
2802 @opindex Wold-style-definition
2803 Warn if an old-style function definition is used. A warning is given
2804 even if there is a previous prototype.
2805
2806 @item -Wmissing-prototypes @r{(C only)}
2807 @opindex Wmissing-prototypes
2808 Warn if a global function is defined without a previous prototype
2809 declaration. This warning is issued even if the definition itself
2810 provides a prototype. The aim is to detect global functions that fail
2811 to be declared in header files.
2812
2813 @item -Wmissing-declarations @r{(C only)}
2814 @opindex Wmissing-declarations
2815 Warn if a global function is defined without a previous declaration.
2816 Do so even if the definition itself provides a prototype.
2817 Use this option to detect global functions that are not declared in
2818 header files.
2819
2820 @item -Wmissing-noreturn
2821 @opindex Wmissing-noreturn
2822 Warn about functions which might be candidates for attribute @code{noreturn}.
2823 Note these are only possible candidates, not absolute ones. Care should
2824 be taken to manually verify functions actually do not ever return before
2825 adding the @code{noreturn} attribute, otherwise subtle code generation
2826 bugs could be introduced. You will not get a warning for @code{main} in
2827 hosted C environments.
2828
2829 @item -Wmissing-format-attribute
2830 @opindex Wmissing-format-attribute
2831 @opindex Wformat
2832 If @option{-Wformat} is enabled, also warn about functions which might be
2833 candidates for @code{format} attributes. Note these are only possible
2834 candidates, not absolute ones. GCC will guess that @code{format}
2835 attributes might be appropriate for any function that calls a function
2836 like @code{vprintf} or @code{vscanf}, but this might not always be the
2837 case, and some functions for which @code{format} attributes are
2838 appropriate may not be detected. This option has no effect unless
2839 @option{-Wformat} is enabled (possibly by @option{-Wall}).
2840
2841 @item -Wno-multichar
2842 @opindex Wno-multichar
2843 @opindex Wmultichar
2844 Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
2845 Usually they indicate a typo in the user's code, as they have
2846 implementation-defined values, and should not be used in portable code.
2847
2848 @item -Wno-deprecated-declarations
2849 @opindex Wno-deprecated-declarations
2850 Do not warn about uses of functions, variables, and types marked as
2851 deprecated by using the @code{deprecated} attribute.
2852 (@pxref{Function Attributes}, @pxref{Variable Attributes},
2853 @pxref{Type Attributes}.)
2854
2855 @item -Wpacked
2856 @opindex Wpacked
2857 Warn if a structure is given the packed attribute, but the packed
2858 attribute has no effect on the layout or size of the structure.
2859 Such structures may be mis-aligned for little benefit. For
2860 instance, in this code, the variable @code{f.x} in @code{struct bar}
2861 will be misaligned even though @code{struct bar} does not itself
2862 have the packed attribute:
2863
2864 @smallexample
2865 @group
2866 struct foo @{
2867 int x;
2868 char a, b, c, d;
2869 @} __attribute__((packed));
2870 struct bar @{
2871 char z;
2872 struct foo f;
2873 @};
2874 @end group
2875 @end smallexample
2876
2877 @item -Wpadded
2878 @opindex Wpadded
2879 Warn if padding is included in a structure, either to align an element
2880 of the structure or to align the whole structure. Sometimes when this
2881 happens it is possible to rearrange the fields of the structure to
2882 reduce the padding and so make the structure smaller.
2883
2884 @item -Wredundant-decls
2885 @opindex Wredundant-decls
2886 Warn if anything is declared more than once in the same scope, even in
2887 cases where multiple declaration is valid and changes nothing.
2888
2889 @item -Wnested-externs @r{(C only)}
2890 @opindex Wnested-externs
2891 Warn if an @code{extern} declaration is encountered within a function.
2892
2893 @item -Wunreachable-code
2894 @opindex Wunreachable-code
2895 Warn if the compiler detects that code will never be executed.
2896
2897 This option is intended to warn when the compiler detects that at
2898 least a whole line of source code will never be executed, because
2899 some condition is never satisfied or because it is after a
2900 procedure that never returns.
2901
2902 It is possible for this option to produce a warning even though there
2903 are circumstances under which part of the affected line can be executed,
2904 so care should be taken when removing apparently-unreachable code.
2905
2906 For instance, when a function is inlined, a warning may mean that the
2907 line is unreachable in only one inlined copy of the function.
2908
2909 This option is not made part of @option{-Wall} because in a debugging
2910 version of a program there is often substantial code which checks
2911 correct functioning of the program and is, hopefully, unreachable
2912 because the program does work. Another common use of unreachable
2913 code is to provide behavior which is selectable at compile-time.
2914
2915 @item -Winline
2916 @opindex Winline
2917 Warn if a function can not be inlined and it was declared as inline.
2918 Even with this option, the compiler will not warn about failures to
2919 inline functions declared in system headers.
2920
2921 The compiler uses a variety of heuristics to determine whether or not
2922 to inline a function. For example, the compiler takes into account
2923 the size of the function being inlined and the the amount of inlining
2924 that has already been done in the current function. Therefore,
2925 seemingly insignificant changes in the source program can cause the
2926 warnings produced by @option{-Winline} to appear or disappear.
2927
2928 @item -Wno-invalid-offsetof @r{(C++ only)}
2929 @opindex Wno-invalid-offsetof
2930 Suppress warnings from applying the @samp{offsetof} macro to a non-POD
2931 type. According to the 1998 ISO C++ standard, applying @samp{offsetof}
2932 to a non-POD type is undefined. In existing C++ implementations,
2933 however, @samp{offsetof} typically gives meaningful results even when
2934 applied to certain kinds of non-POD types. (Such as a simple
2935 @samp{struct} that fails to be a POD type only by virtue of having a
2936 constructor.) This flag is for users who are aware that they are
2937 writing nonportable code and who have deliberately chosen to ignore the
2938 warning about it.
2939
2940 The restrictions on @samp{offsetof} may be relaxed in a future version
2941 of the C++ standard.
2942
2943 @item -Winvalid-pch
2944 @opindex Winvalid-pch
2945 Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
2946 the search path but can't be used.
2947
2948 @item -Wlong-long
2949 @opindex Wlong-long
2950 @opindex Wno-long-long
2951 Warn if @samp{long long} type is used. This is default. To inhibit
2952 the warning messages, use @option{-Wno-long-long}. Flags
2953 @option{-Wlong-long} and @option{-Wno-long-long} are taken into account
2954 only when @option{-pedantic} flag is used.
2955
2956 @item -Wvariadic-macros
2957 @opindex Wvariadic-macros
2958 @opindex Wno-variadic-macros
2959 Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU
2960 alternate syntax when in pedantic ISO C99 mode. This is default.
2961 To inhibit the warning messages, use @option{-Wno-variadic-macros}.
2962
2963 @item -Wdisabled-optimization
2964 @opindex Wdisabled-optimization
2965 Warn if a requested optimization pass is disabled. This warning does
2966 not generally indicate that there is anything wrong with your code; it
2967 merely indicates that GCC's optimizers were unable to handle the code
2968 effectively. Often, the problem is that your code is too big or too
2969 complex; GCC will refuse to optimize programs when the optimization
2970 itself is likely to take inordinate amounts of time.
2971
2972 @item -Werror
2973 @opindex Werror
2974 Make all warnings into errors.
2975 @end table
2976
2977 @node Debugging Options
2978 @section Options for Debugging Your Program or GCC
2979 @cindex options, debugging
2980 @cindex debugging information options
2981
2982 GCC has various special options that are used for debugging
2983 either your program or GCC:
2984
2985 @table @gcctabopt
2986 @item -g
2987 @opindex g
2988 Produce debugging information in the operating system's native format
2989 (stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
2990 information.
2991
2992 On most systems that use stabs format, @option{-g} enables use of extra
2993 debugging information that only GDB can use; this extra information
2994 makes debugging work better in GDB but will probably make other debuggers
2995 crash or
2996 refuse to read the program. If you want to control for certain whether
2997 to generate the extra information, use @option{-gstabs+}, @option{-gstabs},
2998 @option{-gxcoff+}, @option{-gxcoff}, or @option{-gvms} (see below).
2999
3000 Unlike most other C compilers, GCC allows you to use @option{-g} with
3001 @option{-O}. The shortcuts taken by optimized code may occasionally
3002 produce surprising results: some variables you declared may not exist
3003 at all; flow of control may briefly move where you did not expect it;
3004 some statements may not be executed because they compute constant
3005 results or their values were already at hand; some statements may
3006 execute in different places because they were moved out of loops.
3007
3008 Nevertheless it proves possible to debug optimized output. This makes
3009 it reasonable to use the optimizer for programs that might have bugs.
3010
3011 The following options are useful when GCC is generated with the
3012 capability for more than one debugging format.
3013
3014 @item -ggdb
3015 @opindex ggdb
3016 Produce debugging information for use by GDB@. This means to use the
3017 most expressive format available (DWARF 2, stabs, or the native format
3018 if neither of those are supported), including GDB extensions if at all
3019 possible.
3020
3021 @item -gstabs
3022 @opindex gstabs
3023 Produce debugging information in stabs format (if that is supported),
3024 without GDB extensions. This is the format used by DBX on most BSD
3025 systems. On MIPS, Alpha and System V Release 4 systems this option
3026 produces stabs debugging output which is not understood by DBX or SDB@.
3027 On System V Release 4 systems this option requires the GNU assembler.
3028
3029 @item -feliminate-unused-debug-symbols
3030 @opindex feliminate-unused-debug-symbols
3031 Produce debugging information in stabs format (if that is supported),
3032 for only symbols that are actually used.
3033
3034 @item -gstabs+
3035 @opindex gstabs+
3036 Produce debugging information in stabs format (if that is supported),
3037 using GNU extensions understood only by the GNU debugger (GDB)@. The
3038 use of these extensions is likely to make other debuggers crash or
3039 refuse to read the program.
3040
3041 @item -gcoff
3042 @opindex gcoff
3043 Produce debugging information in COFF format (if that is supported).
3044 This is the format used by SDB on most System V systems prior to
3045 System V Release 4.
3046
3047 @item -gxcoff
3048 @opindex gxcoff
3049 Produce debugging information in XCOFF format (if that is supported).
3050 This is the format used by the DBX debugger on IBM RS/6000 systems.
3051
3052 @item -gxcoff+
3053 @opindex gxcoff+
3054 Produce debugging information in XCOFF format (if that is supported),
3055 using GNU extensions understood only by the GNU debugger (GDB)@. The
3056 use of these extensions is likely to make other debuggers crash or
3057 refuse to read the program, and may cause assemblers other than the GNU
3058 assembler (GAS) to fail with an error.
3059
3060 @item -gdwarf-2
3061 @opindex gdwarf-2
3062 Produce debugging information in DWARF version 2 format (if that is
3063 supported). This is the format used by DBX on IRIX 6.
3064
3065 @item -gvms
3066 @opindex gvms
3067 Produce debugging information in VMS debug format (if that is
3068 supported). This is the format used by DEBUG on VMS systems.
3069
3070 @item -g@var{level}
3071 @itemx -ggdb@var{level}
3072 @itemx -gstabs@var{level}
3073 @itemx -gcoff@var{level}
3074 @itemx -gxcoff@var{level}
3075 @itemx -gvms@var{level}
3076 Request debugging information and also use @var{level} to specify how
3077 much information. The default level is 2.
3078
3079 Level 1 produces minimal information, enough for making backtraces in
3080 parts of the program that you don't plan to debug. This includes
3081 descriptions of functions and external variables, but no information
3082 about local variables and no line numbers.
3083
3084 Level 3 includes extra information, such as all the macro definitions
3085 present in the program. Some debuggers support macro expansion when
3086 you use @option{-g3}.
3087
3088 Note that in order to avoid confusion between DWARF1 debug level 2,
3089 and DWARF2 @option{-gdwarf-2} does not accept a concatenated debug
3090 level. Instead use an additional @option{-g@var{level}} option to
3091 change the debug level for DWARF2.
3092
3093 @item -feliminate-dwarf2-dups
3094 @opindex feliminate-dwarf2-dups
3095 Compress DWARF2 debugging information by eliminating duplicated
3096 information about each symbol. This option only makes sense when
3097 generating DWARF2 debugging information with @option{-gdwarf-2}.
3098
3099 @cindex @command{prof}
3100 @item -p
3101 @opindex p
3102 Generate extra code to write profile information suitable for the
3103 analysis program @command{prof}. You must use this option when compiling
3104 the source files you want data about, and you must also use it when
3105 linking.
3106
3107 @cindex @command{gprof}
3108 @item -pg
3109 @opindex pg
3110 Generate extra code to write profile information suitable for the
3111 analysis program @command{gprof}. You must use this option when compiling
3112 the source files you want data about, and you must also use it when
3113 linking.
3114
3115 @item -Q
3116 @opindex Q
3117 Makes the compiler print out each function name as it is compiled, and
3118 print some statistics about each pass when it finishes.
3119
3120 @item -ftime-report
3121 @opindex ftime-report
3122 Makes the compiler print some statistics about the time consumed by each
3123 pass when it finishes.
3124
3125 @item -fmem-report
3126 @opindex fmem-report
3127 Makes the compiler print some statistics about permanent memory
3128 allocation when it finishes.
3129
3130 @item -fprofile-arcs
3131 @opindex fprofile-arcs
3132 Add code so that program flow @dfn{arcs} are instrumented. During
3133 execution the program records how many times each branch and call is
3134 executed and how many times it is taken or returns. When the compiled
3135 program exits it saves this data to a file called
3136 @file{@var{auxname}.gcda} for each source file. The data may be used for
3137 profile-directed optimizations (@option{-fbranch-probabilities}), or for
3138 test coverage analysis (@option{-ftest-coverage}). Each object file's
3139 @var{auxname} is generated from the name of the output file, if
3140 explicitly specified and it is not the final executable, otherwise it is
3141 the basename of the source file. In both cases any suffix is removed
3142 (e.g. @file{foo.gcda} for input file @file{dir/foo.c}, or
3143 @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
3144
3145 @itemize
3146
3147 @item
3148 Compile the source files with @option{-fprofile-arcs} plus optimization
3149 and code generation options. For test coverage analysis, use the
3150 additional @option{-ftest-coverage} option. You do not need to profile
3151 every source file in a program.
3152
3153 @item
3154 Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
3155 (the latter implies the former).
3156
3157 @item
3158 Run the program on a representative workload to generate the arc profile
3159 information. This may be repeated any number of times. You can run
3160 concurrent instances of your program, and provided that the file system
3161 supports locking, the data files will be correctly updated. Also
3162 @code{fork} calls are detected and correctly handled (double counting
3163 will not happen).
3164
3165 @item
3166 For profile-directed optimizations, compile the source files again with
3167 the same optimization and code generation options plus
3168 @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
3169 Control Optimization}).
3170
3171 @item
3172 For test coverage analysis, use @command{gcov} to produce human readable
3173 information from the @file{.gcno} and @file{.gcda} files. Refer to the
3174 @command{gcov} documentation for further information.
3175
3176 @end itemize
3177
3178 With @option{-fprofile-arcs}, for each function of your program GCC
3179 creates a program flow graph, then finds a spanning tree for the graph.
3180 Only arcs that are not on the spanning tree have to be instrumented: the
3181 compiler adds code to count the number of times that these arcs are
3182 executed. When an arc is the only exit or only entrance to a block, the
3183 instrumentation code can be added to the block; otherwise, a new basic
3184 block must be created to hold the instrumentation code.
3185
3186 @need 2000
3187 @item -ftest-coverage
3188 @opindex ftest-coverage
3189 Produce a notes file that the @command{gcov} code-coverage utility
3190 (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
3191 show program coverage. Each source file's note file is called
3192 @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
3193 above for a description of @var{auxname} and instructions on how to
3194 generate test coverage data. Coverage data will match the source files
3195 more closely, if you do not optimize.
3196
3197 @item -d@var{letters}
3198 @opindex d
3199 Says to make debugging dumps during compilation at times specified by
3200 @var{letters}. This is used for debugging the compiler. The file names
3201 for most of the dumps are made by appending a pass number and a word to
3202 the @var{dumpname}. @var{dumpname} is generated from the name of the
3203 output file, if explicitly specified and it is not an executable,
3204 otherwise it is the basename of the source file. In both cases any
3205 suffix is removed (e.g. @file{foo.01.rtl} or @file{foo.02.sibling}).
3206 Here are the possible letters for use in @var{letters}, and their
3207 meanings:
3208
3209 @table @samp
3210 @item A
3211 @opindex dA
3212 Annotate the assembler output with miscellaneous debugging information.
3213 @item b
3214 @opindex db
3215 Dump after computing branch probabilities, to @file{@var{file}.12.bp}.
3216 @item B
3217 @opindex dB
3218 Dump after block reordering, to @file{@var{file}.31.bbro}.
3219 @item c
3220 @opindex dc
3221 Dump after instruction combination, to the file @file{@var{file}.20.combine}.
3222 @item C
3223 @opindex dC
3224 Dump after the first if conversion, to the file @file{@var{file}.14.ce1}.
3225 Also dump after the second if conversion, to the file @file{@var{file}.21.ce2}.
3226 @item d
3227 @opindex dd
3228 Dump after branch target load optimization, to to @file{@var{file}.32.btl}.
3229 Also dump after delayed branch scheduling, to @file{@var{file}.36.dbr}.
3230 @item D
3231 @opindex dD
3232 Dump all macro definitions, at the end of preprocessing, in addition to
3233 normal output.
3234 @item E
3235 @opindex dE
3236 Dump after the third if conversion, to @file{@var{file}.30.ce3}.
3237 @item f
3238 @opindex df
3239 Dump after control and data flow analysis, to @file{@var{file}.11.cfg}.
3240 Also dump after life analysis, to @file{@var{file}.19.life}.
3241 @item F
3242 @opindex dF
3243 Dump after purging @code{ADDRESSOF} codes, to @file{@var{file}.07.addressof}.
3244 @item g
3245 @opindex dg
3246 Dump after global register allocation, to @file{@var{file}.25.greg}.
3247 @item G
3248 @opindex dG
3249 Dump after GCSE, to @file{@var{file}.08.gcse}.
3250 Also dump after jump bypassing and control flow optimizations, to
3251 @file{@var{file}.10.bypass}.
3252 @item h
3253 @opindex dh
3254 Dump after finalization of EH handling code, to @file{@var{file}.03.eh}.
3255 @item i
3256 @opindex di
3257 Dump after sibling call optimizations, to @file{@var{file}.02.sibling}.
3258 @item j
3259 @opindex dj
3260 Dump after the first jump optimization, to @file{@var{file}.04.jump}.
3261 @item k
3262 @opindex dk
3263 Dump after conversion from registers to stack, to @file{@var{file}.34.stack}.
3264 @item l
3265 @opindex dl
3266 Dump after local register allocation, to @file{@var{file}.24.lreg}.
3267 @item L
3268 @opindex dL
3269 Dump after loop optimization passes, to @file{@var{file}.09.loop} and
3270 @file{@var{file}.16.loop2}.
3271 @item M
3272 @opindex dM
3273 Dump after performing the machine dependent reorganization pass, to
3274 @file{@var{file}.35.mach}.
3275 @item n
3276 @opindex dn
3277 Dump after register renumbering, to @file{@var{file}.29.rnreg}.
3278 @item N
3279 @opindex dN
3280 Dump after the register move pass, to @file{@var{file}.22.regmove}.
3281 @item o
3282 @opindex do
3283 Dump after post-reload optimizations, to @file{@var{file}.26.postreload}.
3284 @item r
3285 @opindex dr
3286 Dump after RTL generation, to @file{@var{file}.01.rtl}.
3287 @item R
3288 @opindex dR
3289 Dump after the second scheduling pass, to @file{@var{file}.33.sched2}.
3290 @item s
3291 @opindex ds
3292 Dump after CSE (including the jump optimization that sometimes follows
3293 CSE), to @file{@var{file}.06.cse}.
3294 @item S
3295 @opindex dS
3296 Dump after the first scheduling pass, to @file{@var{file}.23.sched}.
3297 @item t
3298 @opindex dt
3299 Dump after the second CSE pass (including the jump optimization that
3300 sometimes follows CSE), to @file{@var{file}.18.cse2}.
3301 @item T
3302 @opindex dT
3303 Dump after running tracer, to @file{@var{file}.15.tracer}.
3304 @item u
3305 @opindex du
3306 Dump after null pointer elimination pass to @file{@var{file}.05.null}.
3307 @item U
3308 @opindex dU
3309 Dump callgraph and unit-at-a-time optimization @file{@var{file}.00.unit}.
3310 @item V
3311 @opindex dV
3312 Dump after the value profile transformations, to @file{@var{file}.13.vpt}.
3313 Also dump after variable tracking, to @file{@var{file}.35.vartrack}.
3314 @item w
3315 @opindex dw
3316 Dump after the second flow pass, to @file{@var{file}.27.flow2}.
3317 @item z
3318 @opindex dz
3319 Dump after the peephole pass, to @file{@var{file}.28.peephole2}.
3320 @item Z
3321 @opindex dZ
3322 Dump after constructing the web, to @file{@var{file}.17.web}.
3323 @item a
3324 @opindex da
3325 Produce all the dumps listed above.
3326 @item H
3327 @opindex dH
3328 Produce a core dump whenever an error occurs.
3329 @item m
3330 @opindex dm
3331 Print statistics on memory usage, at the end of the run, to
3332 standard error.
3333 @item p
3334 @opindex dp
3335 Annotate the assembler output with a comment indicating which
3336 pattern and alternative was used. The length of each instruction is
3337 also printed.
3338 @item P
3339 @opindex dP
3340 Dump the RTL in the assembler output as a comment before each instruction.
3341 Also turns on @option{-dp} annotation.
3342 @item v
3343 @opindex dv
3344 For each of the other indicated dump files (except for
3345 @file{@var{file}.01.rtl}), dump a representation of the control flow graph
3346 suitable for viewing with VCG to @file{@var{file}.@var{pass}.vcg}.
3347 @item x
3348 @opindex dx
3349 Just generate RTL for a function instead of compiling it. Usually used
3350 with @samp{r}.
3351 @item y
3352 @opindex dy
3353 Dump debugging information during parsing, to standard error.
3354 @end table
3355
3356 @item -fdump-unnumbered
3357 @opindex fdump-unnumbered
3358 When doing debugging dumps (see @option{-d} option above), suppress instruction
3359 numbers and line number note output. This makes it more feasible to
3360 use diff on debugging dumps for compiler invocations with different
3361 options, in particular with and without @option{-g}.
3362
3363 @item -fdump-translation-unit @r{(C and C++ only)}
3364 @itemx -fdump-translation-unit-@var{options} @r{(C and C++ only)}
3365 @opindex fdump-translation-unit
3366 Dump a representation of the tree structure for the entire translation
3367 unit to a file. The file name is made by appending @file{.tu} to the
3368 source file name. If the @samp{-@var{options}} form is used, @var{options}
3369 controls the details of the dump as described for the
3370 @option{-fdump-tree} options.
3371
3372 @item -fdump-class-hierarchy @r{(C++ only)}
3373 @itemx -fdump-class-hierarchy-@var{options} @r{(C++ only)}
3374 @opindex fdump-class-hierarchy
3375 Dump a representation of each class's hierarchy and virtual function
3376 table layout to a file. The file name is made by appending @file{.class}
3377 to the source file name. If the @samp{-@var{options}} form is used,
3378 @var{options} controls the details of the dump as described for the
3379 @option{-fdump-tree} options.
3380
3381 @item -fdump-tree-@var{switch} @r{(C++ only)}
3382 @itemx -fdump-tree-@var{switch}-@var{options} @r{(C++ only)}
3383 @opindex fdump-tree
3384 Control the dumping at various stages of processing the intermediate
3385 language tree to a file. The file name is generated by appending a switch
3386 specific suffix to the source file name. If the @samp{-@var{options}}
3387 form is used, @var{options} is a list of @samp{-} separated options that
3388 control the details of the dump. Not all options are applicable to all
3389 dumps, those which are not meaningful will be ignored. The following
3390 options are available
3391
3392 @table @samp
3393 @item address
3394 Print the address of each node. Usually this is not meaningful as it
3395 changes according to the environment and source file. Its primary use
3396 is for tying up a dump file with a debug environment.
3397 @item slim
3398 Inhibit dumping of members of a scope or body of a function merely
3399 because that scope has been reached. Only dump such items when they
3400 are directly reachable by some other path.
3401 @item all
3402 Turn on all options.
3403 @end table
3404
3405 The following tree dumps are possible:
3406 @table @samp
3407 @item original
3408 Dump before any tree based optimization, to @file{@var{file}.original}.
3409 @item optimized
3410 Dump after all tree based optimization, to @file{@var{file}.optimized}.
3411 @item inlined
3412 Dump after function inlining, to @file{@var{file}.inlined}.
3413 @end table
3414
3415 @item -frandom-seed=@var{string}
3416 @opindex frandom-string
3417 This option provides a seed that GCC uses when it would otherwise use
3418 random numbers. It is used to generate certain symbol names
3419 that have to be different in every compiled file. It is also used to
3420 place unique stamps in coverage data files and the object files that
3421 produce them. You can use the @option{-frandom-seed} option to produce
3422 reproducibly identical object files.
3423
3424 The @var{string} should be different for every file you compile.
3425
3426 @item -fsched-verbose=@var{n}
3427 @opindex fsched-verbose
3428 On targets that use instruction scheduling, this option controls the
3429 amount of debugging output the scheduler prints. This information is
3430 written to standard error, unless @option{-dS} or @option{-dR} is
3431 specified, in which case it is output to the usual dump
3432 listing file, @file{.sched} or @file{.sched2} respectively. However
3433 for @var{n} greater than nine, the output is always printed to standard
3434 error.
3435
3436 For @var{n} greater than zero, @option{-fsched-verbose} outputs the
3437 same information as @option{-dRS}. For @var{n} greater than one, it
3438 also output basic block probabilities, detailed ready list information
3439 and unit/insn info. For @var{n} greater than two, it includes RTL
3440 at abort point, control-flow and regions info. And for @var{n} over
3441 four, @option{-fsched-verbose} also includes dependence info.
3442
3443 @item -save-temps
3444 @opindex save-temps
3445 Store the usual ``temporary'' intermediate files permanently; place them
3446 in the current directory and name them based on the source file. Thus,
3447 compiling @file{foo.c} with @samp{-c -save-temps} would produce files
3448 @file{foo.i} and @file{foo.s}, as well as @file{foo.o}. This creates a
3449 preprocessed @file{foo.i} output file even though the compiler now
3450 normally uses an integrated preprocessor.
3451
3452 @item -time
3453 @opindex time
3454 Report the CPU time taken by each subprocess in the compilation
3455 sequence. For C source files, this is the compiler proper and assembler
3456 (plus the linker if linking is done). The output looks like this:
3457
3458 @smallexample
3459 # cc1 0.12 0.01
3460 # as 0.00 0.01
3461 @end smallexample
3462
3463 The first number on each line is the ``user time,'' that is time spent
3464 executing the program itself. The second number is ``system time,''
3465 time spent executing operating system routines on behalf of the program.
3466 Both numbers are in seconds.
3467
3468 @item -fvar-tracking
3469 @opindex fvar-tracking
3470 Run variable tracking pass. It computes where variables are stored at each
3471 position in code. Better debugging information is then generated
3472 (if the debugging information format supports this information).
3473
3474 It is enabled by default when compiling with optimization (@option{-Os},
3475 @option{-O}, @option{-O2}, ...), debugging information (@option{-g}) and
3476 the debug info format supports it.
3477
3478 @item -print-file-name=@var{library}
3479 @opindex print-file-name
3480 Print the full absolute name of the library file @var{library} that
3481 would be used when linking---and don't do anything else. With this
3482 option, GCC does not compile or link anything; it just prints the
3483 file name.
3484
3485 @item -print-multi-directory
3486 @opindex print-multi-directory
3487 Print the directory name corresponding to the multilib selected by any
3488 other switches present in the command line. This directory is supposed
3489 to exist in @env{GCC_EXEC_PREFIX}.
3490
3491 @item -print-multi-lib
3492 @opindex print-multi-lib
3493 Print the mapping from multilib directory names to compiler switches
3494 that enable them. The directory name is separated from the switches by
3495 @samp{;}, and each switch starts with an @samp{@@} instead of the
3496 @samp{-}, without spaces between multiple switches. This is supposed to
3497 ease shell-processing.
3498
3499 @item -print-prog-name=@var{program}
3500 @opindex print-prog-name
3501 Like @option{-print-file-name}, but searches for a program such as @samp{cpp}.
3502
3503 @item -print-libgcc-file-name
3504 @opindex print-libgcc-file-name
3505 Same as @option{-print-file-name=libgcc.a}.
3506
3507 This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
3508 but you do want to link with @file{libgcc.a}. You can do
3509
3510 @smallexample
3511 gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
3512 @end smallexample
3513
3514 @item -print-search-dirs
3515 @opindex print-search-dirs
3516 Print the name of the configured installation directory and a list of
3517 program and library directories gcc will search---and don't do anything else.
3518
3519 This is useful when gcc prints the error message
3520 @samp{installation problem, cannot exec cpp0: No such file or directory}.
3521 To resolve this you either need to put @file{cpp0} and the other compiler
3522 components where gcc expects to find them, or you can set the environment
3523 variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
3524 Don't forget the trailing '/'.
3525 @xref{Environment Variables}.
3526
3527 @item -dumpmachine
3528 @opindex dumpmachine
3529 Print the compiler's target machine (for example,
3530 @samp{i686-pc-linux-gnu})---and don't do anything else.
3531
3532 @item -dumpversion
3533 @opindex dumpversion
3534 Print the compiler version (for example, @samp{3.0})---and don't do
3535 anything else.
3536
3537 @item -dumpspecs
3538 @opindex dumpspecs
3539 Print the compiler's built-in specs---and don't do anything else. (This
3540 is used when GCC itself is being built.) @xref{Spec Files}.
3541
3542 @item -feliminate-unused-debug-types
3543 @opindex feliminate-unused-debug-types
3544 Normally, when producing DWARF2 output, GCC will emit debugging
3545 information for all types declared in a compilation
3546 unit, regardless of whether or not they are actually used
3547 in that compilation unit. Sometimes this is useful, such as
3548 if, in the debugger, you want to cast a value to a type that is
3549 not actually used in your program (but is declared). More often,
3550 however, this results in a significant amount of wasted space.
3551 With this option, GCC will avoid producing debug symbol output
3552 for types that are nowhere used in the source file being compiled.
3553 @end table
3554
3555 @node Optimize Options
3556 @section Options That Control Optimization
3557 @cindex optimize options
3558 @cindex options, optimization
3559
3560 These options control various sorts of optimizations.
3561
3562 Without any optimization option, the compiler's goal is to reduce the
3563 cost of compilation and to make debugging produce the expected
3564 results. Statements are independent: if you stop the program with a
3565 breakpoint between statements, you can then assign a new value to any
3566 variable or change the program counter to any other statement in the
3567 function and get exactly the results you would expect from the source
3568 code.
3569
3570 Turning on optimization flags makes the compiler attempt to improve
3571 the performance and/or code size at the expense of compilation time
3572 and possibly the ability to debug the program.
3573
3574 The compiler performs optimization based on the knowledge it has of
3575 the program. Using the @option{-funit-at-a-time} flag will allow the
3576 compiler to consider information gained from later functions in the
3577 file when compiling a function. Compiling multiple files at once to a
3578 single output file (and using @option{-funit-at-a-time}) will allow
3579 the compiler to use information gained from all of the files when
3580 compiling each of them.
3581
3582 Not all optimizations are controlled directly by a flag. Only
3583 optimizations that have a flag are listed.
3584
3585 @table @gcctabopt
3586 @item -O
3587 @itemx -O1
3588 @opindex O
3589 @opindex O1
3590 Optimize. Optimizing compilation takes somewhat more time, and a lot
3591 more memory for a large function.
3592
3593 With @option{-O}, the compiler tries to reduce code size and execution
3594 time, without performing any optimizations that take a great deal of
3595 compilation time.
3596
3597 @option{-O} turns on the following optimization flags:
3598 @gccoptlist{-fdefer-pop @gol
3599 -fmerge-constants @gol
3600 -fthread-jumps @gol
3601 -floop-optimize @gol
3602 -fif-conversion @gol
3603 -fif-conversion2 @gol
3604 -fdelayed-branch @gol
3605 -fguess-branch-probability @gol
3606 -fcprop-registers}
3607
3608 @option{-O} also turns on @option{-fomit-frame-pointer} on machines
3609 where doing so does not interfere with debugging.
3610
3611 @item -O2
3612 @opindex O2
3613 Optimize even more. GCC performs nearly all supported optimizations
3614 that do not involve a space-speed tradeoff. The compiler does not
3615 perform loop unrolling or function inlining when you specify @option{-O2}.
3616 As compared to @option{-O}, this option increases both compilation time
3617 and the performance of the generated code.
3618
3619 @option{-O2} turns on all optimization flags specified by @option{-O}. It
3620 also turns on the following optimization flags:
3621 @gccoptlist{-fforce-mem @gol
3622 -foptimize-sibling-calls @gol
3623 -fstrength-reduce @gol
3624 -fcse-follow-jumps -fcse-skip-blocks @gol
3625 -frerun-cse-after-loop -frerun-loop-opt @gol
3626 -fgcse -fgcse-lm -fgcse-sm -fgcse-las @gol
3627 -fdelete-null-pointer-checks @gol
3628 -fexpensive-optimizations @gol
3629 -fregmove @gol
3630 -fschedule-insns -fschedule-insns2 @gol
3631 -fsched-interblock -fsched-spec @gol
3632 -fcaller-saves @gol
3633 -fpeephole2 @gol
3634 -freorder-blocks -freorder-functions @gol
3635 -fstrict-aliasing @gol
3636 -funit-at-a-time @gol
3637 -falign-functions -falign-jumps @gol
3638 -falign-loops -falign-labels @gol
3639 -fcrossjumping}
3640
3641 Please note the warning under @option{-fgcse} about
3642 invoking @option{-O2} on programs that use computed gotos.
3643
3644 @item -O3
3645 @opindex O3
3646 Optimize yet more. @option{-O3} turns on all optimizations specified by
3647 @option{-O2} and also turns on the @option{-finline-functions},
3648 @option{-fweb} and @option{-frename-registers} options.
3649
3650 @item -O0
3651 @opindex O0
3652 Do not optimize. This is the default.
3653
3654 @item -Os
3655 @opindex Os
3656 Optimize for size. @option{-Os} enables all @option{-O2} optimizations that
3657 do not typically increase code size. It also performs further
3658 optimizations designed to reduce code size.
3659
3660 @option{-Os} disables the following optimization flags:
3661 @gccoptlist{-falign-functions -falign-jumps -falign-loops @gol
3662 -falign-labels -freorder-blocks -fprefetch-loop-arrays}
3663
3664 If you use multiple @option{-O} options, with or without level numbers,
3665 the last such option is the one that is effective.
3666 @end table
3667
3668 Options of the form @option{-f@var{flag}} specify machine-independent
3669 flags. Most flags have both positive and negative forms; the negative
3670 form of @option{-ffoo} would be @option{-fno-foo}. In the table
3671 below, only one of the forms is listed---the one you typically will
3672 use. You can figure out the other form by either removing @samp{no-}
3673 or adding it.
3674
3675 The following options control specific optimizations. They are either
3676 activated by @option{-O} options or are related to ones that are. You
3677 can use the following flags in the rare cases when ``fine-tuning'' of
3678 optimizations to be performed is desired.
3679
3680 @table @gcctabopt
3681 @item -fno-default-inline
3682 @opindex fno-default-inline
3683 Do not make member functions inline by default merely because they are
3684 defined inside the class scope (C++ only). Otherwise, when you specify
3685 @w{@option{-O}}, member functions defined inside class scope are compiled
3686 inline by default; i.e., you don't need to add @samp{inline} in front of
3687 the member function name.
3688
3689 @item -fno-defer-pop
3690 @opindex fno-defer-pop
3691 Always pop the arguments to each function call as soon as that function
3692 returns. For machines which must pop arguments after a function call,
3693 the compiler normally lets arguments accumulate on the stack for several
3694 function calls and pops them all at once.
3695
3696 Disabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
3697
3698 @item -fforce-mem
3699 @opindex fforce-mem
3700 Force memory operands to be copied into registers before doing
3701 arithmetic on them. This produces better code by making all memory
3702 references potential common subexpressions. When they are not common
3703 subexpressions, instruction combination should eliminate the separate
3704 register-load.
3705
3706 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3707
3708 @item -fforce-addr
3709 @opindex fforce-addr
3710 Force memory address constants to be copied into registers before
3711 doing arithmetic on them. This may produce better code just as
3712 @option{-fforce-mem} may.
3713
3714 @item -fomit-frame-pointer
3715 @opindex fomit-frame-pointer
3716 Don't keep the frame pointer in a register for functions that
3717 don't need one. This avoids the instructions to save, set up and
3718 restore frame pointers; it also makes an extra register available
3719 in many functions. @strong{It also makes debugging impossible on
3720 some machines.}
3721
3722 On some machines, such as the VAX, this flag has no effect, because
3723 the standard calling sequence automatically handles the frame pointer
3724 and nothing is saved by pretending it doesn't exist. The
3725 machine-description macro @code{FRAME_POINTER_REQUIRED} controls
3726 whether a target machine supports this flag. @xref{Registers,,Register
3727 Usage, gccint, GNU Compiler Collection (GCC) Internals}.
3728
3729 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
3730
3731 @item -foptimize-sibling-calls
3732 @opindex foptimize-sibling-calls
3733 Optimize sibling and tail recursive calls.
3734
3735 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3736
3737 @item -fno-inline
3738 @opindex fno-inline
3739 Don't pay attention to the @code{inline} keyword. Normally this option
3740 is used to keep the compiler from expanding any functions inline.
3741 Note that if you are not optimizing, no functions can be expanded inline.
3742
3743 @item -finline-functions
3744 @opindex finline-functions
3745 Integrate all simple functions into their callers. The compiler
3746 heuristically decides which functions are simple enough to be worth
3747 integrating in this way.
3748
3749 If all calls to a given function are integrated, and the function is
3750 declared @code{static}, then the function is normally not output as
3751 assembler code in its own right.
3752
3753 Enabled at level @option{-O3}.
3754
3755 @item -finline-limit=@var{n}
3756 @opindex finline-limit
3757 By default, gcc limits the size of functions that can be inlined. This flag
3758 allows the control of this limit for functions that are explicitly marked as
3759 inline (i.e., marked with the inline keyword or defined within the class
3760 definition in c++). @var{n} is the size of functions that can be inlined in
3761 number of pseudo instructions (not counting parameter handling). The default
3762 value of @var{n} is 600.
3763 Increasing this value can result in more inlined code at
3764 the cost of compilation time and memory consumption. Decreasing usually makes
3765 the compilation faster and less code will be inlined (which presumably
3766 means slower programs). This option is particularly useful for programs that
3767 use inlining heavily such as those based on recursive templates with C++.
3768
3769 Inlining is actually controlled by a number of parameters, which may be
3770 specified individually by using @option{--param @var{name}=@var{value}}.
3771 The @option{-finline-limit=@var{n}} option sets some of these parameters
3772 as follows:
3773
3774 @table @gcctabopt
3775 @item max-inline-insns-single
3776 is set to @var{n}/2.
3777 @item max-inline-insns-auto
3778 is set to @var{n}/2.
3779 @item min-inline-insns
3780 is set to 130 or @var{n}/4, whichever is smaller.
3781 @item max-inline-insns-rtl
3782 is set to @var{n}.
3783 @end table
3784
3785 See below for a documentation of the individual
3786 parameters controlling inlining.
3787
3788 @emph{Note:} pseudo instruction represents, in this particular context, an
3789 abstract measurement of function's size. In no way, it represents a count
3790 of assembly instructions and as such its exact meaning might change from one
3791 release to an another.
3792
3793 @item -fkeep-inline-functions
3794 @opindex fkeep-inline-functions
3795 Even if all calls to a given function are integrated, and the function
3796 is declared @code{static}, nevertheless output a separate run-time
3797 callable version of the function. This switch does not affect
3798 @code{extern inline} functions.
3799
3800 @item -fkeep-static-consts
3801 @opindex fkeep-static-consts
3802 Emit variables declared @code{static const} when optimization isn't turned
3803 on, even if the variables aren't referenced.
3804
3805 GCC enables this option by default. If you want to force the compiler to
3806 check if the variable was referenced, regardless of whether or not
3807 optimization is turned on, use the @option{-fno-keep-static-consts} option.
3808
3809 @item -fmerge-constants
3810 Attempt to merge identical constants (string constants and floating point
3811 constants) across compilation units.
3812
3813 This option is the default for optimized compilation if the assembler and
3814 linker support it. Use @option{-fno-merge-constants} to inhibit this
3815 behavior.
3816
3817 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
3818
3819 @item -fmerge-all-constants
3820 Attempt to merge identical constants and identical variables.
3821
3822 This option implies @option{-fmerge-constants}. In addition to
3823 @option{-fmerge-constants} this considers e.g. even constant initialized
3824 arrays or initialized constant variables with integral or floating point
3825 types. Languages like C or C++ require each non-automatic variable to
3826 have distinct location, so using this option will result in non-conforming
3827 behavior.
3828
3829 @item -fnew-ra
3830 @opindex fnew-ra
3831 Use a graph coloring register allocator. Currently this option is meant
3832 for testing, so we are interested to hear about miscompilations with
3833 @option{-fnew-ra}.
3834
3835 @item -fno-branch-count-reg
3836 @opindex fno-branch-count-reg
3837 Do not use ``decrement and branch'' instructions on a count register,
3838 but instead generate a sequence of instructions that decrement a
3839 register, compare it against zero, then branch based upon the result.
3840 This option is only meaningful on architectures that support such
3841 instructions, which include x86, PowerPC, IA-64 and S/390.
3842
3843 The default is @option{-fbranch-count-reg}, enabled when
3844 @option{-fstrength-reduce} is enabled.
3845
3846 @item -fno-function-cse
3847 @opindex fno-function-cse
3848 Do not put function addresses in registers; make each instruction that
3849 calls a constant function contain the function's address explicitly.
3850
3851 This option results in less efficient code, but some strange hacks
3852 that alter the assembler output may be confused by the optimizations
3853 performed when this option is not used.
3854
3855 The default is @option{-ffunction-cse}
3856
3857 @item -fno-zero-initialized-in-bss
3858 @opindex fno-zero-initialized-in-bss
3859 If the target supports a BSS section, GCC by default puts variables that
3860 are initialized to zero into BSS@. This can save space in the resulting
3861 code.
3862
3863 This option turns off this behavior because some programs explicitly
3864 rely on variables going to the data section. E.g., so that the
3865 resulting executable can find the beginning of that section and/or make
3866 assumptions based on that.
3867
3868 The default is @option{-fzero-initialized-in-bss}.
3869
3870 @item -fstrength-reduce
3871 @opindex fstrength-reduce
3872 Perform the optimizations of loop strength reduction and
3873 elimination of iteration variables.
3874
3875 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3876
3877 @item -fthread-jumps
3878 @opindex fthread-jumps
3879 Perform optimizations where we check to see if a jump branches to a
3880 location where another comparison subsumed by the first is found. If
3881 so, the first branch is redirected to either the destination of the
3882 second branch or a point immediately following it, depending on whether
3883 the condition is known to be true or false.
3884
3885 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
3886
3887 @item -fcse-follow-jumps
3888 @opindex fcse-follow-jumps
3889 In common subexpression elimination, scan through jump instructions
3890 when the target of the jump is not reached by any other path. For
3891 example, when CSE encounters an @code{if} statement with an
3892 @code{else} clause, CSE will follow the jump when the condition
3893 tested is false.
3894
3895 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3896
3897 @item -fcse-skip-blocks
3898 @opindex fcse-skip-blocks
3899 This is similar to @option{-fcse-follow-jumps}, but causes CSE to
3900 follow jumps which conditionally skip over blocks. When CSE
3901 encounters a simple @code{if} statement with no else clause,
3902 @option{-fcse-skip-blocks} causes CSE to follow the jump around the
3903 body of the @code{if}.
3904
3905 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3906
3907 @item -frerun-cse-after-loop
3908 @opindex frerun-cse-after-loop
3909 Re-run common subexpression elimination after loop optimizations has been
3910 performed.
3911
3912 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3913
3914 @item -frerun-loop-opt
3915 @opindex frerun-loop-opt
3916 Run the loop optimizer twice.
3917
3918 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3919
3920 @item -fgcse
3921 @opindex fgcse
3922 Perform a global common subexpression elimination pass.
3923 This pass also performs global constant and copy propagation.
3924
3925 @emph{Note:} When compiling a program using computed gotos, a GCC
3926 extension, you may get better runtime performance if you disable
3927 the global common subexpression elimination pass by adding
3928 @option{-fno-gcse} to the command line.
3929
3930 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3931
3932 @item -fgcse-lm
3933 @opindex fgcse-lm
3934 When @option{-fgcse-lm} is enabled, global common subexpression elimination will
3935 attempt to move loads which are only killed by stores into themselves. This
3936 allows a loop containing a load/store sequence to be changed to a load outside
3937 the loop, and a copy/store within the loop.
3938
3939 Enabled by default when gcse is enabled.
3940
3941 @item -fgcse-sm
3942 @opindex fgcse-sm
3943 When @option{-fgcse-sm} is enabled, a store motion pass is run after
3944 global common subexpression elimination. This pass will attempt to move
3945 stores out of loops. When used in conjunction with @option{-fgcse-lm},
3946 loops containing a load/store sequence can be changed to a load before
3947 the loop and a store after the loop.
3948
3949 Enabled by default when gcse is enabled.
3950
3951 @item -fgcse-las
3952 @opindex fgcse-las
3953 When @option{-fgcse-las} is enabled, the global common subexpression
3954 elimination pass eliminates redundant loads that come after stores to the
3955 same memory location (both partial and full redundancies).
3956
3957 Enabled by default when gcse is enabled.
3958
3959 @item -floop-optimize
3960 @opindex floop-optimize
3961 Perform loop optimizations: move constant expressions out of loops, simplify
3962 exit test conditions and optionally do strength-reduction and loop unrolling as
3963 well.
3964
3965 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
3966
3967 @item -fcrossjumping
3968 @opindex crossjumping
3969 Perform cross-jumping transformation. This transformation unifies equivalent code and save code size. The
3970 resulting code may or may not perform better than without cross-jumping.
3971
3972 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
3973
3974 @item -fif-conversion
3975 @opindex if-conversion
3976 Attempt to transform conditional jumps into branch-less equivalents. This
3977 include use of conditional moves, min, max, set flags and abs instructions, and
3978 some tricks doable by standard arithmetics. The use of conditional execution
3979 on chips where it is available is controlled by @code{if-conversion2}.
3980
3981 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
3982
3983 @item -fif-conversion2
3984 @opindex if-conversion2
3985 Use conditional execution (where available) to transform conditional jumps into
3986 branch-less equivalents.
3987
3988 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
3989
3990 @item -fdelete-null-pointer-checks
3991 @opindex fdelete-null-pointer-checks
3992 Use global dataflow analysis to identify and eliminate useless checks
3993 for null pointers. The compiler assumes that dereferencing a null
3994 pointer would have halted the program. If a pointer is checked after
3995 it has already been dereferenced, it cannot be null.
3996
3997 In some environments, this assumption is not true, and programs can
3998 safely dereference null pointers. Use
3999 @option{-fno-delete-null-pointer-checks} to disable this optimization
4000 for programs which depend on that behavior.
4001
4002 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4003
4004 @item -fexpensive-optimizations
4005 @opindex fexpensive-optimizations
4006 Perform a number of minor optimizations that are relatively expensive.
4007
4008 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4009
4010 @item -foptimize-register-move
4011 @itemx -fregmove
4012 @opindex foptimize-register-move
4013 @opindex fregmove
4014 Attempt to reassign register numbers in move instructions and as
4015 operands of other simple instructions in order to maximize the amount of
4016 register tying. This is especially helpful on machines with two-operand
4017 instructions.
4018
4019 Note @option{-fregmove} and @option{-foptimize-register-move} are the same
4020 optimization.
4021
4022 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4023
4024 @item -fdelayed-branch
4025 @opindex fdelayed-branch
4026 If supported for the target machine, attempt to reorder instructions
4027 to exploit instruction slots available after delayed branch
4028 instructions.
4029
4030 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4031
4032 @item -fschedule-insns
4033 @opindex fschedule-insns
4034 If supported for the target machine, attempt to reorder instructions to
4035 eliminate execution stalls due to required data being unavailable. This
4036 helps machines that have slow floating point or memory load instructions
4037 by allowing other instructions to be issued until the result of the load
4038 or floating point instruction is required.
4039
4040 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4041
4042 @item -fschedule-insns2
4043 @opindex fschedule-insns2
4044 Similar to @option{-fschedule-insns}, but requests an additional pass of
4045 instruction scheduling after register allocation has been done. This is
4046 especially useful on machines with a relatively small number of
4047 registers and where memory load instructions take more than one cycle.
4048
4049 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4050
4051 @item -fno-sched-interblock
4052 @opindex fno-sched-interblock
4053 Don't schedule instructions across basic blocks. This is normally
4054 enabled by default when scheduling before register allocation, i.e.@:
4055 with @option{-fschedule-insns} or at @option{-O2} or higher.
4056
4057 @item -fno-sched-spec
4058 @opindex fno-sched-spec
4059 Don't allow speculative motion of non-load instructions. This is normally
4060 enabled by default when scheduling before register allocation, i.e.@:
4061 with @option{-fschedule-insns} or at @option{-O2} or higher.
4062
4063 @item -fsched-spec-load
4064 @opindex fsched-spec-load
4065 Allow speculative motion of some load instructions. This only makes
4066 sense when scheduling before register allocation, i.e.@: with
4067 @option{-fschedule-insns} or at @option{-O2} or higher.
4068
4069 @item -fsched-spec-load-dangerous
4070 @opindex fsched-spec-load-dangerous
4071 Allow speculative motion of more load instructions. This only makes
4072 sense when scheduling before register allocation, i.e.@: with
4073 @option{-fschedule-insns} or at @option{-O2} or higher.
4074
4075 @item -fsched-stalled-insns=@var{n}
4076 @opindex fsched-stalled-insns
4077 Define how many insns (if any) can be moved prematurely from the queue
4078 of stalled insns into the ready list, during the second scheduling pass.
4079
4080 @item -fsched-stalled-insns-dep=@var{n}
4081 @opindex fsched-stalled-insns-dep
4082 Define how many insn groups (cycles) will be examined for a dependency
4083 on a stalled insn that is candidate for premature removal from the queue
4084 of stalled insns. Has an effect only during the second scheduling pass,
4085 and only if @option{-fsched-stalled-insns} is used and its value is not zero.
4086
4087 @item -fsched2-use-superblocks
4088 @opindex fsched2-use-superblocks
4089 When scheduling after register allocation, do use superblock scheduling
4090 algorithm. Superblock scheduling allows motion across basic block boundaries
4091 resulting on faster schedules. This option is experimental, as not all machine
4092 descriptions used by GCC model the CPU closely enough to avoid unreliable
4093 results from the algorithm.
4094
4095 This only makes sense when scheduling after register allocation, i.e.@: with
4096 @option{-fschedule-insns2} or at @option{-O2} or higher.
4097
4098 @item -fsched2-use-traces
4099 @opindex fsched2-use-traces
4100 Use @option{-fsched2-use-superblocks} algorithm when scheduling after register
4101 allocation and additionally perform code duplication in order to increase the
4102 size of superblocks using tracer pass. See @option{-ftracer} for details on
4103 trace formation.
4104
4105 This mode should produce faster but significantly longer programs. Also
4106 without @code{-fbranch-probabilities} the traces constructed may not match the
4107 reality and hurt the performance. This only makes
4108 sense when scheduling after register allocation, i.e.@: with
4109 @option{-fschedule-insns2} or at @option{-O2} or higher.
4110
4111 @item -fcaller-saves
4112 @opindex fcaller-saves
4113 Enable values to be allocated in registers that will be clobbered by
4114 function calls, by emitting extra instructions to save and restore the
4115 registers around such calls. Such allocation is done only when it
4116 seems to result in better code than would otherwise be produced.
4117
4118 This option is always enabled by default on certain machines, usually
4119 those which have no call-preserved registers to use instead.
4120
4121 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4122
4123 @item -fmove-all-movables
4124 @opindex fmove-all-movables
4125 Forces all invariant computations in loops to be moved
4126 outside the loop.
4127
4128 @item -freduce-all-givs
4129 @opindex freduce-all-givs
4130 Forces all general-induction variables in loops to be
4131 strength-reduced.
4132
4133 @emph{Note:} When compiling programs written in Fortran,
4134 @option{-fmove-all-movables} and @option{-freduce-all-givs} are enabled
4135 by default when you use the optimizer.
4136
4137 These options may generate better or worse code; results are highly
4138 dependent on the structure of loops within the source code.
4139
4140 These two options are intended to be removed someday, once
4141 they have helped determine the efficacy of various
4142 approaches to improving loop optimizations.
4143
4144 Please let us (@w{@email{gcc@@gcc.gnu.org}} and @w{@email{fortran@@gnu.org}})
4145 know how use of these options affects
4146 the performance of your production code.
4147 We're very interested in code that runs @emph{slower}
4148 when these options are @emph{enabled}.
4149
4150 @item -fno-peephole
4151 @itemx -fno-peephole2
4152 @opindex fno-peephole
4153 @opindex fno-peephole2
4154 Disable any machine-specific peephole optimizations. The difference
4155 between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
4156 are implemented in the compiler; some targets use one, some use the
4157 other, a few use both.
4158
4159 @option{-fpeephole} is enabled by default.
4160 @option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4161
4162 @item -fno-guess-branch-probability
4163 @opindex fno-guess-branch-probability
4164 Do not guess branch probabilities using a randomized model.
4165
4166 Sometimes gcc will opt to use a randomized model to guess branch
4167 probabilities, when none are available from either profiling feedback
4168 (@option{-fprofile-arcs}) or @samp{__builtin_expect}. This means that
4169 different runs of the compiler on the same program may produce different
4170 object code.
4171
4172 In a hard real-time system, people don't want different runs of the
4173 compiler to produce code that has different behavior; minimizing
4174 non-determinism is of paramount import. This switch allows users to
4175 reduce non-determinism, possibly at the expense of inferior
4176 optimization.
4177
4178 The default is @option{-fguess-branch-probability} at levels
4179 @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4180
4181 @item -freorder-blocks
4182 @opindex freorder-blocks
4183 Reorder basic blocks in the compiled function in order to reduce number of
4184 taken branches and improve code locality.
4185
4186 Enabled at levels @option{-O2}, @option{-O3}.
4187
4188 @item -freorder-functions
4189 @opindex freorder-functions
4190 Reorder basic blocks in the compiled function in order to reduce number of
4191 taken branches and improve code locality. This is implemented by using special
4192 subsections @code{text.hot} for most frequently executed functions and
4193 @code{text.unlikely} for unlikely executed functions. Reordering is done by
4194 the linker so object file format must support named sections and linker must
4195 place them in a reasonable way.
4196
4197 Also profile feedback must be available in to make this option effective. See
4198 @option{-fprofile-arcs} for details.
4199
4200 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4201
4202 @item -fstrict-aliasing
4203 @opindex fstrict-aliasing
4204 Allows the compiler to assume the strictest aliasing rules applicable to
4205 the language being compiled. For C (and C++), this activates
4206 optimizations based on the type of expressions. In particular, an
4207 object of one type is assumed never to reside at the same address as an
4208 object of a different type, unless the types are almost the same. For
4209 example, an @code{unsigned int} can alias an @code{int}, but not a
4210 @code{void*} or a @code{double}. A character type may alias any other
4211 type.
4212
4213 Pay special attention to code like this:
4214 @smallexample
4215 union a_union @{
4216 int i;
4217 double d;
4218 @};
4219
4220 int f() @{
4221 a_union t;
4222 t.d = 3.0;
4223 return t.i;
4224 @}
4225 @end smallexample
4226 The practice of reading from a different union member than the one most
4227 recently written to (called ``type-punning'') is common. Even with
4228 @option{-fstrict-aliasing}, type-punning is allowed, provided the memory
4229 is accessed through the union type. So, the code above will work as
4230 expected. However, this code might not:
4231 @smallexample
4232 int f() @{
4233 a_union t;
4234 int* ip;
4235 t.d = 3.0;
4236 ip = &t.i;
4237 return *ip;
4238 @}
4239 @end smallexample
4240
4241 Every language that wishes to perform language-specific alias analysis
4242 should define a function that computes, given an @code{tree}
4243 node, an alias set for the node. Nodes in different alias sets are not
4244 allowed to alias. For an example, see the C front-end function
4245 @code{c_get_alias_set}.
4246
4247 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4248
4249 @item -falign-functions
4250 @itemx -falign-functions=@var{n}
4251 @opindex falign-functions
4252 Align the start of functions to the next power-of-two greater than
4253 @var{n}, skipping up to @var{n} bytes. For instance,
4254 @option{-falign-functions=32} aligns functions to the next 32-byte
4255 boundary, but @option{-falign-functions=24} would align to the next
4256 32-byte boundary only if this can be done by skipping 23 bytes or less.
4257
4258 @option{-fno-align-functions} and @option{-falign-functions=1} are
4259 equivalent and mean that functions will not be aligned.
4260
4261 Some assemblers only support this flag when @var{n} is a power of two;
4262 in that case, it is rounded up.
4263
4264 If @var{n} is not specified or is zero, use a machine-dependent default.
4265
4266 Enabled at levels @option{-O2}, @option{-O3}.
4267
4268 @item -falign-labels
4269 @itemx -falign-labels=@var{n}
4270 @opindex falign-labels
4271 Align all branch targets to a power-of-two boundary, skipping up to
4272 @var{n} bytes like @option{-falign-functions}. This option can easily
4273 make code slower, because it must insert dummy operations for when the
4274 branch target is reached in the usual flow of the code.
4275
4276 @option{-fno-align-labels} and @option{-falign-labels=1} are
4277 equivalent and mean that labels will not be aligned.
4278
4279 If @option{-falign-loops} or @option{-falign-jumps} are applicable and
4280 are greater than this value, then their values are used instead.
4281
4282 If @var{n} is not specified or is zero, use a machine-dependent default
4283 which is very likely to be @samp{1}, meaning no alignment.
4284
4285 Enabled at levels @option{-O2}, @option{-O3}.
4286
4287 @item -falign-loops
4288 @itemx -falign-loops=@var{n}
4289 @opindex falign-loops
4290 Align loops to a power-of-two boundary, skipping up to @var{n} bytes
4291 like @option{-falign-functions}. The hope is that the loop will be
4292 executed many times, which will make up for any execution of the dummy
4293 operations.
4294
4295 @option{-fno-align-loops} and @option{-falign-loops=1} are
4296 equivalent and mean that loops will not be aligned.
4297
4298 If @var{n} is not specified or is zero, use a machine-dependent default.
4299
4300 Enabled at levels @option{-O2}, @option{-O3}.
4301
4302 @item -falign-jumps
4303 @itemx -falign-jumps=@var{n}
4304 @opindex falign-jumps
4305 Align branch targets to a power-of-two boundary, for branch targets
4306 where the targets can only be reached by jumping, skipping up to @var{n}
4307 bytes like @option{-falign-functions}. In this case, no dummy operations
4308 need be executed.
4309
4310 @option{-fno-align-jumps} and @option{-falign-jumps=1} are
4311 equivalent and mean that loops will not be aligned.
4312
4313 If @var{n} is not specified or is zero, use a machine-dependent default.
4314
4315 Enabled at levels @option{-O2}, @option{-O3}.
4316
4317 @item -frename-registers
4318 @opindex frename-registers
4319 Attempt to avoid false dependencies in scheduled code by making use
4320 of registers left over after register allocation. This optimization
4321 will most benefit processors with lots of registers. It can, however,
4322 make debugging impossible, since variables will no longer stay in
4323 a ``home register''.
4324
4325 @item -fweb
4326 @opindex fweb
4327 Constructs webs as commonly used for register allocation purposes and assign
4328 each web individual pseudo register. This allows our register allocation pass
4329 to operate on pseudos directly, but also strengthens several other optimization
4330 passes, such as CSE, loop optimizer and trivial dead code remover. It can,
4331 however, make debugging impossible, since variables will no longer stay in a
4332 ``home register''.
4333
4334 Enabled at levels @option{-O3}.
4335
4336 @item -fno-cprop-registers
4337 @opindex fno-cprop-registers
4338 After register allocation and post-register allocation instruction splitting,
4339 we perform a copy-propagation pass to try to reduce scheduling dependencies
4340 and occasionally eliminate the copy.
4341
4342 Disabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4343
4344 @item -fprofile-generate
4345 @opindex fprofile-generate
4346 Enable options usually used for instrumenting application to produce profile usefull
4347 for later recompilation profile feedback based optimization.
4348
4349 The following options are enabled: @code{-fprofile-arcs}, @code{-fprofile-values}, @code{-fvpt}
4350
4351 @item -fprofile-use
4352 @opindex fprofile-use
4353 Enable profile feedback directed optimizations, and optimizations
4354 generally profitable only with profile feedback available.
4355
4356 The following options are enabled: @code{-fbranch-probabilities},
4357 @code{-fvpt}, @code{-funroll-loops}, @code{-fpeel-loops}, @code{-ftracer}.
4358
4359 @end table
4360
4361 The following options control compiler behavior regarding floating
4362 point arithmetic. These options trade off between speed and
4363 correctness. All must be specifically enabled.
4364
4365 @table @gcctabopt
4366 @item -ffloat-store
4367 @opindex ffloat-store
4368 Do not store floating point variables in registers, and inhibit other
4369 options that might change whether a floating point value is taken from a
4370 register or memory.
4371
4372 @cindex floating point precision
4373 This option prevents undesirable excess precision on machines such as
4374 the 68000 where the floating registers (of the 68881) keep more
4375 precision than a @code{double} is supposed to have. Similarly for the
4376 x86 architecture. For most programs, the excess precision does only
4377 good, but a few programs rely on the precise definition of IEEE floating
4378 point. Use @option{-ffloat-store} for such programs, after modifying
4379 them to store all pertinent intermediate computations into variables.
4380
4381 @item -ffast-math
4382 @opindex ffast-math
4383 Sets @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, @*
4384 @option{-fno-trapping-math}, @option{-ffinite-math-only},
4385 @option{-fno-rounding-math} and @option{-fno-signaling-nans}.
4386
4387 This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
4388
4389 This option should never be turned on by any @option{-O} option since
4390 it can result in incorrect output for programs which depend on
4391 an exact implementation of IEEE or ISO rules/specifications for
4392 math functions.
4393
4394 @item -fno-math-errno
4395 @opindex fno-math-errno
4396 Do not set ERRNO after calling math functions that are executed
4397 with a single instruction, e.g., sqrt. A program that relies on
4398 IEEE exceptions for math error handling may want to use this flag
4399 for speed while maintaining IEEE arithmetic compatibility.
4400
4401 This option should never be turned on by any @option{-O} option since
4402 it can result in incorrect output for programs which depend on
4403 an exact implementation of IEEE or ISO rules/specifications for
4404 math functions.
4405
4406 The default is @option{-fmath-errno}.
4407
4408 @item -funsafe-math-optimizations
4409 @opindex funsafe-math-optimizations
4410 Allow optimizations for floating-point arithmetic that (a) assume
4411 that arguments and results are valid and (b) may violate IEEE or
4412 ANSI standards. When used at link-time, it may include libraries
4413 or startup files that change the default FPU control word or other
4414 similar optimizations.
4415
4416 This option should never be turned on by any @option{-O} option since
4417 it can result in incorrect output for programs which depend on
4418 an exact implementation of IEEE or ISO rules/specifications for
4419 math functions.
4420
4421 The default is @option{-fno-unsafe-math-optimizations}.
4422
4423 @item -ffinite-math-only
4424 @opindex ffinite-math-only
4425 Allow optimizations for floating-point arithmetic that assume
4426 that arguments and results are not NaNs or +-Infs.
4427
4428 This option should never be turned on by any @option{-O} option since
4429 it can result in incorrect output for programs which depend on
4430 an exact implementation of IEEE or ISO rules/specifications.
4431
4432 The default is @option{-fno-finite-math-only}.
4433
4434 @item -fno-trapping-math
4435 @opindex fno-trapping-math
4436 Compile code assuming that floating-point operations cannot generate
4437 user-visible traps. These traps include division by zero, overflow,
4438 underflow, inexact result and invalid operation. This option implies
4439 @option{-fno-signaling-nans}. Setting this option may allow faster
4440 code if one relies on ``non-stop'' IEEE arithmetic, for example.
4441
4442 This option should never be turned on by any @option{-O} option since
4443 it can result in incorrect output for programs which depend on
4444 an exact implementation of IEEE or ISO rules/specifications for
4445 math functions.
4446
4447 The default is @option{-ftrapping-math}.
4448
4449 @item -frounding-math
4450 @opindex frounding-math
4451 Disable transformations and optimizations that assume default floating
4452 point rounding behavior. This is round-to-zero for all floating point
4453 to integer conversions, and round-to-nearest for all other arithmetic
4454 truncations. This option should be specified for programs that change
4455 the FP rounding mode dynamically, or that may be executed with a
4456 non-default rounding mode. This option disables constant folding of
4457 floating point expressions at compile-time (which may be affected by
4458 rounding mode) and arithmetic transformations that are unsafe in the
4459 presence of sign-dependent rounding modes.
4460
4461 The default is @option{-fno-rounding-math}.
4462
4463 This option is experimental and does not currently guarantee to
4464 disable all GCC optimizations that are affected by rounding mode.
4465 Future versions of gcc may provide finer control of this setting
4466 using C99's @code{FENV_ACCESS} pragma. This command line option
4467 will be used to specify the default state for @code{FENV_ACCESS}.
4468
4469 @item -fsignaling-nans
4470 @opindex fsignaling-nans
4471 Compile code assuming that IEEE signaling NaNs may generate user-visible
4472 traps during floating-point operations. Setting this option disables
4473 optimizations that may change the number of exceptions visible with
4474 signaling NaNs. This option implies @option{-ftrapping-math}.
4475
4476 This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
4477 be defined.
4478
4479 The default is @option{-fno-signaling-nans}.
4480
4481 This option is experimental and does not currently guarantee to
4482 disable all GCC optimizations that affect signaling NaN behavior.
4483
4484 @item -fsingle-precision-constant
4485 @opindex fsingle-precision-constant
4486 Treat floating point constant as single precision constant instead of
4487 implicitly converting it to double precision constant.
4488
4489
4490 @end table
4491
4492 The following options control optimizations that may improve
4493 performance, but are not enabled by any @option{-O} options. This
4494 section includes experimental options that may produce broken code.
4495
4496 @table @gcctabopt
4497 @item -fbranch-probabilities
4498 @opindex fbranch-probabilities
4499 After running a program compiled with @option{-fprofile-arcs}
4500 (@pxref{Debugging Options,, Options for Debugging Your Program or
4501 @command{gcc}}), you can compile it a second time using
4502 @option{-fbranch-probabilities}, to improve optimizations based on
4503 the number of times each branch was taken. When the program
4504 compiled with @option{-fprofile-arcs} exits it saves arc execution
4505 counts to a file called @file{@var{sourcename}.gcda} for each source
4506 file The information in this data file is very dependent on the
4507 structure of the generated code, so you must use the same source code
4508 and the same optimization options for both compilations.
4509
4510 With @option{-fbranch-probabilities}, GCC puts a
4511 @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
4512 These can be used to improve optimization. Currently, they are only
4513 used in one place: in @file{reorg.c}, instead of guessing which path a
4514 branch is mostly to take, the @samp{REG_BR_PROB} values are used to
4515 exactly determine which path is taken more often.
4516
4517 @item -fprofile-values
4518 @opindex fprofile-values
4519 If combined with @option{-fprofile-arcs}, it adds code so that some
4520 data about values of expressions in the program is gathered.
4521
4522 With @option{-fbranch-probabilities}, it reads back the data gathered
4523 from profiling values of expressions and adds @samp{REG_VALUE_PROFILE}
4524 notes to instructions for their later usage in optimizations.
4525
4526 @item -fvpt
4527 @opindex fvpt
4528 If combined with @option{-fprofile-arcs}, it instructs the compiler to add
4529 a code to gather information about values of expressions.
4530
4531 With @option{-fbranch-probabilities}, it reads back the data gathered
4532 and actually performs the optimizations based on them.
4533 Currently the optimizations include specialization of division operation
4534 using the knowledge about the value of the denominator.
4535
4536 @item -fnew-ra
4537 @opindex fnew-ra
4538 Use a graph coloring register allocator. Currently this option is meant
4539 for testing, so we are interested to hear about miscompilations with
4540 @option{-fnew-ra}.
4541
4542 @item -ftracer
4543 @opindex ftracer
4544 Perform tail duplication to enlarge superblock size. This transformation
4545 simplifies the control flow of the function allowing other optimizations to do
4546 better job.
4547
4548 @item -funit-at-a-time
4549 @opindex funit-at-a-time
4550 Parse the whole compilation unit before starting to produce code.
4551 This allows some extra optimizations to take place but consumes more
4552 memory.
4553
4554 @item -funroll-loops
4555 @opindex funroll-loops
4556 Unroll loops whose number of iterations can be determined at compile time or
4557 upon entry to the loop. @option{-funroll-loops} implies
4558 @option{-frerun-cse-after-loop}. It also turns on complete loop peeling
4559 (i.e. complete removal of loops with small constant number of iterations).
4560 This option makes code larger, and may or may not make it run faster.
4561
4562 @item -funroll-all-loops
4563 @opindex funroll-all-loops
4564 Unroll all loops, even if their number of iterations is uncertain when
4565 the loop is entered. This usually makes programs run more slowly.
4566 @option{-funroll-all-loops} implies the same options as
4567 @option{-funroll-loops}.
4568
4569 @item -fpeel-loops
4570 @opindex fpeel-loops
4571 Peels the loops for that there is enough information that they do not
4572 roll much (from profile feedback). It also turns on complete loop peeling
4573 (i.e. complete removal of loops with small constant number of iterations).
4574
4575 @item -funswitch-loops
4576 @opindex funswitch-loops
4577 Move branches with loop invariant conditions out of the loop, with duplicates
4578 of the loop on both branches (modified according to result of the condition).
4579
4580 @item -fold-unroll-loops
4581 @opindex fold-unroll-loops
4582 Unroll loops whose number of iterations can be determined at compile
4583 time or upon entry to the loop, using the old loop unroller whose loop
4584 recognition is based on notes from frontend. @option{-fold-unroll-loops} implies
4585 both @option{-fstrength-reduce} and @option{-frerun-cse-after-loop}. This
4586 option makes code larger, and may or may not make it run faster.
4587
4588 @item -fold-unroll-all-loops
4589 @opindex fold-unroll-all-loops
4590 Unroll all loops, even if their number of iterations is uncertain when
4591 the loop is entered. This is done using the old loop unroller whose loop
4592 recognition is based on notes from frontend. This usually makes programs run more slowly.
4593 @option{-fold-unroll-all-loops} implies the same options as
4594 @option{-fold-unroll-loops}.
4595
4596 @item -funswitch-loops
4597 @opindex funswitch-loops
4598 Move branches with loop invariant conditions out of the loop, with duplicates
4599 of the loop on both branches (modified according to result of the condition).
4600
4601 @item -funswitch-loops
4602 @opindex funswitch-loops
4603 Move branches with loop invariant conditions out of the loop, with duplicates
4604 of the loop on both branches (modified according to result of the condition).
4605
4606 @item -fprefetch-loop-arrays
4607 @opindex fprefetch-loop-arrays
4608 If supported by the target machine, generate instructions to prefetch
4609 memory to improve the performance of loops that access large arrays.
4610
4611 Disabled at level @option{-Os}.
4612
4613 @item -ffunction-sections
4614 @itemx -fdata-sections
4615 @opindex ffunction-sections
4616 @opindex fdata-sections
4617 Place each function or data item into its own section in the output
4618 file if the target supports arbitrary sections. The name of the
4619 function or the name of the data item determines the section's name
4620 in the output file.
4621
4622 Use these options on systems where the linker can perform optimizations
4623 to improve locality of reference in the instruction space. Most systems
4624 using the ELF object format and SPARC processors running Solaris 2 have
4625 linkers with such optimizations. AIX may have these optimizations in
4626 the future.
4627
4628 Only use these options when there are significant benefits from doing
4629 so. When you specify these options, the assembler and linker will
4630 create larger object and executable files and will also be slower.
4631 You will not be able to use @code{gprof} on all systems if you
4632 specify this option and you may have problems with debugging if
4633 you specify both this option and @option{-g}.
4634
4635 @item -fbranch-target-load-optimize
4636 @opindex fbranch-target-load-optimize
4637 Perform branch target register load optimization before prologue / epilogue
4638 threading.
4639 The use of target registers can typically be exposed only during reload,
4640 thus hoisting loads out of loops and doing inter-block scheduling needs
4641 a separate optimization pass.
4642
4643 @item -fbranch-target-load-optimize2
4644 @opindex fbranch-target-load-optimize2
4645 Perform branch target register load optimization after prologue / epilogue
4646 threading.
4647
4648 @item -fbtr-bb-exclusive
4649 @opindex fbtr-bb-exclusive
4650 WHen performing branch target register load optimization, don't reuse
4651 branch target registers in within any basic block.
4652
4653 @item --param @var{name}=@var{value}
4654 @opindex param
4655 In some places, GCC uses various constants to control the amount of
4656 optimization that is done. For example, GCC will not inline functions
4657 that contain more that a certain number of instructions. You can
4658 control some of these constants on the command-line using the
4659 @option{--param} option.
4660
4661 The names of specific parameters, and the meaning of the values, are
4662 tied to the internals of the compiler, and are subject to change
4663 without notice in future releases.
4664
4665 In each case, the @var{value} is an integer. The allowable choices for
4666 @var{name} are given in the following table:
4667
4668 @table @gcctabopt
4669 @item max-crossjump-edges
4670 The maximum number of incoming edges to consider for crossjumping.
4671 The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
4672 the number of edges incoming to each block. Increasing values mean
4673 more aggressive optimization, making the compile time increase with
4674 probably small improvement in executable size.
4675
4676 @item max-delay-slot-insn-search
4677 The maximum number of instructions to consider when looking for an
4678 instruction to fill a delay slot. If more than this arbitrary number of
4679 instructions is searched, the time savings from filling the delay slot
4680 will be minimal so stop searching. Increasing values mean more
4681 aggressive optimization, making the compile time increase with probably
4682 small improvement in executable run time.
4683
4684 @item max-delay-slot-live-search
4685 When trying to fill delay slots, the maximum number of instructions to
4686 consider when searching for a block with valid live register
4687 information. Increasing this arbitrarily chosen value means more
4688 aggressive optimization, increasing the compile time. This parameter
4689 should be removed when the delay slot code is rewritten to maintain the
4690 control-flow graph.
4691
4692 @item max-gcse-memory
4693 The approximate maximum amount of memory that will be allocated in
4694 order to perform the global common subexpression elimination
4695 optimization. If more memory than specified is required, the
4696 optimization will not be done.
4697
4698 @item max-gcse-passes
4699 The maximum number of passes of GCSE to run.
4700
4701 @item max-pending-list-length
4702 The maximum number of pending dependencies scheduling will allow
4703 before flushing the current state and starting over. Large functions
4704 with few branches or calls can create excessively large lists which
4705 needlessly consume memory and resources.
4706
4707 @item max-inline-insns-single
4708 Several parameters control the tree inliner used in gcc.
4709 This number sets the maximum number of instructions (counted in gcc's
4710 internal representation) in a single function that the tree inliner
4711 will consider for inlining. This only affects functions declared
4712 inline and methods implemented in a class declaration (C++).
4713 The default value is 500.
4714
4715 @item max-inline-insns-auto
4716 When you use @option{-finline-functions} (included in @option{-O3}),
4717 a lot of functions that would otherwise not be considered for inlining
4718 by the compiler will be investigated. To those functions, a different
4719 (more restrictive) limit compared to functions declared inline can
4720 be applied.
4721 The default value is 120.
4722
4723 @item large-function-insns
4724 The limit specifying really large functions. For functions greater than this
4725 limit inlining is constrained by @option{--param large-function-growth}.
4726 This parameter is useful primarily to avoid extreme compilation time caused by non-linear
4727 algorithms used by the backend.
4728 This parameter is ignored when @option{-funit-at-a-time} is not used.
4729 The default value is 3000.
4730
4731 @item large-function-growth
4732 Specifies maximal growth of large function caused by inlining in percents.
4733 This parameter is ignored when @option{-funit-at-a-time} is not used.
4734 The default value is 200.
4735
4736 @item inline-unit-growth
4737 Specifies maximal overall growth of the compilation unit caused by inlining.
4738 This parameter is ignored when @option{-funit-at-a-time} is not used.
4739 The default value is 150.
4740
4741 @item max-inline-insns-rtl
4742 For languages that use the RTL inliner (this happens at a later stage
4743 than tree inlining), you can set the maximum allowable size (counted
4744 in RTL instructions) for the RTL inliner with this parameter.
4745 The default value is 600.
4746
4747 @item max-unrolled-insns
4748 The maximum number of instructions that a loop should have if that loop
4749 is unrolled, and if the loop is unrolled, it determines how many times
4750 the loop code is unrolled.
4751
4752 @item max-average-unrolled-insns
4753 The maximum number of instructions biased by probabilities of their execution
4754 that a loop should have if that loop is unrolled, and if the loop is unrolled,
4755 it determines how many times the loop code is unrolled.
4756
4757 @item max-unroll-times
4758 The maximum number of unrollings of a single loop.
4759
4760 @item max-peeled-insns
4761 The maximum number of instructions that a loop should have if that loop
4762 is peeled, and if the loop is peeled, it determines how many times
4763 the loop code is peeled.
4764
4765 @item max-peel-times
4766 The maximum number of peelings of a single loop.
4767
4768 @item max-completely-peeled-insns
4769 The maximum number of insns of a completely peeled loop.
4770
4771 @item max-completely-peel-times
4772 The maximum number of iterations of a loop to be suitable for complete peeling.
4773
4774 @item max-unswitch-insns
4775 The maximum number of insns of an unswitched loop.
4776
4777 @item max-unswitch-level
4778 The maximum number of branches unswitched in a single loop.
4779
4780 @item hot-bb-count-fraction
4781 Select fraction of the maximal count of repetitions of basic block in program
4782 given basic block needs to have to be considered hot.
4783
4784 @item hot-bb-frequency-fraction
4785 Select fraction of the maximal frequency of executions of basic block in
4786 function given basic block needs to have to be considered hot
4787
4788 @item tracer-dynamic-coverage
4789 @itemx tracer-dynamic-coverage-feedback
4790
4791 This value is used to limit superblock formation once the given percentage of
4792 executed instructions is covered. This limits unnecessary code size
4793 expansion.
4794
4795 The @option{tracer-dynamic-coverage-feedback} is used only when profile
4796 feedback is available. The real profiles (as opposed to statically estimated
4797 ones) are much less balanced allowing the threshold to be larger value.
4798
4799 @item tracer-max-code-growth
4800 Stop tail duplication once code growth has reached given percentage. This is
4801 rather hokey argument, as most of the duplicates will be eliminated later in
4802 cross jumping, so it may be set to much higher values than is the desired code
4803 growth.
4804
4805 @item tracer-min-branch-ratio
4806
4807 Stop reverse growth when the reverse probability of best edge is less than this
4808 threshold (in percent).
4809
4810 @item tracer-min-branch-ratio
4811 @itemx tracer-min-branch-ratio-feedback
4812
4813 Stop forward growth if the best edge do have probability lower than this
4814 threshold.
4815
4816 Similarly to @option{tracer-dynamic-coverage} two values are present, one for
4817 compilation for profile feedback and one for compilation without. The value
4818 for compilation with profile feedback needs to be more conservative (higher) in
4819 order to make tracer effective.
4820
4821 @item max-cse-path-length
4822
4823 Maximum number of basic blocks on path that cse considers.
4824
4825 @item ggc-min-expand
4826
4827 GCC uses a garbage collector to manage its own memory allocation. This
4828 parameter specifies the minimum percentage by which the garbage
4829 collector's heap should be allowed to expand between collections.
4830 Tuning this may improve compilation speed; it has no effect on code
4831 generation.
4832
4833 The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
4834 RAM >= 1GB. If @code{getrlimit} is available, the notion of "RAM" is
4835 the smallest of actual RAM, RLIMIT_RSS, RLIMIT_DATA and RLIMIT_AS. If
4836 GCC is not able to calculate RAM on a particular platform, the lower
4837 bound of 30% is used. Setting this parameter and
4838 @option{ggc-min-heapsize} to zero causes a full collection to occur at
4839 every opportunity. This is extremely slow, but can be useful for
4840 debugging.
4841
4842 @item ggc-min-heapsize
4843
4844 Minimum size of the garbage collector's heap before it begins bothering
4845 to collect garbage. The first collection occurs after the heap expands
4846 by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
4847 tuning this may improve compilation speed, and has no effect on code
4848 generation.
4849
4850 The default is RAM/8, with a lower bound of 4096 (four megabytes) and an
4851 upper bound of 131072 (128 megabytes). If @code{getrlimit} is
4852 available, the notion of "RAM" is the smallest of actual RAM,
4853 RLIMIT_RSS, RLIMIT_DATA and RLIMIT_AS. If GCC is not able to calculate
4854 RAM on a particular platform, the lower bound is used. Setting this
4855 parameter very large effectively disables garbage collection. Setting
4856 this parameter and @option{ggc-min-expand} to zero causes a full
4857 collection to occur at every opportunity.
4858
4859 @item max-reload-search-insns
4860 The maximum number of instruction reload should look backward for equivalent
4861 register. Increasing values mean more aggressive optimization, making the
4862 compile time increase with probably slightly better performance. The default
4863 value is 100.
4864
4865 @item max-cselib-memory-location
4866 The maximum number of memory locations cselib should take into acount.
4867 Increasing values mean more aggressive optimization, making the compile time
4868 increase with probably slightly better performance. The default value is 500.
4869
4870 @item reorder-blocks-duplicate
4871 @itemx reorder-blocks-duplicate-feedback
4872
4873 Used by basic block reordering pass to decide whether to use unconditional
4874 branch or duplicate the code on its destination. Code is duplicated when its
4875 estimated size is smaller than this value multiplied by the estimated size of
4876 unconditional jump in the hot spots of the program.
4877
4878 The @option{reorder-block-duplicate-feedback} is used only when profile
4879 feedback is available and may be set to higher values than
4880 @option{reorder-block-duplicate} since information about the hot spots is more
4881 accurate.
4882 @end table
4883 @end table
4884
4885 @node Preprocessor Options
4886 @section Options Controlling the Preprocessor
4887 @cindex preprocessor options
4888 @cindex options, preprocessor
4889
4890 These options control the C preprocessor, which is run on each C source
4891 file before actual compilation.
4892
4893 If you use the @option{-E} option, nothing is done except preprocessing.
4894 Some of these options make sense only together with @option{-E} because
4895 they cause the preprocessor output to be unsuitable for actual
4896 compilation.
4897
4898 @table @gcctabopt
4899 @opindex Wp
4900 You can use @option{-Wp,@var{option}} to bypass the compiler driver
4901 and pass @var{option} directly through to the preprocessor. If
4902 @var{option} contains commas, it is split into multiple options at the
4903 commas. However, many options are modified, translated or interpreted
4904 by the compiler driver before being passed to the preprocessor, and
4905 @option{-Wp} forcibly bypasses this phase. The preprocessor's direct
4906 interface is undocumented and subject to change, so whenever possible
4907 you should avoid using @option{-Wp} and let the driver handle the
4908 options instead.
4909
4910 @item -Xpreprocessor @var{option}
4911 @opindex preprocessor
4912 Pass @var{option} as an option to the preprocessor. You can use this to
4913 supply system-specific preprocessor options which GCC does not know how to
4914 recognize.
4915
4916 If you want to pass an option that takes an argument, you must use
4917 @option{-Xpreprocessor} twice, once for the option and once for the argument.
4918 @end table
4919
4920 @include cppopts.texi
4921
4922 @node Assembler Options
4923 @section Passing Options to the Assembler
4924
4925 @c prevent bad page break with this line
4926 You can pass options to the assembler.
4927
4928 @table @gcctabopt
4929 @item -Wa,@var{option}
4930 @opindex Wa
4931 Pass @var{option} as an option to the assembler. If @var{option}
4932 contains commas, it is split into multiple options at the commas.
4933
4934 @item -Xassembler @var{option}
4935 @opindex Xassembler
4936 Pass @var{option} as an option to the assembler. You can use this to
4937 supply system-specific assembler options which GCC does not know how to
4938 recognize.
4939
4940 If you want to pass an option that takes an argument, you must use
4941 @option{-Xassembler} twice, once for the option and once for the argument.
4942
4943 @end table
4944
4945 @node Link Options
4946 @section Options for Linking
4947 @cindex link options
4948 @cindex options, linking
4949
4950 These options come into play when the compiler links object files into
4951 an executable output file. They are meaningless if the compiler is
4952 not doing a link step.
4953
4954 @table @gcctabopt
4955 @cindex file names
4956 @item @var{object-file-name}
4957 A file name that does not end in a special recognized suffix is
4958 considered to name an object file or library. (Object files are
4959 distinguished from libraries by the linker according to the file
4960 contents.) If linking is done, these object files are used as input
4961 to the linker.
4962
4963 @item -c
4964 @itemx -S
4965 @itemx -E
4966 @opindex c
4967 @opindex S
4968 @opindex E
4969 If any of these options is used, then the linker is not run, and
4970 object file names should not be used as arguments. @xref{Overall
4971 Options}.
4972
4973 @cindex Libraries
4974 @item -l@var{library}
4975 @itemx -l @var{library}
4976 @opindex l
4977 Search the library named @var{library} when linking. (The second
4978 alternative with the library as a separate argument is only for
4979 POSIX compliance and is not recommended.)
4980
4981 It makes a difference where in the command you write this option; the
4982 linker searches and processes libraries and object files in the order they
4983 are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
4984 after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
4985 to functions in @samp{z}, those functions may not be loaded.
4986
4987 The linker searches a standard list of directories for the library,
4988 which is actually a file named @file{lib@var{library}.a}. The linker
4989 then uses this file as if it had been specified precisely by name.
4990
4991 The directories searched include several standard system directories
4992 plus any that you specify with @option{-L}.
4993
4994 Normally the files found this way are library files---archive files
4995 whose members are object files. The linker handles an archive file by
4996 scanning through it for members which define symbols that have so far
4997 been referenced but not defined. But if the file that is found is an
4998 ordinary object file, it is linked in the usual fashion. The only
4999 difference between using an @option{-l} option and specifying a file name
5000 is that @option{-l} surrounds @var{library} with @samp{lib} and @samp{.a}
5001 and searches several directories.
5002
5003 @item -lobjc
5004 @opindex lobjc
5005 You need this special case of the @option{-l} option in order to
5006 link an Objective-C program.
5007
5008 @item -nostartfiles
5009 @opindex nostartfiles
5010 Do not use the standard system startup files when linking.
5011 The standard system libraries are used normally, unless @option{-nostdlib}
5012 or @option{-nodefaultlibs} is used.
5013
5014 @item -nodefaultlibs
5015 @opindex nodefaultlibs
5016 Do not use the standard system libraries when linking.
5017 Only the libraries you specify will be passed to the linker.
5018 The standard startup files are used normally, unless @option{-nostartfiles}
5019 is used. The compiler may generate calls to memcmp, memset, and memcpy
5020 for System V (and ISO C) environments or to bcopy and bzero for
5021 BSD environments. These entries are usually resolved by entries in
5022 libc. These entry points should be supplied through some other
5023 mechanism when this option is specified.
5024
5025 @item -nostdlib
5026 @opindex nostdlib
5027 Do not use the standard system startup files or libraries when linking.
5028 No startup files and only the libraries you specify will be passed to
5029 the linker. The compiler may generate calls to memcmp, memset, and memcpy
5030 for System V (and ISO C) environments or to bcopy and bzero for
5031 BSD environments. These entries are usually resolved by entries in
5032 libc. These entry points should be supplied through some other
5033 mechanism when this option is specified.
5034
5035 @cindex @option{-lgcc}, use with @option{-nostdlib}
5036 @cindex @option{-nostdlib} and unresolved references
5037 @cindex unresolved references and @option{-nostdlib}
5038 @cindex @option{-lgcc}, use with @option{-nodefaultlibs}
5039 @cindex @option{-nodefaultlibs} and unresolved references
5040 @cindex unresolved references and @option{-nodefaultlibs}
5041 One of the standard libraries bypassed by @option{-nostdlib} and
5042 @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
5043 that GCC uses to overcome shortcomings of particular machines, or special
5044 needs for some languages.
5045 (@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
5046 Collection (GCC) Internals},
5047 for more discussion of @file{libgcc.a}.)
5048 In most cases, you need @file{libgcc.a} even when you want to avoid
5049 other standard libraries. In other words, when you specify @option{-nostdlib}
5050 or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
5051 This ensures that you have no unresolved references to internal GCC
5052 library subroutines. (For example, @samp{__main}, used to ensure C++
5053 constructors will be called; @pxref{Collect2,,@code{collect2}, gccint,
5054 GNU Compiler Collection (GCC) Internals}.)
5055
5056 @item -pie
5057 @opindex pie
5058 Produce a position independent executable on targets which support it.
5059 For predictable results, you must also specify the same set of options
5060 that were used to generate code (@option{-fpie}, @option{-fPIE},
5061 or model suboptions) when you specify this option.
5062
5063 @item -s
5064 @opindex s
5065 Remove all symbol table and relocation information from the executable.
5066
5067 @item -static
5068 @opindex static
5069 On systems that support dynamic linking, this prevents linking with the shared
5070 libraries. On other systems, this option has no effect.
5071
5072 @item -shared
5073 @opindex shared
5074 Produce a shared object which can then be linked with other objects to
5075 form an executable. Not all systems support this option. For predictable
5076 results, you must also specify the same set of options that were used to
5077 generate code (@option{-fpic}, @option{-fPIC}, or model suboptions)
5078 when you specify this option.@footnote{On some systems, @samp{gcc -shared}
5079 needs to build supplementary stub code for constructors to work. On
5080 multi-libbed systems, @samp{gcc -shared} must select the correct support
5081 libraries to link against. Failing to supply the correct flags may lead
5082 to subtle defects. Supplying them in cases where they are not necessary
5083 is innocuous.}
5084
5085 @item -shared-libgcc
5086 @itemx -static-libgcc
5087 @opindex shared-libgcc
5088 @opindex static-libgcc
5089 On systems that provide @file{libgcc} as a shared library, these options
5090 force the use of either the shared or static version respectively.
5091 If no shared version of @file{libgcc} was built when the compiler was
5092 configured, these options have no effect.
5093
5094 There are several situations in which an application should use the
5095 shared @file{libgcc} instead of the static version. The most common
5096 of these is when the application wishes to throw and catch exceptions
5097 across different shared libraries. In that case, each of the libraries
5098 as well as the application itself should use the shared @file{libgcc}.
5099
5100 Therefore, the G++ and GCJ drivers automatically add
5101 @option{-shared-libgcc} whenever you build a shared library or a main
5102 executable, because C++ and Java programs typically use exceptions, so
5103 this is the right thing to do.
5104
5105 If, instead, you use the GCC driver to create shared libraries, you may
5106 find that they will not always be linked with the shared @file{libgcc}.
5107 If GCC finds, at its configuration time, that you have a GNU linker that
5108 does not support option @option{--eh-frame-hdr}, it will link the shared
5109 version of @file{libgcc} into shared libraries by default. Otherwise,
5110 it will take advantage of the linker and optimize away the linking with
5111 the shared version of @file{libgcc}, linking with the static version of
5112 libgcc by default. This allows exceptions to propagate through such
5113 shared libraries, without incurring relocation costs at library load
5114 time.
5115
5116 However, if a library or main executable is supposed to throw or catch
5117 exceptions, you must link it using the G++ or GCJ driver, as appropriate
5118 for the languages used in the program, or using the option
5119 @option{-shared-libgcc}, such that it is linked with the shared
5120 @file{libgcc}.
5121
5122 @item -symbolic
5123 @opindex symbolic
5124 Bind references to global symbols when building a shared object. Warn
5125 about any unresolved references (unless overridden by the link editor
5126 option @samp{-Xlinker -z -Xlinker defs}). Only a few systems support
5127 this option.
5128
5129 @item -Xlinker @var{option}
5130 @opindex Xlinker
5131 Pass @var{option} as an option to the linker. You can use this to
5132 supply system-specific linker options which GCC does not know how to
5133 recognize.
5134
5135 If you want to pass an option that takes an argument, you must use
5136 @option{-Xlinker} twice, once for the option and once for the argument.
5137 For example, to pass @option{-assert definitions}, you must write
5138 @samp{-Xlinker -assert -Xlinker definitions}. It does not work to write
5139 @option{-Xlinker "-assert definitions"}, because this passes the entire
5140 string as a single argument, which is not what the linker expects.
5141
5142 @item -Wl,@var{option}
5143 @opindex Wl
5144 Pass @var{option} as an option to the linker. If @var{option} contains
5145 commas, it is split into multiple options at the commas.
5146
5147 @item -u @var{symbol}
5148 @opindex u
5149 Pretend the symbol @var{symbol} is undefined, to force linking of
5150 library modules to define it. You can use @option{-u} multiple times with
5151 different symbols to force loading of additional library modules.
5152 @end table
5153
5154 @node Directory Options
5155 @section Options for Directory Search
5156 @cindex directory options
5157 @cindex options, directory search
5158 @cindex search path
5159
5160 These options specify directories to search for header files, for
5161 libraries and for parts of the compiler:
5162
5163 @table @gcctabopt
5164 @item -I@var{dir}
5165 @opindex I
5166 Add the directory @var{dir} to the head of the list of directories to be
5167 searched for header files. This can be used to override a system header
5168 file, substituting your own version, since these directories are
5169 searched before the system header file directories. However, you should
5170 not use this option to add directories that contain vendor-supplied
5171 system header files (use @option{-isystem} for that). If you use more than
5172 one @option{-I} option, the directories are scanned in left-to-right
5173 order; the standard system directories come after.
5174
5175 If a standard system include directory, or a directory specified with
5176 @option{-isystem}, is also specified with @option{-I}, the @option{-I}
5177 option will be ignored. The directory will still be searched but as a
5178 system directory at its normal position in the system include chain.
5179 This is to ensure that GCC's procedure to fix buggy system headers and
5180 the ordering for the include_next directive are not inadvertently changed.
5181 If you really need to change the search order for system directories,
5182 use the @option{-nostdinc} and/or @option{-isystem} options.
5183
5184 @item -I-
5185 @opindex I-
5186 Any directories you specify with @option{-I} options before the @option{-I-}
5187 option are searched only for the case of @samp{#include "@var{file}"};
5188 they are not searched for @samp{#include <@var{file}>}.
5189
5190 If additional directories are specified with @option{-I} options after
5191 the @option{-I-}, these directories are searched for all @samp{#include}
5192 directives. (Ordinarily @emph{all} @option{-I} directories are used
5193 this way.)
5194
5195 In addition, the @option{-I-} option inhibits the use of the current
5196 directory (where the current input file came from) as the first search
5197 directory for @samp{#include "@var{file}"}. There is no way to
5198 override this effect of @option{-I-}. With @option{-I.} you can specify
5199 searching the directory which was current when the compiler was
5200 invoked. That is not exactly the same as what the preprocessor does
5201 by default, but it is often satisfactory.
5202
5203 @option{-I-} does not inhibit the use of the standard system directories
5204 for header files. Thus, @option{-I-} and @option{-nostdinc} are
5205 independent.
5206
5207 @item -L@var{dir}
5208 @opindex L
5209 Add directory @var{dir} to the list of directories to be searched
5210 for @option{-l}.
5211
5212 @item -B@var{prefix}
5213 @opindex B
5214 This option specifies where to find the executables, libraries,
5215 include files, and data files of the compiler itself.
5216
5217 The compiler driver program runs one or more of the subprograms
5218 @file{cpp}, @file{cc1}, @file{as} and @file{ld}. It tries
5219 @var{prefix} as a prefix for each program it tries to run, both with and
5220 without @samp{@var{machine}/@var{version}/} (@pxref{Target Options}).
5221
5222 For each subprogram to be run, the compiler driver first tries the
5223 @option{-B} prefix, if any. If that name is not found, or if @option{-B}
5224 was not specified, the driver tries two standard prefixes, which are
5225 @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
5226 those results in a file name that is found, the unmodified program
5227 name is searched for using the directories specified in your
5228 @env{PATH} environment variable.
5229
5230 The compiler will check to see if the path provided by the @option{-B}
5231 refers to a directory, and if necessary it will add a directory
5232 separator character at the end of the path.
5233
5234 @option{-B} prefixes that effectively specify directory names also apply
5235 to libraries in the linker, because the compiler translates these
5236 options into @option{-L} options for the linker. They also apply to
5237 includes files in the preprocessor, because the compiler translates these
5238 options into @option{-isystem} options for the preprocessor. In this case,
5239 the compiler appends @samp{include} to the prefix.
5240
5241 The run-time support file @file{libgcc.a} can also be searched for using
5242 the @option{-B} prefix, if needed. If it is not found there, the two
5243 standard prefixes above are tried, and that is all. The file is left
5244 out of the link if it is not found by those means.
5245
5246 Another way to specify a prefix much like the @option{-B} prefix is to use
5247 the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
5248 Variables}.
5249
5250 As a special kludge, if the path provided by @option{-B} is
5251 @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
5252 9, then it will be replaced by @file{[dir/]include}. This is to help
5253 with boot-strapping the compiler.
5254
5255 @item -specs=@var{file}
5256 @opindex specs
5257 Process @var{file} after the compiler reads in the standard @file{specs}
5258 file, in order to override the defaults that the @file{gcc} driver
5259 program uses when determining what switches to pass to @file{cc1},
5260 @file{cc1plus}, @file{as}, @file{ld}, etc. More than one
5261 @option{-specs=@var{file}} can be specified on the command line, and they
5262 are processed in order, from left to right.
5263 @end table
5264
5265 @c man end
5266
5267 @node Spec Files
5268 @section Specifying subprocesses and the switches to pass to them
5269 @cindex Spec Files
5270
5271 @command{gcc} is a driver program. It performs its job by invoking a
5272 sequence of other programs to do the work of compiling, assembling and
5273 linking. GCC interprets its command-line parameters and uses these to
5274 deduce which programs it should invoke, and which command-line options
5275 it ought to place on their command lines. This behavior is controlled
5276 by @dfn{spec strings}. In most cases there is one spec string for each
5277 program that GCC can invoke, but a few programs have multiple spec
5278 strings to control their behavior. The spec strings built into GCC can
5279 be overridden by using the @option{-specs=} command-line switch to specify
5280 a spec file.
5281
5282 @dfn{Spec files} are plaintext files that are used to construct spec
5283 strings. They consist of a sequence of directives separated by blank
5284 lines. The type of directive is determined by the first non-whitespace
5285 character on the line and it can be one of the following:
5286
5287 @table @code
5288 @item %@var{command}
5289 Issues a @var{command} to the spec file processor. The commands that can
5290 appear here are:
5291
5292 @table @code
5293 @item %include <@var{file}>
5294 @cindex %include
5295 Search for @var{file} and insert its text at the current point in the
5296 specs file.
5297
5298 @item %include_noerr <@var{file}>
5299 @cindex %include_noerr
5300 Just like @samp{%include}, but do not generate an error message if the include
5301 file cannot be found.
5302
5303 @item %rename @var{old_name} @var{new_name}
5304 @cindex %rename
5305 Rename the spec string @var{old_name} to @var{new_name}.
5306
5307 @end table
5308
5309 @item *[@var{spec_name}]:
5310 This tells the compiler to create, override or delete the named spec
5311 string. All lines after this directive up to the next directive or
5312 blank line are considered to be the text for the spec string. If this
5313 results in an empty string then the spec will be deleted. (Or, if the
5314 spec did not exist, then nothing will happened.) Otherwise, if the spec
5315 does not currently exist a new spec will be created. If the spec does
5316 exist then its contents will be overridden by the text of this
5317 directive, unless the first character of that text is the @samp{+}
5318 character, in which case the text will be appended to the spec.
5319
5320 @item [@var{suffix}]:
5321 Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
5322 and up to the next directive or blank line are considered to make up the
5323 spec string for the indicated suffix. When the compiler encounters an
5324 input file with the named suffix, it will processes the spec string in
5325 order to work out how to compile that file. For example:
5326
5327 @smallexample
5328 .ZZ:
5329 z-compile -input %i
5330 @end smallexample
5331
5332 This says that any input file whose name ends in @samp{.ZZ} should be
5333 passed to the program @samp{z-compile}, which should be invoked with the
5334 command-line switch @option{-input} and with the result of performing the
5335 @samp{%i} substitution. (See below.)
5336
5337 As an alternative to providing a spec string, the text that follows a
5338 suffix directive can be one of the following:
5339
5340 @table @code
5341 @item @@@var{language}
5342 This says that the suffix is an alias for a known @var{language}. This is
5343 similar to using the @option{-x} command-line switch to GCC to specify a
5344 language explicitly. For example:
5345
5346 @smallexample
5347 .ZZ:
5348 @@c++
5349 @end smallexample
5350
5351 Says that .ZZ files are, in fact, C++ source files.
5352
5353 @item #@var{name}
5354 This causes an error messages saying:
5355
5356 @smallexample
5357 @var{name} compiler not installed on this system.
5358 @end smallexample
5359 @end table
5360
5361 GCC already has an extensive list of suffixes built into it.
5362 This directive will add an entry to the end of the list of suffixes, but
5363 since the list is searched from the end backwards, it is effectively
5364 possible to override earlier entries using this technique.
5365
5366 @end table
5367
5368 GCC has the following spec strings built into it. Spec files can
5369 override these strings or create their own. Note that individual
5370 targets can also add their own spec strings to this list.
5371
5372 @smallexample
5373 asm Options to pass to the assembler
5374 asm_final Options to pass to the assembler post-processor
5375 cpp Options to pass to the C preprocessor
5376 cc1 Options to pass to the C compiler
5377 cc1plus Options to pass to the C++ compiler
5378 endfile Object files to include at the end of the link
5379 link Options to pass to the linker
5380 lib Libraries to include on the command line to the linker
5381 libgcc Decides which GCC support library to pass to the linker
5382 linker Sets the name of the linker
5383 predefines Defines to be passed to the C preprocessor
5384 signed_char Defines to pass to CPP to say whether @code{char} is signed
5385 by default
5386 startfile Object files to include at the start of the link
5387 @end smallexample
5388
5389 Here is a small example of a spec file:
5390
5391 @smallexample
5392 %rename lib old_lib
5393
5394 *lib:
5395 --start-group -lgcc -lc -leval1 --end-group %(old_lib)
5396 @end smallexample
5397
5398 This example renames the spec called @samp{lib} to @samp{old_lib} and
5399 then overrides the previous definition of @samp{lib} with a new one.
5400 The new definition adds in some extra command-line options before
5401 including the text of the old definition.
5402
5403 @dfn{Spec strings} are a list of command-line options to be passed to their
5404 corresponding program. In addition, the spec strings can contain
5405 @samp{%}-prefixed sequences to substitute variable text or to
5406 conditionally insert text into the command line. Using these constructs
5407 it is possible to generate quite complex command lines.
5408
5409 Here is a table of all defined @samp{%}-sequences for spec
5410 strings. Note that spaces are not generated automatically around the
5411 results of expanding these sequences. Therefore you can concatenate them
5412 together or combine them with constant text in a single argument.
5413
5414 @table @code
5415 @item %%
5416 Substitute one @samp{%} into the program name or argument.
5417
5418 @item %i
5419 Substitute the name of the input file being processed.
5420
5421 @item %b
5422 Substitute the basename of the input file being processed.
5423 This is the substring up to (and not including) the last period
5424 and not including the directory.
5425
5426 @item %B
5427 This is the same as @samp{%b}, but include the file suffix (text after
5428 the last period).
5429
5430 @item %d
5431 Marks the argument containing or following the @samp{%d} as a
5432 temporary file name, so that that file will be deleted if GCC exits
5433 successfully. Unlike @samp{%g}, this contributes no text to the
5434 argument.
5435
5436 @item %g@var{suffix}
5437 Substitute a file name that has suffix @var{suffix} and is chosen
5438 once per compilation, and mark the argument in the same way as
5439 @samp{%d}. To reduce exposure to denial-of-service attacks, the file
5440 name is now chosen in a way that is hard to predict even when previously
5441 chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
5442 might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
5443 the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
5444 treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
5445 was simply substituted with a file name chosen once per compilation,
5446 without regard to any appended suffix (which was therefore treated
5447 just like ordinary text), making such attacks more likely to succeed.
5448
5449 @item %u@var{suffix}
5450 Like @samp{%g}, but generates a new temporary file name even if
5451 @samp{%u@var{suffix}} was already seen.
5452
5453 @item %U@var{suffix}
5454 Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
5455 new one if there is no such last file name. In the absence of any
5456 @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
5457 the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
5458 would involve the generation of two distinct file names, one
5459 for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
5460 simply substituted with a file name chosen for the previous @samp{%u},
5461 without regard to any appended suffix.
5462
5463 @item %j@var{suffix}
5464 Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
5465 writable, and if save-temps is off; otherwise, substitute the name
5466 of a temporary file, just like @samp{%u}. This temporary file is not
5467 meant for communication between processes, but rather as a junk
5468 disposal mechanism.
5469
5470 @item %|@var{suffix}
5471 @itemx %m@var{suffix}
5472 Like @samp{%g}, except if @option{-pipe} is in effect. In that case
5473 @samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
5474 all. These are the two most common ways to instruct a program that it
5475 should read from standard input or write to standard output. If you
5476 need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
5477 construct: see for example @file{f/lang-specs.h}.
5478
5479 @item %.@var{SUFFIX}
5480 Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
5481 when it is subsequently output with @samp{%*}. @var{SUFFIX} is
5482 terminated by the next space or %.
5483
5484 @item %w
5485 Marks the argument containing or following the @samp{%w} as the
5486 designated output file of this compilation. This puts the argument
5487 into the sequence of arguments that @samp{%o} will substitute later.
5488
5489 @item %o
5490 Substitutes the names of all the output files, with spaces
5491 automatically placed around them. You should write spaces
5492 around the @samp{%o} as well or the results are undefined.
5493 @samp{%o} is for use in the specs for running the linker.
5494 Input files whose names have no recognized suffix are not compiled
5495 at all, but they are included among the output files, so they will
5496 be linked.
5497
5498 @item %O
5499 Substitutes the suffix for object files. Note that this is
5500 handled specially when it immediately follows @samp{%g, %u, or %U},
5501 because of the need for those to form complete file names. The
5502 handling is such that @samp{%O} is treated exactly as if it had already
5503 been substituted, except that @samp{%g, %u, and %U} do not currently
5504 support additional @var{suffix} characters following @samp{%O} as they would
5505 following, for example, @samp{.o}.
5506
5507 @item %p
5508 Substitutes the standard macro predefinitions for the
5509 current target machine. Use this when running @code{cpp}.
5510
5511 @item %P
5512 Like @samp{%p}, but puts @samp{__} before and after the name of each
5513 predefined macro, except for macros that start with @samp{__} or with
5514 @samp{_@var{L}}, where @var{L} is an uppercase letter. This is for ISO
5515 C@.
5516
5517 @item %I
5518 Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
5519 @option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}), and
5520 @option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
5521 as necessary.
5522
5523 @item %s
5524 Current argument is the name of a library or startup file of some sort.
5525 Search for that file in a standard list of directories and substitute
5526 the full name found.
5527
5528 @item %e@var{str}
5529 Print @var{str} as an error message. @var{str} is terminated by a newline.
5530 Use this when inconsistent options are detected.
5531
5532 @item %(@var{name})
5533 Substitute the contents of spec string @var{name} at this point.
5534
5535 @item %[@var{name}]
5536 Like @samp{%(@dots{})} but put @samp{__} around @option{-D} arguments.
5537
5538 @item %x@{@var{option}@}
5539 Accumulate an option for @samp{%X}.
5540
5541 @item %X
5542 Output the accumulated linker options specified by @option{-Wl} or a @samp{%x}
5543 spec string.
5544
5545 @item %Y
5546 Output the accumulated assembler options specified by @option{-Wa}.
5547
5548 @item %Z
5549 Output the accumulated preprocessor options specified by @option{-Wp}.
5550
5551 @item %a
5552 Process the @code{asm} spec. This is used to compute the
5553 switches to be passed to the assembler.
5554
5555 @item %A
5556 Process the @code{asm_final} spec. This is a spec string for
5557 passing switches to an assembler post-processor, if such a program is
5558 needed.
5559
5560 @item %l
5561 Process the @code{link} spec. This is the spec for computing the
5562 command line passed to the linker. Typically it will make use of the
5563 @samp{%L %G %S %D and %E} sequences.
5564
5565 @item %D
5566 Dump out a @option{-L} option for each directory that GCC believes might
5567 contain startup files. If the target supports multilibs then the
5568 current multilib directory will be prepended to each of these paths.
5569
5570 @item %M
5571 Output the multilib directory with directory separators replaced with
5572 @samp{_}. If multilib directories are not set, or the multilib directory is
5573 @file{.} then this option emits nothing.
5574
5575 @item %L
5576 Process the @code{lib} spec. This is a spec string for deciding which
5577 libraries should be included on the command line to the linker.
5578
5579 @item %G
5580 Process the @code{libgcc} spec. This is a spec string for deciding
5581 which GCC support library should be included on the command line to the linker.
5582
5583 @item %S
5584 Process the @code{startfile} spec. This is a spec for deciding which
5585 object files should be the first ones passed to the linker. Typically
5586 this might be a file named @file{crt0.o}.
5587
5588 @item %E
5589 Process the @code{endfile} spec. This is a spec string that specifies
5590 the last object files that will be passed to the linker.
5591
5592 @item %C
5593 Process the @code{cpp} spec. This is used to construct the arguments
5594 to be passed to the C preprocessor.
5595
5596 @item %c
5597 Process the @code{signed_char} spec. This is intended to be used
5598 to tell cpp whether a char is signed. It typically has the definition:
5599 @smallexample
5600 %@{funsigned-char:-D__CHAR_UNSIGNED__@}
5601 @end smallexample
5602
5603 @item %1
5604 Process the @code{cc1} spec. This is used to construct the options to be
5605 passed to the actual C compiler (@samp{cc1}).
5606
5607 @item %2
5608 Process the @code{cc1plus} spec. This is used to construct the options to be
5609 passed to the actual C++ compiler (@samp{cc1plus}).
5610
5611 @item %*
5612 Substitute the variable part of a matched option. See below.
5613 Note that each comma in the substituted string is replaced by
5614 a single space.
5615
5616 @item %<@code{S}
5617 Remove all occurrences of @code{-S} from the command line. Note---this
5618 command is position dependent. @samp{%} commands in the spec string
5619 before this one will see @code{-S}, @samp{%} commands in the spec string
5620 after this one will not.
5621
5622 @item %:@var{function}(@var{args})
5623 Call the named function @var{function}, passing it @var{args}.
5624 @var{args} is first processed as a nested spec string, then split
5625 into an argument vector in the usual fashion. The function returns
5626 a string which is processed as if it had appeared literally as part
5627 of the current spec.
5628
5629 The following built-in spec functions are provided:
5630
5631 @table @code
5632 @item @code{if-exists}
5633 The @code{if-exists} spec function takes one argument, an absolute
5634 pathname to a file. If the file exists, @code{if-exists} returns the
5635 pathname. Here is a small example of its usage:
5636
5637 @smallexample
5638 *startfile:
5639 crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
5640 @end smallexample
5641
5642 @item @code{if-exists-else}
5643 The @code{if-exists-else} spec function is similar to the @code{if-exists}
5644 spec function, except that it takes two arguments. The first argument is
5645 an absolute pathname to a file. If the file exists, @code{if-exists-else}
5646 returns the pathname. If it does not exist, it returns the second argument.
5647 This way, @code{if-exists-else} can be used to select one file or another,
5648 based on the existence of the first. Here is a small example of its usage:
5649
5650 @smallexample
5651 *startfile:
5652 crt0%O%s %:if-exists(crti%O%s) \
5653 %:if-exists-else(crtbeginT%O%s crtbegin%O%s)
5654 @end smallexample
5655 @end table
5656
5657 @item %@{@code{S}@}
5658 Substitutes the @code{-S} switch, if that switch was given to GCC@.
5659 If that switch was not specified, this substitutes nothing. Note that
5660 the leading dash is omitted when specifying this option, and it is
5661 automatically inserted if the substitution is performed. Thus the spec
5662 string @samp{%@{foo@}} would match the command-line option @option{-foo}
5663 and would output the command line option @option{-foo}.
5664
5665 @item %W@{@code{S}@}
5666 Like %@{@code{S}@} but mark last argument supplied within as a file to be
5667 deleted on failure.
5668
5669 @item %@{@code{S}*@}
5670 Substitutes all the switches specified to GCC whose names start
5671 with @code{-S}, but which also take an argument. This is used for
5672 switches like @option{-o}, @option{-D}, @option{-I}, etc.
5673 GCC considers @option{-o foo} as being
5674 one switch whose names starts with @samp{o}. %@{o*@} would substitute this
5675 text, including the space. Thus two arguments would be generated.
5676
5677 @item %@{@code{S}*&@code{T}*@}
5678 Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
5679 (the order of @code{S} and @code{T} in the spec is not significant).
5680 There can be any number of ampersand-separated variables; for each the
5681 wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
5682
5683 @item %@{@code{S}:@code{X}@}
5684 Substitutes @code{X}, if the @samp{-S} switch was given to GCC@.
5685
5686 @item %@{!@code{S}:@code{X}@}
5687 Substitutes @code{X}, if the @samp{-S} switch was @emph{not} given to GCC@.
5688
5689 @item %@{@code{S}*:@code{X}@}
5690 Substitutes @code{X} if one or more switches whose names start with
5691 @code{-S} are specified to GCC@. Normally @code{X} is substituted only
5692 once, no matter how many such switches appeared. However, if @code{%*}
5693 appears somewhere in @code{X}, then @code{X} will be substituted once
5694 for each matching switch, with the @code{%*} replaced by the part of
5695 that switch that matched the @code{*}.
5696
5697 @item %@{.@code{S}:@code{X}@}
5698 Substitutes @code{X}, if processing a file with suffix @code{S}.
5699
5700 @item %@{!.@code{S}:@code{X}@}
5701 Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
5702
5703 @item %@{@code{S}|@code{P}:@code{X}@}
5704 Substitutes @code{X} if either @code{-S} or @code{-P} was given to GCC@.
5705 This may be combined with @samp{!}, @samp{.}, and @code{*} sequences as well,
5706 although they have a stronger binding than the @samp{|}. If @code{%*}
5707 appears in @code{X}, all of the alternatives must be starred, and only
5708 the first matching alternative is substituted.
5709
5710 For example, a spec string like this:
5711
5712 @smallexample
5713 %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
5714 @end smallexample
5715
5716 will output the following command-line options from the following input
5717 command-line options:
5718
5719 @smallexample
5720 fred.c -foo -baz
5721 jim.d -bar -boggle
5722 -d fred.c -foo -baz -boggle
5723 -d jim.d -bar -baz -boggle
5724 @end smallexample
5725
5726 @item %@{S:X; T:Y; :D@}
5727
5728 If @code{S} was given to GCC, substitutes @code{X}; else if @code{T} was
5729 given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
5730 be as many clauses as you need. This may be combined with @code{.},
5731 @code{!}, @code{|}, and @code{*} as needed.
5732
5733
5734 @end table
5735
5736 The conditional text @code{X} in a %@{@code{S}:@code{X}@} or similar
5737 construct may contain other nested @samp{%} constructs or spaces, or
5738 even newlines. They are processed as usual, as described above.
5739 Trailing white space in @code{X} is ignored. White space may also
5740 appear anywhere on the left side of the colon in these constructs,
5741 except between @code{.} or @code{*} and the corresponding word.
5742
5743 The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
5744 handled specifically in these constructs. If another value of
5745 @option{-O} or the negated form of a @option{-f}, @option{-m}, or
5746 @option{-W} switch is found later in the command line, the earlier
5747 switch value is ignored, except with @{@code{S}*@} where @code{S} is
5748 just one letter, which passes all matching options.
5749
5750 The character @samp{|} at the beginning of the predicate text is used to
5751 indicate that a command should be piped to the following command, but
5752 only if @option{-pipe} is specified.
5753
5754 It is built into GCC which switches take arguments and which do not.
5755 (You might think it would be useful to generalize this to allow each
5756 compiler's spec to say which switches take arguments. But this cannot
5757 be done in a consistent fashion. GCC cannot even decide which input
5758 files have been specified without knowing which switches take arguments,
5759 and it must know which input files to compile in order to tell which
5760 compilers to run).
5761
5762 GCC also knows implicitly that arguments starting in @option{-l} are to be
5763 treated as compiler output files, and passed to the linker in their
5764 proper position among the other output files.
5765
5766 @c man begin OPTIONS
5767
5768 @node Target Options
5769 @section Specifying Target Machine and Compiler Version
5770 @cindex target options
5771 @cindex cross compiling
5772 @cindex specifying machine version
5773 @cindex specifying compiler version and target machine
5774 @cindex compiler version, specifying
5775 @cindex target machine, specifying
5776
5777 The usual way to run GCC is to run the executable called @file{gcc}, or
5778 @file{<machine>-gcc} when cross-compiling, or
5779 @file{<machine>-gcc-<version>} to run a version other than the one that
5780 was installed last. Sometimes this is inconvenient, so GCC provides
5781 options that will switch to another cross-compiler or version.
5782
5783 @table @gcctabopt
5784 @item -b @var{machine}
5785 @opindex b
5786 The argument @var{machine} specifies the target machine for compilation.
5787
5788 The value to use for @var{machine} is the same as was specified as the
5789 machine type when configuring GCC as a cross-compiler. For
5790 example, if a cross-compiler was configured with @samp{configure
5791 i386v}, meaning to compile for an 80386 running System V, then you
5792 would specify @option{-b i386v} to run that cross compiler.
5793
5794 @item -V @var{version}
5795 @opindex V
5796 The argument @var{version} specifies which version of GCC to run.
5797 This is useful when multiple versions are installed. For example,
5798 @var{version} might be @samp{2.0}, meaning to run GCC version 2.0.
5799 @end table
5800
5801 The @option{-V} and @option{-b} options work by running the
5802 @file{<machine>-gcc-<version>} executable, so there's no real reason to
5803 use them if you can just run that directly.
5804
5805 @node Submodel Options
5806 @section Hardware Models and Configurations
5807 @cindex submodel options
5808 @cindex specifying hardware config
5809 @cindex hardware models and configurations, specifying
5810 @cindex machine dependent options
5811
5812 Earlier we discussed the standard option @option{-b} which chooses among
5813 different installed compilers for completely different target
5814 machines, such as VAX vs.@: 68000 vs.@: 80386.
5815
5816 In addition, each of these target machine types can have its own
5817 special options, starting with @samp{-m}, to choose among various
5818 hardware models or configurations---for example, 68010 vs 68020,
5819 floating coprocessor or none. A single installed version of the
5820 compiler can compile for any model or configuration, according to the
5821 options specified.
5822
5823 Some configurations of the compiler also support additional special
5824 options, usually for compatibility with other compilers on the same
5825 platform.
5826
5827 These options are defined by the macro @code{TARGET_SWITCHES} in the
5828 machine description. The default for the options is also defined by
5829 that macro, which enables you to change the defaults.
5830
5831 @menu
5832 * M680x0 Options::
5833 * M68hc1x Options::
5834 * VAX Options::
5835 * SPARC Options::
5836 * ARM Options::
5837 * MN10300 Options::
5838 * M32R/D Options::
5839 * RS/6000 and PowerPC Options::
5840 * Darwin Options::
5841 * MIPS Options::
5842 * i386 and x86-64 Options::
5843 * HPPA Options::
5844 * DEC Alpha Options::
5845 * DEC Alpha/VMS Options::
5846 * H8/300 Options::
5847 * SH Options::
5848 * System V Options::
5849 * TMS320C3x/C4x Options::
5850 * V850 Options::
5851 * ARC Options::
5852 * NS32K Options::
5853 * AVR Options::
5854 * MCore Options::
5855 * IA-64 Options::
5856 * S/390 and zSeries Options::
5857 * CRIS Options::
5858 * MMIX Options::
5859 * PDP-11 Options::
5860 * Xstormy16 Options::
5861 * Xtensa Options::
5862 * FRV Options::
5863 @end menu
5864
5865 @node M680x0 Options
5866 @subsection M680x0 Options
5867 @cindex M680x0 options
5868
5869 These are the @samp{-m} options defined for the 68000 series. The default
5870 values for these options depends on which style of 68000 was selected when
5871 the compiler was configured; the defaults for the most common choices are
5872 given below.
5873
5874 @table @gcctabopt
5875 @item -m68000
5876 @itemx -mc68000
5877 @opindex m68000
5878 @opindex mc68000
5879 Generate output for a 68000. This is the default
5880 when the compiler is configured for 68000-based systems.
5881
5882 Use this option for microcontrollers with a 68000 or EC000 core,
5883 including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
5884
5885 @item -m68020
5886 @itemx -mc68020
5887 @opindex m68020
5888 @opindex mc68020
5889 Generate output for a 68020. This is the default
5890 when the compiler is configured for 68020-based systems.
5891
5892 @item -m68881
5893 @opindex m68881
5894 Generate output containing 68881 instructions for floating point.
5895 This is the default for most 68020 systems unless @option{--nfp} was
5896 specified when the compiler was configured.
5897
5898 @item -m68030
5899 @opindex m68030
5900 Generate output for a 68030. This is the default when the compiler is
5901 configured for 68030-based systems.
5902
5903 @item -m68040
5904 @opindex m68040
5905 Generate output for a 68040. This is the default when the compiler is
5906 configured for 68040-based systems.
5907
5908 This option inhibits the use of 68881/68882 instructions that have to be
5909 emulated by software on the 68040. Use this option if your 68040 does not
5910 have code to emulate those instructions.
5911
5912 @item -m68060
5913 @opindex m68060
5914 Generate output for a 68060. This is the default when the compiler is
5915 configured for 68060-based systems.
5916
5917 This option inhibits the use of 68020 and 68881/68882 instructions that
5918 have to be emulated by software on the 68060. Use this option if your 68060
5919 does not have code to emulate those instructions.
5920
5921 @item -mcpu32
5922 @opindex mcpu32
5923 Generate output for a CPU32. This is the default
5924 when the compiler is configured for CPU32-based systems.
5925
5926 Use this option for microcontrollers with a
5927 CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
5928 68336, 68340, 68341, 68349 and 68360.
5929
5930 @item -m5200
5931 @opindex m5200
5932 Generate output for a 520X ``coldfire'' family cpu. This is the default
5933 when the compiler is configured for 520X-based systems.
5934
5935 Use this option for microcontroller with a 5200 core, including
5936 the MCF5202, MCF5203, MCF5204 and MCF5202.
5937
5938
5939 @item -m68020-40
5940 @opindex m68020-40
5941 Generate output for a 68040, without using any of the new instructions.
5942 This results in code which can run relatively efficiently on either a
5943 68020/68881 or a 68030 or a 68040. The generated code does use the
5944 68881 instructions that are emulated on the 68040.
5945
5946 @item -m68020-60
5947 @opindex m68020-60
5948 Generate output for a 68060, without using any of the new instructions.
5949 This results in code which can run relatively efficiently on either a
5950 68020/68881 or a 68030 or a 68040. The generated code does use the
5951 68881 instructions that are emulated on the 68060.
5952
5953 @item -msoft-float
5954 @opindex msoft-float
5955 Generate output containing library calls for floating point.
5956 @strong{Warning:} the requisite libraries are not available for all m68k
5957 targets. Normally the facilities of the machine's usual C compiler are
5958 used, but this can't be done directly in cross-compilation. You must
5959 make your own arrangements to provide suitable library functions for
5960 cross-compilation. The embedded targets @samp{m68k-*-aout} and
5961 @samp{m68k-*-coff} do provide software floating point support.
5962
5963 @item -mshort
5964 @opindex mshort
5965 Consider type @code{int} to be 16 bits wide, like @code{short int}.
5966
5967 @item -mnobitfield
5968 @opindex mnobitfield
5969 Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
5970 and @option{-m5200} options imply @w{@option{-mnobitfield}}.
5971
5972 @item -mbitfield
5973 @opindex mbitfield
5974 Do use the bit-field instructions. The @option{-m68020} option implies
5975 @option{-mbitfield}. This is the default if you use a configuration
5976 designed for a 68020.
5977
5978 @item -mrtd
5979 @opindex mrtd
5980 Use a different function-calling convention, in which functions
5981 that take a fixed number of arguments return with the @code{rtd}
5982 instruction, which pops their arguments while returning. This
5983 saves one instruction in the caller since there is no need to pop
5984 the arguments there.
5985
5986 This calling convention is incompatible with the one normally
5987 used on Unix, so you cannot use it if you need to call libraries
5988 compiled with the Unix compiler.
5989
5990 Also, you must provide function prototypes for all functions that
5991 take variable numbers of arguments (including @code{printf});
5992 otherwise incorrect code will be generated for calls to those
5993 functions.
5994
5995 In addition, seriously incorrect code will result if you call a
5996 function with too many arguments. (Normally, extra arguments are
5997 harmlessly ignored.)
5998
5999 The @code{rtd} instruction is supported by the 68010, 68020, 68030,
6000 68040, 68060 and CPU32 processors, but not by the 68000 or 5200.
6001
6002 @item -malign-int
6003 @itemx -mno-align-int
6004 @opindex malign-int
6005 @opindex mno-align-int
6006 Control whether GCC aligns @code{int}, @code{long}, @code{long long},
6007 @code{float}, @code{double}, and @code{long double} variables on a 32-bit
6008 boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
6009 Aligning variables on 32-bit boundaries produces code that runs somewhat
6010 faster on processors with 32-bit busses at the expense of more memory.
6011
6012 @strong{Warning:} if you use the @option{-malign-int} switch, GCC will
6013 align structures containing the above types differently than
6014 most published application binary interface specifications for the m68k.
6015
6016 @item -mpcrel
6017 @opindex mpcrel
6018 Use the pc-relative addressing mode of the 68000 directly, instead of
6019 using a global offset table. At present, this option implies @option{-fpic},
6020 allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
6021 not presently supported with @option{-mpcrel}, though this could be supported for
6022 68020 and higher processors.
6023
6024 @item -mno-strict-align
6025 @itemx -mstrict-align
6026 @opindex mno-strict-align
6027 @opindex mstrict-align
6028 Do not (do) assume that unaligned memory references will be handled by
6029 the system.
6030
6031 @item -msep-data
6032 Generate code that allows the data segment to be located in a different
6033 area of memory from the text segment. This allows for execute in place in
6034 an environment without virtual memory management. This option implies -fPIC.
6035
6036 @item -mno-sep-data
6037 Generate code that assumes that the data segment follows the text segment.
6038 This is the default.
6039
6040 @item -mid-shared-library
6041 Generate code that supports shared libraries via the library ID method.
6042 This allows for execute in place and shared libraries in an environment
6043 without virtual memory management. This option implies -fPIC.
6044
6045 @item -mno-id-shared-library
6046 Generate code that doesn't assume ID based shared libraries are being used.
6047 This is the default.
6048
6049 @item -mshared-library-id=n
6050 Specified the identification number of the ID based shared library being
6051 compiled. Specifying a value of 0 will generate more compact code, specifying
6052 other values will force the allocation of that number to the current
6053 library but is no more space or time efficient than omitting this option.
6054
6055 @end table
6056
6057 @node M68hc1x Options
6058 @subsection M68hc1x Options
6059 @cindex M68hc1x options
6060
6061 These are the @samp{-m} options defined for the 68hc11 and 68hc12
6062 microcontrollers. The default values for these options depends on
6063 which style of microcontroller was selected when the compiler was configured;
6064 the defaults for the most common choices are given below.
6065
6066 @table @gcctabopt
6067 @item -m6811
6068 @itemx -m68hc11
6069 @opindex m6811
6070 @opindex m68hc11
6071 Generate output for a 68HC11. This is the default
6072 when the compiler is configured for 68HC11-based systems.
6073
6074 @item -m6812
6075 @itemx -m68hc12
6076 @opindex m6812
6077 @opindex m68hc12
6078 Generate output for a 68HC12. This is the default
6079 when the compiler is configured for 68HC12-based systems.
6080
6081 @item -m68S12
6082 @itemx -m68hcs12
6083 @opindex m68S12
6084 @opindex m68hcs12
6085 Generate output for a 68HCS12.
6086
6087 @item -mauto-incdec
6088 @opindex mauto-incdec
6089 Enable the use of 68HC12 pre and post auto-increment and auto-decrement
6090 addressing modes.
6091
6092 @item -minmax
6093 @itemx -nominmax
6094 @opindex minmax
6095 @opindex mnominmax
6096 Enable the use of 68HC12 min and max instructions.
6097
6098 @item -mlong-calls
6099 @itemx -mno-long-calls
6100 @opindex mlong-calls
6101 @opindex mno-long-calls
6102 Treat all calls as being far away (near). If calls are assumed to be
6103 far away, the compiler will use the @code{call} instruction to
6104 call a function and the @code{rtc} instruction for returning.
6105
6106 @item -mshort
6107 @opindex mshort
6108 Consider type @code{int} to be 16 bits wide, like @code{short int}.
6109
6110 @item -msoft-reg-count=@var{count}
6111 @opindex msoft-reg-count
6112 Specify the number of pseudo-soft registers which are used for the
6113 code generation. The maximum number is 32. Using more pseudo-soft
6114 register may or may not result in better code depending on the program.
6115 The default is 4 for 68HC11 and 2 for 68HC12.
6116
6117 @end table
6118
6119 @node VAX Options
6120 @subsection VAX Options
6121 @cindex VAX options
6122
6123 These @samp{-m} options are defined for the VAX:
6124
6125 @table @gcctabopt
6126 @item -munix
6127 @opindex munix
6128 Do not output certain jump instructions (@code{aobleq} and so on)
6129 that the Unix assembler for the VAX cannot handle across long
6130 ranges.
6131
6132 @item -mgnu
6133 @opindex mgnu
6134 Do output those jump instructions, on the assumption that you
6135 will assemble with the GNU assembler.
6136
6137 @item -mg
6138 @opindex mg
6139 Output code for g-format floating point numbers instead of d-format.
6140 @end table
6141
6142 @node SPARC Options
6143 @subsection SPARC Options
6144 @cindex SPARC options
6145
6146 These @samp{-m} options are supported on the SPARC:
6147
6148 @table @gcctabopt
6149 @item -mno-app-regs
6150 @itemx -mapp-regs
6151 @opindex mno-app-regs
6152 @opindex mapp-regs
6153 Specify @option{-mapp-regs} to generate output using the global registers
6154 2 through 4, which the SPARC SVR4 ABI reserves for applications. This
6155 is the default.
6156
6157 To be fully SVR4 ABI compliant at the cost of some performance loss,
6158 specify @option{-mno-app-regs}. You should compile libraries and system
6159 software with this option.
6160
6161 @item -mfpu
6162 @itemx -mhard-float
6163 @opindex mfpu
6164 @opindex mhard-float
6165 Generate output containing floating point instructions. This is the
6166 default.
6167
6168 @item -mno-fpu
6169 @itemx -msoft-float
6170 @opindex mno-fpu
6171 @opindex msoft-float
6172 Generate output containing library calls for floating point.
6173 @strong{Warning:} the requisite libraries are not available for all SPARC
6174 targets. Normally the facilities of the machine's usual C compiler are
6175 used, but this cannot be done directly in cross-compilation. You must make
6176 your own arrangements to provide suitable library functions for
6177 cross-compilation. The embedded targets @samp{sparc-*-aout} and
6178 @samp{sparclite-*-*} do provide software floating point support.
6179
6180 @option{-msoft-float} changes the calling convention in the output file;
6181 therefore, it is only useful if you compile @emph{all} of a program with
6182 this option. In particular, you need to compile @file{libgcc.a}, the
6183 library that comes with GCC, with @option{-msoft-float} in order for
6184 this to work.
6185
6186 @item -mhard-quad-float
6187 @opindex mhard-quad-float
6188 Generate output containing quad-word (long double) floating point
6189 instructions.
6190
6191 @item -msoft-quad-float
6192 @opindex msoft-quad-float
6193 Generate output containing library calls for quad-word (long double)
6194 floating point instructions. The functions called are those specified
6195 in the SPARC ABI@. This is the default.
6196
6197 As of this writing, there are no SPARC implementations that have hardware
6198 support for the quad-word floating point instructions. They all invoke
6199 a trap handler for one of these instructions, and then the trap handler
6200 emulates the effect of the instruction. Because of the trap handler overhead,
6201 this is much slower than calling the ABI library routines. Thus the
6202 @option{-msoft-quad-float} option is the default.
6203
6204 @item -mno-unaligned-doubles
6205 @itemx -munaligned-doubles
6206 @opindex mno-unaligned-doubles
6207 @opindex munaligned-doubles
6208 Assume that doubles have 8 byte alignment. This is the default.
6209
6210 With @option{-munaligned-doubles}, GCC assumes that doubles have 8 byte
6211 alignment only if they are contained in another type, or if they have an
6212 absolute address. Otherwise, it assumes they have 4 byte alignment.
6213 Specifying this option avoids some rare compatibility problems with code
6214 generated by other compilers. It is not the default because it results
6215 in a performance loss, especially for floating point code.
6216
6217 @item -mno-faster-structs
6218 @itemx -mfaster-structs
6219 @opindex mno-faster-structs
6220 @opindex mfaster-structs
6221 With @option{-mfaster-structs}, the compiler assumes that structures
6222 should have 8 byte alignment. This enables the use of pairs of
6223 @code{ldd} and @code{std} instructions for copies in structure
6224 assignment, in place of twice as many @code{ld} and @code{st} pairs.
6225 However, the use of this changed alignment directly violates the SPARC
6226 ABI@. Thus, it's intended only for use on targets where the developer
6227 acknowledges that their resulting code will not be directly in line with
6228 the rules of the ABI@.
6229
6230 @item -mimpure-text
6231 @opindex mimpure-text
6232 @option{-mimpure-text}, used in addition to @option{-shared}, tells
6233 the compiler to not pass @option{-z text} to the linker when linking a
6234 shared object. Using this option, you can link position-dependent
6235 code into a shared object.
6236
6237 @option{-mimpure-text} suppresses the ``relocations remain against
6238 allocatable but non-writable sections'' linker error message.
6239 However, the necessary relocations will trigger copy-on-write, and the
6240 shared object is not actually shared across processes. Instead of
6241 using @option{-mimpure-text}, you should compile all source code with
6242 @option{-fpic} or @option{-fPIC}.
6243
6244 This option is only available on SunOS and Solaris.
6245
6246 @item -mcpu=@var{cpu_type}
6247 @opindex mcpu
6248 Set the instruction set, register set, and instruction scheduling parameters
6249 for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
6250 @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{sparclite},
6251 @samp{f930}, @samp{f934}, @samp{hypersparc}, @samp{sparclite86x},
6252 @samp{sparclet}, @samp{tsc701}, @samp{v9}, @samp{ultrasparc}, and
6253 @samp{ultrasparc3}.
6254
6255 Default instruction scheduling parameters are used for values that select
6256 an architecture and not an implementation. These are @samp{v7}, @samp{v8},
6257 @samp{sparclite}, @samp{sparclet}, @samp{v9}.
6258
6259 Here is a list of each supported architecture and their supported
6260 implementations.
6261
6262 @smallexample
6263 v7: cypress
6264 v8: supersparc, hypersparc
6265 sparclite: f930, f934, sparclite86x
6266 sparclet: tsc701
6267 v9: ultrasparc, ultrasparc3
6268 @end smallexample
6269
6270 By default (unless configured otherwise), GCC generates code for the V7
6271 variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
6272 additionally optimizes it for the Cypress CY7C602 chip, as used in the
6273 SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
6274 SPARCStation 1, 2, IPX etc.
6275
6276 With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
6277 architecture. The only difference from V7 code is that the compiler emits
6278 the integer multiply and integer divide instructions which exist in SPARC-V8
6279 but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
6280 optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
6281 2000 series.
6282
6283 With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
6284 the SPARC architecture. This adds the integer multiply, integer divide step
6285 and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
6286 With @option{-mcpu=f930}, the compiler additionally optimizes it for the
6287 Fujitsu MB86930 chip, which is the original SPARClite, with no FPU. With
6288 @option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
6289 MB86934 chip, which is the more recent SPARClite with FPU.
6290
6291 With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
6292 the SPARC architecture. This adds the integer multiply, multiply/accumulate,
6293 integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
6294 but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
6295 optimizes it for the TEMIC SPARClet chip.
6296
6297 With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
6298 architecture. This adds 64-bit integer and floating-point move instructions,
6299 3 additional floating-point condition code registers and conditional move
6300 instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
6301 optimizes it for the Sun UltraSPARC I/II chips. With
6302 @option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
6303 Sun UltraSPARC III chip.
6304
6305 @item -mtune=@var{cpu_type}
6306 @opindex mtune
6307 Set the instruction scheduling parameters for machine type
6308 @var{cpu_type}, but do not set the instruction set or register set that the
6309 option @option{-mcpu=@var{cpu_type}} would.
6310
6311 The same values for @option{-mcpu=@var{cpu_type}} can be used for
6312 @option{-mtune=@var{cpu_type}}, but the only useful values are those
6313 that select a particular cpu implementation. Those are @samp{cypress},
6314 @samp{supersparc}, @samp{hypersparc}, @samp{f930}, @samp{f934},
6315 @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc}, and
6316 @samp{ultrasparc3}.
6317
6318 @item -mv8plus
6319 @itemx -mno-v8plus
6320 @opindex -mv8plus
6321 @opindex -mno-v8plus
6322 With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI. The
6323 difference from the V8 ABI is that the global and out registers are
6324 considered 64-bit wide. This is enabled by default on Solaris in 32-bit
6325 mode for all SPARC-V9 processors.
6326
6327 @item -mvis
6328 @itemx -mno-vis
6329 @opindex -mvis
6330 @opindex -mno-vis
6331 With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
6332 Visual Instruction Set extensions. The default is @option{-mno-vis}.
6333 @end table
6334
6335 These @samp{-m} options are supported in addition to the above
6336 on SPARC-V9 processors in 64-bit environments:
6337
6338 @table @gcctabopt
6339 @item -mlittle-endian
6340 @opindex mlittle-endian
6341 Generate code for a processor running in little-endian mode. It is only
6342 available for a few configurations and most notably not on Solaris.
6343
6344 @item -m32
6345 @itemx -m64
6346 @opindex m32
6347 @opindex m64
6348 Generate code for a 32-bit or 64-bit environment.
6349 The 32-bit environment sets int, long and pointer to 32 bits.
6350 The 64-bit environment sets int to 32 bits and long and pointer
6351 to 64 bits.
6352
6353 @item -mcmodel=medlow
6354 @opindex mcmodel=medlow
6355 Generate code for the Medium/Low code model: the program must be linked
6356 in the low 32 bits of the address space. Pointers are 64 bits.
6357 Programs can be statically or dynamically linked.
6358
6359 @item -mcmodel=medmid
6360 @opindex mcmodel=medmid
6361 Generate code for the Medium/Middle code model: the program must be linked
6362 in the low 44 bits of the address space, the text segment must be less than
6363 2G bytes, and data segment must be within 2G of the text segment.
6364 Pointers are 64 bits.
6365
6366 @item -mcmodel=medany
6367 @opindex mcmodel=medany
6368 Generate code for the Medium/Anywhere code model: the program may be linked
6369 anywhere in the address space, the text segment must be less than
6370 2G bytes, and data segment must be within 2G of the text segment.
6371 Pointers are 64 bits.
6372
6373 @item -mcmodel=embmedany
6374 @opindex mcmodel=embmedany
6375 Generate code for the Medium/Anywhere code model for embedded systems:
6376 assume a 32-bit text and a 32-bit data segment, both starting anywhere
6377 (determined at link time). Register %g4 points to the base of the
6378 data segment. Pointers are still 64 bits.
6379 Programs are statically linked, PIC is not supported.
6380
6381 @item -mstack-bias
6382 @itemx -mno-stack-bias
6383 @opindex mstack-bias
6384 @opindex mno-stack-bias
6385 With @option{-mstack-bias}, GCC assumes that the stack pointer, and
6386 frame pointer if present, are offset by @minus{}2047 which must be added back
6387 when making stack frame references. This is the default in 64-bit mode.
6388 Otherwise, assume no such offset is present.
6389 @end table
6390
6391 @node ARM Options
6392 @subsection ARM Options
6393 @cindex ARM options
6394
6395 These @samp{-m} options are defined for Advanced RISC Machines (ARM)
6396 architectures:
6397
6398 @table @gcctabopt
6399 @item -mapcs-frame
6400 @opindex mapcs-frame
6401 Generate a stack frame that is compliant with the ARM Procedure Call
6402 Standard for all functions, even if this is not strictly necessary for
6403 correct execution of the code. Specifying @option{-fomit-frame-pointer}
6404 with this option will cause the stack frames not to be generated for
6405 leaf functions. The default is @option{-mno-apcs-frame}.
6406
6407 @item -mapcs
6408 @opindex mapcs
6409 This is a synonym for @option{-mapcs-frame}.
6410
6411 @item -mapcs-26
6412 @opindex mapcs-26
6413 Generate code for a processor running with a 26-bit program counter,
6414 and conforming to the function calling standards for the APCS 26-bit
6415 option. This option replaces the @option{-m2} and @option{-m3} options
6416 of previous releases of the compiler.
6417
6418 @item -mapcs-32
6419 @opindex mapcs-32
6420 Generate code for a processor running with a 32-bit program counter,
6421 and conforming to the function calling standards for the APCS 32-bit
6422 option. This option replaces the @option{-m6} option of previous releases
6423 of the compiler.
6424
6425 @ignore
6426 @c not currently implemented
6427 @item -mapcs-stack-check
6428 @opindex mapcs-stack-check
6429 Generate code to check the amount of stack space available upon entry to
6430 every function (that actually uses some stack space). If there is
6431 insufficient space available then either the function
6432 @samp{__rt_stkovf_split_small} or @samp{__rt_stkovf_split_big} will be
6433 called, depending upon the amount of stack space required. The run time
6434 system is required to provide these functions. The default is
6435 @option{-mno-apcs-stack-check}, since this produces smaller code.
6436
6437 @c not currently implemented
6438 @item -mapcs-float
6439 @opindex mapcs-float
6440 Pass floating point arguments using the float point registers. This is
6441 one of the variants of the APCS@. This option is recommended if the
6442 target hardware has a floating point unit or if a lot of floating point
6443 arithmetic is going to be performed by the code. The default is
6444 @option{-mno-apcs-float}, since integer only code is slightly increased in
6445 size if @option{-mapcs-float} is used.
6446
6447 @c not currently implemented
6448 @item -mapcs-reentrant
6449 @opindex mapcs-reentrant
6450 Generate reentrant, position independent code. The default is
6451 @option{-mno-apcs-reentrant}.
6452 @end ignore
6453
6454 @item -mthumb-interwork
6455 @opindex mthumb-interwork
6456 Generate code which supports calling between the ARM and Thumb
6457 instruction sets. Without this option the two instruction sets cannot
6458 be reliably used inside one program. The default is
6459 @option{-mno-thumb-interwork}, since slightly larger code is generated
6460 when @option{-mthumb-interwork} is specified.
6461
6462 @item -mno-sched-prolog
6463 @opindex mno-sched-prolog
6464 Prevent the reordering of instructions in the function prolog, or the
6465 merging of those instruction with the instructions in the function's
6466 body. This means that all functions will start with a recognizable set
6467 of instructions (or in fact one of a choice from a small set of
6468 different function prologues), and this information can be used to
6469 locate the start if functions inside an executable piece of code. The
6470 default is @option{-msched-prolog}.
6471
6472 @item -mhard-float
6473 @opindex mhard-float
6474 Generate output containing floating point instructions. This is the
6475 default.
6476
6477 @item -msoft-float
6478 @opindex msoft-float
6479 Generate output containing library calls for floating point.
6480 @strong{Warning:} the requisite libraries are not available for all ARM
6481 targets. Normally the facilities of the machine's usual C compiler are
6482 used, but this cannot be done directly in cross-compilation. You must make
6483 your own arrangements to provide suitable library functions for
6484 cross-compilation.
6485
6486 @option{-msoft-float} changes the calling convention in the output file;
6487 therefore, it is only useful if you compile @emph{all} of a program with
6488 this option. In particular, you need to compile @file{libgcc.a}, the
6489 library that comes with GCC, with @option{-msoft-float} in order for
6490 this to work.
6491
6492 @item -mfloat-abi=@var{name}
6493 @opindex mfloat-abi
6494 Specifies which ABI to use for floating point values. Permissible values
6495 are: @samp{soft}, @samp{softfp} and @samp{hard}.
6496
6497 @samp{soft} and @samp{hard} are equivalent to @option{-msoft-float}
6498 and @option{-mhard-float} respectively. @samp{softfp} allows the generation
6499 of floating point instructions, but still uses the soft-float calling
6500 conventions.
6501
6502 @item -mlittle-endian
6503 @opindex mlittle-endian
6504 Generate code for a processor running in little-endian mode. This is
6505 the default for all standard configurations.
6506
6507 @item -mbig-endian
6508 @opindex mbig-endian
6509 Generate code for a processor running in big-endian mode; the default is
6510 to compile code for a little-endian processor.
6511
6512 @item -mwords-little-endian
6513 @opindex mwords-little-endian
6514 This option only applies when generating code for big-endian processors.
6515 Generate code for a little-endian word order but a big-endian byte
6516 order. That is, a byte order of the form @samp{32107654}. Note: this
6517 option should only be used if you require compatibility with code for
6518 big-endian ARM processors generated by versions of the compiler prior to
6519 2.8.
6520
6521 @item -malignment-traps
6522 @opindex malignment-traps
6523 Generate code that will not trap if the MMU has alignment traps enabled.
6524 On ARM architectures prior to ARMv4, there were no instructions to
6525 access half-word objects stored in memory. However, when reading from
6526 memory a feature of the ARM architecture allows a word load to be used,
6527 even if the address is unaligned, and the processor core will rotate the
6528 data as it is being loaded. This option tells the compiler that such
6529 misaligned accesses will cause a MMU trap and that it should instead
6530 synthesize the access as a series of byte accesses. The compiler can
6531 still use word accesses to load half-word data if it knows that the
6532 address is aligned to a word boundary.
6533
6534 This option is ignored when compiling for ARM architecture 4 or later,
6535 since these processors have instructions to directly access half-word
6536 objects in memory.
6537
6538 @item -mno-alignment-traps
6539 @opindex mno-alignment-traps
6540 Generate code that assumes that the MMU will not trap unaligned
6541 accesses. This produces better code when the target instruction set
6542 does not have half-word memory operations (i.e.@: implementations prior to
6543 ARMv4).
6544
6545 Note that you cannot use this option to access unaligned word objects,
6546 since the processor will only fetch one 32-bit aligned object from
6547 memory.
6548
6549 The default setting for most targets is @option{-mno-alignment-traps}, since
6550 this produces better code when there are no half-word memory
6551 instructions available.
6552
6553 @item -mshort-load-bytes
6554 @itemx -mno-short-load-words
6555 @opindex mshort-load-bytes
6556 @opindex mno-short-load-words
6557 These are deprecated aliases for @option{-malignment-traps}.
6558
6559 @item -mno-short-load-bytes
6560 @itemx -mshort-load-words
6561 @opindex mno-short-load-bytes
6562 @opindex mshort-load-words
6563 This are deprecated aliases for @option{-mno-alignment-traps}.
6564
6565 @item -mcpu=@var{name}
6566 @opindex mcpu
6567 This specifies the name of the target ARM processor. GCC uses this name
6568 to determine what kind of instructions it can emit when generating
6569 assembly code. Permissible names are: @samp{arm2}, @samp{arm250},
6570 @samp{arm3}, @samp{arm6}, @samp{arm60}, @samp{arm600}, @samp{arm610},
6571 @samp{arm620}, @samp{arm7}, @samp{arm7m}, @samp{arm7d}, @samp{arm7dm},
6572 @samp{arm7di}, @samp{arm7dmi}, @samp{arm70}, @samp{arm700},
6573 @samp{arm700i}, @samp{arm710}, @samp{arm710c}, @samp{arm7100},
6574 @samp{arm7500}, @samp{arm7500fe}, @samp{arm7tdmi}, @samp{arm8},
6575 @samp{strongarm}, @samp{strongarm110}, @samp{strongarm1100},
6576 @samp{arm8}, @samp{arm810}, @samp{arm9}, @samp{arm9e}, @samp{arm920},
6577 @samp{arm920t}, @samp{arm926ejs}, @samp{arm940t}, @samp{arm9tdmi},
6578 @samp{arm10tdmi}, @samp{arm1020t}, @samp{arm1026ejs},
6579 @samp{arm1136js}, @samp{arm1136jfs} ,@samp{xscale}, @samp{iwmmxt},
6580 @samp{ep9312}.
6581
6582 @itemx -mtune=@var{name}
6583 @opindex mtune
6584 This option is very similar to the @option{-mcpu=} option, except that
6585 instead of specifying the actual target processor type, and hence
6586 restricting which instructions can be used, it specifies that GCC should
6587 tune the performance of the code as if the target were of the type
6588 specified in this option, but still choosing the instructions that it
6589 will generate based on the cpu specified by a @option{-mcpu=} option.
6590 For some ARM implementations better performance can be obtained by using
6591 this option.
6592
6593 @item -march=@var{name}
6594 @opindex march
6595 This specifies the name of the target ARM architecture. GCC uses this
6596 name to determine what kind of instructions it can emit when generating
6597 assembly code. This option can be used in conjunction with or instead
6598 of the @option{-mcpu=} option. Permissible names are: @samp{armv2},
6599 @samp{armv2a}, @samp{armv3}, @samp{armv3m}, @samp{armv4}, @samp{armv4t},
6600 @samp{armv5}, @samp{armv5t}, @samp{armv5te}, @samp{armv6}, @samp{armv6j},
6601 @samp{iwmmxt}, @samp{ep9312}.
6602
6603 @item -mfpu=@var{name}
6604 @itemx -mfpe=@var{number}
6605 @itemx -mfp=@var{number}
6606 @opindex mfpu
6607 @opindex mfpe
6608 @opindex mfp
6609 This specifies what floating point hardware (or hardware emulation) is
6610 available on the target. Permissible names are: @samp{fpa}, @samp{fpe2},
6611 @samp{fpe3}, @samp{maverick}, @samp{vfp}. @option{-mfp} and @option{-mfpe}
6612 are synonyms for @option{-mpfu}=@samp{fpe}@var{number}, for compatibility
6613 with older versions of GCC@.
6614
6615 If @option{-msoft-float} is specified this specifies the format of
6616 floating point values.
6617
6618 @item -mstructure-size-boundary=@var{n}
6619 @opindex mstructure-size-boundary
6620 The size of all structures and unions will be rounded up to a multiple
6621 of the number of bits set by this option. Permissible values are 8 and
6622 32. The default value varies for different toolchains. For the COFF
6623 targeted toolchain the default value is 8. Specifying the larger number
6624 can produce faster, more efficient code, but can also increase the size
6625 of the program. The two values are potentially incompatible. Code
6626 compiled with one value cannot necessarily expect to work with code or
6627 libraries compiled with the other value, if they exchange information
6628 using structures or unions.
6629
6630 @item -mabort-on-noreturn
6631 @opindex mabort-on-noreturn
6632 Generate a call to the function @code{abort} at the end of a
6633 @code{noreturn} function. It will be executed if the function tries to
6634 return.
6635
6636 @item -mlong-calls
6637 @itemx -mno-long-calls
6638 @opindex mlong-calls
6639 @opindex mno-long-calls
6640 Tells the compiler to perform function calls by first loading the
6641 address of the function into a register and then performing a subroutine
6642 call on this register. This switch is needed if the target function
6643 will lie outside of the 64 megabyte addressing range of the offset based
6644 version of subroutine call instruction.
6645
6646 Even if this switch is enabled, not all function calls will be turned
6647 into long calls. The heuristic is that static functions, functions
6648 which have the @samp{short-call} attribute, functions that are inside
6649 the scope of a @samp{#pragma no_long_calls} directive and functions whose
6650 definitions have already been compiled within the current compilation
6651 unit, will not be turned into long calls. The exception to this rule is
6652 that weak function definitions, functions with the @samp{long-call}
6653 attribute or the @samp{section} attribute, and functions that are within
6654 the scope of a @samp{#pragma long_calls} directive, will always be
6655 turned into long calls.
6656
6657 This feature is not enabled by default. Specifying
6658 @option{-mno-long-calls} will restore the default behavior, as will
6659 placing the function calls within the scope of a @samp{#pragma
6660 long_calls_off} directive. Note these switches have no effect on how
6661 the compiler generates code to handle function calls via function
6662 pointers.
6663
6664 @item -mnop-fun-dllimport
6665 @opindex mnop-fun-dllimport
6666 Disable support for the @code{dllimport} attribute.
6667
6668 @item -msingle-pic-base
6669 @opindex msingle-pic-base
6670 Treat the register used for PIC addressing as read-only, rather than
6671 loading it in the prologue for each function. The run-time system is
6672 responsible for initializing this register with an appropriate value
6673 before execution begins.
6674
6675 @item -mpic-register=@var{reg}
6676 @opindex mpic-register
6677 Specify the register to be used for PIC addressing. The default is R10
6678 unless stack-checking is enabled, when R9 is used.
6679
6680 @item -mcirrus-fix-invalid-insns
6681 @opindex mcirrus-fix-invalid-insns
6682 @opindex mno-cirrus-fix-invalid-insns
6683 Insert NOPs into the instruction stream to in order to work around
6684 problems with invalid Maverick instruction combinations. This option
6685 is only valid if the @option{-mcpu=ep9312} option has been used to
6686 enable generation of instructions for the Cirrus Maverick floating
6687 point co-processor. This option is not enabled by default, since the
6688 problem is only present in older Maverick implementations. The default
6689 can be re-enabled by use of the @option{-mno-cirrus-fix-invalid-insns}
6690 switch.
6691
6692 @item -mpoke-function-name
6693 @opindex mpoke-function-name
6694 Write the name of each function into the text section, directly
6695 preceding the function prologue. The generated code is similar to this:
6696
6697 @smallexample
6698 t0
6699 .ascii "arm_poke_function_name", 0
6700 .align
6701 t1
6702 .word 0xff000000 + (t1 - t0)
6703 arm_poke_function_name
6704 mov ip, sp
6705 stmfd sp!, @{fp, ip, lr, pc@}
6706 sub fp, ip, #4
6707 @end smallexample
6708
6709 When performing a stack backtrace, code can inspect the value of
6710 @code{pc} stored at @code{fp + 0}. If the trace function then looks at
6711 location @code{pc - 12} and the top 8 bits are set, then we know that
6712 there is a function name embedded immediately preceding this location
6713 and has length @code{((pc[-3]) & 0xff000000)}.
6714
6715 @item -mthumb
6716 @opindex mthumb
6717 Generate code for the 16-bit Thumb instruction set. The default is to
6718 use the 32-bit ARM instruction set.
6719
6720 @item -mtpcs-frame
6721 @opindex mtpcs-frame
6722 Generate a stack frame that is compliant with the Thumb Procedure Call
6723 Standard for all non-leaf functions. (A leaf function is one that does
6724 not call any other functions.) The default is @option{-mno-tpcs-frame}.
6725
6726 @item -mtpcs-leaf-frame
6727 @opindex mtpcs-leaf-frame
6728 Generate a stack frame that is compliant with the Thumb Procedure Call
6729 Standard for all leaf functions. (A leaf function is one that does
6730 not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
6731
6732 @item -mcallee-super-interworking
6733 @opindex mcallee-super-interworking
6734 Gives all externally visible functions in the file being compiled an ARM
6735 instruction set header which switches to Thumb mode before executing the
6736 rest of the function. This allows these functions to be called from
6737 non-interworking code.
6738
6739 @item -mcaller-super-interworking
6740 @opindex mcaller-super-interworking
6741 Allows calls via function pointers (including virtual functions) to
6742 execute correctly regardless of whether the target code has been
6743 compiled for interworking or not. There is a small overhead in the cost
6744 of executing a function pointer if this option is enabled.
6745
6746 @end table
6747
6748 @node MN10300 Options
6749 @subsection MN10300 Options
6750 @cindex MN10300 options
6751
6752 These @option{-m} options are defined for Matsushita MN10300 architectures:
6753
6754 @table @gcctabopt
6755 @item -mmult-bug
6756 @opindex mmult-bug
6757 Generate code to avoid bugs in the multiply instructions for the MN10300
6758 processors. This is the default.
6759
6760 @item -mno-mult-bug
6761 @opindex mno-mult-bug
6762 Do not generate code to avoid bugs in the multiply instructions for the
6763 MN10300 processors.
6764
6765 @item -mam33
6766 @opindex mam33
6767 Generate code which uses features specific to the AM33 processor.
6768
6769 @item -mno-am33
6770 @opindex mno-am33
6771 Do not generate code which uses features specific to the AM33 processor. This
6772 is the default.
6773
6774 @item -mno-crt0
6775 @opindex mno-crt0
6776 Do not link in the C run-time initialization object file.
6777
6778 @item -mrelax
6779 @opindex mrelax
6780 Indicate to the linker that it should perform a relaxation optimization pass
6781 to shorten branches, calls and absolute memory addresses. This option only
6782 has an effect when used on the command line for the final link step.
6783
6784 This option makes symbolic debugging impossible.
6785 @end table
6786
6787
6788 @node M32R/D Options
6789 @subsection M32R/D Options
6790 @cindex M32R/D options
6791
6792 These @option{-m} options are defined for Renesas M32R/D architectures:
6793
6794 @table @gcctabopt
6795 @item -m32r2
6796 @opindex m32r2
6797 Generate code for the M32R/2@.
6798
6799 @item -m32rx
6800 @opindex m32rx
6801 Generate code for the M32R/X@.
6802
6803 @item -m32r
6804 @opindex m32r
6805 Generate code for the M32R@. This is the default.
6806
6807 @item -mmodel=small
6808 @opindex mmodel=small
6809 Assume all objects live in the lower 16MB of memory (so that their addresses
6810 can be loaded with the @code{ld24} instruction), and assume all subroutines
6811 are reachable with the @code{bl} instruction.
6812 This is the default.
6813
6814 The addressability of a particular object can be set with the
6815 @code{model} attribute.
6816
6817 @item -mmodel=medium
6818 @opindex mmodel=medium
6819 Assume objects may be anywhere in the 32-bit address space (the compiler
6820 will generate @code{seth/add3} instructions to load their addresses), and
6821 assume all subroutines are reachable with the @code{bl} instruction.
6822
6823 @item -mmodel=large
6824 @opindex mmodel=large
6825 Assume objects may be anywhere in the 32-bit address space (the compiler
6826 will generate @code{seth/add3} instructions to load their addresses), and
6827 assume subroutines may not be reachable with the @code{bl} instruction
6828 (the compiler will generate the much slower @code{seth/add3/jl}
6829 instruction sequence).
6830
6831 @item -msdata=none
6832 @opindex msdata=none
6833 Disable use of the small data area. Variables will be put into
6834 one of @samp{.data}, @samp{bss}, or @samp{.rodata} (unless the
6835 @code{section} attribute has been specified).
6836 This is the default.
6837
6838 The small data area consists of sections @samp{.sdata} and @samp{.sbss}.
6839 Objects may be explicitly put in the small data area with the
6840 @code{section} attribute using one of these sections.
6841
6842 @item -msdata=sdata
6843 @opindex msdata=sdata
6844 Put small global and static data in the small data area, but do not
6845 generate special code to reference them.
6846
6847 @item -msdata=use
6848 @opindex msdata=use
6849 Put small global and static data in the small data area, and generate
6850 special instructions to reference them.
6851
6852 @item -G @var{num}
6853 @opindex G
6854 @cindex smaller data references
6855 Put global and static objects less than or equal to @var{num} bytes
6856 into the small data or bss sections instead of the normal data or bss
6857 sections. The default value of @var{num} is 8.
6858 The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
6859 for this option to have any effect.
6860
6861 All modules should be compiled with the same @option{-G @var{num}} value.
6862 Compiling with different values of @var{num} may or may not work; if it
6863 doesn't the linker will give an error message---incorrect code will not be
6864 generated.
6865
6866 @item -mdebug
6867 @opindex -mdebug
6868 Makes the M32R specific code in the compiler display some statistics
6869 that might help in debugging programs.
6870
6871 @item -malign-loops
6872 @opindex malign-loops
6873 Align all loops to a 32-byte boundary.
6874
6875 @item -mno-align-loops
6876 @opindex mno-align-loops
6877 Do not enforce a 32-byte alignment for loops. This is the default.
6878
6879 @item -missue-rate=@var{number}
6880 @opindex missue-rate=@var{number}
6881 Issue @var{number} instructions per cycle. @var{number} can only be 1
6882 or 2.
6883
6884 @item -mbranch-cost=@var{number}
6885 @opindex mbranch-cost=@var{number}
6886 @var{number} can only be 1 or 2. If it is 1 then branches will be
6887 preferred over conditional code, if it is 2, then the opposite will
6888 apply.
6889
6890 @item -mflush-trap=@var{number}
6891 @opindex mflush-trap=@var{number}
6892 Specifies the trap number to use to flush the cache. The default is
6893 12. Valid numbers are between 0 and 15 inclusive.
6894
6895 @item -mno-flush-trap
6896 @opindex mno-flush-trap
6897 Specifies that the cache cannot be flushed by using a trap.
6898
6899 @item -mflush-func=@var{name}
6900 @opindex mflush-func=@var{name}
6901 Specifies the name of the operating system function to call to flush
6902 the cache. The default is @emph{_flush_cache}, but a function call
6903 will only be used if a trap is not available.
6904
6905 @item -mno-flush-func
6906 @opindex mno-flush-func
6907 Indicates that there is no OS function for flushing the cache.
6908
6909 @end table
6910
6911 @node RS/6000 and PowerPC Options
6912 @subsection IBM RS/6000 and PowerPC Options
6913 @cindex RS/6000 and PowerPC Options
6914 @cindex IBM RS/6000 and PowerPC Options
6915
6916 These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
6917 @table @gcctabopt
6918 @item -mpower
6919 @itemx -mno-power
6920 @itemx -mpower2
6921 @itemx -mno-power2
6922 @itemx -mpowerpc
6923 @itemx -mno-powerpc
6924 @itemx -mpowerpc-gpopt
6925 @itemx -mno-powerpc-gpopt
6926 @itemx -mpowerpc-gfxopt
6927 @itemx -mno-powerpc-gfxopt
6928 @itemx -mpowerpc64
6929 @itemx -mno-powerpc64
6930 @opindex mpower
6931 @opindex mno-power
6932 @opindex mpower2
6933 @opindex mno-power2
6934 @opindex mpowerpc
6935 @opindex mno-powerpc
6936 @opindex mpowerpc-gpopt
6937 @opindex mno-powerpc-gpopt
6938 @opindex mpowerpc-gfxopt
6939 @opindex mno-powerpc-gfxopt
6940 @opindex mpowerpc64
6941 @opindex mno-powerpc64
6942 GCC supports two related instruction set architectures for the
6943 RS/6000 and PowerPC@. The @dfn{POWER} instruction set are those
6944 instructions supported by the @samp{rios} chip set used in the original
6945 RS/6000 systems and the @dfn{PowerPC} instruction set is the
6946 architecture of the Motorola MPC5xx, MPC6xx, MPC8xx microprocessors, and
6947 the IBM 4xx microprocessors.
6948
6949 Neither architecture is a subset of the other. However there is a
6950 large common subset of instructions supported by both. An MQ
6951 register is included in processors supporting the POWER architecture.
6952
6953 You use these options to specify which instructions are available on the
6954 processor you are using. The default value of these options is
6955 determined when configuring GCC@. Specifying the
6956 @option{-mcpu=@var{cpu_type}} overrides the specification of these
6957 options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
6958 rather than the options listed above.
6959
6960 The @option{-mpower} option allows GCC to generate instructions that
6961 are found only in the POWER architecture and to use the MQ register.
6962 Specifying @option{-mpower2} implies @option{-power} and also allows GCC
6963 to generate instructions that are present in the POWER2 architecture but
6964 not the original POWER architecture.
6965
6966 The @option{-mpowerpc} option allows GCC to generate instructions that
6967 are found only in the 32-bit subset of the PowerPC architecture.
6968 Specifying @option{-mpowerpc-gpopt} implies @option{-mpowerpc} and also allows
6969 GCC to use the optional PowerPC architecture instructions in the
6970 General Purpose group, including floating-point square root. Specifying
6971 @option{-mpowerpc-gfxopt} implies @option{-mpowerpc} and also allows GCC to
6972 use the optional PowerPC architecture instructions in the Graphics
6973 group, including floating-point select.
6974
6975 The @option{-mpowerpc64} option allows GCC to generate the additional
6976 64-bit instructions that are found in the full PowerPC64 architecture
6977 and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
6978 @option{-mno-powerpc64}.
6979
6980 If you specify both @option{-mno-power} and @option{-mno-powerpc}, GCC
6981 will use only the instructions in the common subset of both
6982 architectures plus some special AIX common-mode calls, and will not use
6983 the MQ register. Specifying both @option{-mpower} and @option{-mpowerpc}
6984 permits GCC to use any instruction from either architecture and to
6985 allow use of the MQ register; specify this for the Motorola MPC601.
6986
6987 @item -mnew-mnemonics
6988 @itemx -mold-mnemonics
6989 @opindex mnew-mnemonics
6990 @opindex mold-mnemonics
6991 Select which mnemonics to use in the generated assembler code. With
6992 @option{-mnew-mnemonics}, GCC uses the assembler mnemonics defined for
6993 the PowerPC architecture. With @option{-mold-mnemonics} it uses the
6994 assembler mnemonics defined for the POWER architecture. Instructions
6995 defined in only one architecture have only one mnemonic; GCC uses that
6996 mnemonic irrespective of which of these options is specified.
6997
6998 GCC defaults to the mnemonics appropriate for the architecture in
6999 use. Specifying @option{-mcpu=@var{cpu_type}} sometimes overrides the
7000 value of these option. Unless you are building a cross-compiler, you
7001 should normally not specify either @option{-mnew-mnemonics} or
7002 @option{-mold-mnemonics}, but should instead accept the default.
7003
7004 @item -mcpu=@var{cpu_type}
7005 @opindex mcpu
7006 Set architecture type, register usage, choice of mnemonics, and
7007 instruction scheduling parameters for machine type @var{cpu_type}.
7008 Supported values for @var{cpu_type} are @samp{401}, @samp{403},
7009 @samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{505},
7010 @samp{601}, @samp{602}, @samp{603}, @samp{603e}, @samp{604},
7011 @samp{604e}, @samp{620}, @samp{630}, @samp{740}, @samp{7400},
7012 @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
7013 @samp{860}, @samp{970}, @samp{common}, @samp{ec603e}, @samp{G3},
7014 @samp{G4}, @samp{G5}, @samp{power}, @samp{power2}, @samp{power3},
7015 @samp{power4}, @samp{powerpc}, @samp{powerpc64}, @samp{rios},
7016 @samp{rios1}, @samp{rios2}, @samp{rsc}, and @samp{rs64a}.
7017
7018 @option{-mcpu=common} selects a completely generic processor. Code
7019 generated under this option will run on any POWER or PowerPC processor.
7020 GCC will use only the instructions in the common subset of both
7021 architectures, and will not use the MQ register. GCC assumes a generic
7022 processor model for scheduling purposes.
7023
7024 @option{-mcpu=power}, @option{-mcpu=power2}, @option{-mcpu=powerpc}, and
7025 @option{-mcpu=powerpc64} specify generic POWER, POWER2, pure 32-bit
7026 PowerPC (i.e., not MPC601), and 64-bit PowerPC architecture machine
7027 types, with an appropriate, generic processor model assumed for
7028 scheduling purposes.
7029
7030 The other options specify a specific processor. Code generated under
7031 those options will run best on that processor, and may not run at all on
7032 others.
7033
7034 The @option{-mcpu} options automatically enable or disable the
7035 following options: @option{-maltivec}, @option{-mhard-float},
7036 @option{-mmfcrf}, @option{-mmultiple}, @option{-mnew-mnemonics},
7037 @option{-mpower}, @option{-mpower2}, @option{-mpowerpc64},
7038 @option{-mpowerpc-gpopt}, @option{-mpowerpc-gfxopt},
7039 @option{-mstring}. The particular options set for any particular CPU
7040 will vary between compiler versions, depending on what setting seems
7041 to produce optimal code for that CPU; it doesn't necessarily reflect
7042 the actual hardware's capabilities. If you wish to set an individual
7043 option to a particular value, you may specify it after the
7044 @option{-mcpu} option, like @samp{-mcpu=970 -mno-altivec}.
7045
7046 On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
7047 not enabled or disabled by the @option{-mcpu} option at present, since
7048 AIX does not have full support for these options. You may still
7049 enable or disable them individually if you're sure it'll work in your
7050 environment.
7051
7052 @item -mtune=@var{cpu_type}
7053 @opindex mtune
7054 Set the instruction scheduling parameters for machine type
7055 @var{cpu_type}, but do not set the architecture type, register usage, or
7056 choice of mnemonics, as @option{-mcpu=@var{cpu_type}} would. The same
7057 values for @var{cpu_type} are used for @option{-mtune} as for
7058 @option{-mcpu}. If both are specified, the code generated will use the
7059 architecture, registers, and mnemonics set by @option{-mcpu}, but the
7060 scheduling parameters set by @option{-mtune}.
7061
7062 @item -maltivec
7063 @itemx -mno-altivec
7064 @opindex maltivec
7065 @opindex mno-altivec
7066 These switches enable or disable the use of built-in functions that
7067 allow access to the AltiVec instruction set. You may also need to set
7068 @option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
7069 enhancements.
7070
7071 @item -mabi=spe
7072 @opindex mabi=spe
7073 Extend the current ABI with SPE ABI extensions. This does not change
7074 the default ABI, instead it adds the SPE ABI extensions to the current
7075 ABI@.
7076
7077 @item -mabi=no-spe
7078 @opindex mabi=no-spe
7079 Disable Booke SPE ABI extensions for the current ABI.
7080
7081 @item -misel=@var{yes/no}
7082 @itemx -misel
7083 @opindex misel
7084 This switch enables or disables the generation of ISEL instructions.
7085
7086 @item -mspe=@var{yes/no}
7087 @itemx -mspe
7088 @opindex mspe
7089 This switch enables or disables the generation of SPE simd
7090 instructions.
7091
7092 @item -mfloat-gprs=@var{yes/no}
7093 @itemx -mfloat-gprs
7094 @opindex mfloat-gprs
7095 This switch enables or disables the generation of floating point
7096 operations on the general purpose registers for architectures that
7097 support it. This option is currently only available on the MPC8540.
7098
7099 @item -mfull-toc
7100 @itemx -mno-fp-in-toc
7101 @itemx -mno-sum-in-toc
7102 @itemx -mminimal-toc
7103 @opindex mfull-toc
7104 @opindex mno-fp-in-toc
7105 @opindex mno-sum-in-toc
7106 @opindex mminimal-toc
7107 Modify generation of the TOC (Table Of Contents), which is created for
7108 every executable file. The @option{-mfull-toc} option is selected by
7109 default. In that case, GCC will allocate at least one TOC entry for
7110 each unique non-automatic variable reference in your program. GCC
7111 will also place floating-point constants in the TOC@. However, only
7112 16,384 entries are available in the TOC@.
7113
7114 If you receive a linker error message that saying you have overflowed
7115 the available TOC space, you can reduce the amount of TOC space used
7116 with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
7117 @option{-mno-fp-in-toc} prevents GCC from putting floating-point
7118 constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
7119 generate code to calculate the sum of an address and a constant at
7120 run-time instead of putting that sum into the TOC@. You may specify one
7121 or both of these options. Each causes GCC to produce very slightly
7122 slower and larger code at the expense of conserving TOC space.
7123
7124 If you still run out of space in the TOC even when you specify both of
7125 these options, specify @option{-mminimal-toc} instead. This option causes
7126 GCC to make only one TOC entry for every file. When you specify this
7127 option, GCC will produce code that is slower and larger but which
7128 uses extremely little TOC space. You may wish to use this option
7129 only on files that contain less frequently executed code.
7130
7131 @item -maix64
7132 @itemx -maix32
7133 @opindex maix64
7134 @opindex maix32
7135 Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
7136 @code{long} type, and the infrastructure needed to support them.
7137 Specifying @option{-maix64} implies @option{-mpowerpc64} and
7138 @option{-mpowerpc}, while @option{-maix32} disables the 64-bit ABI and
7139 implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
7140
7141 @item -mxl-call
7142 @itemx -mno-xl-call
7143 @opindex mxl-call
7144 @opindex mno-xl-call
7145 On AIX, pass floating-point arguments to prototyped functions beyond the
7146 register save area (RSA) on the stack in addition to argument FPRs. The
7147 AIX calling convention was extended but not initially documented to
7148 handle an obscure K&R C case of calling a function that takes the
7149 address of its arguments with fewer arguments than declared. AIX XL
7150 compilers access floating point arguments which do not fit in the
7151 RSA from the stack when a subroutine is compiled without
7152 optimization. Because always storing floating-point arguments on the
7153 stack is inefficient and rarely needed, this option is not enabled by
7154 default and only is necessary when calling subroutines compiled by AIX
7155 XL compilers without optimization.
7156
7157 @item -mpe
7158 @opindex mpe
7159 Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
7160 application written to use message passing with special startup code to
7161 enable the application to run. The system must have PE installed in the
7162 standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
7163 must be overridden with the @option{-specs=} option to specify the
7164 appropriate directory location. The Parallel Environment does not
7165 support threads, so the @option{-mpe} option and the @option{-pthread}
7166 option are incompatible.
7167
7168 @item -malign-natural
7169 @itemx -malign-power
7170 @opindex malign-natural
7171 @opindex malign-power
7172 On AIX, Darwin, and 64-bit PowerPC GNU/Linux, the option
7173 @option{-malign-natural} overrides the ABI-defined alignment of larger
7174 types, such as floating-point doubles, on their natural size-based boundary.
7175 The option @option{-malign-power} instructs GCC to follow the ABI-specified
7176 alignment rules. GCC defaults to the standard alignment defined in the ABI.
7177
7178 @item -msoft-float
7179 @itemx -mhard-float
7180 @opindex msoft-float
7181 @opindex mhard-float
7182 Generate code that does not use (uses) the floating-point register set.
7183 Software floating point emulation is provided if you use the
7184 @option{-msoft-float} option, and pass the option to GCC when linking.
7185
7186 @item -mmultiple
7187 @itemx -mno-multiple
7188 @opindex mmultiple
7189 @opindex mno-multiple
7190 Generate code that uses (does not use) the load multiple word
7191 instructions and the store multiple word instructions. These
7192 instructions are generated by default on POWER systems, and not
7193 generated on PowerPC systems. Do not use @option{-mmultiple} on little
7194 endian PowerPC systems, since those instructions do not work when the
7195 processor is in little endian mode. The exceptions are PPC740 and
7196 PPC750 which permit the instructions usage in little endian mode.
7197
7198 @item -mstring
7199 @itemx -mno-string
7200 @opindex mstring
7201 @opindex mno-string
7202 Generate code that uses (does not use) the load string instructions
7203 and the store string word instructions to save multiple registers and
7204 do small block moves. These instructions are generated by default on
7205 POWER systems, and not generated on PowerPC systems. Do not use
7206 @option{-mstring} on little endian PowerPC systems, since those
7207 instructions do not work when the processor is in little endian mode.
7208 The exceptions are PPC740 and PPC750 which permit the instructions
7209 usage in little endian mode.
7210
7211 @item -mupdate
7212 @itemx -mno-update
7213 @opindex mupdate
7214 @opindex mno-update
7215 Generate code that uses (does not use) the load or store instructions
7216 that update the base register to the address of the calculated memory
7217 location. These instructions are generated by default. If you use
7218 @option{-mno-update}, there is a small window between the time that the
7219 stack pointer is updated and the address of the previous frame is
7220 stored, which means code that walks the stack frame across interrupts or
7221 signals may get corrupted data.
7222
7223 @item -mfused-madd
7224 @itemx -mno-fused-madd
7225 @opindex mfused-madd
7226 @opindex mno-fused-madd
7227 Generate code that uses (does not use) the floating point multiply and
7228 accumulate instructions. These instructions are generated by default if
7229 hardware floating is used.
7230
7231 @item -mno-bit-align
7232 @itemx -mbit-align
7233 @opindex mno-bit-align
7234 @opindex mbit-align
7235 On System V.4 and embedded PowerPC systems do not (do) force structures
7236 and unions that contain bit-fields to be aligned to the base type of the
7237 bit-field.
7238
7239 For example, by default a structure containing nothing but 8
7240 @code{unsigned} bit-fields of length 1 would be aligned to a 4 byte
7241 boundary and have a size of 4 bytes. By using @option{-mno-bit-align},
7242 the structure would be aligned to a 1 byte boundary and be one byte in
7243 size.
7244
7245 @item -mno-strict-align
7246 @itemx -mstrict-align
7247 @opindex mno-strict-align
7248 @opindex mstrict-align
7249 On System V.4 and embedded PowerPC systems do not (do) assume that
7250 unaligned memory references will be handled by the system.
7251
7252 @item -mrelocatable
7253 @itemx -mno-relocatable
7254 @opindex mrelocatable
7255 @opindex mno-relocatable
7256 On embedded PowerPC systems generate code that allows (does not allow)
7257 the program to be relocated to a different address at runtime. If you
7258 use @option{-mrelocatable} on any module, all objects linked together must
7259 be compiled with @option{-mrelocatable} or @option{-mrelocatable-lib}.
7260
7261 @item -mrelocatable-lib
7262 @itemx -mno-relocatable-lib
7263 @opindex mrelocatable-lib
7264 @opindex mno-relocatable-lib
7265 On embedded PowerPC systems generate code that allows (does not allow)
7266 the program to be relocated to a different address at runtime. Modules
7267 compiled with @option{-mrelocatable-lib} can be linked with either modules
7268 compiled without @option{-mrelocatable} and @option{-mrelocatable-lib} or
7269 with modules compiled with the @option{-mrelocatable} options.
7270
7271 @item -mno-toc
7272 @itemx -mtoc
7273 @opindex mno-toc
7274 @opindex mtoc
7275 On System V.4 and embedded PowerPC systems do not (do) assume that
7276 register 2 contains a pointer to a global area pointing to the addresses
7277 used in the program.
7278
7279 @item -mlittle
7280 @itemx -mlittle-endian
7281 @opindex mlittle
7282 @opindex mlittle-endian
7283 On System V.4 and embedded PowerPC systems compile code for the
7284 processor in little endian mode. The @option{-mlittle-endian} option is
7285 the same as @option{-mlittle}.
7286
7287 @item -mbig
7288 @itemx -mbig-endian
7289 @opindex mbig
7290 @opindex mbig-endian
7291 On System V.4 and embedded PowerPC systems compile code for the
7292 processor in big endian mode. The @option{-mbig-endian} option is
7293 the same as @option{-mbig}.
7294
7295 @item -mdynamic-no-pic
7296 @opindex mdynamic-no-pic
7297 On Darwin and Mac OS X systems, compile code so that it is not
7298 relocatable, but that its external references are relocatable. The
7299 resulting code is suitable for applications, but not shared
7300 libraries.
7301
7302 @item -mprioritize-restricted-insns=@var{priority}
7303 @opindex mprioritize-restricted-insns
7304 This option controls the priority that is assigned to
7305 dispatch-slot restricted instructions during the second scheduling
7306 pass. The argument @var{priority} takes the value @var{0/1/2} to assign
7307 @var{no/highest/second-highest} priority to dispatch slot restricted
7308 instructions.
7309
7310 @item -msched-costly-dep=@var{dependence_type}
7311 @opindex msched-costly-dep
7312 This option controls which dependences are considered costly
7313 by the target during instruction scheduling. The argument
7314 @var{dependence_type} takes one of the following values:
7315 @var{no}: no dependence is costly,
7316 @var{all}: all dependences are costly,
7317 @var{true_store_to_load}: a true dependence from store to load is costly,
7318 @var{store_to_load}: any dependence from store to load is costly,
7319 @var{number}: any dependence which latency >= @var{number} is costly.
7320
7321 @item -minsert-sched-nops=@var{scheme}
7322 @opindex minsert-sched-nops
7323 This option controls which nop insertion scheme will be used during
7324 the second scheduling pass. The argument @var{scheme} takes one of the
7325 following values:
7326 @var{no}: Don't insert nops.
7327 @var{pad}: Pad with nops any dispatch group which has vacant issue slots,
7328 according to the scheduler's grouping.
7329 @var{regroup_exact}: Insert nops to force costly dependent insns into
7330 separate groups. Insert exactly as many nops as needed to force an insn
7331 to a new group, according to the estimated processor grouping.
7332 @var{number}: Insert nops to force costly dependent insns into
7333 separate groups. Insert @var{number} nops to force an insn to a new group.
7334
7335 @item -mcall-sysv
7336 @opindex mcall-sysv
7337 On System V.4 and embedded PowerPC systems compile code using calling
7338 conventions that adheres to the March 1995 draft of the System V
7339 Application Binary Interface, PowerPC processor supplement. This is the
7340 default unless you configured GCC using @samp{powerpc-*-eabiaix}.
7341
7342 @item -mcall-sysv-eabi
7343 @opindex mcall-sysv-eabi
7344 Specify both @option{-mcall-sysv} and @option{-meabi} options.
7345
7346 @item -mcall-sysv-noeabi
7347 @opindex mcall-sysv-noeabi
7348 Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
7349
7350 @item -mcall-solaris
7351 @opindex mcall-solaris
7352 On System V.4 and embedded PowerPC systems compile code for the Solaris
7353 operating system.
7354
7355 @item -mcall-linux
7356 @opindex mcall-linux
7357 On System V.4 and embedded PowerPC systems compile code for the
7358 Linux-based GNU system.
7359
7360 @item -mcall-gnu
7361 @opindex mcall-gnu
7362 On System V.4 and embedded PowerPC systems compile code for the
7363 Hurd-based GNU system.
7364
7365 @item -mcall-netbsd
7366 @opindex mcall-netbsd
7367 On System V.4 and embedded PowerPC systems compile code for the
7368 NetBSD operating system.
7369
7370 @item -maix-struct-return
7371 @opindex maix-struct-return
7372 Return all structures in memory (as specified by the AIX ABI)@.
7373
7374 @item -msvr4-struct-return
7375 @opindex msvr4-struct-return
7376 Return structures smaller than 8 bytes in registers (as specified by the
7377 SVR4 ABI)@.
7378
7379 @item -mabi=altivec
7380 @opindex mabi=altivec
7381 Extend the current ABI with AltiVec ABI extensions. This does not
7382 change the default ABI, instead it adds the AltiVec ABI extensions to
7383 the current ABI@.
7384
7385 @item -mabi=no-altivec
7386 @opindex mabi=no-altivec
7387 Disable AltiVec ABI extensions for the current ABI.
7388
7389 @item -mprototype
7390 @itemx -mno-prototype
7391 @opindex mprototype
7392 @opindex mno-prototype
7393 On System V.4 and embedded PowerPC systems assume that all calls to
7394 variable argument functions are properly prototyped. Otherwise, the
7395 compiler must insert an instruction before every non prototyped call to
7396 set or clear bit 6 of the condition code register (@var{CR}) to
7397 indicate whether floating point values were passed in the floating point
7398 registers in case the function takes a variable arguments. With
7399 @option{-mprototype}, only calls to prototyped variable argument functions
7400 will set or clear the bit.
7401
7402 @item -msim
7403 @opindex msim
7404 On embedded PowerPC systems, assume that the startup module is called
7405 @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
7406 @file{libc.a}. This is the default for @samp{powerpc-*-eabisim}.
7407 configurations.
7408
7409 @item -mmvme
7410 @opindex mmvme
7411 On embedded PowerPC systems, assume that the startup module is called
7412 @file{crt0.o} and the standard C libraries are @file{libmvme.a} and
7413 @file{libc.a}.
7414
7415 @item -mads
7416 @opindex mads
7417 On embedded PowerPC systems, assume that the startup module is called
7418 @file{crt0.o} and the standard C libraries are @file{libads.a} and
7419 @file{libc.a}.
7420
7421 @item -myellowknife
7422 @opindex myellowknife
7423 On embedded PowerPC systems, assume that the startup module is called
7424 @file{crt0.o} and the standard C libraries are @file{libyk.a} and
7425 @file{libc.a}.
7426
7427 @item -mvxworks
7428 @opindex mvxworks
7429 On System V.4 and embedded PowerPC systems, specify that you are
7430 compiling for a VxWorks system.
7431
7432 @item -mwindiss
7433 @opindex mwindiss
7434 Specify that you are compiling for the WindISS simulation environment.
7435
7436 @item -memb
7437 @opindex memb
7438 On embedded PowerPC systems, set the @var{PPC_EMB} bit in the ELF flags
7439 header to indicate that @samp{eabi} extended relocations are used.
7440
7441 @item -meabi
7442 @itemx -mno-eabi
7443 @opindex meabi
7444 @opindex mno-eabi
7445 On System V.4 and embedded PowerPC systems do (do not) adhere to the
7446 Embedded Applications Binary Interface (eabi) which is a set of
7447 modifications to the System V.4 specifications. Selecting @option{-meabi}
7448 means that the stack is aligned to an 8 byte boundary, a function
7449 @code{__eabi} is called to from @code{main} to set up the eabi
7450 environment, and the @option{-msdata} option can use both @code{r2} and
7451 @code{r13} to point to two separate small data areas. Selecting
7452 @option{-mno-eabi} means that the stack is aligned to a 16 byte boundary,
7453 do not call an initialization function from @code{main}, and the
7454 @option{-msdata} option will only use @code{r13} to point to a single
7455 small data area. The @option{-meabi} option is on by default if you
7456 configured GCC using one of the @samp{powerpc*-*-eabi*} options.
7457
7458 @item -msdata=eabi
7459 @opindex msdata=eabi
7460 On System V.4 and embedded PowerPC systems, put small initialized
7461 @code{const} global and static data in the @samp{.sdata2} section, which
7462 is pointed to by register @code{r2}. Put small initialized
7463 non-@code{const} global and static data in the @samp{.sdata} section,
7464 which is pointed to by register @code{r13}. Put small uninitialized
7465 global and static data in the @samp{.sbss} section, which is adjacent to
7466 the @samp{.sdata} section. The @option{-msdata=eabi} option is
7467 incompatible with the @option{-mrelocatable} option. The
7468 @option{-msdata=eabi} option also sets the @option{-memb} option.
7469
7470 @item -msdata=sysv
7471 @opindex msdata=sysv
7472 On System V.4 and embedded PowerPC systems, put small global and static
7473 data in the @samp{.sdata} section, which is pointed to by register
7474 @code{r13}. Put small uninitialized global and static data in the
7475 @samp{.sbss} section, which is adjacent to the @samp{.sdata} section.
7476 The @option{-msdata=sysv} option is incompatible with the
7477 @option{-mrelocatable} option.
7478
7479 @item -msdata=default
7480 @itemx -msdata
7481 @opindex msdata=default
7482 @opindex msdata
7483 On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
7484 compile code the same as @option{-msdata=eabi}, otherwise compile code the
7485 same as @option{-msdata=sysv}.
7486
7487 @item -msdata-data
7488 @opindex msdata-data
7489 On System V.4 and embedded PowerPC systems, put small global and static
7490 data in the @samp{.sdata} section. Put small uninitialized global and
7491 static data in the @samp{.sbss} section. Do not use register @code{r13}
7492 to address small data however. This is the default behavior unless
7493 other @option{-msdata} options are used.
7494
7495 @item -msdata=none
7496 @itemx -mno-sdata
7497 @opindex msdata=none
7498 @opindex mno-sdata
7499 On embedded PowerPC systems, put all initialized global and static data
7500 in the @samp{.data} section, and all uninitialized data in the
7501 @samp{.bss} section.
7502
7503 @item -G @var{num}
7504 @opindex G
7505 @cindex smaller data references (PowerPC)
7506 @cindex .sdata/.sdata2 references (PowerPC)
7507 On embedded PowerPC systems, put global and static items less than or
7508 equal to @var{num} bytes into the small data or bss sections instead of
7509 the normal data or bss section. By default, @var{num} is 8. The
7510 @option{-G @var{num}} switch is also passed to the linker.
7511 All modules should be compiled with the same @option{-G @var{num}} value.
7512
7513 @item -mregnames
7514 @itemx -mno-regnames
7515 @opindex mregnames
7516 @opindex mno-regnames
7517 On System V.4 and embedded PowerPC systems do (do not) emit register
7518 names in the assembly language output using symbolic forms.
7519
7520 @item -mlongcall
7521 @itemx -mno-longcall
7522 @opindex mlongcall
7523 @opindex mno-longcall
7524 Default to making all function calls via pointers, so that functions
7525 which reside further than 64 megabytes (67,108,864 bytes) from the
7526 current location can be called. This setting can be overridden by the
7527 @code{shortcall} function attribute, or by @code{#pragma longcall(0)}.
7528
7529 Some linkers are capable of detecting out-of-range calls and generating
7530 glue code on the fly. On these systems, long calls are unnecessary and
7531 generate slower code. As of this writing, the AIX linker can do this,
7532 as can the GNU linker for PowerPC/64. It is planned to add this feature
7533 to the GNU linker for 32-bit PowerPC systems as well.
7534
7535 On Mach-O (Darwin) systems, this option directs the compiler emit to
7536 the glue for every direct call, and the Darwin linker decides whether
7537 to use or discard it.
7538
7539 In the future, we may cause GCC to ignore all longcall specifications
7540 when the linker is known to generate glue.
7541
7542 @item -pthread
7543 @opindex pthread
7544 Adds support for multithreading with the @dfn{pthreads} library.
7545 This option sets flags for both the preprocessor and linker.
7546
7547 @end table
7548
7549 @node Darwin Options
7550 @subsection Darwin Options
7551 @cindex Darwin options
7552
7553 These options are defined for all architectures running the Darwin operating
7554 system. They are useful for compatibility with other Mac OS compilers.
7555
7556 @table @gcctabopt
7557 @item -all_load
7558 @opindex all_load
7559 Loads all members of static archive libraries.
7560 See man ld(1) for more information.
7561
7562 @item -arch_errors_fatal
7563 @opindex arch_errors_fatal
7564 Cause the errors having to do with files that have the wrong architecture
7565 to be fatal.
7566
7567 @item -bind_at_load
7568 @opindex bind_at_load
7569 Causes the output file to be marked such that the dynamic linker will
7570 bind all undefined references when the file is loaded or launched.
7571
7572 @item -bundle
7573 @opindex bundle
7574 Produce a Mach-o bundle format file.
7575 See man ld(1) for more information.
7576
7577 @item -bundle_loader @var{executable}
7578 @opindex bundle_loader
7579 This specifies the @var{executable} that will be loading the build
7580 output file being linked. See man ld(1) for more information.
7581
7582 @item -allowable_client @var{client_name}
7583 @itemx -arch_only
7584
7585 @itemx -client_name
7586 @itemx -compatibility_version
7587 @itemx -current_version
7588 @itemx -dependency-file
7589 @itemx -dylib_file
7590 @itemx -dylinker_install_name
7591 @itemx -dynamic
7592 @itemx -dynamiclib
7593 @itemx -exported_symbols_list
7594 @itemx -filelist
7595 @itemx -flat_namespace
7596 @itemx -force_cpusubtype_ALL
7597 @itemx -force_flat_namespace
7598 @itemx -headerpad_max_install_names
7599 @itemx -image_base
7600 @itemx -init
7601 @itemx -install_name
7602 @itemx -keep_private_externs
7603 @itemx -multi_module
7604 @itemx -multiply_defined
7605 @itemx -multiply_defined_unused
7606 @itemx -noall_load
7607 @itemx -nofixprebinding
7608 @itemx -nomultidefs
7609 @itemx -noprebind
7610 @itemx -noseglinkedit
7611 @itemx -pagezero_size
7612 @itemx -prebind
7613 @itemx -prebind_all_twolevel_modules
7614 @itemx -private_bundle
7615 @itemx -read_only_relocs
7616 @itemx -sectalign
7617 @itemx -sectobjectsymbols
7618 @itemx -whyload
7619 @itemx -seg1addr
7620 @itemx -sectcreate
7621 @itemx -sectobjectsymbols
7622 @itemx -sectorder
7623 @itemx -seg_addr_table
7624 @itemx -seg_addr_table_filename
7625 @itemx -seglinkedit
7626 @itemx -segprot
7627 @itemx -segs_read_only_addr
7628 @itemx -segs_read_write_addr
7629 @itemx -single_module
7630 @itemx -static
7631 @itemx -sub_library
7632 @itemx -sub_umbrella
7633 @itemx -twolevel_namespace
7634 @itemx -umbrella
7635 @itemx -undefined
7636 @itemx -unexported_symbols_list
7637 @itemx -weak_reference_mismatches
7638 @itemx -whatsloaded
7639
7640 @opindex allowable_client
7641 @opindex arch_only
7642 @opindex client_name
7643 @opindex compatibility_version
7644 @opindex current_version
7645 @opindex dependency-file
7646 @opindex dylib_file
7647 @opindex dylinker_install_name
7648 @opindex dynamic
7649 @opindex dynamiclib
7650 @opindex exported_symbols_list
7651 @opindex filelist
7652 @opindex flat_namespace
7653 @opindex force_cpusubtype_ALL
7654 @opindex force_flat_namespace
7655 @opindex headerpad_max_install_names
7656 @opindex image_base
7657 @opindex init
7658 @opindex install_name
7659 @opindex keep_private_externs
7660 @opindex multi_module
7661 @opindex multiply_defined
7662 @opindex multiply_defined_unused
7663 @opindex noall_load
7664 @opindex nofixprebinding
7665 @opindex nomultidefs
7666 @opindex noprebind
7667 @opindex noseglinkedit
7668 @opindex pagezero_size
7669 @opindex prebind
7670 @opindex prebind_all_twolevel_modules
7671 @opindex private_bundle
7672 @opindex read_only_relocs
7673 @opindex sectalign
7674 @opindex sectobjectsymbols
7675 @opindex whyload
7676 @opindex seg1addr
7677 @opindex sectcreate
7678 @opindex sectobjectsymbols
7679 @opindex sectorder
7680 @opindex seg_addr_table
7681 @opindex seg_addr_table_filename
7682 @opindex seglinkedit
7683 @opindex segprot
7684 @opindex segs_read_only_addr
7685 @opindex segs_read_write_addr
7686 @opindex single_module
7687 @opindex static
7688 @opindex sub_library
7689 @opindex sub_umbrella
7690 @opindex twolevel_namespace
7691 @opindex umbrella
7692 @opindex undefined
7693 @opindex unexported_symbols_list
7694 @opindex weak_reference_mismatches
7695 @opindex whatsloaded
7696
7697 These options are available for Darwin linker. Darwin linker man page
7698 describes them in detail.
7699 @end table
7700
7701
7702 @node MIPS Options
7703 @subsection MIPS Options
7704 @cindex MIPS options
7705
7706 @table @gcctabopt
7707
7708 @item -EB
7709 @opindex EB
7710 Generate big-endian code.
7711
7712 @item -EL
7713 @opindex EL
7714 Generate little-endian code. This is the default for @samp{mips*el-*-*}
7715 configurations.
7716
7717 @item -march=@var{arch}
7718 @opindex march
7719 Generate code that will run on @var{arch}, which can be the name of a
7720 generic MIPS ISA, or the name of a particular processor.
7721 The ISA names are:
7722 @samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
7723 @samp{mips32}, @samp{mips32r2}, and @samp{mips64}.
7724 The processor names are:
7725 @samp{4kc}, @samp{4kp}, @samp{5kc}, @samp{20kc},
7726 @samp{m4k},
7727 @samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
7728 @samp{r4600}, @samp{r4650}, @samp{r6000}, @samp{r8000}, @samp{rm7000},
7729 @samp{rm9000},
7730 @samp{orion},
7731 @samp{sb1},
7732 @samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4300},
7733 @samp{vr5000}, @samp{vr5400} and @samp{vr5500}.
7734 The special value @samp{from-abi} selects the
7735 most compatible architecture for the selected ABI (that is,
7736 @samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
7737
7738 In processor names, a final @samp{000} can be abbreviated as @samp{k}
7739 (for example, @samp{-march=r2k}). Prefixes are optional, and
7740 @samp{vr} may be written @samp{r}.
7741
7742 GCC defines two macros based on the value of this option. The first
7743 is @samp{_MIPS_ARCH}, which gives the name of target architecture, as
7744 a string. The second has the form @samp{_MIPS_ARCH_@var{foo}},
7745 where @var{foo} is the capitalized value of @samp{_MIPS_ARCH}@.
7746 For example, @samp{-march=r2000} will set @samp{_MIPS_ARCH}
7747 to @samp{"r2000"} and define the macro @samp{_MIPS_ARCH_R2000}.
7748
7749 Note that the @samp{_MIPS_ARCH} macro uses the processor names given
7750 above. In other words, it will have the full prefix and will not
7751 abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
7752 the macro names the resolved architecture (either @samp{"mips1"} or
7753 @samp{"mips3"}). It names the default architecture when no
7754 @option{-march} option is given.
7755
7756 @item -mtune=@var{arch}
7757 @opindex mtune
7758 Optimize for @var{arch}. Among other things, this option controls
7759 the way instructions are scheduled, and the perceived cost of arithmetic
7760 operations. The list of @var{arch} values is the same as for
7761 @option{-march}.
7762
7763 When this option is not used, GCC will optimize for the processor
7764 specified by @option{-march}. By using @option{-march} and
7765 @option{-mtune} together, it is possible to generate code that will
7766 run on a family of processors, but optimize the code for one
7767 particular member of that family.
7768
7769 @samp{-mtune} defines the macros @samp{_MIPS_TUNE} and
7770 @samp{_MIPS_TUNE_@var{foo}}, which work in the same way as the
7771 @samp{-march} ones described above.
7772
7773 @item -mips1
7774 @opindex mips1
7775 Equivalent to @samp{-march=mips1}.
7776
7777 @item -mips2
7778 @opindex mips2
7779 Equivalent to @samp{-march=mips2}.
7780
7781 @item -mips3
7782 @opindex mips3
7783 Equivalent to @samp{-march=mips3}.
7784
7785 @item -mips4
7786 @opindex mips4
7787 Equivalent to @samp{-march=mips4}.
7788
7789 @item -mips32
7790 @opindex mips32
7791 Equivalent to @samp{-march=mips32}.
7792
7793 @item -mips32r2
7794 @opindex mips32r2
7795 Equivalent to @samp{-march=mips32r2}.
7796
7797 @item -mips64
7798 @opindex mips64
7799 Equivalent to @samp{-march=mips64}.
7800
7801 @item -mips16
7802 @itemx -mno-mips16
7803 @opindex mips16
7804 @opindex mno-mips16
7805 Use (do not use) the MIPS16 ISA.
7806
7807 @item -mabi=32
7808 @itemx -mabi=o64
7809 @itemx -mabi=n32
7810 @itemx -mabi=64
7811 @itemx -mabi=eabi
7812 @opindex mabi=32
7813 @opindex mabi=o64
7814 @opindex mabi=n32
7815 @opindex mabi=64
7816 @opindex mabi=eabi
7817 Generate code for the given ABI@.
7818
7819 Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
7820 generates 64-bit code when you select a 64-bit architecture, but you
7821 can use @option{-mgp32} to get 32-bit code instead.
7822
7823 @item -mabicalls
7824 @itemx -mno-abicalls
7825 @opindex mabicalls
7826 @opindex mno-abicalls
7827 Generate (do not generate) SVR4-style position-independent code.
7828 @option{-mabicalls} is the default for SVR4-based systems.
7829
7830 @item -mxgot
7831 @itemx -mno-xgot
7832 @opindex mxgot
7833 @opindex mno-xgot
7834 Lift (do not lift) the usual restrictions on the size of the global
7835 offset table.
7836
7837 GCC normally uses a single instruction to load values from the GOT.
7838 While this is relatively efficient, it will only work if the GOT
7839 is smaller than about 64k. Anything larger will cause the linker
7840 to report an error such as:
7841
7842 @cindex relocation truncated to fit (MIPS)
7843 @smallexample
7844 relocation truncated to fit: R_MIPS_GOT16 foobar
7845 @end smallexample
7846
7847 If this happens, you should recompile your code with @option{-mxgot}.
7848 It should then work with very large GOTs, although it will also be
7849 less efficient, since it will take three instructions to fetch the
7850 value of a global symbol.
7851
7852 Note that some linkers can create multiple GOTs. If you have such a
7853 linker, you should only need to use @option{-mxgot} when a single object
7854 file accesses more than 64k's worth of GOT entries. Very few do.
7855
7856 These options have no effect unless GCC is generating position
7857 independent code.
7858
7859 @item -membedded-pic
7860 @itemx -mno-embedded-pic
7861 @opindex membedded-pic
7862 @opindex mno-embedded-pic
7863 Generate (do not generate) position-independent code suitable for some
7864 embedded systems. All calls are made using PC relative addresses, and
7865 all data is addressed using the $gp register. No more than 65536
7866 bytes of global data may be used. This requires GNU as and GNU ld,
7867 which do most of the work.
7868
7869 @item -mgp32
7870 @opindex mgp32
7871 Assume that general-purpose registers are 32 bits wide.
7872
7873 @item -mgp64
7874 @opindex mgp64
7875 Assume that general-purpose registers are 64 bits wide.
7876
7877 @item -mfp32
7878 @opindex mfp32
7879 Assume that floating-point registers are 32 bits wide.
7880
7881 @item -mfp64
7882 @opindex mfp64
7883 Assume that floating-point registers are 64 bits wide.
7884
7885 @item -mhard-float
7886 @opindex mhard-float
7887 Use floating-point coprocessor instructions.
7888
7889 @item -msoft-float
7890 @opindex msoft-float
7891 Do not use floating-point coprocessor instructions. Implement
7892 floating-point calculations using library calls instead.
7893
7894 @item -msingle-float
7895 @opindex msingle-float
7896 Assume that the floating-point coprocessor only supports single-precision
7897 operations.
7898
7899 @itemx -mdouble-float
7900 @opindex mdouble-float
7901 Assume that the floating-point coprocessor supports double-precision
7902 operations. This is the default.
7903
7904 @item -mint64
7905 @opindex mint64
7906 Force @code{int} and @code{long} types to be 64 bits wide. See
7907 @option{-mlong32} for an explanation of the default and the way
7908 that the pointer size is determined.
7909
7910 @item -mlong64
7911 @opindex mlong64
7912 Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
7913 an explanation of the default and the way that the pointer size is
7914 determined.
7915
7916 @item -mlong32
7917 @opindex mlong32
7918 Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
7919
7920 The default size of @code{int}s, @code{long}s and pointers depends on
7921 the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
7922 uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
7923 32-bit @code{long}s. Pointers are the same size as @code{long}s,
7924 or the same size as integer registers, whichever is smaller.
7925
7926 @item -G @var{num}
7927 @opindex G
7928 @cindex smaller data references (MIPS)
7929 @cindex gp-relative references (MIPS)
7930 Put global and static items less than or equal to @var{num} bytes into
7931 the small data or bss section instead of the normal data or bss section.
7932 This allows the data to be accessed using a single instruction.
7933
7934 All modules should be compiled with the same @option{-G @var{num}}
7935 value.
7936
7937 @item -membedded-data
7938 @itemx -mno-embedded-data
7939 @opindex membedded-data
7940 @opindex mno-embedded-data
7941 Allocate variables to the read-only data section first if possible, then
7942 next in the small data section if possible, otherwise in data. This gives
7943 slightly slower code than the default, but reduces the amount of RAM required
7944 when executing, and thus may be preferred for some embedded systems.
7945
7946 @item -muninit-const-in-rodata
7947 @itemx -mno-uninit-const-in-rodata
7948 @opindex muninit-const-in-rodata
7949 @opindex mno-uninit-const-in-rodata
7950 Put uninitialized @code{const} variables in the read-only data section.
7951 This option is only meaningful in conjunction with @option{-membedded-data}.
7952
7953 @item -msplit-addresses
7954 @itemx -mno-split-addresses
7955 @opindex msplit-addresses
7956 @opindex mno-split-addresses
7957 Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
7958 relocation operators. This option has been superceded by
7959 @option{-mexplicit-relocs} but is retained for backwards compatibility.
7960
7961 @item -mexplicit-relocs
7962 @itemx -mno-explicit-relocs
7963 @opindex mexplicit-relocs
7964 @opindex mno-explicit-relocs
7965 Use (do not use) assembler relocation operators when dealing with symbolic
7966 addresses. The alternative, selected by @option{-mno-explicit-relocs},
7967 is to use assembler macros instead.
7968
7969 @option{-mexplicit-relocs} is usually the default if GCC was configured
7970 to use an assembler that supports relocation operators. However, the
7971 combination of @option{-mabicalls} and @option{-fno-unit-at-a-time}
7972 implies @option{-mno-explicit-relocs} unless explicitly overridden.
7973 This is because, when generating abicalls, the choice of relocation
7974 depends on whether a symbol is local or global. In some rare cases,
7975 GCC will not be able to decide this until the whole compilation unit
7976 has been read.
7977
7978 @item -mrnames
7979 @itemx -mno-rnames
7980 @opindex mrnames
7981 @opindex mno-rnames
7982 Generate (do not generate) code that refers to registers using their
7983 software names. The default is @option{-mno-rnames}, which tells GCC
7984 to use hardware names like @samp{$4} instead of software names like
7985 @samp{a0}. The only assembler known to support @option{-rnames} is
7986 the Algorithmics assembler.
7987
7988 @item -mcheck-zero-division
7989 @itemx -mno-check-zero-division
7990 @opindex mcheck-zero-division
7991 @opindex mno-check-zero-division
7992 Trap (do not trap) on integer division by zero. The default is
7993 @option{-mcheck-zero-division}.
7994
7995 @item -mmemcpy
7996 @itemx -mno-memcpy
7997 @opindex mmemcpy
7998 @opindex mno-memcpy
7999 Force (do not force) the use of @code{memcpy()} for non-trivial block
8000 moves. The default is @option{-mno-memcpy}, which allows GCC to inline
8001 most constant-sized copies.
8002
8003 @item -mlong-calls
8004 @itemx -mno-long-calls
8005 @opindex mlong-calls
8006 @opindex mno-long-calls
8007 Disable (do not disable) use of the @code{jal} instruction. Calling
8008 functions using @code{jal} is more efficient but requires the caller
8009 and callee to be in the same 256 megabyte segment.
8010
8011 This option has no effect on abicalls code. The default is
8012 @option{-mno-long-calls}.
8013
8014 @item -mmad
8015 @itemx -mno-mad
8016 @opindex mmad
8017 @opindex mno-mad
8018 Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
8019 instructions, as provided by the R4650 ISA.
8020
8021 @item -mfused-madd
8022 @itemx -mno-fused-madd
8023 @opindex mfused-madd
8024 @opindex mno-fused-madd
8025 Enable (disable) use of the floating point multiply-accumulate
8026 instructions, when they are available. The default is
8027 @option{-mfused-madd}.
8028
8029 When multiply-accumulate instructions are used, the intermediate
8030 product is calculated to infinite precision and is not subject to
8031 the FCSR Flush to Zero bit. This may be undesirable in some
8032 circumstances.
8033
8034 @item -nocpp
8035 @opindex nocpp
8036 Tell the MIPS assembler to not run its preprocessor over user
8037 assembler files (with a @samp{.s} suffix) when assembling them.
8038
8039 @item -mfix-r4000
8040 @itemx -mno-fix-r4000
8041 @opindex mfix-r4000
8042 @opindex mno-fix-r4000
8043 Work around certain R4000 CPU errata:
8044 @itemize @minus
8045 @item
8046 A double-word or a variable shift may give an incorrect result if executed
8047 immediately after starting an integer division.
8048 @item
8049 A double-word or a variable shift may give an incorrect result if executed
8050 while an integer multiplication is in progress.
8051 @end itemize
8052
8053 @item -mfix-sb1
8054 @itemx -mno-fix-sb1
8055 @opindex mfix-sb1
8056 Work around certain SB-1 CPU core errata.
8057 (This flag currently works around the SB-1 revision 2
8058 ``F1'' and ``F2'' floating point errata.)
8059
8060 @item -mflush-func=@var{func}
8061 @itemx -mno-flush-func
8062 @opindex mflush-func
8063 Specifies the function to call to flush the I and D caches, or to not
8064 call any such function. If called, the function must take the same
8065 arguments as the common @code{_flush_func()}, that is, the address of the
8066 memory range for which the cache is being flushed, the size of the
8067 memory range, and the number 3 (to flush both caches). The default
8068 depends on the target gcc was configured for, but commonly is either
8069 @samp{_flush_func} or @samp{__cpu_flush}.
8070
8071 @item -mbranch-likely
8072 @itemx -mno-branch-likely
8073 @opindex mbranch-likely
8074 @opindex mno-branch-likely
8075 Enable or disable use of Branch Likely instructions, regardless of the
8076 default for the selected architecture. By default, Branch Likely
8077 instructions may be generated if they are supported by the selected
8078 architecture. An exception is for the MIPS32 and MIPS64 architectures
8079 and processors which implement those architectures; for those, Branch
8080 Likely instructions will not be generated by default because the MIPS32
8081 and MIPS64 architectures specifically deprecate their use.
8082 @end table
8083
8084 @node i386 and x86-64 Options
8085 @subsection Intel 386 and AMD x86-64 Options
8086 @cindex i386 Options
8087 @cindex x86-64 Options
8088 @cindex Intel 386 Options
8089 @cindex AMD x86-64 Options
8090
8091 These @samp{-m} options are defined for the i386 and x86-64 family of
8092 computers:
8093
8094 @table @gcctabopt
8095 @item -mtune=@var{cpu-type}
8096 @opindex mtune
8097 Tune to @var{cpu-type} everything applicable about the generated code, except
8098 for the ABI and the set of available instructions. The choices for
8099 @var{cpu-type} are:
8100 @table @emph
8101 @item i386
8102 Original Intel's i386 CPU.
8103 @item i486
8104 Intel's i486 CPU. (No scheduling is implemented for this chip.)
8105 @item i586, pentium
8106 Intel Pentium CPU with no MMX support.
8107 @item pentium-mmx
8108 Intel PentiumMMX CPU based on Pentium core with MMX instruction set support.
8109 @item i686, pentiumpro
8110 Intel PentiumPro CPU.
8111 @item pentium2
8112 Intel Pentium2 CPU based on PentiumPro core with MMX instruction set support.
8113 @item pentium3, pentium3m
8114 Intel Pentium3 CPU based on PentiumPro core with MMX and SSE instruction set
8115 support.
8116 @item pentium-m
8117 Low power version of Intel Pentium3 CPU with MMX, SSE and SSE2 instruction set
8118 support. Used by Centrino notebooks.
8119 @item pentium4, pentium4m
8120 Intel Pentium4 CPU with MMX, SSE and SSE2 instruction set support.
8121 @item prescott
8122 Improved version of Intel Pentium4 CPU with MMX, SSE, SSE2 and SSE3 instruction
8123 set support.
8124 @item nocona
8125 Improved version of Intel Pentium4 CPU with 64-bit extensions, MMX, SSE,
8126 SSE2 and SSE3 instruction set support.
8127 @item k6
8128 AMD K6 CPU with MMX instruction set support.
8129 @item k6-2, k6-3
8130 Improved versions of AMD K6 CPU with MMX and 3dNOW! instruction set support.
8131 @item athlon, athlon-tbird
8132 AMD Athlon CPU with MMX, 3dNOW!, enhanced 3dNOW! and SSE prefetch instructions
8133 support.
8134 @item athlon-4, athlon-xp, athlon-mp
8135 Improved AMD Athlon CPU with MMX, 3dNOW!, enhanced 3dNOW! and full SSE
8136 instruction set support.
8137 @item k8, opteron, athlon64, athlon-fx
8138 AMD K8 core based CPUs with x86-64 instruction set support. (This supersets
8139 MMX, SSE, SSE2, 3dNOW!, enhanced 3dNOW! and 64-bit instruction set extensions.)
8140 @item winchip-c6
8141 IDT Winchip C6 CPU, dealt in same way as i486 with additional MMX instruction
8142 set support.
8143 @item winchip2
8144 IDT Winchip2 CPU, dealt in same way as i486 with additional MMX and 3dNOW!
8145 instruction set support.
8146 @item c3
8147 Via C3 CPU with MMX and 3dNOW! instruction set support. (No scheduling is
8148 implemented for this chip.)
8149 @item c3-2
8150 Via C3-2 CPU with MMX and SSE instruction set support. (No scheduling is
8151 implemented for this chip.)
8152 @end table
8153
8154 While picking a specific @var{cpu-type} will schedule things appropriately
8155 for that particular chip, the compiler will not generate any code that
8156 does not run on the i386 without the @option{-march=@var{cpu-type}} option
8157 being used.
8158
8159 @item -march=@var{cpu-type}
8160 @opindex march
8161 Generate instructions for the machine type @var{cpu-type}. The choices
8162 for @var{cpu-type} are the same as for @option{-mtune}. Moreover,
8163 specifying @option{-march=@var{cpu-type}} implies @option{-mtune=@var{cpu-type}}.
8164
8165 @item -mcpu=@var{cpu-type}
8166 @opindex mcpu
8167 A deprecated synonym for @option{-mtune}.
8168
8169 @item -m386
8170 @itemx -m486
8171 @itemx -mpentium
8172 @itemx -mpentiumpro
8173 @opindex m386
8174 @opindex m486
8175 @opindex mpentium
8176 @opindex mpentiumpro
8177 These options are synonyms for @option{-mtune=i386}, @option{-mtune=i486},
8178 @option{-mtune=pentium}, and @option{-mtune=pentiumpro} respectively.
8179 These synonyms are deprecated.
8180
8181 @item -mfpmath=@var{unit}
8182 @opindex march
8183 Generate floating point arithmetics for selected unit @var{unit}. The choices
8184 for @var{unit} are:
8185
8186 @table @samp
8187 @item 387
8188 Use the standard 387 floating point coprocessor present majority of chips and
8189 emulated otherwise. Code compiled with this option will run almost everywhere.
8190 The temporary results are computed in 80bit precision instead of precision
8191 specified by the type resulting in slightly different results compared to most
8192 of other chips. See @option{-ffloat-store} for more detailed description.
8193
8194 This is the default choice for i386 compiler.
8195
8196 @item sse
8197 Use scalar floating point instructions present in the SSE instruction set.
8198 This instruction set is supported by Pentium3 and newer chips, in the AMD line
8199 by Athlon-4, Athlon-xp and Athlon-mp chips. The earlier version of SSE
8200 instruction set supports only single precision arithmetics, thus the double and
8201 extended precision arithmetics is still done using 387. Later version, present
8202 only in Pentium4 and the future AMD x86-64 chips supports double precision
8203 arithmetics too.
8204
8205 For i387 you need to use @option{-march=@var{cpu-type}}, @option{-msse} or
8206 @option{-msse2} switches to enable SSE extensions and make this option
8207 effective. For x86-64 compiler, these extensions are enabled by default.
8208
8209 The resulting code should be considerably faster in the majority of cases and avoid
8210 the numerical instability problems of 387 code, but may break some existing
8211 code that expects temporaries to be 80bit.
8212
8213 This is the default choice for the x86-64 compiler.
8214
8215 @item sse,387
8216 Attempt to utilize both instruction sets at once. This effectively double the
8217 amount of available registers and on chips with separate execution units for
8218 387 and SSE the execution resources too. Use this option with care, as it is
8219 still experimental, because the gcc register allocator does not model separate
8220 functional units well resulting in instable performance.
8221 @end table
8222
8223 @item -masm=@var{dialect}
8224 @opindex masm=@var{dialect}
8225 Output asm instructions using selected @var{dialect}. Supported choices are
8226 @samp{intel} or @samp{att} (the default one).
8227
8228 @item -mieee-fp
8229 @itemx -mno-ieee-fp
8230 @opindex mieee-fp
8231 @opindex mno-ieee-fp
8232 Control whether or not the compiler uses IEEE floating point
8233 comparisons. These handle correctly the case where the result of a
8234 comparison is unordered.
8235
8236 @item -msoft-float
8237 @opindex msoft-float
8238 Generate output containing library calls for floating point.
8239 @strong{Warning:} the requisite libraries are not part of GCC@.
8240 Normally the facilities of the machine's usual C compiler are used, but
8241 this can't be done directly in cross-compilation. You must make your
8242 own arrangements to provide suitable library functions for
8243 cross-compilation.
8244
8245 On machines where a function returns floating point results in the 80387
8246 register stack, some floating point opcodes may be emitted even if
8247 @option{-msoft-float} is used.
8248
8249 @item -mno-fp-ret-in-387
8250 @opindex mno-fp-ret-in-387
8251 Do not use the FPU registers for return values of functions.
8252
8253 The usual calling convention has functions return values of types
8254 @code{float} and @code{double} in an FPU register, even if there
8255 is no FPU@. The idea is that the operating system should emulate
8256 an FPU@.
8257
8258 The option @option{-mno-fp-ret-in-387} causes such values to be returned
8259 in ordinary CPU registers instead.
8260
8261 @item -mno-fancy-math-387
8262 @opindex mno-fancy-math-387
8263 Some 387 emulators do not support the @code{sin}, @code{cos} and
8264 @code{sqrt} instructions for the 387. Specify this option to avoid
8265 generating those instructions. This option is the default on FreeBSD,
8266 OpenBSD and NetBSD@. This option is overridden when @option{-march}
8267 indicates that the target cpu will always have an FPU and so the
8268 instruction will not need emulation. As of revision 2.6.1, these
8269 instructions are not generated unless you also use the
8270 @option{-funsafe-math-optimizations} switch.
8271
8272 @item -malign-double
8273 @itemx -mno-align-double
8274 @opindex malign-double
8275 @opindex mno-align-double
8276 Control whether GCC aligns @code{double}, @code{long double}, and
8277 @code{long long} variables on a two word boundary or a one word
8278 boundary. Aligning @code{double} variables on a two word boundary will
8279 produce code that runs somewhat faster on a @samp{Pentium} at the
8280 expense of more memory.
8281
8282 @strong{Warning:} if you use the @option{-malign-double} switch,
8283 structures containing the above types will be aligned differently than
8284 the published application binary interface specifications for the 386
8285 and will not be binary compatible with structures in code compiled
8286 without that switch.
8287
8288 @item -m96bit-long-double
8289 @itemx -m128bit-long-double
8290 @opindex m96bit-long-double
8291 @opindex m128bit-long-double
8292 These switches control the size of @code{long double} type. The i386
8293 application binary interface specifies the size to be 96 bits,
8294 so @option{-m96bit-long-double} is the default in 32 bit mode.
8295
8296 Modern architectures (Pentium and newer) would prefer @code{long double}
8297 to be aligned to an 8 or 16 byte boundary. In arrays or structures
8298 conforming to the ABI, this would not be possible. So specifying a
8299 @option{-m128bit-long-double} will align @code{long double}
8300 to a 16 byte boundary by padding the @code{long double} with an additional
8301 32 bit zero.
8302
8303 In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
8304 its ABI specifies that @code{long double} is to be aligned on 16 byte boundary.
8305
8306 Notice that neither of these options enable any extra precision over the x87
8307 standard of 80 bits for a @code{long double}.
8308
8309 @strong{Warning:} if you override the default value for your target ABI, the
8310 structures and arrays containing @code{long double} variables will change
8311 their size as well as function calling convention for function taking
8312 @code{long double} will be modified. Hence they will not be binary
8313 compatible with arrays or structures in code compiled without that switch.
8314
8315
8316 @item -msvr3-shlib
8317 @itemx -mno-svr3-shlib
8318 @opindex msvr3-shlib
8319 @opindex mno-svr3-shlib
8320 Control whether GCC places uninitialized local variables into the
8321 @code{bss} or @code{data} segments. @option{-msvr3-shlib} places them
8322 into @code{bss}. These options are meaningful only on System V Release 3.
8323
8324 @item -mrtd
8325 @opindex mrtd
8326 Use a different function-calling convention, in which functions that
8327 take a fixed number of arguments return with the @code{ret} @var{num}
8328 instruction, which pops their arguments while returning. This saves one
8329 instruction in the caller since there is no need to pop the arguments
8330 there.
8331
8332 You can specify that an individual function is called with this calling
8333 sequence with the function attribute @samp{stdcall}. You can also
8334 override the @option{-mrtd} option by using the function attribute
8335 @samp{cdecl}. @xref{Function Attributes}.
8336
8337 @strong{Warning:} this calling convention is incompatible with the one
8338 normally used on Unix, so you cannot use it if you need to call
8339 libraries compiled with the Unix compiler.
8340
8341 Also, you must provide function prototypes for all functions that
8342 take variable numbers of arguments (including @code{printf});
8343 otherwise incorrect code will be generated for calls to those
8344 functions.
8345
8346 In addition, seriously incorrect code will result if you call a
8347 function with too many arguments. (Normally, extra arguments are
8348 harmlessly ignored.)
8349
8350 @item -mregparm=@var{num}
8351 @opindex mregparm
8352 Control how many registers are used to pass integer arguments. By
8353 default, no registers are used to pass arguments, and at most 3
8354 registers can be used. You can control this behavior for a specific
8355 function by using the function attribute @samp{regparm}.
8356 @xref{Function Attributes}.
8357
8358 @strong{Warning:} if you use this switch, and
8359 @var{num} is nonzero, then you must build all modules with the same
8360 value, including any libraries. This includes the system libraries and
8361 startup modules.
8362
8363 @item -mpreferred-stack-boundary=@var{num}
8364 @opindex mpreferred-stack-boundary
8365 Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
8366 byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
8367 the default is 4 (16 bytes or 128 bits), except when optimizing for code
8368 size (@option{-Os}), in which case the default is the minimum correct
8369 alignment (4 bytes for x86, and 8 bytes for x86-64).
8370
8371 On Pentium and PentiumPro, @code{double} and @code{long double} values
8372 should be aligned to an 8 byte boundary (see @option{-malign-double}) or
8373 suffer significant run time performance penalties. On Pentium III, the
8374 Streaming SIMD Extension (SSE) data type @code{__m128} suffers similar
8375 penalties if it is not 16 byte aligned.
8376
8377 To ensure proper alignment of this values on the stack, the stack boundary
8378 must be as aligned as that required by any value stored on the stack.
8379 Further, every function must be generated such that it keeps the stack
8380 aligned. Thus calling a function compiled with a higher preferred
8381 stack boundary from a function compiled with a lower preferred stack
8382 boundary will most likely misalign the stack. It is recommended that
8383 libraries that use callbacks always use the default setting.
8384
8385 This extra alignment does consume extra stack space, and generally
8386 increases code size. Code that is sensitive to stack space usage, such
8387 as embedded systems and operating system kernels, may want to reduce the
8388 preferred alignment to @option{-mpreferred-stack-boundary=2}.
8389
8390 @item -mmmx
8391 @itemx -mno-mmx
8392 @item -msse
8393 @itemx -mno-sse
8394 @item -msse2
8395 @itemx -mno-sse2
8396 @item -msse3
8397 @itemx -mno-sse3
8398 @item -m3dnow
8399 @itemx -mno-3dnow
8400 @opindex mmmx
8401 @opindex mno-mmx
8402 @opindex msse
8403 @opindex mno-sse
8404 @opindex m3dnow
8405 @opindex mno-3dnow
8406 These switches enable or disable the use of built-in functions that allow
8407 direct access to the MMX, SSE, SSE2, SSE3 and 3Dnow extensions of the
8408 instruction set.
8409
8410 @xref{X86 Built-in Functions}, for details of the functions enabled
8411 and disabled by these switches.
8412
8413 To have SSE/SSE2 instructions generated automatically from floating-point
8414 code, see @option{-mfpmath=sse}.
8415
8416 @item -mpush-args
8417 @itemx -mno-push-args
8418 @opindex mpush-args
8419 @opindex mno-push-args
8420 Use PUSH operations to store outgoing parameters. This method is shorter
8421 and usually equally fast as method using SUB/MOV operations and is enabled
8422 by default. In some cases disabling it may improve performance because of
8423 improved scheduling and reduced dependencies.
8424
8425 @item -maccumulate-outgoing-args
8426 @opindex maccumulate-outgoing-args
8427 If enabled, the maximum amount of space required for outgoing arguments will be
8428 computed in the function prologue. This is faster on most modern CPUs
8429 because of reduced dependencies, improved scheduling and reduced stack usage
8430 when preferred stack boundary is not equal to 2. The drawback is a notable
8431 increase in code size. This switch implies @option{-mno-push-args}.
8432
8433 @item -mthreads
8434 @opindex mthreads
8435 Support thread-safe exception handling on @samp{Mingw32}. Code that relies
8436 on thread-safe exception handling must compile and link all code with the
8437 @option{-mthreads} option. When compiling, @option{-mthreads} defines
8438 @option{-D_MT}; when linking, it links in a special thread helper library
8439 @option{-lmingwthrd} which cleans up per thread exception handling data.
8440
8441 @item -mno-align-stringops
8442 @opindex mno-align-stringops
8443 Do not align destination of inlined string operations. This switch reduces
8444 code size and improves performance in case the destination is already aligned,
8445 but gcc don't know about it.
8446
8447 @item -minline-all-stringops
8448 @opindex minline-all-stringops
8449 By default GCC inlines string operations only when destination is known to be
8450 aligned at least to 4 byte boundary. This enables more inlining, increase code
8451 size, but may improve performance of code that depends on fast memcpy, strlen
8452 and memset for short lengths.
8453
8454 @item -momit-leaf-frame-pointer
8455 @opindex momit-leaf-frame-pointer
8456 Don't keep the frame pointer in a register for leaf functions. This
8457 avoids the instructions to save, set up and restore frame pointers and
8458 makes an extra register available in leaf functions. The option
8459 @option{-fomit-frame-pointer} removes the frame pointer for all functions
8460 which might make debugging harder.
8461
8462 @item -mtls-direct-seg-refs
8463 @itemx -mno-tls-direct-seg-refs
8464 @opindex mtls-direct-seg-refs
8465 Controls whether TLS variables may be accessed with offsets from the
8466 TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
8467 or whether the thread base pointer must be added. Whether or not this
8468 is legal depends on the operating system, and whether it maps the
8469 segment to cover the entire TLS area.
8470
8471 For systems that use GNU libc, the default is on.
8472 @end table
8473
8474 These @samp{-m} switches are supported in addition to the above
8475 on AMD x86-64 processors in 64-bit environments.
8476
8477 @table @gcctabopt
8478 @item -m32
8479 @itemx -m64
8480 @opindex m32
8481 @opindex m64
8482 Generate code for a 32-bit or 64-bit environment.
8483 The 32-bit environment sets int, long and pointer to 32 bits and
8484 generates code that runs on any i386 system.
8485 The 64-bit environment sets int to 32 bits and long and pointer
8486 to 64 bits and generates code for AMD's x86-64 architecture.
8487
8488 @item -mno-red-zone
8489 @opindex no-red-zone
8490 Do not use a so called red zone for x86-64 code. The red zone is mandated
8491 by the x86-64 ABI, it is a 128-byte area beyond the location of the
8492 stack pointer that will not be modified by signal or interrupt handlers
8493 and therefore can be used for temporary data without adjusting the stack
8494 pointer. The flag @option{-mno-red-zone} disables this red zone.
8495
8496 @item -mcmodel=small
8497 @opindex mcmodel=small
8498 Generate code for the small code model: the program and its symbols must
8499 be linked in the lower 2 GB of the address space. Pointers are 64 bits.
8500 Programs can be statically or dynamically linked. This is the default
8501 code model.
8502
8503 @item -mcmodel=kernel
8504 @opindex mcmodel=kernel
8505 Generate code for the kernel code model. The kernel runs in the
8506 negative 2 GB of the address space.
8507 This model has to be used for Linux kernel code.
8508
8509 @item -mcmodel=medium
8510 @opindex mcmodel=medium
8511 Generate code for the medium model: The program is linked in the lower 2
8512 GB of the address space but symbols can be located anywhere in the
8513 address space. Programs can be statically or dynamically linked, but
8514 building of shared libraries are not supported with the medium model.
8515
8516 @item -mcmodel=large
8517 @opindex mcmodel=large
8518 Generate code for the large model: This model makes no assumptions
8519 about addresses and sizes of sections. Currently GCC does not implement
8520 this model.
8521 @end table
8522
8523 @node HPPA Options
8524 @subsection HPPA Options
8525 @cindex HPPA Options
8526
8527 These @samp{-m} options are defined for the HPPA family of computers:
8528
8529 @table @gcctabopt
8530 @item -march=@var{architecture-type}
8531 @opindex march
8532 Generate code for the specified architecture. The choices for
8533 @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
8534 1.1, and @samp{2.0} for PA 2.0 processors. Refer to
8535 @file{/usr/lib/sched.models} on an HP-UX system to determine the proper
8536 architecture option for your machine. Code compiled for lower numbered
8537 architectures will run on higher numbered architectures, but not the
8538 other way around.
8539
8540 PA 2.0 support currently requires gas snapshot 19990413 or later. The
8541 next release of binutils (current is 2.9.1) will probably contain PA 2.0
8542 support.
8543
8544 @item -mpa-risc-1-0
8545 @itemx -mpa-risc-1-1
8546 @itemx -mpa-risc-2-0
8547 @opindex mpa-risc-1-0
8548 @opindex mpa-risc-1-1
8549 @opindex mpa-risc-2-0
8550 Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
8551
8552 @item -mbig-switch
8553 @opindex mbig-switch
8554 Generate code suitable for big switch tables. Use this option only if
8555 the assembler/linker complain about out of range branches within a switch
8556 table.
8557
8558 @item -mjump-in-delay
8559 @opindex mjump-in-delay
8560 Fill delay slots of function calls with unconditional jump instructions
8561 by modifying the return pointer for the function call to be the target
8562 of the conditional jump.
8563
8564 @item -mdisable-fpregs
8565 @opindex mdisable-fpregs
8566 Prevent floating point registers from being used in any manner. This is
8567 necessary for compiling kernels which perform lazy context switching of
8568 floating point registers. If you use this option and attempt to perform
8569 floating point operations, the compiler will abort.
8570
8571 @item -mdisable-indexing
8572 @opindex mdisable-indexing
8573 Prevent the compiler from using indexing address modes. This avoids some
8574 rather obscure problems when compiling MIG generated code under MACH@.
8575
8576 @item -mno-space-regs
8577 @opindex mno-space-regs
8578 Generate code that assumes the target has no space registers. This allows
8579 GCC to generate faster indirect calls and use unscaled index address modes.
8580
8581 Such code is suitable for level 0 PA systems and kernels.
8582
8583 @item -mfast-indirect-calls
8584 @opindex mfast-indirect-calls
8585 Generate code that assumes calls never cross space boundaries. This
8586 allows GCC to emit code which performs faster indirect calls.
8587
8588 This option will not work in the presence of shared libraries or nested
8589 functions.
8590
8591 @item -mlong-load-store
8592 @opindex mlong-load-store
8593 Generate 3-instruction load and store sequences as sometimes required by
8594 the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
8595 the HP compilers.
8596
8597 @item -mportable-runtime
8598 @opindex mportable-runtime
8599 Use the portable calling conventions proposed by HP for ELF systems.
8600
8601 @item -mgas
8602 @opindex mgas
8603 Enable the use of assembler directives only GAS understands.
8604
8605 @item -mschedule=@var{cpu-type}
8606 @opindex mschedule
8607 Schedule code according to the constraints for the machine type
8608 @var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
8609 @samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
8610 to @file{/usr/lib/sched.models} on an HP-UX system to determine the
8611 proper scheduling option for your machine. The default scheduling is
8612 @samp{8000}.
8613
8614 @item -mlinker-opt
8615 @opindex mlinker-opt
8616 Enable the optimization pass in the HP-UX linker. Note this makes symbolic
8617 debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
8618 linkers in which they give bogus error messages when linking some programs.
8619
8620 @item -msoft-float
8621 @opindex msoft-float
8622 Generate output containing library calls for floating point.
8623 @strong{Warning:} the requisite libraries are not available for all HPPA
8624 targets. Normally the facilities of the machine's usual C compiler are
8625 used, but this cannot be done directly in cross-compilation. You must make
8626 your own arrangements to provide suitable library functions for
8627 cross-compilation. The embedded target @samp{hppa1.1-*-pro}
8628 does provide software floating point support.
8629
8630 @option{-msoft-float} changes the calling convention in the output file;
8631 therefore, it is only useful if you compile @emph{all} of a program with
8632 this option. In particular, you need to compile @file{libgcc.a}, the
8633 library that comes with GCC, with @option{-msoft-float} in order for
8634 this to work.
8635
8636 @item -msio
8637 @opindex msio
8638 Generate the predefine, @code{_SIO}, for server IO. The default is
8639 @option{-mwsio}. This generates the predefines, @code{__hp9000s700},
8640 @code{__hp9000s700__} and @code{_WSIO}, for workstation IO. These
8641 options are available under HP-UX and HI-UX.
8642
8643 @item -mgnu-ld
8644 @opindex gnu-ld
8645 Use GNU ld specific options. This passes @option{-shared} to ld when
8646 building a shared library. It is the default when GCC is configured,
8647 explicitly or implicitly, with the GNU linker. This option does not
8648 have any affect on which ld is called, it only changes what parameters
8649 are passed to that ld. The ld that is called is determined by the
8650 @option{--with-ld} configure option, gcc's program search path, and
8651 finally by the user's @env{PATH}. The linker used by GCC can be printed
8652 using @samp{which `gcc -print-prog-name=ld`}.
8653
8654 @item -mhp-ld
8655 @opindex hp-ld
8656 Use HP ld specific options. This passes @option{-b} to ld when building
8657 a shared library and passes @option{+Accept TypeMismatch} to ld on all
8658 links. It is the default when GCC is configured, explicitly or
8659 implicitly, with the HP linker. This option does not have any affect on
8660 which ld is called, it only changes what parameters are passed to that
8661 ld. The ld that is called is determined by the @option{--with-ld}
8662 configure option, gcc's program search path, and finally by the user's
8663 @env{PATH}. The linker used by GCC can be printed using @samp{which
8664 `gcc -print-prog-name=ld`}.
8665
8666 @item -mfdpic
8667 @opindex mfdpic
8668
8669 Select the FDPIC ABI, that uses function descriptors to represent
8670 pointers to functions. Without any PIC/PIE-related options, it
8671 implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
8672 assumes GOT entries and small data are within a 12-bit range from the
8673 GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
8674 are computed with 32 bits.
8675
8676 @item -minline-plt
8677 @opindex minline-plt
8678
8679 Enable inlining of PLT entries in function calls to functions that are
8680 not known to bind locally. It has no effect without @option{-mfdpic}.
8681 It's enabled by default if optimizing for speed and compiling for
8682 shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
8683 optimization option such as @option{-O3} or above is present in the
8684 command line.
8685
8686 @item -mgprel-ro
8687 @opindex mgprel-ro
8688
8689 Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
8690 that is known to be in read-only sections. It's enabled by default,
8691 except for @option{-fpic} or @option{-fpie}: even though it may help
8692 make the global offset table smaller, it trades 1 instruction for 4.
8693 With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
8694 one of which may be shared by multiple symbols, and it avoids the need
8695 for a GOT entry for the referenced symbol, so it's more likely to be a
8696 win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
8697
8698 @item -multilib-library-pic
8699 @opindex multilib-library-pic
8700
8701 Link with the (library, not FD) pic libraries. It's implied by
8702 @option{-mlibrary-pic}, as well as by @option{-fPIC} and
8703 @option{-fpic} without @option{-mfdpic}. You should never have to use
8704 it explicitly.
8705
8706 @item -mlinked-fp
8707 @opindex mlinked-fp
8708
8709 Follow the EABI requirement of always creating a frame pointer whenever
8710 a stack frame is allocated. This option is enabled by default and can
8711 be disabled with @option{-mno-linked-fp}.
8712
8713 @item -mlong-calls
8714 @opindex mno-long-calls
8715 Generate code that uses long call sequences. This ensures that a call
8716 is always able to reach linker generated stubs. The default is to generate
8717 long calls only when the distance from the call site to the beginning
8718 of the function or translation unit, as the case may be, exceeds a
8719 predefined limit set by the branch type being used. The limits for
8720 normal calls are 7,600,000 and 240,000 bytes, respectively for the
8721 PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
8722 240,000 bytes.
8723
8724 Distances are measured from the beginning of functions when using the
8725 @option{-ffunction-sections} option, or when using the @option{-mgas}
8726 and @option{-mno-portable-runtime} options together under HP-UX with
8727 the SOM linker.
8728
8729 It is normally not desirable to use this option as it will degrade
8730 performance. However, it may be useful in large applications,
8731 particularly when partial linking is used to build the application.
8732
8733 The types of long calls used depends on the capabilities of the
8734 assembler and linker, and the type of code being generated. The
8735 impact on systems that support long absolute calls, and long pic
8736 symbol-difference or pc-relative calls should be relatively small.
8737 However, an indirect call is used on 32-bit ELF systems in pic code
8738 and it is quite long.
8739
8740 @item -nolibdld
8741 @opindex nolibdld
8742 Suppress the generation of link options to search libdld.sl when the
8743 @option{-static} option is specified on HP-UX 10 and later.
8744
8745 @item -static
8746 @opindex static
8747 The HP-UX implementation of setlocale in libc has a dependency on
8748 libdld.sl. There isn't an archive version of libdld.sl. Thus,
8749 when the @option{-static} option is specified, special link options
8750 are needed to resolve this dependency.
8751
8752 On HP-UX 10 and later, the GCC driver adds the necessary options to
8753 link with libdld.sl when the @option{-static} option is specified.
8754 This causes the resulting binary to be dynamic. On the 64-bit port,
8755 the linkers generate dynamic binaries by default in any case. The
8756 @option{-nolibdld} option can be used to prevent the GCC driver from
8757 adding these link options.
8758
8759 @item -threads
8760 @opindex threads
8761 Add support for multithreading with the @dfn{dce thread} library
8762 under HP-UX. This option sets flags for both the preprocessor and
8763 linker.
8764 @end table
8765
8766 @node DEC Alpha Options
8767 @subsection DEC Alpha Options
8768
8769 These @samp{-m} options are defined for the DEC Alpha implementations:
8770
8771 @table @gcctabopt
8772 @item -mno-soft-float
8773 @itemx -msoft-float
8774 @opindex mno-soft-float
8775 @opindex msoft-float
8776 Use (do not use) the hardware floating-point instructions for
8777 floating-point operations. When @option{-msoft-float} is specified,
8778 functions in @file{libgcc.a} will be used to perform floating-point
8779 operations. Unless they are replaced by routines that emulate the
8780 floating-point operations, or compiled in such a way as to call such
8781 emulations routines, these routines will issue floating-point
8782 operations. If you are compiling for an Alpha without floating-point
8783 operations, you must ensure that the library is built so as not to call
8784 them.
8785
8786 Note that Alpha implementations without floating-point operations are
8787 required to have floating-point registers.
8788
8789 @item -mfp-reg
8790 @itemx -mno-fp-regs
8791 @opindex mfp-reg
8792 @opindex mno-fp-regs
8793 Generate code that uses (does not use) the floating-point register set.
8794 @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
8795 register set is not used, floating point operands are passed in integer
8796 registers as if they were integers and floating-point results are passed
8797 in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
8798 so any function with a floating-point argument or return value called by code
8799 compiled with @option{-mno-fp-regs} must also be compiled with that
8800 option.
8801
8802 A typical use of this option is building a kernel that does not use,
8803 and hence need not save and restore, any floating-point registers.
8804
8805 @item -mieee
8806 @opindex mieee
8807 The Alpha architecture implements floating-point hardware optimized for
8808 maximum performance. It is mostly compliant with the IEEE floating
8809 point standard. However, for full compliance, software assistance is
8810 required. This option generates code fully IEEE compliant code
8811 @emph{except} that the @var{inexact-flag} is not maintained (see below).
8812 If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
8813 defined during compilation. The resulting code is less efficient but is
8814 able to correctly support denormalized numbers and exceptional IEEE
8815 values such as not-a-number and plus/minus infinity. Other Alpha
8816 compilers call this option @option{-ieee_with_no_inexact}.
8817
8818 @item -mieee-with-inexact
8819 @opindex mieee-with-inexact
8820 This is like @option{-mieee} except the generated code also maintains
8821 the IEEE @var{inexact-flag}. Turning on this option causes the
8822 generated code to implement fully-compliant IEEE math. In addition to
8823 @code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
8824 macro. On some Alpha implementations the resulting code may execute
8825 significantly slower than the code generated by default. Since there is
8826 very little code that depends on the @var{inexact-flag}, you should
8827 normally not specify this option. Other Alpha compilers call this
8828 option @option{-ieee_with_inexact}.
8829
8830 @item -mfp-trap-mode=@var{trap-mode}
8831 @opindex mfp-trap-mode
8832 This option controls what floating-point related traps are enabled.
8833 Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
8834 The trap mode can be set to one of four values:
8835
8836 @table @samp
8837 @item n
8838 This is the default (normal) setting. The only traps that are enabled
8839 are the ones that cannot be disabled in software (e.g., division by zero
8840 trap).
8841
8842 @item u
8843 In addition to the traps enabled by @samp{n}, underflow traps are enabled
8844 as well.
8845
8846 @item su
8847 Like @samp{su}, but the instructions are marked to be safe for software
8848 completion (see Alpha architecture manual for details).
8849
8850 @item sui
8851 Like @samp{su}, but inexact traps are enabled as well.
8852 @end table
8853
8854 @item -mfp-rounding-mode=@var{rounding-mode}
8855 @opindex mfp-rounding-mode
8856 Selects the IEEE rounding mode. Other Alpha compilers call this option
8857 @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
8858 of:
8859
8860 @table @samp
8861 @item n
8862 Normal IEEE rounding mode. Floating point numbers are rounded towards
8863 the nearest machine number or towards the even machine number in case
8864 of a tie.
8865
8866 @item m
8867 Round towards minus infinity.
8868
8869 @item c
8870 Chopped rounding mode. Floating point numbers are rounded towards zero.
8871
8872 @item d
8873 Dynamic rounding mode. A field in the floating point control register
8874 (@var{fpcr}, see Alpha architecture reference manual) controls the
8875 rounding mode in effect. The C library initializes this register for
8876 rounding towards plus infinity. Thus, unless your program modifies the
8877 @var{fpcr}, @samp{d} corresponds to round towards plus infinity.
8878 @end table
8879
8880 @item -mtrap-precision=@var{trap-precision}
8881 @opindex mtrap-precision
8882 In the Alpha architecture, floating point traps are imprecise. This
8883 means without software assistance it is impossible to recover from a
8884 floating trap and program execution normally needs to be terminated.
8885 GCC can generate code that can assist operating system trap handlers
8886 in determining the exact location that caused a floating point trap.
8887 Depending on the requirements of an application, different levels of
8888 precisions can be selected:
8889
8890 @table @samp
8891 @item p
8892 Program precision. This option is the default and means a trap handler
8893 can only identify which program caused a floating point exception.
8894
8895 @item f
8896 Function precision. The trap handler can determine the function that
8897 caused a floating point exception.
8898
8899 @item i
8900 Instruction precision. The trap handler can determine the exact
8901 instruction that caused a floating point exception.
8902 @end table
8903
8904 Other Alpha compilers provide the equivalent options called
8905 @option{-scope_safe} and @option{-resumption_safe}.
8906
8907 @item -mieee-conformant
8908 @opindex mieee-conformant
8909 This option marks the generated code as IEEE conformant. You must not
8910 use this option unless you also specify @option{-mtrap-precision=i} and either
8911 @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
8912 is to emit the line @samp{.eflag 48} in the function prologue of the
8913 generated assembly file. Under DEC Unix, this has the effect that
8914 IEEE-conformant math library routines will be linked in.
8915
8916 @item -mbuild-constants
8917 @opindex mbuild-constants
8918 Normally GCC examines a 32- or 64-bit integer constant to
8919 see if it can construct it from smaller constants in two or three
8920 instructions. If it cannot, it will output the constant as a literal and
8921 generate code to load it from the data segment at runtime.
8922
8923 Use this option to require GCC to construct @emph{all} integer constants
8924 using code, even if it takes more instructions (the maximum is six).
8925
8926 You would typically use this option to build a shared library dynamic
8927 loader. Itself a shared library, it must relocate itself in memory
8928 before it can find the variables and constants in its own data segment.
8929
8930 @item -malpha-as
8931 @itemx -mgas
8932 @opindex malpha-as
8933 @opindex mgas
8934 Select whether to generate code to be assembled by the vendor-supplied
8935 assembler (@option{-malpha-as}) or by the GNU assembler @option{-mgas}.
8936
8937 @item -mbwx
8938 @itemx -mno-bwx
8939 @itemx -mcix
8940 @itemx -mno-cix
8941 @itemx -mfix
8942 @itemx -mno-fix
8943 @itemx -mmax
8944 @itemx -mno-max
8945 @opindex mbwx
8946 @opindex mno-bwx
8947 @opindex mcix
8948 @opindex mno-cix
8949 @opindex mfix
8950 @opindex mno-fix
8951 @opindex mmax
8952 @opindex mno-max
8953 Indicate whether GCC should generate code to use the optional BWX,
8954 CIX, FIX and MAX instruction sets. The default is to use the instruction
8955 sets supported by the CPU type specified via @option{-mcpu=} option or that
8956 of the CPU on which GCC was built if none was specified.
8957
8958 @item -mfloat-vax
8959 @itemx -mfloat-ieee
8960 @opindex mfloat-vax
8961 @opindex mfloat-ieee
8962 Generate code that uses (does not use) VAX F and G floating point
8963 arithmetic instead of IEEE single and double precision.
8964
8965 @item -mexplicit-relocs
8966 @itemx -mno-explicit-relocs
8967 @opindex mexplicit-relocs
8968 @opindex mno-explicit-relocs
8969 Older Alpha assemblers provided no way to generate symbol relocations
8970 except via assembler macros. Use of these macros does not allow
8971 optimal instruction scheduling. GNU binutils as of version 2.12
8972 supports a new syntax that allows the compiler to explicitly mark
8973 which relocations should apply to which instructions. This option
8974 is mostly useful for debugging, as GCC detects the capabilities of
8975 the assembler when it is built and sets the default accordingly.
8976
8977 @item -msmall-data
8978 @itemx -mlarge-data
8979 @opindex msmall-data
8980 @opindex mlarge-data
8981 When @option{-mexplicit-relocs} is in effect, static data is
8982 accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
8983 is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
8984 (the @code{.sdata} and @code{.sbss} sections) and are accessed via
8985 16-bit relocations off of the @code{$gp} register. This limits the
8986 size of the small data area to 64KB, but allows the variables to be
8987 directly accessed via a single instruction.
8988
8989 The default is @option{-mlarge-data}. With this option the data area
8990 is limited to just below 2GB. Programs that require more than 2GB of
8991 data must use @code{malloc} or @code{mmap} to allocate the data in the
8992 heap instead of in the program's data segment.
8993
8994 When generating code for shared libraries, @option{-fpic} implies
8995 @option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
8996
8997 @item -msmall-text
8998 @itemx -mlarge-text
8999 @opindex msmall-text
9000 @opindex mlarge-text
9001 When @option{-msmall-text} is used, the compiler assumes that the
9002 code of the entire program (or shared library) fits in 4MB, and is
9003 thus reachable with a branch instruction. When @option{-msmall-data}
9004 is used, the compiler can assume that all local symbols share the
9005 same @code{$gp} value, and thus reduce the number of instructions
9006 required for a function call from 4 to 1.
9007
9008 The default is @option{-mlarge-text}.
9009
9010 @item -mcpu=@var{cpu_type}
9011 @opindex mcpu
9012 Set the instruction set and instruction scheduling parameters for
9013 machine type @var{cpu_type}. You can specify either the @samp{EV}
9014 style name or the corresponding chip number. GCC supports scheduling
9015 parameters for the EV4, EV5 and EV6 family of processors and will
9016 choose the default values for the instruction set from the processor
9017 you specify. If you do not specify a processor type, GCC will default
9018 to the processor on which the compiler was built.
9019
9020 Supported values for @var{cpu_type} are
9021
9022 @table @samp
9023 @item ev4
9024 @itemx ev45
9025 @itemx 21064
9026 Schedules as an EV4 and has no instruction set extensions.
9027
9028 @item ev5
9029 @itemx 21164
9030 Schedules as an EV5 and has no instruction set extensions.
9031
9032 @item ev56
9033 @itemx 21164a
9034 Schedules as an EV5 and supports the BWX extension.
9035
9036 @item pca56
9037 @itemx 21164pc
9038 @itemx 21164PC
9039 Schedules as an EV5 and supports the BWX and MAX extensions.
9040
9041 @item ev6
9042 @itemx 21264
9043 Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
9044
9045 @item ev67
9046 @itemx 21264a
9047 Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
9048 @end table
9049
9050 @item -mtune=@var{cpu_type}
9051 @opindex mtune
9052 Set only the instruction scheduling parameters for machine type
9053 @var{cpu_type}. The instruction set is not changed.
9054
9055 @item -mmemory-latency=@var{time}
9056 @opindex mmemory-latency
9057 Sets the latency the scheduler should assume for typical memory
9058 references as seen by the application. This number is highly
9059 dependent on the memory access patterns used by the application
9060 and the size of the external cache on the machine.
9061
9062 Valid options for @var{time} are
9063
9064 @table @samp
9065 @item @var{number}
9066 A decimal number representing clock cycles.
9067
9068 @item L1
9069 @itemx L2
9070 @itemx L3
9071 @itemx main
9072 The compiler contains estimates of the number of clock cycles for
9073 ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
9074 (also called Dcache, Scache, and Bcache), as well as to main memory.
9075 Note that L3 is only valid for EV5.
9076
9077 @end table
9078 @end table
9079
9080 @node DEC Alpha/VMS Options
9081 @subsection DEC Alpha/VMS Options
9082
9083 These @samp{-m} options are defined for the DEC Alpha/VMS implementations:
9084
9085 @table @gcctabopt
9086 @item -mvms-return-codes
9087 @opindex mvms-return-codes
9088 Return VMS condition codes from main. The default is to return POSIX
9089 style condition (e.g.@ error) codes.
9090 @end table
9091
9092 @node H8/300 Options
9093 @subsection H8/300 Options
9094
9095 These @samp{-m} options are defined for the H8/300 implementations:
9096
9097 @table @gcctabopt
9098 @item -mrelax
9099 @opindex mrelax
9100 Shorten some address references at link time, when possible; uses the
9101 linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
9102 ld, Using ld}, for a fuller description.
9103
9104 @item -mh
9105 @opindex mh
9106 Generate code for the H8/300H@.
9107
9108 @item -ms
9109 @opindex ms
9110 Generate code for the H8S@.
9111
9112 @item -mn
9113 @opindex mn
9114 Generate code for the H8S and H8/300H in the normal mode. This switch
9115 must be used either with -mh or -ms.
9116
9117 @item -ms2600
9118 @opindex ms2600
9119 Generate code for the H8S/2600. This switch must be used with @option{-ms}.
9120
9121 @item -mint32
9122 @opindex mint32
9123 Make @code{int} data 32 bits by default.
9124
9125 @item -malign-300
9126 @opindex malign-300
9127 On the H8/300H and H8S, use the same alignment rules as for the H8/300.
9128 The default for the H8/300H and H8S is to align longs and floats on 4
9129 byte boundaries.
9130 @option{-malign-300} causes them to be aligned on 2 byte boundaries.
9131 This option has no effect on the H8/300.
9132 @end table
9133
9134 @node SH Options
9135 @subsection SH Options
9136
9137 These @samp{-m} options are defined for the SH implementations:
9138
9139 @table @gcctabopt
9140 @item -m1
9141 @opindex m1
9142 Generate code for the SH1.
9143
9144 @item -m2
9145 @opindex m2
9146 Generate code for the SH2.
9147
9148 @item -m2e
9149 Generate code for the SH2e.
9150
9151 @item -m3
9152 @opindex m3
9153 Generate code for the SH3.
9154
9155 @item -m3e
9156 @opindex m3e
9157 Generate code for the SH3e.
9158
9159 @item -m4-nofpu
9160 @opindex m4-nofpu
9161 Generate code for the SH4 without a floating-point unit.
9162
9163 @item -m4-single-only
9164 @opindex m4-single-only
9165 Generate code for the SH4 with a floating-point unit that only
9166 supports single-precision arithmetic.
9167
9168 @item -m4-single
9169 @opindex m4-single
9170 Generate code for the SH4 assuming the floating-point unit is in
9171 single-precision mode by default.
9172
9173 @item -m4
9174 @opindex m4
9175 Generate code for the SH4.
9176
9177 @item -mb
9178 @opindex mb
9179 Compile code for the processor in big endian mode.
9180
9181 @item -ml
9182 @opindex ml
9183 Compile code for the processor in little endian mode.
9184
9185 @item -mdalign
9186 @opindex mdalign
9187 Align doubles at 64-bit boundaries. Note that this changes the calling
9188 conventions, and thus some functions from the standard C library will
9189 not work unless you recompile it first with @option{-mdalign}.
9190
9191 @item -mrelax
9192 @opindex mrelax
9193 Shorten some address references at link time, when possible; uses the
9194 linker option @option{-relax}.
9195
9196 @item -mbigtable
9197 @opindex mbigtable
9198 Use 32-bit offsets in @code{switch} tables. The default is to use
9199 16-bit offsets.
9200
9201 @item -mfmovd
9202 @opindex mfmovd
9203 Enable the use of the instruction @code{fmovd}.
9204
9205 @item -mhitachi
9206 @opindex mhitachi
9207 Comply with the calling conventions defined by Renesas.
9208
9209 @item -mnomacsave
9210 @opindex mnomacsave
9211 Mark the @code{MAC} register as call-clobbered, even if
9212 @option{-mhitachi} is given.
9213
9214 @item -mieee
9215 @opindex mieee
9216 Increase IEEE-compliance of floating-point code.
9217
9218 @item -misize
9219 @opindex misize
9220 Dump instruction size and location in the assembly code.
9221
9222 @item -mpadstruct
9223 @opindex mpadstruct
9224 This option is deprecated. It pads structures to multiple of 4 bytes,
9225 which is incompatible with the SH ABI@.
9226
9227 @item -mspace
9228 @opindex mspace
9229 Optimize for space instead of speed. Implied by @option{-Os}.
9230
9231 @item -mprefergot
9232 @opindex mprefergot
9233 When generating position-independent code, emit function calls using
9234 the Global Offset Table instead of the Procedure Linkage Table.
9235
9236 @item -musermode
9237 @opindex musermode
9238 Generate a library function call to invalidate instruction cache
9239 entries, after fixing up a trampoline. This library function call
9240 doesn't assume it can write to the whole memory address space. This
9241 is the default when the target is @code{sh-*-linux*}.
9242 @end table
9243
9244 @node System V Options
9245 @subsection Options for System V
9246
9247 These additional options are available on System V Release 4 for
9248 compatibility with other compilers on those systems:
9249
9250 @table @gcctabopt
9251 @item -G
9252 @opindex G
9253 Create a shared object.
9254 It is recommended that @option{-symbolic} or @option{-shared} be used instead.
9255
9256 @item -Qy
9257 @opindex Qy
9258 Identify the versions of each tool used by the compiler, in a
9259 @code{.ident} assembler directive in the output.
9260
9261 @item -Qn
9262 @opindex Qn
9263 Refrain from adding @code{.ident} directives to the output file (this is
9264 the default).
9265
9266 @item -YP,@var{dirs}
9267 @opindex YP
9268 Search the directories @var{dirs}, and no others, for libraries
9269 specified with @option{-l}.
9270
9271 @item -Ym,@var{dir}
9272 @opindex Ym
9273 Look in the directory @var{dir} to find the M4 preprocessor.
9274 The assembler uses this option.
9275 @c This is supposed to go with a -Yd for predefined M4 macro files, but
9276 @c the generic assembler that comes with Solaris takes just -Ym.
9277 @end table
9278
9279 @node TMS320C3x/C4x Options
9280 @subsection TMS320C3x/C4x Options
9281 @cindex TMS320C3x/C4x Options
9282
9283 These @samp{-m} options are defined for TMS320C3x/C4x implementations:
9284
9285 @table @gcctabopt
9286
9287 @item -mcpu=@var{cpu_type}
9288 @opindex mcpu
9289 Set the instruction set, register set, and instruction scheduling
9290 parameters for machine type @var{cpu_type}. Supported values for
9291 @var{cpu_type} are @samp{c30}, @samp{c31}, @samp{c32}, @samp{c40}, and
9292 @samp{c44}. The default is @samp{c40} to generate code for the
9293 TMS320C40.
9294
9295 @item -mbig-memory
9296 @itemx -mbig
9297 @itemx -msmall-memory
9298 @itemx -msmall
9299 @opindex mbig-memory
9300 @opindex mbig
9301 @opindex msmall-memory
9302 @opindex msmall
9303 Generates code for the big or small memory model. The small memory
9304 model assumed that all data fits into one 64K word page. At run-time
9305 the data page (DP) register must be set to point to the 64K page
9306 containing the .bss and .data program sections. The big memory model is
9307 the default and requires reloading of the DP register for every direct
9308 memory access.
9309
9310 @item -mbk
9311 @itemx -mno-bk
9312 @opindex mbk
9313 @opindex mno-bk
9314 Allow (disallow) allocation of general integer operands into the block
9315 count register BK@.
9316
9317 @item -mdb
9318 @itemx -mno-db
9319 @opindex mdb
9320 @opindex mno-db
9321 Enable (disable) generation of code using decrement and branch,
9322 DBcond(D), instructions. This is enabled by default for the C4x. To be
9323 on the safe side, this is disabled for the C3x, since the maximum
9324 iteration count on the C3x is @math{2^{23} + 1} (but who iterates loops more than
9325 @math{2^{23}} times on the C3x?). Note that GCC will try to reverse a loop so
9326 that it can utilize the decrement and branch instruction, but will give
9327 up if there is more than one memory reference in the loop. Thus a loop
9328 where the loop counter is decremented can generate slightly more
9329 efficient code, in cases where the RPTB instruction cannot be utilized.
9330
9331 @item -mdp-isr-reload
9332 @itemx -mparanoid
9333 @opindex mdp-isr-reload
9334 @opindex mparanoid
9335 Force the DP register to be saved on entry to an interrupt service
9336 routine (ISR), reloaded to point to the data section, and restored on
9337 exit from the ISR@. This should not be required unless someone has
9338 violated the small memory model by modifying the DP register, say within
9339 an object library.
9340
9341 @item -mmpyi
9342 @itemx -mno-mpyi
9343 @opindex mmpyi
9344 @opindex mno-mpyi
9345 For the C3x use the 24-bit MPYI instruction for integer multiplies
9346 instead of a library call to guarantee 32-bit results. Note that if one
9347 of the operands is a constant, then the multiplication will be performed
9348 using shifts and adds. If the @option{-mmpyi} option is not specified for the C3x,
9349 then squaring operations are performed inline instead of a library call.
9350
9351 @item -mfast-fix
9352 @itemx -mno-fast-fix
9353 @opindex mfast-fix
9354 @opindex mno-fast-fix
9355 The C3x/C4x FIX instruction to convert a floating point value to an
9356 integer value chooses the nearest integer less than or equal to the
9357 floating point value rather than to the nearest integer. Thus if the
9358 floating point number is negative, the result will be incorrectly
9359 truncated an additional code is necessary to detect and correct this
9360 case. This option can be used to disable generation of the additional
9361 code required to correct the result.
9362
9363 @item -mrptb
9364 @itemx -mno-rptb
9365 @opindex mrptb
9366 @opindex mno-rptb
9367 Enable (disable) generation of repeat block sequences using the RPTB
9368 instruction for zero overhead looping. The RPTB construct is only used
9369 for innermost loops that do not call functions or jump across the loop
9370 boundaries. There is no advantage having nested RPTB loops due to the
9371 overhead required to save and restore the RC, RS, and RE registers.
9372 This is enabled by default with @option{-O2}.
9373
9374 @item -mrpts=@var{count}
9375 @itemx -mno-rpts
9376 @opindex mrpts
9377 @opindex mno-rpts
9378 Enable (disable) the use of the single instruction repeat instruction
9379 RPTS@. If a repeat block contains a single instruction, and the loop
9380 count can be guaranteed to be less than the value @var{count}, GCC will
9381 emit a RPTS instruction instead of a RPTB@. If no value is specified,
9382 then a RPTS will be emitted even if the loop count cannot be determined
9383 at compile time. Note that the repeated instruction following RPTS does
9384 not have to be reloaded from memory each iteration, thus freeing up the
9385 CPU buses for operands. However, since interrupts are blocked by this
9386 instruction, it is disabled by default.
9387
9388 @item -mloop-unsigned
9389 @itemx -mno-loop-unsigned
9390 @opindex mloop-unsigned
9391 @opindex mno-loop-unsigned
9392 The maximum iteration count when using RPTS and RPTB (and DB on the C40)
9393 is @math{2^{31} + 1} since these instructions test if the iteration count is
9394 negative to terminate the loop. If the iteration count is unsigned
9395 there is a possibility than the @math{2^{31} + 1} maximum iteration count may be
9396 exceeded. This switch allows an unsigned iteration count.
9397
9398 @item -mti
9399 @opindex mti
9400 Try to emit an assembler syntax that the TI assembler (asm30) is happy
9401 with. This also enforces compatibility with the API employed by the TI
9402 C3x C compiler. For example, long doubles are passed as structures
9403 rather than in floating point registers.
9404
9405 @item -mregparm
9406 @itemx -mmemparm
9407 @opindex mregparm
9408 @opindex mmemparm
9409 Generate code that uses registers (stack) for passing arguments to functions.
9410 By default, arguments are passed in registers where possible rather
9411 than by pushing arguments on to the stack.
9412
9413 @item -mparallel-insns
9414 @itemx -mno-parallel-insns
9415 @opindex mparallel-insns
9416 @opindex mno-parallel-insns
9417 Allow the generation of parallel instructions. This is enabled by
9418 default with @option{-O2}.
9419
9420 @item -mparallel-mpy
9421 @itemx -mno-parallel-mpy
9422 @opindex mparallel-mpy
9423 @opindex mno-parallel-mpy
9424 Allow the generation of MPY||ADD and MPY||SUB parallel instructions,
9425 provided @option{-mparallel-insns} is also specified. These instructions have
9426 tight register constraints which can pessimize the code generation
9427 of large functions.
9428
9429 @end table
9430
9431 @node V850 Options
9432 @subsection V850 Options
9433 @cindex V850 Options
9434
9435 These @samp{-m} options are defined for V850 implementations:
9436
9437 @table @gcctabopt
9438 @item -mlong-calls
9439 @itemx -mno-long-calls
9440 @opindex mlong-calls
9441 @opindex mno-long-calls
9442 Treat all calls as being far away (near). If calls are assumed to be
9443 far away, the compiler will always load the functions address up into a
9444 register, and call indirect through the pointer.
9445
9446 @item -mno-ep
9447 @itemx -mep
9448 @opindex mno-ep
9449 @opindex mep
9450 Do not optimize (do optimize) basic blocks that use the same index
9451 pointer 4 or more times to copy pointer into the @code{ep} register, and
9452 use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
9453 option is on by default if you optimize.
9454
9455 @item -mno-prolog-function
9456 @itemx -mprolog-function
9457 @opindex mno-prolog-function
9458 @opindex mprolog-function
9459 Do not use (do use) external functions to save and restore registers
9460 at the prologue and epilogue of a function. The external functions
9461 are slower, but use less code space if more than one function saves
9462 the same number of registers. The @option{-mprolog-function} option
9463 is on by default if you optimize.
9464
9465 @item -mspace
9466 @opindex mspace
9467 Try to make the code as small as possible. At present, this just turns
9468 on the @option{-mep} and @option{-mprolog-function} options.
9469
9470 @item -mtda=@var{n}
9471 @opindex mtda
9472 Put static or global variables whose size is @var{n} bytes or less into
9473 the tiny data area that register @code{ep} points to. The tiny data
9474 area can hold up to 256 bytes in total (128 bytes for byte references).
9475
9476 @item -msda=@var{n}
9477 @opindex msda
9478 Put static or global variables whose size is @var{n} bytes or less into
9479 the small data area that register @code{gp} points to. The small data
9480 area can hold up to 64 kilobytes.
9481
9482 @item -mzda=@var{n}
9483 @opindex mzda
9484 Put static or global variables whose size is @var{n} bytes or less into
9485 the first 32 kilobytes of memory.
9486
9487 @item -mv850
9488 @opindex mv850
9489 Specify that the target processor is the V850.
9490
9491 @item -mbig-switch
9492 @opindex mbig-switch
9493 Generate code suitable for big switch tables. Use this option only if
9494 the assembler/linker complain about out of range branches within a switch
9495 table.
9496
9497 @item -mapp-regs
9498 @opindex mapp-regs
9499 This option will cause r2 and r5 to be used in the code generated by
9500 the compiler. This setting is the default.
9501
9502 @item -mno-app-regs
9503 @opindex mno-app-regs
9504 This option will cause r2 and r5 to be treated as fixed registers.
9505
9506 @item -mv850e1
9507 @opindex mv850e1
9508 Specify that the target processor is the V850E1. The preprocessor
9509 constants @samp{__v850e1__} and @samp{__v850e__} will be defined if
9510 this option is used.
9511
9512 @item -mv850e
9513 @opindex mv850e
9514 Specify that the target processor is the V850E. The preprocessor
9515 constant @samp{__v850e__} will be defined if this option is used.
9516
9517 If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
9518 are defined then a default target processor will be chosen and the
9519 relevant @samp{__v850*__} preprocessor constant will be defined.
9520
9521 The preprocessor constants @samp{__v850} and @samp{__v851__} are always
9522 defined, regardless of which processor variant is the target.
9523
9524 @item -mdisable-callt
9525 @opindex mdisable-callt
9526 This option will suppress generation of the CALLT instruction for the
9527 v850e and v850e1 flavors of the v850 architecture. The default is
9528 @option{-mno-disable-callt} which allows the CALLT instruction to be used.
9529
9530 @end table
9531
9532 @node ARC Options
9533 @subsection ARC Options
9534 @cindex ARC Options
9535
9536 These options are defined for ARC implementations:
9537
9538 @table @gcctabopt
9539 @item -EL
9540 @opindex EL
9541 Compile code for little endian mode. This is the default.
9542
9543 @item -EB
9544 @opindex EB
9545 Compile code for big endian mode.
9546
9547 @item -mmangle-cpu
9548 @opindex mmangle-cpu
9549 Prepend the name of the cpu to all public symbol names.
9550 In multiple-processor systems, there are many ARC variants with different
9551 instruction and register set characteristics. This flag prevents code
9552 compiled for one cpu to be linked with code compiled for another.
9553 No facility exists for handling variants that are ``almost identical''.
9554 This is an all or nothing option.
9555
9556 @item -mcpu=@var{cpu}
9557 @opindex mcpu
9558 Compile code for ARC variant @var{cpu}.
9559 Which variants are supported depend on the configuration.
9560 All variants support @option{-mcpu=base}, this is the default.
9561
9562 @item -mtext=@var{text-section}
9563 @itemx -mdata=@var{data-section}
9564 @itemx -mrodata=@var{readonly-data-section}
9565 @opindex mtext
9566 @opindex mdata
9567 @opindex mrodata
9568 Put functions, data, and readonly data in @var{text-section},
9569 @var{data-section}, and @var{readonly-data-section} respectively
9570 by default. This can be overridden with the @code{section} attribute.
9571 @xref{Variable Attributes}.
9572
9573 @end table
9574
9575 @node NS32K Options
9576 @subsection NS32K Options
9577 @cindex NS32K options
9578
9579 These are the @samp{-m} options defined for the 32000 series. The default
9580 values for these options depends on which style of 32000 was selected when
9581 the compiler was configured; the defaults for the most common choices are
9582 given below.
9583
9584 @table @gcctabopt
9585 @item -m32032
9586 @itemx -m32032
9587 @opindex m32032
9588 @opindex m32032
9589 Generate output for a 32032. This is the default
9590 when the compiler is configured for 32032 and 32016 based systems.
9591
9592 @item -m32332
9593 @itemx -m32332
9594 @opindex m32332
9595 @opindex m32332
9596 Generate output for a 32332. This is the default
9597 when the compiler is configured for 32332-based systems.
9598
9599 @item -m32532
9600 @itemx -m32532
9601 @opindex m32532
9602 @opindex m32532
9603 Generate output for a 32532. This is the default
9604 when the compiler is configured for 32532-based systems.
9605
9606 @item -m32081
9607 @opindex m32081
9608 Generate output containing 32081 instructions for floating point.
9609 This is the default for all systems.
9610
9611 @item -m32381
9612 @opindex m32381
9613 Generate output containing 32381 instructions for floating point. This
9614 also implies @option{-m32081}. The 32381 is only compatible with the 32332
9615 and 32532 cpus. This is the default for the pc532-netbsd configuration.
9616
9617 @item -mmulti-add
9618 @opindex mmulti-add
9619 Try and generate multiply-add floating point instructions @code{polyF}
9620 and @code{dotF}. This option is only available if the @option{-m32381}
9621 option is in effect. Using these instructions requires changes to
9622 register allocation which generally has a negative impact on
9623 performance. This option should only be enabled when compiling code
9624 particularly likely to make heavy use of multiply-add instructions.
9625
9626 @item -mnomulti-add
9627 @opindex mnomulti-add
9628 Do not try and generate multiply-add floating point instructions
9629 @code{polyF} and @code{dotF}. This is the default on all platforms.
9630
9631 @item -msoft-float
9632 @opindex msoft-float
9633 Generate output containing library calls for floating point.
9634 @strong{Warning:} the requisite libraries may not be available.
9635
9636 @item -mieee-compare
9637 @itemx -mno-ieee-compare
9638 @opindex mieee-compare
9639 @opindex mno-ieee-compare
9640 Control whether or not the compiler uses IEEE floating point
9641 comparisons. These handle correctly the case where the result of a
9642 comparison is unordered.
9643 @strong{Warning:} the requisite kernel support may not be available.
9644
9645 @item -mnobitfield
9646 @opindex mnobitfield
9647 Do not use the bit-field instructions. On some machines it is faster to
9648 use shifting and masking operations. This is the default for the pc532.
9649
9650 @item -mbitfield
9651 @opindex mbitfield
9652 Do use the bit-field instructions. This is the default for all platforms
9653 except the pc532.
9654
9655 @item -mrtd
9656 @opindex mrtd
9657 Use a different function-calling convention, in which functions
9658 that take a fixed number of arguments return pop their
9659 arguments on return with the @code{ret} instruction.
9660
9661 This calling convention is incompatible with the one normally
9662 used on Unix, so you cannot use it if you need to call libraries
9663 compiled with the Unix compiler.
9664
9665 Also, you must provide function prototypes for all functions that
9666 take variable numbers of arguments (including @code{printf});
9667 otherwise incorrect code will be generated for calls to those
9668 functions.
9669
9670 In addition, seriously incorrect code will result if you call a
9671 function with too many arguments. (Normally, extra arguments are
9672 harmlessly ignored.)
9673
9674 This option takes its name from the 680x0 @code{rtd} instruction.
9675
9676
9677 @item -mregparam
9678 @opindex mregparam
9679 Use a different function-calling convention where the first two arguments
9680 are passed in registers.
9681
9682 This calling convention is incompatible with the one normally
9683 used on Unix, so you cannot use it if you need to call libraries
9684 compiled with the Unix compiler.
9685
9686 @item -mnoregparam
9687 @opindex mnoregparam
9688 Do not pass any arguments in registers. This is the default for all
9689 targets.
9690
9691 @item -msb
9692 @opindex msb
9693 It is OK to use the sb as an index register which is always loaded with
9694 zero. This is the default for the pc532-netbsd target.
9695
9696 @item -mnosb
9697 @opindex mnosb
9698 The sb register is not available for use or has not been initialized to
9699 zero by the run time system. This is the default for all targets except
9700 the pc532-netbsd. It is also implied whenever @option{-mhimem} or
9701 @option{-fpic} is set.
9702
9703 @item -mhimem
9704 @opindex mhimem
9705 Many ns32000 series addressing modes use displacements of up to 512MB@.
9706 If an address is above 512MB then displacements from zero can not be used.
9707 This option causes code to be generated which can be loaded above 512MB@.
9708 This may be useful for operating systems or ROM code.
9709
9710 @item -mnohimem
9711 @opindex mnohimem
9712 Assume code will be loaded in the first 512MB of virtual address space.
9713 This is the default for all platforms.
9714
9715
9716 @end table
9717
9718 @node AVR Options
9719 @subsection AVR Options
9720 @cindex AVR Options
9721
9722 These options are defined for AVR implementations:
9723
9724 @table @gcctabopt
9725 @item -mmcu=@var{mcu}
9726 @opindex mmcu
9727 Specify ATMEL AVR instruction set or MCU type.
9728
9729 Instruction set avr1 is for the minimal AVR core, not supported by the C
9730 compiler, only for assembler programs (MCU types: at90s1200, attiny10,
9731 attiny11, attiny12, attiny15, attiny28).
9732
9733 Instruction set avr2 (default) is for the classic AVR core with up to
9734 8K program memory space (MCU types: at90s2313, at90s2323, attiny22,
9735 at90s2333, at90s2343, at90s4414, at90s4433, at90s4434, at90s8515,
9736 at90c8534, at90s8535).
9737
9738 Instruction set avr3 is for the classic AVR core with up to 128K program
9739 memory space (MCU types: atmega103, atmega603, at43usb320, at76c711).
9740
9741 Instruction set avr4 is for the enhanced AVR core with up to 8K program
9742 memory space (MCU types: atmega8, atmega83, atmega85).
9743
9744 Instruction set avr5 is for the enhanced AVR core with up to 128K program
9745 memory space (MCU types: atmega16, atmega161, atmega163, atmega32, atmega323,
9746 atmega64, atmega128, at43usb355, at94k).
9747
9748 @item -msize
9749 @opindex msize
9750 Output instruction sizes to the asm file.
9751
9752 @item -minit-stack=@var{N}
9753 @opindex minit-stack
9754 Specify the initial stack address, which may be a symbol or numeric value,
9755 @samp{__stack} is the default.
9756
9757 @item -mno-interrupts
9758 @opindex mno-interrupts
9759 Generated code is not compatible with hardware interrupts.
9760 Code size will be smaller.
9761
9762 @item -mcall-prologues
9763 @opindex mcall-prologues
9764 Functions prologues/epilogues expanded as call to appropriate
9765 subroutines. Code size will be smaller.
9766
9767 @item -mno-tablejump
9768 @opindex mno-tablejump
9769 Do not generate tablejump insns which sometimes increase code size.
9770
9771 @item -mtiny-stack
9772 @opindex mtiny-stack
9773 Change only the low 8 bits of the stack pointer.
9774 @end table
9775
9776 @node MCore Options
9777 @subsection MCore Options
9778 @cindex MCore options
9779
9780 These are the @samp{-m} options defined for the Motorola M*Core
9781 processors.
9782
9783 @table @gcctabopt
9784
9785 @item -mhardlit
9786 @itemx -mno-hardlit
9787 @opindex mhardlit
9788 @opindex mno-hardlit
9789 Inline constants into the code stream if it can be done in two
9790 instructions or less.
9791
9792 @item -mdiv
9793 @itemx -mno-div
9794 @opindex mdiv
9795 @opindex mno-div
9796 Use the divide instruction. (Enabled by default).
9797
9798 @item -mrelax-immediate
9799 @itemx -mno-relax-immediate
9800 @opindex mrelax-immediate
9801 @opindex mno-relax-immediate
9802 Allow arbitrary sized immediates in bit operations.
9803
9804 @item -mwide-bitfields
9805 @itemx -mno-wide-bitfields
9806 @opindex mwide-bitfields
9807 @opindex mno-wide-bitfields
9808 Always treat bit-fields as int-sized.
9809
9810 @item -m4byte-functions
9811 @itemx -mno-4byte-functions
9812 @opindex m4byte-functions
9813 @opindex mno-4byte-functions
9814 Force all functions to be aligned to a four byte boundary.
9815
9816 @item -mcallgraph-data
9817 @itemx -mno-callgraph-data
9818 @opindex mcallgraph-data
9819 @opindex mno-callgraph-data
9820 Emit callgraph information.
9821
9822 @item -mslow-bytes
9823 @itemx -mno-slow-bytes
9824 @opindex mslow-bytes
9825 @opindex mno-slow-bytes
9826 Prefer word access when reading byte quantities.
9827
9828 @item -mlittle-endian
9829 @itemx -mbig-endian
9830 @opindex mlittle-endian
9831 @opindex mbig-endian
9832 Generate code for a little endian target.
9833
9834 @item -m210
9835 @itemx -m340
9836 @opindex m210
9837 @opindex m340
9838 Generate code for the 210 processor.
9839 @end table
9840
9841 @node IA-64 Options
9842 @subsection IA-64 Options
9843 @cindex IA-64 Options
9844
9845 These are the @samp{-m} options defined for the Intel IA-64 architecture.
9846
9847 @table @gcctabopt
9848 @item -mbig-endian
9849 @opindex mbig-endian
9850 Generate code for a big endian target. This is the default for HP-UX@.
9851
9852 @item -mlittle-endian
9853 @opindex mlittle-endian
9854 Generate code for a little endian target. This is the default for AIX5
9855 and GNU/Linux.
9856
9857 @item -mgnu-as
9858 @itemx -mno-gnu-as
9859 @opindex mgnu-as
9860 @opindex mno-gnu-as
9861 Generate (or don't) code for the GNU assembler. This is the default.
9862 @c Also, this is the default if the configure option @option{--with-gnu-as}
9863 @c is used.
9864
9865 @item -mgnu-ld
9866 @itemx -mno-gnu-ld
9867 @opindex mgnu-ld
9868 @opindex mno-gnu-ld
9869 Generate (or don't) code for the GNU linker. This is the default.
9870 @c Also, this is the default if the configure option @option{--with-gnu-ld}
9871 @c is used.
9872
9873 @item -mno-pic
9874 @opindex mno-pic
9875 Generate code that does not use a global pointer register. The result
9876 is not position independent code, and violates the IA-64 ABI@.
9877
9878 @item -mvolatile-asm-stop
9879 @itemx -mno-volatile-asm-stop
9880 @opindex mvolatile-asm-stop
9881 @opindex mno-volatile-asm-stop
9882 Generate (or don't) a stop bit immediately before and after volatile asm
9883 statements.
9884
9885 @item -mb-step
9886 @opindex mb-step
9887 Generate code that works around Itanium B step errata.
9888
9889 @item -mregister-names
9890 @itemx -mno-register-names
9891 @opindex mregister-names
9892 @opindex mno-register-names
9893 Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
9894 the stacked registers. This may make assembler output more readable.
9895
9896 @item -mno-sdata
9897 @itemx -msdata
9898 @opindex mno-sdata
9899 @opindex msdata
9900 Disable (or enable) optimizations that use the small data section. This may
9901 be useful for working around optimizer bugs.
9902
9903 @item -mconstant-gp
9904 @opindex mconstant-gp
9905 Generate code that uses a single constant global pointer value. This is
9906 useful when compiling kernel code.
9907
9908 @item -mauto-pic
9909 @opindex mauto-pic
9910 Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
9911 This is useful when compiling firmware code.
9912
9913 @item -minline-float-divide-min-latency
9914 @opindex minline-float-divide-min-latency
9915 Generate code for inline divides of floating point values
9916 using the minimum latency algorithm.
9917
9918 @item -minline-float-divide-max-throughput
9919 @opindex minline-float-divide-max-throughput
9920 Generate code for inline divides of floating point values
9921 using the maximum throughput algorithm.
9922
9923 @item -minline-int-divide-min-latency
9924 @opindex minline-int-divide-min-latency
9925 Generate code for inline divides of integer values
9926 using the minimum latency algorithm.
9927
9928 @item -minline-int-divide-max-throughput
9929 @opindex minline-int-divide-max-throughput
9930 Generate code for inline divides of integer values
9931 using the maximum throughput algorithm.
9932
9933 @item -mno-dwarf2-asm
9934 @itemx -mdwarf2-asm
9935 @opindex mno-dwarf2-asm
9936 @opindex mdwarf2-asm
9937 Don't (or do) generate assembler code for the DWARF2 line number debugging
9938 info. This may be useful when not using the GNU assembler.
9939
9940 @item -mfixed-range=@var{register-range}
9941 @opindex mfixed-range
9942 Generate code treating the given register range as fixed registers.
9943 A fixed register is one that the register allocator can not use. This is
9944 useful when compiling kernel code. A register range is specified as
9945 two registers separated by a dash. Multiple register ranges can be
9946 specified separated by a comma.
9947
9948 @item -mearly-stop-bits
9949 @itemx -mno-early-stop-bits
9950 @opindex mearly-stop-bits
9951 @opindex mno-early-stop-bits
9952 Allow stop bits to be placed earlier than immediately preceding the
9953 instruction that triggered the stop bit. This can improve instruction
9954 scheduling, but does not always do so.
9955 @end table
9956
9957 @node S/390 and zSeries Options
9958 @subsection S/390 and zSeries Options
9959 @cindex S/390 and zSeries Options
9960
9961 These are the @samp{-m} options defined for the S/390 and zSeries architecture.
9962
9963 @table @gcctabopt
9964 @item -mhard-float
9965 @itemx -msoft-float
9966 @opindex mhard-float
9967 @opindex msoft-float
9968 Use (do not use) the hardware floating-point instructions and registers
9969 for floating-point operations. When @option{-msoft-float} is specified,
9970 functions in @file{libgcc.a} will be used to perform floating-point
9971 operations. When @option{-mhard-float} is specified, the compiler
9972 generates IEEE floating-point instructions. This is the default.
9973
9974 @item -mbackchain
9975 @itemx -mno-backchain
9976 @opindex mbackchain
9977 @opindex mno-backchain
9978 Generate (or do not generate) code which maintains an explicit
9979 backchain within the stack frame that points to the caller's frame.
9980 This may be needed to allow debugging using tools that do not understand
9981 DWARF-2 call frame information. The default is not to generate the
9982 backchain.
9983
9984 @item -msmall-exec
9985 @itemx -mno-small-exec
9986 @opindex msmall-exec
9987 @opindex mno-small-exec
9988 Generate (or do not generate) code using the @code{bras} instruction
9989 to do subroutine calls.
9990 This only works reliably if the total executable size does not
9991 exceed 64k. The default is to use the @code{basr} instruction instead,
9992 which does not have this limitation.
9993
9994 @item -m64
9995 @itemx -m31
9996 @opindex m64
9997 @opindex m31
9998 When @option{-m31} is specified, generate code compliant to the
9999 GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
10000 code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
10001 particular to generate 64-bit instructions. For the @samp{s390}
10002 targets, the default is @option{-m31}, while the @samp{s390x}
10003 targets default to @option{-m64}.
10004
10005 @item -mzarch
10006 @itemx -mesa
10007 @opindex mzarch
10008 @opindex mesa
10009 When @option{-mzarch} is specified, generate code using the
10010 instructions available on z/Architecture.
10011 When @option{-mesa} is specified, generate code using the
10012 instructions available on ESA/390. Note that @option{-mesa} is
10013 not possible with @option{-m64}.
10014 When generating code compliant to the GNU/Linux for S/390 ABI,
10015 the default is @option{-mesa}. When generating code compliant
10016 to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
10017
10018 @item -mmvcle
10019 @itemx -mno-mvcle
10020 @opindex mmvcle
10021 @opindex mno-mvcle
10022 Generate (or do not generate) code using the @code{mvcle} instruction
10023 to perform block moves. When @option{-mno-mvcle} is specified,
10024 use a @code{mvc} loop instead. This is the default.
10025
10026 @item -mdebug
10027 @itemx -mno-debug
10028 @opindex mdebug
10029 @opindex mno-debug
10030 Print (or do not print) additional debug information when compiling.
10031 The default is to not print debug information.
10032
10033 @item -march=@var{cpu-type}
10034 @opindex march
10035 Generate code that will run on @var{cpu-type}, which is the name of a system
10036 representing a certain processor type. Possible values for
10037 @var{cpu-type} are @samp{g5}, @samp{g6}, @samp{z900}, and @samp{z990}.
10038 When generating code using the instructions available on z/Architecture,
10039 the default is @option{-march=z900}. Otherwise, the default is
10040 @option{-march=g5}.
10041
10042 @item -mtune=@var{cpu-type}
10043 @opindex mtune
10044 Tune to @var{cpu-type} everything applicable about the generated code,
10045 except for the ABI and the set of available instructions.
10046 The list of @var{cpu-type} values is the same as for @option{-march}.
10047 The default is the value used for @option{-march}.
10048
10049 @item -mfused-madd
10050 @itemx -mno-fused-madd
10051 @opindex mfused-madd
10052 @opindex mno-fused-madd
10053 Generate code that uses (does not use) the floating point multiply and
10054 accumulate instructions. These instructions are generated by default if
10055 hardware floating point is used.
10056 @end table
10057
10058 @node CRIS Options
10059 @subsection CRIS Options
10060 @cindex CRIS Options
10061
10062 These options are defined specifically for the CRIS ports.
10063
10064 @table @gcctabopt
10065 @item -march=@var{architecture-type}
10066 @itemx -mcpu=@var{architecture-type}
10067 @opindex march
10068 @opindex mcpu
10069 Generate code for the specified architecture. The choices for
10070 @var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
10071 respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX.
10072 Default is @samp{v0} except for cris-axis-linux-gnu, where the default is
10073 @samp{v10}.
10074
10075 @item -mtune=@var{architecture-type}
10076 @opindex mtune
10077 Tune to @var{architecture-type} everything applicable about the generated
10078 code, except for the ABI and the set of available instructions. The
10079 choices for @var{architecture-type} are the same as for
10080 @option{-march=@var{architecture-type}}.
10081
10082 @item -mmax-stack-frame=@var{n}
10083 @opindex mmax-stack-frame
10084 Warn when the stack frame of a function exceeds @var{n} bytes.
10085
10086 @item -melinux-stacksize=@var{n}
10087 @opindex melinux-stacksize
10088 Only available with the @samp{cris-axis-aout} target. Arranges for
10089 indications in the program to the kernel loader that the stack of the
10090 program should be set to @var{n} bytes.
10091
10092 @item -metrax4
10093 @itemx -metrax100
10094 @opindex metrax4
10095 @opindex metrax100
10096 The options @option{-metrax4} and @option{-metrax100} are synonyms for
10097 @option{-march=v3} and @option{-march=v8} respectively.
10098
10099 @item -mpdebug
10100 @opindex mpdebug
10101 Enable CRIS-specific verbose debug-related information in the assembly
10102 code. This option also has the effect to turn off the @samp{#NO_APP}
10103 formatted-code indicator to the assembler at the beginning of the
10104 assembly file.
10105
10106 @item -mcc-init
10107 @opindex mcc-init
10108 Do not use condition-code results from previous instruction; always emit
10109 compare and test instructions before use of condition codes.
10110
10111 @item -mno-side-effects
10112 @opindex mno-side-effects
10113 Do not emit instructions with side-effects in addressing modes other than
10114 post-increment.
10115
10116 @item -mstack-align
10117 @itemx -mno-stack-align
10118 @itemx -mdata-align
10119 @itemx -mno-data-align
10120 @itemx -mconst-align
10121 @itemx -mno-const-align
10122 @opindex mstack-align
10123 @opindex mno-stack-align
10124 @opindex mdata-align
10125 @opindex mno-data-align
10126 @opindex mconst-align
10127 @opindex mno-const-align
10128 These options (no-options) arranges (eliminate arrangements) for the
10129 stack-frame, individual data and constants to be aligned for the maximum
10130 single data access size for the chosen CPU model. The default is to
10131 arrange for 32-bit alignment. ABI details such as structure layout are
10132 not affected by these options.
10133
10134 @item -m32-bit
10135 @itemx -m16-bit
10136 @itemx -m8-bit
10137 @opindex m32-bit
10138 @opindex m16-bit
10139 @opindex m8-bit
10140 Similar to the stack- data- and const-align options above, these options
10141 arrange for stack-frame, writable data and constants to all be 32-bit,
10142 16-bit or 8-bit aligned. The default is 32-bit alignment.
10143
10144 @item -mno-prologue-epilogue
10145 @itemx -mprologue-epilogue
10146 @opindex mno-prologue-epilogue
10147 @opindex mprologue-epilogue
10148 With @option{-mno-prologue-epilogue}, the normal function prologue and
10149 epilogue that sets up the stack-frame are omitted and no return
10150 instructions or return sequences are generated in the code. Use this
10151 option only together with visual inspection of the compiled code: no
10152 warnings or errors are generated when call-saved registers must be saved,
10153 or storage for local variable needs to be allocated.
10154
10155 @item -mno-gotplt
10156 @itemx -mgotplt
10157 @opindex mno-gotplt
10158 @opindex mgotplt
10159 With @option{-fpic} and @option{-fPIC}, don't generate (do generate)
10160 instruction sequences that load addresses for functions from the PLT part
10161 of the GOT rather than (traditional on other architectures) calls to the
10162 PLT. The default is @option{-mgotplt}.
10163
10164 @item -maout
10165 @opindex maout
10166 Legacy no-op option only recognized with the cris-axis-aout target.
10167
10168 @item -melf
10169 @opindex melf
10170 Legacy no-op option only recognized with the cris-axis-elf and
10171 cris-axis-linux-gnu targets.
10172
10173 @item -melinux
10174 @opindex melinux
10175 Only recognized with the cris-axis-aout target, where it selects a
10176 GNU/linux-like multilib, include files and instruction set for
10177 @option{-march=v8}.
10178
10179 @item -mlinux
10180 @opindex mlinux
10181 Legacy no-op option only recognized with the cris-axis-linux-gnu target.
10182
10183 @item -sim
10184 @opindex sim
10185 This option, recognized for the cris-axis-aout and cris-axis-elf arranges
10186 to link with input-output functions from a simulator library. Code,
10187 initialized data and zero-initialized data are allocated consecutively.
10188
10189 @item -sim2
10190 @opindex sim2
10191 Like @option{-sim}, but pass linker options to locate initialized data at
10192 0x40000000 and zero-initialized data at 0x80000000.
10193 @end table
10194
10195 @node MMIX Options
10196 @subsection MMIX Options
10197 @cindex MMIX Options
10198
10199 These options are defined for the MMIX:
10200
10201 @table @gcctabopt
10202 @item -mlibfuncs
10203 @itemx -mno-libfuncs
10204 @opindex mlibfuncs
10205 @opindex mno-libfuncs
10206 Specify that intrinsic library functions are being compiled, passing all
10207 values in registers, no matter the size.
10208
10209 @item -mepsilon
10210 @itemx -mno-epsilon
10211 @opindex mepsilon
10212 @opindex mno-epsilon
10213 Generate floating-point comparison instructions that compare with respect
10214 to the @code{rE} epsilon register.
10215
10216 @item -mabi=mmixware
10217 @itemx -mabi=gnu
10218 @opindex mabi-mmixware
10219 @opindex mabi=gnu
10220 Generate code that passes function parameters and return values that (in
10221 the called function) are seen as registers @code{$0} and up, as opposed to
10222 the GNU ABI which uses global registers @code{$231} and up.
10223
10224 @item -mzero-extend
10225 @itemx -mno-zero-extend
10226 @opindex mzero-extend
10227 @opindex mno-zero-extend
10228 When reading data from memory in sizes shorter than 64 bits, use (do not
10229 use) zero-extending load instructions by default, rather than
10230 sign-extending ones.
10231
10232 @item -mknuthdiv
10233 @itemx -mno-knuthdiv
10234 @opindex mknuthdiv
10235 @opindex mno-knuthdiv
10236 Make the result of a division yielding a remainder have the same sign as
10237 the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
10238 remainder follows the sign of the dividend. Both methods are
10239 arithmetically valid, the latter being almost exclusively used.
10240
10241 @item -mtoplevel-symbols
10242 @itemx -mno-toplevel-symbols
10243 @opindex mtoplevel-symbols
10244 @opindex mno-toplevel-symbols
10245 Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
10246 code can be used with the @code{PREFIX} assembly directive.
10247
10248 @item -melf
10249 @opindex melf
10250 Generate an executable in the ELF format, rather than the default
10251 @samp{mmo} format used by the @command{mmix} simulator.
10252
10253 @item -mbranch-predict
10254 @itemx -mno-branch-predict
10255 @opindex mbranch-predict
10256 @opindex mno-branch-predict
10257 Use (do not use) the probable-branch instructions, when static branch
10258 prediction indicates a probable branch.
10259
10260 @item -mbase-addresses
10261 @itemx -mno-base-addresses
10262 @opindex mbase-addresses
10263 @opindex mno-base-addresses
10264 Generate (do not generate) code that uses @emph{base addresses}. Using a
10265 base address automatically generates a request (handled by the assembler
10266 and the linker) for a constant to be set up in a global register. The
10267 register is used for one or more base address requests within the range 0
10268 to 255 from the value held in the register. The generally leads to short
10269 and fast code, but the number of different data items that can be
10270 addressed is limited. This means that a program that uses lots of static
10271 data may require @option{-mno-base-addresses}.
10272
10273 @item -msingle-exit
10274 @itemx -mno-single-exit
10275 @opindex msingle-exit
10276 @opindex mno-single-exit
10277 Force (do not force) generated code to have a single exit point in each
10278 function.
10279 @end table
10280
10281 @node PDP-11 Options
10282 @subsection PDP-11 Options
10283 @cindex PDP-11 Options
10284
10285 These options are defined for the PDP-11:
10286
10287 @table @gcctabopt
10288 @item -mfpu
10289 @opindex mfpu
10290 Use hardware FPP floating point. This is the default. (FIS floating
10291 point on the PDP-11/40 is not supported.)
10292
10293 @item -msoft-float
10294 @opindex msoft-float
10295 Do not use hardware floating point.
10296
10297 @item -mac0
10298 @opindex mac0
10299 Return floating-point results in ac0 (fr0 in Unix assembler syntax).
10300
10301 @item -mno-ac0
10302 @opindex mno-ac0
10303 Return floating-point results in memory. This is the default.
10304
10305 @item -m40
10306 @opindex m40
10307 Generate code for a PDP-11/40.
10308
10309 @item -m45
10310 @opindex m45
10311 Generate code for a PDP-11/45. This is the default.
10312
10313 @item -m10
10314 @opindex m10
10315 Generate code for a PDP-11/10.
10316
10317 @item -mbcopy-builtin
10318 @opindex bcopy-builtin
10319 Use inline @code{movstrhi} patterns for copying memory. This is the
10320 default.
10321
10322 @item -mbcopy
10323 @opindex mbcopy
10324 Do not use inline @code{movstrhi} patterns for copying memory.
10325
10326 @item -mint16
10327 @itemx -mno-int32
10328 @opindex mint16
10329 @opindex mno-int32
10330 Use 16-bit @code{int}. This is the default.
10331
10332 @item -mint32
10333 @itemx -mno-int16
10334 @opindex mint32
10335 @opindex mno-int16
10336 Use 32-bit @code{int}.
10337
10338 @item -mfloat64
10339 @itemx -mno-float32
10340 @opindex mfloat64
10341 @opindex mno-float32
10342 Use 64-bit @code{float}. This is the default.
10343
10344 @item -mfloat32
10345 @itemx -mno-float64
10346 @opindex mfloat32
10347 @opindex mno-float64
10348 Use 32-bit @code{float}.
10349
10350 @item -mabshi
10351 @opindex mabshi
10352 Use @code{abshi2} pattern. This is the default.
10353
10354 @item -mno-abshi
10355 @opindex mno-abshi
10356 Do not use @code{abshi2} pattern.
10357
10358 @item -mbranch-expensive
10359 @opindex mbranch-expensive
10360 Pretend that branches are expensive. This is for experimenting with
10361 code generation only.
10362
10363 @item -mbranch-cheap
10364 @opindex mbranch-cheap
10365 Do not pretend that branches are expensive. This is the default.
10366
10367 @item -msplit
10368 @opindex msplit
10369 Generate code for a system with split I&D.
10370
10371 @item -mno-split
10372 @opindex mno-split
10373 Generate code for a system without split I&D. This is the default.
10374
10375 @item -munix-asm
10376 @opindex munix-asm
10377 Use Unix assembler syntax. This is the default when configured for
10378 @samp{pdp11-*-bsd}.
10379
10380 @item -mdec-asm
10381 @opindex mdec-asm
10382 Use DEC assembler syntax. This is the default when configured for any
10383 PDP-11 target other than @samp{pdp11-*-bsd}.
10384 @end table
10385
10386 @node Xstormy16 Options
10387 @subsection Xstormy16 Options
10388 @cindex Xstormy16 Options
10389
10390 These options are defined for Xstormy16:
10391
10392 @table @gcctabopt
10393 @item -msim
10394 @opindex msim
10395 Choose startup files and linker script suitable for the simulator.
10396 @end table
10397
10398 @node FRV Options
10399 @subsection FRV Options
10400 @cindex FRV Options
10401
10402 @table @gcctabopt
10403 @item -mgpr-32
10404 @opindex mgpr-32
10405
10406 Only use the first 32 general purpose registers.
10407
10408 @item -mgpr-64
10409 @opindex mgpr-64
10410
10411 Use all 64 general purpose registers.
10412
10413 @item -mfpr-32
10414 @opindex mfpr-32
10415
10416 Use only the first 32 floating point registers.
10417
10418 @item -mfpr-64
10419 @opindex mfpr-64
10420
10421 Use all 64 floating point registers
10422
10423 @item -mhard-float
10424 @opindex mhard-float
10425
10426 Use hardware instructions for floating point operations.
10427
10428 @item -msoft-float
10429 @opindex msoft-float
10430
10431 Use library routines for floating point operations.
10432
10433 @item -malloc-cc
10434 @opindex malloc-cc
10435
10436 Dynamically allocate condition code registers.
10437
10438 @item -mfixed-cc
10439 @opindex mfixed-cc
10440
10441 Do not try to dynamically allocate condition code registers, only
10442 use @code{icc0} and @code{fcc0}.
10443
10444 @item -mdword
10445 @opindex mdword
10446
10447 Change ABI to use double word insns.
10448
10449 @item -mno-dword
10450 @opindex mno-dword
10451
10452 Do not use double word instructions.
10453
10454 @item -mdouble
10455 @opindex mdouble
10456
10457 Use floating point double instructions.
10458
10459 @item -mno-double
10460 @opindex mno-double
10461
10462 Do not use floating point double instructions.
10463
10464 @item -mmedia
10465 @opindex mmedia
10466
10467 Use media instructions.
10468
10469 @item -mno-media
10470 @opindex mno-media
10471
10472 Do not use media instructions.
10473
10474 @item -mmuladd
10475 @opindex mmuladd
10476
10477 Use multiply and add/subtract instructions.
10478
10479 @item -mno-muladd
10480 @opindex mno-muladd
10481
10482 Do not use multiply and add/subtract instructions.
10483
10484 @item -mlibrary-pic
10485 @opindex mlibrary-pic
10486
10487 Generate position-independent EABI code.
10488
10489 @item -macc-4
10490 @opindex macc-4
10491
10492 Use only the first four media accumulator registers.
10493
10494 @item -macc-8
10495 @opindex macc-8
10496
10497 Use all eight media accumulator registers.
10498
10499 @item -mpack
10500 @opindex mpack
10501
10502 Pack VLIW instructions.
10503
10504 @item -mno-pack
10505 @opindex mno-pack
10506
10507 Do not pack VLIW instructions.
10508
10509 @item -mno-eflags
10510 @opindex mno-eflags
10511
10512 Do not mark ABI switches in e_flags.
10513
10514 @item -mcond-move
10515 @opindex mcond-move
10516
10517 Enable the use of conditional-move instructions (default).
10518
10519 This switch is mainly for debugging the compiler and will likely be removed
10520 in a future version.
10521
10522 @item -mno-cond-move
10523 @opindex mno-cond-move
10524
10525 Disable the use of conditional-move instructions.
10526
10527 This switch is mainly for debugging the compiler and will likely be removed
10528 in a future version.
10529
10530 @item -mscc
10531 @opindex mscc
10532
10533 Enable the use of conditional set instructions (default).
10534
10535 This switch is mainly for debugging the compiler and will likely be removed
10536 in a future version.
10537
10538 @item -mno-scc
10539 @opindex mno-scc
10540
10541 Disable the use of conditional set instructions.
10542
10543 This switch is mainly for debugging the compiler and will likely be removed
10544 in a future version.
10545
10546 @item -mcond-exec
10547 @opindex mcond-exec
10548
10549 Enable the use of conditional execution (default).
10550
10551 This switch is mainly for debugging the compiler and will likely be removed
10552 in a future version.
10553
10554 @item -mno-cond-exec
10555 @opindex mno-cond-exec
10556
10557 Disable the use of conditional execution.
10558
10559 This switch is mainly for debugging the compiler and will likely be removed
10560 in a future version.
10561
10562 @item -mvliw-branch
10563 @opindex mvliw-branch
10564
10565 Run a pass to pack branches into VLIW instructions (default).
10566
10567 This switch is mainly for debugging the compiler and will likely be removed
10568 in a future version.
10569
10570 @item -mno-vliw-branch
10571 @opindex mno-vliw-branch
10572
10573 Do not run a pass to pack branches into VLIW instructions.
10574
10575 This switch is mainly for debugging the compiler and will likely be removed
10576 in a future version.
10577
10578 @item -mmulti-cond-exec
10579 @opindex mmulti-cond-exec
10580
10581 Enable optimization of @code{&&} and @code{||} in conditional execution
10582 (default).
10583
10584 This switch is mainly for debugging the compiler and will likely be removed
10585 in a future version.
10586
10587 @item -mno-multi-cond-exec
10588 @opindex mno-multi-cond-exec
10589
10590 Disable optimization of @code{&&} and @code{||} in conditional execution.
10591
10592 This switch is mainly for debugging the compiler and will likely be removed
10593 in a future version.
10594
10595 @item -mnested-cond-exec
10596 @opindex mnested-cond-exec
10597
10598 Enable nested conditional execution optimizations (default).
10599
10600 This switch is mainly for debugging the compiler and will likely be removed
10601 in a future version.
10602
10603 @item -mno-nested-cond-exec
10604 @opindex mno-nested-cond-exec
10605
10606 Disable nested conditional execution optimizations.
10607
10608 This switch is mainly for debugging the compiler and will likely be removed
10609 in a future version.
10610
10611 @item -mtomcat-stats
10612 @opindex mtomcat-stats
10613
10614 Cause gas to print out tomcat statistics.
10615
10616 @item -mcpu=@var{cpu}
10617 @opindex mcpu
10618
10619 Select the processor type for which to generate code. Possible values are
10620 @samp{simple}, @samp{tomcat}, @samp{fr500}, @samp{fr400}, @samp{fr300},
10621 @samp{frv}.
10622
10623 @end table
10624
10625 @node Xtensa Options
10626 @subsection Xtensa Options
10627 @cindex Xtensa Options
10628
10629 These options are supported for Xtensa targets:
10630
10631 @table @gcctabopt
10632 @item -mconst16
10633 @itemx -mno-const16
10634 @opindex mconst16
10635 @opindex mno-const16
10636 Enable or disable use of @code{CONST16} instructions for loading
10637 constant values. The @code{CONST16} instruction is currently not a
10638 standard option from Tensilica. When enabled, @code{CONST16}
10639 instructions are always used in place of the standard @code{L32R}
10640 instructions. The use of @code{CONST16} is enabled by default only if
10641 the @code{L32R} instruction is not available.
10642
10643 @item -mfused-madd
10644 @itemx -mno-fused-madd
10645 @opindex mfused-madd
10646 @opindex mno-fused-madd
10647 Enable or disable use of fused multiply/add and multiply/subtract
10648 instructions in the floating-point option. This has no effect if the
10649 floating-point option is not also enabled. Disabling fused multiply/add
10650 and multiply/subtract instructions forces the compiler to use separate
10651 instructions for the multiply and add/subtract operations. This may be
10652 desirable in some cases where strict IEEE 754-compliant results are
10653 required: the fused multiply add/subtract instructions do not round the
10654 intermediate result, thereby producing results with @emph{more} bits of
10655 precision than specified by the IEEE standard. Disabling fused multiply
10656 add/subtract instructions also ensures that the program output is not
10657 sensitive to the compiler's ability to combine multiply and add/subtract
10658 operations.
10659
10660 @item -mtext-section-literals
10661 @itemx -mno-text-section-literals
10662 @opindex mtext-section-literals
10663 @opindex mno-text-section-literals
10664 Control the treatment of literal pools. The default is
10665 @option{-mno-text-section-literals}, which places literals in a separate
10666 section in the output file. This allows the literal pool to be placed
10667 in a data RAM/ROM, and it also allows the linker to combine literal
10668 pools from separate object files to remove redundant literals and
10669 improve code size. With @option{-mtext-section-literals}, the literals
10670 are interspersed in the text section in order to keep them as close as
10671 possible to their references. This may be necessary for large assembly
10672 files.
10673
10674 @item -mtarget-align
10675 @itemx -mno-target-align
10676 @opindex mtarget-align
10677 @opindex mno-target-align
10678 When this option is enabled, GCC instructs the assembler to
10679 automatically align instructions to reduce branch penalties at the
10680 expense of some code density. The assembler attempts to widen density
10681 instructions to align branch targets and the instructions following call
10682 instructions. If there are not enough preceding safe density
10683 instructions to align a target, no widening will be performed. The
10684 default is @option{-mtarget-align}. These options do not affect the
10685 treatment of auto-aligned instructions like @code{LOOP}, which the
10686 assembler will always align, either by widening density instructions or
10687 by inserting no-op instructions.
10688
10689 @item -mlongcalls
10690 @itemx -mno-longcalls
10691 @opindex mlongcalls
10692 @opindex mno-longcalls
10693 When this option is enabled, GCC instructs the assembler to translate
10694 direct calls to indirect calls unless it can determine that the target
10695 of a direct call is in the range allowed by the call instruction. This
10696 translation typically occurs for calls to functions in other source
10697 files. Specifically, the assembler translates a direct @code{CALL}
10698 instruction into an @code{L32R} followed by a @code{CALLX} instruction.
10699 The default is @option{-mno-longcalls}. This option should be used in
10700 programs where the call target can potentially be out of range. This
10701 option is implemented in the assembler, not the compiler, so the
10702 assembly code generated by GCC will still show direct call
10703 instructions---look at the disassembled object code to see the actual
10704 instructions. Note that the assembler will use an indirect call for
10705 every cross-file call, not just those that really will be out of range.
10706 @end table
10707
10708 @node Code Gen Options
10709 @section Options for Code Generation Conventions
10710 @cindex code generation conventions
10711 @cindex options, code generation
10712 @cindex run-time options
10713
10714 These machine-independent options control the interface conventions
10715 used in code generation.
10716
10717 Most of them have both positive and negative forms; the negative form
10718 of @option{-ffoo} would be @option{-fno-foo}. In the table below, only
10719 one of the forms is listed---the one which is not the default. You
10720 can figure out the other form by either removing @samp{no-} or adding
10721 it.
10722
10723 @table @gcctabopt
10724 @item -fbounds-check
10725 @opindex fbounds-check
10726 For front-ends that support it, generate additional code to check that
10727 indices used to access arrays are within the declared range. This is
10728 currently only supported by the Java and Fortran 77 front-ends, where
10729 this option defaults to true and false respectively.
10730
10731 @item -ftrapv
10732 @opindex ftrapv
10733 This option generates traps for signed overflow on addition, subtraction,
10734 multiplication operations.
10735
10736 @item -fwrapv
10737 @opindex fwrapv
10738 This option instructs the compiler to assume that signed arithmetic
10739 overflow of addition, subtraction and multiplication wraps around
10740 using twos-complement representation. This flag enables some optimizations
10741 and disables other. This option is enabled by default for the Java
10742 front-end, as required by the Java language specification.
10743
10744 @item -fexceptions
10745 @opindex fexceptions
10746 Enable exception handling. Generates extra code needed to propagate
10747 exceptions. For some targets, this implies GCC will generate frame
10748 unwind information for all functions, which can produce significant data
10749 size overhead, although it does not affect execution. If you do not
10750 specify this option, GCC will enable it by default for languages like
10751 C++ which normally require exception handling, and disable it for
10752 languages like C that do not normally require it. However, you may need
10753 to enable this option when compiling C code that needs to interoperate
10754 properly with exception handlers written in C++. You may also wish to
10755 disable this option if you are compiling older C++ programs that don't
10756 use exception handling.
10757
10758 @item -fnon-call-exceptions
10759 @opindex fnon-call-exceptions
10760 Generate code that allows trapping instructions to throw exceptions.
10761 Note that this requires platform-specific runtime support that does
10762 not exist everywhere. Moreover, it only allows @emph{trapping}
10763 instructions to throw exceptions, i.e.@: memory references or floating
10764 point instructions. It does not allow exceptions to be thrown from
10765 arbitrary signal handlers such as @code{SIGALRM}.
10766
10767 @item -funwind-tables
10768 @opindex funwind-tables
10769 Similar to @option{-fexceptions}, except that it will just generate any needed
10770 static data, but will not affect the generated code in any other way.
10771 You will normally not enable this option; instead, a language processor
10772 that needs this handling would enable it on your behalf.
10773
10774 @item -fasynchronous-unwind-tables
10775 @opindex funwind-tables
10776 Generate unwind table in dwarf2 format, if supported by target machine. The
10777 table is exact at each instruction boundary, so it can be used for stack
10778 unwinding from asynchronous events (such as debugger or garbage collector).
10779
10780 @item -fpcc-struct-return
10781 @opindex fpcc-struct-return
10782 Return ``short'' @code{struct} and @code{union} values in memory like
10783 longer ones, rather than in registers. This convention is less
10784 efficient, but it has the advantage of allowing intercallability between
10785 GCC-compiled files and files compiled with other compilers, particularly
10786 the Portable C Compiler (pcc).
10787
10788 The precise convention for returning structures in memory depends
10789 on the target configuration macros.
10790
10791 Short structures and unions are those whose size and alignment match
10792 that of some integer type.
10793
10794 @strong{Warning:} code compiled with the @option{-fpcc-struct-return}
10795 switch is not binary compatible with code compiled with the
10796 @option{-freg-struct-return} switch.
10797 Use it to conform to a non-default application binary interface.
10798
10799 @item -freg-struct-return
10800 @opindex freg-struct-return
10801 Return @code{struct} and @code{union} values in registers when possible.
10802 This is more efficient for small structures than
10803 @option{-fpcc-struct-return}.
10804
10805 If you specify neither @option{-fpcc-struct-return} nor
10806 @option{-freg-struct-return}, GCC defaults to whichever convention is
10807 standard for the target. If there is no standard convention, GCC
10808 defaults to @option{-fpcc-struct-return}, except on targets where GCC is
10809 the principal compiler. In those cases, we can choose the standard, and
10810 we chose the more efficient register return alternative.
10811
10812 @strong{Warning:} code compiled with the @option{-freg-struct-return}
10813 switch is not binary compatible with code compiled with the
10814 @option{-fpcc-struct-return} switch.
10815 Use it to conform to a non-default application binary interface.
10816
10817 @item -fshort-enums
10818 @opindex fshort-enums
10819 Allocate to an @code{enum} type only as many bytes as it needs for the
10820 declared range of possible values. Specifically, the @code{enum} type
10821 will be equivalent to the smallest integer type which has enough room.
10822
10823 @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
10824 code that is not binary compatible with code generated without that switch.
10825 Use it to conform to a non-default application binary interface.
10826
10827 @item -fshort-double
10828 @opindex fshort-double
10829 Use the same size for @code{double} as for @code{float}.
10830
10831 @strong{Warning:} the @option{-fshort-double} switch causes GCC to generate
10832 code that is not binary compatible with code generated without that switch.
10833 Use it to conform to a non-default application binary interface.
10834
10835 @item -fshort-wchar
10836 @opindex fshort-wchar
10837 Override the underlying type for @samp{wchar_t} to be @samp{short
10838 unsigned int} instead of the default for the target. This option is
10839 useful for building programs to run under WINE@.
10840
10841 @strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
10842 code that is not binary compatible with code generated without that switch.
10843 Use it to conform to a non-default application binary interface.
10844
10845 @item -fshared-data
10846 @opindex fshared-data
10847 Requests that the data and non-@code{const} variables of this
10848 compilation be shared data rather than private data. The distinction
10849 makes sense only on certain operating systems, where shared data is
10850 shared between processes running the same program, while private data
10851 exists in one copy per process.
10852
10853 @item -fno-common
10854 @opindex fno-common
10855 In C, allocate even uninitialized global variables in the data section of the
10856 object file, rather than generating them as common blocks. This has the
10857 effect that if the same variable is declared (without @code{extern}) in
10858 two different compilations, you will get an error when you link them.
10859 The only reason this might be useful is if you wish to verify that the
10860 program will work on other systems which always work this way.
10861
10862 @item -fno-ident
10863 @opindex fno-ident
10864 Ignore the @samp{#ident} directive.
10865
10866 @item -finhibit-size-directive
10867 @opindex finhibit-size-directive
10868 Don't output a @code{.size} assembler directive, or anything else that
10869 would cause trouble if the function is split in the middle, and the
10870 two halves are placed at locations far apart in memory. This option is
10871 used when compiling @file{crtstuff.c}; you should not need to use it
10872 for anything else.
10873
10874 @item -fverbose-asm
10875 @opindex fverbose-asm
10876 Put extra commentary information in the generated assembly code to
10877 make it more readable. This option is generally only of use to those
10878 who actually need to read the generated assembly code (perhaps while
10879 debugging the compiler itself).
10880
10881 @option{-fno-verbose-asm}, the default, causes the
10882 extra information to be omitted and is useful when comparing two assembler
10883 files.
10884
10885 @item -fpic
10886 @opindex fpic
10887 @cindex global offset table
10888 @cindex PIC
10889 Generate position-independent code (PIC) suitable for use in a shared
10890 library, if supported for the target machine. Such code accesses all
10891 constant addresses through a global offset table (GOT)@. The dynamic
10892 loader resolves the GOT entries when the program starts (the dynamic
10893 loader is not part of GCC; it is part of the operating system). If
10894 the GOT size for the linked executable exceeds a machine-specific
10895 maximum size, you get an error message from the linker indicating that
10896 @option{-fpic} does not work; in that case, recompile with @option{-fPIC}
10897 instead. (These maximums are 8k on the SPARC and 32k
10898 on the m68k and RS/6000. The 386 has no such limit.)
10899
10900 Position-independent code requires special support, and therefore works
10901 only on certain machines. For the 386, GCC supports PIC for System V
10902 but not for the Sun 386i. Code generated for the IBM RS/6000 is always
10903 position-independent.
10904
10905 @item -fPIC
10906 @opindex fPIC
10907 If supported for the target machine, emit position-independent code,
10908 suitable for dynamic linking and avoiding any limit on the size of the
10909 global offset table. This option makes a difference on the m68k
10910 and the SPARC.
10911
10912 Position-independent code requires special support, and therefore works
10913 only on certain machines.
10914
10915 @item -fpie
10916 @itemx -fPIE
10917 @opindex fpie
10918 @opindex fPIE
10919 These options are similar to @option{-fpic} and @option{-fPIC}, but
10920 generated position independent code can be only linked into executables.
10921 Usually these options are used when @option{-pie} GCC option will be
10922 used during linking.
10923
10924 @item -ffixed-@var{reg}
10925 @opindex ffixed
10926 Treat the register named @var{reg} as a fixed register; generated code
10927 should never refer to it (except perhaps as a stack pointer, frame
10928 pointer or in some other fixed role).
10929
10930 @var{reg} must be the name of a register. The register names accepted
10931 are machine-specific and are defined in the @code{REGISTER_NAMES}
10932 macro in the machine description macro file.
10933
10934 This flag does not have a negative form, because it specifies a
10935 three-way choice.
10936
10937 @item -fcall-used-@var{reg}
10938 @opindex fcall-used
10939 Treat the register named @var{reg} as an allocable register that is
10940 clobbered by function calls. It may be allocated for temporaries or
10941 variables that do not live across a call. Functions compiled this way
10942 will not save and restore the register @var{reg}.
10943
10944 It is an error to used this flag with the frame pointer or stack pointer.
10945 Use of this flag for other registers that have fixed pervasive roles in
10946 the machine's execution model will produce disastrous results.
10947
10948 This flag does not have a negative form, because it specifies a
10949 three-way choice.
10950
10951 @item -fcall-saved-@var{reg}
10952 @opindex fcall-saved
10953 Treat the register named @var{reg} as an allocable register saved by
10954 functions. It may be allocated even for temporaries or variables that
10955 live across a call. Functions compiled this way will save and restore
10956 the register @var{reg} if they use it.
10957
10958 It is an error to used this flag with the frame pointer or stack pointer.
10959 Use of this flag for other registers that have fixed pervasive roles in
10960 the machine's execution model will produce disastrous results.
10961
10962 A different sort of disaster will result from the use of this flag for
10963 a register in which function values may be returned.
10964
10965 This flag does not have a negative form, because it specifies a
10966 three-way choice.
10967
10968 @item -fpack-struct
10969 @opindex fpack-struct
10970 Pack all structure members together without holes.
10971
10972 @strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
10973 code that is not binary compatible with code generated without that switch.
10974 Additionally, it makes the code suboptimal.
10975 Use it to conform to a non-default application binary interface.
10976
10977 @item -finstrument-functions
10978 @opindex finstrument-functions
10979 Generate instrumentation calls for entry and exit to functions. Just
10980 after function entry and just before function exit, the following
10981 profiling functions will be called with the address of the current
10982 function and its call site. (On some platforms,
10983 @code{__builtin_return_address} does not work beyond the current
10984 function, so the call site information may not be available to the
10985 profiling functions otherwise.)
10986
10987 @smallexample
10988 void __cyg_profile_func_enter (void *this_fn,
10989 void *call_site);
10990 void __cyg_profile_func_exit (void *this_fn,
10991 void *call_site);
10992 @end smallexample
10993
10994 The first argument is the address of the start of the current function,
10995 which may be looked up exactly in the symbol table.
10996
10997 This instrumentation is also done for functions expanded inline in other
10998 functions. The profiling calls will indicate where, conceptually, the
10999 inline function is entered and exited. This means that addressable
11000 versions of such functions must be available. If all your uses of a
11001 function are expanded inline, this may mean an additional expansion of
11002 code size. If you use @samp{extern inline} in your C code, an
11003 addressable version of such functions must be provided. (This is
11004 normally the case anyways, but if you get lucky and the optimizer always
11005 expands the functions inline, you might have gotten away without
11006 providing static copies.)
11007
11008 A function may be given the attribute @code{no_instrument_function}, in
11009 which case this instrumentation will not be done. This can be used, for
11010 example, for the profiling functions listed above, high-priority
11011 interrupt routines, and any functions from which the profiling functions
11012 cannot safely be called (perhaps signal handlers, if the profiling
11013 routines generate output or allocate memory).
11014
11015 @item -fstack-check
11016 @opindex fstack-check
11017 Generate code to verify that you do not go beyond the boundary of the
11018 stack. You should specify this flag if you are running in an
11019 environment with multiple threads, but only rarely need to specify it in
11020 a single-threaded environment since stack overflow is automatically
11021 detected on nearly all systems if there is only one stack.
11022
11023 Note that this switch does not actually cause checking to be done; the
11024 operating system must do that. The switch causes generation of code
11025 to ensure that the operating system sees the stack being extended.
11026
11027 @item -fstack-limit-register=@var{reg}
11028 @itemx -fstack-limit-symbol=@var{sym}
11029 @itemx -fno-stack-limit
11030 @opindex fstack-limit-register
11031 @opindex fstack-limit-symbol
11032 @opindex fno-stack-limit
11033 Generate code to ensure that the stack does not grow beyond a certain value,
11034 either the value of a register or the address of a symbol. If the stack
11035 would grow beyond the value, a signal is raised. For most targets,
11036 the signal is raised before the stack overruns the boundary, so
11037 it is possible to catch the signal without taking special precautions.
11038
11039 For instance, if the stack starts at absolute address @samp{0x80000000}
11040 and grows downwards, you can use the flags
11041 @option{-fstack-limit-symbol=__stack_limit} and
11042 @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
11043 of 128KB@. Note that this may only work with the GNU linker.
11044
11045 @cindex aliasing of parameters
11046 @cindex parameters, aliased
11047 @item -fargument-alias
11048 @itemx -fargument-noalias
11049 @itemx -fargument-noalias-global
11050 @opindex fargument-alias
11051 @opindex fargument-noalias
11052 @opindex fargument-noalias-global
11053 Specify the possible relationships among parameters and between
11054 parameters and global data.
11055
11056 @option{-fargument-alias} specifies that arguments (parameters) may
11057 alias each other and may alias global storage.@*
11058 @option{-fargument-noalias} specifies that arguments do not alias
11059 each other, but may alias global storage.@*
11060 @option{-fargument-noalias-global} specifies that arguments do not
11061 alias each other and do not alias global storage.
11062
11063 Each language will automatically use whatever option is required by
11064 the language standard. You should not need to use these options yourself.
11065
11066 @item -fleading-underscore
11067 @opindex fleading-underscore
11068 This option and its counterpart, @option{-fno-leading-underscore}, forcibly
11069 change the way C symbols are represented in the object file. One use
11070 is to help link with legacy assembly code.
11071
11072 @strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
11073 generate code that is not binary compatible with code generated without that
11074 switch. Use it to conform to a non-default application binary interface.
11075 Not all targets provide complete support for this switch.
11076
11077 @item -ftls-model=@var{model}
11078 Alter the thread-local storage model to be used (@pxref{Thread-Local}).
11079 The @var{model} argument should be one of @code{global-dynamic},
11080 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
11081
11082 The default without @option{-fpic} is @code{initial-exec}; with
11083 @option{-fpic} the default is @code{global-dynamic}.
11084 @end table
11085
11086 @c man end
11087
11088 @node Environment Variables
11089 @section Environment Variables Affecting GCC
11090 @cindex environment variables
11091
11092 @c man begin ENVIRONMENT
11093 This section describes several environment variables that affect how GCC
11094 operates. Some of them work by specifying directories or prefixes to use
11095 when searching for various kinds of files. Some are used to specify other
11096 aspects of the compilation environment.
11097
11098 Note that you can also specify places to search using options such as
11099 @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
11100 take precedence over places specified using environment variables, which
11101 in turn take precedence over those specified by the configuration of GCC@.
11102 @xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
11103 GNU Compiler Collection (GCC) Internals}.
11104
11105 @table @env
11106 @item LANG
11107 @itemx LC_CTYPE
11108 @c @itemx LC_COLLATE
11109 @itemx LC_MESSAGES
11110 @c @itemx LC_MONETARY
11111 @c @itemx LC_NUMERIC
11112 @c @itemx LC_TIME
11113 @itemx LC_ALL
11114 @findex LANG
11115 @findex LC_CTYPE
11116 @c @findex LC_COLLATE
11117 @findex LC_MESSAGES
11118 @c @findex LC_MONETARY
11119 @c @findex LC_NUMERIC
11120 @c @findex LC_TIME
11121 @findex LC_ALL
11122 @cindex locale
11123 These environment variables control the way that GCC uses
11124 localization information that allow GCC to work with different
11125 national conventions. GCC inspects the locale categories
11126 @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
11127 so. These locale categories can be set to any value supported by your
11128 installation. A typical value is @samp{en_UK} for English in the United
11129 Kingdom.
11130
11131 The @env{LC_CTYPE} environment variable specifies character
11132 classification. GCC uses it to determine the character boundaries in
11133 a string; this is needed for some multibyte encodings that contain quote
11134 and escape characters that would otherwise be interpreted as a string
11135 end or escape.
11136
11137 The @env{LC_MESSAGES} environment variable specifies the language to
11138 use in diagnostic messages.
11139
11140 If the @env{LC_ALL} environment variable is set, it overrides the value
11141 of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
11142 and @env{LC_MESSAGES} default to the value of the @env{LANG}
11143 environment variable. If none of these variables are set, GCC
11144 defaults to traditional C English behavior.
11145
11146 @item TMPDIR
11147 @findex TMPDIR
11148 If @env{TMPDIR} is set, it specifies the directory to use for temporary
11149 files. GCC uses temporary files to hold the output of one stage of
11150 compilation which is to be used as input to the next stage: for example,
11151 the output of the preprocessor, which is the input to the compiler
11152 proper.
11153
11154 @item GCC_EXEC_PREFIX
11155 @findex GCC_EXEC_PREFIX
11156 If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
11157 names of the subprograms executed by the compiler. No slash is added
11158 when this prefix is combined with the name of a subprogram, but you can
11159 specify a prefix that ends with a slash if you wish.
11160
11161 If @env{GCC_EXEC_PREFIX} is not set, GCC will attempt to figure out
11162 an appropriate prefix to use based on the pathname it was invoked with.
11163
11164 If GCC cannot find the subprogram using the specified prefix, it
11165 tries looking in the usual places for the subprogram.
11166
11167 The default value of @env{GCC_EXEC_PREFIX} is
11168 @file{@var{prefix}/lib/gcc/} where @var{prefix} is the value
11169 of @code{prefix} when you ran the @file{configure} script.
11170
11171 Other prefixes specified with @option{-B} take precedence over this prefix.
11172
11173 This prefix is also used for finding files such as @file{crt0.o} that are
11174 used for linking.
11175
11176 In addition, the prefix is used in an unusual way in finding the
11177 directories to search for header files. For each of the standard
11178 directories whose name normally begins with @samp{/usr/local/lib/gcc}
11179 (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
11180 replacing that beginning with the specified prefix to produce an
11181 alternate directory name. Thus, with @option{-Bfoo/}, GCC will search
11182 @file{foo/bar} where it would normally search @file{/usr/local/lib/bar}.
11183 These alternate directories are searched first; the standard directories
11184 come next.
11185
11186 @item COMPILER_PATH
11187 @findex COMPILER_PATH
11188 The value of @env{COMPILER_PATH} is a colon-separated list of
11189 directories, much like @env{PATH}. GCC tries the directories thus
11190 specified when searching for subprograms, if it can't find the
11191 subprograms using @env{GCC_EXEC_PREFIX}.
11192
11193 @item LIBRARY_PATH
11194 @findex LIBRARY_PATH
11195 The value of @env{LIBRARY_PATH} is a colon-separated list of
11196 directories, much like @env{PATH}. When configured as a native compiler,
11197 GCC tries the directories thus specified when searching for special
11198 linker files, if it can't find them using @env{GCC_EXEC_PREFIX}. Linking
11199 using GCC also uses these directories when searching for ordinary
11200 libraries for the @option{-l} option (but directories specified with
11201 @option{-L} come first).
11202
11203 @item LANG
11204 @findex LANG
11205 @cindex locale definition
11206 This variable is used to pass locale information to the compiler. One way in
11207 which this information is used is to determine the character set to be used
11208 when character literals, string literals and comments are parsed in C and C++.
11209 When the compiler is configured to allow multibyte characters,
11210 the following values for @env{LANG} are recognized:
11211
11212 @table @samp
11213 @item C-JIS
11214 Recognize JIS characters.
11215 @item C-SJIS
11216 Recognize SJIS characters.
11217 @item C-EUCJP
11218 Recognize EUCJP characters.
11219 @end table
11220
11221 If @env{LANG} is not defined, or if it has some other value, then the
11222 compiler will use mblen and mbtowc as defined by the default locale to
11223 recognize and translate multibyte characters.
11224 @end table
11225
11226 @noindent
11227 Some additional environments variables affect the behavior of the
11228 preprocessor.
11229
11230 @include cppenv.texi
11231
11232 @c man end
11233
11234 @node Precompiled Headers
11235 @section Using Precompiled Headers
11236 @cindex precompiled headers
11237 @cindex speed of compilation
11238
11239 Often large projects have many header files that are included in every
11240 source file. The time the compiler takes to process these header files
11241 over and over again can account for nearly all of the time required to
11242 build the project. To make builds faster, GCC allows users to
11243 `precompile' a header file; then, if builds can use the precompiled
11244 header file they will be much faster.
11245
11246 To create a precompiled header file, simply compile it as you would any
11247 other file, if necessary using the @option{-x} option to make the driver
11248 treat it as a C or C++ header file. You will probably want to use a
11249 tool like @command{make} to keep the precompiled header up-to-date when
11250 the headers it contains change.
11251
11252 A precompiled header file will be searched for when @code{#include} is
11253 seen in the compilation. As it searches for the included file
11254 (@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
11255 compiler looks for a precompiled header in each directory just before it
11256 looks for the include file in that directory. The name searched for is
11257 the name specified in the @code{#include} with @samp{.gch} appended. If
11258 the precompiled header file can't be used, it is ignored.
11259
11260 For instance, if you have @code{#include "all.h"}, and you have
11261 @file{all.h.gch} in the same directory as @file{all.h}, then the
11262 precompiled header file will be used if possible, and the original
11263 header will be used otherwise.
11264
11265 Alternatively, you might decide to put the precompiled header file in a
11266 directory and use @option{-I} to ensure that directory is searched
11267 before (or instead of) the directory containing the original header.
11268 Then, if you want to check that the precompiled header file is always
11269 used, you can put a file of the same name as the original header in this
11270 directory containing an @code{#error} command.
11271
11272 This also works with @option{-include}. So yet another way to use
11273 precompiled headers, good for projects not designed with precompiled
11274 header files in mind, is to simply take most of the header files used by
11275 a project, include them from another header file, precompile that header
11276 file, and @option{-include} the precompiled header. If the header files
11277 have guards against multiple inclusion, they will be skipped because
11278 they've already been included (in the precompiled header).
11279
11280 If you need to precompile the same header file for different
11281 languages, targets, or compiler options, you can instead make a
11282 @emph{directory} named like @file{all.h.gch}, and put each precompiled
11283 header in the directory. (It doesn't matter what you call the files
11284 in the directory, every precompiled header in the directory will be
11285 considered.) The first precompiled header encountered in the
11286 directory that is valid for this compilation will be used; they're
11287 searched in no particular order.
11288
11289 There are many other possibilities, limited only by your imagination,
11290 good sense, and the constraints of your build system.
11291
11292 A precompiled header file can be used only when these conditions apply:
11293
11294 @itemize
11295 @item
11296 Only one precompiled header can be used in a particular compilation.
11297 @item
11298 A precompiled header can't be used once the first C token is seen. You
11299 can have preprocessor directives before a precompiled header; you can
11300 even include a precompiled header from inside another header, so long as
11301 there are no C tokens before the @code{#include}.
11302 @item
11303 The precompiled header file must be produced for the same language as
11304 the current compilation. You can't use a C precompiled header for a C++
11305 compilation.
11306 @item
11307 The precompiled header file must be produced by the same compiler
11308 version and configuration as the current compilation is using.
11309 The easiest way to guarantee this is to use the same compiler binary
11310 for creating and using precompiled headers.
11311 @item
11312 Any macros defined before the precompiled header (including with
11313 @option{-D}) must either be defined in the same way as when the
11314 precompiled header was generated, or must not affect the precompiled
11315 header, which usually means that the they don't appear in the
11316 precompiled header at all.
11317 @item
11318 Certain command-line options must be defined in the same way as when the
11319 precompiled header was generated. At present, it's not clear which
11320 options are safe to change and which are not; the safest choice is to
11321 use exactly the same options when generating and using the precompiled
11322 header.
11323 @end itemize
11324
11325 For all of these but the last, the compiler will automatically ignore
11326 the precompiled header if the conditions aren't met. For the last item,
11327 some option changes will cause the precompiled header to be rejected,
11328 but not all incompatible option combinations have yet been found. If
11329 you find a new incompatible combination, please consider filing a bug
11330 report, see @ref{Bugs}.
11331
11332 @node Running Protoize
11333 @section Running Protoize
11334
11335 The program @code{protoize} is an optional part of GCC@. You can use
11336 it to add prototypes to a program, thus converting the program to ISO
11337 C in one respect. The companion program @code{unprotoize} does the
11338 reverse: it removes argument types from any prototypes that are found.
11339
11340 When you run these programs, you must specify a set of source files as
11341 command line arguments. The conversion programs start out by compiling
11342 these files to see what functions they define. The information gathered
11343 about a file @var{foo} is saved in a file named @file{@var{foo}.X}.
11344
11345 After scanning comes actual conversion. The specified files are all
11346 eligible to be converted; any files they include (whether sources or
11347 just headers) are eligible as well.
11348
11349 But not all the eligible files are converted. By default,
11350 @code{protoize} and @code{unprotoize} convert only source and header
11351 files in the current directory. You can specify additional directories
11352 whose files should be converted with the @option{-d @var{directory}}
11353 option. You can also specify particular files to exclude with the
11354 @option{-x @var{file}} option. A file is converted if it is eligible, its
11355 directory name matches one of the specified directory names, and its
11356 name within the directory has not been excluded.
11357
11358 Basic conversion with @code{protoize} consists of rewriting most
11359 function definitions and function declarations to specify the types of
11360 the arguments. The only ones not rewritten are those for varargs
11361 functions.
11362
11363 @code{protoize} optionally inserts prototype declarations at the
11364 beginning of the source file, to make them available for any calls that
11365 precede the function's definition. Or it can insert prototype
11366 declarations with block scope in the blocks where undeclared functions
11367 are called.
11368
11369 Basic conversion with @code{unprotoize} consists of rewriting most
11370 function declarations to remove any argument types, and rewriting
11371 function definitions to the old-style pre-ISO form.
11372
11373 Both conversion programs print a warning for any function declaration or
11374 definition that they can't convert. You can suppress these warnings
11375 with @option{-q}.
11376
11377 The output from @code{protoize} or @code{unprotoize} replaces the
11378 original source file. The original file is renamed to a name ending
11379 with @samp{.save} (for DOS, the saved filename ends in @samp{.sav}
11380 without the original @samp{.c} suffix). If the @samp{.save} (@samp{.sav}
11381 for DOS) file already exists, then the source file is simply discarded.
11382
11383 @code{protoize} and @code{unprotoize} both depend on GCC itself to
11384 scan the program and collect information about the functions it uses.
11385 So neither of these programs will work until GCC is installed.
11386
11387 Here is a table of the options you can use with @code{protoize} and
11388 @code{unprotoize}. Each option works with both programs unless
11389 otherwise stated.
11390
11391 @table @code
11392 @item -B @var{directory}
11393 Look for the file @file{SYSCALLS.c.X} in @var{directory}, instead of the
11394 usual directory (normally @file{/usr/local/lib}). This file contains
11395 prototype information about standard system functions. This option
11396 applies only to @code{protoize}.
11397
11398 @item -c @var{compilation-options}
11399 Use @var{compilation-options} as the options when running @command{gcc} to
11400 produce the @samp{.X} files. The special option @option{-aux-info} is
11401 always passed in addition, to tell @command{gcc} to write a @samp{.X} file.
11402
11403 Note that the compilation options must be given as a single argument to
11404 @code{protoize} or @code{unprotoize}. If you want to specify several
11405 @command{gcc} options, you must quote the entire set of compilation options
11406 to make them a single word in the shell.
11407
11408 There are certain @command{gcc} arguments that you cannot use, because they
11409 would produce the wrong kind of output. These include @option{-g},
11410 @option{-O}, @option{-c}, @option{-S}, and @option{-o} If you include these in
11411 the @var{compilation-options}, they are ignored.
11412
11413 @item -C
11414 Rename files to end in @samp{.C} (@samp{.cc} for DOS-based file
11415 systems) instead of @samp{.c}. This is convenient if you are converting
11416 a C program to C++. This option applies only to @code{protoize}.
11417
11418 @item -g
11419 Add explicit global declarations. This means inserting explicit
11420 declarations at the beginning of each source file for each function
11421 that is called in the file and was not declared. These declarations
11422 precede the first function definition that contains a call to an
11423 undeclared function. This option applies only to @code{protoize}.
11424
11425 @item -i @var{string}
11426 Indent old-style parameter declarations with the string @var{string}.
11427 This option applies only to @code{protoize}.
11428
11429 @code{unprotoize} converts prototyped function definitions to old-style
11430 function definitions, where the arguments are declared between the
11431 argument list and the initial @samp{@{}. By default, @code{unprotoize}
11432 uses five spaces as the indentation. If you want to indent with just
11433 one space instead, use @option{-i " "}.
11434
11435 @item -k
11436 Keep the @samp{.X} files. Normally, they are deleted after conversion
11437 is finished.
11438
11439 @item -l
11440 Add explicit local declarations. @code{protoize} with @option{-l} inserts
11441 a prototype declaration for each function in each block which calls the
11442 function without any declaration. This option applies only to
11443 @code{protoize}.
11444
11445 @item -n
11446 Make no real changes. This mode just prints information about the conversions
11447 that would have been done without @option{-n}.
11448
11449 @item -N
11450 Make no @samp{.save} files. The original files are simply deleted.
11451 Use this option with caution.
11452
11453 @item -p @var{program}
11454 Use the program @var{program} as the compiler. Normally, the name
11455 @file{gcc} is used.
11456
11457 @item -q
11458 Work quietly. Most warnings are suppressed.
11459
11460 @item -v
11461 Print the version number, just like @option{-v} for @command{gcc}.
11462 @end table
11463
11464 If you need special compiler options to compile one of your program's
11465 source files, then you should generate that file's @samp{.X} file
11466 specially, by running @command{gcc} on that source file with the
11467 appropriate options and the option @option{-aux-info}. Then run
11468 @code{protoize} on the entire set of files. @code{protoize} will use
11469 the existing @samp{.X} file because it is newer than the source file.
11470 For example:
11471
11472 @smallexample
11473 gcc -Dfoo=bar file1.c -aux-info file1.X
11474 protoize *.c
11475 @end smallexample
11476
11477 @noindent
11478 You need to include the special files along with the rest in the
11479 @code{protoize} command, even though their @samp{.X} files already
11480 exist, because otherwise they won't get converted.
11481
11482 @xref{Protoize Caveats}, for more information on how to use
11483 @code{protoize} successfully.