1 @c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2 @c 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
11 @c man begin COPYRIGHT
12 Copyright @copyright{} 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
13 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
15 Permission is granted to copy, distribute and/or modify this document
16 under the terms of the GNU Free Documentation License, Version 1.2 or
17 any later version published by the Free Software Foundation; with the
18 Invariant Sections being ``GNU General Public License'' and ``Funding
19 Free Software'', the Front-Cover texts being (a) (see below), and with
20 the Back-Cover Texts being (b) (see below). A copy of the license is
21 included in the gfdl(7) man page.
23 (a) The FSF's Front-Cover Text is:
27 (b) The FSF's Back-Cover Text is:
29 You have freedom to copy and modify this GNU Manual, like GNU
30 software. Copies published by the Free Software Foundation raise
31 funds for GNU development.
33 @c Set file name and title for the man page.
35 @settitle GNU project C and C++ compiler
37 gcc [@option{-c}|@option{-S}|@option{-E}] [@option{-std=}@var{standard}]
38 [@option{-g}] [@option{-pg}] [@option{-O}@var{level}]
39 [@option{-W}@var{warn}@dots{}] [@option{-pedantic}]
40 [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
41 [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
42 [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}]
43 [@option{-o} @var{outfile}] [@@@var{file}] @var{infile}@dots{}
45 Only the most useful options are listed here; see below for the
46 remainder. @samp{g++} accepts mostly the same options as @samp{gcc}.
49 gpl(7), gfdl(7), fsf-funding(7),
50 cpp(1), gcov(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1)
51 and the Info entries for @file{gcc}, @file{cpp}, @file{as},
52 @file{ld}, @file{binutils} and @file{gdb}.
55 For instructions on reporting bugs, see
56 @w{@uref{http://gcc.gnu.org/bugs.html}}.
59 See the Info entry for @command{gcc}, or
60 @w{@uref{http://gcc.gnu.org/onlinedocs/gcc/Contributors.html}},
61 for contributors to GCC@.
66 @chapter GCC Command Options
67 @cindex GCC command options
68 @cindex command options
69 @cindex options, GCC command
71 @c man begin DESCRIPTION
72 When you invoke GCC, it normally does preprocessing, compilation,
73 assembly and linking. The ``overall options'' allow you to stop this
74 process at an intermediate stage. For example, the @option{-c} option
75 says not to run the linker. Then the output consists of object files
76 output by the assembler.
78 Other options are passed on to one stage of processing. Some options
79 control the preprocessor and others the compiler itself. Yet other
80 options control the assembler and linker; most of these are not
81 documented here, since you rarely need to use any of them.
83 @cindex C compilation options
84 Most of the command line options that you can use with GCC are useful
85 for C programs; when an option is only useful with another language
86 (usually C++), the explanation says so explicitly. If the description
87 for a particular option does not mention a source language, you can use
88 that option with all supported languages.
90 @cindex C++ compilation options
91 @xref{Invoking G++,,Compiling C++ Programs}, for a summary of special
92 options for compiling C++ programs.
94 @cindex grouping options
95 @cindex options, grouping
96 The @command{gcc} program accepts options and file names as operands. Many
97 options have multi-letter names; therefore multiple single-letter options
98 may @emph{not} be grouped: @option{-dr} is very different from @w{@samp{-d
101 @cindex order of options
102 @cindex options, order
103 You can mix options and other arguments. For the most part, the order
104 you use doesn't matter. Order does matter when you use several options
105 of the same kind; for example, if you specify @option{-L} more than once,
106 the directories are searched in the order specified.
108 Many options have long names starting with @samp{-f} or with
109 @samp{-W}---for example,
110 @option{-fmove-loop-invariants}, @option{-Wformat} and so on. Most of
111 these have both positive and negative forms; the negative form of
112 @option{-ffoo} would be @option{-fno-foo}. This manual documents
113 only one of these two forms, whichever one is not the default.
117 @xref{Option Index}, for an index to GCC's options.
120 * Option Summary:: Brief list of all options, without explanations.
121 * Overall Options:: Controlling the kind of output:
122 an executable, object files, assembler files,
123 or preprocessed source.
124 * Invoking G++:: Compiling C++ programs.
125 * C Dialect Options:: Controlling the variant of C language compiled.
126 * C++ Dialect Options:: Variations on C++.
127 * Language Independent Options:: Controlling how diagnostics should be
129 * Warning Options:: How picky should the compiler be?
130 * Debugging Options:: Symbol tables, measurements, and debugging dumps.
131 * Optimize Options:: How much optimization?
132 * Preprocessor Options:: Controlling header files and macro definitions.
133 Also, getting dependency information for Make.
134 * Assembler Options:: Passing options to the assembler.
135 * Link Options:: Specifying libraries and so on.
136 * Directory Options:: Where to find header files and libraries.
137 Where to find the compiler executable files.
138 * Spec Files:: How to pass switches to sub-processes.
139 * Target Options:: Running a cross-compiler, or an old version of GCC.
140 * Submodel Options:: Specifying minor hardware or convention variations,
141 such as 68010 vs 68020.
142 * Code Gen Options:: Specifying conventions for function calls, data layout
144 * Environment Variables:: Env vars that affect GCC.
145 * Precompiled Headers:: Compiling a header once, and using it many times.
146 * Running Protoize:: Automatically adding or removing function prototypes.
152 @section Option Summary
154 Here is a summary of all the options, grouped by type. Explanations are
155 in the following sections.
158 @item Overall Options
159 @xref{Overall Options,,Options Controlling the Kind of Output}.
160 @gccoptlist{-c -S -E -o @var{file} -combine -pipe -pass-exit-codes @gol
161 -x @var{language} -v -### --help --target-help --version @@@var{file}}
163 @item C Language Options
164 @xref{C Dialect Options,,Options Controlling C Dialect}.
165 @gccoptlist{-ansi -std=@var{standard} -fgnu89-inline @gol
166 -aux-info @var{filename} @gol
167 -fno-asm -fno-builtin -fno-builtin-@var{function} @gol
168 -fhosted -ffreestanding -fopenmp -fms-extensions @gol
169 -trigraphs -no-integrated-cpp -traditional -traditional-cpp @gol
170 -fallow-single-precision -fcond-mismatch @gol
171 -fsigned-bitfields -fsigned-char @gol
172 -funsigned-bitfields -funsigned-char}
174 @item C++ Language Options
175 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
176 @gccoptlist{-fabi-version=@var{n} -fno-access-control -fcheck-new @gol
177 -fconserve-space -ffriend-injection @gol
178 -fno-elide-constructors @gol
179 -fno-enforce-eh-specs @gol
180 -ffor-scope -fno-for-scope -fno-gnu-keywords @gol
181 -fno-implicit-templates @gol
182 -fno-implicit-inline-templates @gol
183 -fno-implement-inlines -fms-extensions @gol
184 -fno-nonansi-builtins -fno-operator-names @gol
185 -fno-optional-diags -fpermissive @gol
186 -frepo -fno-rtti -fstats -ftemplate-depth-@var{n} @gol
187 -fno-threadsafe-statics -fuse-cxa-atexit -fno-weak -nostdinc++ @gol
188 -fno-default-inline -fvisibility-inlines-hidden @gol
189 -Wabi -Wctor-dtor-privacy @gol
190 -Wnon-virtual-dtor -Wreorder @gol
191 -Weffc++ -Wno-deprecated -Wstrict-null-sentinel @gol
192 -Wno-non-template-friend -Wold-style-cast @gol
193 -Woverloaded-virtual -Wno-pmf-conversions @gol
196 @item Language Independent Options
197 @xref{Language Independent Options,,Options to Control Diagnostic Messages Formatting}.
198 @gccoptlist{-fmessage-length=@var{n} @gol
199 -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]} @gol
200 -fdiagnostics-show-option}
202 @item Warning Options
203 @xref{Warning Options,,Options to Request or Suppress Warnings}.
204 @gccoptlist{-fsyntax-only -pedantic -pedantic-errors @gol
205 -w -Wextra -Wall -Waddress -Waggregate-return -Wno-attributes @gol
206 -Wc++-compat -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
207 -Wconversion -Wno-deprecated-declarations @gol
208 -Wdisabled-optimization -Wno-div-by-zero -Wno-endif-labels @gol
209 -Werror -Werror=* -Werror-implicit-function-declaration @gol
210 -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
211 -Wno-format-extra-args -Wformat-nonliteral @gol
212 -Wformat-security -Wformat-y2k @gol
213 -Wimplicit -Wimplicit-function-declaration -Wimplicit-int @gol
214 -Wimport -Wno-import -Winit-self -Winline @gol
215 -Wno-int-to-pointer-cast @gol
216 -Wno-invalid-offsetof -Winvalid-pch @gol
217 -Wlarger-than-@var{len} -Wunsafe-loop-optimizations -Wlong-long @gol
218 -Wmain -Wmissing-braces -Wmissing-field-initializers @gol
219 -Wmissing-format-attribute -Wmissing-include-dirs @gol
220 -Wmissing-noreturn @gol
221 -Wno-multichar -Wnonnull -Wno-overflow @gol
222 -Woverlength-strings -Wpacked -Wpadded @gol
223 -Wparentheses -Wpointer-arith -Wno-pointer-to-int-cast @gol
224 -Wredundant-decls @gol
225 -Wreturn-type -Wsequence-point -Wshadow @gol
226 -Wsign-compare -Wstack-protector @gol
227 -Wstrict-aliasing -Wstrict-aliasing=2 @gol
228 -Wstrict-overflow -Wstrict-overflow=@var{n} @gol
229 -Wswitch -Wswitch-default -Wswitch-enum @gol
230 -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized @gol
231 -Wunknown-pragmas -Wno-pragmas -Wunreachable-code @gol
232 -Wunused -Wunused-function -Wunused-label -Wunused-parameter @gol
233 -Wunused-value -Wunused-variable -Wvariadic-macros @gol
234 -Wvolatile-register-var -Wwrite-strings}
236 @item C-only Warning Options
237 @gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol
238 -Wmissing-prototypes -Wnested-externs -Wold-style-definition @gol
239 -Wstrict-prototypes -Wtraditional @gol
240 -Wdeclaration-after-statement -Wpointer-sign}
242 @item Debugging Options
243 @xref{Debugging Options,,Options for Debugging Your Program or GCC}.
244 @gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol
245 -fdump-noaddr -fdump-unnumbered -fdump-translation-unit@r{[}-@var{n}@r{]} @gol
246 -fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
247 -fdump-ipa-all -fdump-ipa-cgraph @gol
249 -fdump-tree-original@r{[}-@var{n}@r{]} @gol
250 -fdump-tree-optimized@r{[}-@var{n}@r{]} @gol
251 -fdump-tree-inlined@r{[}-@var{n}@r{]} @gol
252 -fdump-tree-cfg -fdump-tree-vcg -fdump-tree-alias @gol
254 -fdump-tree-ssa@r{[}-@var{n}@r{]} -fdump-tree-pre@r{[}-@var{n}@r{]} @gol
255 -fdump-tree-ccp@r{[}-@var{n}@r{]} -fdump-tree-dce@r{[}-@var{n}@r{]} @gol
256 -fdump-tree-gimple@r{[}-raw@r{]} -fdump-tree-mudflap@r{[}-@var{n}@r{]} @gol
257 -fdump-tree-dom@r{[}-@var{n}@r{]} @gol
258 -fdump-tree-dse@r{[}-@var{n}@r{]} @gol
259 -fdump-tree-phiopt@r{[}-@var{n}@r{]} @gol
260 -fdump-tree-forwprop@r{[}-@var{n}@r{]} @gol
261 -fdump-tree-copyrename@r{[}-@var{n}@r{]} @gol
262 -fdump-tree-nrv -fdump-tree-vect @gol
263 -fdump-tree-sink @gol
264 -fdump-tree-sra@r{[}-@var{n}@r{]} @gol
265 -fdump-tree-salias @gol
266 -fdump-tree-fre@r{[}-@var{n}@r{]} @gol
267 -fdump-tree-vrp@r{[}-@var{n}@r{]} @gol
268 -ftree-vectorizer-verbose=@var{n} @gol
269 -fdump-tree-storeccp@r{[}-@var{n}@r{]} @gol
270 -feliminate-dwarf2-dups -feliminate-unused-debug-types @gol
271 -feliminate-unused-debug-symbols -femit-class-debug-always @gol
272 -fmem-report -fprofile-arcs @gol
273 -frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
274 -ftest-coverage -ftime-report -fvar-tracking @gol
275 -g -g@var{level} -gcoff -gdwarf-2 @gol
276 -ggdb -gstabs -gstabs+ -gvms -gxcoff -gxcoff+ @gol
277 -p -pg -print-file-name=@var{library} -print-libgcc-file-name @gol
278 -print-multi-directory -print-multi-lib @gol
279 -print-prog-name=@var{program} -print-search-dirs -Q @gol
282 @item Optimization Options
283 @xref{Optimize Options,,Options that Control Optimization}.
284 @gccoptlist{-falign-functions=@var{n} -falign-jumps=@var{n} @gol
285 -falign-labels=@var{n} -falign-loops=@var{n} @gol
286 -fbounds-check -fmudflap -fmudflapth -fmudflapir @gol
287 -fbranch-probabilities -fprofile-values -fvpt -fbranch-target-load-optimize @gol
288 -fbranch-target-load-optimize2 -fbtr-bb-exclusive @gol
289 -fcaller-saves -fcprop-registers -fcse-follow-jumps @gol
290 -fcse-skip-blocks -fcx-limited-range -fdata-sections @gol
291 -fdelayed-branch -fdelete-null-pointer-checks -fearly-inlining @gol
292 -fexpensive-optimizations -ffast-math -ffloat-store @gol
293 -fforce-addr -ffunction-sections @gol
294 -fgcse -fgcse-lm -fgcse-sm -fgcse-las -fgcse-after-reload @gol
295 -fcrossjumping -fif-conversion -fif-conversion2 @gol
296 -finline-functions -finline-functions-called-once @gol
297 -finline-limit=@var{n} -fkeep-inline-functions @gol
298 -fkeep-static-consts -fmerge-constants -fmerge-all-constants @gol
299 -fmodulo-sched -fno-branch-count-reg @gol
300 -fno-default-inline -fno-defer-pop -fmove-loop-invariants @gol
301 -fno-function-cse -fno-guess-branch-probability @gol
302 -fno-inline -fno-math-errno -fno-peephole -fno-peephole2 @gol
303 -funsafe-math-optimizations -funsafe-loop-optimizations -ffinite-math-only @gol
304 -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss @gol
305 -fomit-frame-pointer -foptimize-register-move @gol
306 -foptimize-sibling-calls -fprefetch-loop-arrays @gol
307 -fprofile-generate -fprofile-use @gol
308 -fregmove -frename-registers @gol
309 -freorder-blocks -freorder-blocks-and-partition -freorder-functions @gol
310 -frerun-cse-after-loop @gol
311 -frounding-math -frtl-abstract-sequences @gol
312 -fschedule-insns -fschedule-insns2 @gol
313 -fno-sched-interblock -fno-sched-spec -fsched-spec-load @gol
314 -fsched-spec-load-dangerous @gol
315 -fsched-stalled-insns=@var{n} -fsched-stalled-insns-dep=@var{n} @gol
316 -fsched2-use-superblocks @gol
317 -fsched2-use-traces -fsee -freschedule-modulo-scheduled-loops @gol
318 -fsection-anchors -fsignaling-nans -fsingle-precision-constant @gol
319 -fstack-protector -fstack-protector-all @gol
320 -fstrict-aliasing -fstrict-overflow -ftracer -fthread-jumps @gol
321 -funroll-all-loops -funroll-loops -fpeel-loops @gol
322 -fsplit-ivs-in-unroller -funswitch-loops @gol
323 -fvariable-expansion-in-unroller @gol
324 -ftree-pre -ftree-ccp -ftree-dce -ftree-loop-optimize @gol
325 -ftree-loop-linear -ftree-loop-im -ftree-loop-ivcanon -fivopts @gol
326 -ftree-dominator-opts -ftree-dse -ftree-copyrename -ftree-sink @gol
327 -ftree-ch -ftree-sra -ftree-ter -ftree-lrs -ftree-fre -ftree-vectorize @gol
328 -ftree-vect-loop-version -ftree-salias -fipa-pta -fweb @gol
329 -ftree-copy-prop -ftree-store-ccp -ftree-store-copy-prop -fwhole-program @gol
330 --param @var{name}=@var{value}
331 -O -O0 -O1 -O2 -O3 -Os}
333 @item Preprocessor Options
334 @xref{Preprocessor Options,,Options Controlling the Preprocessor}.
335 @gccoptlist{-A@var{question}=@var{answer} @gol
336 -A-@var{question}@r{[}=@var{answer}@r{]} @gol
337 -C -dD -dI -dM -dN @gol
338 -D@var{macro}@r{[}=@var{defn}@r{]} -E -H @gol
339 -idirafter @var{dir} @gol
340 -include @var{file} -imacros @var{file} @gol
341 -iprefix @var{file} -iwithprefix @var{dir} @gol
342 -iwithprefixbefore @var{dir} -isystem @var{dir} @gol
343 -imultilib @var{dir} -isysroot @var{dir} @gol
344 -M -MM -MF -MG -MP -MQ -MT -nostdinc @gol
345 -P -fworking-directory -remap @gol
346 -trigraphs -undef -U@var{macro} -Wp,@var{option} @gol
347 -Xpreprocessor @var{option}}
349 @item Assembler Option
350 @xref{Assembler Options,,Passing Options to the Assembler}.
351 @gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
354 @xref{Link Options,,Options for Linking}.
355 @gccoptlist{@var{object-file-name} -l@var{library} @gol
356 -nostartfiles -nodefaultlibs -nostdlib -pie -rdynamic @gol
357 -s -static -static-libgcc -shared -shared-libgcc -symbolic @gol
358 -Wl,@var{option} -Xlinker @var{option} @gol
361 @item Directory Options
362 @xref{Directory Options,,Options for Directory Search}.
363 @gccoptlist{-B@var{prefix} -I@var{dir} -iquote@var{dir} -L@var{dir}
364 -specs=@var{file} -I- --sysroot=@var{dir}}
367 @c I wrote this xref this way to avoid overfull hbox. -- rms
368 @xref{Target Options}.
369 @gccoptlist{-V @var{version} -b @var{machine}}
371 @item Machine Dependent Options
372 @xref{Submodel Options,,Hardware Models and Configurations}.
373 @c This list is ordered alphanumerically by subsection name.
374 @c Try and put the significant identifier (CPU or system) first,
375 @c so users have a clue at guessing where the ones they want will be.
378 @gccoptlist{-EB -EL @gol
379 -mmangle-cpu -mcpu=@var{cpu} -mtext=@var{text-section} @gol
380 -mdata=@var{data-section} -mrodata=@var{readonly-data-section}}
383 @gccoptlist{-mapcs-frame -mno-apcs-frame @gol
384 -mabi=@var{name} @gol
385 -mapcs-stack-check -mno-apcs-stack-check @gol
386 -mapcs-float -mno-apcs-float @gol
387 -mapcs-reentrant -mno-apcs-reentrant @gol
388 -msched-prolog -mno-sched-prolog @gol
389 -mlittle-endian -mbig-endian -mwords-little-endian @gol
390 -mfloat-abi=@var{name} -msoft-float -mhard-float -mfpe @gol
391 -mthumb-interwork -mno-thumb-interwork @gol
392 -mcpu=@var{name} -march=@var{name} -mfpu=@var{name} @gol
393 -mstructure-size-boundary=@var{n} @gol
394 -mabort-on-noreturn @gol
395 -mlong-calls -mno-long-calls @gol
396 -msingle-pic-base -mno-single-pic-base @gol
397 -mpic-register=@var{reg} @gol
398 -mnop-fun-dllimport @gol
399 -mcirrus-fix-invalid-insns -mno-cirrus-fix-invalid-insns @gol
400 -mpoke-function-name @gol
402 -mtpcs-frame -mtpcs-leaf-frame @gol
403 -mcaller-super-interworking -mcallee-super-interworking @gol
407 @gccoptlist{-mmcu=@var{mcu} -msize -minit-stack=@var{n} -mno-interrupts @gol
408 -mcall-prologues -mno-tablejump -mtiny-stack -mint8}
410 @emph{Blackfin Options}
411 @gccoptlist{-momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer @gol
412 -mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly @gol
413 -mlow-64k -mno-low64k -mid-shared-library @gol
414 -mno-id-shared-library -mshared-library-id=@var{n} @gol
415 -mlong-calls -mno-long-calls}
418 @gccoptlist{-mcpu=@var{cpu} -march=@var{cpu} -mtune=@var{cpu} @gol
419 -mmax-stack-frame=@var{n} -melinux-stacksize=@var{n} @gol
420 -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects @gol
421 -mstack-align -mdata-align -mconst-align @gol
422 -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue -mno-gotplt @gol
423 -melf -maout -melinux -mlinux -sim -sim2 @gol
424 -mmul-bug-workaround -mno-mul-bug-workaround}
427 @gccoptlist{-mmac -mpush-args}
429 @emph{Darwin Options}
430 @gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal @gol
431 -arch_only -bind_at_load -bundle -bundle_loader @gol
432 -client_name -compatibility_version -current_version @gol
434 -dependency-file -dylib_file -dylinker_install_name @gol
435 -dynamic -dynamiclib -exported_symbols_list @gol
436 -filelist -flat_namespace -force_cpusubtype_ALL @gol
437 -force_flat_namespace -headerpad_max_install_names @gol
438 -image_base -init -install_name -keep_private_externs @gol
439 -multi_module -multiply_defined -multiply_defined_unused @gol
440 -noall_load -no_dead_strip_inits_and_terms @gol
441 -nofixprebinding -nomultidefs -noprebind -noseglinkedit @gol
442 -pagezero_size -prebind -prebind_all_twolevel_modules @gol
443 -private_bundle -read_only_relocs -sectalign @gol
444 -sectobjectsymbols -whyload -seg1addr @gol
445 -sectcreate -sectobjectsymbols -sectorder @gol
446 -segaddr -segs_read_only_addr -segs_read_write_addr @gol
447 -seg_addr_table -seg_addr_table_filename -seglinkedit @gol
448 -segprot -segs_read_only_addr -segs_read_write_addr @gol
449 -single_module -static -sub_library -sub_umbrella @gol
450 -twolevel_namespace -umbrella -undefined @gol
451 -unexported_symbols_list -weak_reference_mismatches @gol
452 -whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version} @gol
453 -mkernel -mone-byte-bool}
455 @emph{DEC Alpha Options}
456 @gccoptlist{-mno-fp-regs -msoft-float -malpha-as -mgas @gol
457 -mieee -mieee-with-inexact -mieee-conformant @gol
458 -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} @gol
459 -mtrap-precision=@var{mode} -mbuild-constants @gol
460 -mcpu=@var{cpu-type} -mtune=@var{cpu-type} @gol
461 -mbwx -mmax -mfix -mcix @gol
462 -mfloat-vax -mfloat-ieee @gol
463 -mexplicit-relocs -msmall-data -mlarge-data @gol
464 -msmall-text -mlarge-text @gol
465 -mmemory-latency=@var{time}}
467 @emph{DEC Alpha/VMS Options}
468 @gccoptlist{-mvms-return-codes}
471 @gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 @gol
472 -mhard-float -msoft-float @gol
473 -malloc-cc -mfixed-cc -mdword -mno-dword @gol
474 -mdouble -mno-double @gol
475 -mmedia -mno-media -mmuladd -mno-muladd @gol
476 -mfdpic -minline-plt -mgprel-ro -multilib-library-pic @gol
477 -mlinked-fp -mlong-calls -malign-labels @gol
478 -mlibrary-pic -macc-4 -macc-8 @gol
479 -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move @gol
480 -moptimize-membar -mno-optimize-membar @gol
481 -mscc -mno-scc -mcond-exec -mno-cond-exec @gol
482 -mvliw-branch -mno-vliw-branch @gol
483 -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec @gol
484 -mno-nested-cond-exec -mtomcat-stats @gol
488 @emph{GNU/Linux Options}
489 @gccoptlist{-muclibc}
491 @emph{H8/300 Options}
492 @gccoptlist{-mrelax -mh -ms -mn -mint32 -malign-300}
495 @gccoptlist{-march=@var{architecture-type} @gol
496 -mbig-switch -mdisable-fpregs -mdisable-indexing @gol
497 -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld @gol
498 -mfixed-range=@var{register-range} @gol
499 -mjump-in-delay -mlinker-opt -mlong-calls @gol
500 -mlong-load-store -mno-big-switch -mno-disable-fpregs @gol
501 -mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol
502 -mno-jump-in-delay -mno-long-load-store @gol
503 -mno-portable-runtime -mno-soft-float @gol
504 -mno-space-regs -msoft-float -mpa-risc-1-0 @gol
505 -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol
506 -mschedule=@var{cpu-type} -mspace-regs -msio -mwsio @gol
507 -munix=@var{unix-std} -nolibdld -static -threads}
509 @emph{i386 and x86-64 Options}
510 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
511 -mfpmath=@var{unit} @gol
512 -masm=@var{dialect} -mno-fancy-math-387 @gol
513 -mno-fp-ret-in-387 -msoft-float -msvr3-shlib @gol
514 -mno-wide-multiply -mrtd -malign-double @gol
515 -mpreferred-stack-boundary=@var{num} @gol
516 -mmmx -msse -msse2 -msse3 -mssse3 -m3dnow @gol
517 -mthreads -mno-align-stringops -minline-all-stringops @gol
518 -mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
519 -m96bit-long-double -mregparm=@var{num} -msseregparm @gol
521 -momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs @gol
522 -mcmodel=@var{code-model} @gol
523 -m32 -m64 -mlarge-data-threshold=@var{num}}
526 @gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol
527 -mvolatile-asm-stop -mregister-names -mno-sdata @gol
528 -mconstant-gp -mauto-pic -minline-float-divide-min-latency @gol
529 -minline-float-divide-max-throughput @gol
530 -minline-int-divide-min-latency @gol
531 -minline-int-divide-max-throughput @gol
532 -minline-sqrt-min-latency -minline-sqrt-max-throughput @gol
533 -mno-dwarf2-asm -mearly-stop-bits @gol
534 -mfixed-range=@var{register-range} -mtls-size=@var{tls-size} @gol
535 -mtune=@var{cpu-type} -mt -pthread -milp32 -mlp64 @gol
536 -mno-sched-br-data-spec -msched-ar-data-spec -mno-sched-control-spec @gol
537 -msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec @gol
538 -msched-ldc -mno-sched-control-ldc -mno-sched-spec-verbose @gol
539 -mno-sched-prefer-non-data-spec-insns @gol
540 -mno-sched-prefer-non-control-spec-insns @gol
541 -mno-sched-count-spec-in-critical-path}
543 @emph{M32R/D Options}
544 @gccoptlist{-m32r2 -m32rx -m32r @gol
546 -malign-loops -mno-align-loops @gol
547 -missue-rate=@var{number} @gol
548 -mbranch-cost=@var{number} @gol
549 -mmodel=@var{code-size-model-type} @gol
550 -msdata=@var{sdata-type} @gol
551 -mno-flush-func -mflush-func=@var{name} @gol
552 -mno-flush-trap -mflush-trap=@var{number} @gol
556 @gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
558 @emph{M680x0 Options}
559 @gccoptlist{-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol
560 -m68060 -mcpu32 -m5200 -mcfv4e -m68881 -mbitfield @gol
561 -mc68000 -mc68020 @gol
562 -mnobitfield -mrtd -mshort -msoft-float -mpcrel @gol
563 -malign-int -mstrict-align -msep-data -mno-sep-data @gol
564 -mshared-library-id=n -mid-shared-library -mno-id-shared-library}
566 @emph{M68hc1x Options}
567 @gccoptlist{-m6811 -m6812 -m68hc11 -m68hc12 -m68hcs12 @gol
568 -mauto-incdec -minmax -mlong-calls -mshort @gol
569 -msoft-reg-count=@var{count}}
572 @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol
573 -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol
574 -m4byte-functions -mno-4byte-functions -mcallgraph-data @gol
575 -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol
576 -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
579 @gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} @gol
580 -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips64 @gol
581 -mips16 -mno-mips16 -mabi=@var{abi} -mabicalls -mno-abicalls @gol
582 -mshared -mno-shared -mxgot -mno-xgot -mgp32 -mgp64 @gol
583 -mfp32 -mfp64 -mhard-float -msoft-float @gol
584 -msingle-float -mdouble-float -mdsp -mpaired-single -mips3d @gol
585 -mlong64 -mlong32 -msym32 -mno-sym32 @gol
586 -G@var{num} -membedded-data -mno-embedded-data @gol
587 -muninit-const-in-rodata -mno-uninit-const-in-rodata @gol
588 -msplit-addresses -mno-split-addresses @gol
589 -mexplicit-relocs -mno-explicit-relocs @gol
590 -mcheck-zero-division -mno-check-zero-division @gol
591 -mdivide-traps -mdivide-breaks @gol
592 -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls @gol
593 -mmad -mno-mad -mfused-madd -mno-fused-madd -nocpp @gol
594 -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 @gol
595 -mfix-vr4120 -mno-fix-vr4120 -mfix-vr4130 @gol
596 -mfix-sb1 -mno-fix-sb1 @gol
597 -mflush-func=@var{func} -mno-flush-func @gol
598 -mbranch-likely -mno-branch-likely @gol
599 -mfp-exceptions -mno-fp-exceptions @gol
600 -mvr4130-align -mno-vr4130-align}
603 @gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu @gol
604 -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols @gol
605 -melf -mbranch-predict -mno-branch-predict -mbase-addresses @gol
606 -mno-base-addresses -msingle-exit -mno-single-exit}
608 @emph{MN10300 Options}
609 @gccoptlist{-mmult-bug -mno-mult-bug @gol
610 -mam33 -mno-am33 @gol
611 -mam33-2 -mno-am33-2 @gol
612 -mreturn-pointer-on-d0 @gol
616 @gccoptlist{-mno-crt0 -mbacc -msim @gol
617 -march=@var{cpu-type} }
619 @emph{PDP-11 Options}
620 @gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 @gol
621 -mbcopy -mbcopy-builtin -mint32 -mno-int16 @gol
622 -mint16 -mno-int32 -mfloat32 -mno-float64 @gol
623 -mfloat64 -mno-float32 -mabshi -mno-abshi @gol
624 -mbranch-expensive -mbranch-cheap @gol
625 -msplit -mno-split -munix-asm -mdec-asm}
627 @emph{PowerPC Options}
628 See RS/6000 and PowerPC Options.
630 @emph{RS/6000 and PowerPC Options}
631 @gccoptlist{-mcpu=@var{cpu-type} @gol
632 -mtune=@var{cpu-type} @gol
633 -mpower -mno-power -mpower2 -mno-power2 @gol
634 -mpowerpc -mpowerpc64 -mno-powerpc @gol
635 -maltivec -mno-altivec @gol
636 -mpowerpc-gpopt -mno-powerpc-gpopt @gol
637 -mpowerpc-gfxopt -mno-powerpc-gfxopt @gol
638 -mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mfprnd -mno-fprnd @gol
639 -mnew-mnemonics -mold-mnemonics @gol
640 -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc @gol
641 -m64 -m32 -mxl-compat -mno-xl-compat -mpe @gol
642 -malign-power -malign-natural @gol
643 -msoft-float -mhard-float -mmultiple -mno-multiple @gol
644 -mstring -mno-string -mupdate -mno-update @gol
645 -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol
646 -mstrict-align -mno-strict-align -mrelocatable @gol
647 -mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol
648 -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol
649 -mdynamic-no-pic -maltivec -mswdiv @gol
650 -mprioritize-restricted-insns=@var{priority} @gol
651 -msched-costly-dep=@var{dependence_type} @gol
652 -minsert-sched-nops=@var{scheme} @gol
653 -mcall-sysv -mcall-netbsd @gol
654 -maix-struct-return -msvr4-struct-return @gol
655 -mabi=@var{abi-type} -msecure-plt -mbss-plt @gol
656 -misel -mno-isel @gol
657 -misel=yes -misel=no @gol
659 -mspe=yes -mspe=no @gol
660 -mvrsave -mno-vrsave @gol
661 -mmulhw -mno-mulhw @gol
662 -mdlmzb -mno-dlmzb @gol
663 -mfloat-gprs=yes -mfloat-gprs=no -mfloat-gprs=single -mfloat-gprs=double @gol
664 -mprototype -mno-prototype @gol
665 -msim -mmvme -mads -myellowknife -memb -msdata @gol
666 -msdata=@var{opt} -mvxworks -mwindiss -G @var{num} -pthread}
668 @emph{S/390 and zSeries Options}
669 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
670 -mhard-float -msoft-float -mlong-double-64 -mlong-double-128 @gol
671 -mbackchain -mno-backchain -mpacked-stack -mno-packed-stack @gol
672 -msmall-exec -mno-small-exec -mmvcle -mno-mvcle @gol
673 -m64 -m31 -mdebug -mno-debug -mesa -mzarch @gol
674 -mtpf-trace -mno-tpf-trace -mfused-madd -mno-fused-madd @gol
675 -mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard}
678 @gccoptlist{-meb -mel @gol
682 -mscore5 -mscore5u -mscore7 -mscore7d}
685 @gccoptlist{-m1 -m2 -m2e -m3 -m3e @gol
686 -m4-nofpu -m4-single-only -m4-single -m4 @gol
687 -m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al @gol
688 -m5-64media -m5-64media-nofpu @gol
689 -m5-32media -m5-32media-nofpu @gol
690 -m5-compact -m5-compact-nofpu @gol
691 -mb -ml -mdalign -mrelax @gol
692 -mbigtable -mfmovd -mhitachi -mrenesas -mno-renesas -mnomacsave @gol
693 -mieee -misize -mpadstruct -mspace @gol
694 -mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy} @gol
695 -mdivsi3_libfunc=@var{name} @gol
696 -madjust-unroll -mindexed-addressing -mgettrcost=@var{number} -mpt-fixed @gol
700 @gccoptlist{-mcpu=@var{cpu-type} @gol
701 -mtune=@var{cpu-type} @gol
702 -mcmodel=@var{code-model} @gol
703 -m32 -m64 -mapp-regs -mno-app-regs @gol
704 -mfaster-structs -mno-faster-structs @gol
705 -mfpu -mno-fpu -mhard-float -msoft-float @gol
706 -mhard-quad-float -msoft-quad-float @gol
707 -mimpure-text -mno-impure-text -mlittle-endian @gol
708 -mstack-bias -mno-stack-bias @gol
709 -munaligned-doubles -mno-unaligned-doubles @gol
710 -mv8plus -mno-v8plus -mvis -mno-vis
711 -threads -pthreads -pthread}
713 @emph{System V Options}
714 @gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
716 @emph{TMS320C3x/C4x Options}
717 @gccoptlist{-mcpu=@var{cpu} -mbig -msmall -mregparm -mmemparm @gol
718 -mfast-fix -mmpyi -mbk -mti -mdp-isr-reload @gol
719 -mrpts=@var{count} -mrptb -mdb -mloop-unsigned @gol
720 -mparallel-insns -mparallel-mpy -mpreserve-float}
723 @gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep @gol
724 -mprolog-function -mno-prolog-function -mspace @gol
725 -mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol
726 -mapp-regs -mno-app-regs @gol
727 -mdisable-callt -mno-disable-callt @gol
733 @gccoptlist{-mg -mgnu -munix}
735 @emph{x86-64 Options}
736 See i386 and x86-64 Options.
738 @emph{Xstormy16 Options}
741 @emph{Xtensa Options}
742 @gccoptlist{-mconst16 -mno-const16 @gol
743 -mfused-madd -mno-fused-madd @gol
744 -mtext-section-literals -mno-text-section-literals @gol
745 -mtarget-align -mno-target-align @gol
746 -mlongcalls -mno-longcalls}
748 @emph{zSeries Options}
749 See S/390 and zSeries Options.
751 @item Code Generation Options
752 @xref{Code Gen Options,,Options for Code Generation Conventions}.
753 @gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} @gol
754 -ffixed-@var{reg} -fexceptions @gol
755 -fnon-call-exceptions -funwind-tables @gol
756 -fasynchronous-unwind-tables @gol
757 -finhibit-size-directive -finstrument-functions @gol
758 -fno-common -fno-ident @gol
759 -fpcc-struct-return -fpic -fPIC -fpie -fPIE @gol
760 -fno-jump-tables @gol
761 -freg-struct-return -fshort-enums @gol
762 -fshort-double -fshort-wchar @gol
763 -fverbose-asm -fpack-struct[=@var{n}] -fstack-check @gol
764 -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol
765 -fargument-alias -fargument-noalias @gol
766 -fargument-noalias-global -fargument-noalias-anything
767 -fleading-underscore -ftls-model=@var{model} @gol
768 -ftrapv -fwrapv -fbounds-check @gol
773 * Overall Options:: Controlling the kind of output:
774 an executable, object files, assembler files,
775 or preprocessed source.
776 * C Dialect Options:: Controlling the variant of C language compiled.
777 * C++ Dialect Options:: Variations on C++.
778 * Language Independent Options:: Controlling how diagnostics should be
780 * Warning Options:: How picky should the compiler be?
781 * Debugging Options:: Symbol tables, measurements, and debugging dumps.
782 * Optimize Options:: How much optimization?
783 * Preprocessor Options:: Controlling header files and macro definitions.
784 Also, getting dependency information for Make.
785 * Assembler Options:: Passing options to the assembler.
786 * Link Options:: Specifying libraries and so on.
787 * Directory Options:: Where to find header files and libraries.
788 Where to find the compiler executable files.
789 * Spec Files:: How to pass switches to sub-processes.
790 * Target Options:: Running a cross-compiler, or an old version of GCC.
793 @node Overall Options
794 @section Options Controlling the Kind of Output
796 Compilation can involve up to four stages: preprocessing, compilation
797 proper, assembly and linking, always in that order. GCC is capable of
798 preprocessing and compiling several files either into several
799 assembler input files, or into one assembler input file; then each
800 assembler input file produces an object file, and linking combines all
801 the object files (those newly compiled, and those specified as input)
802 into an executable file.
804 @cindex file name suffix
805 For any given input file, the file name suffix determines what kind of
810 C source code which must be preprocessed.
813 C source code which should not be preprocessed.
816 C++ source code which should not be preprocessed.
819 C, or C++ header file to be turned into a precompiled header.
823 @itemx @var{file}.cxx
824 @itemx @var{file}.cpp
825 @itemx @var{file}.CPP
826 @itemx @var{file}.c++
828 C++ source code which must be preprocessed. Note that in @samp{.cxx},
829 the last two letters must both be literally @samp{x}. Likewise,
830 @samp{.C} refers to a literal capital C@.
834 C++ header file to be turned into a precompiled header.
837 @itemx @var{file}.for
838 @itemx @var{file}.FOR
839 Fixed form Fortran source code which should not be preprocessed.
842 @itemx @var{file}.fpp
843 @itemx @var{file}.FPP
844 Fixed form Fortran source code which must be preprocessed (with the traditional
848 @itemx @var{file}.f95
849 Free form Fortran source code which should not be preprocessed.
852 @itemx @var{file}.F95
853 Free form Fortran source code which must be preprocessed (with the
854 traditional preprocessor).
856 @c FIXME: Descriptions of Java file types.
863 Ada source code file which contains a library unit declaration (a
864 declaration of a package, subprogram, or generic, or a generic
865 instantiation), or a library unit renaming declaration (a package,
866 generic, or subprogram renaming declaration). Such files are also
869 @itemx @var{file}.adb
870 Ada source code file containing a library unit body (a subprogram or
871 package body). Such files are also called @dfn{bodies}.
873 @c GCC also knows about some suffixes for languages not yet included:
884 Assembler code which must be preprocessed.
887 An object file to be fed straight into linking.
888 Any file name with no recognized suffix is treated this way.
892 You can specify the input language explicitly with the @option{-x} option:
895 @item -x @var{language}
896 Specify explicitly the @var{language} for the following input files
897 (rather than letting the compiler choose a default based on the file
898 name suffix). This option applies to all following input files until
899 the next @option{-x} option. Possible values for @var{language} are:
901 c c-header c-cpp-output
902 c++ c++-header c++-cpp-output
903 assembler assembler-with-cpp
911 Turn off any specification of a language, so that subsequent files are
912 handled according to their file name suffixes (as they are if @option{-x}
913 has not been used at all).
915 @item -pass-exit-codes
916 @opindex pass-exit-codes
917 Normally the @command{gcc} program will exit with the code of 1 if any
918 phase of the compiler returns a non-success return code. If you specify
919 @option{-pass-exit-codes}, the @command{gcc} program will instead return with
920 numerically highest error produced by any phase that returned an error
921 indication. The C, C++, and Fortran frontends return 4, if an internal
922 compiler error is encountered.
925 If you only want some of the stages of compilation, you can use
926 @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
927 one of the options @option{-c}, @option{-S}, or @option{-E} to say where
928 @command{gcc} is to stop. Note that some combinations (for example,
929 @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
934 Compile or assemble the source files, but do not link. The linking
935 stage simply is not done. The ultimate output is in the form of an
936 object file for each source file.
938 By default, the object file name for a source file is made by replacing
939 the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
941 Unrecognized input files, not requiring compilation or assembly, are
946 Stop after the stage of compilation proper; do not assemble. The output
947 is in the form of an assembler code file for each non-assembler input
950 By default, the assembler file name for a source file is made by
951 replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
953 Input files that don't require compilation are ignored.
957 Stop after the preprocessing stage; do not run the compiler proper. The
958 output is in the form of preprocessed source code, which is sent to the
961 Input files which don't require preprocessing are ignored.
963 @cindex output file option
966 Place output in file @var{file}. This applies regardless to whatever
967 sort of output is being produced, whether it be an executable file,
968 an object file, an assembler file or preprocessed C code.
970 If @option{-o} is not specified, the default is to put an executable
971 file in @file{a.out}, the object file for
972 @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
973 assembler file in @file{@var{source}.s}, a precompiled header file in
974 @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
979 Print (on standard error output) the commands executed to run the stages
980 of compilation. Also print the version number of the compiler driver
981 program and of the preprocessor and the compiler proper.
985 Like @option{-v} except the commands are not executed and all command
986 arguments are quoted. This is useful for shell scripts to capture the
987 driver-generated command lines.
991 Use pipes rather than temporary files for communication between the
992 various stages of compilation. This fails to work on some systems where
993 the assembler is unable to read from a pipe; but the GNU assembler has
998 If you are compiling multiple source files, this option tells the driver
999 to pass all the source files to the compiler at once (for those
1000 languages for which the compiler can handle this). This will allow
1001 intermodule analysis (IMA) to be performed by the compiler. Currently the only
1002 language for which this is supported is C@. If you pass source files for
1003 multiple languages to the driver, using this option, the driver will invoke
1004 the compiler(s) that support IMA once each, passing each compiler all the
1005 source files appropriate for it. For those languages that do not support
1006 IMA this option will be ignored, and the compiler will be invoked once for
1007 each source file in that language. If you use this option in conjunction
1008 with @option{-save-temps}, the compiler will generate multiple
1010 (one for each source file), but only one (combined) @file{.o} or
1015 Print (on the standard output) a description of the command line options
1016 understood by @command{gcc}. If the @option{-v} option is also specified
1017 then @option{--help} will also be passed on to the various processes
1018 invoked by @command{gcc}, so that they can display the command line options
1019 they accept. If the @option{-Wextra} option is also specified then command
1020 line options which have no documentation associated with them will also
1024 @opindex target-help
1025 Print (on the standard output) a description of target specific command
1026 line options for each tool.
1030 Display the version number and copyrights of the invoked GCC@.
1032 @include @value{srcdir}/../libiberty/at-file.texi
1036 @section Compiling C++ Programs
1038 @cindex suffixes for C++ source
1039 @cindex C++ source file suffixes
1040 C++ source files conventionally use one of the suffixes @samp{.C},
1041 @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
1042 @samp{.cxx}; C++ header files often use @samp{.hh} or @samp{.H}; and
1043 preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
1044 files with these names and compiles them as C++ programs even if you
1045 call the compiler the same way as for compiling C programs (usually
1046 with the name @command{gcc}).
1050 However, the use of @command{gcc} does not add the C++ library.
1051 @command{g++} is a program that calls GCC and treats @samp{.c},
1052 @samp{.h} and @samp{.i} files as C++ source files instead of C source
1053 files unless @option{-x} is used, and automatically specifies linking
1054 against the C++ library. This program is also useful when
1055 precompiling a C header file with a @samp{.h} extension for use in C++
1056 compilations. On many systems, @command{g++} is also installed with
1057 the name @command{c++}.
1059 @cindex invoking @command{g++}
1060 When you compile C++ programs, you may specify many of the same
1061 command-line options that you use for compiling programs in any
1062 language; or command-line options meaningful for C and related
1063 languages; or options that are meaningful only for C++ programs.
1064 @xref{C Dialect Options,,Options Controlling C Dialect}, for
1065 explanations of options for languages related to C@.
1066 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
1067 explanations of options that are meaningful only for C++ programs.
1069 @node C Dialect Options
1070 @section Options Controlling C Dialect
1071 @cindex dialect options
1072 @cindex language dialect options
1073 @cindex options, dialect
1075 The following options control the dialect of C (or languages derived
1076 from C, such as C++) that the compiler accepts:
1079 @cindex ANSI support
1083 In C mode, support all ISO C90 programs. In C++ mode,
1084 remove GNU extensions that conflict with ISO C++.
1086 This turns off certain features of GCC that are incompatible with ISO
1087 C90 (when compiling C code), or of standard C++ (when compiling C++ code),
1088 such as the @code{asm} and @code{typeof} keywords, and
1089 predefined macros such as @code{unix} and @code{vax} that identify the
1090 type of system you are using. It also enables the undesirable and
1091 rarely used ISO trigraph feature. For the C compiler,
1092 it disables recognition of C++ style @samp{//} comments as well as
1093 the @code{inline} keyword.
1095 The alternate keywords @code{__asm__}, @code{__extension__},
1096 @code{__inline__} and @code{__typeof__} continue to work despite
1097 @option{-ansi}. You would not want to use them in an ISO C program, of
1098 course, but it is useful to put them in header files that might be included
1099 in compilations done with @option{-ansi}. Alternate predefined macros
1100 such as @code{__unix__} and @code{__vax__} are also available, with or
1101 without @option{-ansi}.
1103 The @option{-ansi} option does not cause non-ISO programs to be
1104 rejected gratuitously. For that, @option{-pedantic} is required in
1105 addition to @option{-ansi}. @xref{Warning Options}.
1107 The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
1108 option is used. Some header files may notice this macro and refrain
1109 from declaring certain functions or defining certain macros that the
1110 ISO standard doesn't call for; this is to avoid interfering with any
1111 programs that might use these names for other things.
1113 Functions which would normally be built in but do not have semantics
1114 defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
1115 functions with @option{-ansi} is used. @xref{Other Builtins,,Other
1116 built-in functions provided by GCC}, for details of the functions
1121 Determine the language standard. This option is currently only
1122 supported when compiling C or C++. A value for this option must be
1123 provided; possible values are
1128 ISO C90 (same as @option{-ansi}).
1130 @item iso9899:199409
1131 ISO C90 as modified in amendment 1.
1137 ISO C99. Note that this standard is not yet fully supported; see
1138 @w{@uref{http://gcc.gnu.org/gcc-4.2/c99status.html}} for more information. The
1139 names @samp{c9x} and @samp{iso9899:199x} are deprecated.
1142 Default, ISO C90 plus GNU extensions (including some C99 features).
1146 ISO C99 plus GNU extensions. When ISO C99 is fully implemented in GCC,
1147 this will become the default. The name @samp{gnu9x} is deprecated.
1150 The 1998 ISO C++ standard plus amendments.
1153 The same as @option{-std=c++98} plus GNU extensions. This is the
1154 default for C++ code.
1157 Even when this option is not specified, you can still use some of the
1158 features of newer standards in so far as they do not conflict with
1159 previous C standards. For example, you may use @code{__restrict__} even
1160 when @option{-std=c99} is not specified.
1162 The @option{-std} options specifying some version of ISO C have the same
1163 effects as @option{-ansi}, except that features that were not in ISO C90
1164 but are in the specified version (for example, @samp{//} comments and
1165 the @code{inline} keyword in ISO C99) are not disabled.
1167 @xref{Standards,,Language Standards Supported by GCC}, for details of
1168 these standard versions.
1170 @item -fgnu89-inline
1171 @opindex fgnu89-inline
1172 The option @option{-fgnu89-inline} tells GCC to use the traditional
1173 GNU semantics for @code{inline} functions when in C99 mode.
1174 @xref{Inline,,An Inline Function is As Fast As a Macro}. Using this
1175 option is roughly equivalent to adding the @code{gnu_inline} function
1176 attribute to all inline functions (@pxref{Function Attributes}).
1178 This option is accepted by GCC versions 4.1.3 and up. In GCC versions
1179 prior to 4.3, C99 inline semantics are not supported, and thus this
1180 option is effectively assumed to be present regardless of whether or not
1181 it is specified; the only effect of specifying it explicitly is to
1182 disable warnings about using inline functions in C99 mode. Likewise,
1183 the option @option{-fno-gnu89-inline} is not supported in versions of
1184 GCC before 4.3. It will be supported only in C99 or gnu99 mode, not in
1187 The preprocesor macros @code{__GNUC_GNU_INLINE__} and
1188 @code{__GNUC_STDC_INLINE__} may be used to check which semantics are
1189 in effect for @code{inline} functions. @xref{Common Predefined
1190 Macros,,,cpp,The C Preprocessor}.
1192 @item -aux-info @var{filename}
1194 Output to the given filename prototyped declarations for all functions
1195 declared and/or defined in a translation unit, including those in header
1196 files. This option is silently ignored in any language other than C@.
1198 Besides declarations, the file indicates, in comments, the origin of
1199 each declaration (source file and line), whether the declaration was
1200 implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
1201 @samp{O} for old, respectively, in the first character after the line
1202 number and the colon), and whether it came from a declaration or a
1203 definition (@samp{C} or @samp{F}, respectively, in the following
1204 character). In the case of function definitions, a K&R-style list of
1205 arguments followed by their declarations is also provided, inside
1206 comments, after the declaration.
1210 Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
1211 keyword, so that code can use these words as identifiers. You can use
1212 the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
1213 instead. @option{-ansi} implies @option{-fno-asm}.
1215 In C++, this switch only affects the @code{typeof} keyword, since
1216 @code{asm} and @code{inline} are standard keywords. You may want to
1217 use the @option{-fno-gnu-keywords} flag instead, which has the same
1218 effect. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), this
1219 switch only affects the @code{asm} and @code{typeof} keywords, since
1220 @code{inline} is a standard keyword in ISO C99.
1223 @itemx -fno-builtin-@var{function}
1224 @opindex fno-builtin
1225 @cindex built-in functions
1226 Don't recognize built-in functions that do not begin with
1227 @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
1228 functions provided by GCC}, for details of the functions affected,
1229 including those which are not built-in functions when @option{-ansi} or
1230 @option{-std} options for strict ISO C conformance are used because they
1231 do not have an ISO standard meaning.
1233 GCC normally generates special code to handle certain built-in functions
1234 more efficiently; for instance, calls to @code{alloca} may become single
1235 instructions that adjust the stack directly, and calls to @code{memcpy}
1236 may become inline copy loops. The resulting code is often both smaller
1237 and faster, but since the function calls no longer appear as such, you
1238 cannot set a breakpoint on those calls, nor can you change the behavior
1239 of the functions by linking with a different library. In addition,
1240 when a function is recognized as a built-in function, GCC may use
1241 information about that function to warn about problems with calls to
1242 that function, or to generate more efficient code, even if the
1243 resulting code still contains calls to that function. For example,
1244 warnings are given with @option{-Wformat} for bad calls to
1245 @code{printf}, when @code{printf} is built in, and @code{strlen} is
1246 known not to modify global memory.
1248 With the @option{-fno-builtin-@var{function}} option
1249 only the built-in function @var{function} is
1250 disabled. @var{function} must not begin with @samp{__builtin_}. If a
1251 function is named this is not built-in in this version of GCC, this
1252 option is ignored. There is no corresponding
1253 @option{-fbuiltin-@var{function}} option; if you wish to enable
1254 built-in functions selectively when using @option{-fno-builtin} or
1255 @option{-ffreestanding}, you may define macros such as:
1258 #define abs(n) __builtin_abs ((n))
1259 #define strcpy(d, s) __builtin_strcpy ((d), (s))
1264 @cindex hosted environment
1266 Assert that compilation takes place in a hosted environment. This implies
1267 @option{-fbuiltin}. A hosted environment is one in which the
1268 entire standard library is available, and in which @code{main} has a return
1269 type of @code{int}. Examples are nearly everything except a kernel.
1270 This is equivalent to @option{-fno-freestanding}.
1272 @item -ffreestanding
1273 @opindex ffreestanding
1274 @cindex hosted environment
1276 Assert that compilation takes place in a freestanding environment. This
1277 implies @option{-fno-builtin}. A freestanding environment
1278 is one in which the standard library may not exist, and program startup may
1279 not necessarily be at @code{main}. The most obvious example is an OS kernel.
1280 This is equivalent to @option{-fno-hosted}.
1282 @xref{Standards,,Language Standards Supported by GCC}, for details of
1283 freestanding and hosted environments.
1287 @cindex openmp parallel
1288 Enable handling of OpenMP directives @code{#pragma omp} in C/C++ and
1289 @code{!$omp} in Fortran. When @option{-fopenmp} is specified, the
1290 compiler generates parallel code according to the OpenMP Application
1291 Program Interface v2.5 @w{@uref{http://www.openmp.org/}}.
1293 @item -fms-extensions
1294 @opindex fms-extensions
1295 Accept some non-standard constructs used in Microsoft header files.
1297 Some cases of unnamed fields in structures and unions are only
1298 accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
1299 fields within structs/unions}, for details.
1303 Support ISO C trigraphs. The @option{-ansi} option (and @option{-std}
1304 options for strict ISO C conformance) implies @option{-trigraphs}.
1306 @item -no-integrated-cpp
1307 @opindex no-integrated-cpp
1308 Performs a compilation in two passes: preprocessing and compiling. This
1309 option allows a user supplied "cc1", "cc1plus", or "cc1obj" via the
1310 @option{-B} option. The user supplied compilation step can then add in
1311 an additional preprocessing step after normal preprocessing but before
1312 compiling. The default is to use the integrated cpp (internal cpp)
1314 The semantics of this option will change if "cc1", "cc1plus", and
1315 "cc1obj" are merged.
1317 @cindex traditional C language
1318 @cindex C language, traditional
1320 @itemx -traditional-cpp
1321 @opindex traditional-cpp
1322 @opindex traditional
1323 Formerly, these options caused GCC to attempt to emulate a pre-standard
1324 C compiler. They are now only supported with the @option{-E} switch.
1325 The preprocessor continues to support a pre-standard mode. See the GNU
1326 CPP manual for details.
1328 @item -fcond-mismatch
1329 @opindex fcond-mismatch
1330 Allow conditional expressions with mismatched types in the second and
1331 third arguments. The value of such an expression is void. This option
1332 is not supported for C++.
1334 @item -funsigned-char
1335 @opindex funsigned-char
1336 Let the type @code{char} be unsigned, like @code{unsigned char}.
1338 Each kind of machine has a default for what @code{char} should
1339 be. It is either like @code{unsigned char} by default or like
1340 @code{signed char} by default.
1342 Ideally, a portable program should always use @code{signed char} or
1343 @code{unsigned char} when it depends on the signedness of an object.
1344 But many programs have been written to use plain @code{char} and
1345 expect it to be signed, or expect it to be unsigned, depending on the
1346 machines they were written for. This option, and its inverse, let you
1347 make such a program work with the opposite default.
1349 The type @code{char} is always a distinct type from each of
1350 @code{signed char} or @code{unsigned char}, even though its behavior
1351 is always just like one of those two.
1354 @opindex fsigned-char
1355 Let the type @code{char} be signed, like @code{signed char}.
1357 Note that this is equivalent to @option{-fno-unsigned-char}, which is
1358 the negative form of @option{-funsigned-char}. Likewise, the option
1359 @option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
1361 @item -fsigned-bitfields
1362 @itemx -funsigned-bitfields
1363 @itemx -fno-signed-bitfields
1364 @itemx -fno-unsigned-bitfields
1365 @opindex fsigned-bitfields
1366 @opindex funsigned-bitfields
1367 @opindex fno-signed-bitfields
1368 @opindex fno-unsigned-bitfields
1369 These options control whether a bit-field is signed or unsigned, when the
1370 declaration does not use either @code{signed} or @code{unsigned}. By
1371 default, such a bit-field is signed, because this is consistent: the
1372 basic integer types such as @code{int} are signed types.
1375 @node C++ Dialect Options
1376 @section Options Controlling C++ Dialect
1378 @cindex compiler options, C++
1379 @cindex C++ options, command line
1380 @cindex options, C++
1381 This section describes the command-line options that are only meaningful
1382 for C++ programs; but you can also use most of the GNU compiler options
1383 regardless of what language your program is in. For example, you
1384 might compile a file @code{firstClass.C} like this:
1387 g++ -g -frepo -O -c firstClass.C
1391 In this example, only @option{-frepo} is an option meant
1392 only for C++ programs; you can use the other options with any
1393 language supported by GCC@.
1395 Here is a list of options that are @emph{only} for compiling C++ programs:
1399 @item -fabi-version=@var{n}
1400 @opindex fabi-version
1401 Use version @var{n} of the C++ ABI@. Version 2 is the version of the
1402 C++ ABI that first appeared in G++ 3.4. Version 1 is the version of
1403 the C++ ABI that first appeared in G++ 3.2. Version 0 will always be
1404 the version that conforms most closely to the C++ ABI specification.
1405 Therefore, the ABI obtained using version 0 will change as ABI bugs
1408 The default is version 2.
1410 @item -fno-access-control
1411 @opindex fno-access-control
1412 Turn off all access checking. This switch is mainly useful for working
1413 around bugs in the access control code.
1417 Check that the pointer returned by @code{operator new} is non-null
1418 before attempting to modify the storage allocated. This check is
1419 normally unnecessary because the C++ standard specifies that
1420 @code{operator new} will only return @code{0} if it is declared
1421 @samp{throw()}, in which case the compiler will always check the
1422 return value even without this option. In all other cases, when
1423 @code{operator new} has a non-empty exception specification, memory
1424 exhaustion is signalled by throwing @code{std::bad_alloc}. See also
1425 @samp{new (nothrow)}.
1427 @item -fconserve-space
1428 @opindex fconserve-space
1429 Put uninitialized or runtime-initialized global variables into the
1430 common segment, as C does. This saves space in the executable at the
1431 cost of not diagnosing duplicate definitions. If you compile with this
1432 flag and your program mysteriously crashes after @code{main()} has
1433 completed, you may have an object that is being destroyed twice because
1434 two definitions were merged.
1436 This option is no longer useful on most targets, now that support has
1437 been added for putting variables into BSS without making them common.
1439 @item -ffriend-injection
1440 @opindex ffriend-injection
1441 Inject friend functions into the enclosing namespace, so that they are
1442 visible outside the scope of the class in which they are declared.
1443 Friend functions were documented to work this way in the old Annotated
1444 C++ Reference Manual, and versions of G++ before 4.1 always worked
1445 that way. However, in ISO C++ a friend function which is not declared
1446 in an enclosing scope can only be found using argument dependent
1447 lookup. This option causes friends to be injected as they were in
1450 This option is for compatibility, and may be removed in a future
1453 @item -fno-elide-constructors
1454 @opindex fno-elide-constructors
1455 The C++ standard allows an implementation to omit creating a temporary
1456 which is only used to initialize another object of the same type.
1457 Specifying this option disables that optimization, and forces G++ to
1458 call the copy constructor in all cases.
1460 @item -fno-enforce-eh-specs
1461 @opindex fno-enforce-eh-specs
1462 Don't generate code to check for violation of exception specifications
1463 at runtime. This option violates the C++ standard, but may be useful
1464 for reducing code size in production builds, much like defining
1465 @samp{NDEBUG}. This does not give user code permission to throw
1466 exceptions in violation of the exception specifications; the compiler
1467 will still optimize based on the specifications, so throwing an
1468 unexpected exception will result in undefined behavior.
1471 @itemx -fno-for-scope
1473 @opindex fno-for-scope
1474 If @option{-ffor-scope} is specified, the scope of variables declared in
1475 a @i{for-init-statement} is limited to the @samp{for} loop itself,
1476 as specified by the C++ standard.
1477 If @option{-fno-for-scope} is specified, the scope of variables declared in
1478 a @i{for-init-statement} extends to the end of the enclosing scope,
1479 as was the case in old versions of G++, and other (traditional)
1480 implementations of C++.
1482 The default if neither flag is given to follow the standard,
1483 but to allow and give a warning for old-style code that would
1484 otherwise be invalid, or have different behavior.
1486 @item -fno-gnu-keywords
1487 @opindex fno-gnu-keywords
1488 Do not recognize @code{typeof} as a keyword, so that code can use this
1489 word as an identifier. You can use the keyword @code{__typeof__} instead.
1490 @option{-ansi} implies @option{-fno-gnu-keywords}.
1492 @item -fno-implicit-templates
1493 @opindex fno-implicit-templates
1494 Never emit code for non-inline templates which are instantiated
1495 implicitly (i.e.@: by use); only emit code for explicit instantiations.
1496 @xref{Template Instantiation}, for more information.
1498 @item -fno-implicit-inline-templates
1499 @opindex fno-implicit-inline-templates
1500 Don't emit code for implicit instantiations of inline templates, either.
1501 The default is to handle inlines differently so that compiles with and
1502 without optimization will need the same set of explicit instantiations.
1504 @item -fno-implement-inlines
1505 @opindex fno-implement-inlines
1506 To save space, do not emit out-of-line copies of inline functions
1507 controlled by @samp{#pragma implementation}. This will cause linker
1508 errors if these functions are not inlined everywhere they are called.
1510 @item -fms-extensions
1511 @opindex fms-extensions
1512 Disable pedantic warnings about constructs used in MFC, such as implicit
1513 int and getting a pointer to member function via non-standard syntax.
1515 @item -fno-nonansi-builtins
1516 @opindex fno-nonansi-builtins
1517 Disable built-in declarations of functions that are not mandated by
1518 ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
1519 @code{index}, @code{bzero}, @code{conjf}, and other related functions.
1521 @item -fno-operator-names
1522 @opindex fno-operator-names
1523 Do not treat the operator name keywords @code{and}, @code{bitand},
1524 @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
1525 synonyms as keywords.
1527 @item -fno-optional-diags
1528 @opindex fno-optional-diags
1529 Disable diagnostics that the standard says a compiler does not need to
1530 issue. Currently, the only such diagnostic issued by G++ is the one for
1531 a name having multiple meanings within a class.
1534 @opindex fpermissive
1535 Downgrade some diagnostics about nonconformant code from errors to
1536 warnings. Thus, using @option{-fpermissive} will allow some
1537 nonconforming code to compile.
1541 Enable automatic template instantiation at link time. This option also
1542 implies @option{-fno-implicit-templates}. @xref{Template
1543 Instantiation}, for more information.
1547 Disable generation of information about every class with virtual
1548 functions for use by the C++ runtime type identification features
1549 (@samp{dynamic_cast} and @samp{typeid}). If you don't use those parts
1550 of the language, you can save some space by using this flag. Note that
1551 exception handling uses the same information, but it will generate it as
1552 needed. The @samp{dynamic_cast} operator can still be used for casts that
1553 do not require runtime type information, i.e. casts to @code{void *} or to
1554 unambiguous base classes.
1558 Emit statistics about front-end processing at the end of the compilation.
1559 This information is generally only useful to the G++ development team.
1561 @item -ftemplate-depth-@var{n}
1562 @opindex ftemplate-depth
1563 Set the maximum instantiation depth for template classes to @var{n}.
1564 A limit on the template instantiation depth is needed to detect
1565 endless recursions during template class instantiation. ANSI/ISO C++
1566 conforming programs must not rely on a maximum depth greater than 17.
1568 @item -fno-threadsafe-statics
1569 @opindex fno-threadsafe-statics
1570 Do not emit the extra code to use the routines specified in the C++
1571 ABI for thread-safe initialization of local statics. You can use this
1572 option to reduce code size slightly in code that doesn't need to be
1575 @item -fuse-cxa-atexit
1576 @opindex fuse-cxa-atexit
1577 Register destructors for objects with static storage duration with the
1578 @code{__cxa_atexit} function rather than the @code{atexit} function.
1579 This option is required for fully standards-compliant handling of static
1580 destructors, but will only work if your C library supports
1581 @code{__cxa_atexit}.
1583 @item -fno-use-cxa-get-exception-ptr
1584 @opindex fno-use-cxa-get-exception-ptr
1585 Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
1586 will cause @code{std::uncaught_exception} to be incorrect, but is necessary
1587 if the runtime routine is not available.
1589 @item -fvisibility-inlines-hidden
1590 @opindex fvisibility-inlines-hidden
1591 This switch declares that the user does not attempt to compare
1592 pointers to inline methods where the addresses of the two functions
1593 were taken in different shared objects.
1595 The effect of this is that GCC may, effectively, mark inline methods with
1596 @code{__attribute__ ((visibility ("hidden")))} so that they do not
1597 appear in the export table of a DSO and do not require a PLT indirection
1598 when used within the DSO@. Enabling this option can have a dramatic effect
1599 on load and link times of a DSO as it massively reduces the size of the
1600 dynamic export table when the library makes heavy use of templates.
1602 The behaviour of this switch is not quite the same as marking the
1603 methods as hidden directly, because it does not affect static variables
1604 local to the function or cause the compiler to deduce that
1605 the function is defined in only one shared object.
1607 You may mark a method as having a visibility explicitly to negate the
1608 effect of the switch for that method. For example, if you do want to
1609 compare pointers to a particular inline method, you might mark it as
1610 having default visibility. Marking the enclosing class with explicit
1611 visibility will have no effect.
1613 Explicitly instantiated inline methods are unaffected by this option
1614 as their linkage might otherwise cross a shared library boundary.
1615 @xref{Template Instantiation}.
1619 Do not use weak symbol support, even if it is provided by the linker.
1620 By default, G++ will use weak symbols if they are available. This
1621 option exists only for testing, and should not be used by end-users;
1622 it will result in inferior code and has no benefits. This option may
1623 be removed in a future release of G++.
1627 Do not search for header files in the standard directories specific to
1628 C++, but do still search the other standard directories. (This option
1629 is used when building the C++ library.)
1632 In addition, these optimization, warning, and code generation options
1633 have meanings only for C++ programs:
1636 @item -fno-default-inline
1637 @opindex fno-default-inline
1638 Do not assume @samp{inline} for functions defined inside a class scope.
1639 @xref{Optimize Options,,Options That Control Optimization}. Note that these
1640 functions will have linkage like inline functions; they just won't be
1643 @item -Wabi @r{(C++ only)}
1645 Warn when G++ generates code that is probably not compatible with the
1646 vendor-neutral C++ ABI@. Although an effort has been made to warn about
1647 all such cases, there are probably some cases that are not warned about,
1648 even though G++ is generating incompatible code. There may also be
1649 cases where warnings are emitted even though the code that is generated
1652 You should rewrite your code to avoid these warnings if you are
1653 concerned about the fact that code generated by G++ may not be binary
1654 compatible with code generated by other compilers.
1656 The known incompatibilities at this point include:
1661 Incorrect handling of tail-padding for bit-fields. G++ may attempt to
1662 pack data into the same byte as a base class. For example:
1665 struct A @{ virtual void f(); int f1 : 1; @};
1666 struct B : public A @{ int f2 : 1; @};
1670 In this case, G++ will place @code{B::f2} into the same byte
1671 as@code{A::f1}; other compilers will not. You can avoid this problem
1672 by explicitly padding @code{A} so that its size is a multiple of the
1673 byte size on your platform; that will cause G++ and other compilers to
1674 layout @code{B} identically.
1677 Incorrect handling of tail-padding for virtual bases. G++ does not use
1678 tail padding when laying out virtual bases. For example:
1681 struct A @{ virtual void f(); char c1; @};
1682 struct B @{ B(); char c2; @};
1683 struct C : public A, public virtual B @{@};
1687 In this case, G++ will not place @code{B} into the tail-padding for
1688 @code{A}; other compilers will. You can avoid this problem by
1689 explicitly padding @code{A} so that its size is a multiple of its
1690 alignment (ignoring virtual base classes); that will cause G++ and other
1691 compilers to layout @code{C} identically.
1694 Incorrect handling of bit-fields with declared widths greater than that
1695 of their underlying types, when the bit-fields appear in a union. For
1699 union U @{ int i : 4096; @};
1703 Assuming that an @code{int} does not have 4096 bits, G++ will make the
1704 union too small by the number of bits in an @code{int}.
1707 Empty classes can be placed at incorrect offsets. For example:
1717 struct C : public B, public A @{@};
1721 G++ will place the @code{A} base class of @code{C} at a nonzero offset;
1722 it should be placed at offset zero. G++ mistakenly believes that the
1723 @code{A} data member of @code{B} is already at offset zero.
1726 Names of template functions whose types involve @code{typename} or
1727 template template parameters can be mangled incorrectly.
1730 template <typename Q>
1731 void f(typename Q::X) @{@}
1733 template <template <typename> class Q>
1734 void f(typename Q<int>::X) @{@}
1738 Instantiations of these templates may be mangled incorrectly.
1742 @item -Wctor-dtor-privacy @r{(C++ only)}
1743 @opindex Wctor-dtor-privacy
1744 Warn when a class seems unusable because all the constructors or
1745 destructors in that class are private, and it has neither friends nor
1746 public static member functions.
1748 @item -Wnon-virtual-dtor @r{(C++ only)}
1749 @opindex Wnon-virtual-dtor
1750 Warn when a class appears to be polymorphic, thereby requiring a virtual
1751 destructor, yet it declares a non-virtual one. This warning is also
1752 enabled if -Weffc++ is specified.
1754 @item -Wreorder @r{(C++ only)}
1756 @cindex reordering, warning
1757 @cindex warning for reordering of member initializers
1758 Warn when the order of member initializers given in the code does not
1759 match the order in which they must be executed. For instance:
1765 A(): j (0), i (1) @{ @}
1769 The compiler will rearrange the member initializers for @samp{i}
1770 and @samp{j} to match the declaration order of the members, emitting
1771 a warning to that effect. This warning is enabled by @option{-Wall}.
1774 The following @option{-W@dots{}} options are not affected by @option{-Wall}.
1777 @item -Weffc++ @r{(C++ only)}
1779 Warn about violations of the following style guidelines from Scott Meyers'
1780 @cite{Effective C++} book:
1784 Item 11: Define a copy constructor and an assignment operator for classes
1785 with dynamically allocated memory.
1788 Item 12: Prefer initialization to assignment in constructors.
1791 Item 14: Make destructors virtual in base classes.
1794 Item 15: Have @code{operator=} return a reference to @code{*this}.
1797 Item 23: Don't try to return a reference when you must return an object.
1801 Also warn about violations of the following style guidelines from
1802 Scott Meyers' @cite{More Effective C++} book:
1806 Item 6: Distinguish between prefix and postfix forms of increment and
1807 decrement operators.
1810 Item 7: Never overload @code{&&}, @code{||}, or @code{,}.
1814 When selecting this option, be aware that the standard library
1815 headers do not obey all of these guidelines; use @samp{grep -v}
1816 to filter out those warnings.
1818 @item -Wno-deprecated @r{(C++ only)}
1819 @opindex Wno-deprecated
1820 Do not warn about usage of deprecated features. @xref{Deprecated Features}.
1822 @item -Wstrict-null-sentinel @r{(C++ only)}
1823 @opindex Wstrict-null-sentinel
1824 Warn also about the use of an uncasted @code{NULL} as sentinel. When
1825 compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
1826 to @code{__null}. Although it is a null pointer constant not a null pointer,
1827 it is guaranteed to of the same size as a pointer. But this use is
1828 not portable across different compilers.
1830 @item -Wno-non-template-friend @r{(C++ only)}
1831 @opindex Wno-non-template-friend
1832 Disable warnings when non-templatized friend functions are declared
1833 within a template. Since the advent of explicit template specification
1834 support in G++, if the name of the friend is an unqualified-id (i.e.,
1835 @samp{friend foo(int)}), the C++ language specification demands that the
1836 friend declare or define an ordinary, nontemplate function. (Section
1837 14.5.3). Before G++ implemented explicit specification, unqualified-ids
1838 could be interpreted as a particular specialization of a templatized
1839 function. Because this non-conforming behavior is no longer the default
1840 behavior for G++, @option{-Wnon-template-friend} allows the compiler to
1841 check existing code for potential trouble spots and is on by default.
1842 This new compiler behavior can be turned off with
1843 @option{-Wno-non-template-friend} which keeps the conformant compiler code
1844 but disables the helpful warning.
1846 @item -Wold-style-cast @r{(C++ only)}
1847 @opindex Wold-style-cast
1848 Warn if an old-style (C-style) cast to a non-void type is used within
1849 a C++ program. The new-style casts (@samp{dynamic_cast},
1850 @samp{static_cast}, @samp{reinterpret_cast}, and @samp{const_cast}) are
1851 less vulnerable to unintended effects and much easier to search for.
1853 @item -Woverloaded-virtual @r{(C++ only)}
1854 @opindex Woverloaded-virtual
1855 @cindex overloaded virtual fn, warning
1856 @cindex warning for overloaded virtual fn
1857 Warn when a function declaration hides virtual functions from a
1858 base class. For example, in:
1865 struct B: public A @{
1870 the @code{A} class version of @code{f} is hidden in @code{B}, and code
1878 will fail to compile.
1880 @item -Wno-pmf-conversions @r{(C++ only)}
1881 @opindex Wno-pmf-conversions
1882 Disable the diagnostic for converting a bound pointer to member function
1885 @item -Wsign-promo @r{(C++ only)}
1886 @opindex Wsign-promo
1887 Warn when overload resolution chooses a promotion from unsigned or
1888 enumerated type to a signed type, over a conversion to an unsigned type of
1889 the same size. Previous versions of G++ would try to preserve
1890 unsignedness, but the standard mandates the current behavior.
1895 A& operator = (int);
1905 In this example, G++ will synthesize a default @samp{A& operator =
1906 (const A&);}, while cfront will use the user-defined @samp{operator =}.
1909 @node Language Independent Options
1910 @section Options to Control Diagnostic Messages Formatting
1911 @cindex options to control diagnostics formatting
1912 @cindex diagnostic messages
1913 @cindex message formatting
1915 Traditionally, diagnostic messages have been formatted irrespective of
1916 the output device's aspect (e.g.@: its width, @dots{}). The options described
1917 below can be used to control the diagnostic messages formatting
1918 algorithm, e.g.@: how many characters per line, how often source location
1919 information should be reported. Right now, only the C++ front end can
1920 honor these options. However it is expected, in the near future, that
1921 the remaining front ends would be able to digest them correctly.
1924 @item -fmessage-length=@var{n}
1925 @opindex fmessage-length
1926 Try to format error messages so that they fit on lines of about @var{n}
1927 characters. The default is 72 characters for @command{g++} and 0 for the rest of
1928 the front ends supported by GCC@. If @var{n} is zero, then no
1929 line-wrapping will be done; each error message will appear on a single
1932 @opindex fdiagnostics-show-location
1933 @item -fdiagnostics-show-location=once
1934 Only meaningful in line-wrapping mode. Instructs the diagnostic messages
1935 reporter to emit @emph{once} source location information; that is, in
1936 case the message is too long to fit on a single physical line and has to
1937 be wrapped, the source location won't be emitted (as prefix) again,
1938 over and over, in subsequent continuation lines. This is the default
1941 @item -fdiagnostics-show-location=every-line
1942 Only meaningful in line-wrapping mode. Instructs the diagnostic
1943 messages reporter to emit the same source location information (as
1944 prefix) for physical lines that result from the process of breaking
1945 a message which is too long to fit on a single line.
1947 @item -fdiagnostics-show-option
1948 @opindex fdiagnostics-show-option
1949 This option instructs the diagnostic machinery to add text to each
1950 diagnostic emitted, which indicates which command line option directly
1951 controls that diagnostic, when such an option is known to the
1952 diagnostic machinery.
1956 @node Warning Options
1957 @section Options to Request or Suppress Warnings
1958 @cindex options to control warnings
1959 @cindex warning messages
1960 @cindex messages, warning
1961 @cindex suppressing warnings
1963 Warnings are diagnostic messages that report constructions which
1964 are not inherently erroneous but which are risky or suggest there
1965 may have been an error.
1967 You can request many specific warnings with options beginning @samp{-W},
1968 for example @option{-Wimplicit} to request warnings on implicit
1969 declarations. Each of these specific warning options also has a
1970 negative form beginning @samp{-Wno-} to turn off warnings;
1971 for example, @option{-Wno-implicit}. This manual lists only one of the
1972 two forms, whichever is not the default.
1974 The following options control the amount and kinds of warnings produced
1975 by GCC; for further, language-specific options also refer to
1976 @ref{C++ Dialect Options}.
1979 @cindex syntax checking
1981 @opindex fsyntax-only
1982 Check the code for syntax errors, but don't do anything beyond that.
1986 Issue all the warnings demanded by strict ISO C and ISO C++;
1987 reject all programs that use forbidden extensions, and some other
1988 programs that do not follow ISO C and ISO C++. For ISO C, follows the
1989 version of the ISO C standard specified by any @option{-std} option used.
1991 Valid ISO C and ISO C++ programs should compile properly with or without
1992 this option (though a rare few will require @option{-ansi} or a
1993 @option{-std} option specifying the required version of ISO C)@. However,
1994 without this option, certain GNU extensions and traditional C and C++
1995 features are supported as well. With this option, they are rejected.
1997 @option{-pedantic} does not cause warning messages for use of the
1998 alternate keywords whose names begin and end with @samp{__}. Pedantic
1999 warnings are also disabled in the expression that follows
2000 @code{__extension__}. However, only system header files should use
2001 these escape routes; application programs should avoid them.
2002 @xref{Alternate Keywords}.
2004 Some users try to use @option{-pedantic} to check programs for strict ISO
2005 C conformance. They soon find that it does not do quite what they want:
2006 it finds some non-ISO practices, but not all---only those for which
2007 ISO C @emph{requires} a diagnostic, and some others for which
2008 diagnostics have been added.
2010 A feature to report any failure to conform to ISO C might be useful in
2011 some instances, but would require considerable additional work and would
2012 be quite different from @option{-pedantic}. We don't have plans to
2013 support such a feature in the near future.
2015 Where the standard specified with @option{-std} represents a GNU
2016 extended dialect of C, such as @samp{gnu89} or @samp{gnu99}, there is a
2017 corresponding @dfn{base standard}, the version of ISO C on which the GNU
2018 extended dialect is based. Warnings from @option{-pedantic} are given
2019 where they are required by the base standard. (It would not make sense
2020 for such warnings to be given only for features not in the specified GNU
2021 C dialect, since by definition the GNU dialects of C include all
2022 features the compiler supports with the given option, and there would be
2023 nothing to warn about.)
2025 @item -pedantic-errors
2026 @opindex pedantic-errors
2027 Like @option{-pedantic}, except that errors are produced rather than
2032 Inhibit all warning messages.
2036 Inhibit warning messages about the use of @samp{#import}.
2038 @item -Wchar-subscripts
2039 @opindex Wchar-subscripts
2040 Warn if an array subscript has type @code{char}. This is a common cause
2041 of error, as programmers often forget that this type is signed on some
2043 This warning is enabled by @option{-Wall}.
2047 Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*}
2048 comment, or whenever a Backslash-Newline appears in a @samp{//} comment.
2049 This warning is enabled by @option{-Wall}.
2051 @item -Wfatal-errors
2052 @opindex Wfatal-errors
2053 This option causes the compiler to abort compilation on the first error
2054 occurred rather than trying to keep going and printing further error
2059 @opindex ffreestanding
2060 @opindex fno-builtin
2061 Check calls to @code{printf} and @code{scanf}, etc., to make sure that
2062 the arguments supplied have types appropriate to the format string
2063 specified, and that the conversions specified in the format string make
2064 sense. This includes standard functions, and others specified by format
2065 attributes (@pxref{Function Attributes}), in the @code{printf},
2066 @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
2067 not in the C standard) families (or other target-specific families).
2068 Which functions are checked without format attributes having been
2069 specified depends on the standard version selected, and such checks of
2070 functions without the attribute specified are disabled by
2071 @option{-ffreestanding} or @option{-fno-builtin}.
2073 The formats are checked against the format features supported by GNU
2074 libc version 2.2. These include all ISO C90 and C99 features, as well
2075 as features from the Single Unix Specification and some BSD and GNU
2076 extensions. Other library implementations may not support all these
2077 features; GCC does not support warning about features that go beyond a
2078 particular library's limitations. However, if @option{-pedantic} is used
2079 with @option{-Wformat}, warnings will be given about format features not
2080 in the selected standard version (but not for @code{strfmon} formats,
2081 since those are not in any version of the C standard). @xref{C Dialect
2082 Options,,Options Controlling C Dialect}.
2084 Since @option{-Wformat} also checks for null format arguments for
2085 several functions, @option{-Wformat} also implies @option{-Wnonnull}.
2087 @option{-Wformat} is included in @option{-Wall}. For more control over some
2088 aspects of format checking, the options @option{-Wformat-y2k},
2089 @option{-Wno-format-extra-args}, @option{-Wno-format-zero-length},
2090 @option{-Wformat-nonliteral}, @option{-Wformat-security}, and
2091 @option{-Wformat=2} are available, but are not included in @option{-Wall}.
2094 @opindex Wformat-y2k
2095 If @option{-Wformat} is specified, also warn about @code{strftime}
2096 formats which may yield only a two-digit year.
2098 @item -Wno-format-extra-args
2099 @opindex Wno-format-extra-args
2100 If @option{-Wformat} is specified, do not warn about excess arguments to a
2101 @code{printf} or @code{scanf} format function. The C standard specifies
2102 that such arguments are ignored.
2104 Where the unused arguments lie between used arguments that are
2105 specified with @samp{$} operand number specifications, normally
2106 warnings are still given, since the implementation could not know what
2107 type to pass to @code{va_arg} to skip the unused arguments. However,
2108 in the case of @code{scanf} formats, this option will suppress the
2109 warning if the unused arguments are all pointers, since the Single
2110 Unix Specification says that such unused arguments are allowed.
2112 @item -Wno-format-zero-length
2113 @opindex Wno-format-zero-length
2114 If @option{-Wformat} is specified, do not warn about zero-length formats.
2115 The C standard specifies that zero-length formats are allowed.
2117 @item -Wformat-nonliteral
2118 @opindex Wformat-nonliteral
2119 If @option{-Wformat} is specified, also warn if the format string is not a
2120 string literal and so cannot be checked, unless the format function
2121 takes its format arguments as a @code{va_list}.
2123 @item -Wformat-security
2124 @opindex Wformat-security
2125 If @option{-Wformat} is specified, also warn about uses of format
2126 functions that represent possible security problems. At present, this
2127 warns about calls to @code{printf} and @code{scanf} functions where the
2128 format string is not a string literal and there are no format arguments,
2129 as in @code{printf (foo);}. This may be a security hole if the format
2130 string came from untrusted input and contains @samp{%n}. (This is
2131 currently a subset of what @option{-Wformat-nonliteral} warns about, but
2132 in future warnings may be added to @option{-Wformat-security} that are not
2133 included in @option{-Wformat-nonliteral}.)
2137 Enable @option{-Wformat} plus format checks not included in
2138 @option{-Wformat}. Currently equivalent to @samp{-Wformat
2139 -Wformat-nonliteral -Wformat-security -Wformat-y2k}.
2143 Warn about passing a null pointer for arguments marked as
2144 requiring a non-null value by the @code{nonnull} function attribute.
2146 @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
2147 can be disabled with the @option{-Wno-nonnull} option.
2149 @item -Winit-self @r{(C and C++ only)}
2151 Warn about uninitialized variables which are initialized with themselves.
2152 Note this option can only be used with the @option{-Wuninitialized} option,
2153 which in turn only works with @option{-O1} and above.
2155 For example, GCC will warn about @code{i} being uninitialized in the
2156 following snippet only when @option{-Winit-self} has been specified:
2167 @item -Wimplicit-int
2168 @opindex Wimplicit-int
2169 Warn when a declaration does not specify a type.
2170 This warning is enabled by @option{-Wall}.
2172 @item -Wimplicit-function-declaration
2173 @itemx -Werror-implicit-function-declaration
2174 @opindex Wimplicit-function-declaration
2175 @opindex Werror-implicit-function-declaration
2176 Give a warning (or error) whenever a function is used before being
2177 declared. The form @option{-Wno-error-implicit-function-declaration}
2179 This warning is enabled by @option{-Wall} (as a warning, not an error).
2183 Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
2184 This warning is enabled by @option{-Wall}.
2188 Warn if the type of @samp{main} is suspicious. @samp{main} should be a
2189 function with external linkage, returning int, taking either zero
2190 arguments, two, or three arguments of appropriate types.
2191 This warning is enabled by @option{-Wall}.
2193 @item -Wmissing-braces
2194 @opindex Wmissing-braces
2195 Warn if an aggregate or union initializer is not fully bracketed. In
2196 the following example, the initializer for @samp{a} is not fully
2197 bracketed, but that for @samp{b} is fully bracketed.
2200 int a[2][2] = @{ 0, 1, 2, 3 @};
2201 int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
2204 This warning is enabled by @option{-Wall}.
2206 @item -Wmissing-include-dirs @r{(C and C++ only)}
2207 @opindex Wmissing-include-dirs
2208 Warn if a user-supplied include directory does not exist.
2211 @opindex Wparentheses
2212 Warn if parentheses are omitted in certain contexts, such
2213 as when there is an assignment in a context where a truth value
2214 is expected, or when operators are nested whose precedence people
2215 often get confused about. Only the warning for an assignment used as
2216 a truth value is supported when compiling C++; the other warnings are
2217 only supported when compiling C@.
2219 Also warn if a comparison like @samp{x<=y<=z} appears; this is
2220 equivalent to @samp{(x<=y ? 1 : 0) <= z}, which is a different
2221 interpretation from that of ordinary mathematical notation.
2223 Also warn about constructions where there may be confusion to which
2224 @code{if} statement an @code{else} branch belongs. Here is an example of
2239 In C, every @code{else} branch belongs to the innermost possible @code{if}
2240 statement, which in this example is @code{if (b)}. This is often not
2241 what the programmer expected, as illustrated in the above example by
2242 indentation the programmer chose. When there is the potential for this
2243 confusion, GCC will issue a warning when this flag is specified.
2244 To eliminate the warning, add explicit braces around the innermost
2245 @code{if} statement so there is no way the @code{else} could belong to
2246 the enclosing @code{if}. The resulting code would look like this:
2262 This warning is enabled by @option{-Wall}.
2264 @item -Wsequence-point
2265 @opindex Wsequence-point
2266 Warn about code that may have undefined semantics because of violations
2267 of sequence point rules in the C and C++ standards.
2269 The C and C++ standards defines the order in which expressions in a C/C++
2270 program are evaluated in terms of @dfn{sequence points}, which represent
2271 a partial ordering between the execution of parts of the program: those
2272 executed before the sequence point, and those executed after it. These
2273 occur after the evaluation of a full expression (one which is not part
2274 of a larger expression), after the evaluation of the first operand of a
2275 @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
2276 function is called (but after the evaluation of its arguments and the
2277 expression denoting the called function), and in certain other places.
2278 Other than as expressed by the sequence point rules, the order of
2279 evaluation of subexpressions of an expression is not specified. All
2280 these rules describe only a partial order rather than a total order,
2281 since, for example, if two functions are called within one expression
2282 with no sequence point between them, the order in which the functions
2283 are called is not specified. However, the standards committee have
2284 ruled that function calls do not overlap.
2286 It is not specified when between sequence points modifications to the
2287 values of objects take effect. Programs whose behavior depends on this
2288 have undefined behavior; the C and C++ standards specify that ``Between
2289 the previous and next sequence point an object shall have its stored
2290 value modified at most once by the evaluation of an expression.
2291 Furthermore, the prior value shall be read only to determine the value
2292 to be stored.''. If a program breaks these rules, the results on any
2293 particular implementation are entirely unpredictable.
2295 Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
2296 = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
2297 diagnosed by this option, and it may give an occasional false positive
2298 result, but in general it has been found fairly effective at detecting
2299 this sort of problem in programs.
2301 The standard is worded confusingly, therefore there is some debate
2302 over the precise meaning of the sequence point rules in subtle cases.
2303 Links to discussions of the problem, including proposed formal
2304 definitions, may be found on the GCC readings page, at
2305 @w{@uref{http://gcc.gnu.org/readings.html}}.
2307 This warning is enabled by @option{-Wall} for C and C++.
2310 @opindex Wreturn-type
2311 Warn whenever a function is defined with a return-type that defaults to
2312 @code{int}. Also warn about any @code{return} statement with no
2313 return-value in a function whose return-type is not @code{void}.
2315 For C, also warn if the return type of a function has a type qualifier
2316 such as @code{const}. Such a type qualifier has no effect, since the
2317 value returned by a function is not an lvalue. ISO C prohibits
2318 qualified @code{void} return types on function definitions, so such
2319 return types always receive a warning even without this option.
2321 For C++, a function without return type always produces a diagnostic
2322 message, even when @option{-Wno-return-type} is specified. The only
2323 exceptions are @samp{main} and functions defined in system headers.
2325 This warning is enabled by @option{-Wall}.
2329 Warn whenever a @code{switch} statement has an index of enumerated type
2330 and lacks a @code{case} for one or more of the named codes of that
2331 enumeration. (The presence of a @code{default} label prevents this
2332 warning.) @code{case} labels outside the enumeration range also
2333 provoke warnings when this option is used.
2334 This warning is enabled by @option{-Wall}.
2336 @item -Wswitch-default
2337 @opindex Wswitch-switch
2338 Warn whenever a @code{switch} statement does not have a @code{default}
2342 @opindex Wswitch-enum
2343 Warn whenever a @code{switch} statement has an index of enumerated type
2344 and lacks a @code{case} for one or more of the named codes of that
2345 enumeration. @code{case} labels outside the enumeration range also
2346 provoke warnings when this option is used.
2350 Warn if any trigraphs are encountered that might change the meaning of
2351 the program (trigraphs within comments are not warned about).
2352 This warning is enabled by @option{-Wall}.
2354 @item -Wunused-function
2355 @opindex Wunused-function
2356 Warn whenever a static function is declared but not defined or a
2357 non-inline static function is unused.
2358 This warning is enabled by @option{-Wall}.
2360 @item -Wunused-label
2361 @opindex Wunused-label
2362 Warn whenever a label is declared but not used.
2363 This warning is enabled by @option{-Wall}.
2365 To suppress this warning use the @samp{unused} attribute
2366 (@pxref{Variable Attributes}).
2368 @item -Wunused-parameter
2369 @opindex Wunused-parameter
2370 Warn whenever a function parameter is unused aside from its declaration.
2372 To suppress this warning use the @samp{unused} attribute
2373 (@pxref{Variable Attributes}).
2375 @item -Wunused-variable
2376 @opindex Wunused-variable
2377 Warn whenever a local variable or non-constant static variable is unused
2378 aside from its declaration.
2379 This warning is enabled by @option{-Wall}.
2381 To suppress this warning use the @samp{unused} attribute
2382 (@pxref{Variable Attributes}).
2384 @item -Wunused-value
2385 @opindex Wunused-value
2386 Warn whenever a statement computes a result that is explicitly not used.
2387 This warning is enabled by @option{-Wall}.
2389 To suppress this warning cast the expression to @samp{void}.
2393 All the above @option{-Wunused} options combined.
2395 In order to get a warning about an unused function parameter, you must
2396 either specify @samp{-Wextra -Wunused} (note that @samp{-Wall} implies
2397 @samp{-Wunused}), or separately specify @option{-Wunused-parameter}.
2399 @item -Wuninitialized
2400 @opindex Wuninitialized
2401 Warn if an automatic variable is used without first being initialized or
2402 if a variable may be clobbered by a @code{setjmp} call.
2404 These warnings are possible only in optimizing compilation,
2405 because they require data flow information that is computed only
2406 when optimizing. If you do not specify @option{-O}, you will not get
2407 these warnings. Instead, GCC will issue a warning about @option{-Wuninitialized}
2408 requiring @option{-O}.
2410 If you want to warn about code which uses the uninitialized value of the
2411 variable in its own initializer, use the @option{-Winit-self} option.
2413 These warnings occur for individual uninitialized or clobbered
2414 elements of structure, union or array variables as well as for
2415 variables which are uninitialized or clobbered as a whole. They do
2416 not occur for variables or elements declared @code{volatile}. Because
2417 these warnings depend on optimization, the exact variables or elements
2418 for which there are warnings will depend on the precise optimization
2419 options and version of GCC used.
2421 Note that there may be no warning about a variable that is used only
2422 to compute a value that itself is never used, because such
2423 computations may be deleted by data flow analysis before the warnings
2426 These warnings are made optional because GCC is not smart
2427 enough to see all the reasons why the code might be correct
2428 despite appearing to have an error. Here is one example of how
2449 If the value of @code{y} is always 1, 2 or 3, then @code{x} is
2450 always initialized, but GCC doesn't know this. Here is
2451 another common case:
2456 if (change_y) save_y = y, y = new_y;
2458 if (change_y) y = save_y;
2463 This has no bug because @code{save_y} is used only if it is set.
2465 @cindex @code{longjmp} warnings
2466 This option also warns when a non-volatile automatic variable might be
2467 changed by a call to @code{longjmp}. These warnings as well are possible
2468 only in optimizing compilation.
2470 The compiler sees only the calls to @code{setjmp}. It cannot know
2471 where @code{longjmp} will be called; in fact, a signal handler could
2472 call it at any point in the code. As a result, you may get a warning
2473 even when there is in fact no problem because @code{longjmp} cannot
2474 in fact be called at the place which would cause a problem.
2476 Some spurious warnings can be avoided if you declare all the functions
2477 you use that never return as @code{noreturn}. @xref{Function
2480 This warning is enabled by @option{-Wall}.
2482 @item -Wunknown-pragmas
2483 @opindex Wunknown-pragmas
2484 @cindex warning for unknown pragmas
2485 @cindex unknown pragmas, warning
2486 @cindex pragmas, warning of unknown
2487 Warn when a #pragma directive is encountered which is not understood by
2488 GCC@. If this command line option is used, warnings will even be issued
2489 for unknown pragmas in system header files. This is not the case if
2490 the warnings were only enabled by the @option{-Wall} command line option.
2493 @opindex Wno-pragmas
2495 Do not warn about misuses of pragmas, such as incorrect parameters,
2496 invalid syntax, or conflicts between pragmas. See also
2497 @samp{-Wunknown-pragmas}.
2499 @item -Wstrict-aliasing
2500 @opindex Wstrict-aliasing
2501 This option is only active when @option{-fstrict-aliasing} is active.
2502 It warns about code which might break the strict aliasing rules that the
2503 compiler is using for optimization. The warning does not catch all
2504 cases, but does attempt to catch the more common pitfalls. It is
2505 included in @option{-Wall}.
2507 @item -Wstrict-aliasing=2
2508 @opindex Wstrict-aliasing=2
2509 This option is only active when @option{-fstrict-aliasing} is active.
2510 It warns about code which might break the strict aliasing rules that the
2511 compiler is using for optimization. This warning catches more cases than
2512 @option{-Wstrict-aliasing}, but it will also give a warning for some ambiguous
2513 cases that are safe.
2515 @item -Wstrict-overflow
2516 @item -Wstrict-overflow=@var{n}
2517 @opindex Wstrict-overflow
2518 This option is only active when @option{-fstrict-overflow} is active.
2519 It warns about cases where the compiler optimizes based on the
2520 assumption that signed overflow does not occur. Note that it does not
2521 warn about all cases where the code might overflow: it only warns
2522 about cases where the compiler implements some optimization. Thus
2523 this warning depends on the optimization level.
2525 An optimization which assumes that signed overflow does not occur is
2526 perfectly safe if the values of the variables involved are such that
2527 overflow never does, in fact, occur. Therefore this warning can
2528 easily give a false positive: a warning about code which is not
2529 actually a problem. To help focus on important issues, several
2530 warning levels are defined. No warnings are issued for the use of
2531 undefined signed overflow when estimating how many iterations a loop
2532 will require, in particular when determining whether a loop will be
2536 @item -Wstrict-overflow=1
2537 Warn about cases which are both questionable and easy to avoid. For
2538 example: @code{x + 1 > x}; with @option{-fstrict-overflow}, the
2539 compiler will simplify this to @code{1}. This level of
2540 @option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
2541 are not, and must be explicitly requested.
2543 @item -Wstrict-overflow=2
2544 Also warn about other cases where a comparison is simplified to a
2545 constant. For example: @code{abs (x) >= 0}. This can only be
2546 simplified when @option{-fstrict-overflow} is in effect, because
2547 @code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
2548 zero. @option{-Wstrict-overflow} (with no level) is the same as
2549 @option{-Wstrict-overflow=2}.
2551 @item -Wstrict-overflow=3
2552 Also warn about other cases where a comparison is simplified. For
2553 example: @code{x + 1 > 1} will be simplified to @code{x > 0}.
2555 @item -Wstrict-overflow=4
2556 Also warn about other simplifications not covered by the above cases.
2557 For example: @code{(x * 10) / 5} will be simplified to @code{x * 2}.
2559 @item -Wstrict-overflow=5
2560 Also warn about cases where the compiler reduces the magnitude of a
2561 constant involved in a comparison. For example: @code{x + 2 > y} will
2562 be simplified to @code{x + 1 >= y}. This is reported only at the
2563 highest warning level because this simplification applies to many
2564 comparisons, so this warning level will give a very large number of
2570 All of the above @samp{-W} options combined. This enables all the
2571 warnings about constructions that some users consider questionable, and
2572 that are easy to avoid (or modify to prevent the warning), even in
2573 conjunction with macros. This also enables some language-specific
2574 warnings described in @ref{C++ Dialect Options}.
2577 The following @option{-W@dots{}} options are not implied by @option{-Wall}.
2578 Some of them warn about constructions that users generally do not
2579 consider questionable, but which occasionally you might wish to check
2580 for; others warn about constructions that are necessary or hard to avoid
2581 in some cases, and there is no simple way to modify the code to suppress
2588 (This option used to be called @option{-W}. The older name is still
2589 supported, but the newer name is more descriptive.) Print extra warning
2590 messages for these events:
2594 A function can return either with or without a value. (Falling
2595 off the end of the function body is considered returning without
2596 a value.) For example, this function would evoke such a
2610 An expression-statement or the left-hand side of a comma expression
2611 contains no side effects.
2612 To suppress the warning, cast the unused expression to void.
2613 For example, an expression such as @samp{x[i,j]} will cause a warning,
2614 but @samp{x[(void)i,j]} will not.
2617 An unsigned value is compared against zero with @samp{<} or @samp{>=}.
2620 Storage-class specifiers like @code{static} are not the first things in
2621 a declaration. According to the C Standard, this usage is obsolescent.
2624 If @option{-Wall} or @option{-Wunused} is also specified, warn about unused
2628 A comparison between signed and unsigned values could produce an
2629 incorrect result when the signed value is converted to unsigned.
2630 (But don't warn if @option{-Wno-sign-compare} is also specified.)
2633 An aggregate has an initializer which does not initialize all members.
2634 This warning can be independently controlled by
2635 @option{-Wmissing-field-initializers}.
2638 An initialized field without side effects is overridden when using
2639 designated initializers (@pxref{Designated Inits, , Designated
2640 Initializers}). This warning can be independently controlled by
2641 @option{-Woverride-init}.
2644 A function parameter is declared without a type specifier in K&R-style
2652 An empty body occurs in an @samp{if} or @samp{else} statement.
2655 A pointer is compared against integer zero with @samp{<}, @samp{<=},
2656 @samp{>}, or @samp{>=}.
2659 A variable might be changed by @samp{longjmp} or @samp{vfork}.
2661 @item @r{(C++ only)}
2662 An enumerator and a non-enumerator both appear in a conditional expression.
2664 @item @r{(C++ only)}
2665 A non-static reference or non-static @samp{const} member appears in a
2666 class without constructors.
2668 @item @r{(C++ only)}
2669 Ambiguous virtual bases.
2671 @item @r{(C++ only)}
2672 Subscripting an array which has been declared @samp{register}.
2674 @item @r{(C++ only)}
2675 Taking the address of a variable which has been declared @samp{register}.
2677 @item @r{(C++ only)}
2678 A base class is not initialized in a derived class' copy constructor.
2681 @item -Wno-div-by-zero
2682 @opindex Wno-div-by-zero
2683 @opindex Wdiv-by-zero
2684 Do not warn about compile-time integer division by zero. Floating point
2685 division by zero is not warned about, as it can be a legitimate way of
2686 obtaining infinities and NaNs.
2688 @item -Wsystem-headers
2689 @opindex Wsystem-headers
2690 @cindex warnings from system headers
2691 @cindex system headers, warnings from
2692 Print warning messages for constructs found in system header files.
2693 Warnings from system headers are normally suppressed, on the assumption
2694 that they usually do not indicate real problems and would only make the
2695 compiler output harder to read. Using this command line option tells
2696 GCC to emit warnings from system headers as if they occurred in user
2697 code. However, note that using @option{-Wall} in conjunction with this
2698 option will @emph{not} warn about unknown pragmas in system
2699 headers---for that, @option{-Wunknown-pragmas} must also be used.
2702 @opindex Wfloat-equal
2703 Warn if floating point values are used in equality comparisons.
2705 The idea behind this is that sometimes it is convenient (for the
2706 programmer) to consider floating-point values as approximations to
2707 infinitely precise real numbers. If you are doing this, then you need
2708 to compute (by analyzing the code, or in some other way) the maximum or
2709 likely maximum error that the computation introduces, and allow for it
2710 when performing comparisons (and when producing output, but that's a
2711 different problem). In particular, instead of testing for equality, you
2712 would check to see whether the two values have ranges that overlap; and
2713 this is done with the relational operators, so equality comparisons are
2716 @item -Wtraditional @r{(C only)}
2717 @opindex Wtraditional
2718 Warn about certain constructs that behave differently in traditional and
2719 ISO C@. Also warn about ISO C constructs that have no traditional C
2720 equivalent, and/or problematic constructs which should be avoided.
2724 Macro parameters that appear within string literals in the macro body.
2725 In traditional C macro replacement takes place within string literals,
2726 but does not in ISO C@.
2729 In traditional C, some preprocessor directives did not exist.
2730 Traditional preprocessors would only consider a line to be a directive
2731 if the @samp{#} appeared in column 1 on the line. Therefore
2732 @option{-Wtraditional} warns about directives that traditional C
2733 understands but would ignore because the @samp{#} does not appear as the
2734 first character on the line. It also suggests you hide directives like
2735 @samp{#pragma} not understood by traditional C by indenting them. Some
2736 traditional implementations would not recognize @samp{#elif}, so it
2737 suggests avoiding it altogether.
2740 A function-like macro that appears without arguments.
2743 The unary plus operator.
2746 The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating point
2747 constant suffixes. (Traditional C does support the @samp{L} suffix on integer
2748 constants.) Note, these suffixes appear in macros defined in the system
2749 headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
2750 Use of these macros in user code might normally lead to spurious
2751 warnings, however GCC's integrated preprocessor has enough context to
2752 avoid warning in these cases.
2755 A function declared external in one block and then used after the end of
2759 A @code{switch} statement has an operand of type @code{long}.
2762 A non-@code{static} function declaration follows a @code{static} one.
2763 This construct is not accepted by some traditional C compilers.
2766 The ISO type of an integer constant has a different width or
2767 signedness from its traditional type. This warning is only issued if
2768 the base of the constant is ten. I.e.@: hexadecimal or octal values, which
2769 typically represent bit patterns, are not warned about.
2772 Usage of ISO string concatenation is detected.
2775 Initialization of automatic aggregates.
2778 Identifier conflicts with labels. Traditional C lacks a separate
2779 namespace for labels.
2782 Initialization of unions. If the initializer is zero, the warning is
2783 omitted. This is done under the assumption that the zero initializer in
2784 user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
2785 initializer warnings and relies on default initialization to zero in the
2789 Conversions by prototypes between fixed/floating point values and vice
2790 versa. The absence of these prototypes when compiling with traditional
2791 C would cause serious problems. This is a subset of the possible
2792 conversion warnings, for the full set use @option{-Wconversion}.
2795 Use of ISO C style function definitions. This warning intentionally is
2796 @emph{not} issued for prototype declarations or variadic functions
2797 because these ISO C features will appear in your code when using
2798 libiberty's traditional C compatibility macros, @code{PARAMS} and
2799 @code{VPARAMS}. This warning is also bypassed for nested functions
2800 because that feature is already a GCC extension and thus not relevant to
2801 traditional C compatibility.
2804 @item -Wdeclaration-after-statement @r{(C only)}
2805 @opindex Wdeclaration-after-statement
2806 Warn when a declaration is found after a statement in a block. This
2807 construct, known from C++, was introduced with ISO C99 and is by default
2808 allowed in GCC@. It is not supported by ISO C90 and was not supported by
2809 GCC versions before GCC 3.0. @xref{Mixed Declarations}.
2813 Warn if an undefined identifier is evaluated in an @samp{#if} directive.
2815 @item -Wno-endif-labels
2816 @opindex Wno-endif-labels
2817 @opindex Wendif-labels
2818 Do not warn whenever an @samp{#else} or an @samp{#endif} are followed by text.
2822 Warn whenever a local variable shadows another local variable, parameter or
2823 global variable or whenever a built-in function is shadowed.
2825 @item -Wlarger-than-@var{len}
2826 @opindex Wlarger-than
2827 Warn whenever an object of larger than @var{len} bytes is defined.
2829 @item -Wunsafe-loop-optimizations
2830 @opindex Wunsafe-loop-optimizations
2831 Warn if the loop cannot be optimized because the compiler could not
2832 assume anything on the bounds of the loop indices. With
2833 @option{-funsafe-loop-optimizations} warn if the compiler made
2836 @item -Wpointer-arith
2837 @opindex Wpointer-arith
2838 Warn about anything that depends on the ``size of'' a function type or
2839 of @code{void}. GNU C assigns these types a size of 1, for
2840 convenience in calculations with @code{void *} pointers and pointers
2843 @item -Wbad-function-cast @r{(C only)}
2844 @opindex Wbad-function-cast
2845 Warn whenever a function call is cast to a non-matching type.
2846 For example, warn if @code{int malloc()} is cast to @code{anything *}.
2849 Warn about ISO C constructs that are outside of the common subset of
2850 ISO C and ISO C++, e.g.@: request for implicit conversion from
2851 @code{void *} to a pointer to non-@code{void} type.
2855 Warn whenever a pointer is cast so as to remove a type qualifier from
2856 the target type. For example, warn if a @code{const char *} is cast
2857 to an ordinary @code{char *}.
2860 @opindex Wcast-align
2861 Warn whenever a pointer is cast such that the required alignment of the
2862 target is increased. For example, warn if a @code{char *} is cast to
2863 an @code{int *} on machines where integers can only be accessed at
2864 two- or four-byte boundaries.
2866 @item -Wwrite-strings
2867 @opindex Wwrite-strings
2868 When compiling C, give string constants the type @code{const
2869 char[@var{length}]} so that
2870 copying the address of one into a non-@code{const} @code{char *}
2871 pointer will get a warning; when compiling C++, warn about the
2872 deprecated conversion from string literals to @code{char *}. This
2873 warning, by default, is enabled for C++ programs.
2874 These warnings will help you find at
2875 compile time code that can try to write into a string constant, but
2876 only if you have been very careful about using @code{const} in
2877 declarations and prototypes. Otherwise, it will just be a nuisance;
2878 this is why we did not make @option{-Wall} request these warnings.
2881 @opindex Wconversion
2882 Warn if a prototype causes a type conversion that is different from what
2883 would happen to the same argument in the absence of a prototype. This
2884 includes conversions of fixed point to floating and vice versa, and
2885 conversions changing the width or signedness of a fixed point argument
2886 except when the same as the default promotion.
2888 Also, warn if a negative integer constant expression is implicitly
2889 converted to an unsigned type. For example, warn about the assignment
2890 @code{x = -1} if @code{x} is unsigned. But do not warn about explicit
2891 casts like @code{(unsigned) -1}.
2893 @item -Wsign-compare
2894 @opindex Wsign-compare
2895 @cindex warning for comparison of signed and unsigned values
2896 @cindex comparison of signed and unsigned values, warning
2897 @cindex signed and unsigned values, comparison warning
2898 Warn when a comparison between signed and unsigned values could produce
2899 an incorrect result when the signed value is converted to unsigned.
2900 This warning is also enabled by @option{-Wextra}; to get the other warnings
2901 of @option{-Wextra} without this warning, use @samp{-Wextra -Wno-sign-compare}.
2905 @opindex Wno-address
2906 Warn about suspicious uses of memory addresses. These include using
2907 the address of a function in a conditional expression, such as
2908 @code{void func(void); if (func)}, and comparisons against the memory
2909 address of a string literal, such as @code{if (x == "abc")}. Such
2910 uses typically indicate a programmer error: the address of a function
2911 always evaluates to true, so their use in a conditional usually
2912 indicate that the programmer forgot the parentheses in a function
2913 call; and comparisons against string literals result in unspecified
2914 behavior and are not portable in C, so they usually indicate that the
2915 programmer intended to use @code{strcmp}. This warning is enabled by
2918 @item -Waggregate-return
2919 @opindex Waggregate-return
2920 Warn if any functions that return structures or unions are defined or
2921 called. (In languages where you can return an array, this also elicits
2924 @item -Wno-attributes
2925 @opindex Wno-attributes
2926 @opindex Wattributes
2927 Do not warn if an unexpected @code{__attribute__} is used, such as
2928 unrecognized attributes, function attributes applied to variables,
2929 etc. This will not stop errors for incorrect use of supported
2932 @item -Wstrict-prototypes @r{(C only)}
2933 @opindex Wstrict-prototypes
2934 Warn if a function is declared or defined without specifying the
2935 argument types. (An old-style function definition is permitted without
2936 a warning if preceded by a declaration which specifies the argument
2939 @item -Wold-style-definition @r{(C only)}
2940 @opindex Wold-style-definition
2941 Warn if an old-style function definition is used. A warning is given
2942 even if there is a previous prototype.
2944 @item -Wmissing-prototypes @r{(C only)}
2945 @opindex Wmissing-prototypes
2946 Warn if a global function is defined without a previous prototype
2947 declaration. This warning is issued even if the definition itself
2948 provides a prototype. The aim is to detect global functions that fail
2949 to be declared in header files.
2951 @item -Wmissing-declarations @r{(C only)}
2952 @opindex Wmissing-declarations
2953 Warn if a global function is defined without a previous declaration.
2954 Do so even if the definition itself provides a prototype.
2955 Use this option to detect global functions that are not declared in
2958 @item -Wmissing-field-initializers
2959 @opindex Wmissing-field-initializers
2962 Warn if a structure's initializer has some fields missing. For
2963 example, the following code would cause such a warning, because
2964 @code{x.h} is implicitly zero:
2967 struct s @{ int f, g, h; @};
2968 struct s x = @{ 3, 4 @};
2971 This option does not warn about designated initializers, so the following
2972 modification would not trigger a warning:
2975 struct s @{ int f, g, h; @};
2976 struct s x = @{ .f = 3, .g = 4 @};
2979 This warning is included in @option{-Wextra}. To get other @option{-Wextra}
2980 warnings without this one, use @samp{-Wextra -Wno-missing-field-initializers}.
2982 @item -Wmissing-noreturn
2983 @opindex Wmissing-noreturn
2984 Warn about functions which might be candidates for attribute @code{noreturn}.
2985 Note these are only possible candidates, not absolute ones. Care should
2986 be taken to manually verify functions actually do not ever return before
2987 adding the @code{noreturn} attribute, otherwise subtle code generation
2988 bugs could be introduced. You will not get a warning for @code{main} in
2989 hosted C environments.
2991 @item -Wmissing-format-attribute
2992 @opindex Wmissing-format-attribute
2994 Warn about function pointers which might be candidates for @code{format}
2995 attributes. Note these are only possible candidates, not absolute ones.
2996 GCC will guess that function pointers with @code{format} attributes that
2997 are used in assignment, initialization, parameter passing or return
2998 statements should have a corresponding @code{format} attribute in the
2999 resulting type. I.e.@: the left-hand side of the assignment or
3000 initialization, the type of the parameter variable, or the return type
3001 of the containing function respectively should also have a @code{format}
3002 attribute to avoid the warning.
3004 GCC will also warn about function definitions which might be
3005 candidates for @code{format} attributes. Again, these are only
3006 possible candidates. GCC will guess that @code{format} attributes
3007 might be appropriate for any function that calls a function like
3008 @code{vprintf} or @code{vscanf}, but this might not always be the
3009 case, and some functions for which @code{format} attributes are
3010 appropriate may not be detected.
3012 @item -Wno-multichar
3013 @opindex Wno-multichar
3015 Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
3016 Usually they indicate a typo in the user's code, as they have
3017 implementation-defined values, and should not be used in portable code.
3019 @item -Wnormalized=<none|id|nfc|nfkc>
3020 @opindex Wnormalized
3023 @cindex character set, input normalization
3024 In ISO C and ISO C++, two identifiers are different if they are
3025 different sequences of characters. However, sometimes when characters
3026 outside the basic ASCII character set are used, you can have two
3027 different character sequences that look the same. To avoid confusion,
3028 the ISO 10646 standard sets out some @dfn{normalization rules} which
3029 when applied ensure that two sequences that look the same are turned into
3030 the same sequence. GCC can warn you if you are using identifiers which
3031 have not been normalized; this option controls that warning.
3033 There are four levels of warning that GCC supports. The default is
3034 @option{-Wnormalized=nfc}, which warns about any identifier which is
3035 not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
3036 recommended form for most uses.
3038 Unfortunately, there are some characters which ISO C and ISO C++ allow
3039 in identifiers that when turned into NFC aren't allowable as
3040 identifiers. That is, there's no way to use these symbols in portable
3041 ISO C or C++ and have all your identifiers in NFC.
3042 @option{-Wnormalized=id} suppresses the warning for these characters.
3043 It is hoped that future versions of the standards involved will correct
3044 this, which is why this option is not the default.
3046 You can switch the warning off for all characters by writing
3047 @option{-Wnormalized=none}. You would only want to do this if you
3048 were using some other normalization scheme (like ``D''), because
3049 otherwise you can easily create bugs that are literally impossible to see.
3051 Some characters in ISO 10646 have distinct meanings but look identical
3052 in some fonts or display methodologies, especially once formatting has
3053 been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
3054 LETTER N'', will display just like a regular @code{n} which has been
3055 placed in a superscript. ISO 10646 defines the @dfn{NFKC}
3056 normalization scheme to convert all these into a standard form as
3057 well, and GCC will warn if your code is not in NFKC if you use
3058 @option{-Wnormalized=nfkc}. This warning is comparable to warning
3059 about every identifier that contains the letter O because it might be
3060 confused with the digit 0, and so is not the default, but may be
3061 useful as a local coding convention if the programming environment is
3062 unable to be fixed to display these characters distinctly.
3064 @item -Wno-deprecated-declarations
3065 @opindex Wno-deprecated-declarations
3066 Do not warn about uses of functions (@pxref{Function Attributes}),
3067 variables (@pxref{Variable Attributes}), and types (@pxref{Type
3068 Attributes}) marked as deprecated by using the @code{deprecated}
3072 @opindex Wno-overflow
3073 Do not warn about compile-time overflow in constant expressions.
3075 @item -Woverride-init
3076 @opindex Woverride-init
3079 Warn if an initialized field without side effects is overridden when
3080 using designated initializers (@pxref{Designated Inits, , Designated
3083 This warning is included in @option{-Wextra}. To get other
3084 @option{-Wextra} warnings without this one, use @samp{-Wextra
3085 -Wno-override-init}.
3089 Warn if a structure is given the packed attribute, but the packed
3090 attribute has no effect on the layout or size of the structure.
3091 Such structures may be mis-aligned for little benefit. For
3092 instance, in this code, the variable @code{f.x} in @code{struct bar}
3093 will be misaligned even though @code{struct bar} does not itself
3094 have the packed attribute:
3101 @} __attribute__((packed));
3111 Warn if padding is included in a structure, either to align an element
3112 of the structure or to align the whole structure. Sometimes when this
3113 happens it is possible to rearrange the fields of the structure to
3114 reduce the padding and so make the structure smaller.
3116 @item -Wredundant-decls
3117 @opindex Wredundant-decls
3118 Warn if anything is declared more than once in the same scope, even in
3119 cases where multiple declaration is valid and changes nothing.
3121 @item -Wnested-externs @r{(C only)}
3122 @opindex Wnested-externs
3123 Warn if an @code{extern} declaration is encountered within a function.
3125 @item -Wunreachable-code
3126 @opindex Wunreachable-code
3127 Warn if the compiler detects that code will never be executed.
3129 This option is intended to warn when the compiler detects that at
3130 least a whole line of source code will never be executed, because
3131 some condition is never satisfied or because it is after a
3132 procedure that never returns.
3134 It is possible for this option to produce a warning even though there
3135 are circumstances under which part of the affected line can be executed,
3136 so care should be taken when removing apparently-unreachable code.
3138 For instance, when a function is inlined, a warning may mean that the
3139 line is unreachable in only one inlined copy of the function.
3141 This option is not made part of @option{-Wall} because in a debugging
3142 version of a program there is often substantial code which checks
3143 correct functioning of the program and is, hopefully, unreachable
3144 because the program does work. Another common use of unreachable
3145 code is to provide behavior which is selectable at compile-time.
3149 Warn if a function can not be inlined and it was declared as inline.
3150 Even with this option, the compiler will not warn about failures to
3151 inline functions declared in system headers.
3153 The compiler uses a variety of heuristics to determine whether or not
3154 to inline a function. For example, the compiler takes into account
3155 the size of the function being inlined and the amount of inlining
3156 that has already been done in the current function. Therefore,
3157 seemingly insignificant changes in the source program can cause the
3158 warnings produced by @option{-Winline} to appear or disappear.
3160 @item -Wno-invalid-offsetof @r{(C++ only)}
3161 @opindex Wno-invalid-offsetof
3162 Suppress warnings from applying the @samp{offsetof} macro to a non-POD
3163 type. According to the 1998 ISO C++ standard, applying @samp{offsetof}
3164 to a non-POD type is undefined. In existing C++ implementations,
3165 however, @samp{offsetof} typically gives meaningful results even when
3166 applied to certain kinds of non-POD types. (Such as a simple
3167 @samp{struct} that fails to be a POD type only by virtue of having a
3168 constructor.) This flag is for users who are aware that they are
3169 writing nonportable code and who have deliberately chosen to ignore the
3172 The restrictions on @samp{offsetof} may be relaxed in a future version
3173 of the C++ standard.
3175 @item -Wno-int-to-pointer-cast @r{(C only)}
3176 @opindex Wno-int-to-pointer-cast
3177 Suppress warnings from casts to pointer type of an integer of a
3180 @item -Wno-pointer-to-int-cast @r{(C only)}
3181 @opindex Wno-pointer-to-int-cast
3182 Suppress warnings from casts from a pointer to an integer type of a
3186 @opindex Winvalid-pch
3187 Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
3188 the search path but can't be used.
3192 @opindex Wno-long-long
3193 Warn if @samp{long long} type is used. This is default. To inhibit
3194 the warning messages, use @option{-Wno-long-long}. Flags
3195 @option{-Wlong-long} and @option{-Wno-long-long} are taken into account
3196 only when @option{-pedantic} flag is used.
3198 @item -Wvariadic-macros
3199 @opindex Wvariadic-macros
3200 @opindex Wno-variadic-macros
3201 Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU
3202 alternate syntax when in pedantic ISO C99 mode. This is default.
3203 To inhibit the warning messages, use @option{-Wno-variadic-macros}.
3205 @item -Wvolatile-register-var
3206 @opindex Wvolatile-register-var
3207 @opindex Wno-volatile-register-var
3208 Warn if a register variable is declared volatile. The volatile
3209 modifier does not inhibit all optimizations that may eliminate reads
3210 and/or writes to register variables.
3212 @item -Wdisabled-optimization
3213 @opindex Wdisabled-optimization
3214 Warn if a requested optimization pass is disabled. This warning does
3215 not generally indicate that there is anything wrong with your code; it
3216 merely indicates that GCC's optimizers were unable to handle the code
3217 effectively. Often, the problem is that your code is too big or too
3218 complex; GCC will refuse to optimize programs when the optimization
3219 itself is likely to take inordinate amounts of time.
3221 @item -Wpointer-sign
3222 @opindex Wpointer-sign
3223 @opindex Wno-pointer-sign
3224 Warn for pointer argument passing or assignment with different signedness.
3225 This option is only supported for C. It is implied by @option{-Wall}
3226 and by @option{-pedantic}, which can be disabled with
3227 @option{-Wno-pointer-sign}.
3231 Make all warnings into errors.
3235 Make the specified warning into an errors. The specifier for a
3236 warning is appended, for example @option{-Werror=switch} turns the
3237 warnings controlled by @option{-Wswitch} into errors. This switch
3238 takes a negative form, to be used to negate @option{-Werror} for
3239 specific warnings, for example @option{-Wno-error=switch} makes
3240 @option{-Wswitch} warnings not be errors, even when @option{-Werror}
3241 is in effect. You can use the @option{-fdiagnostics-show-option}
3242 option to have each controllable warning amended with the option which
3243 controls it, to determine what to use with this option.
3245 Note that specifying @option{-Werror=}@var{foo} automatically implies
3246 @option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
3249 @item -Wstack-protector
3250 @opindex Wstack-protector
3251 This option is only active when @option{-fstack-protector} is active. It
3252 warns about functions that will not be protected against stack smashing.
3254 @item -Woverlength-strings
3255 @opindex Woverlength-strings
3256 Warn about string constants which are longer than the ``minimum
3257 maximum'' length specified in the C standard. Modern compilers
3258 generally allow string constants which are much longer than the
3259 standard's minimum limit, but very portable programs should avoid
3260 using longer strings.
3262 The limit applies @emph{after} string constant concatenation, and does
3263 not count the trailing NUL@. In C89, the limit was 509 characters; in
3264 C99, it was raised to 4095. C++98 does not specify a normative
3265 minimum maximum, so we do not diagnose overlength strings in C++@.
3267 This option is implied by @option{-pedantic}, and can be disabled with
3268 @option{-Wno-overlength-strings}.
3271 @node Debugging Options
3272 @section Options for Debugging Your Program or GCC
3273 @cindex options, debugging
3274 @cindex debugging information options
3276 GCC has various special options that are used for debugging
3277 either your program or GCC:
3282 Produce debugging information in the operating system's native format
3283 (stabs, COFF, XCOFF, or DWARF 2)@. GDB can work with this debugging
3286 On most systems that use stabs format, @option{-g} enables use of extra
3287 debugging information that only GDB can use; this extra information
3288 makes debugging work better in GDB but will probably make other debuggers
3290 refuse to read the program. If you want to control for certain whether
3291 to generate the extra information, use @option{-gstabs+}, @option{-gstabs},
3292 @option{-gxcoff+}, @option{-gxcoff}, or @option{-gvms} (see below).
3294 GCC allows you to use @option{-g} with
3295 @option{-O}. The shortcuts taken by optimized code may occasionally
3296 produce surprising results: some variables you declared may not exist
3297 at all; flow of control may briefly move where you did not expect it;
3298 some statements may not be executed because they compute constant
3299 results or their values were already at hand; some statements may
3300 execute in different places because they were moved out of loops.
3302 Nevertheless it proves possible to debug optimized output. This makes
3303 it reasonable to use the optimizer for programs that might have bugs.
3305 The following options are useful when GCC is generated with the
3306 capability for more than one debugging format.
3310 Produce debugging information for use by GDB@. This means to use the
3311 most expressive format available (DWARF 2, stabs, or the native format
3312 if neither of those are supported), including GDB extensions if at all
3317 Produce debugging information in stabs format (if that is supported),
3318 without GDB extensions. This is the format used by DBX on most BSD
3319 systems. On MIPS, Alpha and System V Release 4 systems this option
3320 produces stabs debugging output which is not understood by DBX or SDB@.
3321 On System V Release 4 systems this option requires the GNU assembler.
3323 @item -feliminate-unused-debug-symbols
3324 @opindex feliminate-unused-debug-symbols
3325 Produce debugging information in stabs format (if that is supported),
3326 for only symbols that are actually used.
3328 @item -femit-class-debug-always
3329 Instead of emitting debugging information for a C++ class in only one
3330 object file, emit it in all object files using the class. This option
3331 should be used only with debuggers that are unable to handle the way GCC
3332 normally emits debugging information for classes because using this
3333 option will increase the size of debugging information by as much as a
3338 Produce debugging information in stabs format (if that is supported),
3339 using GNU extensions understood only by the GNU debugger (GDB)@. The
3340 use of these extensions is likely to make other debuggers crash or
3341 refuse to read the program.
3345 Produce debugging information in COFF format (if that is supported).
3346 This is the format used by SDB on most System V systems prior to
3351 Produce debugging information in XCOFF format (if that is supported).
3352 This is the format used by the DBX debugger on IBM RS/6000 systems.
3356 Produce debugging information in XCOFF format (if that is supported),
3357 using GNU extensions understood only by the GNU debugger (GDB)@. The
3358 use of these extensions is likely to make other debuggers crash or
3359 refuse to read the program, and may cause assemblers other than the GNU
3360 assembler (GAS) to fail with an error.
3364 Produce debugging information in DWARF version 2 format (if that is
3365 supported). This is the format used by DBX on IRIX 6. With this
3366 option, GCC uses features of DWARF version 3 when they are useful;
3367 version 3 is upward compatible with version 2, but may still cause
3368 problems for older debuggers.
3372 Produce debugging information in VMS debug format (if that is
3373 supported). This is the format used by DEBUG on VMS systems.
3376 @itemx -ggdb@var{level}
3377 @itemx -gstabs@var{level}
3378 @itemx -gcoff@var{level}
3379 @itemx -gxcoff@var{level}
3380 @itemx -gvms@var{level}
3381 Request debugging information and also use @var{level} to specify how
3382 much information. The default level is 2.
3384 Level 1 produces minimal information, enough for making backtraces in
3385 parts of the program that you don't plan to debug. This includes
3386 descriptions of functions and external variables, but no information
3387 about local variables and no line numbers.
3389 Level 3 includes extra information, such as all the macro definitions
3390 present in the program. Some debuggers support macro expansion when
3391 you use @option{-g3}.
3393 @option{-gdwarf-2} does not accept a concatenated debug level, because
3394 GCC used to support an option @option{-gdwarf} that meant to generate
3395 debug information in version 1 of the DWARF format (which is very
3396 different from version 2), and it would have been too confusing. That
3397 debug format is long obsolete, but the option cannot be changed now.
3398 Instead use an additional @option{-g@var{level}} option to change the
3399 debug level for DWARF2.
3401 @item -feliminate-dwarf2-dups
3402 @opindex feliminate-dwarf2-dups
3403 Compress DWARF2 debugging information by eliminating duplicated
3404 information about each symbol. This option only makes sense when
3405 generating DWARF2 debugging information with @option{-gdwarf-2}.
3407 @cindex @command{prof}
3410 Generate extra code to write profile information suitable for the
3411 analysis program @command{prof}. You must use this option when compiling
3412 the source files you want data about, and you must also use it when
3415 @cindex @command{gprof}
3418 Generate extra code to write profile information suitable for the
3419 analysis program @command{gprof}. You must use this option when compiling
3420 the source files you want data about, and you must also use it when
3425 Makes the compiler print out each function name as it is compiled, and
3426 print some statistics about each pass when it finishes.
3429 @opindex ftime-report
3430 Makes the compiler print some statistics about the time consumed by each
3431 pass when it finishes.
3434 @opindex fmem-report
3435 Makes the compiler print some statistics about permanent memory
3436 allocation when it finishes.
3438 @item -fprofile-arcs
3439 @opindex fprofile-arcs
3440 Add code so that program flow @dfn{arcs} are instrumented. During
3441 execution the program records how many times each branch and call is
3442 executed and how many times it is taken or returns. When the compiled
3443 program exits it saves this data to a file called
3444 @file{@var{auxname}.gcda} for each source file. The data may be used for
3445 profile-directed optimizations (@option{-fbranch-probabilities}), or for
3446 test coverage analysis (@option{-ftest-coverage}). Each object file's
3447 @var{auxname} is generated from the name of the output file, if
3448 explicitly specified and it is not the final executable, otherwise it is
3449 the basename of the source file. In both cases any suffix is removed
3450 (e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
3451 @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
3452 @xref{Cross-profiling}.
3454 @cindex @command{gcov}
3458 This option is used to compile and link code instrumented for coverage
3459 analysis. The option is a synonym for @option{-fprofile-arcs}
3460 @option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
3461 linking). See the documentation for those options for more details.
3466 Compile the source files with @option{-fprofile-arcs} plus optimization
3467 and code generation options. For test coverage analysis, use the
3468 additional @option{-ftest-coverage} option. You do not need to profile
3469 every source file in a program.
3472 Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
3473 (the latter implies the former).
3476 Run the program on a representative workload to generate the arc profile
3477 information. This may be repeated any number of times. You can run
3478 concurrent instances of your program, and provided that the file system
3479 supports locking, the data files will be correctly updated. Also
3480 @code{fork} calls are detected and correctly handled (double counting
3484 For profile-directed optimizations, compile the source files again with
3485 the same optimization and code generation options plus
3486 @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
3487 Control Optimization}).
3490 For test coverage analysis, use @command{gcov} to produce human readable
3491 information from the @file{.gcno} and @file{.gcda} files. Refer to the
3492 @command{gcov} documentation for further information.
3496 With @option{-fprofile-arcs}, for each function of your program GCC
3497 creates a program flow graph, then finds a spanning tree for the graph.
3498 Only arcs that are not on the spanning tree have to be instrumented: the
3499 compiler adds code to count the number of times that these arcs are
3500 executed. When an arc is the only exit or only entrance to a block, the
3501 instrumentation code can be added to the block; otherwise, a new basic
3502 block must be created to hold the instrumentation code.
3505 @item -ftest-coverage
3506 @opindex ftest-coverage
3507 Produce a notes file that the @command{gcov} code-coverage utility
3508 (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
3509 show program coverage. Each source file's note file is called
3510 @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
3511 above for a description of @var{auxname} and instructions on how to
3512 generate test coverage data. Coverage data will match the source files
3513 more closely, if you do not optimize.
3515 @item -d@var{letters}
3516 @item -fdump-rtl-@var{pass}
3518 Says to make debugging dumps during compilation at times specified by
3519 @var{letters}. This is used for debugging the RTL-based passes of the
3520 compiler. The file names for most of the dumps are made by appending a
3521 pass number and a word to the @var{dumpname}. @var{dumpname} is generated
3522 from the name of the output file, if explicitly specified and it is not
3523 an executable, otherwise it is the basename of the source file.
3525 Most debug dumps can be enabled either passing a letter to the @option{-d}
3526 option, or with a long @option{-fdump-rtl} switch; here are the possible
3527 letters for use in @var{letters} and @var{pass}, and their meanings:
3532 Annotate the assembler output with miscellaneous debugging information.
3535 @itemx -fdump-rtl-bbro
3537 @opindex fdump-rtl-bbro
3538 Dump after block reordering, to @file{@var{file}.148r.bbro}.
3541 @itemx -fdump-rtl-combine
3543 @opindex fdump-rtl-combine
3544 Dump after instruction combination, to the file @file{@var{file}.129r.combine}.
3547 @itemx -fdump-rtl-ce1
3548 @itemx -fdump-rtl-ce2
3550 @opindex fdump-rtl-ce1
3551 @opindex fdump-rtl-ce2
3552 @option{-dC} and @option{-fdump-rtl-ce1} enable dumping after the
3553 first if conversion, to the file @file{@var{file}.117r.ce1}. @option{-dC}
3554 and @option{-fdump-rtl-ce2} enable dumping after the second if
3555 conversion, to the file @file{@var{file}.130r.ce2}.
3558 @itemx -fdump-rtl-btl
3559 @itemx -fdump-rtl-dbr
3561 @opindex fdump-rtl-btl
3562 @opindex fdump-rtl-dbr
3563 @option{-dd} and @option{-fdump-rtl-btl} enable dumping after branch
3564 target load optimization, to @file{@var{file}.31.btl}. @option{-dd}
3565 and @option{-fdump-rtl-dbr} enable dumping after delayed branch
3566 scheduling, to @file{@var{file}.36.dbr}.
3570 Dump all macro definitions, at the end of preprocessing, in addition to
3574 @itemx -fdump-rtl-ce3
3576 @opindex fdump-rtl-ce3
3577 Dump after the third if conversion, to @file{@var{file}.146r.ce3}.
3580 @itemx -fdump-rtl-cfg
3581 @itemx -fdump-rtl-life
3583 @opindex fdump-rtl-cfg
3584 @opindex fdump-rtl-life
3585 @option{-df} and @option{-fdump-rtl-cfg} enable dumping after control
3586 and data flow analysis, to @file{@var{file}.116r.cfg}. @option{-df}
3587 and @option{-fdump-rtl-cfg} enable dumping dump after life analysis,
3588 to @file{@var{file}.128r.life1} and @file{@var{file}.135r.life2}.
3591 @itemx -fdump-rtl-greg
3593 @opindex fdump-rtl-greg
3594 Dump after global register allocation, to @file{@var{file}.139r.greg}.
3597 @itemx -fdump-rtl-gcse
3598 @itemx -fdump-rtl-bypass
3600 @opindex fdump-rtl-gcse
3601 @opindex fdump-rtl-bypass
3602 @option{-dG} and @option{-fdump-rtl-gcse} enable dumping after GCSE, to
3603 @file{@var{file}.114r.gcse}. @option{-dG} and @option{-fdump-rtl-bypass}
3604 enable dumping after jump bypassing and control flow optimizations, to
3605 @file{@var{file}.115r.bypass}.
3608 @itemx -fdump-rtl-eh
3610 @opindex fdump-rtl-eh
3611 Dump after finalization of EH handling code, to @file{@var{file}.02.eh}.
3614 @itemx -fdump-rtl-sibling
3616 @opindex fdump-rtl-sibling
3617 Dump after sibling call optimizations, to @file{@var{file}.106r.sibling}.
3620 @itemx -fdump-rtl-jump
3622 @opindex fdump-rtl-jump
3623 Dump after the first jump optimization, to @file{@var{file}.112r.jump}.
3626 @itemx -fdump-rtl-stack
3628 @opindex fdump-rtl-stack
3629 Dump after conversion from registers to stack, to @file{@var{file}.152r.stack}.
3632 @itemx -fdump-rtl-lreg
3634 @opindex fdump-rtl-lreg
3635 Dump after local register allocation, to @file{@var{file}.138r.lreg}.
3638 @itemx -fdump-rtl-loop2
3640 @opindex fdump-rtl-loop2
3641 @option{-dL} and @option{-fdump-rtl-loop2} enable dumping after the
3642 loop optimization pass, to @file{@var{file}.119r.loop2},
3643 @file{@var{file}.120r.loop2_init},
3644 @file{@var{file}.121r.loop2_invariant}, and
3645 @file{@var{file}.125r.loop2_done}.
3648 @itemx -fdump-rtl-sms
3650 @opindex fdump-rtl-sms
3651 Dump after modulo scheduling, to @file{@var{file}.136r.sms}.
3654 @itemx -fdump-rtl-mach
3656 @opindex fdump-rtl-mach
3657 Dump after performing the machine dependent reorganization pass, to
3658 @file{@var{file}.155r.mach}.
3661 @itemx -fdump-rtl-rnreg
3663 @opindex fdump-rtl-rnreg
3664 Dump after register renumbering, to @file{@var{file}.147r.rnreg}.
3667 @itemx -fdump-rtl-regmove
3669 @opindex fdump-rtl-regmove
3670 Dump after the register move pass, to @file{@var{file}.132r.regmove}.
3673 @itemx -fdump-rtl-postreload
3675 @opindex fdump-rtl-postreload
3676 Dump after post-reload optimizations, to @file{@var{file}.24.postreload}.
3679 @itemx -fdump-rtl-expand
3681 @opindex fdump-rtl-expand
3682 Dump after RTL generation, to @file{@var{file}.104r.expand}.
3685 @itemx -fdump-rtl-sched2
3687 @opindex fdump-rtl-sched2
3688 Dump after the second scheduling pass, to @file{@var{file}.150r.sched2}.
3691 @itemx -fdump-rtl-cse
3693 @opindex fdump-rtl-cse
3694 Dump after CSE (including the jump optimization that sometimes follows
3695 CSE), to @file{@var{file}.113r.cse}.
3698 @itemx -fdump-rtl-sched
3700 @opindex fdump-rtl-sched
3701 Dump after the first scheduling pass, to @file{@var{file}.21.sched}.
3704 @itemx -fdump-rtl-cse2
3706 @opindex fdump-rtl-cse2
3707 Dump after the second CSE pass (including the jump optimization that
3708 sometimes follows CSE), to @file{@var{file}.127r.cse2}.
3711 @itemx -fdump-rtl-tracer
3713 @opindex fdump-rtl-tracer
3714 Dump after running tracer, to @file{@var{file}.118r.tracer}.
3717 @itemx -fdump-rtl-vpt
3718 @itemx -fdump-rtl-vartrack
3720 @opindex fdump-rtl-vpt
3721 @opindex fdump-rtl-vartrack
3722 @option{-dV} and @option{-fdump-rtl-vpt} enable dumping after the value
3723 profile transformations, to @file{@var{file}.10.vpt}. @option{-dV}
3724 and @option{-fdump-rtl-vartrack} enable dumping after variable tracking,
3725 to @file{@var{file}.154r.vartrack}.
3728 @itemx -fdump-rtl-flow2
3730 @opindex fdump-rtl-flow2
3731 Dump after the second flow pass, to @file{@var{file}.142r.flow2}.
3734 @itemx -fdump-rtl-peephole2
3736 @opindex fdump-rtl-peephole2
3737 Dump after the peephole pass, to @file{@var{file}.145r.peephole2}.
3740 @itemx -fdump-rtl-web
3742 @opindex fdump-rtl-web
3743 Dump after live range splitting, to @file{@var{file}.126r.web}.
3746 @itemx -fdump-rtl-all
3748 @opindex fdump-rtl-all
3749 Produce all the dumps listed above.
3753 Produce a core dump whenever an error occurs.
3757 Print statistics on memory usage, at the end of the run, to
3762 Annotate the assembler output with a comment indicating which
3763 pattern and alternative was used. The length of each instruction is
3768 Dump the RTL in the assembler output as a comment before each instruction.
3769 Also turns on @option{-dp} annotation.
3773 For each of the other indicated dump files (either with @option{-d} or
3774 @option{-fdump-rtl-@var{pass}}), dump a representation of the control flow
3775 graph suitable for viewing with VCG to @file{@var{file}.@var{pass}.vcg}.
3779 Just generate RTL for a function instead of compiling it. Usually used
3780 with @samp{r} (@option{-fdump-rtl-expand}).
3784 Dump debugging information during parsing, to standard error.
3788 @opindex fdump-noaddr
3789 When doing debugging dumps (see @option{-d} option above), suppress
3790 address output. This makes it more feasible to use diff on debugging
3791 dumps for compiler invocations with different compiler binaries and/or
3792 different text / bss / data / heap / stack / dso start locations.
3794 @item -fdump-unnumbered
3795 @opindex fdump-unnumbered
3796 When doing debugging dumps (see @option{-d} option above), suppress instruction
3797 numbers, line number note and address output. This makes it more feasible to
3798 use diff on debugging dumps for compiler invocations with different
3799 options, in particular with and without @option{-g}.
3801 @item -fdump-translation-unit @r{(C++ only)}
3802 @itemx -fdump-translation-unit-@var{options} @r{(C++ only)}
3803 @opindex fdump-translation-unit
3804 Dump a representation of the tree structure for the entire translation
3805 unit to a file. The file name is made by appending @file{.tu} to the
3806 source file name. If the @samp{-@var{options}} form is used, @var{options}
3807 controls the details of the dump as described for the
3808 @option{-fdump-tree} options.
3810 @item -fdump-class-hierarchy @r{(C++ only)}
3811 @itemx -fdump-class-hierarchy-@var{options} @r{(C++ only)}
3812 @opindex fdump-class-hierarchy
3813 Dump a representation of each class's hierarchy and virtual function
3814 table layout to a file. The file name is made by appending @file{.class}
3815 to the source file name. If the @samp{-@var{options}} form is used,
3816 @var{options} controls the details of the dump as described for the
3817 @option{-fdump-tree} options.
3819 @item -fdump-ipa-@var{switch}
3821 Control the dumping at various stages of inter-procedural analysis
3822 language tree to a file. The file name is generated by appending a switch
3823 specific suffix to the source file name. The following dumps are possible:
3827 Enables all inter-procedural analysis dumps; currently the only produced
3828 dump is the @samp{cgraph} dump.
3831 Dumps information about call-graph optimization, unused function removal,
3832 and inlining decisions.
3835 @item -fdump-tree-@var{switch}
3836 @itemx -fdump-tree-@var{switch}-@var{options}
3838 Control the dumping at various stages of processing the intermediate
3839 language tree to a file. The file name is generated by appending a switch
3840 specific suffix to the source file name. If the @samp{-@var{options}}
3841 form is used, @var{options} is a list of @samp{-} separated options that
3842 control the details of the dump. Not all options are applicable to all
3843 dumps, those which are not meaningful will be ignored. The following
3844 options are available
3848 Print the address of each node. Usually this is not meaningful as it
3849 changes according to the environment and source file. Its primary use
3850 is for tying up a dump file with a debug environment.
3852 Inhibit dumping of members of a scope or body of a function merely
3853 because that scope has been reached. Only dump such items when they
3854 are directly reachable by some other path. When dumping pretty-printed
3855 trees, this option inhibits dumping the bodies of control structures.
3857 Print a raw representation of the tree. By default, trees are
3858 pretty-printed into a C-like representation.
3860 Enable more detailed dumps (not honored by every dump option).
3862 Enable dumping various statistics about the pass (not honored by every dump
3865 Enable showing basic block boundaries (disabled in raw dumps).
3867 Enable showing virtual operands for every statement.
3869 Enable showing line numbers for statements.
3871 Enable showing the unique ID (@code{DECL_UID}) for each variable.
3873 Turn on all options, except @option{raw}, @option{slim} and @option{lineno}.
3876 The following tree dumps are possible:
3880 Dump before any tree based optimization, to @file{@var{file}.original}.
3883 Dump after all tree based optimization, to @file{@var{file}.optimized}.
3886 Dump after function inlining, to @file{@var{file}.inlined}.
3889 @opindex fdump-tree-gimple
3890 Dump each function before and after the gimplification pass to a file. The
3891 file name is made by appending @file{.gimple} to the source file name.
3894 @opindex fdump-tree-cfg
3895 Dump the control flow graph of each function to a file. The file name is
3896 made by appending @file{.cfg} to the source file name.
3899 @opindex fdump-tree-vcg
3900 Dump the control flow graph of each function to a file in VCG format. The
3901 file name is made by appending @file{.vcg} to the source file name. Note
3902 that if the file contains more than one function, the generated file cannot
3903 be used directly by VCG@. You will need to cut and paste each function's
3904 graph into its own separate file first.
3907 @opindex fdump-tree-ch
3908 Dump each function after copying loop headers. The file name is made by
3909 appending @file{.ch} to the source file name.
3912 @opindex fdump-tree-ssa
3913 Dump SSA related information to a file. The file name is made by appending
3914 @file{.ssa} to the source file name.
3917 @opindex fdump-tree-salias
3918 Dump structure aliasing variable information to a file. This file name
3919 is made by appending @file{.salias} to the source file name.
3922 @opindex fdump-tree-alias
3923 Dump aliasing information for each function. The file name is made by
3924 appending @file{.alias} to the source file name.
3927 @opindex fdump-tree-ccp
3928 Dump each function after CCP@. The file name is made by appending
3929 @file{.ccp} to the source file name.
3932 @opindex fdump-tree-storeccp
3933 Dump each function after STORE-CCP. The file name is made by appending
3934 @file{.storeccp} to the source file name.
3937 @opindex fdump-tree-pre
3938 Dump trees after partial redundancy elimination. The file name is made
3939 by appending @file{.pre} to the source file name.
3942 @opindex fdump-tree-fre
3943 Dump trees after full redundancy elimination. The file name is made
3944 by appending @file{.fre} to the source file name.
3947 @opindex fdump-tree-copyprop
3948 Dump trees after copy propagation. The file name is made
3949 by appending @file{.copyprop} to the source file name.
3951 @item store_copyprop
3952 @opindex fdump-tree-store_copyprop
3953 Dump trees after store copy-propagation. The file name is made
3954 by appending @file{.store_copyprop} to the source file name.
3957 @opindex fdump-tree-dce
3958 Dump each function after dead code elimination. The file name is made by
3959 appending @file{.dce} to the source file name.
3962 @opindex fdump-tree-mudflap
3963 Dump each function after adding mudflap instrumentation. The file name is
3964 made by appending @file{.mudflap} to the source file name.
3967 @opindex fdump-tree-sra
3968 Dump each function after performing scalar replacement of aggregates. The
3969 file name is made by appending @file{.sra} to the source file name.
3972 @opindex fdump-tree-sink
3973 Dump each function after performing code sinking. The file name is made
3974 by appending @file{.sink} to the source file name.
3977 @opindex fdump-tree-dom
3978 Dump each function after applying dominator tree optimizations. The file
3979 name is made by appending @file{.dom} to the source file name.
3982 @opindex fdump-tree-dse
3983 Dump each function after applying dead store elimination. The file
3984 name is made by appending @file{.dse} to the source file name.
3987 @opindex fdump-tree-phiopt
3988 Dump each function after optimizing PHI nodes into straightline code. The file
3989 name is made by appending @file{.phiopt} to the source file name.
3992 @opindex fdump-tree-forwprop
3993 Dump each function after forward propagating single use variables. The file
3994 name is made by appending @file{.forwprop} to the source file name.
3997 @opindex fdump-tree-copyrename
3998 Dump each function after applying the copy rename optimization. The file
3999 name is made by appending @file{.copyrename} to the source file name.
4002 @opindex fdump-tree-nrv
4003 Dump each function after applying the named return value optimization on
4004 generic trees. The file name is made by appending @file{.nrv} to the source
4008 @opindex fdump-tree-vect
4009 Dump each function after applying vectorization of loops. The file name is
4010 made by appending @file{.vect} to the source file name.
4013 @opindex fdump-tree-vrp
4014 Dump each function after Value Range Propagation (VRP). The file name
4015 is made by appending @file{.vrp} to the source file name.
4018 @opindex fdump-tree-all
4019 Enable all the available tree dumps with the flags provided in this option.
4022 @item -ftree-vectorizer-verbose=@var{n}
4023 @opindex ftree-vectorizer-verbose
4024 This option controls the amount of debugging output the vectorizer prints.
4025 This information is written to standard error, unless
4026 @option{-fdump-tree-all} or @option{-fdump-tree-vect} is specified,
4027 in which case it is output to the usual dump listing file, @file{.vect}.
4028 For @var{n}=0 no diagnostic information is reported.
4029 If @var{n}=1 the vectorizer reports each loop that got vectorized,
4030 and the total number of loops that got vectorized.
4031 If @var{n}=2 the vectorizer also reports non-vectorized loops that passed
4032 the first analysis phase (vect_analyze_loop_form) - i.e. countable,
4033 inner-most, single-bb, single-entry/exit loops. This is the same verbosity
4034 level that @option{-fdump-tree-vect-stats} uses.
4035 Higher verbosity levels mean either more information dumped for each
4036 reported loop, or same amount of information reported for more loops:
4037 If @var{n}=3, alignment related information is added to the reports.
4038 If @var{n}=4, data-references related information (e.g. memory dependences,
4039 memory access-patterns) is added to the reports.
4040 If @var{n}=5, the vectorizer reports also non-vectorized inner-most loops
4041 that did not pass the first analysis phase (i.e. may not be countable, or
4042 may have complicated control-flow).
4043 If @var{n}=6, the vectorizer reports also non-vectorized nested loops.
4044 For @var{n}=7, all the information the vectorizer generates during its
4045 analysis and transformation is reported. This is the same verbosity level
4046 that @option{-fdump-tree-vect-details} uses.
4048 @item -frandom-seed=@var{string}
4049 @opindex frandom-string
4050 This option provides a seed that GCC uses when it would otherwise use
4051 random numbers. It is used to generate certain symbol names
4052 that have to be different in every compiled file. It is also used to
4053 place unique stamps in coverage data files and the object files that
4054 produce them. You can use the @option{-frandom-seed} option to produce
4055 reproducibly identical object files.
4057 The @var{string} should be different for every file you compile.
4059 @item -fsched-verbose=@var{n}
4060 @opindex fsched-verbose
4061 On targets that use instruction scheduling, this option controls the
4062 amount of debugging output the scheduler prints. This information is
4063 written to standard error, unless @option{-dS} or @option{-dR} is
4064 specified, in which case it is output to the usual dump
4065 listing file, @file{.sched} or @file{.sched2} respectively. However
4066 for @var{n} greater than nine, the output is always printed to standard
4069 For @var{n} greater than zero, @option{-fsched-verbose} outputs the
4070 same information as @option{-dRS}. For @var{n} greater than one, it
4071 also output basic block probabilities, detailed ready list information
4072 and unit/insn info. For @var{n} greater than two, it includes RTL
4073 at abort point, control-flow and regions info. And for @var{n} over
4074 four, @option{-fsched-verbose} also includes dependence info.
4078 Store the usual ``temporary'' intermediate files permanently; place them
4079 in the current directory and name them based on the source file. Thus,
4080 compiling @file{foo.c} with @samp{-c -save-temps} would produce files
4081 @file{foo.i} and @file{foo.s}, as well as @file{foo.o}. This creates a
4082 preprocessed @file{foo.i} output file even though the compiler now
4083 normally uses an integrated preprocessor.
4085 When used in combination with the @option{-x} command line option,
4086 @option{-save-temps} is sensible enough to avoid over writing an
4087 input source file with the same extension as an intermediate file.
4088 The corresponding intermediate file may be obtained by renaming the
4089 source file before using @option{-save-temps}.
4093 Report the CPU time taken by each subprocess in the compilation
4094 sequence. For C source files, this is the compiler proper and assembler
4095 (plus the linker if linking is done). The output looks like this:
4102 The first number on each line is the ``user time'', that is time spent
4103 executing the program itself. The second number is ``system time'',
4104 time spent executing operating system routines on behalf of the program.
4105 Both numbers are in seconds.
4107 @item -fvar-tracking
4108 @opindex fvar-tracking
4109 Run variable tracking pass. It computes where variables are stored at each
4110 position in code. Better debugging information is then generated
4111 (if the debugging information format supports this information).
4113 It is enabled by default when compiling with optimization (@option{-Os},
4114 @option{-O}, @option{-O2}, ...), debugging information (@option{-g}) and
4115 the debug info format supports it.
4117 @item -print-file-name=@var{library}
4118 @opindex print-file-name
4119 Print the full absolute name of the library file @var{library} that
4120 would be used when linking---and don't do anything else. With this
4121 option, GCC does not compile or link anything; it just prints the
4124 @item -print-multi-directory
4125 @opindex print-multi-directory
4126 Print the directory name corresponding to the multilib selected by any
4127 other switches present in the command line. This directory is supposed
4128 to exist in @env{GCC_EXEC_PREFIX}.
4130 @item -print-multi-lib
4131 @opindex print-multi-lib
4132 Print the mapping from multilib directory names to compiler switches
4133 that enable them. The directory name is separated from the switches by
4134 @samp{;}, and each switch starts with an @samp{@@} instead of the
4135 @samp{-}, without spaces between multiple switches. This is supposed to
4136 ease shell-processing.
4138 @item -print-prog-name=@var{program}
4139 @opindex print-prog-name
4140 Like @option{-print-file-name}, but searches for a program such as @samp{cpp}.
4142 @item -print-libgcc-file-name
4143 @opindex print-libgcc-file-name
4144 Same as @option{-print-file-name=libgcc.a}.
4146 This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
4147 but you do want to link with @file{libgcc.a}. You can do
4150 gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
4153 @item -print-search-dirs
4154 @opindex print-search-dirs
4155 Print the name of the configured installation directory and a list of
4156 program and library directories @command{gcc} will search---and don't do anything else.
4158 This is useful when @command{gcc} prints the error message
4159 @samp{installation problem, cannot exec cpp0: No such file or directory}.
4160 To resolve this you either need to put @file{cpp0} and the other compiler
4161 components where @command{gcc} expects to find them, or you can set the environment
4162 variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
4163 Don't forget the trailing @samp{/}.
4164 @xref{Environment Variables}.
4167 @opindex dumpmachine
4168 Print the compiler's target machine (for example,
4169 @samp{i686-pc-linux-gnu})---and don't do anything else.
4172 @opindex dumpversion
4173 Print the compiler version (for example, @samp{3.0})---and don't do
4178 Print the compiler's built-in specs---and don't do anything else. (This
4179 is used when GCC itself is being built.) @xref{Spec Files}.
4181 @item -feliminate-unused-debug-types
4182 @opindex feliminate-unused-debug-types
4183 Normally, when producing DWARF2 output, GCC will emit debugging
4184 information for all types declared in a compilation
4185 unit, regardless of whether or not they are actually used
4186 in that compilation unit. Sometimes this is useful, such as
4187 if, in the debugger, you want to cast a value to a type that is
4188 not actually used in your program (but is declared). More often,
4189 however, this results in a significant amount of wasted space.
4190 With this option, GCC will avoid producing debug symbol output
4191 for types that are nowhere used in the source file being compiled.
4194 @node Optimize Options
4195 @section Options That Control Optimization
4196 @cindex optimize options
4197 @cindex options, optimization
4199 These options control various sorts of optimizations.
4201 Without any optimization option, the compiler's goal is to reduce the
4202 cost of compilation and to make debugging produce the expected
4203 results. Statements are independent: if you stop the program with a
4204 breakpoint between statements, you can then assign a new value to any
4205 variable or change the program counter to any other statement in the
4206 function and get exactly the results you would expect from the source
4209 Turning on optimization flags makes the compiler attempt to improve
4210 the performance and/or code size at the expense of compilation time
4211 and possibly the ability to debug the program.
4213 The compiler performs optimization based on the knowledge it has of
4214 the program. Optimization levels @option{-O} and above, in
4215 particular, enable @emph{unit-at-a-time} mode, which allows the
4216 compiler to consider information gained from later functions in
4217 the file when compiling a function. Compiling multiple files at
4218 once to a single output file in @emph{unit-at-a-time} mode allows
4219 the compiler to use information gained from all of the files when
4220 compiling each of them.
4222 Not all optimizations are controlled directly by a flag. Only
4223 optimizations that have a flag are listed.
4230 Optimize. Optimizing compilation takes somewhat more time, and a lot
4231 more memory for a large function.
4233 With @option{-O}, the compiler tries to reduce code size and execution
4234 time, without performing any optimizations that take a great deal of
4237 @option{-O} turns on the following optimization flags:
4238 @gccoptlist{-fdefer-pop @gol
4239 -fdelayed-branch @gol
4240 -fguess-branch-probability @gol
4241 -fcprop-registers @gol
4242 -fif-conversion @gol
4243 -fif-conversion2 @gol
4246 -ftree-dominator-opts @gol
4251 -ftree-copyrename @gol
4254 -funit-at-a-time @gol
4257 @option{-O} also turns on @option{-fomit-frame-pointer} on machines
4258 where doing so does not interfere with debugging.
4262 Optimize even more. GCC performs nearly all supported optimizations
4263 that do not involve a space-speed tradeoff. The compiler does not
4264 perform loop unrolling or function inlining when you specify @option{-O2}.
4265 As compared to @option{-O}, this option increases both compilation time
4266 and the performance of the generated code.
4268 @option{-O2} turns on all optimization flags specified by @option{-O}. It
4269 also turns on the following optimization flags:
4270 @gccoptlist{-fthread-jumps @gol
4272 -foptimize-sibling-calls @gol
4273 -fcse-follow-jumps -fcse-skip-blocks @gol
4274 -fgcse -fgcse-lm @gol
4275 -fexpensive-optimizations @gol
4276 -frerun-cse-after-loop @gol
4279 -fschedule-insns -fschedule-insns2 @gol
4280 -fsched-interblock -fsched-spec @gol
4282 -fstrict-aliasing -fstrict-overflow @gol
4283 -fdelete-null-pointer-checks @gol
4284 -freorder-blocks -freorder-functions @gol
4285 -falign-functions -falign-jumps @gol
4286 -falign-loops -falign-labels @gol
4290 Please note the warning under @option{-fgcse} about
4291 invoking @option{-O2} on programs that use computed gotos.
4293 @option{-O2} doesn't turn on @option{-ftree-vrp} for the Ada compiler.
4294 This option must be explicitly specified on the command line to be
4295 enabled for the Ada compiler.
4299 Optimize yet more. @option{-O3} turns on all optimizations specified by
4300 @option{-O2} and also turns on the @option{-finline-functions},
4301 @option{-funswitch-loops} and @option{-fgcse-after-reload} options.
4305 Do not optimize. This is the default.
4309 Optimize for size. @option{-Os} enables all @option{-O2} optimizations that
4310 do not typically increase code size. It also performs further
4311 optimizations designed to reduce code size.
4313 @option{-Os} disables the following optimization flags:
4314 @gccoptlist{-falign-functions -falign-jumps -falign-loops @gol
4315 -falign-labels -freorder-blocks -freorder-blocks-and-partition @gol
4316 -fprefetch-loop-arrays -ftree-vect-loop-version}
4318 If you use multiple @option{-O} options, with or without level numbers,
4319 the last such option is the one that is effective.
4322 Options of the form @option{-f@var{flag}} specify machine-independent
4323 flags. Most flags have both positive and negative forms; the negative
4324 form of @option{-ffoo} would be @option{-fno-foo}. In the table
4325 below, only one of the forms is listed---the one you typically will
4326 use. You can figure out the other form by either removing @samp{no-}
4329 The following options control specific optimizations. They are either
4330 activated by @option{-O} options or are related to ones that are. You
4331 can use the following flags in the rare cases when ``fine-tuning'' of
4332 optimizations to be performed is desired.
4335 @item -fno-default-inline
4336 @opindex fno-default-inline
4337 Do not make member functions inline by default merely because they are
4338 defined inside the class scope (C++ only). Otherwise, when you specify
4339 @w{@option{-O}}, member functions defined inside class scope are compiled
4340 inline by default; i.e., you don't need to add @samp{inline} in front of
4341 the member function name.
4343 @item -fno-defer-pop
4344 @opindex fno-defer-pop
4345 Always pop the arguments to each function call as soon as that function
4346 returns. For machines which must pop arguments after a function call,
4347 the compiler normally lets arguments accumulate on the stack for several
4348 function calls and pops them all at once.
4350 Disabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4354 Force memory operands to be copied into registers before doing
4355 arithmetic on them. This produces better code by making all memory
4356 references potential common subexpressions. When they are not common
4357 subexpressions, instruction combination should eliminate the separate
4358 register-load. This option is now a nop and will be removed in 4.3.
4361 @opindex fforce-addr
4362 Force memory address constants to be copied into registers before
4363 doing arithmetic on them.
4365 @item -fomit-frame-pointer
4366 @opindex fomit-frame-pointer
4367 Don't keep the frame pointer in a register for functions that
4368 don't need one. This avoids the instructions to save, set up and
4369 restore frame pointers; it also makes an extra register available
4370 in many functions. @strong{It also makes debugging impossible on
4373 On some machines, such as the VAX, this flag has no effect, because
4374 the standard calling sequence automatically handles the frame pointer
4375 and nothing is saved by pretending it doesn't exist. The
4376 machine-description macro @code{FRAME_POINTER_REQUIRED} controls
4377 whether a target machine supports this flag. @xref{Registers,,Register
4378 Usage, gccint, GNU Compiler Collection (GCC) Internals}.
4380 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4382 @item -foptimize-sibling-calls
4383 @opindex foptimize-sibling-calls
4384 Optimize sibling and tail recursive calls.
4386 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4390 Don't pay attention to the @code{inline} keyword. Normally this option
4391 is used to keep the compiler from expanding any functions inline.
4392 Note that if you are not optimizing, no functions can be expanded inline.
4394 @item -finline-functions
4395 @opindex finline-functions
4396 Integrate all simple functions into their callers. The compiler
4397 heuristically decides which functions are simple enough to be worth
4398 integrating in this way.
4400 If all calls to a given function are integrated, and the function is
4401 declared @code{static}, then the function is normally not output as
4402 assembler code in its own right.
4404 Enabled at level @option{-O3}.
4406 @item -finline-functions-called-once
4407 @opindex finline-functions-called-once
4408 Consider all @code{static} functions called once for inlining into their
4409 caller even if they are not marked @code{inline}. If a call to a given
4410 function is integrated, then the function is not output as assembler code
4413 Enabled if @option{-funit-at-a-time} is enabled.
4415 @item -fearly-inlining
4416 @opindex fearly-inlining
4417 Inline functions marked by @code{always_inline} and functions whose body seems
4418 smaller than the function call overhead early before doing
4419 @option{-fprofile-generate} instrumentation and real inlining pass. Doing so
4420 makes profiling significantly cheaper and usually inlining faster on programs
4421 having large chains of nested wrapper functions.
4425 @item -finline-limit=@var{n}
4426 @opindex finline-limit
4427 By default, GCC limits the size of functions that can be inlined. This flag
4428 allows the control of this limit for functions that are explicitly marked as
4429 inline (i.e., marked with the inline keyword or defined within the class
4430 definition in c++). @var{n} is the size of functions that can be inlined in
4431 number of pseudo instructions (not counting parameter handling). The default
4432 value of @var{n} is 600.
4433 Increasing this value can result in more inlined code at
4434 the cost of compilation time and memory consumption. Decreasing usually makes
4435 the compilation faster and less code will be inlined (which presumably
4436 means slower programs). This option is particularly useful for programs that
4437 use inlining heavily such as those based on recursive templates with C++.
4439 Inlining is actually controlled by a number of parameters, which may be
4440 specified individually by using @option{--param @var{name}=@var{value}}.
4441 The @option{-finline-limit=@var{n}} option sets some of these parameters
4445 @item max-inline-insns-single
4446 is set to @var{n}/2.
4447 @item max-inline-insns-auto
4448 is set to @var{n}/2.
4449 @item min-inline-insns
4450 is set to 130 or @var{n}/4, whichever is smaller.
4451 @item max-inline-insns-rtl
4455 See below for a documentation of the individual
4456 parameters controlling inlining.
4458 @emph{Note:} pseudo instruction represents, in this particular context, an
4459 abstract measurement of function's size. In no way does it represent a count
4460 of assembly instructions and as such its exact meaning might change from one
4461 release to an another.
4463 @item -fkeep-inline-functions
4464 @opindex fkeep-inline-functions
4465 In C, emit @code{static} functions that are declared @code{inline}
4466 into the object file, even if the function has been inlined into all
4467 of its callers. This switch does not affect functions using the
4468 @code{extern inline} extension in GNU C@. In C++, emit any and all
4469 inline functions into the object file.
4471 @item -fkeep-static-consts
4472 @opindex fkeep-static-consts
4473 Emit variables declared @code{static const} when optimization isn't turned
4474 on, even if the variables aren't referenced.
4476 GCC enables this option by default. If you want to force the compiler to
4477 check if the variable was referenced, regardless of whether or not
4478 optimization is turned on, use the @option{-fno-keep-static-consts} option.
4480 @item -fmerge-constants
4481 Attempt to merge identical constants (string constants and floating point
4482 constants) across compilation units.
4484 This option is the default for optimized compilation if the assembler and
4485 linker support it. Use @option{-fno-merge-constants} to inhibit this
4488 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4490 @item -fmerge-all-constants
4491 Attempt to merge identical constants and identical variables.
4493 This option implies @option{-fmerge-constants}. In addition to
4494 @option{-fmerge-constants} this considers e.g.@: even constant initialized
4495 arrays or initialized constant variables with integral or floating point
4496 types. Languages like C or C++ require each non-automatic variable to
4497 have distinct location, so using this option will result in non-conforming
4500 @item -fmodulo-sched
4501 @opindex fmodulo-sched
4502 Perform swing modulo scheduling immediately before the first scheduling
4503 pass. This pass looks at innermost loops and reorders their
4504 instructions by overlapping different iterations.
4506 @item -fno-branch-count-reg
4507 @opindex fno-branch-count-reg
4508 Do not use ``decrement and branch'' instructions on a count register,
4509 but instead generate a sequence of instructions that decrement a
4510 register, compare it against zero, then branch based upon the result.
4511 This option is only meaningful on architectures that support such
4512 instructions, which include x86, PowerPC, IA-64 and S/390.
4514 The default is @option{-fbranch-count-reg}.
4516 @item -fno-function-cse
4517 @opindex fno-function-cse
4518 Do not put function addresses in registers; make each instruction that
4519 calls a constant function contain the function's address explicitly.
4521 This option results in less efficient code, but some strange hacks
4522 that alter the assembler output may be confused by the optimizations
4523 performed when this option is not used.
4525 The default is @option{-ffunction-cse}
4527 @item -fno-zero-initialized-in-bss
4528 @opindex fno-zero-initialized-in-bss
4529 If the target supports a BSS section, GCC by default puts variables that
4530 are initialized to zero into BSS@. This can save space in the resulting
4533 This option turns off this behavior because some programs explicitly
4534 rely on variables going to the data section. E.g., so that the
4535 resulting executable can find the beginning of that section and/or make
4536 assumptions based on that.
4538 The default is @option{-fzero-initialized-in-bss}.
4540 @item -fbounds-check
4541 @opindex fbounds-check
4542 For front-ends that support it, generate additional code to check that
4543 indices used to access arrays are within the declared range. This is
4544 currently only supported by the Java and Fortran front-ends, where
4545 this option defaults to true and false respectively.
4547 @item -fmudflap -fmudflapth -fmudflapir
4551 @cindex bounds checking
4553 For front-ends that support it (C and C++), instrument all risky
4554 pointer/array dereferencing operations, some standard library
4555 string/heap functions, and some other associated constructs with
4556 range/validity tests. Modules so instrumented should be immune to
4557 buffer overflows, invalid heap use, and some other classes of C/C++
4558 programming errors. The instrumentation relies on a separate runtime
4559 library (@file{libmudflap}), which will be linked into a program if
4560 @option{-fmudflap} is given at link time. Run-time behavior of the
4561 instrumented program is controlled by the @env{MUDFLAP_OPTIONS}
4562 environment variable. See @code{env MUDFLAP_OPTIONS=-help a.out}
4565 Use @option{-fmudflapth} instead of @option{-fmudflap} to compile and to
4566 link if your program is multi-threaded. Use @option{-fmudflapir}, in
4567 addition to @option{-fmudflap} or @option{-fmudflapth}, if
4568 instrumentation should ignore pointer reads. This produces less
4569 instrumentation (and therefore faster execution) and still provides
4570 some protection against outright memory corrupting writes, but allows
4571 erroneously read data to propagate within a program.
4573 @item -fthread-jumps
4574 @opindex fthread-jumps
4575 Perform optimizations where we check to see if a jump branches to a
4576 location where another comparison subsumed by the first is found. If
4577 so, the first branch is redirected to either the destination of the
4578 second branch or a point immediately following it, depending on whether
4579 the condition is known to be true or false.
4581 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4583 @item -fcse-follow-jumps
4584 @opindex fcse-follow-jumps
4585 In common subexpression elimination, scan through jump instructions
4586 when the target of the jump is not reached by any other path. For
4587 example, when CSE encounters an @code{if} statement with an
4588 @code{else} clause, CSE will follow the jump when the condition
4591 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4593 @item -fcse-skip-blocks
4594 @opindex fcse-skip-blocks
4595 This is similar to @option{-fcse-follow-jumps}, but causes CSE to
4596 follow jumps which conditionally skip over blocks. When CSE
4597 encounters a simple @code{if} statement with no else clause,
4598 @option{-fcse-skip-blocks} causes CSE to follow the jump around the
4599 body of the @code{if}.
4601 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4603 @item -frerun-cse-after-loop
4604 @opindex frerun-cse-after-loop
4605 Re-run common subexpression elimination after loop optimizations has been
4608 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4612 Perform a global common subexpression elimination pass.
4613 This pass also performs global constant and copy propagation.
4615 @emph{Note:} When compiling a program using computed gotos, a GCC
4616 extension, you may get better runtime performance if you disable
4617 the global common subexpression elimination pass by adding
4618 @option{-fno-gcse} to the command line.
4620 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4624 When @option{-fgcse-lm} is enabled, global common subexpression elimination will
4625 attempt to move loads which are only killed by stores into themselves. This
4626 allows a loop containing a load/store sequence to be changed to a load outside
4627 the loop, and a copy/store within the loop.
4629 Enabled by default when gcse is enabled.
4633 When @option{-fgcse-sm} is enabled, a store motion pass is run after
4634 global common subexpression elimination. This pass will attempt to move
4635 stores out of loops. When used in conjunction with @option{-fgcse-lm},
4636 loops containing a load/store sequence can be changed to a load before
4637 the loop and a store after the loop.
4639 Not enabled at any optimization level.
4643 When @option{-fgcse-las} is enabled, the global common subexpression
4644 elimination pass eliminates redundant loads that come after stores to the
4645 same memory location (both partial and full redundancies).
4647 Not enabled at any optimization level.
4649 @item -fgcse-after-reload
4650 @opindex fgcse-after-reload
4651 When @option{-fgcse-after-reload} is enabled, a redundant load elimination
4652 pass is performed after reload. The purpose of this pass is to cleanup
4655 @item -funsafe-loop-optimizations
4656 @opindex funsafe-loop-optimizations
4657 If given, the loop optimizer will assume that loop indices do not
4658 overflow, and that the loops with nontrivial exit condition are not
4659 infinite. This enables a wider range of loop optimizations even if
4660 the loop optimizer itself cannot prove that these assumptions are valid.
4661 Using @option{-Wunsafe-loop-optimizations}, the compiler will warn you
4662 if it finds this kind of loop.
4664 @item -fcrossjumping
4665 @opindex crossjumping
4666 Perform cross-jumping transformation. This transformation unifies equivalent code and save code size. The
4667 resulting code may or may not perform better than without cross-jumping.
4669 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4671 @item -fif-conversion
4672 @opindex if-conversion
4673 Attempt to transform conditional jumps into branch-less equivalents. This
4674 include use of conditional moves, min, max, set flags and abs instructions, and
4675 some tricks doable by standard arithmetics. The use of conditional execution
4676 on chips where it is available is controlled by @code{if-conversion2}.
4678 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4680 @item -fif-conversion2
4681 @opindex if-conversion2
4682 Use conditional execution (where available) to transform conditional jumps into
4683 branch-less equivalents.
4685 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4687 @item -fdelete-null-pointer-checks
4688 @opindex fdelete-null-pointer-checks
4689 Use global dataflow analysis to identify and eliminate useless checks
4690 for null pointers. The compiler assumes that dereferencing a null
4691 pointer would have halted the program. If a pointer is checked after
4692 it has already been dereferenced, it cannot be null.
4694 In some environments, this assumption is not true, and programs can
4695 safely dereference null pointers. Use
4696 @option{-fno-delete-null-pointer-checks} to disable this optimization
4697 for programs which depend on that behavior.
4699 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4701 @item -fexpensive-optimizations
4702 @opindex fexpensive-optimizations
4703 Perform a number of minor optimizations that are relatively expensive.
4705 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4707 @item -foptimize-register-move
4709 @opindex foptimize-register-move
4711 Attempt to reassign register numbers in move instructions and as
4712 operands of other simple instructions in order to maximize the amount of
4713 register tying. This is especially helpful on machines with two-operand
4716 Note @option{-fregmove} and @option{-foptimize-register-move} are the same
4719 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4721 @item -fdelayed-branch
4722 @opindex fdelayed-branch
4723 If supported for the target machine, attempt to reorder instructions
4724 to exploit instruction slots available after delayed branch
4727 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4729 @item -fschedule-insns
4730 @opindex fschedule-insns
4731 If supported for the target machine, attempt to reorder instructions to
4732 eliminate execution stalls due to required data being unavailable. This
4733 helps machines that have slow floating point or memory load instructions
4734 by allowing other instructions to be issued until the result of the load
4735 or floating point instruction is required.
4737 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4739 @item -fschedule-insns2
4740 @opindex fschedule-insns2
4741 Similar to @option{-fschedule-insns}, but requests an additional pass of
4742 instruction scheduling after register allocation has been done. This is
4743 especially useful on machines with a relatively small number of
4744 registers and where memory load instructions take more than one cycle.
4746 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4748 @item -fno-sched-interblock
4749 @opindex fno-sched-interblock
4750 Don't schedule instructions across basic blocks. This is normally
4751 enabled by default when scheduling before register allocation, i.e.@:
4752 with @option{-fschedule-insns} or at @option{-O2} or higher.
4754 @item -fno-sched-spec
4755 @opindex fno-sched-spec
4756 Don't allow speculative motion of non-load instructions. This is normally
4757 enabled by default when scheduling before register allocation, i.e.@:
4758 with @option{-fschedule-insns} or at @option{-O2} or higher.
4760 @item -fsched-spec-load
4761 @opindex fsched-spec-load
4762 Allow speculative motion of some load instructions. This only makes
4763 sense when scheduling before register allocation, i.e.@: with
4764 @option{-fschedule-insns} or at @option{-O2} or higher.
4766 @item -fsched-spec-load-dangerous
4767 @opindex fsched-spec-load-dangerous
4768 Allow speculative motion of more load instructions. This only makes
4769 sense when scheduling before register allocation, i.e.@: with
4770 @option{-fschedule-insns} or at @option{-O2} or higher.
4772 @item -fsched-stalled-insns=@var{n}
4773 @opindex fsched-stalled-insns
4774 Define how many insns (if any) can be moved prematurely from the queue
4775 of stalled insns into the ready list, during the second scheduling pass.
4777 @item -fsched-stalled-insns-dep=@var{n}
4778 @opindex fsched-stalled-insns-dep
4779 Define how many insn groups (cycles) will be examined for a dependency
4780 on a stalled insn that is candidate for premature removal from the queue
4781 of stalled insns. Has an effect only during the second scheduling pass,
4782 and only if @option{-fsched-stalled-insns} is used and its value is not zero.
4784 @item -fsched2-use-superblocks
4785 @opindex fsched2-use-superblocks
4786 When scheduling after register allocation, do use superblock scheduling
4787 algorithm. Superblock scheduling allows motion across basic block boundaries
4788 resulting on faster schedules. This option is experimental, as not all machine
4789 descriptions used by GCC model the CPU closely enough to avoid unreliable
4790 results from the algorithm.
4792 This only makes sense when scheduling after register allocation, i.e.@: with
4793 @option{-fschedule-insns2} or at @option{-O2} or higher.
4795 @item -fsched2-use-traces
4796 @opindex fsched2-use-traces
4797 Use @option{-fsched2-use-superblocks} algorithm when scheduling after register
4798 allocation and additionally perform code duplication in order to increase the
4799 size of superblocks using tracer pass. See @option{-ftracer} for details on
4802 This mode should produce faster but significantly longer programs. Also
4803 without @option{-fbranch-probabilities} the traces constructed may not
4804 match the reality and hurt the performance. This only makes
4805 sense when scheduling after register allocation, i.e.@: with
4806 @option{-fschedule-insns2} or at @option{-O2} or higher.
4810 Eliminates redundant extension instructions and move the non redundant
4811 ones to optimal placement using LCM.
4813 @item -freschedule-modulo-scheduled-loops
4814 @opindex fscheduling-in-modulo-scheduled-loops
4815 The modulo scheduling comes before the traditional scheduling, if a loop was modulo scheduled
4816 we may want to prevent the later scheduling passes from changing its schedule, we use this
4817 option to control that.
4819 @item -fcaller-saves
4820 @opindex fcaller-saves
4821 Enable values to be allocated in registers that will be clobbered by
4822 function calls, by emitting extra instructions to save and restore the
4823 registers around such calls. Such allocation is done only when it
4824 seems to result in better code than would otherwise be produced.
4826 This option is always enabled by default on certain machines, usually
4827 those which have no call-preserved registers to use instead.
4829 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4832 Perform Partial Redundancy Elimination (PRE) on trees. This flag is
4833 enabled by default at @option{-O2} and @option{-O3}.
4836 Perform Full Redundancy Elimination (FRE) on trees. The difference
4837 between FRE and PRE is that FRE only considers expressions
4838 that are computed on all paths leading to the redundant computation.
4839 This analysis faster than PRE, though it exposes fewer redundancies.
4840 This flag is enabled by default at @option{-O} and higher.
4842 @item -ftree-copy-prop
4843 Perform copy propagation on trees. This pass eliminates unnecessary
4844 copy operations. This flag is enabled by default at @option{-O} and
4847 @item -ftree-store-copy-prop
4848 Perform copy propagation of memory loads and stores. This pass
4849 eliminates unnecessary copy operations in memory references
4850 (structures, global variables, arrays, etc). This flag is enabled by
4851 default at @option{-O2} and higher.
4854 Perform structural alias analysis on trees. This flag
4855 is enabled by default at @option{-O} and higher.
4858 Perform interprocedural pointer analysis.
4861 Perform forward store motion on trees. This flag is
4862 enabled by default at @option{-O} and higher.
4865 Perform sparse conditional constant propagation (CCP) on trees. This
4866 pass only operates on local scalar variables and is enabled by default
4867 at @option{-O} and higher.
4869 @item -ftree-store-ccp
4870 Perform sparse conditional constant propagation (CCP) on trees. This
4871 pass operates on both local scalar variables and memory stores and
4872 loads (global variables, structures, arrays, etc). This flag is
4873 enabled by default at @option{-O2} and higher.
4876 Perform dead code elimination (DCE) on trees. This flag is enabled by
4877 default at @option{-O} and higher.
4879 @item -ftree-dominator-opts
4880 Perform a variety of simple scalar cleanups (constant/copy
4881 propagation, redundancy elimination, range propagation and expression
4882 simplification) based on a dominator tree traversal. This also
4883 performs jump threading (to reduce jumps to jumps). This flag is
4884 enabled by default at @option{-O} and higher.
4887 Perform loop header copying on trees. This is beneficial since it increases
4888 effectiveness of code motion optimizations. It also saves one jump. This flag
4889 is enabled by default at @option{-O} and higher. It is not enabled
4890 for @option{-Os}, since it usually increases code size.
4892 @item -ftree-loop-optimize
4893 Perform loop optimizations on trees. This flag is enabled by default
4894 at @option{-O} and higher.
4896 @item -ftree-loop-linear
4897 Perform linear loop transformations on tree. This flag can improve cache
4898 performance and allow further loop optimizations to take place.
4900 @item -ftree-loop-im
4901 Perform loop invariant motion on trees. This pass moves only invariants that
4902 would be hard to handle at RTL level (function calls, operations that expand to
4903 nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
4904 operands of conditions that are invariant out of the loop, so that we can use
4905 just trivial invariantness analysis in loop unswitching. The pass also includes
4908 @item -ftree-loop-ivcanon
4909 Create a canonical counter for number of iterations in the loop for that
4910 determining number of iterations requires complicated analysis. Later
4911 optimizations then may determine the number easily. Useful especially
4912 in connection with unrolling.
4915 Perform induction variable optimizations (strength reduction, induction
4916 variable merging and induction variable elimination) on trees.
4919 Perform scalar replacement of aggregates. This pass replaces structure
4920 references with scalars to prevent committing structures to memory too
4921 early. This flag is enabled by default at @option{-O} and higher.
4923 @item -ftree-copyrename
4924 Perform copy renaming on trees. This pass attempts to rename compiler
4925 temporaries to other variables at copy locations, usually resulting in
4926 variable names which more closely resemble the original variables. This flag
4927 is enabled by default at @option{-O} and higher.
4930 Perform temporary expression replacement during the SSA->normal phase. Single
4931 use/single def temporaries are replaced at their use location with their
4932 defining expression. This results in non-GIMPLE code, but gives the expanders
4933 much more complex trees to work on resulting in better RTL generation. This is
4934 enabled by default at @option{-O} and higher.
4937 Perform live range splitting during the SSA->normal phase. Distinct live
4938 ranges of a variable are split into unique variables, allowing for better
4939 optimization later. This is enabled by default at @option{-O} and higher.
4941 @item -ftree-vectorize
4942 Perform loop vectorization on trees.
4944 @item -ftree-vect-loop-version
4945 @opindex ftree-vect-loop-version
4946 Perform loop versioning when doing loop vectorization on trees. When a loop
4947 appears to be vectorizable except that data alignment or data dependence cannot
4948 be determined at compile time then vectorized and non-vectorized versions of
4949 the loop are generated along with runtime checks for alignment or dependence
4950 to control which version is executed. This option is enabled by default
4951 except at level @option{-Os} where it is disabled.
4954 Perform Value Range Propagation on trees. This is similar to the
4955 constant propagation pass, but instead of values, ranges of values are
4956 propagated. This allows the optimizers to remove unnecessary range
4957 checks like array bound checks and null pointer checks. This is
4958 enabled by default at @option{-O2} and higher. Null pointer check
4959 elimination is only done if @option{-fdelete-null-pointer-checks} is
4964 Perform tail duplication to enlarge superblock size. This transformation
4965 simplifies the control flow of the function allowing other optimizations to do
4968 @item -funroll-loops
4969 @opindex funroll-loops
4970 Unroll loops whose number of iterations can be determined at compile
4971 time or upon entry to the loop. @option{-funroll-loops} implies
4972 @option{-frerun-cse-after-loop}. This option makes code larger,
4973 and may or may not make it run faster.
4975 @item -funroll-all-loops
4976 @opindex funroll-all-loops
4977 Unroll all loops, even if their number of iterations is uncertain when
4978 the loop is entered. This usually makes programs run more slowly.
4979 @option{-funroll-all-loops} implies the same options as
4980 @option{-funroll-loops},
4982 @item -fsplit-ivs-in-unroller
4983 @opindex fsplit-ivs-in-unroller
4984 Enables expressing of values of induction variables in later iterations
4985 of the unrolled loop using the value in the first iteration. This breaks
4986 long dependency chains, thus improving efficiency of the scheduling passes.
4988 Combination of @option{-fweb} and CSE is often sufficient to obtain the
4989 same effect. However in cases the loop body is more complicated than
4990 a single basic block, this is not reliable. It also does not work at all
4991 on some of the architectures due to restrictions in the CSE pass.
4993 This optimization is enabled by default.
4995 @item -fvariable-expansion-in-unroller
4996 @opindex fvariable-expansion-in-unroller
4997 With this option, the compiler will create multiple copies of some
4998 local variables when unrolling a loop which can result in superior code.
5000 @item -fprefetch-loop-arrays
5001 @opindex fprefetch-loop-arrays
5002 If supported by the target machine, generate instructions to prefetch
5003 memory to improve the performance of loops that access large arrays.
5005 This option may generate better or worse code; results are highly
5006 dependent on the structure of loops within the source code.
5008 Disabled at level @option{-Os}.
5011 @itemx -fno-peephole2
5012 @opindex fno-peephole
5013 @opindex fno-peephole2
5014 Disable any machine-specific peephole optimizations. The difference
5015 between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
5016 are implemented in the compiler; some targets use one, some use the
5017 other, a few use both.
5019 @option{-fpeephole} is enabled by default.
5020 @option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
5022 @item -fno-guess-branch-probability
5023 @opindex fno-guess-branch-probability
5024 Do not guess branch probabilities using heuristics.
5026 GCC will use heuristics to guess branch probabilities if they are
5027 not provided by profiling feedback (@option{-fprofile-arcs}). These
5028 heuristics are based on the control flow graph. If some branch probabilities
5029 are specified by @samp{__builtin_expect}, then the heuristics will be
5030 used to guess branch probabilities for the rest of the control flow graph,
5031 taking the @samp{__builtin_expect} info into account. The interactions
5032 between the heuristics and @samp{__builtin_expect} can be complex, and in
5033 some cases, it may be useful to disable the heuristics so that the effects
5034 of @samp{__builtin_expect} are easier to understand.
5036 The default is @option{-fguess-branch-probability} at levels
5037 @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
5039 @item -freorder-blocks
5040 @opindex freorder-blocks
5041 Reorder basic blocks in the compiled function in order to reduce number of
5042 taken branches and improve code locality.
5044 Enabled at levels @option{-O2}, @option{-O3}.
5046 @item -freorder-blocks-and-partition
5047 @opindex freorder-blocks-and-partition
5048 In addition to reordering basic blocks in the compiled function, in order
5049 to reduce number of taken branches, partitions hot and cold basic blocks
5050 into separate sections of the assembly and .o files, to improve
5051 paging and cache locality performance.
5053 This optimization is automatically turned off in the presence of
5054 exception handling, for linkonce sections, for functions with a user-defined
5055 section attribute and on any architecture that does not support named
5058 @item -freorder-functions
5059 @opindex freorder-functions
5060 Reorder functions in the object file in order to
5061 improve code locality. This is implemented by using special
5062 subsections @code{.text.hot} for most frequently executed functions and
5063 @code{.text.unlikely} for unlikely executed functions. Reordering is done by
5064 the linker so object file format must support named sections and linker must
5065 place them in a reasonable way.
5067 Also profile feedback must be available in to make this option effective. See
5068 @option{-fprofile-arcs} for details.
5070 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
5072 @item -fstrict-aliasing
5073 @opindex fstrict-aliasing
5074 Allows the compiler to assume the strictest aliasing rules applicable to
5075 the language being compiled. For C (and C++), this activates
5076 optimizations based on the type of expressions. In particular, an
5077 object of one type is assumed never to reside at the same address as an
5078 object of a different type, unless the types are almost the same. For
5079 example, an @code{unsigned int} can alias an @code{int}, but not a
5080 @code{void*} or a @code{double}. A character type may alias any other
5083 Pay special attention to code like this:
5096 The practice of reading from a different union member than the one most
5097 recently written to (called ``type-punning'') is common. Even with
5098 @option{-fstrict-aliasing}, type-punning is allowed, provided the memory
5099 is accessed through the union type. So, the code above will work as
5100 expected. However, this code might not:
5111 Every language that wishes to perform language-specific alias analysis
5112 should define a function that computes, given an @code{tree}
5113 node, an alias set for the node. Nodes in different alias sets are not
5114 allowed to alias. For an example, see the C front-end function
5115 @code{c_get_alias_set}.
5117 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
5119 @item -fstrict-overflow
5120 @opindex fstrict-overflow
5121 Allow the compiler to assume strict signed overflow rules, depending
5122 on the language being compiled. For C (and C++) this means that
5123 overflow when doing arithmetic with signed numbers is undefined, which
5124 means that the compiler may assume that it will not happen. This
5125 permits various optimizations. For example, the compiler will assume
5126 that an expression like @code{i + 10 > i} will always be true for
5127 signed @code{i}. This assumption is only valid if signed overflow is
5128 undefined, as the expression is false if @code{i + 10} overflows when
5129 using twos complement arithmetic. When this option is in effect any
5130 attempt to determine whether an operation on signed numbers will
5131 overflow must be written carefully to not actually involve overflow.
5133 See also the @option{-fwrapv} option. Using @option{-fwrapv} means
5134 that signed overflow is fully defined: it wraps. When
5135 @option{-fwrapv} is used, there is no difference between
5136 @option{-fstrict-overflow} and @option{-fno-strict-overflow}. With
5137 @option{-fwrapv} certain types of overflow are permitted. For
5138 example, if the compiler gets an overflow when doing arithmetic on
5139 constants, the overflowed value can still be used with
5140 @option{-fwrapv}, but not otherwise.
5142 The @option{-fstrict-overflow} option is enabled at levels
5143 @option{-O2}, @option{-O3}, @option{-Os}.
5145 @item -falign-functions
5146 @itemx -falign-functions=@var{n}
5147 @opindex falign-functions
5148 Align the start of functions to the next power-of-two greater than
5149 @var{n}, skipping up to @var{n} bytes. For instance,
5150 @option{-falign-functions=32} aligns functions to the next 32-byte
5151 boundary, but @option{-falign-functions=24} would align to the next
5152 32-byte boundary only if this can be done by skipping 23 bytes or less.
5154 @option{-fno-align-functions} and @option{-falign-functions=1} are
5155 equivalent and mean that functions will not be aligned.
5157 Some assemblers only support this flag when @var{n} is a power of two;
5158 in that case, it is rounded up.
5160 If @var{n} is not specified or is zero, use a machine-dependent default.
5162 Enabled at levels @option{-O2}, @option{-O3}.
5164 @item -falign-labels
5165 @itemx -falign-labels=@var{n}
5166 @opindex falign-labels
5167 Align all branch targets to a power-of-two boundary, skipping up to
5168 @var{n} bytes like @option{-falign-functions}. This option can easily
5169 make code slower, because it must insert dummy operations for when the
5170 branch target is reached in the usual flow of the code.
5172 @option{-fno-align-labels} and @option{-falign-labels=1} are
5173 equivalent and mean that labels will not be aligned.
5175 If @option{-falign-loops} or @option{-falign-jumps} are applicable and
5176 are greater than this value, then their values are used instead.
5178 If @var{n} is not specified or is zero, use a machine-dependent default
5179 which is very likely to be @samp{1}, meaning no alignment.
5181 Enabled at levels @option{-O2}, @option{-O3}.
5184 @itemx -falign-loops=@var{n}
5185 @opindex falign-loops
5186 Align loops to a power-of-two boundary, skipping up to @var{n} bytes
5187 like @option{-falign-functions}. The hope is that the loop will be
5188 executed many times, which will make up for any execution of the dummy
5191 @option{-fno-align-loops} and @option{-falign-loops=1} are
5192 equivalent and mean that loops will not be aligned.
5194 If @var{n} is not specified or is zero, use a machine-dependent default.
5196 Enabled at levels @option{-O2}, @option{-O3}.
5199 @itemx -falign-jumps=@var{n}
5200 @opindex falign-jumps
5201 Align branch targets to a power-of-two boundary, for branch targets
5202 where the targets can only be reached by jumping, skipping up to @var{n}
5203 bytes like @option{-falign-functions}. In this case, no dummy operations
5206 @option{-fno-align-jumps} and @option{-falign-jumps=1} are
5207 equivalent and mean that loops will not be aligned.
5209 If @var{n} is not specified or is zero, use a machine-dependent default.
5211 Enabled at levels @option{-O2}, @option{-O3}.
5213 @item -funit-at-a-time
5214 @opindex funit-at-a-time
5215 Parse the whole compilation unit before starting to produce code.
5216 This allows some extra optimizations to take place but consumes
5217 more memory (in general). There are some compatibility issues
5218 with @emph{unit-at-a-time} mode:
5221 enabling @emph{unit-at-a-time} mode may change the order
5222 in which functions, variables, and top-level @code{asm} statements
5223 are emitted, and will likely break code relying on some particular
5224 ordering. The majority of such top-level @code{asm} statements,
5225 though, can be replaced by @code{section} attributes. The
5226 @option{fno-toplevel-reorder} option may be used to keep the ordering
5227 used in the input file, at the cost of some optimizations.
5230 @emph{unit-at-a-time} mode removes unreferenced static variables
5231 and functions. This may result in undefined references
5232 when an @code{asm} statement refers directly to variables or functions
5233 that are otherwise unused. In that case either the variable/function
5234 shall be listed as an operand of the @code{asm} statement operand or,
5235 in the case of top-level @code{asm} statements the attribute @code{used}
5236 shall be used on the declaration.
5239 Static functions now can use non-standard passing conventions that
5240 may break @code{asm} statements calling functions directly. Again,
5241 attribute @code{used} will prevent this behavior.
5244 As a temporary workaround, @option{-fno-unit-at-a-time} can be used,
5245 but this scheme may not be supported by future releases of GCC@.
5247 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
5249 @item -fno-toplevel-reorder
5250 Do not reorder top-level functions, variables, and @code{asm}
5251 statements. Output them in the same order that they appear in the
5252 input file. When this option is used, unreferenced static variables
5253 will not be removed. This option is intended to support existing code
5254 which relies on a particular ordering. For new code, it is better to
5259 Constructs webs as commonly used for register allocation purposes and assign
5260 each web individual pseudo register. This allows the register allocation pass
5261 to operate on pseudos directly, but also strengthens several other optimization
5262 passes, such as CSE, loop optimizer and trivial dead code remover. It can,
5263 however, make debugging impossible, since variables will no longer stay in a
5266 Enabled by default with @option{-funroll-loops}.
5268 @item -fwhole-program
5269 @opindex fwhole-program
5270 Assume that the current compilation unit represents whole program being
5271 compiled. All public functions and variables with the exception of @code{main}
5272 and those merged by attribute @code{externally_visible} become static functions
5273 and in a affect gets more aggressively optimized by interprocedural optimizers.
5274 While this option is equivalent to proper use of @code{static} keyword for
5275 programs consisting of single file, in combination with option
5276 @option{--combine} this flag can be used to compile most of smaller scale C
5277 programs since the functions and variables become local for the whole combined
5278 compilation unit, not for the single source file itself.
5281 @item -fno-cprop-registers
5282 @opindex fno-cprop-registers
5283 After register allocation and post-register allocation instruction splitting,
5284 we perform a copy-propagation pass to try to reduce scheduling dependencies
5285 and occasionally eliminate the copy.
5287 Disabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
5289 @item -fprofile-generate
5290 @opindex fprofile-generate
5292 Enable options usually used for instrumenting application to produce
5293 profile useful for later recompilation with profile feedback based
5294 optimization. You must use @option{-fprofile-generate} both when
5295 compiling and when linking your program.
5297 The following options are enabled: @code{-fprofile-arcs}, @code{-fprofile-values}, @code{-fvpt}.
5300 @opindex fprofile-use
5301 Enable profile feedback directed optimizations, and optimizations
5302 generally profitable only with profile feedback available.
5304 The following options are enabled: @code{-fbranch-probabilities}, @code{-fvpt},
5305 @code{-funroll-loops}, @code{-fpeel-loops}, @code{-ftracer}
5309 The following options control compiler behavior regarding floating
5310 point arithmetic. These options trade off between speed and
5311 correctness. All must be specifically enabled.
5315 @opindex ffloat-store
5316 Do not store floating point variables in registers, and inhibit other
5317 options that might change whether a floating point value is taken from a
5320 @cindex floating point precision
5321 This option prevents undesirable excess precision on machines such as
5322 the 68000 where the floating registers (of the 68881) keep more
5323 precision than a @code{double} is supposed to have. Similarly for the
5324 x86 architecture. For most programs, the excess precision does only
5325 good, but a few programs rely on the precise definition of IEEE floating
5326 point. Use @option{-ffloat-store} for such programs, after modifying
5327 them to store all pertinent intermediate computations into variables.
5331 Sets @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, @*
5332 @option{-fno-trapping-math}, @option{-ffinite-math-only},
5333 @option{-fno-rounding-math}, @option{-fno-signaling-nans}
5334 and @option{fcx-limited-range}.
5336 This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
5338 This option should never be turned on by any @option{-O} option since
5339 it can result in incorrect output for programs which depend on
5340 an exact implementation of IEEE or ISO rules/specifications for
5343 @item -fno-math-errno
5344 @opindex fno-math-errno
5345 Do not set ERRNO after calling math functions that are executed
5346 with a single instruction, e.g., sqrt. A program that relies on
5347 IEEE exceptions for math error handling may want to use this flag
5348 for speed while maintaining IEEE arithmetic compatibility.
5350 This option should never be turned on by any @option{-O} option since
5351 it can result in incorrect output for programs which depend on
5352 an exact implementation of IEEE or ISO rules/specifications for
5355 The default is @option{-fmath-errno}.
5357 On Darwin and FreeBSD systems, the math library never sets @code{errno}.
5359 no reason for the compiler to consider the possibility that it might,
5360 and @option{-fno-math-errno} is the default.
5362 @item -funsafe-math-optimizations
5363 @opindex funsafe-math-optimizations
5364 Allow optimizations for floating-point arithmetic that (a) assume
5365 that arguments and results are valid and (b) may violate IEEE or
5366 ANSI standards. When used at link-time, it may include libraries
5367 or startup files that change the default FPU control word or other
5368 similar optimizations.
5370 This option should never be turned on by any @option{-O} option since
5371 it can result in incorrect output for programs which depend on
5372 an exact implementation of IEEE or ISO rules/specifications for
5375 The default is @option{-fno-unsafe-math-optimizations}.
5377 @item -ffinite-math-only
5378 @opindex ffinite-math-only
5379 Allow optimizations for floating-point arithmetic that assume
5380 that arguments and results are not NaNs or +-Infs.
5382 This option should never be turned on by any @option{-O} option since
5383 it can result in incorrect output for programs which depend on
5384 an exact implementation of IEEE or ISO rules/specifications.
5386 The default is @option{-fno-finite-math-only}.
5388 @item -fno-trapping-math
5389 @opindex fno-trapping-math
5390 Compile code assuming that floating-point operations cannot generate
5391 user-visible traps. These traps include division by zero, overflow,
5392 underflow, inexact result and invalid operation. This option implies
5393 @option{-fno-signaling-nans}. Setting this option may allow faster
5394 code if one relies on ``non-stop'' IEEE arithmetic, for example.
5396 This option should never be turned on by any @option{-O} option since
5397 it can result in incorrect output for programs which depend on
5398 an exact implementation of IEEE or ISO rules/specifications for
5401 The default is @option{-ftrapping-math}.
5403 @item -frounding-math
5404 @opindex frounding-math
5405 Disable transformations and optimizations that assume default floating
5406 point rounding behavior. This is round-to-zero for all floating point
5407 to integer conversions, and round-to-nearest for all other arithmetic
5408 truncations. This option should be specified for programs that change
5409 the FP rounding mode dynamically, or that may be executed with a
5410 non-default rounding mode. This option disables constant folding of
5411 floating point expressions at compile-time (which may be affected by
5412 rounding mode) and arithmetic transformations that are unsafe in the
5413 presence of sign-dependent rounding modes.
5415 The default is @option{-fno-rounding-math}.
5417 This option is experimental and does not currently guarantee to
5418 disable all GCC optimizations that are affected by rounding mode.
5419 Future versions of GCC may provide finer control of this setting
5420 using C99's @code{FENV_ACCESS} pragma. This command line option
5421 will be used to specify the default state for @code{FENV_ACCESS}.
5423 @item -frtl-abstract-sequences
5424 @opindex frtl-abstract-sequences
5425 It is a size optimization method. This option is to find identical
5426 sequences of code, which can be turned into pseudo-procedures and
5427 then replace all occurrences with calls to the newly created
5428 subroutine. It is kind of an opposite of @option{-finline-functions}.
5429 This optimization runs at RTL level.
5431 @item -fsignaling-nans
5432 @opindex fsignaling-nans
5433 Compile code assuming that IEEE signaling NaNs may generate user-visible
5434 traps during floating-point operations. Setting this option disables
5435 optimizations that may change the number of exceptions visible with
5436 signaling NaNs. This option implies @option{-ftrapping-math}.
5438 This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
5441 The default is @option{-fno-signaling-nans}.
5443 This option is experimental and does not currently guarantee to
5444 disable all GCC optimizations that affect signaling NaN behavior.
5446 @item -fsingle-precision-constant
5447 @opindex fsingle-precision-constant
5448 Treat floating point constant as single precision constant instead of
5449 implicitly converting it to double precision constant.
5451 @item -fcx-limited-range
5452 @itemx -fno-cx-limited-range
5453 @opindex fcx-limited-range
5454 @opindex fno-cx-limited-range
5455 When enabled, this option states that a range reduction step is not
5456 needed when performing complex division. The default is
5457 @option{-fno-cx-limited-range}, but is enabled by @option{-ffast-math}.
5459 This option controls the default setting of the ISO C99
5460 @code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
5465 The following options control optimizations that may improve
5466 performance, but are not enabled by any @option{-O} options. This
5467 section includes experimental options that may produce broken code.
5470 @item -fbranch-probabilities
5471 @opindex fbranch-probabilities
5472 After running a program compiled with @option{-fprofile-arcs}
5473 (@pxref{Debugging Options,, Options for Debugging Your Program or
5474 @command{gcc}}), you can compile it a second time using
5475 @option{-fbranch-probabilities}, to improve optimizations based on
5476 the number of times each branch was taken. When the program
5477 compiled with @option{-fprofile-arcs} exits it saves arc execution
5478 counts to a file called @file{@var{sourcename}.gcda} for each source
5479 file The information in this data file is very dependent on the
5480 structure of the generated code, so you must use the same source code
5481 and the same optimization options for both compilations.
5483 With @option{-fbranch-probabilities}, GCC puts a
5484 @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
5485 These can be used to improve optimization. Currently, they are only
5486 used in one place: in @file{reorg.c}, instead of guessing which path a
5487 branch is mostly to take, the @samp{REG_BR_PROB} values are used to
5488 exactly determine which path is taken more often.
5490 @item -fprofile-values
5491 @opindex fprofile-values
5492 If combined with @option{-fprofile-arcs}, it adds code so that some
5493 data about values of expressions in the program is gathered.
5495 With @option{-fbranch-probabilities}, it reads back the data gathered
5496 from profiling values of expressions and adds @samp{REG_VALUE_PROFILE}
5497 notes to instructions for their later usage in optimizations.
5499 Enabled with @option{-fprofile-generate} and @option{-fprofile-use}.
5503 If combined with @option{-fprofile-arcs}, it instructs the compiler to add
5504 a code to gather information about values of expressions.
5506 With @option{-fbranch-probabilities}, it reads back the data gathered
5507 and actually performs the optimizations based on them.
5508 Currently the optimizations include specialization of division operation
5509 using the knowledge about the value of the denominator.
5511 @item -frename-registers
5512 @opindex frename-registers
5513 Attempt to avoid false dependencies in scheduled code by making use
5514 of registers left over after register allocation. This optimization
5515 will most benefit processors with lots of registers. Depending on the
5516 debug information format adopted by the target, however, it can
5517 make debugging impossible, since variables will no longer stay in
5518 a ``home register''.
5520 Enabled by default with @option{-funroll-loops}.
5524 Perform tail duplication to enlarge superblock size. This transformation
5525 simplifies the control flow of the function allowing other optimizations to do
5528 Enabled with @option{-fprofile-use}.
5530 @item -funroll-loops
5531 @opindex funroll-loops
5532 Unroll loops whose number of iterations can be determined at compile time or
5533 upon entry to the loop. @option{-funroll-loops} implies
5534 @option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
5535 It also turns on complete loop peeling (i.e.@: complete removal of loops with
5536 small constant number of iterations). This option makes code larger, and may
5537 or may not make it run faster.
5539 Enabled with @option{-fprofile-use}.
5541 @item -funroll-all-loops
5542 @opindex funroll-all-loops
5543 Unroll all loops, even if their number of iterations is uncertain when
5544 the loop is entered. This usually makes programs run more slowly.
5545 @option{-funroll-all-loops} implies the same options as
5546 @option{-funroll-loops}.
5549 @opindex fpeel-loops
5550 Peels the loops for that there is enough information that they do not
5551 roll much (from profile feedback). It also turns on complete loop peeling
5552 (i.e.@: complete removal of loops with small constant number of iterations).
5554 Enabled with @option{-fprofile-use}.
5556 @item -fmove-loop-invariants
5557 @opindex fmove-loop-invariants
5558 Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
5559 at level @option{-O1}
5561 @item -funswitch-loops
5562 @opindex funswitch-loops
5563 Move branches with loop invariant conditions out of the loop, with duplicates
5564 of the loop on both branches (modified according to result of the condition).
5566 @item -ffunction-sections
5567 @itemx -fdata-sections
5568 @opindex ffunction-sections
5569 @opindex fdata-sections
5570 Place each function or data item into its own section in the output
5571 file if the target supports arbitrary sections. The name of the
5572 function or the name of the data item determines the section's name
5575 Use these options on systems where the linker can perform optimizations
5576 to improve locality of reference in the instruction space. Most systems
5577 using the ELF object format and SPARC processors running Solaris 2 have
5578 linkers with such optimizations. AIX may have these optimizations in
5581 Only use these options when there are significant benefits from doing
5582 so. When you specify these options, the assembler and linker will
5583 create larger object and executable files and will also be slower.
5584 You will not be able to use @code{gprof} on all systems if you
5585 specify this option and you may have problems with debugging if
5586 you specify both this option and @option{-g}.
5588 @item -fbranch-target-load-optimize
5589 @opindex fbranch-target-load-optimize
5590 Perform branch target register load optimization before prologue / epilogue
5592 The use of target registers can typically be exposed only during reload,
5593 thus hoisting loads out of loops and doing inter-block scheduling needs
5594 a separate optimization pass.
5596 @item -fbranch-target-load-optimize2
5597 @opindex fbranch-target-load-optimize2
5598 Perform branch target register load optimization after prologue / epilogue
5601 @item -fbtr-bb-exclusive
5602 @opindex fbtr-bb-exclusive
5603 When performing branch target register load optimization, don't reuse
5604 branch target registers in within any basic block.
5606 @item -fstack-protector
5607 Emit extra code to check for buffer overflows, such as stack smashing
5608 attacks. This is done by adding a guard variable to functions with
5609 vulnerable objects. This includes functions that call alloca, and
5610 functions with buffers larger than 8 bytes. The guards are initialized
5611 when a function is entered and then checked when the function exits.
5612 If a guard check fails, an error message is printed and the program exits.
5614 @item -fstack-protector-all
5615 Like @option{-fstack-protector} except that all functions are protected.
5617 @item -fsection-anchors
5618 @opindex fsection-anchors
5619 Try to reduce the number of symbolic address calculations by using
5620 shared ``anchor'' symbols to address nearby objects. This transformation
5621 can help to reduce the number of GOT entries and GOT accesses on some
5624 For example, the implementation of the following function @code{foo}:
5628 int foo (void) @{ return a + b + c; @}
5631 would usually calculate the addresses of all three variables, but if you
5632 compile it with @option{-fsection-anchors}, it will access the variables
5633 from a common anchor point instead. The effect is similar to the
5634 following pseudocode (which isn't valid C):
5639 register int *xr = &x;
5640 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
5644 Not all targets support this option.
5646 @item --param @var{name}=@var{value}
5648 In some places, GCC uses various constants to control the amount of
5649 optimization that is done. For example, GCC will not inline functions
5650 that contain more that a certain number of instructions. You can
5651 control some of these constants on the command-line using the
5652 @option{--param} option.
5654 The names of specific parameters, and the meaning of the values, are
5655 tied to the internals of the compiler, and are subject to change
5656 without notice in future releases.
5658 In each case, the @var{value} is an integer. The allowable choices for
5659 @var{name} are given in the following table:
5662 @item salias-max-implicit-fields
5663 The maximum number of fields in a variable without direct
5664 structure accesses for which structure aliasing will consider trying
5665 to track each field. The default is 5
5667 @item salias-max-array-elements
5668 The maximum number of elements an array can have and its elements
5669 still be tracked individually by structure aliasing. The default is 4
5671 @item sra-max-structure-size
5672 The maximum structure size, in bytes, at which the scalar replacement
5673 of aggregates (SRA) optimization will perform block copies. The
5674 default value, 0, implies that GCC will select the most appropriate
5677 @item sra-field-structure-ratio
5678 The threshold ratio (as a percentage) between instantiated fields and
5679 the complete structure size. We say that if the ratio of the number
5680 of bytes in instantiated fields to the number of bytes in the complete
5681 structure exceeds this parameter, then block copies are not used. The
5684 @item max-crossjump-edges
5685 The maximum number of incoming edges to consider for crossjumping.
5686 The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
5687 the number of edges incoming to each block. Increasing values mean
5688 more aggressive optimization, making the compile time increase with
5689 probably small improvement in executable size.
5691 @item min-crossjump-insns
5692 The minimum number of instructions which must be matched at the end
5693 of two blocks before crossjumping will be performed on them. This
5694 value is ignored in the case where all instructions in the block being
5695 crossjumped from are matched. The default value is 5.
5697 @item max-grow-copy-bb-insns
5698 The maximum code size expansion factor when copying basic blocks
5699 instead of jumping. The expansion is relative to a jump instruction.
5700 The default value is 8.
5702 @item max-goto-duplication-insns
5703 The maximum number of instructions to duplicate to a block that jumps
5704 to a computed goto. To avoid @math{O(N^2)} behavior in a number of
5705 passes, GCC factors computed gotos early in the compilation process,
5706 and unfactors them as late as possible. Only computed jumps at the
5707 end of a basic blocks with no more than max-goto-duplication-insns are
5708 unfactored. The default value is 8.
5710 @item max-delay-slot-insn-search
5711 The maximum number of instructions to consider when looking for an
5712 instruction to fill a delay slot. If more than this arbitrary number of
5713 instructions is searched, the time savings from filling the delay slot
5714 will be minimal so stop searching. Increasing values mean more
5715 aggressive optimization, making the compile time increase with probably
5716 small improvement in executable run time.
5718 @item max-delay-slot-live-search
5719 When trying to fill delay slots, the maximum number of instructions to
5720 consider when searching for a block with valid live register
5721 information. Increasing this arbitrarily chosen value means more
5722 aggressive optimization, increasing the compile time. This parameter
5723 should be removed when the delay slot code is rewritten to maintain the
5726 @item max-gcse-memory
5727 The approximate maximum amount of memory that will be allocated in
5728 order to perform the global common subexpression elimination
5729 optimization. If more memory than specified is required, the
5730 optimization will not be done.
5732 @item max-gcse-passes
5733 The maximum number of passes of GCSE to run. The default is 1.
5735 @item max-pending-list-length
5736 The maximum number of pending dependencies scheduling will allow
5737 before flushing the current state and starting over. Large functions
5738 with few branches or calls can create excessively large lists which
5739 needlessly consume memory and resources.
5741 @item max-inline-insns-single
5742 Several parameters control the tree inliner used in gcc.
5743 This number sets the maximum number of instructions (counted in GCC's
5744 internal representation) in a single function that the tree inliner
5745 will consider for inlining. This only affects functions declared
5746 inline and methods implemented in a class declaration (C++).
5747 The default value is 450.
5749 @item max-inline-insns-auto
5750 When you use @option{-finline-functions} (included in @option{-O3}),
5751 a lot of functions that would otherwise not be considered for inlining
5752 by the compiler will be investigated. To those functions, a different
5753 (more restrictive) limit compared to functions declared inline can
5755 The default value is 90.
5757 @item large-function-insns
5758 The limit specifying really large functions. For functions larger than this
5759 limit after inlining inlining is constrained by
5760 @option{--param large-function-growth}. This parameter is useful primarily
5761 to avoid extreme compilation time caused by non-linear algorithms used by the
5763 This parameter is ignored when @option{-funit-at-a-time} is not used.
5764 The default value is 2700.
5766 @item large-function-growth
5767 Specifies maximal growth of large function caused by inlining in percents.
5768 This parameter is ignored when @option{-funit-at-a-time} is not used.
5769 The default value is 100 which limits large function growth to 2.0 times
5772 @item large-unit-insns
5773 The limit specifying large translation unit. Growth caused by inlining of
5774 units larger than this limit is limited by @option{--param inline-unit-growth}.
5775 For small units this might be too tight (consider unit consisting of function A
5776 that is inline and B that just calls A three time. If B is small relative to
5777 A, the growth of unit is 300\% and yet such inlining is very sane. For very
5778 large units consisting of small inlininable functions however the overall unit
5779 growth limit is needed to avoid exponential explosion of code size. Thus for
5780 smaller units, the size is increased to @option{--param large-unit-insns}
5781 before applying @option{--param inline-unit-growth}. The default is 10000
5783 @item inline-unit-growth
5784 Specifies maximal overall growth of the compilation unit caused by inlining.
5785 This parameter is ignored when @option{-funit-at-a-time} is not used.
5786 The default value is 50 which limits unit growth to 1.5 times the original
5789 @item max-inline-insns-recursive
5790 @itemx max-inline-insns-recursive-auto
5791 Specifies maximum number of instructions out-of-line copy of self recursive inline
5792 function can grow into by performing recursive inlining.
5794 For functions declared inline @option{--param max-inline-insns-recursive} is
5795 taken into account. For function not declared inline, recursive inlining
5796 happens only when @option{-finline-functions} (included in @option{-O3}) is
5797 enabled and @option{--param max-inline-insns-recursive-auto} is used. The
5798 default value is 450.
5800 @item max-inline-recursive-depth
5801 @itemx max-inline-recursive-depth-auto
5802 Specifies maximum recursion depth used by the recursive inlining.
5804 For functions declared inline @option{--param max-inline-recursive-depth} is
5805 taken into account. For function not declared inline, recursive inlining
5806 happens only when @option{-finline-functions} (included in @option{-O3}) is
5807 enabled and @option{--param max-inline-recursive-depth-auto} is used. The
5808 default value is 450.
5810 @item min-inline-recursive-probability
5811 Recursive inlining is profitable only for function having deep recursion
5812 in average and can hurt for function having little recursion depth by
5813 increasing the prologue size or complexity of function body to other
5816 When profile feedback is available (see @option{-fprofile-generate}) the actual
5817 recursion depth can be guessed from probability that function will recurse via
5818 given call expression. This parameter limits inlining only to call expression
5819 whose probability exceeds given threshold (in percents). The default value is
5822 @item inline-call-cost
5823 Specify cost of call instruction relative to simple arithmetics operations
5824 (having cost of 1). Increasing this cost disqualifies inlining of non-leaf
5825 functions and at the same time increases size of leaf function that is believed to
5826 reduce function size by being inlined. In effect it increases amount of
5827 inlining for code having large abstraction penalty (many functions that just
5828 pass the arguments to other functions) and decrease inlining for code with low
5829 abstraction penalty. The default value is 16.
5831 @item max-unrolled-insns
5832 The maximum number of instructions that a loop should have if that loop
5833 is unrolled, and if the loop is unrolled, it determines how many times
5834 the loop code is unrolled.
5836 @item max-average-unrolled-insns
5837 The maximum number of instructions biased by probabilities of their execution
5838 that a loop should have if that loop is unrolled, and if the loop is unrolled,
5839 it determines how many times the loop code is unrolled.
5841 @item max-unroll-times
5842 The maximum number of unrollings of a single loop.
5844 @item max-peeled-insns
5845 The maximum number of instructions that a loop should have if that loop
5846 is peeled, and if the loop is peeled, it determines how many times
5847 the loop code is peeled.
5849 @item max-peel-times
5850 The maximum number of peelings of a single loop.
5852 @item max-completely-peeled-insns
5853 The maximum number of insns of a completely peeled loop.
5855 @item max-completely-peel-times
5856 The maximum number of iterations of a loop to be suitable for complete peeling.
5858 @item max-unswitch-insns
5859 The maximum number of insns of an unswitched loop.
5861 @item max-unswitch-level
5862 The maximum number of branches unswitched in a single loop.
5865 The minimum cost of an expensive expression in the loop invariant motion.
5867 @item iv-consider-all-candidates-bound
5868 Bound on number of candidates for induction variables below that
5869 all candidates are considered for each use in induction variable
5870 optimizations. Only the most relevant candidates are considered
5871 if there are more candidates, to avoid quadratic time complexity.
5873 @item iv-max-considered-uses
5874 The induction variable optimizations give up on loops that contain more
5875 induction variable uses.
5877 @item iv-always-prune-cand-set-bound
5878 If number of candidates in the set is smaller than this value,
5879 we always try to remove unnecessary ivs from the set during its
5880 optimization when a new iv is added to the set.
5882 @item scev-max-expr-size
5883 Bound on size of expressions used in the scalar evolutions analyzer.
5884 Large expressions slow the analyzer.
5886 @item vect-max-version-checks
5887 The maximum number of runtime checks that can be performed when doing
5888 loop versioning in the vectorizer. See option ftree-vect-loop-version
5889 for more information.
5891 @item max-iterations-to-track
5893 The maximum number of iterations of a loop the brute force algorithm
5894 for analysis of # of iterations of the loop tries to evaluate.
5896 @item hot-bb-count-fraction
5897 Select fraction of the maximal count of repetitions of basic block in program
5898 given basic block needs to have to be considered hot.
5900 @item hot-bb-frequency-fraction
5901 Select fraction of the maximal frequency of executions of basic block in
5902 function given basic block needs to have to be considered hot
5904 @item max-predicted-iterations
5905 The maximum number of loop iterations we predict statically. This is useful
5906 in cases where function contain single loop with known bound and other loop
5907 with unknown. We predict the known number of iterations correctly, while
5908 the unknown number of iterations average to roughly 10. This means that the
5909 loop without bounds would appear artificially cold relative to the other one.
5911 @item tracer-dynamic-coverage
5912 @itemx tracer-dynamic-coverage-feedback
5914 This value is used to limit superblock formation once the given percentage of
5915 executed instructions is covered. This limits unnecessary code size
5918 The @option{tracer-dynamic-coverage-feedback} is used only when profile
5919 feedback is available. The real profiles (as opposed to statically estimated
5920 ones) are much less balanced allowing the threshold to be larger value.
5922 @item tracer-max-code-growth
5923 Stop tail duplication once code growth has reached given percentage. This is
5924 rather hokey argument, as most of the duplicates will be eliminated later in
5925 cross jumping, so it may be set to much higher values than is the desired code
5928 @item tracer-min-branch-ratio
5930 Stop reverse growth when the reverse probability of best edge is less than this
5931 threshold (in percent).
5933 @item tracer-min-branch-ratio
5934 @itemx tracer-min-branch-ratio-feedback
5936 Stop forward growth if the best edge do have probability lower than this
5939 Similarly to @option{tracer-dynamic-coverage} two values are present, one for
5940 compilation for profile feedback and one for compilation without. The value
5941 for compilation with profile feedback needs to be more conservative (higher) in
5942 order to make tracer effective.
5944 @item max-cse-path-length
5946 Maximum number of basic blocks on path that cse considers. The default is 10.
5949 The maximum instructions CSE process before flushing. The default is 1000.
5951 @item global-var-threshold
5953 Counts the number of function calls (@var{n}) and the number of
5954 call-clobbered variables (@var{v}). If @var{n}x@var{v} is larger than this limit, a
5955 single artificial variable will be created to represent all the
5956 call-clobbered variables at function call sites. This artificial
5957 variable will then be made to alias every call-clobbered variable.
5958 (done as @code{int * size_t} on the host machine; beware overflow).
5960 @item max-aliased-vops
5962 Maximum number of virtual operands allowed to represent aliases
5963 before triggering the alias grouping heuristic. Alias grouping
5964 reduces compile times and memory consumption needed for aliasing at
5965 the expense of precision loss in alias information.
5967 @item ggc-min-expand
5969 GCC uses a garbage collector to manage its own memory allocation. This
5970 parameter specifies the minimum percentage by which the garbage
5971 collector's heap should be allowed to expand between collections.
5972 Tuning this may improve compilation speed; it has no effect on code
5975 The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
5976 RAM >= 1GB@. If @code{getrlimit} is available, the notion of "RAM" is
5977 the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
5978 GCC is not able to calculate RAM on a particular platform, the lower
5979 bound of 30% is used. Setting this parameter and
5980 @option{ggc-min-heapsize} to zero causes a full collection to occur at
5981 every opportunity. This is extremely slow, but can be useful for
5984 @item ggc-min-heapsize
5986 Minimum size of the garbage collector's heap before it begins bothering
5987 to collect garbage. The first collection occurs after the heap expands
5988 by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
5989 tuning this may improve compilation speed, and has no effect on code
5992 The default is the smaller of RAM/8, RLIMIT_RSS, or a limit which
5993 tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
5994 with a lower bound of 4096 (four megabytes) and an upper bound of
5995 131072 (128 megabytes). If GCC is not able to calculate RAM on a
5996 particular platform, the lower bound is used. Setting this parameter
5997 very large effectively disables garbage collection. Setting this
5998 parameter and @option{ggc-min-expand} to zero causes a full collection
5999 to occur at every opportunity.
6001 @item max-reload-search-insns
6002 The maximum number of instruction reload should look backward for equivalent
6003 register. Increasing values mean more aggressive optimization, making the
6004 compile time increase with probably slightly better performance. The default
6007 @item max-cselib-memory-locations
6008 The maximum number of memory locations cselib should take into account.
6009 Increasing values mean more aggressive optimization, making the compile time
6010 increase with probably slightly better performance. The default value is 500.
6012 @item max-flow-memory-locations
6013 Similar as @option{max-cselib-memory-locations} but for dataflow liveness.
6014 The default value is 100.
6016 @item reorder-blocks-duplicate
6017 @itemx reorder-blocks-duplicate-feedback
6019 Used by basic block reordering pass to decide whether to use unconditional
6020 branch or duplicate the code on its destination. Code is duplicated when its
6021 estimated size is smaller than this value multiplied by the estimated size of
6022 unconditional jump in the hot spots of the program.
6024 The @option{reorder-block-duplicate-feedback} is used only when profile
6025 feedback is available and may be set to higher values than
6026 @option{reorder-block-duplicate} since information about the hot spots is more
6029 @item max-sched-ready-insns
6030 The maximum number of instructions ready to be issued the scheduler should
6031 consider at any given time during the first scheduling pass. Increasing
6032 values mean more thorough searches, making the compilation time increase
6033 with probably little benefit. The default value is 100.
6035 @item max-sched-region-blocks
6036 The maximum number of blocks in a region to be considered for
6037 interblock scheduling. The default value is 10.
6039 @item max-sched-region-insns
6040 The maximum number of insns in a region to be considered for
6041 interblock scheduling. The default value is 100.
6044 The minimum probability (in percents) of reaching a source block
6045 for interblock speculative scheduling. The default value is 40.
6047 @item max-sched-extend-regions-iters
6048 The maximum number of iterations through CFG to extend regions.
6049 0 - disable region extension,
6050 N - do at most N iterations.
6051 The default value is 0.
6053 @item max-sched-insn-conflict-delay
6054 The maximum conflict delay for an insn to be considered for speculative motion.
6055 The default value is 3.
6057 @item sched-spec-prob-cutoff
6058 The minimal probability of speculation success (in percents), so that
6059 speculative insn will be scheduled.
6060 The default value is 40.
6062 @item max-last-value-rtl
6064 The maximum size measured as number of RTLs that can be recorded in an expression
6065 in combiner for a pseudo register as last known value of that register. The default
6068 @item integer-share-limit
6069 Small integer constants can use a shared data structure, reducing the
6070 compiler's memory usage and increasing its speed. This sets the maximum
6071 value of a shared integer constant's. The default value is 256.
6073 @item min-virtual-mappings
6074 Specifies the minimum number of virtual mappings in the incremental
6075 SSA updater that should be registered to trigger the virtual mappings
6076 heuristic defined by virtual-mappings-ratio. The default value is
6079 @item virtual-mappings-ratio
6080 If the number of virtual mappings is virtual-mappings-ratio bigger
6081 than the number of virtual symbols to be updated, then the incremental
6082 SSA updater switches to a full update for those symbols. The default
6085 @item ssp-buffer-size
6086 The minimum size of buffers (i.e. arrays) that will receive stack smashing
6087 protection when @option{-fstack-protection} is used.
6089 @item max-jump-thread-duplication-stmts
6090 Maximum number of statements allowed in a block that needs to be
6091 duplicated when threading jumps.
6093 @item max-fields-for-field-sensitive
6094 Maximum number of fields in a structure we will treat in
6095 a field sensitive manner during pointer analysis.
6100 @node Preprocessor Options
6101 @section Options Controlling the Preprocessor
6102 @cindex preprocessor options
6103 @cindex options, preprocessor
6105 These options control the C preprocessor, which is run on each C source
6106 file before actual compilation.
6108 If you use the @option{-E} option, nothing is done except preprocessing.
6109 Some of these options make sense only together with @option{-E} because
6110 they cause the preprocessor output to be unsuitable for actual
6115 You can use @option{-Wp,@var{option}} to bypass the compiler driver
6116 and pass @var{option} directly through to the preprocessor. If
6117 @var{option} contains commas, it is split into multiple options at the
6118 commas. However, many options are modified, translated or interpreted
6119 by the compiler driver before being passed to the preprocessor, and
6120 @option{-Wp} forcibly bypasses this phase. The preprocessor's direct
6121 interface is undocumented and subject to change, so whenever possible
6122 you should avoid using @option{-Wp} and let the driver handle the
6125 @item -Xpreprocessor @var{option}
6126 @opindex preprocessor
6127 Pass @var{option} as an option to the preprocessor. You can use this to
6128 supply system-specific preprocessor options which GCC does not know how to
6131 If you want to pass an option that takes an argument, you must use
6132 @option{-Xpreprocessor} twice, once for the option and once for the argument.
6135 @include cppopts.texi
6137 @node Assembler Options
6138 @section Passing Options to the Assembler
6140 @c prevent bad page break with this line
6141 You can pass options to the assembler.
6144 @item -Wa,@var{option}
6146 Pass @var{option} as an option to the assembler. If @var{option}
6147 contains commas, it is split into multiple options at the commas.
6149 @item -Xassembler @var{option}
6151 Pass @var{option} as an option to the assembler. You can use this to
6152 supply system-specific assembler options which GCC does not know how to
6155 If you want to pass an option that takes an argument, you must use
6156 @option{-Xassembler} twice, once for the option and once for the argument.
6161 @section Options for Linking
6162 @cindex link options
6163 @cindex options, linking
6165 These options come into play when the compiler links object files into
6166 an executable output file. They are meaningless if the compiler is
6167 not doing a link step.
6171 @item @var{object-file-name}
6172 A file name that does not end in a special recognized suffix is
6173 considered to name an object file or library. (Object files are
6174 distinguished from libraries by the linker according to the file
6175 contents.) If linking is done, these object files are used as input
6184 If any of these options is used, then the linker is not run, and
6185 object file names should not be used as arguments. @xref{Overall
6189 @item -l@var{library}
6190 @itemx -l @var{library}
6192 Search the library named @var{library} when linking. (The second
6193 alternative with the library as a separate argument is only for
6194 POSIX compliance and is not recommended.)
6196 It makes a difference where in the command you write this option; the
6197 linker searches and processes libraries and object files in the order they
6198 are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
6199 after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
6200 to functions in @samp{z}, those functions may not be loaded.
6202 The linker searches a standard list of directories for the library,
6203 which is actually a file named @file{lib@var{library}.a}. The linker
6204 then uses this file as if it had been specified precisely by name.
6206 The directories searched include several standard system directories
6207 plus any that you specify with @option{-L}.
6209 Normally the files found this way are library files---archive files
6210 whose members are object files. The linker handles an archive file by
6211 scanning through it for members which define symbols that have so far
6212 been referenced but not defined. But if the file that is found is an
6213 ordinary object file, it is linked in the usual fashion. The only
6214 difference between using an @option{-l} option and specifying a file name
6215 is that @option{-l} surrounds @var{library} with @samp{lib} and @samp{.a}
6216 and searches several directories.
6219 @opindex nostartfiles
6220 Do not use the standard system startup files when linking.
6221 The standard system libraries are used normally, unless @option{-nostdlib}
6222 or @option{-nodefaultlibs} is used.
6224 @item -nodefaultlibs
6225 @opindex nodefaultlibs
6226 Do not use the standard system libraries when linking.
6227 Only the libraries you specify will be passed to the linker.
6228 The standard startup files are used normally, unless @option{-nostartfiles}
6229 is used. The compiler may generate calls to @code{memcmp},
6230 @code{memset}, @code{memcpy} and @code{memmove}.
6231 These entries are usually resolved by entries in
6232 libc. These entry points should be supplied through some other
6233 mechanism when this option is specified.
6237 Do not use the standard system startup files or libraries when linking.
6238 No startup files and only the libraries you specify will be passed to
6239 the linker. The compiler may generate calls to @code{memcmp}, @code{memset},
6240 @code{memcpy} and @code{memmove}.
6241 These entries are usually resolved by entries in
6242 libc. These entry points should be supplied through some other
6243 mechanism when this option is specified.
6245 @cindex @option{-lgcc}, use with @option{-nostdlib}
6246 @cindex @option{-nostdlib} and unresolved references
6247 @cindex unresolved references and @option{-nostdlib}
6248 @cindex @option{-lgcc}, use with @option{-nodefaultlibs}
6249 @cindex @option{-nodefaultlibs} and unresolved references
6250 @cindex unresolved references and @option{-nodefaultlibs}
6251 One of the standard libraries bypassed by @option{-nostdlib} and
6252 @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
6253 that GCC uses to overcome shortcomings of particular machines, or special
6254 needs for some languages.
6255 (@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
6256 Collection (GCC) Internals},
6257 for more discussion of @file{libgcc.a}.)
6258 In most cases, you need @file{libgcc.a} even when you want to avoid
6259 other standard libraries. In other words, when you specify @option{-nostdlib}
6260 or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
6261 This ensures that you have no unresolved references to internal GCC
6262 library subroutines. (For example, @samp{__main}, used to ensure C++
6263 constructors will be called; @pxref{Collect2,,@code{collect2}, gccint,
6264 GNU Compiler Collection (GCC) Internals}.)
6268 Produce a position independent executable on targets which support it.
6269 For predictable results, you must also specify the same set of options
6270 that were used to generate code (@option{-fpie}, @option{-fPIE},
6271 or model suboptions) when you specify this option.
6275 Pass the flag @option{-export-dynamic} to the ELF linker, on targets
6276 that support it. This instructs the linker to add all symbols, not
6277 only used ones, to the dynamic symbol table. This option is needed
6278 for some uses of @code{dlopen} or to allow obtaining backtraces
6279 from within a program.
6283 Remove all symbol table and relocation information from the executable.
6287 On systems that support dynamic linking, this prevents linking with the shared
6288 libraries. On other systems, this option has no effect.
6292 Produce a shared object which can then be linked with other objects to
6293 form an executable. Not all systems support this option. For predictable
6294 results, you must also specify the same set of options that were used to
6295 generate code (@option{-fpic}, @option{-fPIC}, or model suboptions)
6296 when you specify this option.@footnote{On some systems, @samp{gcc -shared}
6297 needs to build supplementary stub code for constructors to work. On
6298 multi-libbed systems, @samp{gcc -shared} must select the correct support
6299 libraries to link against. Failing to supply the correct flags may lead
6300 to subtle defects. Supplying them in cases where they are not necessary
6303 @item -shared-libgcc
6304 @itemx -static-libgcc
6305 @opindex shared-libgcc
6306 @opindex static-libgcc
6307 On systems that provide @file{libgcc} as a shared library, these options
6308 force the use of either the shared or static version respectively.
6309 If no shared version of @file{libgcc} was built when the compiler was
6310 configured, these options have no effect.
6312 There are several situations in which an application should use the
6313 shared @file{libgcc} instead of the static version. The most common
6314 of these is when the application wishes to throw and catch exceptions
6315 across different shared libraries. In that case, each of the libraries
6316 as well as the application itself should use the shared @file{libgcc}.
6318 Therefore, the G++ and GCJ drivers automatically add
6319 @option{-shared-libgcc} whenever you build a shared library or a main
6320 executable, because C++ and Java programs typically use exceptions, so
6321 this is the right thing to do.
6323 If, instead, you use the GCC driver to create shared libraries, you may
6324 find that they will not always be linked with the shared @file{libgcc}.
6325 If GCC finds, at its configuration time, that you have a non-GNU linker
6326 or a GNU linker that does not support option @option{--eh-frame-hdr},
6327 it will link the shared version of @file{libgcc} into shared libraries
6328 by default. Otherwise, it will take advantage of the linker and optimize
6329 away the linking with the shared version of @file{libgcc}, linking with
6330 the static version of libgcc by default. This allows exceptions to
6331 propagate through such shared libraries, without incurring relocation
6332 costs at library load time.
6334 However, if a library or main executable is supposed to throw or catch
6335 exceptions, you must link it using the G++ or GCJ driver, as appropriate
6336 for the languages used in the program, or using the option
6337 @option{-shared-libgcc}, such that it is linked with the shared
6342 Bind references to global symbols when building a shared object. Warn
6343 about any unresolved references (unless overridden by the link editor
6344 option @samp{-Xlinker -z -Xlinker defs}). Only a few systems support
6347 @item -Xlinker @var{option}
6349 Pass @var{option} as an option to the linker. You can use this to
6350 supply system-specific linker options which GCC does not know how to
6353 If you want to pass an option that takes an argument, you must use
6354 @option{-Xlinker} twice, once for the option and once for the argument.
6355 For example, to pass @option{-assert definitions}, you must write
6356 @samp{-Xlinker -assert -Xlinker definitions}. It does not work to write
6357 @option{-Xlinker "-assert definitions"}, because this passes the entire
6358 string as a single argument, which is not what the linker expects.
6360 @item -Wl,@var{option}
6362 Pass @var{option} as an option to the linker. If @var{option} contains
6363 commas, it is split into multiple options at the commas.
6365 @item -u @var{symbol}
6367 Pretend the symbol @var{symbol} is undefined, to force linking of
6368 library modules to define it. You can use @option{-u} multiple times with
6369 different symbols to force loading of additional library modules.
6372 @node Directory Options
6373 @section Options for Directory Search
6374 @cindex directory options
6375 @cindex options, directory search
6378 These options specify directories to search for header files, for
6379 libraries and for parts of the compiler:
6384 Add the directory @var{dir} to the head of the list of directories to be
6385 searched for header files. This can be used to override a system header
6386 file, substituting your own version, since these directories are
6387 searched before the system header file directories. However, you should
6388 not use this option to add directories that contain vendor-supplied
6389 system header files (use @option{-isystem} for that). If you use more than
6390 one @option{-I} option, the directories are scanned in left-to-right
6391 order; the standard system directories come after.
6393 If a standard system include directory, or a directory specified with
6394 @option{-isystem}, is also specified with @option{-I}, the @option{-I}
6395 option will be ignored. The directory will still be searched but as a
6396 system directory at its normal position in the system include chain.
6397 This is to ensure that GCC's procedure to fix buggy system headers and
6398 the ordering for the include_next directive are not inadvertently changed.
6399 If you really need to change the search order for system directories,
6400 use the @option{-nostdinc} and/or @option{-isystem} options.
6402 @item -iquote@var{dir}
6404 Add the directory @var{dir} to the head of the list of directories to
6405 be searched for header files only for the case of @samp{#include
6406 "@var{file}"}; they are not searched for @samp{#include <@var{file}>},
6407 otherwise just like @option{-I}.
6411 Add directory @var{dir} to the list of directories to be searched
6414 @item -B@var{prefix}
6416 This option specifies where to find the executables, libraries,
6417 include files, and data files of the compiler itself.
6419 The compiler driver program runs one or more of the subprograms
6420 @file{cpp}, @file{cc1}, @file{as} and @file{ld}. It tries
6421 @var{prefix} as a prefix for each program it tries to run, both with and
6422 without @samp{@var{machine}/@var{version}/} (@pxref{Target Options}).
6424 For each subprogram to be run, the compiler driver first tries the
6425 @option{-B} prefix, if any. If that name is not found, or if @option{-B}
6426 was not specified, the driver tries two standard prefixes, which are
6427 @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
6428 those results in a file name that is found, the unmodified program
6429 name is searched for using the directories specified in your
6430 @env{PATH} environment variable.
6432 The compiler will check to see if the path provided by the @option{-B}
6433 refers to a directory, and if necessary it will add a directory
6434 separator character at the end of the path.
6436 @option{-B} prefixes that effectively specify directory names also apply
6437 to libraries in the linker, because the compiler translates these
6438 options into @option{-L} options for the linker. They also apply to
6439 includes files in the preprocessor, because the compiler translates these
6440 options into @option{-isystem} options for the preprocessor. In this case,
6441 the compiler appends @samp{include} to the prefix.
6443 The run-time support file @file{libgcc.a} can also be searched for using
6444 the @option{-B} prefix, if needed. If it is not found there, the two
6445 standard prefixes above are tried, and that is all. The file is left
6446 out of the link if it is not found by those means.
6448 Another way to specify a prefix much like the @option{-B} prefix is to use
6449 the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
6452 As a special kludge, if the path provided by @option{-B} is
6453 @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
6454 9, then it will be replaced by @file{[dir/]include}. This is to help
6455 with boot-strapping the compiler.
6457 @item -specs=@var{file}
6459 Process @var{file} after the compiler reads in the standard @file{specs}
6460 file, in order to override the defaults that the @file{gcc} driver
6461 program uses when determining what switches to pass to @file{cc1},
6462 @file{cc1plus}, @file{as}, @file{ld}, etc. More than one
6463 @option{-specs=@var{file}} can be specified on the command line, and they
6464 are processed in order, from left to right.
6466 @item --sysroot=@var{dir}
6468 Use @var{dir} as the logical root directory for headers and libraries.
6469 For example, if the compiler would normally search for headers in
6470 @file{/usr/include} and libraries in @file{/usr/lib}, it will instead
6471 search @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
6473 If you use both this option and the @option{-isysroot} option, then
6474 the @option{--sysroot} option will apply to libraries, but the
6475 @option{-isysroot} option will apply to header files.
6477 The GNU linker (beginning with version 2.16) has the necessary support
6478 for this option. If your linker does not support this option, the
6479 header file aspect of @option{--sysroot} will still work, but the
6480 library aspect will not.
6484 This option has been deprecated. Please use @option{-iquote} instead for
6485 @option{-I} directories before the @option{-I-} and remove the @option{-I-}.
6486 Any directories you specify with @option{-I} options before the @option{-I-}
6487 option are searched only for the case of @samp{#include "@var{file}"};
6488 they are not searched for @samp{#include <@var{file}>}.
6490 If additional directories are specified with @option{-I} options after
6491 the @option{-I-}, these directories are searched for all @samp{#include}
6492 directives. (Ordinarily @emph{all} @option{-I} directories are used
6495 In addition, the @option{-I-} option inhibits the use of the current
6496 directory (where the current input file came from) as the first search
6497 directory for @samp{#include "@var{file}"}. There is no way to
6498 override this effect of @option{-I-}. With @option{-I.} you can specify
6499 searching the directory which was current when the compiler was
6500 invoked. That is not exactly the same as what the preprocessor does
6501 by default, but it is often satisfactory.
6503 @option{-I-} does not inhibit the use of the standard system directories
6504 for header files. Thus, @option{-I-} and @option{-nostdinc} are
6511 @section Specifying subprocesses and the switches to pass to them
6514 @command{gcc} is a driver program. It performs its job by invoking a
6515 sequence of other programs to do the work of compiling, assembling and
6516 linking. GCC interprets its command-line parameters and uses these to
6517 deduce which programs it should invoke, and which command-line options
6518 it ought to place on their command lines. This behavior is controlled
6519 by @dfn{spec strings}. In most cases there is one spec string for each
6520 program that GCC can invoke, but a few programs have multiple spec
6521 strings to control their behavior. The spec strings built into GCC can
6522 be overridden by using the @option{-specs=} command-line switch to specify
6525 @dfn{Spec files} are plaintext files that are used to construct spec
6526 strings. They consist of a sequence of directives separated by blank
6527 lines. The type of directive is determined by the first non-whitespace
6528 character on the line and it can be one of the following:
6531 @item %@var{command}
6532 Issues a @var{command} to the spec file processor. The commands that can
6536 @item %include <@var{file}>
6538 Search for @var{file} and insert its text at the current point in the
6541 @item %include_noerr <@var{file}>
6542 @cindex %include_noerr
6543 Just like @samp{%include}, but do not generate an error message if the include
6544 file cannot be found.
6546 @item %rename @var{old_name} @var{new_name}
6548 Rename the spec string @var{old_name} to @var{new_name}.
6552 @item *[@var{spec_name}]:
6553 This tells the compiler to create, override or delete the named spec
6554 string. All lines after this directive up to the next directive or
6555 blank line are considered to be the text for the spec string. If this
6556 results in an empty string then the spec will be deleted. (Or, if the
6557 spec did not exist, then nothing will happened.) Otherwise, if the spec
6558 does not currently exist a new spec will be created. If the spec does
6559 exist then its contents will be overridden by the text of this
6560 directive, unless the first character of that text is the @samp{+}
6561 character, in which case the text will be appended to the spec.
6563 @item [@var{suffix}]:
6564 Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
6565 and up to the next directive or blank line are considered to make up the
6566 spec string for the indicated suffix. When the compiler encounters an
6567 input file with the named suffix, it will processes the spec string in
6568 order to work out how to compile that file. For example:
6575 This says that any input file whose name ends in @samp{.ZZ} should be
6576 passed to the program @samp{z-compile}, which should be invoked with the
6577 command-line switch @option{-input} and with the result of performing the
6578 @samp{%i} substitution. (See below.)
6580 As an alternative to providing a spec string, the text that follows a
6581 suffix directive can be one of the following:
6584 @item @@@var{language}
6585 This says that the suffix is an alias for a known @var{language}. This is
6586 similar to using the @option{-x} command-line switch to GCC to specify a
6587 language explicitly. For example:
6594 Says that .ZZ files are, in fact, C++ source files.
6597 This causes an error messages saying:
6600 @var{name} compiler not installed on this system.
6604 GCC already has an extensive list of suffixes built into it.
6605 This directive will add an entry to the end of the list of suffixes, but
6606 since the list is searched from the end backwards, it is effectively
6607 possible to override earlier entries using this technique.
6611 GCC has the following spec strings built into it. Spec files can
6612 override these strings or create their own. Note that individual
6613 targets can also add their own spec strings to this list.
6616 asm Options to pass to the assembler
6617 asm_final Options to pass to the assembler post-processor
6618 cpp Options to pass to the C preprocessor
6619 cc1 Options to pass to the C compiler
6620 cc1plus Options to pass to the C++ compiler
6621 endfile Object files to include at the end of the link
6622 link Options to pass to the linker
6623 lib Libraries to include on the command line to the linker
6624 libgcc Decides which GCC support library to pass to the linker
6625 linker Sets the name of the linker
6626 predefines Defines to be passed to the C preprocessor
6627 signed_char Defines to pass to CPP to say whether @code{char} is signed
6629 startfile Object files to include at the start of the link
6632 Here is a small example of a spec file:
6638 --start-group -lgcc -lc -leval1 --end-group %(old_lib)
6641 This example renames the spec called @samp{lib} to @samp{old_lib} and
6642 then overrides the previous definition of @samp{lib} with a new one.
6643 The new definition adds in some extra command-line options before
6644 including the text of the old definition.
6646 @dfn{Spec strings} are a list of command-line options to be passed to their
6647 corresponding program. In addition, the spec strings can contain
6648 @samp{%}-prefixed sequences to substitute variable text or to
6649 conditionally insert text into the command line. Using these constructs
6650 it is possible to generate quite complex command lines.
6652 Here is a table of all defined @samp{%}-sequences for spec
6653 strings. Note that spaces are not generated automatically around the
6654 results of expanding these sequences. Therefore you can concatenate them
6655 together or combine them with constant text in a single argument.
6659 Substitute one @samp{%} into the program name or argument.
6662 Substitute the name of the input file being processed.
6665 Substitute the basename of the input file being processed.
6666 This is the substring up to (and not including) the last period
6667 and not including the directory.
6670 This is the same as @samp{%b}, but include the file suffix (text after
6674 Marks the argument containing or following the @samp{%d} as a
6675 temporary file name, so that that file will be deleted if GCC exits
6676 successfully. Unlike @samp{%g}, this contributes no text to the
6679 @item %g@var{suffix}
6680 Substitute a file name that has suffix @var{suffix} and is chosen
6681 once per compilation, and mark the argument in the same way as
6682 @samp{%d}. To reduce exposure to denial-of-service attacks, the file
6683 name is now chosen in a way that is hard to predict even when previously
6684 chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
6685 might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
6686 the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
6687 treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
6688 was simply substituted with a file name chosen once per compilation,
6689 without regard to any appended suffix (which was therefore treated
6690 just like ordinary text), making such attacks more likely to succeed.
6692 @item %u@var{suffix}
6693 Like @samp{%g}, but generates a new temporary file name even if
6694 @samp{%u@var{suffix}} was already seen.
6696 @item %U@var{suffix}
6697 Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
6698 new one if there is no such last file name. In the absence of any
6699 @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
6700 the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
6701 would involve the generation of two distinct file names, one
6702 for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
6703 simply substituted with a file name chosen for the previous @samp{%u},
6704 without regard to any appended suffix.
6706 @item %j@var{suffix}
6707 Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
6708 writable, and if save-temps is off; otherwise, substitute the name
6709 of a temporary file, just like @samp{%u}. This temporary file is not
6710 meant for communication between processes, but rather as a junk
6713 @item %|@var{suffix}
6714 @itemx %m@var{suffix}
6715 Like @samp{%g}, except if @option{-pipe} is in effect. In that case
6716 @samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
6717 all. These are the two most common ways to instruct a program that it
6718 should read from standard input or write to standard output. If you
6719 need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
6720 construct: see for example @file{f/lang-specs.h}.
6722 @item %.@var{SUFFIX}
6723 Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
6724 when it is subsequently output with @samp{%*}. @var{SUFFIX} is
6725 terminated by the next space or %.
6728 Marks the argument containing or following the @samp{%w} as the
6729 designated output file of this compilation. This puts the argument
6730 into the sequence of arguments that @samp{%o} will substitute later.
6733 Substitutes the names of all the output files, with spaces
6734 automatically placed around them. You should write spaces
6735 around the @samp{%o} as well or the results are undefined.
6736 @samp{%o} is for use in the specs for running the linker.
6737 Input files whose names have no recognized suffix are not compiled
6738 at all, but they are included among the output files, so they will
6742 Substitutes the suffix for object files. Note that this is
6743 handled specially when it immediately follows @samp{%g, %u, or %U},
6744 because of the need for those to form complete file names. The
6745 handling is such that @samp{%O} is treated exactly as if it had already
6746 been substituted, except that @samp{%g, %u, and %U} do not currently
6747 support additional @var{suffix} characters following @samp{%O} as they would
6748 following, for example, @samp{.o}.
6751 Substitutes the standard macro predefinitions for the
6752 current target machine. Use this when running @code{cpp}.
6755 Like @samp{%p}, but puts @samp{__} before and after the name of each
6756 predefined macro, except for macros that start with @samp{__} or with
6757 @samp{_@var{L}}, where @var{L} is an uppercase letter. This is for ISO
6761 Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
6762 @option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
6763 @option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
6764 and @option{-imultilib} as necessary.
6767 Current argument is the name of a library or startup file of some sort.
6768 Search for that file in a standard list of directories and substitute
6769 the full name found.
6772 Print @var{str} as an error message. @var{str} is terminated by a newline.
6773 Use this when inconsistent options are detected.
6776 Substitute the contents of spec string @var{name} at this point.
6779 Like @samp{%(@dots{})} but put @samp{__} around @option{-D} arguments.
6781 @item %x@{@var{option}@}
6782 Accumulate an option for @samp{%X}.
6785 Output the accumulated linker options specified by @option{-Wl} or a @samp{%x}
6789 Output the accumulated assembler options specified by @option{-Wa}.
6792 Output the accumulated preprocessor options specified by @option{-Wp}.
6795 Process the @code{asm} spec. This is used to compute the
6796 switches to be passed to the assembler.
6799 Process the @code{asm_final} spec. This is a spec string for
6800 passing switches to an assembler post-processor, if such a program is
6804 Process the @code{link} spec. This is the spec for computing the
6805 command line passed to the linker. Typically it will make use of the
6806 @samp{%L %G %S %D and %E} sequences.
6809 Dump out a @option{-L} option for each directory that GCC believes might
6810 contain startup files. If the target supports multilibs then the
6811 current multilib directory will be prepended to each of these paths.
6814 Process the @code{lib} spec. This is a spec string for deciding which
6815 libraries should be included on the command line to the linker.
6818 Process the @code{libgcc} spec. This is a spec string for deciding
6819 which GCC support library should be included on the command line to the linker.
6822 Process the @code{startfile} spec. This is a spec for deciding which
6823 object files should be the first ones passed to the linker. Typically
6824 this might be a file named @file{crt0.o}.
6827 Process the @code{endfile} spec. This is a spec string that specifies
6828 the last object files that will be passed to the linker.
6831 Process the @code{cpp} spec. This is used to construct the arguments
6832 to be passed to the C preprocessor.
6835 Process the @code{cc1} spec. This is used to construct the options to be
6836 passed to the actual C compiler (@samp{cc1}).
6839 Process the @code{cc1plus} spec. This is used to construct the options to be
6840 passed to the actual C++ compiler (@samp{cc1plus}).
6843 Substitute the variable part of a matched option. See below.
6844 Note that each comma in the substituted string is replaced by
6848 Remove all occurrences of @code{-S} from the command line. Note---this
6849 command is position dependent. @samp{%} commands in the spec string
6850 before this one will see @code{-S}, @samp{%} commands in the spec string
6851 after this one will not.
6853 @item %:@var{function}(@var{args})
6854 Call the named function @var{function}, passing it @var{args}.
6855 @var{args} is first processed as a nested spec string, then split
6856 into an argument vector in the usual fashion. The function returns
6857 a string which is processed as if it had appeared literally as part
6858 of the current spec.
6860 The following built-in spec functions are provided:
6863 @item @code{if-exists}
6864 The @code{if-exists} spec function takes one argument, an absolute
6865 pathname to a file. If the file exists, @code{if-exists} returns the
6866 pathname. Here is a small example of its usage:
6870 crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
6873 @item @code{if-exists-else}
6874 The @code{if-exists-else} spec function is similar to the @code{if-exists}
6875 spec function, except that it takes two arguments. The first argument is
6876 an absolute pathname to a file. If the file exists, @code{if-exists-else}
6877 returns the pathname. If it does not exist, it returns the second argument.
6878 This way, @code{if-exists-else} can be used to select one file or another,
6879 based on the existence of the first. Here is a small example of its usage:
6883 crt0%O%s %:if-exists(crti%O%s) \
6884 %:if-exists-else(crtbeginT%O%s crtbegin%O%s)
6887 @item @code{replace-outfile}
6888 The @code{replace-outfile} spec function takes two arguments. It looks for the
6889 first argument in the outfiles array and replaces it with the second argument. Here
6890 is a small example of its usage:
6893 %@{static|static-libgcc|static-libstdc++:%:replace-outfile(-lstdc++ \
6901 Substitutes the @code{-S} switch, if that switch was given to GCC@.
6902 If that switch was not specified, this substitutes nothing. Note that
6903 the leading dash is omitted when specifying this option, and it is
6904 automatically inserted if the substitution is performed. Thus the spec
6905 string @samp{%@{foo@}} would match the command-line option @option{-foo}
6906 and would output the command line option @option{-foo}.
6908 @item %W@{@code{S}@}
6909 Like %@{@code{S}@} but mark last argument supplied within as a file to be
6912 @item %@{@code{S}*@}
6913 Substitutes all the switches specified to GCC whose names start
6914 with @code{-S}, but which also take an argument. This is used for
6915 switches like @option{-o}, @option{-D}, @option{-I}, etc.
6916 GCC considers @option{-o foo} as being
6917 one switch whose names starts with @samp{o}. %@{o*@} would substitute this
6918 text, including the space. Thus two arguments would be generated.
6920 @item %@{@code{S}*&@code{T}*@}
6921 Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
6922 (the order of @code{S} and @code{T} in the spec is not significant).
6923 There can be any number of ampersand-separated variables; for each the
6924 wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
6926 @item %@{@code{S}:@code{X}@}
6927 Substitutes @code{X}, if the @samp{-S} switch was given to GCC@.
6929 @item %@{!@code{S}:@code{X}@}
6930 Substitutes @code{X}, if the @samp{-S} switch was @emph{not} given to GCC@.
6932 @item %@{@code{S}*:@code{X}@}
6933 Substitutes @code{X} if one or more switches whose names start with
6934 @code{-S} are specified to GCC@. Normally @code{X} is substituted only
6935 once, no matter how many such switches appeared. However, if @code{%*}
6936 appears somewhere in @code{X}, then @code{X} will be substituted once
6937 for each matching switch, with the @code{%*} replaced by the part of
6938 that switch that matched the @code{*}.
6940 @item %@{.@code{S}:@code{X}@}
6941 Substitutes @code{X}, if processing a file with suffix @code{S}.
6943 @item %@{!.@code{S}:@code{X}@}
6944 Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
6946 @item %@{@code{S}|@code{P}:@code{X}@}
6947 Substitutes @code{X} if either @code{-S} or @code{-P} was given to GCC@.
6948 This may be combined with @samp{!}, @samp{.}, and @code{*} sequences as well,
6949 although they have a stronger binding than the @samp{|}. If @code{%*}
6950 appears in @code{X}, all of the alternatives must be starred, and only
6951 the first matching alternative is substituted.
6953 For example, a spec string like this:
6956 %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
6959 will output the following command-line options from the following input
6960 command-line options:
6965 -d fred.c -foo -baz -boggle
6966 -d jim.d -bar -baz -boggle
6969 @item %@{S:X; T:Y; :D@}
6971 If @code{S} was given to GCC, substitutes @code{X}; else if @code{T} was
6972 given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
6973 be as many clauses as you need. This may be combined with @code{.},
6974 @code{!}, @code{|}, and @code{*} as needed.
6979 The conditional text @code{X} in a %@{@code{S}:@code{X}@} or similar
6980 construct may contain other nested @samp{%} constructs or spaces, or
6981 even newlines. They are processed as usual, as described above.
6982 Trailing white space in @code{X} is ignored. White space may also
6983 appear anywhere on the left side of the colon in these constructs,
6984 except between @code{.} or @code{*} and the corresponding word.
6986 The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
6987 handled specifically in these constructs. If another value of
6988 @option{-O} or the negated form of a @option{-f}, @option{-m}, or
6989 @option{-W} switch is found later in the command line, the earlier
6990 switch value is ignored, except with @{@code{S}*@} where @code{S} is
6991 just one letter, which passes all matching options.
6993 The character @samp{|} at the beginning of the predicate text is used to
6994 indicate that a command should be piped to the following command, but
6995 only if @option{-pipe} is specified.
6997 It is built into GCC which switches take arguments and which do not.
6998 (You might think it would be useful to generalize this to allow each
6999 compiler's spec to say which switches take arguments. But this cannot
7000 be done in a consistent fashion. GCC cannot even decide which input
7001 files have been specified without knowing which switches take arguments,
7002 and it must know which input files to compile in order to tell which
7005 GCC also knows implicitly that arguments starting in @option{-l} are to be
7006 treated as compiler output files, and passed to the linker in their
7007 proper position among the other output files.
7009 @c man begin OPTIONS
7011 @node Target Options
7012 @section Specifying Target Machine and Compiler Version
7013 @cindex target options
7014 @cindex cross compiling
7015 @cindex specifying machine version
7016 @cindex specifying compiler version and target machine
7017 @cindex compiler version, specifying
7018 @cindex target machine, specifying
7020 The usual way to run GCC is to run the executable called @file{gcc}, or
7021 @file{<machine>-gcc} when cross-compiling, or
7022 @file{<machine>-gcc-<version>} to run a version other than the one that
7023 was installed last. Sometimes this is inconvenient, so GCC provides
7024 options that will switch to another cross-compiler or version.
7027 @item -b @var{machine}
7029 The argument @var{machine} specifies the target machine for compilation.
7031 The value to use for @var{machine} is the same as was specified as the
7032 machine type when configuring GCC as a cross-compiler. For
7033 example, if a cross-compiler was configured with @samp{configure
7034 arm-elf}, meaning to compile for an arm processor with elf binaries,
7035 then you would specify @option{-b arm-elf} to run that cross compiler.
7036 Because there are other options beginning with @option{-b}, the
7037 configuration must contain a hyphen.
7039 @item -V @var{version}
7041 The argument @var{version} specifies which version of GCC to run.
7042 This is useful when multiple versions are installed. For example,
7043 @var{version} might be @samp{4.0}, meaning to run GCC version 4.0.
7046 The @option{-V} and @option{-b} options work by running the
7047 @file{<machine>-gcc-<version>} executable, so there's no real reason to
7048 use them if you can just run that directly.
7050 @node Submodel Options
7051 @section Hardware Models and Configurations
7052 @cindex submodel options
7053 @cindex specifying hardware config
7054 @cindex hardware models and configurations, specifying
7055 @cindex machine dependent options
7057 Earlier we discussed the standard option @option{-b} which chooses among
7058 different installed compilers for completely different target
7059 machines, such as VAX vs.@: 68000 vs.@: 80386.
7061 In addition, each of these target machine types can have its own
7062 special options, starting with @samp{-m}, to choose among various
7063 hardware models or configurations---for example, 68010 vs 68020,
7064 floating coprocessor or none. A single installed version of the
7065 compiler can compile for any model or configuration, according to the
7068 Some configurations of the compiler also support additional special
7069 options, usually for compatibility with other compilers on the same
7072 @c This list is ordered alphanumerically by subsection name.
7073 @c It should be the same order and spelling as these options are listed
7074 @c in Machine Dependent Options
7080 * Blackfin Options::
7084 * DEC Alpha Options::
7085 * DEC Alpha/VMS Options::
7087 * GNU/Linux Options::
7090 * i386 and x86-64 Options::
7103 * RS/6000 and PowerPC Options::
7104 * S/390 and zSeries Options::
7108 * System V Options::
7109 * TMS320C3x/C4x Options::
7113 * Xstormy16 Options::
7119 @subsection ARC Options
7122 These options are defined for ARC implementations:
7127 Compile code for little endian mode. This is the default.
7131 Compile code for big endian mode.
7134 @opindex mmangle-cpu
7135 Prepend the name of the cpu to all public symbol names.
7136 In multiple-processor systems, there are many ARC variants with different
7137 instruction and register set characteristics. This flag prevents code
7138 compiled for one cpu to be linked with code compiled for another.
7139 No facility exists for handling variants that are ``almost identical''.
7140 This is an all or nothing option.
7142 @item -mcpu=@var{cpu}
7144 Compile code for ARC variant @var{cpu}.
7145 Which variants are supported depend on the configuration.
7146 All variants support @option{-mcpu=base}, this is the default.
7148 @item -mtext=@var{text-section}
7149 @itemx -mdata=@var{data-section}
7150 @itemx -mrodata=@var{readonly-data-section}
7154 Put functions, data, and readonly data in @var{text-section},
7155 @var{data-section}, and @var{readonly-data-section} respectively
7156 by default. This can be overridden with the @code{section} attribute.
7157 @xref{Variable Attributes}.
7162 @subsection ARM Options
7165 These @samp{-m} options are defined for Advanced RISC Machines (ARM)
7169 @item -mabi=@var{name}
7171 Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
7172 @samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}.
7175 @opindex mapcs-frame
7176 Generate a stack frame that is compliant with the ARM Procedure Call
7177 Standard for all functions, even if this is not strictly necessary for
7178 correct execution of the code. Specifying @option{-fomit-frame-pointer}
7179 with this option will cause the stack frames not to be generated for
7180 leaf functions. The default is @option{-mno-apcs-frame}.
7184 This is a synonym for @option{-mapcs-frame}.
7187 @c not currently implemented
7188 @item -mapcs-stack-check
7189 @opindex mapcs-stack-check
7190 Generate code to check the amount of stack space available upon entry to
7191 every function (that actually uses some stack space). If there is
7192 insufficient space available then either the function
7193 @samp{__rt_stkovf_split_small} or @samp{__rt_stkovf_split_big} will be
7194 called, depending upon the amount of stack space required. The run time
7195 system is required to provide these functions. The default is
7196 @option{-mno-apcs-stack-check}, since this produces smaller code.
7198 @c not currently implemented
7200 @opindex mapcs-float
7201 Pass floating point arguments using the float point registers. This is
7202 one of the variants of the APCS@. This option is recommended if the
7203 target hardware has a floating point unit or if a lot of floating point
7204 arithmetic is going to be performed by the code. The default is
7205 @option{-mno-apcs-float}, since integer only code is slightly increased in
7206 size if @option{-mapcs-float} is used.
7208 @c not currently implemented
7209 @item -mapcs-reentrant
7210 @opindex mapcs-reentrant
7211 Generate reentrant, position independent code. The default is
7212 @option{-mno-apcs-reentrant}.
7215 @item -mthumb-interwork
7216 @opindex mthumb-interwork
7217 Generate code which supports calling between the ARM and Thumb
7218 instruction sets. Without this option the two instruction sets cannot
7219 be reliably used inside one program. The default is
7220 @option{-mno-thumb-interwork}, since slightly larger code is generated
7221 when @option{-mthumb-interwork} is specified.
7223 @item -mno-sched-prolog
7224 @opindex mno-sched-prolog
7225 Prevent the reordering of instructions in the function prolog, or the
7226 merging of those instruction with the instructions in the function's
7227 body. This means that all functions will start with a recognizable set
7228 of instructions (or in fact one of a choice from a small set of
7229 different function prologues), and this information can be used to
7230 locate the start if functions inside an executable piece of code. The
7231 default is @option{-msched-prolog}.
7234 @opindex mhard-float
7235 Generate output containing floating point instructions. This is the
7239 @opindex msoft-float
7240 Generate output containing library calls for floating point.
7241 @strong{Warning:} the requisite libraries are not available for all ARM
7242 targets. Normally the facilities of the machine's usual C compiler are
7243 used, but this cannot be done directly in cross-compilation. You must make
7244 your own arrangements to provide suitable library functions for
7247 @option{-msoft-float} changes the calling convention in the output file;
7248 therefore, it is only useful if you compile @emph{all} of a program with
7249 this option. In particular, you need to compile @file{libgcc.a}, the
7250 library that comes with GCC, with @option{-msoft-float} in order for
7253 @item -mfloat-abi=@var{name}
7255 Specifies which ABI to use for floating point values. Permissible values
7256 are: @samp{soft}, @samp{softfp} and @samp{hard}.
7258 @samp{soft} and @samp{hard} are equivalent to @option{-msoft-float}
7259 and @option{-mhard-float} respectively. @samp{softfp} allows the generation
7260 of floating point instructions, but still uses the soft-float calling
7263 @item -mlittle-endian
7264 @opindex mlittle-endian
7265 Generate code for a processor running in little-endian mode. This is
7266 the default for all standard configurations.
7269 @opindex mbig-endian
7270 Generate code for a processor running in big-endian mode; the default is
7271 to compile code for a little-endian processor.
7273 @item -mwords-little-endian
7274 @opindex mwords-little-endian
7275 This option only applies when generating code for big-endian processors.
7276 Generate code for a little-endian word order but a big-endian byte
7277 order. That is, a byte order of the form @samp{32107654}. Note: this
7278 option should only be used if you require compatibility with code for
7279 big-endian ARM processors generated by versions of the compiler prior to
7282 @item -mcpu=@var{name}
7284 This specifies the name of the target ARM processor. GCC uses this name
7285 to determine what kind of instructions it can emit when generating
7286 assembly code. Permissible names are: @samp{arm2}, @samp{arm250},
7287 @samp{arm3}, @samp{arm6}, @samp{arm60}, @samp{arm600}, @samp{arm610},
7288 @samp{arm620}, @samp{arm7}, @samp{arm7m}, @samp{arm7d}, @samp{arm7dm},
7289 @samp{arm7di}, @samp{arm7dmi}, @samp{arm70}, @samp{arm700},
7290 @samp{arm700i}, @samp{arm710}, @samp{arm710c}, @samp{arm7100},
7291 @samp{arm7500}, @samp{arm7500fe}, @samp{arm7tdmi}, @samp{arm7tdmi-s},
7292 @samp{arm8}, @samp{strongarm}, @samp{strongarm110}, @samp{strongarm1100},
7293 @samp{arm8}, @samp{arm810}, @samp{arm9}, @samp{arm9e}, @samp{arm920},
7294 @samp{arm920t}, @samp{arm922t}, @samp{arm946e-s}, @samp{arm966e-s},
7295 @samp{arm968e-s}, @samp{arm926ej-s}, @samp{arm940t}, @samp{arm9tdmi},
7296 @samp{arm10tdmi}, @samp{arm1020t}, @samp{arm1026ej-s},
7297 @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
7298 @samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
7299 @samp{arm1176jz-s}, @samp{arm1176jzf-s}, @samp{xscale}, @samp{iwmmxt},
7302 @itemx -mtune=@var{name}
7304 This option is very similar to the @option{-mcpu=} option, except that
7305 instead of specifying the actual target processor type, and hence
7306 restricting which instructions can be used, it specifies that GCC should
7307 tune the performance of the code as if the target were of the type
7308 specified in this option, but still choosing the instructions that it
7309 will generate based on the cpu specified by a @option{-mcpu=} option.
7310 For some ARM implementations better performance can be obtained by using
7313 @item -march=@var{name}
7315 This specifies the name of the target ARM architecture. GCC uses this
7316 name to determine what kind of instructions it can emit when generating
7317 assembly code. This option can be used in conjunction with or instead
7318 of the @option{-mcpu=} option. Permissible names are: @samp{armv2},
7319 @samp{armv2a}, @samp{armv3}, @samp{armv3m}, @samp{armv4}, @samp{armv4t},
7320 @samp{armv5}, @samp{armv5t}, @samp{armv5te}, @samp{armv6}, @samp{armv6j},
7321 @samp{iwmmxt}, @samp{ep9312}.
7323 @item -mfpu=@var{name}
7324 @itemx -mfpe=@var{number}
7325 @itemx -mfp=@var{number}
7329 This specifies what floating point hardware (or hardware emulation) is
7330 available on the target. Permissible names are: @samp{fpa}, @samp{fpe2},
7331 @samp{fpe3}, @samp{maverick}, @samp{vfp}. @option{-mfp} and @option{-mfpe}
7332 are synonyms for @option{-mfpu}=@samp{fpe}@var{number}, for compatibility
7333 with older versions of GCC@.
7335 If @option{-msoft-float} is specified this specifies the format of
7336 floating point values.
7338 @item -mstructure-size-boundary=@var{n}
7339 @opindex mstructure-size-boundary
7340 The size of all structures and unions will be rounded up to a multiple
7341 of the number of bits set by this option. Permissible values are 8, 32
7342 and 64. The default value varies for different toolchains. For the COFF
7343 targeted toolchain the default value is 8. A value of 64 is only allowed
7344 if the underlying ABI supports it.
7346 Specifying the larger number can produce faster, more efficient code, but
7347 can also increase the size of the program. Different values are potentially
7348 incompatible. Code compiled with one value cannot necessarily expect to
7349 work with code or libraries compiled with another value, if they exchange
7350 information using structures or unions.
7352 @item -mabort-on-noreturn
7353 @opindex mabort-on-noreturn
7354 Generate a call to the function @code{abort} at the end of a
7355 @code{noreturn} function. It will be executed if the function tries to
7359 @itemx -mno-long-calls
7360 @opindex mlong-calls
7361 @opindex mno-long-calls
7362 Tells the compiler to perform function calls by first loading the
7363 address of the function into a register and then performing a subroutine
7364 call on this register. This switch is needed if the target function
7365 will lie outside of the 64 megabyte addressing range of the offset based
7366 version of subroutine call instruction.
7368 Even if this switch is enabled, not all function calls will be turned
7369 into long calls. The heuristic is that static functions, functions
7370 which have the @samp{short-call} attribute, functions that are inside
7371 the scope of a @samp{#pragma no_long_calls} directive and functions whose
7372 definitions have already been compiled within the current compilation
7373 unit, will not be turned into long calls. The exception to this rule is
7374 that weak function definitions, functions with the @samp{long-call}
7375 attribute or the @samp{section} attribute, and functions that are within
7376 the scope of a @samp{#pragma long_calls} directive, will always be
7377 turned into long calls.
7379 This feature is not enabled by default. Specifying
7380 @option{-mno-long-calls} will restore the default behavior, as will
7381 placing the function calls within the scope of a @samp{#pragma
7382 long_calls_off} directive. Note these switches have no effect on how
7383 the compiler generates code to handle function calls via function
7386 @item -mnop-fun-dllimport
7387 @opindex mnop-fun-dllimport
7388 Disable support for the @code{dllimport} attribute.
7390 @item -msingle-pic-base
7391 @opindex msingle-pic-base
7392 Treat the register used for PIC addressing as read-only, rather than
7393 loading it in the prologue for each function. The run-time system is
7394 responsible for initializing this register with an appropriate value
7395 before execution begins.
7397 @item -mpic-register=@var{reg}
7398 @opindex mpic-register
7399 Specify the register to be used for PIC addressing. The default is R10
7400 unless stack-checking is enabled, when R9 is used.
7402 @item -mcirrus-fix-invalid-insns
7403 @opindex mcirrus-fix-invalid-insns
7404 @opindex mno-cirrus-fix-invalid-insns
7405 Insert NOPs into the instruction stream to in order to work around
7406 problems with invalid Maverick instruction combinations. This option
7407 is only valid if the @option{-mcpu=ep9312} option has been used to
7408 enable generation of instructions for the Cirrus Maverick floating
7409 point co-processor. This option is not enabled by default, since the
7410 problem is only present in older Maverick implementations. The default
7411 can be re-enabled by use of the @option{-mno-cirrus-fix-invalid-insns}
7414 @item -mpoke-function-name
7415 @opindex mpoke-function-name
7416 Write the name of each function into the text section, directly
7417 preceding the function prologue. The generated code is similar to this:
7421 .ascii "arm_poke_function_name", 0
7424 .word 0xff000000 + (t1 - t0)
7425 arm_poke_function_name
7427 stmfd sp!, @{fp, ip, lr, pc@}
7431 When performing a stack backtrace, code can inspect the value of
7432 @code{pc} stored at @code{fp + 0}. If the trace function then looks at
7433 location @code{pc - 12} and the top 8 bits are set, then we know that
7434 there is a function name embedded immediately preceding this location
7435 and has length @code{((pc[-3]) & 0xff000000)}.
7439 Generate code for the 16-bit Thumb instruction set. The default is to
7440 use the 32-bit ARM instruction set.
7443 @opindex mtpcs-frame
7444 Generate a stack frame that is compliant with the Thumb Procedure Call
7445 Standard for all non-leaf functions. (A leaf function is one that does
7446 not call any other functions.) The default is @option{-mno-tpcs-frame}.
7448 @item -mtpcs-leaf-frame
7449 @opindex mtpcs-leaf-frame
7450 Generate a stack frame that is compliant with the Thumb Procedure Call
7451 Standard for all leaf functions. (A leaf function is one that does
7452 not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
7454 @item -mcallee-super-interworking
7455 @opindex mcallee-super-interworking
7456 Gives all externally visible functions in the file being compiled an ARM
7457 instruction set header which switches to Thumb mode before executing the
7458 rest of the function. This allows these functions to be called from
7459 non-interworking code.
7461 @item -mcaller-super-interworking
7462 @opindex mcaller-super-interworking
7463 Allows calls via function pointers (including virtual functions) to
7464 execute correctly regardless of whether the target code has been
7465 compiled for interworking or not. There is a small overhead in the cost
7466 of executing a function pointer if this option is enabled.
7468 @item -mtp=@var{name}
7470 Specify the access model for the thread local storage pointer. The valid
7471 models are @option{soft}, which generates calls to @code{__aeabi_read_tp},
7472 @option{cp15}, which fetches the thread pointer from @code{cp15} directly
7473 (supported in the arm6k architecture), and @option{auto}, which uses the
7474 best available method for the selected processor. The default setting is
7480 @subsection AVR Options
7483 These options are defined for AVR implementations:
7486 @item -mmcu=@var{mcu}
7488 Specify ATMEL AVR instruction set or MCU type.
7490 Instruction set avr1 is for the minimal AVR core, not supported by the C
7491 compiler, only for assembler programs (MCU types: at90s1200, attiny10,
7492 attiny11, attiny12, attiny15, attiny28).
7494 Instruction set avr2 (default) is for the classic AVR core with up to
7495 8K program memory space (MCU types: at90s2313, at90s2323, attiny22,
7496 at90s2333, at90s2343, at90s4414, at90s4433, at90s4434, at90s8515,
7497 at90c8534, at90s8535).
7499 Instruction set avr3 is for the classic AVR core with up to 128K program
7500 memory space (MCU types: atmega103, atmega603, at43usb320, at76c711).
7502 Instruction set avr4 is for the enhanced AVR core with up to 8K program
7503 memory space (MCU types: atmega8, atmega83, atmega85).
7505 Instruction set avr5 is for the enhanced AVR core with up to 128K program
7506 memory space (MCU types: atmega16, atmega161, atmega163, atmega32, atmega323,
7507 atmega64, atmega128, at43usb355, at94k).
7511 Output instruction sizes to the asm file.
7513 @item -minit-stack=@var{N}
7514 @opindex minit-stack
7515 Specify the initial stack address, which may be a symbol or numeric value,
7516 @samp{__stack} is the default.
7518 @item -mno-interrupts
7519 @opindex mno-interrupts
7520 Generated code is not compatible with hardware interrupts.
7521 Code size will be smaller.
7523 @item -mcall-prologues
7524 @opindex mcall-prologues
7525 Functions prologues/epilogues expanded as call to appropriate
7526 subroutines. Code size will be smaller.
7528 @item -mno-tablejump
7529 @opindex mno-tablejump
7530 Do not generate tablejump insns which sometimes increase code size.
7533 @opindex mtiny-stack
7534 Change only the low 8 bits of the stack pointer.
7538 Assume int to be 8 bit integer. This affects the sizes of all types: A
7539 char will be 1 byte, an int will be 1 byte, an long will be 2 bytes
7540 and long long will be 4 bytes. Please note that this option does not
7541 comply to the C standards, but it will provide you with smaller code
7545 @node Blackfin Options
7546 @subsection Blackfin Options
7547 @cindex Blackfin Options
7550 @item -momit-leaf-frame-pointer
7551 @opindex momit-leaf-frame-pointer
7552 Don't keep the frame pointer in a register for leaf functions. This
7553 avoids the instructions to save, set up and restore frame pointers and
7554 makes an extra register available in leaf functions. The option
7555 @option{-fomit-frame-pointer} removes the frame pointer for all functions
7556 which might make debugging harder.
7558 @item -mspecld-anomaly
7559 @opindex mspecld-anomaly
7560 When enabled, the compiler will ensure that the generated code does not
7561 contain speculative loads after jump instructions. This option is enabled
7564 @item -mno-specld-anomaly
7565 @opindex mno-specld-anomaly
7566 Don't generate extra code to prevent speculative loads from occurring.
7568 @item -mcsync-anomaly
7569 @opindex mcsync-anomaly
7570 When enabled, the compiler will ensure that the generated code does not
7571 contain CSYNC or SSYNC instructions too soon after conditional branches.
7572 This option is enabled by default.
7574 @item -mno-csync-anomaly
7575 @opindex mno-csync-anomaly
7576 Don't generate extra code to prevent CSYNC or SSYNC instructions from
7577 occurring too soon after a conditional branch.
7581 When enabled, the compiler is free to take advantage of the knowledge that
7582 the entire program fits into the low 64k of memory.
7585 @opindex mno-low-64k
7586 Assume that the program is arbitrarily large. This is the default.
7588 @item -mid-shared-library
7589 @opindex mid-shared-library
7590 Generate code that supports shared libraries via the library ID method.
7591 This allows for execute in place and shared libraries in an environment
7592 without virtual memory management. This option implies @option{-fPIC}.
7594 @item -mno-id-shared-library
7595 @opindex mno-id-shared-library
7596 Generate code that doesn't assume ID based shared libraries are being used.
7597 This is the default.
7599 @item -mshared-library-id=n
7600 @opindex mshared-library-id
7601 Specified the identification number of the ID based shared library being
7602 compiled. Specifying a value of 0 will generate more compact code, specifying
7603 other values will force the allocation of that number to the current
7604 library but is no more space or time efficient than omitting this option.
7607 @itemx -mno-long-calls
7608 @opindex mlong-calls
7609 @opindex mno-long-calls
7610 Tells the compiler to perform function calls by first loading the
7611 address of the function into a register and then performing a subroutine
7612 call on this register. This switch is needed if the target function
7613 will lie outside of the 24 bit addressing range of the offset based
7614 version of subroutine call instruction.
7616 This feature is not enabled by default. Specifying
7617 @option{-mno-long-calls} will restore the default behavior. Note these
7618 switches have no effect on how the compiler generates code to handle
7619 function calls via function pointers.
7623 @subsection CRIS Options
7624 @cindex CRIS Options
7626 These options are defined specifically for the CRIS ports.
7629 @item -march=@var{architecture-type}
7630 @itemx -mcpu=@var{architecture-type}
7633 Generate code for the specified architecture. The choices for
7634 @var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
7635 respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
7636 Default is @samp{v0} except for cris-axis-linux-gnu, where the default is
7639 @item -mtune=@var{architecture-type}
7641 Tune to @var{architecture-type} everything applicable about the generated
7642 code, except for the ABI and the set of available instructions. The
7643 choices for @var{architecture-type} are the same as for
7644 @option{-march=@var{architecture-type}}.
7646 @item -mmax-stack-frame=@var{n}
7647 @opindex mmax-stack-frame
7648 Warn when the stack frame of a function exceeds @var{n} bytes.
7650 @item -melinux-stacksize=@var{n}
7651 @opindex melinux-stacksize
7652 Only available with the @samp{cris-axis-aout} target. Arranges for
7653 indications in the program to the kernel loader that the stack of the
7654 program should be set to @var{n} bytes.
7660 The options @option{-metrax4} and @option{-metrax100} are synonyms for
7661 @option{-march=v3} and @option{-march=v8} respectively.
7663 @item -mmul-bug-workaround
7664 @itemx -mno-mul-bug-workaround
7665 @opindex mmul-bug-workaround
7666 @opindex mno-mul-bug-workaround
7667 Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
7668 models where it applies. This option is active by default.
7672 Enable CRIS-specific verbose debug-related information in the assembly
7673 code. This option also has the effect to turn off the @samp{#NO_APP}
7674 formatted-code indicator to the assembler at the beginning of the
7679 Do not use condition-code results from previous instruction; always emit
7680 compare and test instructions before use of condition codes.
7682 @item -mno-side-effects
7683 @opindex mno-side-effects
7684 Do not emit instructions with side-effects in addressing modes other than
7688 @itemx -mno-stack-align
7690 @itemx -mno-data-align
7691 @itemx -mconst-align
7692 @itemx -mno-const-align
7693 @opindex mstack-align
7694 @opindex mno-stack-align
7695 @opindex mdata-align
7696 @opindex mno-data-align
7697 @opindex mconst-align
7698 @opindex mno-const-align
7699 These options (no-options) arranges (eliminate arrangements) for the
7700 stack-frame, individual data and constants to be aligned for the maximum
7701 single data access size for the chosen CPU model. The default is to
7702 arrange for 32-bit alignment. ABI details such as structure layout are
7703 not affected by these options.
7711 Similar to the stack- data- and const-align options above, these options
7712 arrange for stack-frame, writable data and constants to all be 32-bit,
7713 16-bit or 8-bit aligned. The default is 32-bit alignment.
7715 @item -mno-prologue-epilogue
7716 @itemx -mprologue-epilogue
7717 @opindex mno-prologue-epilogue
7718 @opindex mprologue-epilogue
7719 With @option{-mno-prologue-epilogue}, the normal function prologue and
7720 epilogue that sets up the stack-frame are omitted and no return
7721 instructions or return sequences are generated in the code. Use this
7722 option only together with visual inspection of the compiled code: no
7723 warnings or errors are generated when call-saved registers must be saved,
7724 or storage for local variable needs to be allocated.
7730 With @option{-fpic} and @option{-fPIC}, don't generate (do generate)
7731 instruction sequences that load addresses for functions from the PLT part
7732 of the GOT rather than (traditional on other architectures) calls to the
7733 PLT@. The default is @option{-mgotplt}.
7737 Legacy no-op option only recognized with the cris-axis-aout target.
7741 Legacy no-op option only recognized with the cris-axis-elf and
7742 cris-axis-linux-gnu targets.
7746 Only recognized with the cris-axis-aout target, where it selects a
7747 GNU/linux-like multilib, include files and instruction set for
7752 Legacy no-op option only recognized with the cris-axis-linux-gnu target.
7756 This option, recognized for the cris-axis-aout and cris-axis-elf arranges
7757 to link with input-output functions from a simulator library. Code,
7758 initialized data and zero-initialized data are allocated consecutively.
7762 Like @option{-sim}, but pass linker options to locate initialized data at
7763 0x40000000 and zero-initialized data at 0x80000000.
7767 @subsection CRX Options
7770 These options are defined specifically for the CRX ports.
7776 Enable the use of multiply-accumulate instructions. Disabled by default.
7780 Push instructions will be used to pass outgoing arguments when functions
7781 are called. Enabled by default.
7784 @node Darwin Options
7785 @subsection Darwin Options
7786 @cindex Darwin options
7788 These options are defined for all architectures running the Darwin operating
7791 FSF GCC on Darwin does not create ``fat'' object files; it will create
7792 an object file for the single architecture that it was built to
7793 target. Apple's GCC on Darwin does create ``fat'' files if multiple
7794 @option{-arch} options are used; it does so by running the compiler or
7795 linker multiple times and joining the results together with
7798 The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
7799 @samp{i686}) is determined by the flags that specify the ISA
7800 that GCC is targetting, like @option{-mcpu} or @option{-march}. The
7801 @option{-force_cpusubtype_ALL} option can be used to override this.
7803 The Darwin tools vary in their behavior when presented with an ISA
7804 mismatch. The assembler, @file{as}, will only permit instructions to
7805 be used that are valid for the subtype of the file it is generating,
7806 so you cannot put 64-bit instructions in an @samp{ppc750} object file.
7807 The linker for shared libraries, @file{/usr/bin/libtool}, will fail
7808 and print an error if asked to create a shared library with a less
7809 restrictive subtype than its input files (for instance, trying to put
7810 a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
7811 for executables, @file{ld}, will quietly give the executable the most
7812 restrictive subtype of any of its input files.
7817 Add the framework directory @var{dir} to the head of the list of
7818 directories to be searched for header files. These directories are
7819 interleaved with those specified by @option{-I} options and are
7820 scanned in a left-to-right order.
7822 A framework directory is a directory with frameworks in it. A
7823 framework is a directory with a @samp{"Headers"} and/or
7824 @samp{"PrivateHeaders"} directory contained directly in it that ends
7825 in @samp{".framework"}. The name of a framework is the name of this
7826 directory excluding the @samp{".framework"}. Headers associated with
7827 the framework are found in one of those two directories, with
7828 @samp{"Headers"} being searched first. A subframework is a framework
7829 directory that is in a framework's @samp{"Frameworks"} directory.
7830 Includes of subframework headers can only appear in a header of a
7831 framework that contains the subframework, or in a sibling subframework
7832 header. Two subframeworks are siblings if they occur in the same
7833 framework. A subframework should not have the same name as a
7834 framework, a warning will be issued if this is violated. Currently a
7835 subframework cannot have subframeworks, in the future, the mechanism
7836 may be extended to support this. The standard frameworks can be found
7837 in @samp{"/System/Library/Frameworks"} and
7838 @samp{"/Library/Frameworks"}. An example include looks like
7839 @code{#include <Framework/header.h>}, where @samp{Framework} denotes
7840 the name of the framework and header.h is found in the
7841 @samp{"PrivateHeaders"} or @samp{"Headers"} directory.
7845 Emit debugging information for symbols that are used. For STABS
7846 debugging format, this enables @option{-feliminate-unused-debug-symbols}.
7847 This is by default ON@.
7851 Emit debugging information for all symbols and types.
7853 @item -mmacosx-version-min=@var{version}
7854 The earliest version of MacOS X that this executable will run on
7855 is @var{version}. Typical values of @var{version} include @code{10.1},
7856 @code{10.2}, and @code{10.3.9}.
7858 The default for this option is to make choices that seem to be most
7863 Enable kernel development mode. The @option{-mkernel} option sets
7864 @option{-static}, @option{-fno-common}, @option{-fno-cxa-atexit},
7865 @option{-fno-exceptions}, @option{-fno-non-call-exceptions},
7866 @option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
7867 applicable. This mode also sets @option{-mno-altivec},
7868 @option{-msoft-float}, @option{-fno-builtin} and
7869 @option{-mlong-branch} for PowerPC targets.
7871 @item -mone-byte-bool
7872 @opindex mone-byte-bool
7873 Override the defaults for @samp{bool} so that @samp{sizeof(bool)==1}.
7874 By default @samp{sizeof(bool)} is @samp{4} when compiling for
7875 Darwin/PowerPC and @samp{1} when compiling for Darwin/x86, so this
7876 option has no effect on x86.
7878 @strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
7879 to generate code that is not binary compatible with code generated
7880 without that switch. Using this switch may require recompiling all
7881 other modules in a program, including system libraries. Use this
7882 switch to conform to a non-default data model.
7884 @item -mfix-and-continue
7885 @itemx -ffix-and-continue
7886 @itemx -findirect-data
7887 @opindex mfix-and-continue
7888 @opindex ffix-and-continue
7889 @opindex findirect-data
7890 Generate code suitable for fast turn around development. Needed to
7891 enable gdb to dynamically load @code{.o} files into already running
7892 programs. @option{-findirect-data} and @option{-ffix-and-continue}
7893 are provided for backwards compatibility.
7897 Loads all members of static archive libraries.
7898 See man ld(1) for more information.
7900 @item -arch_errors_fatal
7901 @opindex arch_errors_fatal
7902 Cause the errors having to do with files that have the wrong architecture
7906 @opindex bind_at_load
7907 Causes the output file to be marked such that the dynamic linker will
7908 bind all undefined references when the file is loaded or launched.
7912 Produce a Mach-o bundle format file.
7913 See man ld(1) for more information.
7915 @item -bundle_loader @var{executable}
7916 @opindex bundle_loader
7917 This option specifies the @var{executable} that will be loading the build
7918 output file being linked. See man ld(1) for more information.
7922 When passed this option, GCC will produce a dynamic library instead of
7923 an executable when linking, using the Darwin @file{libtool} command.
7925 @item -force_cpusubtype_ALL
7926 @opindex force_cpusubtype_ALL
7927 This causes GCC's output file to have the @var{ALL} subtype, instead of
7928 one controlled by the @option{-mcpu} or @option{-march} option.
7930 @item -allowable_client @var{client_name}
7932 @itemx -compatibility_version
7933 @itemx -current_version
7935 @itemx -dependency-file
7937 @itemx -dylinker_install_name
7939 @itemx -exported_symbols_list
7941 @itemx -flat_namespace
7942 @itemx -force_flat_namespace
7943 @itemx -headerpad_max_install_names
7946 @itemx -install_name
7947 @itemx -keep_private_externs
7948 @itemx -multi_module
7949 @itemx -multiply_defined
7950 @itemx -multiply_defined_unused
7952 @itemx -no_dead_strip_inits_and_terms
7953 @itemx -nofixprebinding
7956 @itemx -noseglinkedit
7957 @itemx -pagezero_size
7959 @itemx -prebind_all_twolevel_modules
7960 @itemx -private_bundle
7961 @itemx -read_only_relocs
7963 @itemx -sectobjectsymbols
7967 @itemx -sectobjectsymbols
7970 @itemx -segs_read_only_addr
7971 @itemx -segs_read_write_addr
7972 @itemx -seg_addr_table
7973 @itemx -seg_addr_table_filename
7976 @itemx -segs_read_only_addr
7977 @itemx -segs_read_write_addr
7978 @itemx -single_module
7981 @itemx -sub_umbrella
7982 @itemx -twolevel_namespace
7985 @itemx -unexported_symbols_list
7986 @itemx -weak_reference_mismatches
7989 @opindex allowable_client
7990 @opindex client_name
7991 @opindex compatibility_version
7992 @opindex current_version
7994 @opindex dependency-file
7996 @opindex dylinker_install_name
7998 @opindex exported_symbols_list
8000 @opindex flat_namespace
8001 @opindex force_flat_namespace
8002 @opindex headerpad_max_install_names
8005 @opindex install_name
8006 @opindex keep_private_externs
8007 @opindex multi_module
8008 @opindex multiply_defined
8009 @opindex multiply_defined_unused
8011 @opindex no_dead_strip_inits_and_terms
8012 @opindex nofixprebinding
8013 @opindex nomultidefs
8015 @opindex noseglinkedit
8016 @opindex pagezero_size
8018 @opindex prebind_all_twolevel_modules
8019 @opindex private_bundle
8020 @opindex read_only_relocs
8022 @opindex sectobjectsymbols
8026 @opindex sectobjectsymbols
8029 @opindex segs_read_only_addr
8030 @opindex segs_read_write_addr
8031 @opindex seg_addr_table
8032 @opindex seg_addr_table_filename
8033 @opindex seglinkedit
8035 @opindex segs_read_only_addr
8036 @opindex segs_read_write_addr
8037 @opindex single_module
8039 @opindex sub_library
8040 @opindex sub_umbrella
8041 @opindex twolevel_namespace
8044 @opindex unexported_symbols_list
8045 @opindex weak_reference_mismatches
8046 @opindex whatsloaded
8048 These options are passed to the Darwin linker. The Darwin linker man page
8049 describes them in detail.
8052 @node DEC Alpha Options
8053 @subsection DEC Alpha Options
8055 These @samp{-m} options are defined for the DEC Alpha implementations:
8058 @item -mno-soft-float
8060 @opindex mno-soft-float
8061 @opindex msoft-float
8062 Use (do not use) the hardware floating-point instructions for
8063 floating-point operations. When @option{-msoft-float} is specified,
8064 functions in @file{libgcc.a} will be used to perform floating-point
8065 operations. Unless they are replaced by routines that emulate the
8066 floating-point operations, or compiled in such a way as to call such
8067 emulations routines, these routines will issue floating-point
8068 operations. If you are compiling for an Alpha without floating-point
8069 operations, you must ensure that the library is built so as not to call
8072 Note that Alpha implementations without floating-point operations are
8073 required to have floating-point registers.
8078 @opindex mno-fp-regs
8079 Generate code that uses (does not use) the floating-point register set.
8080 @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
8081 register set is not used, floating point operands are passed in integer
8082 registers as if they were integers and floating-point results are passed
8083 in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
8084 so any function with a floating-point argument or return value called by code
8085 compiled with @option{-mno-fp-regs} must also be compiled with that
8088 A typical use of this option is building a kernel that does not use,
8089 and hence need not save and restore, any floating-point registers.
8093 The Alpha architecture implements floating-point hardware optimized for
8094 maximum performance. It is mostly compliant with the IEEE floating
8095 point standard. However, for full compliance, software assistance is
8096 required. This option generates code fully IEEE compliant code
8097 @emph{except} that the @var{inexact-flag} is not maintained (see below).
8098 If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
8099 defined during compilation. The resulting code is less efficient but is
8100 able to correctly support denormalized numbers and exceptional IEEE
8101 values such as not-a-number and plus/minus infinity. Other Alpha
8102 compilers call this option @option{-ieee_with_no_inexact}.
8104 @item -mieee-with-inexact
8105 @opindex mieee-with-inexact
8106 This is like @option{-mieee} except the generated code also maintains
8107 the IEEE @var{inexact-flag}. Turning on this option causes the
8108 generated code to implement fully-compliant IEEE math. In addition to
8109 @code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
8110 macro. On some Alpha implementations the resulting code may execute
8111 significantly slower than the code generated by default. Since there is
8112 very little code that depends on the @var{inexact-flag}, you should
8113 normally not specify this option. Other Alpha compilers call this
8114 option @option{-ieee_with_inexact}.
8116 @item -mfp-trap-mode=@var{trap-mode}
8117 @opindex mfp-trap-mode
8118 This option controls what floating-point related traps are enabled.
8119 Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
8120 The trap mode can be set to one of four values:
8124 This is the default (normal) setting. The only traps that are enabled
8125 are the ones that cannot be disabled in software (e.g., division by zero
8129 In addition to the traps enabled by @samp{n}, underflow traps are enabled
8133 Like @samp{u}, but the instructions are marked to be safe for software
8134 completion (see Alpha architecture manual for details).
8137 Like @samp{su}, but inexact traps are enabled as well.
8140 @item -mfp-rounding-mode=@var{rounding-mode}
8141 @opindex mfp-rounding-mode
8142 Selects the IEEE rounding mode. Other Alpha compilers call this option
8143 @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
8148 Normal IEEE rounding mode. Floating point numbers are rounded towards
8149 the nearest machine number or towards the even machine number in case
8153 Round towards minus infinity.
8156 Chopped rounding mode. Floating point numbers are rounded towards zero.
8159 Dynamic rounding mode. A field in the floating point control register
8160 (@var{fpcr}, see Alpha architecture reference manual) controls the
8161 rounding mode in effect. The C library initializes this register for
8162 rounding towards plus infinity. Thus, unless your program modifies the
8163 @var{fpcr}, @samp{d} corresponds to round towards plus infinity.
8166 @item -mtrap-precision=@var{trap-precision}
8167 @opindex mtrap-precision
8168 In the Alpha architecture, floating point traps are imprecise. This
8169 means without software assistance it is impossible to recover from a
8170 floating trap and program execution normally needs to be terminated.
8171 GCC can generate code that can assist operating system trap handlers
8172 in determining the exact location that caused a floating point trap.
8173 Depending on the requirements of an application, different levels of
8174 precisions can be selected:
8178 Program precision. This option is the default and means a trap handler
8179 can only identify which program caused a floating point exception.
8182 Function precision. The trap handler can determine the function that
8183 caused a floating point exception.
8186 Instruction precision. The trap handler can determine the exact
8187 instruction that caused a floating point exception.
8190 Other Alpha compilers provide the equivalent options called
8191 @option{-scope_safe} and @option{-resumption_safe}.
8193 @item -mieee-conformant
8194 @opindex mieee-conformant
8195 This option marks the generated code as IEEE conformant. You must not
8196 use this option unless you also specify @option{-mtrap-precision=i} and either
8197 @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
8198 is to emit the line @samp{.eflag 48} in the function prologue of the
8199 generated assembly file. Under DEC Unix, this has the effect that
8200 IEEE-conformant math library routines will be linked in.
8202 @item -mbuild-constants
8203 @opindex mbuild-constants
8204 Normally GCC examines a 32- or 64-bit integer constant to
8205 see if it can construct it from smaller constants in two or three
8206 instructions. If it cannot, it will output the constant as a literal and
8207 generate code to load it from the data segment at runtime.
8209 Use this option to require GCC to construct @emph{all} integer constants
8210 using code, even if it takes more instructions (the maximum is six).
8212 You would typically use this option to build a shared library dynamic
8213 loader. Itself a shared library, it must relocate itself in memory
8214 before it can find the variables and constants in its own data segment.
8220 Select whether to generate code to be assembled by the vendor-supplied
8221 assembler (@option{-malpha-as}) or by the GNU assembler @option{-mgas}.
8239 Indicate whether GCC should generate code to use the optional BWX,
8240 CIX, FIX and MAX instruction sets. The default is to use the instruction
8241 sets supported by the CPU type specified via @option{-mcpu=} option or that
8242 of the CPU on which GCC was built if none was specified.
8247 @opindex mfloat-ieee
8248 Generate code that uses (does not use) VAX F and G floating point
8249 arithmetic instead of IEEE single and double precision.
8251 @item -mexplicit-relocs
8252 @itemx -mno-explicit-relocs
8253 @opindex mexplicit-relocs
8254 @opindex mno-explicit-relocs
8255 Older Alpha assemblers provided no way to generate symbol relocations
8256 except via assembler macros. Use of these macros does not allow
8257 optimal instruction scheduling. GNU binutils as of version 2.12
8258 supports a new syntax that allows the compiler to explicitly mark
8259 which relocations should apply to which instructions. This option
8260 is mostly useful for debugging, as GCC detects the capabilities of
8261 the assembler when it is built and sets the default accordingly.
8265 @opindex msmall-data
8266 @opindex mlarge-data
8267 When @option{-mexplicit-relocs} is in effect, static data is
8268 accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
8269 is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
8270 (the @code{.sdata} and @code{.sbss} sections) and are accessed via
8271 16-bit relocations off of the @code{$gp} register. This limits the
8272 size of the small data area to 64KB, but allows the variables to be
8273 directly accessed via a single instruction.
8275 The default is @option{-mlarge-data}. With this option the data area
8276 is limited to just below 2GB@. Programs that require more than 2GB of
8277 data must use @code{malloc} or @code{mmap} to allocate the data in the
8278 heap instead of in the program's data segment.
8280 When generating code for shared libraries, @option{-fpic} implies
8281 @option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
8285 @opindex msmall-text
8286 @opindex mlarge-text
8287 When @option{-msmall-text} is used, the compiler assumes that the
8288 code of the entire program (or shared library) fits in 4MB, and is
8289 thus reachable with a branch instruction. When @option{-msmall-data}
8290 is used, the compiler can assume that all local symbols share the
8291 same @code{$gp} value, and thus reduce the number of instructions
8292 required for a function call from 4 to 1.
8294 The default is @option{-mlarge-text}.
8296 @item -mcpu=@var{cpu_type}
8298 Set the instruction set and instruction scheduling parameters for
8299 machine type @var{cpu_type}. You can specify either the @samp{EV}
8300 style name or the corresponding chip number. GCC supports scheduling
8301 parameters for the EV4, EV5 and EV6 family of processors and will
8302 choose the default values for the instruction set from the processor
8303 you specify. If you do not specify a processor type, GCC will default
8304 to the processor on which the compiler was built.
8306 Supported values for @var{cpu_type} are
8312 Schedules as an EV4 and has no instruction set extensions.
8316 Schedules as an EV5 and has no instruction set extensions.
8320 Schedules as an EV5 and supports the BWX extension.
8325 Schedules as an EV5 and supports the BWX and MAX extensions.
8329 Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
8333 Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
8336 @item -mtune=@var{cpu_type}
8338 Set only the instruction scheduling parameters for machine type
8339 @var{cpu_type}. The instruction set is not changed.
8341 @item -mmemory-latency=@var{time}
8342 @opindex mmemory-latency
8343 Sets the latency the scheduler should assume for typical memory
8344 references as seen by the application. This number is highly
8345 dependent on the memory access patterns used by the application
8346 and the size of the external cache on the machine.
8348 Valid options for @var{time} are
8352 A decimal number representing clock cycles.
8358 The compiler contains estimates of the number of clock cycles for
8359 ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
8360 (also called Dcache, Scache, and Bcache), as well as to main memory.
8361 Note that L3 is only valid for EV5.
8366 @node DEC Alpha/VMS Options
8367 @subsection DEC Alpha/VMS Options
8369 These @samp{-m} options are defined for the DEC Alpha/VMS implementations:
8372 @item -mvms-return-codes
8373 @opindex mvms-return-codes
8374 Return VMS condition codes from main. The default is to return POSIX
8375 style condition (e.g.@ error) codes.
8379 @subsection FRV Options
8386 Only use the first 32 general purpose registers.
8391 Use all 64 general purpose registers.
8396 Use only the first 32 floating point registers.
8401 Use all 64 floating point registers
8404 @opindex mhard-float
8406 Use hardware instructions for floating point operations.
8409 @opindex msoft-float
8411 Use library routines for floating point operations.
8416 Dynamically allocate condition code registers.
8421 Do not try to dynamically allocate condition code registers, only
8422 use @code{icc0} and @code{fcc0}.
8427 Change ABI to use double word insns.
8432 Do not use double word instructions.
8437 Use floating point double instructions.
8442 Do not use floating point double instructions.
8447 Use media instructions.
8452 Do not use media instructions.
8457 Use multiply and add/subtract instructions.
8462 Do not use multiply and add/subtract instructions.
8467 Select the FDPIC ABI, that uses function descriptors to represent
8468 pointers to functions. Without any PIC/PIE-related options, it
8469 implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
8470 assumes GOT entries and small data are within a 12-bit range from the
8471 GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
8472 are computed with 32 bits.
8475 @opindex minline-plt
8477 Enable inlining of PLT entries in function calls to functions that are
8478 not known to bind locally. It has no effect without @option{-mfdpic}.
8479 It's enabled by default if optimizing for speed and compiling for
8480 shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
8481 optimization option such as @option{-O3} or above is present in the
8487 Assume a large TLS segment when generating thread-local code.
8492 Do not assume a large TLS segment when generating thread-local code.
8497 Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
8498 that is known to be in read-only sections. It's enabled by default,
8499 except for @option{-fpic} or @option{-fpie}: even though it may help
8500 make the global offset table smaller, it trades 1 instruction for 4.
8501 With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
8502 one of which may be shared by multiple symbols, and it avoids the need
8503 for a GOT entry for the referenced symbol, so it's more likely to be a
8504 win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
8506 @item -multilib-library-pic
8507 @opindex multilib-library-pic
8509 Link with the (library, not FD) pic libraries. It's implied by
8510 @option{-mlibrary-pic}, as well as by @option{-fPIC} and
8511 @option{-fpic} without @option{-mfdpic}. You should never have to use
8517 Follow the EABI requirement of always creating a frame pointer whenever
8518 a stack frame is allocated. This option is enabled by default and can
8519 be disabled with @option{-mno-linked-fp}.
8522 @opindex mlong-calls
8524 Use indirect addressing to call functions outside the current
8525 compilation unit. This allows the functions to be placed anywhere
8526 within the 32-bit address space.
8528 @item -malign-labels
8529 @opindex malign-labels
8531 Try to align labels to an 8-byte boundary by inserting nops into the
8532 previous packet. This option only has an effect when VLIW packing
8533 is enabled. It doesn't create new packets; it merely adds nops to
8537 @opindex mlibrary-pic
8539 Generate position-independent EABI code.
8544 Use only the first four media accumulator registers.
8549 Use all eight media accumulator registers.
8554 Pack VLIW instructions.
8559 Do not pack VLIW instructions.
8564 Do not mark ABI switches in e_flags.
8569 Enable the use of conditional-move instructions (default).
8571 This switch is mainly for debugging the compiler and will likely be removed
8572 in a future version.
8574 @item -mno-cond-move
8575 @opindex mno-cond-move
8577 Disable the use of conditional-move instructions.
8579 This switch is mainly for debugging the compiler and will likely be removed
8580 in a future version.
8585 Enable the use of conditional set instructions (default).
8587 This switch is mainly for debugging the compiler and will likely be removed
8588 in a future version.
8593 Disable the use of conditional set instructions.
8595 This switch is mainly for debugging the compiler and will likely be removed
8596 in a future version.
8601 Enable the use of conditional execution (default).
8603 This switch is mainly for debugging the compiler and will likely be removed
8604 in a future version.
8606 @item -mno-cond-exec
8607 @opindex mno-cond-exec
8609 Disable the use of conditional execution.
8611 This switch is mainly for debugging the compiler and will likely be removed
8612 in a future version.
8615 @opindex mvliw-branch
8617 Run a pass to pack branches into VLIW instructions (default).
8619 This switch is mainly for debugging the compiler and will likely be removed
8620 in a future version.
8622 @item -mno-vliw-branch
8623 @opindex mno-vliw-branch
8625 Do not run a pass to pack branches into VLIW instructions.
8627 This switch is mainly for debugging the compiler and will likely be removed
8628 in a future version.
8630 @item -mmulti-cond-exec
8631 @opindex mmulti-cond-exec
8633 Enable optimization of @code{&&} and @code{||} in conditional execution
8636 This switch is mainly for debugging the compiler and will likely be removed
8637 in a future version.
8639 @item -mno-multi-cond-exec
8640 @opindex mno-multi-cond-exec
8642 Disable optimization of @code{&&} and @code{||} in conditional execution.
8644 This switch is mainly for debugging the compiler and will likely be removed
8645 in a future version.
8647 @item -mnested-cond-exec
8648 @opindex mnested-cond-exec
8650 Enable nested conditional execution optimizations (default).
8652 This switch is mainly for debugging the compiler and will likely be removed
8653 in a future version.
8655 @item -mno-nested-cond-exec
8656 @opindex mno-nested-cond-exec
8658 Disable nested conditional execution optimizations.
8660 This switch is mainly for debugging the compiler and will likely be removed
8661 in a future version.
8663 @item -moptimize-membar
8664 @opindex moptimize-membar
8666 This switch removes redundant @code{membar} instructions from the
8667 compiler generated code. It is enabled by default.
8669 @item -mno-optimize-membar
8670 @opindex mno-optimize-membar
8672 This switch disables the automatic removal of redundant @code{membar}
8673 instructions from the generated code.
8675 @item -mtomcat-stats
8676 @opindex mtomcat-stats
8678 Cause gas to print out tomcat statistics.
8680 @item -mcpu=@var{cpu}
8683 Select the processor type for which to generate code. Possible values are
8684 @samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
8685 @samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
8689 @node GNU/Linux Options
8690 @subsection GNU/Linux Options
8692 These @samp{-m} options are defined for GNU/Linux targets:
8697 Use the GNU C library instead of uClibc. This is the default except
8698 on @samp{*-*-linux-*uclibc*} targets.
8702 Use uClibc instead of the GNU C library. This is the default on
8703 @samp{*-*-linux-*uclibc*} targets.
8706 @node H8/300 Options
8707 @subsection H8/300 Options
8709 These @samp{-m} options are defined for the H8/300 implementations:
8714 Shorten some address references at link time, when possible; uses the
8715 linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
8716 ld, Using ld}, for a fuller description.
8720 Generate code for the H8/300H@.
8724 Generate code for the H8S@.
8728 Generate code for the H8S and H8/300H in the normal mode. This switch
8729 must be used either with @option{-mh} or @option{-ms}.
8733 Generate code for the H8S/2600. This switch must be used with @option{-ms}.
8737 Make @code{int} data 32 bits by default.
8741 On the H8/300H and H8S, use the same alignment rules as for the H8/300.
8742 The default for the H8/300H and H8S is to align longs and floats on 4
8744 @option{-malign-300} causes them to be aligned on 2 byte boundaries.
8745 This option has no effect on the H8/300.
8749 @subsection HPPA Options
8750 @cindex HPPA Options
8752 These @samp{-m} options are defined for the HPPA family of computers:
8755 @item -march=@var{architecture-type}
8757 Generate code for the specified architecture. The choices for
8758 @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
8759 1.1, and @samp{2.0} for PA 2.0 processors. Refer to
8760 @file{/usr/lib/sched.models} on an HP-UX system to determine the proper
8761 architecture option for your machine. Code compiled for lower numbered
8762 architectures will run on higher numbered architectures, but not the
8766 @itemx -mpa-risc-1-1
8767 @itemx -mpa-risc-2-0
8768 @opindex mpa-risc-1-0
8769 @opindex mpa-risc-1-1
8770 @opindex mpa-risc-2-0
8771 Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
8774 @opindex mbig-switch
8775 Generate code suitable for big switch tables. Use this option only if
8776 the assembler/linker complain about out of range branches within a switch
8779 @item -mjump-in-delay
8780 @opindex mjump-in-delay
8781 Fill delay slots of function calls with unconditional jump instructions
8782 by modifying the return pointer for the function call to be the target
8783 of the conditional jump.
8785 @item -mdisable-fpregs
8786 @opindex mdisable-fpregs
8787 Prevent floating point registers from being used in any manner. This is
8788 necessary for compiling kernels which perform lazy context switching of
8789 floating point registers. If you use this option and attempt to perform
8790 floating point operations, the compiler will abort.
8792 @item -mdisable-indexing
8793 @opindex mdisable-indexing
8794 Prevent the compiler from using indexing address modes. This avoids some
8795 rather obscure problems when compiling MIG generated code under MACH@.
8797 @item -mno-space-regs
8798 @opindex mno-space-regs
8799 Generate code that assumes the target has no space registers. This allows
8800 GCC to generate faster indirect calls and use unscaled index address modes.
8802 Such code is suitable for level 0 PA systems and kernels.
8804 @item -mfast-indirect-calls
8805 @opindex mfast-indirect-calls
8806 Generate code that assumes calls never cross space boundaries. This
8807 allows GCC to emit code which performs faster indirect calls.
8809 This option will not work in the presence of shared libraries or nested
8812 @item -mfixed-range=@var{register-range}
8813 @opindex mfixed-range
8814 Generate code treating the given register range as fixed registers.
8815 A fixed register is one that the register allocator can not use. This is
8816 useful when compiling kernel code. A register range is specified as
8817 two registers separated by a dash. Multiple register ranges can be
8818 specified separated by a comma.
8820 @item -mlong-load-store
8821 @opindex mlong-load-store
8822 Generate 3-instruction load and store sequences as sometimes required by
8823 the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
8826 @item -mportable-runtime
8827 @opindex mportable-runtime
8828 Use the portable calling conventions proposed by HP for ELF systems.
8832 Enable the use of assembler directives only GAS understands.
8834 @item -mschedule=@var{cpu-type}
8836 Schedule code according to the constraints for the machine type
8837 @var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
8838 @samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
8839 to @file{/usr/lib/sched.models} on an HP-UX system to determine the
8840 proper scheduling option for your machine. The default scheduling is
8844 @opindex mlinker-opt
8845 Enable the optimization pass in the HP-UX linker. Note this makes symbolic
8846 debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
8847 linkers in which they give bogus error messages when linking some programs.
8850 @opindex msoft-float
8851 Generate output containing library calls for floating point.
8852 @strong{Warning:} the requisite libraries are not available for all HPPA
8853 targets. Normally the facilities of the machine's usual C compiler are
8854 used, but this cannot be done directly in cross-compilation. You must make
8855 your own arrangements to provide suitable library functions for
8856 cross-compilation. The embedded target @samp{hppa1.1-*-pro}
8857 does provide software floating point support.
8859 @option{-msoft-float} changes the calling convention in the output file;
8860 therefore, it is only useful if you compile @emph{all} of a program with
8861 this option. In particular, you need to compile @file{libgcc.a}, the
8862 library that comes with GCC, with @option{-msoft-float} in order for
8867 Generate the predefine, @code{_SIO}, for server IO@. The default is
8868 @option{-mwsio}. This generates the predefines, @code{__hp9000s700},
8869 @code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
8870 options are available under HP-UX and HI-UX@.
8874 Use GNU ld specific options. This passes @option{-shared} to ld when
8875 building a shared library. It is the default when GCC is configured,
8876 explicitly or implicitly, with the GNU linker. This option does not
8877 have any affect on which ld is called, it only changes what parameters
8878 are passed to that ld. The ld that is called is determined by the
8879 @option{--with-ld} configure option, GCC's program search path, and
8880 finally by the user's @env{PATH}. The linker used by GCC can be printed
8881 using @samp{which `gcc -print-prog-name=ld`}. This option is only available
8882 on the 64 bit HP-UX GCC, i.e. configured with @samp{hppa*64*-*-hpux*}.
8886 Use HP ld specific options. This passes @option{-b} to ld when building
8887 a shared library and passes @option{+Accept TypeMismatch} to ld on all
8888 links. It is the default when GCC is configured, explicitly or
8889 implicitly, with the HP linker. This option does not have any affect on
8890 which ld is called, it only changes what parameters are passed to that
8891 ld. The ld that is called is determined by the @option{--with-ld}
8892 configure option, GCC's program search path, and finally by the user's
8893 @env{PATH}. The linker used by GCC can be printed using @samp{which
8894 `gcc -print-prog-name=ld`}. This option is only available on the 64 bit
8895 HP-UX GCC, i.e. configured with @samp{hppa*64*-*-hpux*}.
8898 @opindex mno-long-calls
8899 Generate code that uses long call sequences. This ensures that a call
8900 is always able to reach linker generated stubs. The default is to generate
8901 long calls only when the distance from the call site to the beginning
8902 of the function or translation unit, as the case may be, exceeds a
8903 predefined limit set by the branch type being used. The limits for
8904 normal calls are 7,600,000 and 240,000 bytes, respectively for the
8905 PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
8908 Distances are measured from the beginning of functions when using the
8909 @option{-ffunction-sections} option, or when using the @option{-mgas}
8910 and @option{-mno-portable-runtime} options together under HP-UX with
8913 It is normally not desirable to use this option as it will degrade
8914 performance. However, it may be useful in large applications,
8915 particularly when partial linking is used to build the application.
8917 The types of long calls used depends on the capabilities of the
8918 assembler and linker, and the type of code being generated. The
8919 impact on systems that support long absolute calls, and long pic
8920 symbol-difference or pc-relative calls should be relatively small.
8921 However, an indirect call is used on 32-bit ELF systems in pic code
8922 and it is quite long.
8924 @item -munix=@var{unix-std}
8926 Generate compiler predefines and select a startfile for the specified
8927 UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
8928 and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
8929 is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
8930 11.11 and later. The default values are @samp{93} for HP-UX 10.00,
8931 @samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
8934 @option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
8935 @option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
8936 and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
8937 @option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
8938 @code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
8939 @code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
8941 It is @emph{important} to note that this option changes the interfaces
8942 for various library routines. It also affects the operational behavior
8943 of the C library. Thus, @emph{extreme} care is needed in using this
8946 Library code that is intended to operate with more than one UNIX
8947 standard must test, set and restore the variable @var{__xpg4_extended_mask}
8948 as appropriate. Most GNU software doesn't provide this capability.
8952 Suppress the generation of link options to search libdld.sl when the
8953 @option{-static} option is specified on HP-UX 10 and later.
8957 The HP-UX implementation of setlocale in libc has a dependency on
8958 libdld.sl. There isn't an archive version of libdld.sl. Thus,
8959 when the @option{-static} option is specified, special link options
8960 are needed to resolve this dependency.
8962 On HP-UX 10 and later, the GCC driver adds the necessary options to
8963 link with libdld.sl when the @option{-static} option is specified.
8964 This causes the resulting binary to be dynamic. On the 64-bit port,
8965 the linkers generate dynamic binaries by default in any case. The
8966 @option{-nolibdld} option can be used to prevent the GCC driver from
8967 adding these link options.
8971 Add support for multithreading with the @dfn{dce thread} library
8972 under HP-UX@. This option sets flags for both the preprocessor and
8976 @node i386 and x86-64 Options
8977 @subsection Intel 386 and AMD x86-64 Options
8978 @cindex i386 Options
8979 @cindex x86-64 Options
8980 @cindex Intel 386 Options
8981 @cindex AMD x86-64 Options
8983 These @samp{-m} options are defined for the i386 and x86-64 family of
8987 @item -mtune=@var{cpu-type}
8989 Tune to @var{cpu-type} everything applicable about the generated code, except
8990 for the ABI and the set of available instructions. The choices for
8994 Produce code optimized for the most common IA32/AMD64/EM64T processors.
8995 If you know the CPU on which your code will run, then you should use
8996 the corresponding @option{-mtune} option instead of
8997 @option{-mtune=generic}. But, if you do not know exactly what CPU users
8998 of your application will have, then you should use this option.
9000 As new processors are deployed in the marketplace, the behavior of this
9001 option will change. Therefore, if you upgrade to a newer version of
9002 GCC, the code generated option will change to reflect the processors
9003 that were most common when that version of GCC was released.
9005 There is no @option{-march=generic} option because @option{-march}
9006 indicates the instruction set the compiler can use, and there is no
9007 generic instruction set applicable to all processors. In contrast,
9008 @option{-mtune} indicates the processor (or, in this case, collection of
9009 processors) for which the code is optimized.
9011 This selects the CPU to tune for at compilation time by determining
9012 the processor type of the compiling machine. Using @option{-mtune=native}
9013 will produce code optimized for the local machine under the constraints
9014 of the selected instruction set. Using @option{-march=native} will
9015 enable all instruction subsets supported by the local machine (hence
9016 the result might not run on different machines).
9018 Original Intel's i386 CPU@.
9020 Intel's i486 CPU@. (No scheduling is implemented for this chip.)
9022 Intel Pentium CPU with no MMX support.
9024 Intel PentiumMMX CPU based on Pentium core with MMX instruction set support.
9026 Intel PentiumPro CPU@.
9028 Same as @code{generic}, but when used as @code{march} option, PentiumPro
9029 instruction set will be used, so the code will run on all i686 family chips.
9031 Intel Pentium2 CPU based on PentiumPro core with MMX instruction set support.
9032 @item pentium3, pentium3m
9033 Intel Pentium3 CPU based on PentiumPro core with MMX and SSE instruction set
9036 Low power version of Intel Pentium3 CPU with MMX, SSE and SSE2 instruction set
9037 support. Used by Centrino notebooks.
9038 @item pentium4, pentium4m
9039 Intel Pentium4 CPU with MMX, SSE and SSE2 instruction set support.
9041 Improved version of Intel Pentium4 CPU with MMX, SSE, SSE2 and SSE3 instruction
9044 Improved version of Intel Pentium4 CPU with 64-bit extensions, MMX, SSE,
9045 SSE2 and SSE3 instruction set support.
9047 Intel Core2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3 and SSSE3
9048 instruction set support.
9050 AMD K6 CPU with MMX instruction set support.
9052 Improved versions of AMD K6 CPU with MMX and 3dNOW! instruction set support.
9053 @item athlon, athlon-tbird
9054 AMD Athlon CPU with MMX, 3dNOW!, enhanced 3dNOW! and SSE prefetch instructions
9056 @item athlon-4, athlon-xp, athlon-mp
9057 Improved AMD Athlon CPU with MMX, 3dNOW!, enhanced 3dNOW! and full SSE
9058 instruction set support.
9059 @item k8, opteron, athlon64, athlon-fx
9060 AMD K8 core based CPUs with x86-64 instruction set support. (This supersets
9061 MMX, SSE, SSE2, 3dNOW!, enhanced 3dNOW! and 64-bit instruction set extensions.)
9062 @item k8-sse3, opteron-sse3, athlon64-sse3
9063 Improved versions of k8, opteron and athlon64 with SSE3 instruction set support.
9065 IDT Winchip C6 CPU, dealt in same way as i486 with additional MMX instruction
9068 IDT Winchip2 CPU, dealt in same way as i486 with additional MMX and 3dNOW!
9069 instruction set support.
9071 Via C3 CPU with MMX and 3dNOW! instruction set support. (No scheduling is
9072 implemented for this chip.)
9074 Via C3-2 CPU with MMX and SSE instruction set support. (No scheduling is
9075 implemented for this chip.)
9077 Embedded AMD CPU with MMX and 3dNOW! instruction set support.
9080 While picking a specific @var{cpu-type} will schedule things appropriately
9081 for that particular chip, the compiler will not generate any code that
9082 does not run on the i386 without the @option{-march=@var{cpu-type}} option
9085 @item -march=@var{cpu-type}
9087 Generate instructions for the machine type @var{cpu-type}. The choices
9088 for @var{cpu-type} are the same as for @option{-mtune}. Moreover,
9089 specifying @option{-march=@var{cpu-type}} implies @option{-mtune=@var{cpu-type}}.
9091 @item -mcpu=@var{cpu-type}
9093 A deprecated synonym for @option{-mtune}.
9102 @opindex mpentiumpro
9103 These options are synonyms for @option{-mtune=i386}, @option{-mtune=i486},
9104 @option{-mtune=pentium}, and @option{-mtune=pentiumpro} respectively.
9105 These synonyms are deprecated.
9107 @item -mfpmath=@var{unit}
9109 Generate floating point arithmetics for selected unit @var{unit}. The choices
9114 Use the standard 387 floating point coprocessor present majority of chips and
9115 emulated otherwise. Code compiled with this option will run almost everywhere.
9116 The temporary results are computed in 80bit precision instead of precision
9117 specified by the type resulting in slightly different results compared to most
9118 of other chips. See @option{-ffloat-store} for more detailed description.
9120 This is the default choice for i386 compiler.
9123 Use scalar floating point instructions present in the SSE instruction set.
9124 This instruction set is supported by Pentium3 and newer chips, in the AMD line
9125 by Athlon-4, Athlon-xp and Athlon-mp chips. The earlier version of SSE
9126 instruction set supports only single precision arithmetics, thus the double and
9127 extended precision arithmetics is still done using 387. Later version, present
9128 only in Pentium4 and the future AMD x86-64 chips supports double precision
9131 For the i386 compiler, you need to use @option{-march=@var{cpu-type}}, @option{-msse}
9132 or @option{-msse2} switches to enable SSE extensions and make this option
9133 effective. For the x86-64 compiler, these extensions are enabled by default.
9135 The resulting code should be considerably faster in the majority of cases and avoid
9136 the numerical instability problems of 387 code, but may break some existing
9137 code that expects temporaries to be 80bit.
9139 This is the default choice for the x86-64 compiler.
9142 Attempt to utilize both instruction sets at once. This effectively double the
9143 amount of available registers and on chips with separate execution units for
9144 387 and SSE the execution resources too. Use this option with care, as it is
9145 still experimental, because the GCC register allocator does not model separate
9146 functional units well resulting in instable performance.
9149 @item -masm=@var{dialect}
9150 @opindex masm=@var{dialect}
9151 Output asm instructions using selected @var{dialect}. Supported
9152 choices are @samp{intel} or @samp{att} (the default one). Darwin does
9153 not support @samp{intel}.
9158 @opindex mno-ieee-fp
9159 Control whether or not the compiler uses IEEE floating point
9160 comparisons. These handle correctly the case where the result of a
9161 comparison is unordered.
9164 @opindex msoft-float
9165 Generate output containing library calls for floating point.
9166 @strong{Warning:} the requisite libraries are not part of GCC@.
9167 Normally the facilities of the machine's usual C compiler are used, but
9168 this can't be done directly in cross-compilation. You must make your
9169 own arrangements to provide suitable library functions for
9172 On machines where a function returns floating point results in the 80387
9173 register stack, some floating point opcodes may be emitted even if
9174 @option{-msoft-float} is used.
9176 @item -mno-fp-ret-in-387
9177 @opindex mno-fp-ret-in-387
9178 Do not use the FPU registers for return values of functions.
9180 The usual calling convention has functions return values of types
9181 @code{float} and @code{double} in an FPU register, even if there
9182 is no FPU@. The idea is that the operating system should emulate
9185 The option @option{-mno-fp-ret-in-387} causes such values to be returned
9186 in ordinary CPU registers instead.
9188 @item -mno-fancy-math-387
9189 @opindex mno-fancy-math-387
9190 Some 387 emulators do not support the @code{sin}, @code{cos} and
9191 @code{sqrt} instructions for the 387. Specify this option to avoid
9192 generating those instructions. This option is the default on
9193 OpenBSD and NetBSD@. This option is overridden when @option{-march}
9194 indicates that the target cpu will always have an FPU and so the
9195 instruction will not need emulation. As of revision 2.6.1, these
9196 instructions are not generated unless you also use the
9197 @option{-funsafe-math-optimizations} switch.
9199 @item -malign-double
9200 @itemx -mno-align-double
9201 @opindex malign-double
9202 @opindex mno-align-double
9203 Control whether GCC aligns @code{double}, @code{long double}, and
9204 @code{long long} variables on a two word boundary or a one word
9205 boundary. Aligning @code{double} variables on a two word boundary will
9206 produce code that runs somewhat faster on a @samp{Pentium} at the
9207 expense of more memory.
9209 On x86-64, @option{-malign-double} is enabled by default.
9211 @strong{Warning:} if you use the @option{-malign-double} switch,
9212 structures containing the above types will be aligned differently than
9213 the published application binary interface specifications for the 386
9214 and will not be binary compatible with structures in code compiled
9215 without that switch.
9217 @item -m96bit-long-double
9218 @itemx -m128bit-long-double
9219 @opindex m96bit-long-double
9220 @opindex m128bit-long-double
9221 These switches control the size of @code{long double} type. The i386
9222 application binary interface specifies the size to be 96 bits,
9223 so @option{-m96bit-long-double} is the default in 32 bit mode.
9225 Modern architectures (Pentium and newer) would prefer @code{long double}
9226 to be aligned to an 8 or 16 byte boundary. In arrays or structures
9227 conforming to the ABI, this would not be possible. So specifying a
9228 @option{-m128bit-long-double} will align @code{long double}
9229 to a 16 byte boundary by padding the @code{long double} with an additional
9232 In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
9233 its ABI specifies that @code{long double} is to be aligned on 16 byte boundary.
9235 Notice that neither of these options enable any extra precision over the x87
9236 standard of 80 bits for a @code{long double}.
9238 @strong{Warning:} if you override the default value for your target ABI, the
9239 structures and arrays containing @code{long double} variables will change
9240 their size as well as function calling convention for function taking
9241 @code{long double} will be modified. Hence they will not be binary
9242 compatible with arrays or structures in code compiled without that switch.
9244 @item -mmlarge-data-threshold=@var{number}
9245 @opindex mlarge-data-threshold=@var{number}
9246 When @option{-mcmodel=medium} is specified, the data greater than
9247 @var{threshold} are placed in large data section. This value must be the
9248 same across all object linked into the binary and defaults to 65535.
9251 @itemx -mno-svr3-shlib
9252 @opindex msvr3-shlib
9253 @opindex mno-svr3-shlib
9254 Control whether GCC places uninitialized local variables into the
9255 @code{bss} or @code{data} segments. @option{-msvr3-shlib} places them
9256 into @code{bss}. These options are meaningful only on System V Release 3.
9260 Use a different function-calling convention, in which functions that
9261 take a fixed number of arguments return with the @code{ret} @var{num}
9262 instruction, which pops their arguments while returning. This saves one
9263 instruction in the caller since there is no need to pop the arguments
9266 You can specify that an individual function is called with this calling
9267 sequence with the function attribute @samp{stdcall}. You can also
9268 override the @option{-mrtd} option by using the function attribute
9269 @samp{cdecl}. @xref{Function Attributes}.
9271 @strong{Warning:} this calling convention is incompatible with the one
9272 normally used on Unix, so you cannot use it if you need to call
9273 libraries compiled with the Unix compiler.
9275 Also, you must provide function prototypes for all functions that
9276 take variable numbers of arguments (including @code{printf});
9277 otherwise incorrect code will be generated for calls to those
9280 In addition, seriously incorrect code will result if you call a
9281 function with too many arguments. (Normally, extra arguments are
9282 harmlessly ignored.)
9284 @item -mregparm=@var{num}
9286 Control how many registers are used to pass integer arguments. By
9287 default, no registers are used to pass arguments, and at most 3
9288 registers can be used. You can control this behavior for a specific
9289 function by using the function attribute @samp{regparm}.
9290 @xref{Function Attributes}.
9292 @strong{Warning:} if you use this switch, and
9293 @var{num} is nonzero, then you must build all modules with the same
9294 value, including any libraries. This includes the system libraries and
9298 @opindex msseregparm
9299 Use SSE register passing conventions for float and double arguments
9300 and return values. You can control this behavior for a specific
9301 function by using the function attribute @samp{sseregparm}.
9302 @xref{Function Attributes}.
9304 @strong{Warning:} if you use this switch then you must build all
9305 modules with the same value, including any libraries. This includes
9306 the system libraries and startup modules.
9308 @item -mstackrealign
9309 @opindex mstackrealign
9310 Realign the stack at entry. On the Intel x86, the
9311 @option{-mstackrealign} option will generate an alternate prologue and
9312 epilogue that realigns the runtime stack. This supports mixing legacy
9313 codes that keep a 4-byte aligned stack with modern codes that keep a
9314 16-byte stack for SSE compatibility. The alternate prologue and
9315 epilogue are slower and bigger than the regular ones, and the
9316 alternate prologue requires an extra scratch register; this lowers the
9317 number of registers available if used in conjunction with the
9318 @code{regparm} attribute. The @option{-mstackrealign} option is
9319 incompatible with the nested function prologue; this is considered a
9320 hard error. See also the attribute @code{force_align_arg_pointer},
9321 applicable to individual functions.
9323 @item -mpreferred-stack-boundary=@var{num}
9324 @opindex mpreferred-stack-boundary
9325 Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
9326 byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
9327 the default is 4 (16 bytes or 128 bits).
9329 On Pentium and PentiumPro, @code{double} and @code{long double} values
9330 should be aligned to an 8 byte boundary (see @option{-malign-double}) or
9331 suffer significant run time performance penalties. On Pentium III, the
9332 Streaming SIMD Extension (SSE) data type @code{__m128} may not work
9333 properly if it is not 16 byte aligned.
9335 To ensure proper alignment of this values on the stack, the stack boundary
9336 must be as aligned as that required by any value stored on the stack.
9337 Further, every function must be generated such that it keeps the stack
9338 aligned. Thus calling a function compiled with a higher preferred
9339 stack boundary from a function compiled with a lower preferred stack
9340 boundary will most likely misalign the stack. It is recommended that
9341 libraries that use callbacks always use the default setting.
9343 This extra alignment does consume extra stack space, and generally
9344 increases code size. Code that is sensitive to stack space usage, such
9345 as embedded systems and operating system kernels, may want to reduce the
9346 preferred alignment to @option{-mpreferred-stack-boundary=2}.
9366 These switches enable or disable the use of instructions in the MMX,
9367 SSE, SSE2, SSE3, SSSE3 or 3DNow! extended instruction sets.
9368 These extensions are also available as built-in functions: see
9369 @ref{X86 Built-in Functions}, for details of the functions enabled and
9370 disabled by these switches.
9372 To have SSE/SSE2 instructions generated automatically from floating-point
9373 code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
9375 These options will enable GCC to use these extended instructions in
9376 generated code, even without @option{-mfpmath=sse}. Applications which
9377 perform runtime CPU detection must compile separate files for each
9378 supported architecture, using the appropriate flags. In particular,
9379 the file containing the CPU detection code should be compiled without
9383 @itemx -mno-push-args
9385 @opindex mno-push-args
9386 Use PUSH operations to store outgoing parameters. This method is shorter
9387 and usually equally fast as method using SUB/MOV operations and is enabled
9388 by default. In some cases disabling it may improve performance because of
9389 improved scheduling and reduced dependencies.
9391 @item -maccumulate-outgoing-args
9392 @opindex maccumulate-outgoing-args
9393 If enabled, the maximum amount of space required for outgoing arguments will be
9394 computed in the function prologue. This is faster on most modern CPUs
9395 because of reduced dependencies, improved scheduling and reduced stack usage
9396 when preferred stack boundary is not equal to 2. The drawback is a notable
9397 increase in code size. This switch implies @option{-mno-push-args}.
9401 Support thread-safe exception handling on @samp{Mingw32}. Code that relies
9402 on thread-safe exception handling must compile and link all code with the
9403 @option{-mthreads} option. When compiling, @option{-mthreads} defines
9404 @option{-D_MT}; when linking, it links in a special thread helper library
9405 @option{-lmingwthrd} which cleans up per thread exception handling data.
9407 @item -mno-align-stringops
9408 @opindex mno-align-stringops
9409 Do not align destination of inlined string operations. This switch reduces
9410 code size and improves performance in case the destination is already aligned,
9411 but GCC doesn't know about it.
9413 @item -minline-all-stringops
9414 @opindex minline-all-stringops
9415 By default GCC inlines string operations only when destination is known to be
9416 aligned at least to 4 byte boundary. This enables more inlining, increase code
9417 size, but may improve performance of code that depends on fast memcpy, strlen
9418 and memset for short lengths.
9420 @item -momit-leaf-frame-pointer
9421 @opindex momit-leaf-frame-pointer
9422 Don't keep the frame pointer in a register for leaf functions. This
9423 avoids the instructions to save, set up and restore frame pointers and
9424 makes an extra register available in leaf functions. The option
9425 @option{-fomit-frame-pointer} removes the frame pointer for all functions
9426 which might make debugging harder.
9428 @item -mtls-direct-seg-refs
9429 @itemx -mno-tls-direct-seg-refs
9430 @opindex mtls-direct-seg-refs
9431 Controls whether TLS variables may be accessed with offsets from the
9432 TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
9433 or whether the thread base pointer must be added. Whether or not this
9434 is legal depends on the operating system, and whether it maps the
9435 segment to cover the entire TLS area.
9437 For systems that use GNU libc, the default is on.
9440 These @samp{-m} switches are supported in addition to the above
9441 on AMD x86-64 processors in 64-bit environments.
9448 Generate code for a 32-bit or 64-bit environment.
9449 The 32-bit environment sets int, long and pointer to 32 bits and
9450 generates code that runs on any i386 system.
9451 The 64-bit environment sets int to 32 bits and long and pointer
9452 to 64 bits and generates code for AMD's x86-64 architecture. For
9453 darwin only the -m64 option turns off the @option{-fno-pic} and
9454 @option{-mdynamic-no-pic} options.
9457 @opindex no-red-zone
9458 Do not use a so called red zone for x86-64 code. The red zone is mandated
9459 by the x86-64 ABI, it is a 128-byte area beyond the location of the
9460 stack pointer that will not be modified by signal or interrupt handlers
9461 and therefore can be used for temporary data without adjusting the stack
9462 pointer. The flag @option{-mno-red-zone} disables this red zone.
9464 @item -mcmodel=small
9465 @opindex mcmodel=small
9466 Generate code for the small code model: the program and its symbols must
9467 be linked in the lower 2 GB of the address space. Pointers are 64 bits.
9468 Programs can be statically or dynamically linked. This is the default
9471 @item -mcmodel=kernel
9472 @opindex mcmodel=kernel
9473 Generate code for the kernel code model. The kernel runs in the
9474 negative 2 GB of the address space.
9475 This model has to be used for Linux kernel code.
9477 @item -mcmodel=medium
9478 @opindex mcmodel=medium
9479 Generate code for the medium model: The program is linked in the lower 2
9480 GB of the address space but symbols can be located anywhere in the
9481 address space. Programs can be statically or dynamically linked, but
9482 building of shared libraries are not supported with the medium model.
9484 @item -mcmodel=large
9485 @opindex mcmodel=large
9486 Generate code for the large model: This model makes no assumptions
9487 about addresses and sizes of sections. Currently GCC does not implement
9492 @subsection IA-64 Options
9493 @cindex IA-64 Options
9495 These are the @samp{-m} options defined for the Intel IA-64 architecture.
9499 @opindex mbig-endian
9500 Generate code for a big endian target. This is the default for HP-UX@.
9502 @item -mlittle-endian
9503 @opindex mlittle-endian
9504 Generate code for a little endian target. This is the default for AIX5
9511 Generate (or don't) code for the GNU assembler. This is the default.
9512 @c Also, this is the default if the configure option @option{--with-gnu-as}
9519 Generate (or don't) code for the GNU linker. This is the default.
9520 @c Also, this is the default if the configure option @option{--with-gnu-ld}
9525 Generate code that does not use a global pointer register. The result
9526 is not position independent code, and violates the IA-64 ABI@.
9528 @item -mvolatile-asm-stop
9529 @itemx -mno-volatile-asm-stop
9530 @opindex mvolatile-asm-stop
9531 @opindex mno-volatile-asm-stop
9532 Generate (or don't) a stop bit immediately before and after volatile asm
9535 @item -mregister-names
9536 @itemx -mno-register-names
9537 @opindex mregister-names
9538 @opindex mno-register-names
9539 Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
9540 the stacked registers. This may make assembler output more readable.
9546 Disable (or enable) optimizations that use the small data section. This may
9547 be useful for working around optimizer bugs.
9550 @opindex mconstant-gp
9551 Generate code that uses a single constant global pointer value. This is
9552 useful when compiling kernel code.
9556 Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
9557 This is useful when compiling firmware code.
9559 @item -minline-float-divide-min-latency
9560 @opindex minline-float-divide-min-latency
9561 Generate code for inline divides of floating point values
9562 using the minimum latency algorithm.
9564 @item -minline-float-divide-max-throughput
9565 @opindex minline-float-divide-max-throughput
9566 Generate code for inline divides of floating point values
9567 using the maximum throughput algorithm.
9569 @item -minline-int-divide-min-latency
9570 @opindex minline-int-divide-min-latency
9571 Generate code for inline divides of integer values
9572 using the minimum latency algorithm.
9574 @item -minline-int-divide-max-throughput
9575 @opindex minline-int-divide-max-throughput
9576 Generate code for inline divides of integer values
9577 using the maximum throughput algorithm.
9579 @item -minline-sqrt-min-latency
9580 @opindex minline-sqrt-min-latency
9581 Generate code for inline square roots
9582 using the minimum latency algorithm.
9584 @item -minline-sqrt-max-throughput
9585 @opindex minline-sqrt-max-throughput
9586 Generate code for inline square roots
9587 using the maximum throughput algorithm.
9589 @item -mno-dwarf2-asm
9591 @opindex mno-dwarf2-asm
9592 @opindex mdwarf2-asm
9593 Don't (or do) generate assembler code for the DWARF2 line number debugging
9594 info. This may be useful when not using the GNU assembler.
9596 @item -mearly-stop-bits
9597 @itemx -mno-early-stop-bits
9598 @opindex mearly-stop-bits
9599 @opindex mno-early-stop-bits
9600 Allow stop bits to be placed earlier than immediately preceding the
9601 instruction that triggered the stop bit. This can improve instruction
9602 scheduling, but does not always do so.
9604 @item -mfixed-range=@var{register-range}
9605 @opindex mfixed-range
9606 Generate code treating the given register range as fixed registers.
9607 A fixed register is one that the register allocator can not use. This is
9608 useful when compiling kernel code. A register range is specified as
9609 two registers separated by a dash. Multiple register ranges can be
9610 specified separated by a comma.
9612 @item -mtls-size=@var{tls-size}
9614 Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
9617 @item -mtune=@var{cpu-type}
9619 Tune the instruction scheduling for a particular CPU, Valid values are
9620 itanium, itanium1, merced, itanium2, and mckinley.
9626 Add support for multithreading using the POSIX threads library. This
9627 option sets flags for both the preprocessor and linker. It does
9628 not affect the thread safety of object code produced by the compiler or
9629 that of libraries supplied with it. These are HP-UX specific flags.
9635 Generate code for a 32-bit or 64-bit environment.
9636 The 32-bit environment sets int, long and pointer to 32 bits.
9637 The 64-bit environment sets int to 32 bits and long and pointer
9638 to 64 bits. These are HP-UX specific flags.
9640 @item -mno-sched-br-data-spec
9641 @itemx -msched-br-data-spec
9642 @opindex mno-sched-br-data-spec
9643 @opindex msched-br-data-spec
9644 (Dis/En)able data speculative scheduling before reload.
9645 This will result in generation of the ld.a instructions and
9646 the corresponding check instructions (ld.c / chk.a).
9647 The default is 'disable'.
9649 @item -msched-ar-data-spec
9650 @itemx -mno-sched-ar-data-spec
9651 @opindex msched-ar-data-spec
9652 @opindex mno-sched-ar-data-spec
9653 (En/Dis)able data speculative scheduling after reload.
9654 This will result in generation of the ld.a instructions and
9655 the corresponding check instructions (ld.c / chk.a).
9656 The default is 'enable'.
9658 @item -mno-sched-control-spec
9659 @itemx -msched-control-spec
9660 @opindex mno-sched-control-spec
9661 @opindex msched-control-spec
9662 (Dis/En)able control speculative scheduling. This feature is
9663 available only during region scheduling (i.e. before reload).
9664 This will result in generation of the ld.s instructions and
9665 the corresponding check instructions chk.s .
9666 The default is 'disable'.
9668 @item -msched-br-in-data-spec
9669 @itemx -mno-sched-br-in-data-spec
9670 @opindex msched-br-in-data-spec
9671 @opindex mno-sched-br-in-data-spec
9672 (En/Dis)able speculative scheduling of the instructions that
9673 are dependent on the data speculative loads before reload.
9674 This is effective only with @option{-msched-br-data-spec} enabled.
9675 The default is 'enable'.
9677 @item -msched-ar-in-data-spec
9678 @itemx -mno-sched-ar-in-data-spec
9679 @opindex msched-ar-in-data-spec
9680 @opindex mno-sched-ar-in-data-spec
9681 (En/Dis)able speculative scheduling of the instructions that
9682 are dependent on the data speculative loads after reload.
9683 This is effective only with @option{-msched-ar-data-spec} enabled.
9684 The default is 'enable'.
9686 @item -msched-in-control-spec
9687 @itemx -mno-sched-in-control-spec
9688 @opindex msched-in-control-spec
9689 @opindex mno-sched-in-control-spec
9690 (En/Dis)able speculative scheduling of the instructions that
9691 are dependent on the control speculative loads.
9692 This is effective only with @option{-msched-control-spec} enabled.
9693 The default is 'enable'.
9696 @itemx -mno-sched-ldc
9698 @opindex mno-sched-ldc
9699 (En/Dis)able use of simple data speculation checks ld.c .
9700 If disabled, only chk.a instructions will be emitted to check
9701 data speculative loads.
9702 The default is 'enable'.
9704 @item -mno-sched-control-ldc
9705 @itemx -msched-control-ldc
9706 @opindex mno-sched-control-ldc
9707 @opindex msched-control-ldc
9708 (Dis/En)able use of ld.c instructions to check control speculative loads.
9709 If enabled, in case of control speculative load with no speculatively
9710 scheduled dependent instructions this load will be emitted as ld.sa and
9711 ld.c will be used to check it.
9712 The default is 'disable'.
9714 @item -mno-sched-spec-verbose
9715 @itemx -msched-spec-verbose
9716 @opindex mno-sched-spec-verbose
9717 @opindex msched-spec-verbose
9718 (Dis/En)able printing of the information about speculative motions.
9720 @item -mno-sched-prefer-non-data-spec-insns
9721 @itemx -msched-prefer-non-data-spec-insns
9722 @opindex mno-sched-prefer-non-data-spec-insns
9723 @opindex msched-prefer-non-data-spec-insns
9724 If enabled, data speculative instructions will be chosen for schedule
9725 only if there are no other choices at the moment. This will make
9726 the use of the data speculation much more conservative.
9727 The default is 'disable'.
9729 @item -mno-sched-prefer-non-control-spec-insns
9730 @itemx -msched-prefer-non-control-spec-insns
9731 @opindex mno-sched-prefer-non-control-spec-insns
9732 @opindex msched-prefer-non-control-spec-insns
9733 If enabled, control speculative instructions will be chosen for schedule
9734 only if there are no other choices at the moment. This will make
9735 the use of the control speculation much more conservative.
9736 The default is 'disable'.
9738 @item -mno-sched-count-spec-in-critical-path
9739 @itemx -msched-count-spec-in-critical-path
9740 @opindex mno-sched-count-spec-in-critical-path
9741 @opindex msched-count-spec-in-critical-path
9742 If enabled, speculative dependencies will be considered during
9743 computation of the instructions priorities. This will make the use of the
9744 speculation a bit more conservative.
9745 The default is 'disable'.
9750 @subsection M32C Options
9751 @cindex M32C options
9754 @item -mcpu=@var{name}
9756 Select the CPU for which code is generated. @var{name} may be one of
9757 @samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
9758 /60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
9763 Specifies that the program will be run on the simulator. This causes
9764 an alternate runtime library to be linked in which supports, for
9765 example, file I/O. You must not use this option when generating
9766 programs that will run on real hardware; you must provide your own
9767 runtime library for whatever I/O functions are needed.
9769 @item -memregs=@var{number}
9771 Specifies the number of memory-based pseudo-registers GCC will use
9772 during code generation. These pseudo-registers will be used like real
9773 registers, so there is a tradeoff between GCC's ability to fit the
9774 code into available registers, and the performance penalty of using
9775 memory instead of registers. Note that all modules in a program must
9776 be compiled with the same value for this option. Because of that, you
9777 must not use this option with the default runtime libraries gcc
9782 @node M32R/D Options
9783 @subsection M32R/D Options
9784 @cindex M32R/D options
9786 These @option{-m} options are defined for Renesas M32R/D architectures:
9791 Generate code for the M32R/2@.
9795 Generate code for the M32R/X@.
9799 Generate code for the M32R@. This is the default.
9802 @opindex mmodel=small
9803 Assume all objects live in the lower 16MB of memory (so that their addresses
9804 can be loaded with the @code{ld24} instruction), and assume all subroutines
9805 are reachable with the @code{bl} instruction.
9806 This is the default.
9808 The addressability of a particular object can be set with the
9809 @code{model} attribute.
9811 @item -mmodel=medium
9812 @opindex mmodel=medium
9813 Assume objects may be anywhere in the 32-bit address space (the compiler
9814 will generate @code{seth/add3} instructions to load their addresses), and
9815 assume all subroutines are reachable with the @code{bl} instruction.
9818 @opindex mmodel=large
9819 Assume objects may be anywhere in the 32-bit address space (the compiler
9820 will generate @code{seth/add3} instructions to load their addresses), and
9821 assume subroutines may not be reachable with the @code{bl} instruction
9822 (the compiler will generate the much slower @code{seth/add3/jl}
9823 instruction sequence).
9826 @opindex msdata=none
9827 Disable use of the small data area. Variables will be put into
9828 one of @samp{.data}, @samp{bss}, or @samp{.rodata} (unless the
9829 @code{section} attribute has been specified).
9830 This is the default.
9832 The small data area consists of sections @samp{.sdata} and @samp{.sbss}.
9833 Objects may be explicitly put in the small data area with the
9834 @code{section} attribute using one of these sections.
9837 @opindex msdata=sdata
9838 Put small global and static data in the small data area, but do not
9839 generate special code to reference them.
9843 Put small global and static data in the small data area, and generate
9844 special instructions to reference them.
9848 @cindex smaller data references
9849 Put global and static objects less than or equal to @var{num} bytes
9850 into the small data or bss sections instead of the normal data or bss
9851 sections. The default value of @var{num} is 8.
9852 The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
9853 for this option to have any effect.
9855 All modules should be compiled with the same @option{-G @var{num}} value.
9856 Compiling with different values of @var{num} may or may not work; if it
9857 doesn't the linker will give an error message---incorrect code will not be
9862 Makes the M32R specific code in the compiler display some statistics
9863 that might help in debugging programs.
9866 @opindex malign-loops
9867 Align all loops to a 32-byte boundary.
9869 @item -mno-align-loops
9870 @opindex mno-align-loops
9871 Do not enforce a 32-byte alignment for loops. This is the default.
9873 @item -missue-rate=@var{number}
9874 @opindex missue-rate=@var{number}
9875 Issue @var{number} instructions per cycle. @var{number} can only be 1
9878 @item -mbranch-cost=@var{number}
9879 @opindex mbranch-cost=@var{number}
9880 @var{number} can only be 1 or 2. If it is 1 then branches will be
9881 preferred over conditional code, if it is 2, then the opposite will
9884 @item -mflush-trap=@var{number}
9885 @opindex mflush-trap=@var{number}
9886 Specifies the trap number to use to flush the cache. The default is
9887 12. Valid numbers are between 0 and 15 inclusive.
9889 @item -mno-flush-trap
9890 @opindex mno-flush-trap
9891 Specifies that the cache cannot be flushed by using a trap.
9893 @item -mflush-func=@var{name}
9894 @opindex mflush-func=@var{name}
9895 Specifies the name of the operating system function to call to flush
9896 the cache. The default is @emph{_flush_cache}, but a function call
9897 will only be used if a trap is not available.
9899 @item -mno-flush-func
9900 @opindex mno-flush-func
9901 Indicates that there is no OS function for flushing the cache.
9905 @node M680x0 Options
9906 @subsection M680x0 Options
9907 @cindex M680x0 options
9909 These are the @samp{-m} options defined for the 68000 series. The default
9910 values for these options depends on which style of 68000 was selected when
9911 the compiler was configured; the defaults for the most common choices are
9919 Generate output for a 68000. This is the default
9920 when the compiler is configured for 68000-based systems.
9922 Use this option for microcontrollers with a 68000 or EC000 core,
9923 including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
9929 Generate output for a 68020. This is the default
9930 when the compiler is configured for 68020-based systems.
9934 Generate output containing 68881 instructions for floating point.
9935 This is the default for most 68020 systems unless @option{--nfp} was
9936 specified when the compiler was configured.
9940 Generate output for a 68030. This is the default when the compiler is
9941 configured for 68030-based systems.
9945 Generate output for a 68040. This is the default when the compiler is
9946 configured for 68040-based systems.
9948 This option inhibits the use of 68881/68882 instructions that have to be
9949 emulated by software on the 68040. Use this option if your 68040 does not
9950 have code to emulate those instructions.
9954 Generate output for a 68060. This is the default when the compiler is
9955 configured for 68060-based systems.
9957 This option inhibits the use of 68020 and 68881/68882 instructions that
9958 have to be emulated by software on the 68060. Use this option if your 68060
9959 does not have code to emulate those instructions.
9963 Generate output for a CPU32. This is the default
9964 when the compiler is configured for CPU32-based systems.
9966 Use this option for microcontrollers with a
9967 CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
9968 68336, 68340, 68341, 68349 and 68360.
9972 Generate output for a 520X ``coldfire'' family cpu. This is the default
9973 when the compiler is configured for 520X-based systems.
9975 Use this option for microcontroller with a 5200 core, including
9976 the MCF5202, MCF5203, MCF5204 and MCF5202.
9980 Generate output for a ColdFire V4e family cpu (e.g.@: 547x/548x).
9981 This includes use of hardware floating point instructions.
9985 Generate output for a 68040, without using any of the new instructions.
9986 This results in code which can run relatively efficiently on either a
9987 68020/68881 or a 68030 or a 68040. The generated code does use the
9988 68881 instructions that are emulated on the 68040.
9992 Generate output for a 68060, without using any of the new instructions.
9993 This results in code which can run relatively efficiently on either a
9994 68020/68881 or a 68030 or a 68040. The generated code does use the
9995 68881 instructions that are emulated on the 68060.
9998 @opindex msoft-float
9999 Generate output containing library calls for floating point.
10000 @strong{Warning:} the requisite libraries are not available for all m68k
10001 targets. Normally the facilities of the machine's usual C compiler are
10002 used, but this can't be done directly in cross-compilation. You must
10003 make your own arrangements to provide suitable library functions for
10004 cross-compilation. The embedded targets @samp{m68k-*-aout} and
10005 @samp{m68k-*-coff} do provide software floating point support.
10009 Consider type @code{int} to be 16 bits wide, like @code{short int}.
10010 Additionally, parameters passed on the stack are also aligned to a
10011 16-bit boundary even on targets whose API mandates promotion to 32-bit.
10014 @opindex mnobitfield
10015 Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
10016 and @option{-m5200} options imply @w{@option{-mnobitfield}}.
10020 Do use the bit-field instructions. The @option{-m68020} option implies
10021 @option{-mbitfield}. This is the default if you use a configuration
10022 designed for a 68020.
10026 Use a different function-calling convention, in which functions
10027 that take a fixed number of arguments return with the @code{rtd}
10028 instruction, which pops their arguments while returning. This
10029 saves one instruction in the caller since there is no need to pop
10030 the arguments there.
10032 This calling convention is incompatible with the one normally
10033 used on Unix, so you cannot use it if you need to call libraries
10034 compiled with the Unix compiler.
10036 Also, you must provide function prototypes for all functions that
10037 take variable numbers of arguments (including @code{printf});
10038 otherwise incorrect code will be generated for calls to those
10041 In addition, seriously incorrect code will result if you call a
10042 function with too many arguments. (Normally, extra arguments are
10043 harmlessly ignored.)
10045 The @code{rtd} instruction is supported by the 68010, 68020, 68030,
10046 68040, 68060 and CPU32 processors, but not by the 68000 or 5200.
10049 @itemx -mno-align-int
10050 @opindex malign-int
10051 @opindex mno-align-int
10052 Control whether GCC aligns @code{int}, @code{long}, @code{long long},
10053 @code{float}, @code{double}, and @code{long double} variables on a 32-bit
10054 boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
10055 Aligning variables on 32-bit boundaries produces code that runs somewhat
10056 faster on processors with 32-bit busses at the expense of more memory.
10058 @strong{Warning:} if you use the @option{-malign-int} switch, GCC will
10059 align structures containing the above types differently than
10060 most published application binary interface specifications for the m68k.
10064 Use the pc-relative addressing mode of the 68000 directly, instead of
10065 using a global offset table. At present, this option implies @option{-fpic},
10066 allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
10067 not presently supported with @option{-mpcrel}, though this could be supported for
10068 68020 and higher processors.
10070 @item -mno-strict-align
10071 @itemx -mstrict-align
10072 @opindex mno-strict-align
10073 @opindex mstrict-align
10074 Do not (do) assume that unaligned memory references will be handled by
10078 Generate code that allows the data segment to be located in a different
10079 area of memory from the text segment. This allows for execute in place in
10080 an environment without virtual memory management. This option implies
10083 @item -mno-sep-data
10084 Generate code that assumes that the data segment follows the text segment.
10085 This is the default.
10087 @item -mid-shared-library
10088 Generate code that supports shared libraries via the library ID method.
10089 This allows for execute in place and shared libraries in an environment
10090 without virtual memory management. This option implies @option{-fPIC}.
10092 @item -mno-id-shared-library
10093 Generate code that doesn't assume ID based shared libraries are being used.
10094 This is the default.
10096 @item -mshared-library-id=n
10097 Specified the identification number of the ID based shared library being
10098 compiled. Specifying a value of 0 will generate more compact code, specifying
10099 other values will force the allocation of that number to the current
10100 library but is no more space or time efficient than omitting this option.
10104 @node M68hc1x Options
10105 @subsection M68hc1x Options
10106 @cindex M68hc1x options
10108 These are the @samp{-m} options defined for the 68hc11 and 68hc12
10109 microcontrollers. The default values for these options depends on
10110 which style of microcontroller was selected when the compiler was configured;
10111 the defaults for the most common choices are given below.
10118 Generate output for a 68HC11. This is the default
10119 when the compiler is configured for 68HC11-based systems.
10125 Generate output for a 68HC12. This is the default
10126 when the compiler is configured for 68HC12-based systems.
10132 Generate output for a 68HCS12.
10134 @item -mauto-incdec
10135 @opindex mauto-incdec
10136 Enable the use of 68HC12 pre and post auto-increment and auto-decrement
10143 Enable the use of 68HC12 min and max instructions.
10146 @itemx -mno-long-calls
10147 @opindex mlong-calls
10148 @opindex mno-long-calls
10149 Treat all calls as being far away (near). If calls are assumed to be
10150 far away, the compiler will use the @code{call} instruction to
10151 call a function and the @code{rtc} instruction for returning.
10155 Consider type @code{int} to be 16 bits wide, like @code{short int}.
10157 @item -msoft-reg-count=@var{count}
10158 @opindex msoft-reg-count
10159 Specify the number of pseudo-soft registers which are used for the
10160 code generation. The maximum number is 32. Using more pseudo-soft
10161 register may or may not result in better code depending on the program.
10162 The default is 4 for 68HC11 and 2 for 68HC12.
10166 @node MCore Options
10167 @subsection MCore Options
10168 @cindex MCore options
10170 These are the @samp{-m} options defined for the Motorola M*Core
10176 @itemx -mno-hardlit
10178 @opindex mno-hardlit
10179 Inline constants into the code stream if it can be done in two
10180 instructions or less.
10186 Use the divide instruction. (Enabled by default).
10188 @item -mrelax-immediate
10189 @itemx -mno-relax-immediate
10190 @opindex mrelax-immediate
10191 @opindex mno-relax-immediate
10192 Allow arbitrary sized immediates in bit operations.
10194 @item -mwide-bitfields
10195 @itemx -mno-wide-bitfields
10196 @opindex mwide-bitfields
10197 @opindex mno-wide-bitfields
10198 Always treat bit-fields as int-sized.
10200 @item -m4byte-functions
10201 @itemx -mno-4byte-functions
10202 @opindex m4byte-functions
10203 @opindex mno-4byte-functions
10204 Force all functions to be aligned to a four byte boundary.
10206 @item -mcallgraph-data
10207 @itemx -mno-callgraph-data
10208 @opindex mcallgraph-data
10209 @opindex mno-callgraph-data
10210 Emit callgraph information.
10213 @itemx -mno-slow-bytes
10214 @opindex mslow-bytes
10215 @opindex mno-slow-bytes
10216 Prefer word access when reading byte quantities.
10218 @item -mlittle-endian
10219 @itemx -mbig-endian
10220 @opindex mlittle-endian
10221 @opindex mbig-endian
10222 Generate code for a little endian target.
10228 Generate code for the 210 processor.
10232 @subsection MIPS Options
10233 @cindex MIPS options
10239 Generate big-endian code.
10243 Generate little-endian code. This is the default for @samp{mips*el-*-*}
10246 @item -march=@var{arch}
10248 Generate code that will run on @var{arch}, which can be the name of a
10249 generic MIPS ISA, or the name of a particular processor.
10251 @samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
10252 @samp{mips32}, @samp{mips32r2}, and @samp{mips64}.
10253 The processor names are:
10254 @samp{4kc}, @samp{4km}, @samp{4kp},
10255 @samp{5kc}, @samp{5kf},
10257 @samp{24k}, @samp{24kc}, @samp{24kf}, @samp{24kx},
10260 @samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
10261 @samp{r4600}, @samp{r4650}, @samp{r6000}, @samp{r8000},
10262 @samp{rm7000}, @samp{rm9000},
10265 @samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
10266 @samp{vr5000}, @samp{vr5400} and @samp{vr5500}.
10267 The special value @samp{from-abi} selects the
10268 most compatible architecture for the selected ABI (that is,
10269 @samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
10271 In processor names, a final @samp{000} can be abbreviated as @samp{k}
10272 (for example, @samp{-march=r2k}). Prefixes are optional, and
10273 @samp{vr} may be written @samp{r}.
10275 GCC defines two macros based on the value of this option. The first
10276 is @samp{_MIPS_ARCH}, which gives the name of target architecture, as
10277 a string. The second has the form @samp{_MIPS_ARCH_@var{foo}},
10278 where @var{foo} is the capitalized value of @samp{_MIPS_ARCH}@.
10279 For example, @samp{-march=r2000} will set @samp{_MIPS_ARCH}
10280 to @samp{"r2000"} and define the macro @samp{_MIPS_ARCH_R2000}.
10282 Note that the @samp{_MIPS_ARCH} macro uses the processor names given
10283 above. In other words, it will have the full prefix and will not
10284 abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
10285 the macro names the resolved architecture (either @samp{"mips1"} or
10286 @samp{"mips3"}). It names the default architecture when no
10287 @option{-march} option is given.
10289 @item -mtune=@var{arch}
10291 Optimize for @var{arch}. Among other things, this option controls
10292 the way instructions are scheduled, and the perceived cost of arithmetic
10293 operations. The list of @var{arch} values is the same as for
10296 When this option is not used, GCC will optimize for the processor
10297 specified by @option{-march}. By using @option{-march} and
10298 @option{-mtune} together, it is possible to generate code that will
10299 run on a family of processors, but optimize the code for one
10300 particular member of that family.
10302 @samp{-mtune} defines the macros @samp{_MIPS_TUNE} and
10303 @samp{_MIPS_TUNE_@var{foo}}, which work in the same way as the
10304 @samp{-march} ones described above.
10308 Equivalent to @samp{-march=mips1}.
10312 Equivalent to @samp{-march=mips2}.
10316 Equivalent to @samp{-march=mips3}.
10320 Equivalent to @samp{-march=mips4}.
10324 Equivalent to @samp{-march=mips32}.
10328 Equivalent to @samp{-march=mips32r2}.
10332 Equivalent to @samp{-march=mips64}.
10337 @opindex mno-mips16
10338 Generate (do not generate) MIPS16 code. If GCC is targetting a
10339 MIPS32 or MIPS64 architecture, it will make use of the MIPS16e ASE@.
10351 Generate code for the given ABI@.
10353 Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
10354 generates 64-bit code when you select a 64-bit architecture, but you
10355 can use @option{-mgp32} to get 32-bit code instead.
10357 For information about the O64 ABI, see
10358 @w{@uref{http://gcc.gnu.org/projects/mipso64-abi.html}}.
10361 @itemx -mno-abicalls
10363 @opindex mno-abicalls
10364 Generate (do not generate) code that is suitable for SVR4-style
10365 dynamic objects. @option{-mabicalls} is the default for SVR4-based
10370 Generate (do not generate) code that is fully position-independent,
10371 and that can therefore be linked into shared libraries. This option
10372 only affects @option{-mabicalls}.
10374 All @option{-mabicalls} code has traditionally been position-independent,
10375 regardless of options like @option{-fPIC} and @option{-fpic}. However,
10376 as an extension, the GNU toolchain allows executables to use absolute
10377 accesses for locally-binding symbols. It can also use shorter GP
10378 initialization sequences and generate direct calls to locally-defined
10379 functions. This mode is selected by @option{-mno-shared}.
10381 @option{-mno-shared} depends on binutils 2.16 or higher and generates
10382 objects that can only be linked by the GNU linker. However, the option
10383 does not affect the ABI of the final executable; it only affects the ABI
10384 of relocatable objects. Using @option{-mno-shared} will generally make
10385 executables both smaller and quicker.
10387 @option{-mshared} is the default.
10393 Lift (do not lift) the usual restrictions on the size of the global
10396 GCC normally uses a single instruction to load values from the GOT@.
10397 While this is relatively efficient, it will only work if the GOT
10398 is smaller than about 64k. Anything larger will cause the linker
10399 to report an error such as:
10401 @cindex relocation truncated to fit (MIPS)
10403 relocation truncated to fit: R_MIPS_GOT16 foobar
10406 If this happens, you should recompile your code with @option{-mxgot}.
10407 It should then work with very large GOTs, although it will also be
10408 less efficient, since it will take three instructions to fetch the
10409 value of a global symbol.
10411 Note that some linkers can create multiple GOTs. If you have such a
10412 linker, you should only need to use @option{-mxgot} when a single object
10413 file accesses more than 64k's worth of GOT entries. Very few do.
10415 These options have no effect unless GCC is generating position
10420 Assume that general-purpose registers are 32 bits wide.
10424 Assume that general-purpose registers are 64 bits wide.
10428 Assume that floating-point registers are 32 bits wide.
10432 Assume that floating-point registers are 64 bits wide.
10435 @opindex mhard-float
10436 Use floating-point coprocessor instructions.
10439 @opindex msoft-float
10440 Do not use floating-point coprocessor instructions. Implement
10441 floating-point calculations using library calls instead.
10443 @item -msingle-float
10444 @opindex msingle-float
10445 Assume that the floating-point coprocessor only supports single-precision
10448 @itemx -mdouble-float
10449 @opindex mdouble-float
10450 Assume that the floating-point coprocessor supports double-precision
10451 operations. This is the default.
10457 Use (do not use) the MIPS DSP ASE. @xref{MIPS DSP Built-in Functions}.
10459 @itemx -mpaired-single
10460 @itemx -mno-paired-single
10461 @opindex mpaired-single
10462 @opindex mno-paired-single
10463 Use (do not use) paired-single floating-point instructions.
10464 @xref{MIPS Paired-Single Support}. This option can only be used
10465 when generating 64-bit code and requires hardware floating-point
10466 support to be enabled.
10471 @opindex mno-mips3d
10472 Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
10473 The option @option{-mips3d} implies @option{-mpaired-single}.
10477 Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
10478 an explanation of the default and the way that the pointer size is
10483 Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
10485 The default size of @code{int}s, @code{long}s and pointers depends on
10486 the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
10487 uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
10488 32-bit @code{long}s. Pointers are the same size as @code{long}s,
10489 or the same size as integer registers, whichever is smaller.
10495 Assume (do not assume) that all symbols have 32-bit values, regardless
10496 of the selected ABI@. This option is useful in combination with
10497 @option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
10498 to generate shorter and faster references to symbolic addresses.
10502 @cindex smaller data references (MIPS)
10503 @cindex gp-relative references (MIPS)
10504 Put global and static items less than or equal to @var{num} bytes into
10505 the small data or bss section instead of the normal data or bss section.
10506 This allows the data to be accessed using a single instruction.
10508 All modules should be compiled with the same @option{-G @var{num}}
10511 @item -membedded-data
10512 @itemx -mno-embedded-data
10513 @opindex membedded-data
10514 @opindex mno-embedded-data
10515 Allocate variables to the read-only data section first if possible, then
10516 next in the small data section if possible, otherwise in data. This gives
10517 slightly slower code than the default, but reduces the amount of RAM required
10518 when executing, and thus may be preferred for some embedded systems.
10520 @item -muninit-const-in-rodata
10521 @itemx -mno-uninit-const-in-rodata
10522 @opindex muninit-const-in-rodata
10523 @opindex mno-uninit-const-in-rodata
10524 Put uninitialized @code{const} variables in the read-only data section.
10525 This option is only meaningful in conjunction with @option{-membedded-data}.
10527 @item -msplit-addresses
10528 @itemx -mno-split-addresses
10529 @opindex msplit-addresses
10530 @opindex mno-split-addresses
10531 Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
10532 relocation operators. This option has been superseded by
10533 @option{-mexplicit-relocs} but is retained for backwards compatibility.
10535 @item -mexplicit-relocs
10536 @itemx -mno-explicit-relocs
10537 @opindex mexplicit-relocs
10538 @opindex mno-explicit-relocs
10539 Use (do not use) assembler relocation operators when dealing with symbolic
10540 addresses. The alternative, selected by @option{-mno-explicit-relocs},
10541 is to use assembler macros instead.
10543 @option{-mexplicit-relocs} is the default if GCC was configured
10544 to use an assembler that supports relocation operators.
10546 @item -mcheck-zero-division
10547 @itemx -mno-check-zero-division
10548 @opindex mcheck-zero-division
10549 @opindex mno-check-zero-division
10550 Trap (do not trap) on integer division by zero. The default is
10551 @option{-mcheck-zero-division}.
10553 @item -mdivide-traps
10554 @itemx -mdivide-breaks
10555 @opindex mdivide-traps
10556 @opindex mdivide-breaks
10557 MIPS systems check for division by zero by generating either a
10558 conditional trap or a break instruction. Using traps results in
10559 smaller code, but is only supported on MIPS II and later. Also, some
10560 versions of the Linux kernel have a bug that prevents trap from
10561 generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
10562 allow conditional traps on architectures that support them and
10563 @option{-mdivide-breaks} to force the use of breaks.
10565 The default is usually @option{-mdivide-traps}, but this can be
10566 overridden at configure time using @option{--with-divide=breaks}.
10567 Divide-by-zero checks can be completely disabled using
10568 @option{-mno-check-zero-division}.
10573 @opindex mno-memcpy
10574 Force (do not force) the use of @code{memcpy()} for non-trivial block
10575 moves. The default is @option{-mno-memcpy}, which allows GCC to inline
10576 most constant-sized copies.
10579 @itemx -mno-long-calls
10580 @opindex mlong-calls
10581 @opindex mno-long-calls
10582 Disable (do not disable) use of the @code{jal} instruction. Calling
10583 functions using @code{jal} is more efficient but requires the caller
10584 and callee to be in the same 256 megabyte segment.
10586 This option has no effect on abicalls code. The default is
10587 @option{-mno-long-calls}.
10593 Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
10594 instructions, as provided by the R4650 ISA@.
10597 @itemx -mno-fused-madd
10598 @opindex mfused-madd
10599 @opindex mno-fused-madd
10600 Enable (disable) use of the floating point multiply-accumulate
10601 instructions, when they are available. The default is
10602 @option{-mfused-madd}.
10604 When multiply-accumulate instructions are used, the intermediate
10605 product is calculated to infinite precision and is not subject to
10606 the FCSR Flush to Zero bit. This may be undesirable in some
10611 Tell the MIPS assembler to not run its preprocessor over user
10612 assembler files (with a @samp{.s} suffix) when assembling them.
10615 @itemx -mno-fix-r4000
10616 @opindex mfix-r4000
10617 @opindex mno-fix-r4000
10618 Work around certain R4000 CPU errata:
10621 A double-word or a variable shift may give an incorrect result if executed
10622 immediately after starting an integer division.
10624 A double-word or a variable shift may give an incorrect result if executed
10625 while an integer multiplication is in progress.
10627 An integer division may give an incorrect result if started in a delay slot
10628 of a taken branch or a jump.
10632 @itemx -mno-fix-r4400
10633 @opindex mfix-r4400
10634 @opindex mno-fix-r4400
10635 Work around certain R4400 CPU errata:
10638 A double-word or a variable shift may give an incorrect result if executed
10639 immediately after starting an integer division.
10643 @itemx -mno-fix-vr4120
10644 @opindex mfix-vr4120
10645 Work around certain VR4120 errata:
10648 @code{dmultu} does not always produce the correct result.
10650 @code{div} and @code{ddiv} do not always produce the correct result if one
10651 of the operands is negative.
10653 The workarounds for the division errata rely on special functions in
10654 @file{libgcc.a}. At present, these functions are only provided by
10655 the @code{mips64vr*-elf} configurations.
10657 Other VR4120 errata require a nop to be inserted between certain pairs of
10658 instructions. These errata are handled by the assembler, not by GCC itself.
10661 @opindex mfix-vr4130
10662 Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
10663 workarounds are implemented by the assembler rather than by GCC,
10664 although GCC will avoid using @code{mflo} and @code{mfhi} if the
10665 VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
10666 instructions are available instead.
10669 @itemx -mno-fix-sb1
10671 Work around certain SB-1 CPU core errata.
10672 (This flag currently works around the SB-1 revision 2
10673 ``F1'' and ``F2'' floating point errata.)
10675 @item -mflush-func=@var{func}
10676 @itemx -mno-flush-func
10677 @opindex mflush-func
10678 Specifies the function to call to flush the I and D caches, or to not
10679 call any such function. If called, the function must take the same
10680 arguments as the common @code{_flush_func()}, that is, the address of the
10681 memory range for which the cache is being flushed, the size of the
10682 memory range, and the number 3 (to flush both caches). The default
10683 depends on the target GCC was configured for, but commonly is either
10684 @samp{_flush_func} or @samp{__cpu_flush}.
10686 @item -mbranch-likely
10687 @itemx -mno-branch-likely
10688 @opindex mbranch-likely
10689 @opindex mno-branch-likely
10690 Enable or disable use of Branch Likely instructions, regardless of the
10691 default for the selected architecture. By default, Branch Likely
10692 instructions may be generated if they are supported by the selected
10693 architecture. An exception is for the MIPS32 and MIPS64 architectures
10694 and processors which implement those architectures; for those, Branch
10695 Likely instructions will not be generated by default because the MIPS32
10696 and MIPS64 architectures specifically deprecate their use.
10698 @item -mfp-exceptions
10699 @itemx -mno-fp-exceptions
10700 @opindex mfp-exceptions
10701 Specifies whether FP exceptions are enabled. This affects how we schedule
10702 FP instructions for some processors. The default is that FP exceptions are
10705 For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
10706 64-bit code, then we can use both FP pipes. Otherwise, we can only use one
10709 @item -mvr4130-align
10710 @itemx -mno-vr4130-align
10711 @opindex mvr4130-align
10712 The VR4130 pipeline is two-way superscalar, but can only issue two
10713 instructions together if the first one is 8-byte aligned. When this
10714 option is enabled, GCC will align pairs of instructions that it
10715 thinks should execute in parallel.
10717 This option only has an effect when optimizing for the VR4130.
10718 It normally makes code faster, but at the expense of making it bigger.
10719 It is enabled by default at optimization level @option{-O3}.
10723 @subsection MMIX Options
10724 @cindex MMIX Options
10726 These options are defined for the MMIX:
10730 @itemx -mno-libfuncs
10732 @opindex mno-libfuncs
10733 Specify that intrinsic library functions are being compiled, passing all
10734 values in registers, no matter the size.
10737 @itemx -mno-epsilon
10739 @opindex mno-epsilon
10740 Generate floating-point comparison instructions that compare with respect
10741 to the @code{rE} epsilon register.
10743 @item -mabi=mmixware
10745 @opindex mabi-mmixware
10747 Generate code that passes function parameters and return values that (in
10748 the called function) are seen as registers @code{$0} and up, as opposed to
10749 the GNU ABI which uses global registers @code{$231} and up.
10751 @item -mzero-extend
10752 @itemx -mno-zero-extend
10753 @opindex mzero-extend
10754 @opindex mno-zero-extend
10755 When reading data from memory in sizes shorter than 64 bits, use (do not
10756 use) zero-extending load instructions by default, rather than
10757 sign-extending ones.
10760 @itemx -mno-knuthdiv
10762 @opindex mno-knuthdiv
10763 Make the result of a division yielding a remainder have the same sign as
10764 the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
10765 remainder follows the sign of the dividend. Both methods are
10766 arithmetically valid, the latter being almost exclusively used.
10768 @item -mtoplevel-symbols
10769 @itemx -mno-toplevel-symbols
10770 @opindex mtoplevel-symbols
10771 @opindex mno-toplevel-symbols
10772 Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
10773 code can be used with the @code{PREFIX} assembly directive.
10777 Generate an executable in the ELF format, rather than the default
10778 @samp{mmo} format used by the @command{mmix} simulator.
10780 @item -mbranch-predict
10781 @itemx -mno-branch-predict
10782 @opindex mbranch-predict
10783 @opindex mno-branch-predict
10784 Use (do not use) the probable-branch instructions, when static branch
10785 prediction indicates a probable branch.
10787 @item -mbase-addresses
10788 @itemx -mno-base-addresses
10789 @opindex mbase-addresses
10790 @opindex mno-base-addresses
10791 Generate (do not generate) code that uses @emph{base addresses}. Using a
10792 base address automatically generates a request (handled by the assembler
10793 and the linker) for a constant to be set up in a global register. The
10794 register is used for one or more base address requests within the range 0
10795 to 255 from the value held in the register. The generally leads to short
10796 and fast code, but the number of different data items that can be
10797 addressed is limited. This means that a program that uses lots of static
10798 data may require @option{-mno-base-addresses}.
10800 @item -msingle-exit
10801 @itemx -mno-single-exit
10802 @opindex msingle-exit
10803 @opindex mno-single-exit
10804 Force (do not force) generated code to have a single exit point in each
10808 @node MN10300 Options
10809 @subsection MN10300 Options
10810 @cindex MN10300 options
10812 These @option{-m} options are defined for Matsushita MN10300 architectures:
10817 Generate code to avoid bugs in the multiply instructions for the MN10300
10818 processors. This is the default.
10820 @item -mno-mult-bug
10821 @opindex mno-mult-bug
10822 Do not generate code to avoid bugs in the multiply instructions for the
10823 MN10300 processors.
10827 Generate code which uses features specific to the AM33 processor.
10831 Do not generate code which uses features specific to the AM33 processor. This
10834 @item -mreturn-pointer-on-d0
10835 @opindex mreturn-pointer-on-d0
10836 When generating a function which returns a pointer, return the pointer
10837 in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
10838 only in a0, and attempts to call such functions without a prototype
10839 would result in errors. Note that this option is on by default; use
10840 @option{-mno-return-pointer-on-d0} to disable it.
10844 Do not link in the C run-time initialization object file.
10848 Indicate to the linker that it should perform a relaxation optimization pass
10849 to shorten branches, calls and absolute memory addresses. This option only
10850 has an effect when used on the command line for the final link step.
10852 This option makes symbolic debugging impossible.
10856 @subsection MT Options
10859 These @option{-m} options are defined for Morpho MT architectures:
10863 @item -march=@var{cpu-type}
10865 Generate code that will run on @var{cpu-type}, which is the name of a system
10866 representing a certain processor type. Possible values for
10867 @var{cpu-type} are @samp{ms1-64-001}, @samp{ms1-16-002},
10868 @samp{ms1-16-003} and @samp{ms2}.
10870 When this option is not used, the default is @option{-march=ms1-16-002}.
10874 Use byte loads and stores when generating code.
10878 Do not use byte loads and stores when generating code.
10882 Use simulator runtime
10886 Do not link in the C run-time initialization object file
10887 @file{crti.o}. Other run-time initialization and termination files
10888 such as @file{startup.o} and @file{exit.o} are still included on the
10889 linker command line.
10893 @node PDP-11 Options
10894 @subsection PDP-11 Options
10895 @cindex PDP-11 Options
10897 These options are defined for the PDP-11:
10902 Use hardware FPP floating point. This is the default. (FIS floating
10903 point on the PDP-11/40 is not supported.)
10906 @opindex msoft-float
10907 Do not use hardware floating point.
10911 Return floating-point results in ac0 (fr0 in Unix assembler syntax).
10915 Return floating-point results in memory. This is the default.
10919 Generate code for a PDP-11/40.
10923 Generate code for a PDP-11/45. This is the default.
10927 Generate code for a PDP-11/10.
10929 @item -mbcopy-builtin
10930 @opindex bcopy-builtin
10931 Use inline @code{movmemhi} patterns for copying memory. This is the
10936 Do not use inline @code{movmemhi} patterns for copying memory.
10942 Use 16-bit @code{int}. This is the default.
10948 Use 32-bit @code{int}.
10951 @itemx -mno-float32
10953 @opindex mno-float32
10954 Use 64-bit @code{float}. This is the default.
10957 @itemx -mno-float64
10959 @opindex mno-float64
10960 Use 32-bit @code{float}.
10964 Use @code{abshi2} pattern. This is the default.
10968 Do not use @code{abshi2} pattern.
10970 @item -mbranch-expensive
10971 @opindex mbranch-expensive
10972 Pretend that branches are expensive. This is for experimenting with
10973 code generation only.
10975 @item -mbranch-cheap
10976 @opindex mbranch-cheap
10977 Do not pretend that branches are expensive. This is the default.
10981 Generate code for a system with split I&D@.
10985 Generate code for a system without split I&D@. This is the default.
10989 Use Unix assembler syntax. This is the default when configured for
10990 @samp{pdp11-*-bsd}.
10994 Use DEC assembler syntax. This is the default when configured for any
10995 PDP-11 target other than @samp{pdp11-*-bsd}.
10998 @node PowerPC Options
10999 @subsection PowerPC Options
11000 @cindex PowerPC options
11002 These are listed under @xref{RS/6000 and PowerPC Options}.
11004 @node RS/6000 and PowerPC Options
11005 @subsection IBM RS/6000 and PowerPC Options
11006 @cindex RS/6000 and PowerPC Options
11007 @cindex IBM RS/6000 and PowerPC Options
11009 These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
11016 @itemx -mno-powerpc
11017 @itemx -mpowerpc-gpopt
11018 @itemx -mno-powerpc-gpopt
11019 @itemx -mpowerpc-gfxopt
11020 @itemx -mno-powerpc-gfxopt
11022 @itemx -mno-powerpc64
11026 @itemx -mno-popcntb
11032 @opindex mno-power2
11034 @opindex mno-powerpc
11035 @opindex mpowerpc-gpopt
11036 @opindex mno-powerpc-gpopt
11037 @opindex mpowerpc-gfxopt
11038 @opindex mno-powerpc-gfxopt
11039 @opindex mpowerpc64
11040 @opindex mno-powerpc64
11044 @opindex mno-popcntb
11047 GCC supports two related instruction set architectures for the
11048 RS/6000 and PowerPC@. The @dfn{POWER} instruction set are those
11049 instructions supported by the @samp{rios} chip set used in the original
11050 RS/6000 systems and the @dfn{PowerPC} instruction set is the
11051 architecture of the Freescale MPC5xx, MPC6xx, MPC8xx microprocessors, and
11052 the IBM 4xx, 6xx, and follow-on microprocessors.
11054 Neither architecture is a subset of the other. However there is a
11055 large common subset of instructions supported by both. An MQ
11056 register is included in processors supporting the POWER architecture.
11058 You use these options to specify which instructions are available on the
11059 processor you are using. The default value of these options is
11060 determined when configuring GCC@. Specifying the
11061 @option{-mcpu=@var{cpu_type}} overrides the specification of these
11062 options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
11063 rather than the options listed above.
11065 The @option{-mpower} option allows GCC to generate instructions that
11066 are found only in the POWER architecture and to use the MQ register.
11067 Specifying @option{-mpower2} implies @option{-power} and also allows GCC
11068 to generate instructions that are present in the POWER2 architecture but
11069 not the original POWER architecture.
11071 The @option{-mpowerpc} option allows GCC to generate instructions that
11072 are found only in the 32-bit subset of the PowerPC architecture.
11073 Specifying @option{-mpowerpc-gpopt} implies @option{-mpowerpc} and also allows
11074 GCC to use the optional PowerPC architecture instructions in the
11075 General Purpose group, including floating-point square root. Specifying
11076 @option{-mpowerpc-gfxopt} implies @option{-mpowerpc} and also allows GCC to
11077 use the optional PowerPC architecture instructions in the Graphics
11078 group, including floating-point select.
11080 The @option{-mmfcrf} option allows GCC to generate the move from
11081 condition register field instruction implemented on the POWER4
11082 processor and other processors that support the PowerPC V2.01
11084 The @option{-mpopcntb} option allows GCC to generate the popcount and
11085 double precision FP reciprocal estimate instruction implemented on the
11086 POWER5 processor and other processors that support the PowerPC V2.02
11088 The @option{-mfprnd} option allows GCC to generate the FP round to
11089 integer instructions implemented on the POWER5+ processor and other
11090 processors that support the PowerPC V2.03 architecture.
11092 The @option{-mpowerpc64} option allows GCC to generate the additional
11093 64-bit instructions that are found in the full PowerPC64 architecture
11094 and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
11095 @option{-mno-powerpc64}.
11097 If you specify both @option{-mno-power} and @option{-mno-powerpc}, GCC
11098 will use only the instructions in the common subset of both
11099 architectures plus some special AIX common-mode calls, and will not use
11100 the MQ register. Specifying both @option{-mpower} and @option{-mpowerpc}
11101 permits GCC to use any instruction from either architecture and to
11102 allow use of the MQ register; specify this for the Motorola MPC601.
11104 @item -mnew-mnemonics
11105 @itemx -mold-mnemonics
11106 @opindex mnew-mnemonics
11107 @opindex mold-mnemonics
11108 Select which mnemonics to use in the generated assembler code. With
11109 @option{-mnew-mnemonics}, GCC uses the assembler mnemonics defined for
11110 the PowerPC architecture. With @option{-mold-mnemonics} it uses the
11111 assembler mnemonics defined for the POWER architecture. Instructions
11112 defined in only one architecture have only one mnemonic; GCC uses that
11113 mnemonic irrespective of which of these options is specified.
11115 GCC defaults to the mnemonics appropriate for the architecture in
11116 use. Specifying @option{-mcpu=@var{cpu_type}} sometimes overrides the
11117 value of these option. Unless you are building a cross-compiler, you
11118 should normally not specify either @option{-mnew-mnemonics} or
11119 @option{-mold-mnemonics}, but should instead accept the default.
11121 @item -mcpu=@var{cpu_type}
11123 Set architecture type, register usage, choice of mnemonics, and
11124 instruction scheduling parameters for machine type @var{cpu_type}.
11125 Supported values for @var{cpu_type} are @samp{401}, @samp{403},
11126 @samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{505},
11127 @samp{601}, @samp{602}, @samp{603}, @samp{603e}, @samp{604},
11128 @samp{604e}, @samp{620}, @samp{630}, @samp{740}, @samp{7400},
11129 @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
11130 @samp{860}, @samp{970}, @samp{8540}, @samp{ec603e}, @samp{G3},
11131 @samp{G4}, @samp{G5}, @samp{power}, @samp{power2}, @samp{power3},
11132 @samp{power4}, @samp{power5}, @samp{power5+}, @samp{power6},
11133 @samp{common}, @samp{powerpc}, @samp{powerpc64},
11134 @samp{rios}, @samp{rios1}, @samp{rios2}, @samp{rsc}, and @samp{rs64}.
11136 @option{-mcpu=common} selects a completely generic processor. Code
11137 generated under this option will run on any POWER or PowerPC processor.
11138 GCC will use only the instructions in the common subset of both
11139 architectures, and will not use the MQ register. GCC assumes a generic
11140 processor model for scheduling purposes.
11142 @option{-mcpu=power}, @option{-mcpu=power2}, @option{-mcpu=powerpc}, and
11143 @option{-mcpu=powerpc64} specify generic POWER, POWER2, pure 32-bit
11144 PowerPC (i.e., not MPC601), and 64-bit PowerPC architecture machine
11145 types, with an appropriate, generic processor model assumed for
11146 scheduling purposes.
11148 The other options specify a specific processor. Code generated under
11149 those options will run best on that processor, and may not run at all on
11152 The @option{-mcpu} options automatically enable or disable the
11153 following options: @option{-maltivec}, @option{-mfprnd},
11154 @option{-mhard-float}, @option{-mmfcrf}, @option{-mmultiple},
11155 @option{-mnew-mnemonics}, @option{-mpopcntb}, @option{-mpower},
11156 @option{-mpower2}, @option{-mpowerpc64}, @option{-mpowerpc-gpopt},
11157 @option{-mpowerpc-gfxopt}, @option{-mstring}, @option{-mmulhw}, @option{-mdlmzb}.
11158 The particular options
11159 set for any particular CPU will vary between compiler versions,
11160 depending on what setting seems to produce optimal code for that CPU;
11161 it doesn't necessarily reflect the actual hardware's capabilities. If
11162 you wish to set an individual option to a particular value, you may
11163 specify it after the @option{-mcpu} option, like @samp{-mcpu=970
11166 On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
11167 not enabled or disabled by the @option{-mcpu} option at present because
11168 AIX does not have full support for these options. You may still
11169 enable or disable them individually if you're sure it'll work in your
11172 @item -mtune=@var{cpu_type}
11174 Set the instruction scheduling parameters for machine type
11175 @var{cpu_type}, but do not set the architecture type, register usage, or
11176 choice of mnemonics, as @option{-mcpu=@var{cpu_type}} would. The same
11177 values for @var{cpu_type} are used for @option{-mtune} as for
11178 @option{-mcpu}. If both are specified, the code generated will use the
11179 architecture, registers, and mnemonics set by @option{-mcpu}, but the
11180 scheduling parameters set by @option{-mtune}.
11186 Generate code to compute division as reciprocal estimate and iterative
11187 refinement, creating opportunities for increased throughput. This
11188 feature requires: optional PowerPC Graphics instruction set for single
11189 precision and FRE instruction for double precision, assuming divides
11190 cannot generate user-visible traps, and the domain values not include
11191 Infinities, denormals or zero denominator.
11194 @itemx -mno-altivec
11196 @opindex mno-altivec
11197 Generate code that uses (does not use) AltiVec instructions, and also
11198 enable the use of built-in functions that allow more direct access to
11199 the AltiVec instruction set. You may also need to set
11200 @option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
11206 @opindex mno-vrsave
11207 Generate VRSAVE instructions when generating AltiVec code.
11210 @opindex msecure-plt
11211 Generate code that allows ld and ld.so to build executables and shared
11212 libraries with non-exec .plt and .got sections. This is a PowerPC
11213 32-bit SYSV ABI option.
11217 Generate code that uses a BSS .plt section that ld.so fills in, and
11218 requires .plt and .got sections that are both writable and executable.
11219 This is a PowerPC 32-bit SYSV ABI option.
11225 This switch enables or disables the generation of ISEL instructions.
11227 @item -misel=@var{yes/no}
11228 This switch has been deprecated. Use @option{-misel} and
11229 @option{-mno-isel} instead.
11235 This switch enables or disables the generation of SPE simd
11238 @item -mspe=@var{yes/no}
11239 This option has been deprecated. Use @option{-mspe} and
11240 @option{-mno-spe} instead.
11242 @item -mfloat-gprs=@var{yes/single/double/no}
11243 @itemx -mfloat-gprs
11244 @opindex mfloat-gprs
11245 This switch enables or disables the generation of floating point
11246 operations on the general purpose registers for architectures that
11249 The argument @var{yes} or @var{single} enables the use of
11250 single-precision floating point operations.
11252 The argument @var{double} enables the use of single and
11253 double-precision floating point operations.
11255 The argument @var{no} disables floating point operations on the
11256 general purpose registers.
11258 This option is currently only available on the MPC854x.
11264 Generate code for 32-bit or 64-bit environments of Darwin and SVR4
11265 targets (including GNU/Linux). The 32-bit environment sets int, long
11266 and pointer to 32 bits and generates code that runs on any PowerPC
11267 variant. The 64-bit environment sets int to 32 bits and long and
11268 pointer to 64 bits, and generates code for PowerPC64, as for
11269 @option{-mpowerpc64}.
11272 @itemx -mno-fp-in-toc
11273 @itemx -mno-sum-in-toc
11274 @itemx -mminimal-toc
11276 @opindex mno-fp-in-toc
11277 @opindex mno-sum-in-toc
11278 @opindex mminimal-toc
11279 Modify generation of the TOC (Table Of Contents), which is created for
11280 every executable file. The @option{-mfull-toc} option is selected by
11281 default. In that case, GCC will allocate at least one TOC entry for
11282 each unique non-automatic variable reference in your program. GCC
11283 will also place floating-point constants in the TOC@. However, only
11284 16,384 entries are available in the TOC@.
11286 If you receive a linker error message that saying you have overflowed
11287 the available TOC space, you can reduce the amount of TOC space used
11288 with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
11289 @option{-mno-fp-in-toc} prevents GCC from putting floating-point
11290 constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
11291 generate code to calculate the sum of an address and a constant at
11292 run-time instead of putting that sum into the TOC@. You may specify one
11293 or both of these options. Each causes GCC to produce very slightly
11294 slower and larger code at the expense of conserving TOC space.
11296 If you still run out of space in the TOC even when you specify both of
11297 these options, specify @option{-mminimal-toc} instead. This option causes
11298 GCC to make only one TOC entry for every file. When you specify this
11299 option, GCC will produce code that is slower and larger but which
11300 uses extremely little TOC space. You may wish to use this option
11301 only on files that contain less frequently executed code.
11307 Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
11308 @code{long} type, and the infrastructure needed to support them.
11309 Specifying @option{-maix64} implies @option{-mpowerpc64} and
11310 @option{-mpowerpc}, while @option{-maix32} disables the 64-bit ABI and
11311 implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
11314 @itemx -mno-xl-compat
11315 @opindex mxl-compat
11316 @opindex mno-xl-compat
11317 Produce code that conforms more closely to IBM XL compiler semantics
11318 when using AIX-compatible ABI. Pass floating-point arguments to
11319 prototyped functions beyond the register save area (RSA) on the stack
11320 in addition to argument FPRs. Do not assume that most significant
11321 double in 128-bit long double value is properly rounded when comparing
11322 values and converting to double. Use XL symbol names for long double
11325 The AIX calling convention was extended but not initially documented to
11326 handle an obscure K&R C case of calling a function that takes the
11327 address of its arguments with fewer arguments than declared. IBM XL
11328 compilers access floating point arguments which do not fit in the
11329 RSA from the stack when a subroutine is compiled without
11330 optimization. Because always storing floating-point arguments on the
11331 stack is inefficient and rarely needed, this option is not enabled by
11332 default and only is necessary when calling subroutines compiled by IBM
11333 XL compilers without optimization.
11337 Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
11338 application written to use message passing with special startup code to
11339 enable the application to run. The system must have PE installed in the
11340 standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
11341 must be overridden with the @option{-specs=} option to specify the
11342 appropriate directory location. The Parallel Environment does not
11343 support threads, so the @option{-mpe} option and the @option{-pthread}
11344 option are incompatible.
11346 @item -malign-natural
11347 @itemx -malign-power
11348 @opindex malign-natural
11349 @opindex malign-power
11350 On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
11351 @option{-malign-natural} overrides the ABI-defined alignment of larger
11352 types, such as floating-point doubles, on their natural size-based boundary.
11353 The option @option{-malign-power} instructs GCC to follow the ABI-specified
11354 alignment rules. GCC defaults to the standard alignment defined in the ABI@.
11356 On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
11360 @itemx -mhard-float
11361 @opindex msoft-float
11362 @opindex mhard-float
11363 Generate code that does not use (uses) the floating-point register set.
11364 Software floating point emulation is provided if you use the
11365 @option{-msoft-float} option, and pass the option to GCC when linking.
11368 @itemx -mno-multiple
11370 @opindex mno-multiple
11371 Generate code that uses (does not use) the load multiple word
11372 instructions and the store multiple word instructions. These
11373 instructions are generated by default on POWER systems, and not
11374 generated on PowerPC systems. Do not use @option{-mmultiple} on little
11375 endian PowerPC systems, since those instructions do not work when the
11376 processor is in little endian mode. The exceptions are PPC740 and
11377 PPC750 which permit the instructions usage in little endian mode.
11382 @opindex mno-string
11383 Generate code that uses (does not use) the load string instructions
11384 and the store string word instructions to save multiple registers and
11385 do small block moves. These instructions are generated by default on
11386 POWER systems, and not generated on PowerPC systems. Do not use
11387 @option{-mstring} on little endian PowerPC systems, since those
11388 instructions do not work when the processor is in little endian mode.
11389 The exceptions are PPC740 and PPC750 which permit the instructions
11390 usage in little endian mode.
11395 @opindex mno-update
11396 Generate code that uses (does not use) the load or store instructions
11397 that update the base register to the address of the calculated memory
11398 location. These instructions are generated by default. If you use
11399 @option{-mno-update}, there is a small window between the time that the
11400 stack pointer is updated and the address of the previous frame is
11401 stored, which means code that walks the stack frame across interrupts or
11402 signals may get corrupted data.
11405 @itemx -mno-fused-madd
11406 @opindex mfused-madd
11407 @opindex mno-fused-madd
11408 Generate code that uses (does not use) the floating point multiply and
11409 accumulate instructions. These instructions are generated by default if
11410 hardware floating is used.
11416 Generate code that uses (does not use) the half-word multiply and
11417 multiply-accumulate instructions on the IBM 405 and 440 processors.
11418 These instructions are generated by default when targetting those
11425 Generate code that uses (does not use) the string-search @samp{dlmzb}
11426 instruction on the IBM 405 and 440 processors. This instruction is
11427 generated by default when targetting those processors.
11429 @item -mno-bit-align
11431 @opindex mno-bit-align
11432 @opindex mbit-align
11433 On System V.4 and embedded PowerPC systems do not (do) force structures
11434 and unions that contain bit-fields to be aligned to the base type of the
11437 For example, by default a structure containing nothing but 8
11438 @code{unsigned} bit-fields of length 1 would be aligned to a 4 byte
11439 boundary and have a size of 4 bytes. By using @option{-mno-bit-align},
11440 the structure would be aligned to a 1 byte boundary and be one byte in
11443 @item -mno-strict-align
11444 @itemx -mstrict-align
11445 @opindex mno-strict-align
11446 @opindex mstrict-align
11447 On System V.4 and embedded PowerPC systems do not (do) assume that
11448 unaligned memory references will be handled by the system.
11450 @item -mrelocatable
11451 @itemx -mno-relocatable
11452 @opindex mrelocatable
11453 @opindex mno-relocatable
11454 On embedded PowerPC systems generate code that allows (does not allow)
11455 the program to be relocated to a different address at runtime. If you
11456 use @option{-mrelocatable} on any module, all objects linked together must
11457 be compiled with @option{-mrelocatable} or @option{-mrelocatable-lib}.
11459 @item -mrelocatable-lib
11460 @itemx -mno-relocatable-lib
11461 @opindex mrelocatable-lib
11462 @opindex mno-relocatable-lib
11463 On embedded PowerPC systems generate code that allows (does not allow)
11464 the program to be relocated to a different address at runtime. Modules
11465 compiled with @option{-mrelocatable-lib} can be linked with either modules
11466 compiled without @option{-mrelocatable} and @option{-mrelocatable-lib} or
11467 with modules compiled with the @option{-mrelocatable} options.
11473 On System V.4 and embedded PowerPC systems do not (do) assume that
11474 register 2 contains a pointer to a global area pointing to the addresses
11475 used in the program.
11478 @itemx -mlittle-endian
11480 @opindex mlittle-endian
11481 On System V.4 and embedded PowerPC systems compile code for the
11482 processor in little endian mode. The @option{-mlittle-endian} option is
11483 the same as @option{-mlittle}.
11486 @itemx -mbig-endian
11488 @opindex mbig-endian
11489 On System V.4 and embedded PowerPC systems compile code for the
11490 processor in big endian mode. The @option{-mbig-endian} option is
11491 the same as @option{-mbig}.
11493 @item -mdynamic-no-pic
11494 @opindex mdynamic-no-pic
11495 On Darwin and Mac OS X systems, compile code so that it is not
11496 relocatable, but that its external references are relocatable. The
11497 resulting code is suitable for applications, but not shared
11500 @item -mprioritize-restricted-insns=@var{priority}
11501 @opindex mprioritize-restricted-insns
11502 This option controls the priority that is assigned to
11503 dispatch-slot restricted instructions during the second scheduling
11504 pass. The argument @var{priority} takes the value @var{0/1/2} to assign
11505 @var{no/highest/second-highest} priority to dispatch slot restricted
11508 @item -msched-costly-dep=@var{dependence_type}
11509 @opindex msched-costly-dep
11510 This option controls which dependences are considered costly
11511 by the target during instruction scheduling. The argument
11512 @var{dependence_type} takes one of the following values:
11513 @var{no}: no dependence is costly,
11514 @var{all}: all dependences are costly,
11515 @var{true_store_to_load}: a true dependence from store to load is costly,
11516 @var{store_to_load}: any dependence from store to load is costly,
11517 @var{number}: any dependence which latency >= @var{number} is costly.
11519 @item -minsert-sched-nops=@var{scheme}
11520 @opindex minsert-sched-nops
11521 This option controls which nop insertion scheme will be used during
11522 the second scheduling pass. The argument @var{scheme} takes one of the
11524 @var{no}: Don't insert nops.
11525 @var{pad}: Pad with nops any dispatch group which has vacant issue slots,
11526 according to the scheduler's grouping.
11527 @var{regroup_exact}: Insert nops to force costly dependent insns into
11528 separate groups. Insert exactly as many nops as needed to force an insn
11529 to a new group, according to the estimated processor grouping.
11530 @var{number}: Insert nops to force costly dependent insns into
11531 separate groups. Insert @var{number} nops to force an insn to a new group.
11534 @opindex mcall-sysv
11535 On System V.4 and embedded PowerPC systems compile code using calling
11536 conventions that adheres to the March 1995 draft of the System V
11537 Application Binary Interface, PowerPC processor supplement. This is the
11538 default unless you configured GCC using @samp{powerpc-*-eabiaix}.
11540 @item -mcall-sysv-eabi
11541 @opindex mcall-sysv-eabi
11542 Specify both @option{-mcall-sysv} and @option{-meabi} options.
11544 @item -mcall-sysv-noeabi
11545 @opindex mcall-sysv-noeabi
11546 Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
11548 @item -mcall-solaris
11549 @opindex mcall-solaris
11550 On System V.4 and embedded PowerPC systems compile code for the Solaris
11554 @opindex mcall-linux
11555 On System V.4 and embedded PowerPC systems compile code for the
11556 Linux-based GNU system.
11560 On System V.4 and embedded PowerPC systems compile code for the
11561 Hurd-based GNU system.
11563 @item -mcall-netbsd
11564 @opindex mcall-netbsd
11565 On System V.4 and embedded PowerPC systems compile code for the
11566 NetBSD operating system.
11568 @item -maix-struct-return
11569 @opindex maix-struct-return
11570 Return all structures in memory (as specified by the AIX ABI)@.
11572 @item -msvr4-struct-return
11573 @opindex msvr4-struct-return
11574 Return structures smaller than 8 bytes in registers (as specified by the
11577 @item -mabi=@var{abi-type}
11579 Extend the current ABI with a particular extension, or remove such extension.
11580 Valid values are @var{altivec}, @var{no-altivec}, @var{spe},
11581 @var{no-spe}, @var{ibmlongdouble}, @var{ieeelongdouble}@.
11585 Extend the current ABI with SPE ABI extensions. This does not change
11586 the default ABI, instead it adds the SPE ABI extensions to the current
11590 @opindex mabi=no-spe
11591 Disable Booke SPE ABI extensions for the current ABI@.
11593 @item -mabi=ibmlongdouble
11594 @opindex mabi=ibmlongdouble
11595 Change the current ABI to use IBM extended precision long double.
11596 This is a PowerPC 32-bit SYSV ABI option.
11598 @item -mabi=ieeelongdouble
11599 @opindex mabi=ieeelongdouble
11600 Change the current ABI to use IEEE extended precision long double.
11601 This is a PowerPC 32-bit Linux ABI option.
11604 @itemx -mno-prototype
11605 @opindex mprototype
11606 @opindex mno-prototype
11607 On System V.4 and embedded PowerPC systems assume that all calls to
11608 variable argument functions are properly prototyped. Otherwise, the
11609 compiler must insert an instruction before every non prototyped call to
11610 set or clear bit 6 of the condition code register (@var{CR}) to
11611 indicate whether floating point values were passed in the floating point
11612 registers in case the function takes a variable arguments. With
11613 @option{-mprototype}, only calls to prototyped variable argument functions
11614 will set or clear the bit.
11618 On embedded PowerPC systems, assume that the startup module is called
11619 @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
11620 @file{libc.a}. This is the default for @samp{powerpc-*-eabisim}.
11625 On embedded PowerPC systems, assume that the startup module is called
11626 @file{crt0.o} and the standard C libraries are @file{libmvme.a} and
11631 On embedded PowerPC systems, assume that the startup module is called
11632 @file{crt0.o} and the standard C libraries are @file{libads.a} and
11635 @item -myellowknife
11636 @opindex myellowknife
11637 On embedded PowerPC systems, assume that the startup module is called
11638 @file{crt0.o} and the standard C libraries are @file{libyk.a} and
11643 On System V.4 and embedded PowerPC systems, specify that you are
11644 compiling for a VxWorks system.
11648 Specify that you are compiling for the WindISS simulation environment.
11652 On embedded PowerPC systems, set the @var{PPC_EMB} bit in the ELF flags
11653 header to indicate that @samp{eabi} extended relocations are used.
11659 On System V.4 and embedded PowerPC systems do (do not) adhere to the
11660 Embedded Applications Binary Interface (eabi) which is a set of
11661 modifications to the System V.4 specifications. Selecting @option{-meabi}
11662 means that the stack is aligned to an 8 byte boundary, a function
11663 @code{__eabi} is called to from @code{main} to set up the eabi
11664 environment, and the @option{-msdata} option can use both @code{r2} and
11665 @code{r13} to point to two separate small data areas. Selecting
11666 @option{-mno-eabi} means that the stack is aligned to a 16 byte boundary,
11667 do not call an initialization function from @code{main}, and the
11668 @option{-msdata} option will only use @code{r13} to point to a single
11669 small data area. The @option{-meabi} option is on by default if you
11670 configured GCC using one of the @samp{powerpc*-*-eabi*} options.
11673 @opindex msdata=eabi
11674 On System V.4 and embedded PowerPC systems, put small initialized
11675 @code{const} global and static data in the @samp{.sdata2} section, which
11676 is pointed to by register @code{r2}. Put small initialized
11677 non-@code{const} global and static data in the @samp{.sdata} section,
11678 which is pointed to by register @code{r13}. Put small uninitialized
11679 global and static data in the @samp{.sbss} section, which is adjacent to
11680 the @samp{.sdata} section. The @option{-msdata=eabi} option is
11681 incompatible with the @option{-mrelocatable} option. The
11682 @option{-msdata=eabi} option also sets the @option{-memb} option.
11685 @opindex msdata=sysv
11686 On System V.4 and embedded PowerPC systems, put small global and static
11687 data in the @samp{.sdata} section, which is pointed to by register
11688 @code{r13}. Put small uninitialized global and static data in the
11689 @samp{.sbss} section, which is adjacent to the @samp{.sdata} section.
11690 The @option{-msdata=sysv} option is incompatible with the
11691 @option{-mrelocatable} option.
11693 @item -msdata=default
11695 @opindex msdata=default
11697 On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
11698 compile code the same as @option{-msdata=eabi}, otherwise compile code the
11699 same as @option{-msdata=sysv}.
11702 @opindex msdata-data
11703 On System V.4 and embedded PowerPC systems, put small global
11704 data in the @samp{.sdata} section. Put small uninitialized global
11705 data in the @samp{.sbss} section. Do not use register @code{r13}
11706 to address small data however. This is the default behavior unless
11707 other @option{-msdata} options are used.
11711 @opindex msdata=none
11713 On embedded PowerPC systems, put all initialized global and static data
11714 in the @samp{.data} section, and all uninitialized data in the
11715 @samp{.bss} section.
11719 @cindex smaller data references (PowerPC)
11720 @cindex .sdata/.sdata2 references (PowerPC)
11721 On embedded PowerPC systems, put global and static items less than or
11722 equal to @var{num} bytes into the small data or bss sections instead of
11723 the normal data or bss section. By default, @var{num} is 8. The
11724 @option{-G @var{num}} switch is also passed to the linker.
11725 All modules should be compiled with the same @option{-G @var{num}} value.
11728 @itemx -mno-regnames
11730 @opindex mno-regnames
11731 On System V.4 and embedded PowerPC systems do (do not) emit register
11732 names in the assembly language output using symbolic forms.
11735 @itemx -mno-longcall
11737 @opindex mno-longcall
11738 By default assume that all calls are far away so that a longer more
11739 expensive calling sequence is required. This is required for calls
11740 further than 32 megabytes (33,554,432 bytes) from the current location.
11741 A short call will be generated if the compiler knows
11742 the call cannot be that far away. This setting can be overridden by
11743 the @code{shortcall} function attribute, or by @code{#pragma
11746 Some linkers are capable of detecting out-of-range calls and generating
11747 glue code on the fly. On these systems, long calls are unnecessary and
11748 generate slower code. As of this writing, the AIX linker can do this,
11749 as can the GNU linker for PowerPC/64. It is planned to add this feature
11750 to the GNU linker for 32-bit PowerPC systems as well.
11752 On Darwin/PPC systems, @code{#pragma longcall} will generate ``jbsr
11753 callee, L42'', plus a ``branch island'' (glue code). The two target
11754 addresses represent the callee and the ``branch island''. The
11755 Darwin/PPC linker will prefer the first address and generate a ``bl
11756 callee'' if the PPC ``bl'' instruction will reach the callee directly;
11757 otherwise, the linker will generate ``bl L42'' to call the ``branch
11758 island''. The ``branch island'' is appended to the body of the
11759 calling function; it computes the full 32-bit address of the callee
11762 On Mach-O (Darwin) systems, this option directs the compiler emit to
11763 the glue for every direct call, and the Darwin linker decides whether
11764 to use or discard it.
11766 In the future, we may cause GCC to ignore all longcall specifications
11767 when the linker is known to generate glue.
11771 Adds support for multithreading with the @dfn{pthreads} library.
11772 This option sets flags for both the preprocessor and linker.
11776 @node S/390 and zSeries Options
11777 @subsection S/390 and zSeries Options
11778 @cindex S/390 and zSeries Options
11780 These are the @samp{-m} options defined for the S/390 and zSeries architecture.
11784 @itemx -msoft-float
11785 @opindex mhard-float
11786 @opindex msoft-float
11787 Use (do not use) the hardware floating-point instructions and registers
11788 for floating-point operations. When @option{-msoft-float} is specified,
11789 functions in @file{libgcc.a} will be used to perform floating-point
11790 operations. When @option{-mhard-float} is specified, the compiler
11791 generates IEEE floating-point instructions. This is the default.
11793 @item -mlong-double-64
11794 @itemx -mlong-double-128
11795 @opindex mlong-double-64
11796 @opindex mlong-double-128
11797 These switches control the size of @code{long double} type. A size
11798 of 64bit makes the @code{long double} type equivalent to the @code{double}
11799 type. This is the default.
11802 @itemx -mno-backchain
11803 @opindex mbackchain
11804 @opindex mno-backchain
11805 Store (do not store) the address of the caller's frame as backchain pointer
11806 into the callee's stack frame.
11807 A backchain may be needed to allow debugging using tools that do not understand
11808 DWARF-2 call frame information.
11809 When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
11810 at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
11811 the backchain is placed into the topmost word of the 96/160 byte register
11814 In general, code compiled with @option{-mbackchain} is call-compatible with
11815 code compiled with @option{-mmo-backchain}; however, use of the backchain
11816 for debugging purposes usually requires that the whole binary is built with
11817 @option{-mbackchain}. Note that the combination of @option{-mbackchain},
11818 @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
11819 to build a linux kernel use @option{-msoft-float}.
11821 The default is to not maintain the backchain.
11823 @item -mpacked-stack
11824 @item -mno-packed-stack
11825 @opindex mpacked-stack
11826 @opindex mno-packed-stack
11827 Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
11828 specified, the compiler uses the all fields of the 96/160 byte register save
11829 area only for their default purpose; unused fields still take up stack space.
11830 When @option{-mpacked-stack} is specified, register save slots are densely
11831 packed at the top of the register save area; unused space is reused for other
11832 purposes, allowing for more efficient use of the available stack space.
11833 However, when @option{-mbackchain} is also in effect, the topmost word of
11834 the save area is always used to store the backchain, and the return address
11835 register is always saved two words below the backchain.
11837 As long as the stack frame backchain is not used, code generated with
11838 @option{-mpacked-stack} is call-compatible with code generated with
11839 @option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
11840 S/390 or zSeries generated code that uses the stack frame backchain at run
11841 time, not just for debugging purposes. Such code is not call-compatible
11842 with code compiled with @option{-mpacked-stack}. Also, note that the
11843 combination of @option{-mbackchain},
11844 @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
11845 to build a linux kernel use @option{-msoft-float}.
11847 The default is to not use the packed stack layout.
11850 @itemx -mno-small-exec
11851 @opindex msmall-exec
11852 @opindex mno-small-exec
11853 Generate (or do not generate) code using the @code{bras} instruction
11854 to do subroutine calls.
11855 This only works reliably if the total executable size does not
11856 exceed 64k. The default is to use the @code{basr} instruction instead,
11857 which does not have this limitation.
11863 When @option{-m31} is specified, generate code compliant to the
11864 GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
11865 code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
11866 particular to generate 64-bit instructions. For the @samp{s390}
11867 targets, the default is @option{-m31}, while the @samp{s390x}
11868 targets default to @option{-m64}.
11874 When @option{-mzarch} is specified, generate code using the
11875 instructions available on z/Architecture.
11876 When @option{-mesa} is specified, generate code using the
11877 instructions available on ESA/390. Note that @option{-mesa} is
11878 not possible with @option{-m64}.
11879 When generating code compliant to the GNU/Linux for S/390 ABI,
11880 the default is @option{-mesa}. When generating code compliant
11881 to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
11887 Generate (or do not generate) code using the @code{mvcle} instruction
11888 to perform block moves. When @option{-mno-mvcle} is specified,
11889 use a @code{mvc} loop instead. This is the default unless optimizing for
11896 Print (or do not print) additional debug information when compiling.
11897 The default is to not print debug information.
11899 @item -march=@var{cpu-type}
11901 Generate code that will run on @var{cpu-type}, which is the name of a system
11902 representing a certain processor type. Possible values for
11903 @var{cpu-type} are @samp{g5}, @samp{g6}, @samp{z900}, and @samp{z990}.
11904 When generating code using the instructions available on z/Architecture,
11905 the default is @option{-march=z900}. Otherwise, the default is
11906 @option{-march=g5}.
11908 @item -mtune=@var{cpu-type}
11910 Tune to @var{cpu-type} everything applicable about the generated code,
11911 except for the ABI and the set of available instructions.
11912 The list of @var{cpu-type} values is the same as for @option{-march}.
11913 The default is the value used for @option{-march}.
11916 @itemx -mno-tpf-trace
11917 @opindex mtpf-trace
11918 @opindex mno-tpf-trace
11919 Generate code that adds (does not add) in TPF OS specific branches to trace
11920 routines in the operating system. This option is off by default, even
11921 when compiling for the TPF OS@.
11924 @itemx -mno-fused-madd
11925 @opindex mfused-madd
11926 @opindex mno-fused-madd
11927 Generate code that uses (does not use) the floating point multiply and
11928 accumulate instructions. These instructions are generated by default if
11929 hardware floating point is used.
11931 @item -mwarn-framesize=@var{framesize}
11932 @opindex mwarn-framesize
11933 Emit a warning if the current function exceeds the given frame size. Because
11934 this is a compile time check it doesn't need to be a real problem when the program
11935 runs. It is intended to identify functions which most probably cause
11936 a stack overflow. It is useful to be used in an environment with limited stack
11937 size e.g.@: the linux kernel.
11939 @item -mwarn-dynamicstack
11940 @opindex mwarn-dynamicstack
11941 Emit a warning if the function calls alloca or uses dynamically
11942 sized arrays. This is generally a bad idea with a limited stack size.
11944 @item -mstack-guard=@var{stack-guard}
11945 @item -mstack-size=@var{stack-size}
11946 @opindex mstack-guard
11947 @opindex mstack-size
11948 These arguments always have to be used in conjunction. If they are present the s390
11949 back end emits additional instructions in the function prologue which trigger a trap
11950 if the stack size is @var{stack-guard} bytes above the @var{stack-size}
11951 (remember that the stack on s390 grows downward). These options are intended to
11952 be used to help debugging stack overflow problems. The additionally emitted code
11953 causes only little overhead and hence can also be used in production like systems
11954 without greater performance degradation. The given values have to be exact
11955 powers of 2 and @var{stack-size} has to be greater than @var{stack-guard} without
11957 In order to be efficient the extra code makes the assumption that the stack starts
11958 at an address aligned to the value given by @var{stack-size}.
11961 @node Score Options
11962 @subsection Score Options
11963 @cindex Score Options
11965 These options are defined for Score implementations:
11970 Compile code for big endian mode. This is the default.
11974 Compile code for little endian mode.
11978 Disable generate bcnz instruction.
11982 Enable generate unaligned load and store instruction.
11986 Enable the use of multiply-accumulate instructions. Disabled by default.
11990 Specify the SCORE5 as the target architecture.
11994 Specify the SCORE5U of the target architecture.
11998 Specify the SCORE7 as the target architecture. This is the default.
12002 Specify the SCORE7D as the target architecture.
12006 @subsection SH Options
12008 These @samp{-m} options are defined for the SH implementations:
12013 Generate code for the SH1.
12017 Generate code for the SH2.
12020 Generate code for the SH2e.
12024 Generate code for the SH3.
12028 Generate code for the SH3e.
12032 Generate code for the SH4 without a floating-point unit.
12034 @item -m4-single-only
12035 @opindex m4-single-only
12036 Generate code for the SH4 with a floating-point unit that only
12037 supports single-precision arithmetic.
12041 Generate code for the SH4 assuming the floating-point unit is in
12042 single-precision mode by default.
12046 Generate code for the SH4.
12050 Generate code for the SH4al-dsp, or for a SH4a in such a way that the
12051 floating-point unit is not used.
12053 @item -m4a-single-only
12054 @opindex m4a-single-only
12055 Generate code for the SH4a, in such a way that no double-precision
12056 floating point operations are used.
12059 @opindex m4a-single
12060 Generate code for the SH4a assuming the floating-point unit is in
12061 single-precision mode by default.
12065 Generate code for the SH4a.
12069 Same as @option{-m4a-nofpu}, except that it implicitly passes
12070 @option{-dsp} to the assembler. GCC doesn't generate any DSP
12071 instructions at the moment.
12075 Compile code for the processor in big endian mode.
12079 Compile code for the processor in little endian mode.
12083 Align doubles at 64-bit boundaries. Note that this changes the calling
12084 conventions, and thus some functions from the standard C library will
12085 not work unless you recompile it first with @option{-mdalign}.
12089 Shorten some address references at link time, when possible; uses the
12090 linker option @option{-relax}.
12094 Use 32-bit offsets in @code{switch} tables. The default is to use
12099 Enable the use of the instruction @code{fmovd}.
12103 Comply with the calling conventions defined by Renesas.
12107 Comply with the calling conventions defined by Renesas.
12111 Comply with the calling conventions defined for GCC before the Renesas
12112 conventions were available. This option is the default for all
12113 targets of the SH toolchain except for @samp{sh-symbianelf}.
12116 @opindex mnomacsave
12117 Mark the @code{MAC} register as call-clobbered, even if
12118 @option{-mhitachi} is given.
12122 Increase IEEE-compliance of floating-point code.
12123 At the moment, this is equivalent to @option{-fno-finite-math-only}.
12124 When generating 16 bit SH opcodes, getting IEEE-conforming results for
12125 comparisons of NANs / infinities incurs extra overhead in every
12126 floating point comparison, therefore the default is set to
12127 @option{-ffinite-math-only}.
12131 Dump instruction size and location in the assembly code.
12134 @opindex mpadstruct
12135 This option is deprecated. It pads structures to multiple of 4 bytes,
12136 which is incompatible with the SH ABI@.
12140 Optimize for space instead of speed. Implied by @option{-Os}.
12143 @opindex mprefergot
12144 When generating position-independent code, emit function calls using
12145 the Global Offset Table instead of the Procedure Linkage Table.
12149 Generate a library function call to invalidate instruction cache
12150 entries, after fixing up a trampoline. This library function call
12151 doesn't assume it can write to the whole memory address space. This
12152 is the default when the target is @code{sh-*-linux*}.
12154 @item -multcost=@var{number}
12155 @opindex multcost=@var{number}
12156 Set the cost to assume for a multiply insn.
12158 @item -mdiv=@var{strategy}
12159 @opindex mdiv=@var{strategy}
12160 Set the division strategy to use for SHmedia code. @var{strategy} must be
12161 one of: call, call2, fp, inv, inv:minlat, inv20u, inv20l, inv:call,
12162 inv:call2, inv:fp .
12163 "fp" performs the operation in floating point. This has a very high latency,
12164 but needs only a few instructions, so it might be a good choice if
12165 your code has enough easily exploitable ILP to allow the compiler to
12166 schedule the floating point instructions together with other instructions.
12167 Division by zero causes a floating point exception.
12168 "inv" uses integer operations to calculate the inverse of the divisor,
12169 and then multiplies the dividend with the inverse. This strategy allows
12170 cse and hoisting of the inverse calculation. Division by zero calculates
12171 an unspecified result, but does not trap.
12172 "inv:minlat" is a variant of "inv" where if no cse / hoisting opportunities
12173 have been found, or if the entire operation has been hoisted to the same
12174 place, the last stages of the inverse calculation are intertwined with the
12175 final multiply to reduce the overall latency, at the expense of using a few
12176 more instructions, and thus offering fewer scheduling opportunities with
12178 "call" calls a library function that usually implements the inv:minlat
12180 This gives high code density for m5-*media-nofpu compilations.
12181 "call2" uses a different entry point of the same library function, where it
12182 assumes that a pointer to a lookup table has already been set up, which
12183 exposes the pointer load to cse / code hoisting optimizations.
12184 "inv:call", "inv:call2" and "inv:fp" all use the "inv" algorithm for initial
12185 code generation, but if the code stays unoptimized, revert to the "call",
12186 "call2", or "fp" strategies, respectively. Note that the
12187 potentially-trapping side effect of division by zero is carried by a
12188 separate instruction, so it is possible that all the integer instructions
12189 are hoisted out, but the marker for the side effect stays where it is.
12190 A recombination to fp operations or a call is not possible in that case.
12191 "inv20u" and "inv20l" are variants of the "inv:minlat" strategy. In the case
12192 that the inverse calculation was nor separated from the multiply, they speed
12193 up division where the dividend fits into 20 bits (plus sign where applicable),
12194 by inserting a test to skip a number of operations in this case; this test
12195 slows down the case of larger dividends. inv20u assumes the case of a such
12196 a small dividend to be unlikely, and inv20l assumes it to be likely.
12198 @item -mdivsi3_libfunc=@var{name}
12199 @opindex mdivsi3_libfunc=@var{name}
12200 Set the name of the library function used for 32 bit signed division to
12201 @var{name}. This only affect the name used in the call and inv:call
12202 division strategies, and the compiler will still expect the same
12203 sets of input/output/clobbered registers as if this option was not present.
12205 @item -madjust-unroll
12206 @opindex madjust-unroll
12207 Throttle unrolling to avoid thrashing target registers.
12208 This option only has an effect if the gcc code base supports the
12209 TARGET_ADJUST_UNROLL_MAX target hook.
12211 @item -mindexed-addressing
12212 @opindex mindexed-addressing
12213 Enable the use of the indexed addressing mode for SHmedia32/SHcompact.
12214 This is only safe if the hardware and/or OS implement 32 bit wrap-around
12215 semantics for the indexed addressing mode. The architecture allows the
12216 implementation of processors with 64 bit MMU, which the OS could use to
12217 get 32 bit addressing, but since no current hardware implementation supports
12218 this or any other way to make the indexed addressing mode safe to use in
12219 the 32 bit ABI, the default is -mno-indexed-addressing.
12221 @item -mgettrcost=@var{number}
12222 @opindex mgettrcost=@var{number}
12223 Set the cost assumed for the gettr instruction to @var{number}.
12224 The default is 2 if @option{-mpt-fixed} is in effect, 100 otherwise.
12228 Assume pt* instructions won't trap. This will generally generate better
12229 scheduled code, but is unsafe on current hardware. The current architecture
12230 definition says that ptabs and ptrel trap when the target anded with 3 is 3.
12231 This has the unintentional effect of making it unsafe to schedule ptabs /
12232 ptrel before a branch, or hoist it out of a loop. For example,
12233 __do_global_ctors, a part of libgcc that runs constructors at program
12234 startup, calls functions in a list which is delimited by -1. With the
12235 -mpt-fixed option, the ptabs will be done before testing against -1.
12236 That means that all the constructors will be run a bit quicker, but when
12237 the loop comes to the end of the list, the program crashes because ptabs
12238 loads -1 into a target register. Since this option is unsafe for any
12239 hardware implementing the current architecture specification, the default
12240 is -mno-pt-fixed. Unless the user specifies a specific cost with
12241 @option{-mgettrcost}, -mno-pt-fixed also implies @option{-mgettrcost=100};
12242 this deters register allocation using target registers for storing
12245 @item -minvalid-symbols
12246 @opindex minvalid-symbols
12247 Assume symbols might be invalid. Ordinary function symbols generated by
12248 the compiler will always be valid to load with movi/shori/ptabs or
12249 movi/shori/ptrel, but with assembler and/or linker tricks it is possible
12250 to generate symbols that will cause ptabs / ptrel to trap.
12251 This option is only meaningful when @option{-mno-pt-fixed} is in effect.
12252 It will then prevent cross-basic-block cse, hoisting and most scheduling
12253 of symbol loads. The default is @option{-mno-invalid-symbols}.
12256 @node SPARC Options
12257 @subsection SPARC Options
12258 @cindex SPARC options
12260 These @samp{-m} options are supported on the SPARC:
12263 @item -mno-app-regs
12265 @opindex mno-app-regs
12267 Specify @option{-mapp-regs} to generate output using the global registers
12268 2 through 4, which the SPARC SVR4 ABI reserves for applications. This
12271 To be fully SVR4 ABI compliant at the cost of some performance loss,
12272 specify @option{-mno-app-regs}. You should compile libraries and system
12273 software with this option.
12276 @itemx -mhard-float
12278 @opindex mhard-float
12279 Generate output containing floating point instructions. This is the
12283 @itemx -msoft-float
12285 @opindex msoft-float
12286 Generate output containing library calls for floating point.
12287 @strong{Warning:} the requisite libraries are not available for all SPARC
12288 targets. Normally the facilities of the machine's usual C compiler are
12289 used, but this cannot be done directly in cross-compilation. You must make
12290 your own arrangements to provide suitable library functions for
12291 cross-compilation. The embedded targets @samp{sparc-*-aout} and
12292 @samp{sparclite-*-*} do provide software floating point support.
12294 @option{-msoft-float} changes the calling convention in the output file;
12295 therefore, it is only useful if you compile @emph{all} of a program with
12296 this option. In particular, you need to compile @file{libgcc.a}, the
12297 library that comes with GCC, with @option{-msoft-float} in order for
12300 @item -mhard-quad-float
12301 @opindex mhard-quad-float
12302 Generate output containing quad-word (long double) floating point
12305 @item -msoft-quad-float
12306 @opindex msoft-quad-float
12307 Generate output containing library calls for quad-word (long double)
12308 floating point instructions. The functions called are those specified
12309 in the SPARC ABI@. This is the default.
12311 As of this writing, there are no SPARC implementations that have hardware
12312 support for the quad-word floating point instructions. They all invoke
12313 a trap handler for one of these instructions, and then the trap handler
12314 emulates the effect of the instruction. Because of the trap handler overhead,
12315 this is much slower than calling the ABI library routines. Thus the
12316 @option{-msoft-quad-float} option is the default.
12318 @item -mno-unaligned-doubles
12319 @itemx -munaligned-doubles
12320 @opindex mno-unaligned-doubles
12321 @opindex munaligned-doubles
12322 Assume that doubles have 8 byte alignment. This is the default.
12324 With @option{-munaligned-doubles}, GCC assumes that doubles have 8 byte
12325 alignment only if they are contained in another type, or if they have an
12326 absolute address. Otherwise, it assumes they have 4 byte alignment.
12327 Specifying this option avoids some rare compatibility problems with code
12328 generated by other compilers. It is not the default because it results
12329 in a performance loss, especially for floating point code.
12331 @item -mno-faster-structs
12332 @itemx -mfaster-structs
12333 @opindex mno-faster-structs
12334 @opindex mfaster-structs
12335 With @option{-mfaster-structs}, the compiler assumes that structures
12336 should have 8 byte alignment. This enables the use of pairs of
12337 @code{ldd} and @code{std} instructions for copies in structure
12338 assignment, in place of twice as many @code{ld} and @code{st} pairs.
12339 However, the use of this changed alignment directly violates the SPARC
12340 ABI@. Thus, it's intended only for use on targets where the developer
12341 acknowledges that their resulting code will not be directly in line with
12342 the rules of the ABI@.
12344 @item -mimpure-text
12345 @opindex mimpure-text
12346 @option{-mimpure-text}, used in addition to @option{-shared}, tells
12347 the compiler to not pass @option{-z text} to the linker when linking a
12348 shared object. Using this option, you can link position-dependent
12349 code into a shared object.
12351 @option{-mimpure-text} suppresses the ``relocations remain against
12352 allocatable but non-writable sections'' linker error message.
12353 However, the necessary relocations will trigger copy-on-write, and the
12354 shared object is not actually shared across processes. Instead of
12355 using @option{-mimpure-text}, you should compile all source code with
12356 @option{-fpic} or @option{-fPIC}.
12358 This option is only available on SunOS and Solaris.
12360 @item -mcpu=@var{cpu_type}
12362 Set the instruction set, register set, and instruction scheduling parameters
12363 for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
12364 @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{sparclite},
12365 @samp{f930}, @samp{f934}, @samp{hypersparc}, @samp{sparclite86x},
12366 @samp{sparclet}, @samp{tsc701}, @samp{v9}, @samp{ultrasparc},
12367 @samp{ultrasparc3}, and @samp{niagara}.
12369 Default instruction scheduling parameters are used for values that select
12370 an architecture and not an implementation. These are @samp{v7}, @samp{v8},
12371 @samp{sparclite}, @samp{sparclet}, @samp{v9}.
12373 Here is a list of each supported architecture and their supported
12378 v8: supersparc, hypersparc
12379 sparclite: f930, f934, sparclite86x
12381 v9: ultrasparc, ultrasparc3, niagara
12384 By default (unless configured otherwise), GCC generates code for the V7
12385 variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
12386 additionally optimizes it for the Cypress CY7C602 chip, as used in the
12387 SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
12388 SPARCStation 1, 2, IPX etc.
12390 With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
12391 architecture. The only difference from V7 code is that the compiler emits
12392 the integer multiply and integer divide instructions which exist in SPARC-V8
12393 but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
12394 optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
12397 With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
12398 the SPARC architecture. This adds the integer multiply, integer divide step
12399 and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
12400 With @option{-mcpu=f930}, the compiler additionally optimizes it for the
12401 Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
12402 @option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
12403 MB86934 chip, which is the more recent SPARClite with FPU@.
12405 With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
12406 the SPARC architecture. This adds the integer multiply, multiply/accumulate,
12407 integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
12408 but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
12409 optimizes it for the TEMIC SPARClet chip.
12411 With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
12412 architecture. This adds 64-bit integer and floating-point move instructions,
12413 3 additional floating-point condition code registers and conditional move
12414 instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
12415 optimizes it for the Sun UltraSPARC I/II/IIi chips. With
12416 @option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
12417 Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
12418 @option{-mcpu=niagara}, the compiler additionally optimizes it for
12419 Sun UltraSPARC T1 chips.
12421 @item -mtune=@var{cpu_type}
12423 Set the instruction scheduling parameters for machine type
12424 @var{cpu_type}, but do not set the instruction set or register set that the
12425 option @option{-mcpu=@var{cpu_type}} would.
12427 The same values for @option{-mcpu=@var{cpu_type}} can be used for
12428 @option{-mtune=@var{cpu_type}}, but the only useful values are those
12429 that select a particular cpu implementation. Those are @samp{cypress},
12430 @samp{supersparc}, @samp{hypersparc}, @samp{f930}, @samp{f934},
12431 @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
12432 @samp{ultrasparc3}, and @samp{niagara}.
12437 @opindex mno-v8plus
12438 With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
12439 difference from the V8 ABI is that the global and out registers are
12440 considered 64-bit wide. This is enabled by default on Solaris in 32-bit
12441 mode for all SPARC-V9 processors.
12447 With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
12448 Visual Instruction Set extensions. The default is @option{-mno-vis}.
12451 These @samp{-m} options are supported in addition to the above
12452 on SPARC-V9 processors in 64-bit environments:
12455 @item -mlittle-endian
12456 @opindex mlittle-endian
12457 Generate code for a processor running in little-endian mode. It is only
12458 available for a few configurations and most notably not on Solaris and Linux.
12464 Generate code for a 32-bit or 64-bit environment.
12465 The 32-bit environment sets int, long and pointer to 32 bits.
12466 The 64-bit environment sets int to 32 bits and long and pointer
12469 @item -mcmodel=medlow
12470 @opindex mcmodel=medlow
12471 Generate code for the Medium/Low code model: 64-bit addresses, programs
12472 must be linked in the low 32 bits of memory. Programs can be statically
12473 or dynamically linked.
12475 @item -mcmodel=medmid
12476 @opindex mcmodel=medmid
12477 Generate code for the Medium/Middle code model: 64-bit addresses, programs
12478 must be linked in the low 44 bits of memory, the text and data segments must
12479 be less than 2GB in size and the data segment must be located within 2GB of
12482 @item -mcmodel=medany
12483 @opindex mcmodel=medany
12484 Generate code for the Medium/Anywhere code model: 64-bit addresses, programs
12485 may be linked anywhere in memory, the text and data segments must be less
12486 than 2GB in size and the data segment must be located within 2GB of the
12489 @item -mcmodel=embmedany
12490 @opindex mcmodel=embmedany
12491 Generate code for the Medium/Anywhere code model for embedded systems:
12492 64-bit addresses, the text and data segments must be less than 2GB in
12493 size, both starting anywhere in memory (determined at link time). The
12494 global register %g4 points to the base of the data segment. Programs
12495 are statically linked and PIC is not supported.
12498 @itemx -mno-stack-bias
12499 @opindex mstack-bias
12500 @opindex mno-stack-bias
12501 With @option{-mstack-bias}, GCC assumes that the stack pointer, and
12502 frame pointer if present, are offset by @minus{}2047 which must be added back
12503 when making stack frame references. This is the default in 64-bit mode.
12504 Otherwise, assume no such offset is present.
12507 These switches are supported in addition to the above on Solaris:
12512 Add support for multithreading using the Solaris threads library. This
12513 option sets flags for both the preprocessor and linker. This option does
12514 not affect the thread safety of object code produced by the compiler or
12515 that of libraries supplied with it.
12519 Add support for multithreading using the POSIX threads library. This
12520 option sets flags for both the preprocessor and linker. This option does
12521 not affect the thread safety of object code produced by the compiler or
12522 that of libraries supplied with it.
12526 This is a synonym for @option{-pthreads}.
12529 @node System V Options
12530 @subsection Options for System V
12532 These additional options are available on System V Release 4 for
12533 compatibility with other compilers on those systems:
12538 Create a shared object.
12539 It is recommended that @option{-symbolic} or @option{-shared} be used instead.
12543 Identify the versions of each tool used by the compiler, in a
12544 @code{.ident} assembler directive in the output.
12548 Refrain from adding @code{.ident} directives to the output file (this is
12551 @item -YP,@var{dirs}
12553 Search the directories @var{dirs}, and no others, for libraries
12554 specified with @option{-l}.
12556 @item -Ym,@var{dir}
12558 Look in the directory @var{dir} to find the M4 preprocessor.
12559 The assembler uses this option.
12560 @c This is supposed to go with a -Yd for predefined M4 macro files, but
12561 @c the generic assembler that comes with Solaris takes just -Ym.
12564 @node TMS320C3x/C4x Options
12565 @subsection TMS320C3x/C4x Options
12566 @cindex TMS320C3x/C4x Options
12568 These @samp{-m} options are defined for TMS320C3x/C4x implementations:
12572 @item -mcpu=@var{cpu_type}
12574 Set the instruction set, register set, and instruction scheduling
12575 parameters for machine type @var{cpu_type}. Supported values for
12576 @var{cpu_type} are @samp{c30}, @samp{c31}, @samp{c32}, @samp{c40}, and
12577 @samp{c44}. The default is @samp{c40} to generate code for the
12582 @itemx -msmall-memory
12584 @opindex mbig-memory
12586 @opindex msmall-memory
12588 Generates code for the big or small memory model. The small memory
12589 model assumed that all data fits into one 64K word page. At run-time
12590 the data page (DP) register must be set to point to the 64K page
12591 containing the .bss and .data program sections. The big memory model is
12592 the default and requires reloading of the DP register for every direct
12599 Allow (disallow) allocation of general integer operands into the block
12600 count register BK@.
12606 Enable (disable) generation of code using decrement and branch,
12607 DBcond(D), instructions. This is enabled by default for the C4x. To be
12608 on the safe side, this is disabled for the C3x, since the maximum
12609 iteration count on the C3x is @math{2^{23} + 1} (but who iterates loops more than
12610 @math{2^{23}} times on the C3x?). Note that GCC will try to reverse a loop so
12611 that it can utilize the decrement and branch instruction, but will give
12612 up if there is more than one memory reference in the loop. Thus a loop
12613 where the loop counter is decremented can generate slightly more
12614 efficient code, in cases where the RPTB instruction cannot be utilized.
12616 @item -mdp-isr-reload
12618 @opindex mdp-isr-reload
12620 Force the DP register to be saved on entry to an interrupt service
12621 routine (ISR), reloaded to point to the data section, and restored on
12622 exit from the ISR@. This should not be required unless someone has
12623 violated the small memory model by modifying the DP register, say within
12630 For the C3x use the 24-bit MPYI instruction for integer multiplies
12631 instead of a library call to guarantee 32-bit results. Note that if one
12632 of the operands is a constant, then the multiplication will be performed
12633 using shifts and adds. If the @option{-mmpyi} option is not specified for the C3x,
12634 then squaring operations are performed inline instead of a library call.
12637 @itemx -mno-fast-fix
12639 @opindex mno-fast-fix
12640 The C3x/C4x FIX instruction to convert a floating point value to an
12641 integer value chooses the nearest integer less than or equal to the
12642 floating point value rather than to the nearest integer. Thus if the
12643 floating point number is negative, the result will be incorrectly
12644 truncated an additional code is necessary to detect and correct this
12645 case. This option can be used to disable generation of the additional
12646 code required to correct the result.
12652 Enable (disable) generation of repeat block sequences using the RPTB
12653 instruction for zero overhead looping. The RPTB construct is only used
12654 for innermost loops that do not call functions or jump across the loop
12655 boundaries. There is no advantage having nested RPTB loops due to the
12656 overhead required to save and restore the RC, RS, and RE registers.
12657 This is enabled by default with @option{-O2}.
12659 @item -mrpts=@var{count}
12663 Enable (disable) the use of the single instruction repeat instruction
12664 RPTS@. If a repeat block contains a single instruction, and the loop
12665 count can be guaranteed to be less than the value @var{count}, GCC will
12666 emit a RPTS instruction instead of a RPTB@. If no value is specified,
12667 then a RPTS will be emitted even if the loop count cannot be determined
12668 at compile time. Note that the repeated instruction following RPTS does
12669 not have to be reloaded from memory each iteration, thus freeing up the
12670 CPU buses for operands. However, since interrupts are blocked by this
12671 instruction, it is disabled by default.
12673 @item -mloop-unsigned
12674 @itemx -mno-loop-unsigned
12675 @opindex mloop-unsigned
12676 @opindex mno-loop-unsigned
12677 The maximum iteration count when using RPTS and RPTB (and DB on the C40)
12678 is @math{2^{31} + 1} since these instructions test if the iteration count is
12679 negative to terminate the loop. If the iteration count is unsigned
12680 there is a possibility than the @math{2^{31} + 1} maximum iteration count may be
12681 exceeded. This switch allows an unsigned iteration count.
12685 Try to emit an assembler syntax that the TI assembler (asm30) is happy
12686 with. This also enforces compatibility with the API employed by the TI
12687 C3x C compiler. For example, long doubles are passed as structures
12688 rather than in floating point registers.
12694 Generate code that uses registers (stack) for passing arguments to functions.
12695 By default, arguments are passed in registers where possible rather
12696 than by pushing arguments on to the stack.
12698 @item -mparallel-insns
12699 @itemx -mno-parallel-insns
12700 @opindex mparallel-insns
12701 @opindex mno-parallel-insns
12702 Allow the generation of parallel instructions. This is enabled by
12703 default with @option{-O2}.
12705 @item -mparallel-mpy
12706 @itemx -mno-parallel-mpy
12707 @opindex mparallel-mpy
12708 @opindex mno-parallel-mpy
12709 Allow the generation of MPY||ADD and MPY||SUB parallel instructions,
12710 provided @option{-mparallel-insns} is also specified. These instructions have
12711 tight register constraints which can pessimize the code generation
12712 of large functions.
12717 @subsection V850 Options
12718 @cindex V850 Options
12720 These @samp{-m} options are defined for V850 implementations:
12724 @itemx -mno-long-calls
12725 @opindex mlong-calls
12726 @opindex mno-long-calls
12727 Treat all calls as being far away (near). If calls are assumed to be
12728 far away, the compiler will always load the functions address up into a
12729 register, and call indirect through the pointer.
12735 Do not optimize (do optimize) basic blocks that use the same index
12736 pointer 4 or more times to copy pointer into the @code{ep} register, and
12737 use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
12738 option is on by default if you optimize.
12740 @item -mno-prolog-function
12741 @itemx -mprolog-function
12742 @opindex mno-prolog-function
12743 @opindex mprolog-function
12744 Do not use (do use) external functions to save and restore registers
12745 at the prologue and epilogue of a function. The external functions
12746 are slower, but use less code space if more than one function saves
12747 the same number of registers. The @option{-mprolog-function} option
12748 is on by default if you optimize.
12752 Try to make the code as small as possible. At present, this just turns
12753 on the @option{-mep} and @option{-mprolog-function} options.
12755 @item -mtda=@var{n}
12757 Put static or global variables whose size is @var{n} bytes or less into
12758 the tiny data area that register @code{ep} points to. The tiny data
12759 area can hold up to 256 bytes in total (128 bytes for byte references).
12761 @item -msda=@var{n}
12763 Put static or global variables whose size is @var{n} bytes or less into
12764 the small data area that register @code{gp} points to. The small data
12765 area can hold up to 64 kilobytes.
12767 @item -mzda=@var{n}
12769 Put static or global variables whose size is @var{n} bytes or less into
12770 the first 32 kilobytes of memory.
12774 Specify that the target processor is the V850.
12777 @opindex mbig-switch
12778 Generate code suitable for big switch tables. Use this option only if
12779 the assembler/linker complain about out of range branches within a switch
12784 This option will cause r2 and r5 to be used in the code generated by
12785 the compiler. This setting is the default.
12787 @item -mno-app-regs
12788 @opindex mno-app-regs
12789 This option will cause r2 and r5 to be treated as fixed registers.
12793 Specify that the target processor is the V850E1. The preprocessor
12794 constants @samp{__v850e1__} and @samp{__v850e__} will be defined if
12795 this option is used.
12799 Specify that the target processor is the V850E@. The preprocessor
12800 constant @samp{__v850e__} will be defined if this option is used.
12802 If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
12803 are defined then a default target processor will be chosen and the
12804 relevant @samp{__v850*__} preprocessor constant will be defined.
12806 The preprocessor constants @samp{__v850} and @samp{__v851__} are always
12807 defined, regardless of which processor variant is the target.
12809 @item -mdisable-callt
12810 @opindex mdisable-callt
12811 This option will suppress generation of the CALLT instruction for the
12812 v850e and v850e1 flavors of the v850 architecture. The default is
12813 @option{-mno-disable-callt} which allows the CALLT instruction to be used.
12818 @subsection VAX Options
12819 @cindex VAX options
12821 These @samp{-m} options are defined for the VAX:
12826 Do not output certain jump instructions (@code{aobleq} and so on)
12827 that the Unix assembler for the VAX cannot handle across long
12832 Do output those jump instructions, on the assumption that you
12833 will assemble with the GNU assembler.
12837 Output code for g-format floating point numbers instead of d-format.
12840 @node x86-64 Options
12841 @subsection x86-64 Options
12842 @cindex x86-64 options
12844 These are listed under @xref{i386 and x86-64 Options}.
12846 @node Xstormy16 Options
12847 @subsection Xstormy16 Options
12848 @cindex Xstormy16 Options
12850 These options are defined for Xstormy16:
12855 Choose startup files and linker script suitable for the simulator.
12858 @node Xtensa Options
12859 @subsection Xtensa Options
12860 @cindex Xtensa Options
12862 These options are supported for Xtensa targets:
12866 @itemx -mno-const16
12868 @opindex mno-const16
12869 Enable or disable use of @code{CONST16} instructions for loading
12870 constant values. The @code{CONST16} instruction is currently not a
12871 standard option from Tensilica. When enabled, @code{CONST16}
12872 instructions are always used in place of the standard @code{L32R}
12873 instructions. The use of @code{CONST16} is enabled by default only if
12874 the @code{L32R} instruction is not available.
12877 @itemx -mno-fused-madd
12878 @opindex mfused-madd
12879 @opindex mno-fused-madd
12880 Enable or disable use of fused multiply/add and multiply/subtract
12881 instructions in the floating-point option. This has no effect if the
12882 floating-point option is not also enabled. Disabling fused multiply/add
12883 and multiply/subtract instructions forces the compiler to use separate
12884 instructions for the multiply and add/subtract operations. This may be
12885 desirable in some cases where strict IEEE 754-compliant results are
12886 required: the fused multiply add/subtract instructions do not round the
12887 intermediate result, thereby producing results with @emph{more} bits of
12888 precision than specified by the IEEE standard. Disabling fused multiply
12889 add/subtract instructions also ensures that the program output is not
12890 sensitive to the compiler's ability to combine multiply and add/subtract
12893 @item -mtext-section-literals
12894 @itemx -mno-text-section-literals
12895 @opindex mtext-section-literals
12896 @opindex mno-text-section-literals
12897 Control the treatment of literal pools. The default is
12898 @option{-mno-text-section-literals}, which places literals in a separate
12899 section in the output file. This allows the literal pool to be placed
12900 in a data RAM/ROM, and it also allows the linker to combine literal
12901 pools from separate object files to remove redundant literals and
12902 improve code size. With @option{-mtext-section-literals}, the literals
12903 are interspersed in the text section in order to keep them as close as
12904 possible to their references. This may be necessary for large assembly
12907 @item -mtarget-align
12908 @itemx -mno-target-align
12909 @opindex mtarget-align
12910 @opindex mno-target-align
12911 When this option is enabled, GCC instructs the assembler to
12912 automatically align instructions to reduce branch penalties at the
12913 expense of some code density. The assembler attempts to widen density
12914 instructions to align branch targets and the instructions following call
12915 instructions. If there are not enough preceding safe density
12916 instructions to align a target, no widening will be performed. The
12917 default is @option{-mtarget-align}. These options do not affect the
12918 treatment of auto-aligned instructions like @code{LOOP}, which the
12919 assembler will always align, either by widening density instructions or
12920 by inserting no-op instructions.
12923 @itemx -mno-longcalls
12924 @opindex mlongcalls
12925 @opindex mno-longcalls
12926 When this option is enabled, GCC instructs the assembler to translate
12927 direct calls to indirect calls unless it can determine that the target
12928 of a direct call is in the range allowed by the call instruction. This
12929 translation typically occurs for calls to functions in other source
12930 files. Specifically, the assembler translates a direct @code{CALL}
12931 instruction into an @code{L32R} followed by a @code{CALLX} instruction.
12932 The default is @option{-mno-longcalls}. This option should be used in
12933 programs where the call target can potentially be out of range. This
12934 option is implemented in the assembler, not the compiler, so the
12935 assembly code generated by GCC will still show direct call
12936 instructions---look at the disassembled object code to see the actual
12937 instructions. Note that the assembler will use an indirect call for
12938 every cross-file call, not just those that really will be out of range.
12941 @node zSeries Options
12942 @subsection zSeries Options
12943 @cindex zSeries options
12945 These are listed under @xref{S/390 and zSeries Options}.
12947 @node Code Gen Options
12948 @section Options for Code Generation Conventions
12949 @cindex code generation conventions
12950 @cindex options, code generation
12951 @cindex run-time options
12953 These machine-independent options control the interface conventions
12954 used in code generation.
12956 Most of them have both positive and negative forms; the negative form
12957 of @option{-ffoo} would be @option{-fno-foo}. In the table below, only
12958 one of the forms is listed---the one which is not the default. You
12959 can figure out the other form by either removing @samp{no-} or adding
12963 @item -fbounds-check
12964 @opindex fbounds-check
12965 For front-ends that support it, generate additional code to check that
12966 indices used to access arrays are within the declared range. This is
12967 currently only supported by the Java and Fortran front-ends, where
12968 this option defaults to true and false respectively.
12972 This option generates traps for signed overflow on addition, subtraction,
12973 multiplication operations.
12977 This option instructs the compiler to assume that signed arithmetic
12978 overflow of addition, subtraction and multiplication wraps around
12979 using twos-complement representation. This flag enables some optimizations
12980 and disables others. This option is enabled by default for the Java
12981 front-end, as required by the Java language specification.
12984 @opindex fexceptions
12985 Enable exception handling. Generates extra code needed to propagate
12986 exceptions. For some targets, this implies GCC will generate frame
12987 unwind information for all functions, which can produce significant data
12988 size overhead, although it does not affect execution. If you do not
12989 specify this option, GCC will enable it by default for languages like
12990 C++ which normally require exception handling, and disable it for
12991 languages like C that do not normally require it. However, you may need
12992 to enable this option when compiling C code that needs to interoperate
12993 properly with exception handlers written in C++. You may also wish to
12994 disable this option if you are compiling older C++ programs that don't
12995 use exception handling.
12997 @item -fnon-call-exceptions
12998 @opindex fnon-call-exceptions
12999 Generate code that allows trapping instructions to throw exceptions.
13000 Note that this requires platform-specific runtime support that does
13001 not exist everywhere. Moreover, it only allows @emph{trapping}
13002 instructions to throw exceptions, i.e.@: memory references or floating
13003 point instructions. It does not allow exceptions to be thrown from
13004 arbitrary signal handlers such as @code{SIGALRM}.
13006 @item -funwind-tables
13007 @opindex funwind-tables
13008 Similar to @option{-fexceptions}, except that it will just generate any needed
13009 static data, but will not affect the generated code in any other way.
13010 You will normally not enable this option; instead, a language processor
13011 that needs this handling would enable it on your behalf.
13013 @item -fasynchronous-unwind-tables
13014 @opindex fasynchronous-unwind-tables
13015 Generate unwind table in dwarf2 format, if supported by target machine. The
13016 table is exact at each instruction boundary, so it can be used for stack
13017 unwinding from asynchronous events (such as debugger or garbage collector).
13019 @item -fpcc-struct-return
13020 @opindex fpcc-struct-return
13021 Return ``short'' @code{struct} and @code{union} values in memory like
13022 longer ones, rather than in registers. This convention is less
13023 efficient, but it has the advantage of allowing intercallability between
13024 GCC-compiled files and files compiled with other compilers, particularly
13025 the Portable C Compiler (pcc).
13027 The precise convention for returning structures in memory depends
13028 on the target configuration macros.
13030 Short structures and unions are those whose size and alignment match
13031 that of some integer type.
13033 @strong{Warning:} code compiled with the @option{-fpcc-struct-return}
13034 switch is not binary compatible with code compiled with the
13035 @option{-freg-struct-return} switch.
13036 Use it to conform to a non-default application binary interface.
13038 @item -freg-struct-return
13039 @opindex freg-struct-return
13040 Return @code{struct} and @code{union} values in registers when possible.
13041 This is more efficient for small structures than
13042 @option{-fpcc-struct-return}.
13044 If you specify neither @option{-fpcc-struct-return} nor
13045 @option{-freg-struct-return}, GCC defaults to whichever convention is
13046 standard for the target. If there is no standard convention, GCC
13047 defaults to @option{-fpcc-struct-return}, except on targets where GCC is
13048 the principal compiler. In those cases, we can choose the standard, and
13049 we chose the more efficient register return alternative.
13051 @strong{Warning:} code compiled with the @option{-freg-struct-return}
13052 switch is not binary compatible with code compiled with the
13053 @option{-fpcc-struct-return} switch.
13054 Use it to conform to a non-default application binary interface.
13056 @item -fshort-enums
13057 @opindex fshort-enums
13058 Allocate to an @code{enum} type only as many bytes as it needs for the
13059 declared range of possible values. Specifically, the @code{enum} type
13060 will be equivalent to the smallest integer type which has enough room.
13062 @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
13063 code that is not binary compatible with code generated without that switch.
13064 Use it to conform to a non-default application binary interface.
13066 @item -fshort-double
13067 @opindex fshort-double
13068 Use the same size for @code{double} as for @code{float}.
13070 @strong{Warning:} the @option{-fshort-double} switch causes GCC to generate
13071 code that is not binary compatible with code generated without that switch.
13072 Use it to conform to a non-default application binary interface.
13074 @item -fshort-wchar
13075 @opindex fshort-wchar
13076 Override the underlying type for @samp{wchar_t} to be @samp{short
13077 unsigned int} instead of the default for the target. This option is
13078 useful for building programs to run under WINE@.
13080 @strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
13081 code that is not binary compatible with code generated without that switch.
13082 Use it to conform to a non-default application binary interface.
13085 @opindex fno-common
13086 In C, allocate even uninitialized global variables in the data section of the
13087 object file, rather than generating them as common blocks. This has the
13088 effect that if the same variable is declared (without @code{extern}) in
13089 two different compilations, you will get an error when you link them.
13090 The only reason this might be useful is if you wish to verify that the
13091 program will work on other systems which always work this way.
13095 Ignore the @samp{#ident} directive.
13097 @item -finhibit-size-directive
13098 @opindex finhibit-size-directive
13099 Don't output a @code{.size} assembler directive, or anything else that
13100 would cause trouble if the function is split in the middle, and the
13101 two halves are placed at locations far apart in memory. This option is
13102 used when compiling @file{crtstuff.c}; you should not need to use it
13105 @item -fverbose-asm
13106 @opindex fverbose-asm
13107 Put extra commentary information in the generated assembly code to
13108 make it more readable. This option is generally only of use to those
13109 who actually need to read the generated assembly code (perhaps while
13110 debugging the compiler itself).
13112 @option{-fno-verbose-asm}, the default, causes the
13113 extra information to be omitted and is useful when comparing two assembler
13118 @cindex global offset table
13120 Generate position-independent code (PIC) suitable for use in a shared
13121 library, if supported for the target machine. Such code accesses all
13122 constant addresses through a global offset table (GOT)@. The dynamic
13123 loader resolves the GOT entries when the program starts (the dynamic
13124 loader is not part of GCC; it is part of the operating system). If
13125 the GOT size for the linked executable exceeds a machine-specific
13126 maximum size, you get an error message from the linker indicating that
13127 @option{-fpic} does not work; in that case, recompile with @option{-fPIC}
13128 instead. (These maximums are 8k on the SPARC and 32k
13129 on the m68k and RS/6000. The 386 has no such limit.)
13131 Position-independent code requires special support, and therefore works
13132 only on certain machines. For the 386, GCC supports PIC for System V
13133 but not for the Sun 386i. Code generated for the IBM RS/6000 is always
13134 position-independent.
13136 When this flag is set, the macros @code{__pic__} and @code{__PIC__}
13141 If supported for the target machine, emit position-independent code,
13142 suitable for dynamic linking and avoiding any limit on the size of the
13143 global offset table. This option makes a difference on the m68k,
13144 PowerPC and SPARC@.
13146 Position-independent code requires special support, and therefore works
13147 only on certain machines.
13149 When this flag is set, the macros @code{__pic__} and @code{__PIC__}
13156 These options are similar to @option{-fpic} and @option{-fPIC}, but
13157 generated position independent code can be only linked into executables.
13158 Usually these options are used when @option{-pie} GCC option will be
13159 used during linking.
13161 @item -fno-jump-tables
13162 @opindex fno-jump-tables
13163 Do not use jump tables for switch statements even where it would be
13164 more efficient than other code generation strategies. This option is
13165 of use in conjunction with @option{-fpic} or @option{-fPIC} for
13166 building code which forms part of a dynamic linker and cannot
13167 reference the address of a jump table. On some targets, jump tables
13168 do not require a GOT and this option is not needed.
13170 @item -ffixed-@var{reg}
13172 Treat the register named @var{reg} as a fixed register; generated code
13173 should never refer to it (except perhaps as a stack pointer, frame
13174 pointer or in some other fixed role).
13176 @var{reg} must be the name of a register. The register names accepted
13177 are machine-specific and are defined in the @code{REGISTER_NAMES}
13178 macro in the machine description macro file.
13180 This flag does not have a negative form, because it specifies a
13183 @item -fcall-used-@var{reg}
13184 @opindex fcall-used
13185 Treat the register named @var{reg} as an allocable register that is
13186 clobbered by function calls. It may be allocated for temporaries or
13187 variables that do not live across a call. Functions compiled this way
13188 will not save and restore the register @var{reg}.
13190 It is an error to used this flag with the frame pointer or stack pointer.
13191 Use of this flag for other registers that have fixed pervasive roles in
13192 the machine's execution model will produce disastrous results.
13194 This flag does not have a negative form, because it specifies a
13197 @item -fcall-saved-@var{reg}
13198 @opindex fcall-saved
13199 Treat the register named @var{reg} as an allocable register saved by
13200 functions. It may be allocated even for temporaries or variables that
13201 live across a call. Functions compiled this way will save and restore
13202 the register @var{reg} if they use it.
13204 It is an error to used this flag with the frame pointer or stack pointer.
13205 Use of this flag for other registers that have fixed pervasive roles in
13206 the machine's execution model will produce disastrous results.
13208 A different sort of disaster will result from the use of this flag for
13209 a register in which function values may be returned.
13211 This flag does not have a negative form, because it specifies a
13214 @item -fpack-struct[=@var{n}]
13215 @opindex fpack-struct
13216 Without a value specified, pack all structure members together without
13217 holes. When a value is specified (which must be a small power of two), pack
13218 structure members according to this value, representing the maximum
13219 alignment (that is, objects with default alignment requirements larger than
13220 this will be output potentially unaligned at the next fitting location.
13222 @strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
13223 code that is not binary compatible with code generated without that switch.
13224 Additionally, it makes the code suboptimal.
13225 Use it to conform to a non-default application binary interface.
13227 @item -finstrument-functions
13228 @opindex finstrument-functions
13229 Generate instrumentation calls for entry and exit to functions. Just
13230 after function entry and just before function exit, the following
13231 profiling functions will be called with the address of the current
13232 function and its call site. (On some platforms,
13233 @code{__builtin_return_address} does not work beyond the current
13234 function, so the call site information may not be available to the
13235 profiling functions otherwise.)
13238 void __cyg_profile_func_enter (void *this_fn,
13240 void __cyg_profile_func_exit (void *this_fn,
13244 The first argument is the address of the start of the current function,
13245 which may be looked up exactly in the symbol table.
13247 This instrumentation is also done for functions expanded inline in other
13248 functions. The profiling calls will indicate where, conceptually, the
13249 inline function is entered and exited. This means that addressable
13250 versions of such functions must be available. If all your uses of a
13251 function are expanded inline, this may mean an additional expansion of
13252 code size. If you use @samp{extern inline} in your C code, an
13253 addressable version of such functions must be provided. (This is
13254 normally the case anyways, but if you get lucky and the optimizer always
13255 expands the functions inline, you might have gotten away without
13256 providing static copies.)
13258 A function may be given the attribute @code{no_instrument_function}, in
13259 which case this instrumentation will not be done. This can be used, for
13260 example, for the profiling functions listed above, high-priority
13261 interrupt routines, and any functions from which the profiling functions
13262 cannot safely be called (perhaps signal handlers, if the profiling
13263 routines generate output or allocate memory).
13265 @item -fstack-check
13266 @opindex fstack-check
13267 Generate code to verify that you do not go beyond the boundary of the
13268 stack. You should specify this flag if you are running in an
13269 environment with multiple threads, but only rarely need to specify it in
13270 a single-threaded environment since stack overflow is automatically
13271 detected on nearly all systems if there is only one stack.
13273 Note that this switch does not actually cause checking to be done; the
13274 operating system must do that. The switch causes generation of code
13275 to ensure that the operating system sees the stack being extended.
13277 @item -fstack-limit-register=@var{reg}
13278 @itemx -fstack-limit-symbol=@var{sym}
13279 @itemx -fno-stack-limit
13280 @opindex fstack-limit-register
13281 @opindex fstack-limit-symbol
13282 @opindex fno-stack-limit
13283 Generate code to ensure that the stack does not grow beyond a certain value,
13284 either the value of a register or the address of a symbol. If the stack
13285 would grow beyond the value, a signal is raised. For most targets,
13286 the signal is raised before the stack overruns the boundary, so
13287 it is possible to catch the signal without taking special precautions.
13289 For instance, if the stack starts at absolute address @samp{0x80000000}
13290 and grows downwards, you can use the flags
13291 @option{-fstack-limit-symbol=__stack_limit} and
13292 @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
13293 of 128KB@. Note that this may only work with the GNU linker.
13295 @cindex aliasing of parameters
13296 @cindex parameters, aliased
13297 @item -fargument-alias
13298 @itemx -fargument-noalias
13299 @itemx -fargument-noalias-global
13300 @itemx -fargument-noalias-anything
13301 @opindex fargument-alias
13302 @opindex fargument-noalias
13303 @opindex fargument-noalias-global
13304 @opindex fargument-noalias-anything
13305 Specify the possible relationships among parameters and between
13306 parameters and global data.
13308 @option{-fargument-alias} specifies that arguments (parameters) may
13309 alias each other and may alias global storage.@*
13310 @option{-fargument-noalias} specifies that arguments do not alias
13311 each other, but may alias global storage.@*
13312 @option{-fargument-noalias-global} specifies that arguments do not
13313 alias each other and do not alias global storage.
13314 @option{-fargument-noalias-anything} specifies that arguments do not
13315 alias any other storage.
13317 Each language will automatically use whatever option is required by
13318 the language standard. You should not need to use these options yourself.
13320 @item -fleading-underscore
13321 @opindex fleading-underscore
13322 This option and its counterpart, @option{-fno-leading-underscore}, forcibly
13323 change the way C symbols are represented in the object file. One use
13324 is to help link with legacy assembly code.
13326 @strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
13327 generate code that is not binary compatible with code generated without that
13328 switch. Use it to conform to a non-default application binary interface.
13329 Not all targets provide complete support for this switch.
13331 @item -ftls-model=@var{model}
13332 Alter the thread-local storage model to be used (@pxref{Thread-Local}).
13333 The @var{model} argument should be one of @code{global-dynamic},
13334 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
13336 The default without @option{-fpic} is @code{initial-exec}; with
13337 @option{-fpic} the default is @code{global-dynamic}.
13339 @item -fvisibility=@var{default|internal|hidden|protected}
13340 @opindex fvisibility
13341 Set the default ELF image symbol visibility to the specified option---all
13342 symbols will be marked with this unless overridden within the code.
13343 Using this feature can very substantially improve linking and
13344 load times of shared object libraries, produce more optimized
13345 code, provide near-perfect API export and prevent symbol clashes.
13346 It is @strong{strongly} recommended that you use this in any shared objects
13349 Despite the nomenclature, @code{default} always means public ie;
13350 available to be linked against from outside the shared object.
13351 @code{protected} and @code{internal} are pretty useless in real-world
13352 usage so the only other commonly used option will be @code{hidden}.
13353 The default if @option{-fvisibility} isn't specified is
13354 @code{default}, i.e., make every
13355 symbol public---this causes the same behavior as previous versions of
13358 A good explanation of the benefits offered by ensuring ELF
13359 symbols have the correct visibility is given by ``How To Write
13360 Shared Libraries'' by Ulrich Drepper (which can be found at
13361 @w{@uref{http://people.redhat.com/~drepper/}})---however a superior
13362 solution made possible by this option to marking things hidden when
13363 the default is public is to make the default hidden and mark things
13364 public. This is the norm with DLL's on Windows and with @option{-fvisibility=hidden}
13365 and @code{__attribute__ ((visibility("default")))} instead of
13366 @code{__declspec(dllexport)} you get almost identical semantics with
13367 identical syntax. This is a great boon to those working with
13368 cross-platform projects.
13370 For those adding visibility support to existing code, you may find
13371 @samp{#pragma GCC visibility} of use. This works by you enclosing
13372 the declarations you wish to set visibility for with (for example)
13373 @samp{#pragma GCC visibility push(hidden)} and
13374 @samp{#pragma GCC visibility pop}.
13375 Bear in mind that symbol visibility should be viewed @strong{as
13376 part of the API interface contract} and thus all new code should
13377 always specify visibility when it is not the default ie; declarations
13378 only for use within the local DSO should @strong{always} be marked explicitly
13379 as hidden as so to avoid PLT indirection overheads---making this
13380 abundantly clear also aids readability and self-documentation of the code.
13381 Note that due to ISO C++ specification requirements, operator new and
13382 operator delete must always be of default visibility.
13384 Be aware that headers from outside your project, in particular system
13385 headers and headers from any other library you use, may not be
13386 expecting to be compiled with visibility other than the default. You
13387 may need to explicitly say @samp{#pragma GCC visibility push(default)}
13388 before including any such headers.
13390 @samp{extern} declarations are not affected by @samp{-fvisibility}, so
13391 a lot of code can be recompiled with @samp{-fvisibility=hidden} with
13392 no modifications. However, this means that calls to @samp{extern}
13393 functions with no explicit visibility will use the PLT, so it is more
13394 effective to use @samp{__attribute ((visibility))} and/or
13395 @samp{#pragma GCC visibility} to tell the compiler which @samp{extern}
13396 declarations should be treated as hidden.
13398 Note that @samp{-fvisibility} does affect C++ vague linkage
13399 entities. This means that, for instance, an exception class that will
13400 be thrown between DSOs must be explicitly marked with default
13401 visibility so that the @samp{type_info} nodes will be unified between
13404 An overview of these techniques, their benefits and how to use them
13405 is at @w{@uref{http://gcc.gnu.org/wiki/Visibility}}.
13411 @node Environment Variables
13412 @section Environment Variables Affecting GCC
13413 @cindex environment variables
13415 @c man begin ENVIRONMENT
13416 This section describes several environment variables that affect how GCC
13417 operates. Some of them work by specifying directories or prefixes to use
13418 when searching for various kinds of files. Some are used to specify other
13419 aspects of the compilation environment.
13421 Note that you can also specify places to search using options such as
13422 @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
13423 take precedence over places specified using environment variables, which
13424 in turn take precedence over those specified by the configuration of GCC@.
13425 @xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
13426 GNU Compiler Collection (GCC) Internals}.
13431 @c @itemx LC_COLLATE
13433 @c @itemx LC_MONETARY
13434 @c @itemx LC_NUMERIC
13439 @c @findex LC_COLLATE
13440 @findex LC_MESSAGES
13441 @c @findex LC_MONETARY
13442 @c @findex LC_NUMERIC
13446 These environment variables control the way that GCC uses
13447 localization information that allow GCC to work with different
13448 national conventions. GCC inspects the locale categories
13449 @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
13450 so. These locale categories can be set to any value supported by your
13451 installation. A typical value is @samp{en_GB.UTF-8} for English in the United
13452 Kingdom encoded in UTF-8.
13454 The @env{LC_CTYPE} environment variable specifies character
13455 classification. GCC uses it to determine the character boundaries in
13456 a string; this is needed for some multibyte encodings that contain quote
13457 and escape characters that would otherwise be interpreted as a string
13460 The @env{LC_MESSAGES} environment variable specifies the language to
13461 use in diagnostic messages.
13463 If the @env{LC_ALL} environment variable is set, it overrides the value
13464 of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
13465 and @env{LC_MESSAGES} default to the value of the @env{LANG}
13466 environment variable. If none of these variables are set, GCC
13467 defaults to traditional C English behavior.
13471 If @env{TMPDIR} is set, it specifies the directory to use for temporary
13472 files. GCC uses temporary files to hold the output of one stage of
13473 compilation which is to be used as input to the next stage: for example,
13474 the output of the preprocessor, which is the input to the compiler
13477 @item GCC_EXEC_PREFIX
13478 @findex GCC_EXEC_PREFIX
13479 If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
13480 names of the subprograms executed by the compiler. No slash is added
13481 when this prefix is combined with the name of a subprogram, but you can
13482 specify a prefix that ends with a slash if you wish.
13484 If @env{GCC_EXEC_PREFIX} is not set, GCC will attempt to figure out
13485 an appropriate prefix to use based on the pathname it was invoked with.
13487 If GCC cannot find the subprogram using the specified prefix, it
13488 tries looking in the usual places for the subprogram.
13490 The default value of @env{GCC_EXEC_PREFIX} is
13491 @file{@var{prefix}/lib/gcc/} where @var{prefix} is the value
13492 of @code{prefix} when you ran the @file{configure} script.
13494 Other prefixes specified with @option{-B} take precedence over this prefix.
13496 This prefix is also used for finding files such as @file{crt0.o} that are
13499 In addition, the prefix is used in an unusual way in finding the
13500 directories to search for header files. For each of the standard
13501 directories whose name normally begins with @samp{/usr/local/lib/gcc}
13502 (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
13503 replacing that beginning with the specified prefix to produce an
13504 alternate directory name. Thus, with @option{-Bfoo/}, GCC will search
13505 @file{foo/bar} where it would normally search @file{/usr/local/lib/bar}.
13506 These alternate directories are searched first; the standard directories
13509 @item COMPILER_PATH
13510 @findex COMPILER_PATH
13511 The value of @env{COMPILER_PATH} is a colon-separated list of
13512 directories, much like @env{PATH}. GCC tries the directories thus
13513 specified when searching for subprograms, if it can't find the
13514 subprograms using @env{GCC_EXEC_PREFIX}.
13517 @findex LIBRARY_PATH
13518 The value of @env{LIBRARY_PATH} is a colon-separated list of
13519 directories, much like @env{PATH}. When configured as a native compiler,
13520 GCC tries the directories thus specified when searching for special
13521 linker files, if it can't find them using @env{GCC_EXEC_PREFIX}. Linking
13522 using GCC also uses these directories when searching for ordinary
13523 libraries for the @option{-l} option (but directories specified with
13524 @option{-L} come first).
13528 @cindex locale definition
13529 This variable is used to pass locale information to the compiler. One way in
13530 which this information is used is to determine the character set to be used
13531 when character literals, string literals and comments are parsed in C and C++.
13532 When the compiler is configured to allow multibyte characters,
13533 the following values for @env{LANG} are recognized:
13537 Recognize JIS characters.
13539 Recognize SJIS characters.
13541 Recognize EUCJP characters.
13544 If @env{LANG} is not defined, or if it has some other value, then the
13545 compiler will use mblen and mbtowc as defined by the default locale to
13546 recognize and translate multibyte characters.
13550 Some additional environments variables affect the behavior of the
13553 @include cppenv.texi
13557 @node Precompiled Headers
13558 @section Using Precompiled Headers
13559 @cindex precompiled headers
13560 @cindex speed of compilation
13562 Often large projects have many header files that are included in every
13563 source file. The time the compiler takes to process these header files
13564 over and over again can account for nearly all of the time required to
13565 build the project. To make builds faster, GCC allows users to
13566 `precompile' a header file; then, if builds can use the precompiled
13567 header file they will be much faster.
13569 To create a precompiled header file, simply compile it as you would any
13570 other file, if necessary using the @option{-x} option to make the driver
13571 treat it as a C or C++ header file. You will probably want to use a
13572 tool like @command{make} to keep the precompiled header up-to-date when
13573 the headers it contains change.
13575 A precompiled header file will be searched for when @code{#include} is
13576 seen in the compilation. As it searches for the included file
13577 (@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
13578 compiler looks for a precompiled header in each directory just before it
13579 looks for the include file in that directory. The name searched for is
13580 the name specified in the @code{#include} with @samp{.gch} appended. If
13581 the precompiled header file can't be used, it is ignored.
13583 For instance, if you have @code{#include "all.h"}, and you have
13584 @file{all.h.gch} in the same directory as @file{all.h}, then the
13585 precompiled header file will be used if possible, and the original
13586 header will be used otherwise.
13588 Alternatively, you might decide to put the precompiled header file in a
13589 directory and use @option{-I} to ensure that directory is searched
13590 before (or instead of) the directory containing the original header.
13591 Then, if you want to check that the precompiled header file is always
13592 used, you can put a file of the same name as the original header in this
13593 directory containing an @code{#error} command.
13595 This also works with @option{-include}. So yet another way to use
13596 precompiled headers, good for projects not designed with precompiled
13597 header files in mind, is to simply take most of the header files used by
13598 a project, include them from another header file, precompile that header
13599 file, and @option{-include} the precompiled header. If the header files
13600 have guards against multiple inclusion, they will be skipped because
13601 they've already been included (in the precompiled header).
13603 If you need to precompile the same header file for different
13604 languages, targets, or compiler options, you can instead make a
13605 @emph{directory} named like @file{all.h.gch}, and put each precompiled
13606 header in the directory, perhaps using @option{-o}. It doesn't matter
13607 what you call the files in the directory, every precompiled header in
13608 the directory will be considered. The first precompiled header
13609 encountered in the directory that is valid for this compilation will
13610 be used; they're searched in no particular order.
13612 There are many other possibilities, limited only by your imagination,
13613 good sense, and the constraints of your build system.
13615 A precompiled header file can be used only when these conditions apply:
13619 Only one precompiled header can be used in a particular compilation.
13622 A precompiled header can't be used once the first C token is seen. You
13623 can have preprocessor directives before a precompiled header; you can
13624 even include a precompiled header from inside another header, so long as
13625 there are no C tokens before the @code{#include}.
13628 The precompiled header file must be produced for the same language as
13629 the current compilation. You can't use a C precompiled header for a C++
13633 The precompiled header file must have been produced by the same compiler
13634 binary as the current compilation is using.
13637 Any macros defined before the precompiled header is included must
13638 either be defined in the same way as when the precompiled header was
13639 generated, or must not affect the precompiled header, which usually
13640 means that they don't appear in the precompiled header at all.
13642 The @option{-D} option is one way to define a macro before a
13643 precompiled header is included; using a @code{#define} can also do it.
13644 There are also some options that define macros implicitly, like
13645 @option{-O} and @option{-Wdeprecated}; the same rule applies to macros
13648 @item If debugging information is output when using the precompiled
13649 header, using @option{-g} or similar, the same kind of debugging information
13650 must have been output when building the precompiled header. However,
13651 a precompiled header built using @option{-g} can be used in a compilation
13652 when no debugging information is being output.
13654 @item The same @option{-m} options must generally be used when building
13655 and using the precompiled header. @xref{Submodel Options},
13656 for any cases where this rule is relaxed.
13658 @item Each of the following options must be the same when building and using
13659 the precompiled header:
13661 @gccoptlist{-fexceptions -funit-at-a-time}
13664 Some other command-line options starting with @option{-f},
13665 @option{-p}, or @option{-O} must be defined in the same way as when
13666 the precompiled header was generated. At present, it's not clear
13667 which options are safe to change and which are not; the safest choice
13668 is to use exactly the same options when generating and using the
13669 precompiled header. The following are known to be safe:
13671 @gccoptlist{-fmessage-length= -fpreprocessed
13672 -fsched-interblock -fsched-spec -fsched-spec-load -fsched-spec-load-dangerous
13673 -fsched-verbose=<number> -fschedule-insns -fvisibility=
13678 For all of these except the last, the compiler will automatically
13679 ignore the precompiled header if the conditions aren't met. If you
13680 find an option combination that doesn't work and doesn't cause the
13681 precompiled header to be ignored, please consider filing a bug report,
13684 If you do use differing options when generating and using the
13685 precompiled header, the actual behavior will be a mixture of the
13686 behavior for the options. For instance, if you use @option{-g} to
13687 generate the precompiled header but not when using it, you may or may
13688 not get debugging information for routines in the precompiled header.
13690 @node Running Protoize
13691 @section Running Protoize
13693 The program @code{protoize} is an optional part of GCC@. You can use
13694 it to add prototypes to a program, thus converting the program to ISO
13695 C in one respect. The companion program @code{unprotoize} does the
13696 reverse: it removes argument types from any prototypes that are found.
13698 When you run these programs, you must specify a set of source files as
13699 command line arguments. The conversion programs start out by compiling
13700 these files to see what functions they define. The information gathered
13701 about a file @var{foo} is saved in a file named @file{@var{foo}.X}.
13703 After scanning comes actual conversion. The specified files are all
13704 eligible to be converted; any files they include (whether sources or
13705 just headers) are eligible as well.
13707 But not all the eligible files are converted. By default,
13708 @code{protoize} and @code{unprotoize} convert only source and header
13709 files in the current directory. You can specify additional directories
13710 whose files should be converted with the @option{-d @var{directory}}
13711 option. You can also specify particular files to exclude with the
13712 @option{-x @var{file}} option. A file is converted if it is eligible, its
13713 directory name matches one of the specified directory names, and its
13714 name within the directory has not been excluded.
13716 Basic conversion with @code{protoize} consists of rewriting most
13717 function definitions and function declarations to specify the types of
13718 the arguments. The only ones not rewritten are those for varargs
13721 @code{protoize} optionally inserts prototype declarations at the
13722 beginning of the source file, to make them available for any calls that
13723 precede the function's definition. Or it can insert prototype
13724 declarations with block scope in the blocks where undeclared functions
13727 Basic conversion with @code{unprotoize} consists of rewriting most
13728 function declarations to remove any argument types, and rewriting
13729 function definitions to the old-style pre-ISO form.
13731 Both conversion programs print a warning for any function declaration or
13732 definition that they can't convert. You can suppress these warnings
13735 The output from @code{protoize} or @code{unprotoize} replaces the
13736 original source file. The original file is renamed to a name ending
13737 with @samp{.save} (for DOS, the saved filename ends in @samp{.sav}
13738 without the original @samp{.c} suffix). If the @samp{.save} (@samp{.sav}
13739 for DOS) file already exists, then the source file is simply discarded.
13741 @code{protoize} and @code{unprotoize} both depend on GCC itself to
13742 scan the program and collect information about the functions it uses.
13743 So neither of these programs will work until GCC is installed.
13745 Here is a table of the options you can use with @code{protoize} and
13746 @code{unprotoize}. Each option works with both programs unless
13750 @item -B @var{directory}
13751 Look for the file @file{SYSCALLS.c.X} in @var{directory}, instead of the
13752 usual directory (normally @file{/usr/local/lib}). This file contains
13753 prototype information about standard system functions. This option
13754 applies only to @code{protoize}.
13756 @item -c @var{compilation-options}
13757 Use @var{compilation-options} as the options when running @command{gcc} to
13758 produce the @samp{.X} files. The special option @option{-aux-info} is
13759 always passed in addition, to tell @command{gcc} to write a @samp{.X} file.
13761 Note that the compilation options must be given as a single argument to
13762 @code{protoize} or @code{unprotoize}. If you want to specify several
13763 @command{gcc} options, you must quote the entire set of compilation options
13764 to make them a single word in the shell.
13766 There are certain @command{gcc} arguments that you cannot use, because they
13767 would produce the wrong kind of output. These include @option{-g},
13768 @option{-O}, @option{-c}, @option{-S}, and @option{-o} If you include these in
13769 the @var{compilation-options}, they are ignored.
13772 Rename files to end in @samp{.C} (@samp{.cc} for DOS-based file
13773 systems) instead of @samp{.c}. This is convenient if you are converting
13774 a C program to C++. This option applies only to @code{protoize}.
13777 Add explicit global declarations. This means inserting explicit
13778 declarations at the beginning of each source file for each function
13779 that is called in the file and was not declared. These declarations
13780 precede the first function definition that contains a call to an
13781 undeclared function. This option applies only to @code{protoize}.
13783 @item -i @var{string}
13784 Indent old-style parameter declarations with the string @var{string}.
13785 This option applies only to @code{protoize}.
13787 @code{unprotoize} converts prototyped function definitions to old-style
13788 function definitions, where the arguments are declared between the
13789 argument list and the initial @samp{@{}. By default, @code{unprotoize}
13790 uses five spaces as the indentation. If you want to indent with just
13791 one space instead, use @option{-i " "}.
13794 Keep the @samp{.X} files. Normally, they are deleted after conversion
13798 Add explicit local declarations. @code{protoize} with @option{-l} inserts
13799 a prototype declaration for each function in each block which calls the
13800 function without any declaration. This option applies only to
13804 Make no real changes. This mode just prints information about the conversions
13805 that would have been done without @option{-n}.
13808 Make no @samp{.save} files. The original files are simply deleted.
13809 Use this option with caution.
13811 @item -p @var{program}
13812 Use the program @var{program} as the compiler. Normally, the name
13813 @file{gcc} is used.
13816 Work quietly. Most warnings are suppressed.
13819 Print the version number, just like @option{-v} for @command{gcc}.
13822 If you need special compiler options to compile one of your program's
13823 source files, then you should generate that file's @samp{.X} file
13824 specially, by running @command{gcc} on that source file with the
13825 appropriate options and the option @option{-aux-info}. Then run
13826 @code{protoize} on the entire set of files. @code{protoize} will use
13827 the existing @samp{.X} file because it is newer than the source file.
13831 gcc -Dfoo=bar file1.c -aux-info file1.X
13836 You need to include the special files along with the rest in the
13837 @code{protoize} command, even though their @samp{.X} files already
13838 exist, because otherwise they won't get converted.
13840 @xref{Protoize Caveats}, for more information on how to use
13841 @code{protoize} successfully.