1 @c Copyright (C) 1988-2021 Free Software Foundation, Inc.
2 @c This is part of the GCC manual.
3 @c For copying conditions, see the file gcc.texi.
10 @c man begin COPYRIGHT
11 Copyright @copyright{} 1988-2021 Free Software Foundation, Inc.
13 Permission is granted to copy, distribute and/or modify this document
14 under the terms of the GNU Free Documentation License, Version 1.3 or
15 any later version published by the Free Software Foundation; with the
16 Invariant Sections being ``GNU General Public License'' and ``Funding
17 Free Software'', the Front-Cover texts being (a) (see below), and with
18 the Back-Cover Texts being (b) (see below). A copy of the license is
19 included in the gfdl(7) man page.
21 (a) The FSF's Front-Cover Text is:
25 (b) The FSF's Back-Cover Text is:
27 You have freedom to copy and modify this GNU Manual, like GNU
28 software. Copies published by the Free Software Foundation raise
29 funds for GNU development.
31 @c Set file name and title for the man page.
33 @settitle GNU project C and C++ compiler
35 gcc [@option{-c}|@option{-S}|@option{-E}] [@option{-std=}@var{standard}]
36 [@option{-g}] [@option{-pg}] [@option{-O}@var{level}]
37 [@option{-W}@var{warn}@dots{}] [@option{-Wpedantic}]
38 [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
39 [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
40 [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}]
41 [@option{-o} @var{outfile}] [@@@var{file}] @var{infile}@dots{}
43 Only the most useful options are listed here; see below for the
44 remainder. @command{g++} accepts mostly the same options as @command{gcc}.
47 gpl(7), gfdl(7), fsf-funding(7),
48 cpp(1), gcov(1), as(1), ld(1), gdb(1), dbx(1)
49 and the Info entries for @file{gcc}, @file{cpp}, @file{as},
50 @file{ld}, @file{binutils} and @file{gdb}.
53 For instructions on reporting bugs, see
57 See the Info entry for @command{gcc}, or
58 @w{@uref{https://gcc.gnu.org/onlinedocs/gcc/Contributors.html}},
59 for contributors to GCC@.
64 @chapter GCC Command Options
65 @cindex GCC command options
66 @cindex command options
67 @cindex options, GCC command
69 @c man begin DESCRIPTION
70 When you invoke GCC, it normally does preprocessing, compilation,
71 assembly and linking. The ``overall options'' allow you to stop this
72 process at an intermediate stage. For example, the @option{-c} option
73 says not to run the linker. Then the output consists of object files
74 output by the assembler.
75 @xref{Overall Options,,Options Controlling the Kind of Output}.
77 Other options are passed on to one or more stages of processing. Some options
78 control the preprocessor and others the compiler itself. Yet other
79 options control the assembler and linker; most of these are not
80 documented here, since you rarely need to use any of them.
82 @cindex C compilation options
83 Most of the command-line options that you can use with GCC are useful
84 for C programs; when an option is only useful with another language
85 (usually C++), the explanation says so explicitly. If the description
86 for a particular option does not mention a source language, you can use
87 that option with all supported languages.
89 @cindex cross compiling
90 @cindex specifying machine version
91 @cindex specifying compiler version and target machine
92 @cindex compiler version, specifying
93 @cindex target machine, specifying
94 The usual way to run GCC is to run the executable called @command{gcc}, or
95 @command{@var{machine}-gcc} when cross-compiling, or
96 @command{@var{machine}-gcc-@var{version}} to run a specific version of GCC.
97 When you compile C++ programs, you should invoke GCC as @command{g++}
98 instead. @xref{Invoking G++,,Compiling C++ Programs},
99 for information about the differences in behavior between @command{gcc}
100 and @command{g++} when compiling C++ programs.
102 @cindex grouping options
103 @cindex options, grouping
104 The @command{gcc} program accepts options and file names as operands. Many
105 options have multi-letter names; therefore multiple single-letter options
106 may @emph{not} be grouped: @option{-dv} is very different from @w{@samp{-d
109 @cindex order of options
110 @cindex options, order
111 You can mix options and other arguments. For the most part, the order
112 you use doesn't matter. Order does matter when you use several
113 options of the same kind; for example, if you specify @option{-L} more
114 than once, the directories are searched in the order specified. Also,
115 the placement of the @option{-l} option is significant.
117 Many options have long names starting with @samp{-f} or with
118 @samp{-W}---for example,
119 @option{-fmove-loop-invariants}, @option{-Wformat} and so on. Most of
120 these have both positive and negative forms; the negative form of
121 @option{-ffoo} is @option{-fno-foo}. This manual documents
122 only one of these two forms, whichever one is not the default.
124 Some options take one or more arguments typically separated either
125 by a space or by the equals sign (@samp{=}) from the option name.
126 Unless documented otherwise, an argument can be either numeric or
127 a string. Numeric arguments must typically be small unsigned decimal
128 or hexadecimal integers. Hexadecimal arguments must begin with
129 the @samp{0x} prefix. Arguments to options that specify a size
130 threshold of some sort may be arbitrarily large decimal or hexadecimal
131 integers followed by a byte size suffix designating a multiple of bytes
132 such as @code{kB} and @code{KiB} for kilobyte and kibibyte, respectively,
133 @code{MB} and @code{MiB} for megabyte and mebibyte, @code{GB} and
134 @code{GiB} for gigabyte and gigibyte, and so on. Such arguments are
135 designated by @var{byte-size} in the following text. Refer to the NIST,
136 IEC, and other relevant national and international standards for the full
137 listing and explanation of the binary and decimal byte size prefixes.
141 @xref{Option Index}, for an index to GCC's options.
144 * Option Summary:: Brief list of all options, without explanations.
145 * Overall Options:: Controlling the kind of output:
146 an executable, object files, assembler files,
147 or preprocessed source.
148 * Invoking G++:: Compiling C++ programs.
149 * C Dialect Options:: Controlling the variant of C language compiled.
150 * C++ Dialect Options:: Variations on C++.
151 * Objective-C and Objective-C++ Dialect Options:: Variations on Objective-C
153 * Diagnostic Message Formatting Options:: Controlling how diagnostics should
155 * Warning Options:: How picky should the compiler be?
156 * Static Analyzer Options:: More expensive warnings.
157 * Debugging Options:: Producing debuggable code.
158 * Optimize Options:: How much optimization?
159 * Instrumentation Options:: Enabling profiling and extra run-time error checking.
160 * Preprocessor Options:: Controlling header files and macro definitions.
161 Also, getting dependency information for Make.
162 * Assembler Options:: Passing options to the assembler.
163 * Link Options:: Specifying libraries and so on.
164 * Directory Options:: Where to find header files and libraries.
165 Where to find the compiler executable files.
166 * Code Gen Options:: Specifying conventions for function calls, data layout
168 * Developer Options:: Printing GCC configuration info, statistics, and
170 * Submodel Options:: Target-specific options, such as compiling for a
171 specific processor variant.
172 * Spec Files:: How to pass switches to sub-processes.
173 * Environment Variables:: Env vars that affect GCC.
174 * Precompiled Headers:: Compiling a header once, and using it many times.
175 * C++ Modules:: Experimental C++20 module system.
181 @section Option Summary
183 Here is a summary of all the options, grouped by type. Explanations are
184 in the following sections.
187 @item Overall Options
188 @xref{Overall Options,,Options Controlling the Kind of Output}.
189 @gccoptlist{-c -S -E -o @var{file} @gol
190 -dumpbase @var{dumpbase} -dumpbase-ext @var{auxdropsuf} @gol
191 -dumpdir @var{dumppfx} -x @var{language} @gol
192 -v -### --help@r{[}=@var{class}@r{[},@dots{}@r{]]} --target-help --version @gol
193 -pass-exit-codes -pipe -specs=@var{file} -wrapper @gol
194 @@@var{file} -ffile-prefix-map=@var{old}=@var{new} @gol
195 -fplugin=@var{file} -fplugin-arg-@var{name}=@var{arg} @gol
196 -fdump-ada-spec@r{[}-slim@r{]} -fada-spec-parent=@var{unit} -fdump-go-spec=@var{file}}
198 @item C Language Options
199 @xref{C Dialect Options,,Options Controlling C Dialect}.
200 @gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename} @gol
201 -fallow-parameterless-variadic-functions -fno-asm @gol
202 -fno-builtin -fno-builtin-@var{function} -fcond-mismatch @gol
203 -ffreestanding -fgimple -fgnu-tm -fgnu89-inline -fhosted @gol
204 -flax-vector-conversions -fms-extensions @gol
205 -foffload=@var{arg} -foffload-options=@var{arg} @gol
206 -fopenacc -fopenacc-dim=@var{geom} @gol
207 -fopenmp -fopenmp-simd @gol
208 -fpermitted-flt-eval-methods=@var{standard} @gol
209 -fplan9-extensions -fsigned-bitfields -funsigned-bitfields @gol
210 -fsigned-char -funsigned-char -fsso-struct=@var{endianness}}
212 @item C++ Language Options
213 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
214 @gccoptlist{-fabi-version=@var{n} -fno-access-control @gol
215 -faligned-new=@var{n} -fargs-in-order=@var{n} -fchar8_t -fcheck-new @gol
216 -fconstexpr-depth=@var{n} -fconstexpr-cache-depth=@var{n} @gol
217 -fconstexpr-loop-limit=@var{n} -fconstexpr-ops-limit=@var{n} @gol
218 -fno-elide-constructors @gol
219 -fno-enforce-eh-specs @gol
220 -fno-gnu-keywords @gol
221 -fno-implicit-templates @gol
222 -fno-implicit-inline-templates @gol
223 -fno-implement-inlines @gol
224 -fmodule-header@r{[}=@var{kind}@r{]} -fmodule-only -fmodules-ts @gol
225 -fmodule-implicit-inline @gol
226 -fno-module-lazy @gol
227 -fmodule-mapper=@var{specification} @gol
228 -fmodule-version-ignore @gol
230 -fnew-inheriting-ctors @gol
231 -fnew-ttp-matching @gol
232 -fno-nonansi-builtins -fnothrow-opt -fno-operator-names @gol
233 -fno-optional-diags -fpermissive @gol
234 -fno-pretty-templates @gol
235 -fno-rtti -fsized-deallocation @gol
236 -ftemplate-backtrace-limit=@var{n} @gol
237 -ftemplate-depth=@var{n} @gol
238 -fno-threadsafe-statics -fuse-cxa-atexit @gol
239 -fno-weak -nostdinc++ @gol
240 -fvisibility-inlines-hidden @gol
241 -fvisibility-ms-compat @gol
242 -fext-numeric-literals @gol
243 -flang-info-include-translate@r{[}=@var{header}@r{]} @gol
244 -flang-info-include-translate-not @gol
245 -flang-info-module-cmi@r{[}=@var{module}@r{]} @gol
246 -stdlib=@var{libstdc++,libc++} @gol
247 -Wabi-tag -Wcatch-value -Wcatch-value=@var{n} @gol
248 -Wno-class-conversion -Wclass-memaccess @gol
249 -Wcomma-subscript -Wconditionally-supported @gol
250 -Wno-conversion-null -Wctad-maybe-unsupported @gol
251 -Wctor-dtor-privacy -Wno-delete-incomplete @gol
252 -Wdelete-non-virtual-dtor -Wno-deprecated-array-compare @gol
253 -Wdeprecated-copy -Wdeprecated-copy-dtor @gol
254 -Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion @gol
255 -Weffc++ -Wno-exceptions -Wextra-semi -Wno-inaccessible-base @gol
256 -Wno-inherited-variadic-ctor -Wno-init-list-lifetime @gol
257 -Winvalid-imported-macros @gol
258 -Wno-invalid-offsetof -Wno-literal-suffix @gol
259 -Wmismatched-new-delete -Wmismatched-tags @gol
260 -Wmultiple-inheritance -Wnamespaces -Wnarrowing @gol
261 -Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor @gol
262 -Wpessimizing-move -Wno-placement-new -Wplacement-new=@var{n} @gol
263 -Wrange-loop-construct -Wredundant-move -Wredundant-tags @gol
264 -Wreorder -Wregister @gol
265 -Wstrict-null-sentinel -Wno-subobject-linkage -Wtemplates @gol
266 -Wno-non-template-friend -Wold-style-cast @gol
267 -Woverloaded-virtual -Wno-pmf-conversions -Wsign-promo @gol
268 -Wsized-deallocation -Wsuggest-final-methods @gol
269 -Wsuggest-final-types -Wsuggest-override @gol
270 -Wno-terminate -Wuseless-cast -Wno-vexing-parse @gol
271 -Wvirtual-inheritance @gol
272 -Wno-virtual-move-assign -Wvolatile -Wzero-as-null-pointer-constant}
274 @item Objective-C and Objective-C++ Language Options
275 @xref{Objective-C and Objective-C++ Dialect Options,,Options Controlling
276 Objective-C and Objective-C++ Dialects}.
277 @gccoptlist{-fconstant-string-class=@var{class-name} @gol
278 -fgnu-runtime -fnext-runtime @gol
279 -fno-nil-receivers @gol
280 -fobjc-abi-version=@var{n} @gol
281 -fobjc-call-cxx-cdtors @gol
282 -fobjc-direct-dispatch @gol
283 -fobjc-exceptions @gol
286 -fobjc-std=objc1 @gol
287 -fno-local-ivars @gol
288 -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]} @gol
289 -freplace-objc-classes @gol
292 -Wassign-intercept -Wno-property-assign-default @gol
293 -Wno-protocol -Wobjc-root-class -Wselector @gol
294 -Wstrict-selector-match @gol
295 -Wundeclared-selector}
297 @item Diagnostic Message Formatting Options
298 @xref{Diagnostic Message Formatting Options,,Options to Control Diagnostic Messages Formatting}.
299 @gccoptlist{-fmessage-length=@var{n} @gol
300 -fdiagnostics-plain-output @gol
301 -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]} @gol
302 -fdiagnostics-color=@r{[}auto@r{|}never@r{|}always@r{]} @gol
303 -fdiagnostics-urls=@r{[}auto@r{|}never@r{|}always@r{]} @gol
304 -fdiagnostics-format=@r{[}text@r{|}json@r{]} @gol
305 -fno-diagnostics-show-option -fno-diagnostics-show-caret @gol
306 -fno-diagnostics-show-labels -fno-diagnostics-show-line-numbers @gol
307 -fno-diagnostics-show-cwe @gol
308 -fdiagnostics-minimum-margin-width=@var{width} @gol
309 -fdiagnostics-parseable-fixits -fdiagnostics-generate-patch @gol
310 -fdiagnostics-show-template-tree -fno-elide-type @gol
311 -fdiagnostics-path-format=@r{[}none@r{|}separate-events@r{|}inline-events@r{]} @gol
312 -fdiagnostics-show-path-depths @gol
313 -fno-show-column @gol
314 -fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]} @gol
315 -fdiagnostics-column-origin=@var{origin} @gol
316 -fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]}}
318 @item Warning Options
319 @xref{Warning Options,,Options to Request or Suppress Warnings}.
320 @gccoptlist{-fsyntax-only -fmax-errors=@var{n} -Wpedantic @gol
321 -pedantic-errors @gol
322 -w -Wextra -Wall -Wabi=@var{n} @gol
323 -Waddress -Wno-address-of-packed-member -Waggregate-return @gol
324 -Walloc-size-larger-than=@var{byte-size} -Walloc-zero @gol
325 -Walloca -Walloca-larger-than=@var{byte-size} @gol
326 -Wno-aggressive-loop-optimizations @gol
327 -Warith-conversion @gol
328 -Warray-bounds -Warray-bounds=@var{n} -Warray-compare @gol
329 -Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias @gol
330 -Wno-attribute-warning @gol
331 -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{]} @gol
332 -Wbool-compare -Wbool-operation @gol
333 -Wno-builtin-declaration-mismatch @gol
334 -Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat @gol
335 -Wc11-c2x-compat @gol
336 -Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat @gol
338 -Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions @gol
339 -Wno-c++20-extensions -Wno-c++23-extensions @gol
340 -Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual @gol
341 -Wchar-subscripts @gol
342 -Wclobbered -Wcomment @gol
343 -Wconversion -Wno-coverage-mismatch -Wno-cpp @gol
344 -Wdangling-else -Wdate-time @gol
345 -Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init @gol
346 -Wdisabled-optimization @gol
347 -Wno-discarded-array-qualifiers -Wno-discarded-qualifiers @gol
348 -Wno-div-by-zero -Wdouble-promotion @gol
349 -Wduplicated-branches -Wduplicated-cond @gol
350 -Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion @gol
351 -Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors @gol
352 -Wfloat-conversion -Wfloat-equal -Wformat -Wformat=2 @gol
353 -Wno-format-contains-nul -Wno-format-extra-args @gol
354 -Wformat-nonliteral -Wformat-overflow=@var{n} @gol
355 -Wformat-security -Wformat-signedness -Wformat-truncation=@var{n} @gol
356 -Wformat-y2k -Wframe-address @gol
357 -Wframe-larger-than=@var{byte-size} -Wno-free-nonheap-object @gol
358 -Wno-if-not-aligned -Wno-ignored-attributes @gol
359 -Wignored-qualifiers -Wno-incompatible-pointer-types @gol
360 -Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=@var{n} @gol
361 -Wno-implicit-function-declaration -Wno-implicit-int @gol
362 -Winfinite-recursion @gol
363 -Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context @gol
364 -Wno-int-to-pointer-cast -Wno-invalid-memory-model @gol
365 -Winvalid-pch -Wjump-misses-init -Wlarger-than=@var{byte-size} @gol
366 -Wlogical-not-parentheses -Wlogical-op -Wlong-long @gol
367 -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized @gol
368 -Wmemset-elt-size -Wmemset-transposed-args @gol
369 -Wmisleading-indentation -Wmissing-attributes -Wmissing-braces @gol
370 -Wmissing-field-initializers -Wmissing-format-attribute @gol
371 -Wmissing-include-dirs -Wmissing-noreturn -Wno-missing-profile @gol
372 -Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare @gol
373 -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} @gol
374 -Wnull-dereference -Wno-odr @gol
375 -Wopenacc-parallelism @gol
377 -Wno-overflow -Woverlength-strings -Wno-override-init-side-effects @gol
378 -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded @gol
379 -Wparentheses -Wno-pedantic-ms-format @gol
380 -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast @gol
381 -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol
382 -Wrestrict -Wno-return-local-addr -Wreturn-type @gol
383 -Wno-scalar-storage-order -Wsequence-point @gol
384 -Wshadow -Wshadow=global -Wshadow=local -Wshadow=compatible-local @gol
385 -Wno-shadow-ivar @gol
386 -Wno-shift-count-negative -Wno-shift-count-overflow -Wshift-negative-value @gol
387 -Wno-shift-overflow -Wshift-overflow=@var{n} @gol
388 -Wsign-compare -Wsign-conversion @gol
389 -Wno-sizeof-array-argument @gol
390 -Wsizeof-array-div @gol
391 -Wsizeof-pointer-div -Wsizeof-pointer-memaccess @gol
392 -Wstack-protector -Wstack-usage=@var{byte-size} -Wstrict-aliasing @gol
393 -Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n} @gol
394 -Wstring-compare @gol
395 -Wno-stringop-overflow -Wno-stringop-overread @gol
396 -Wno-stringop-truncation @gol
397 -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}malloc@r{]} @gol
398 -Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum @gol
399 -Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand @gol
400 -Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs @gol
401 -Wtsan -Wtype-limits -Wundef @gol
402 -Wuninitialized -Wunknown-pragmas @gol
403 -Wunsuffixed-float-constants -Wunused @gol
404 -Wunused-but-set-parameter -Wunused-but-set-variable @gol
405 -Wunused-const-variable -Wunused-const-variable=@var{n} @gol
406 -Wunused-function -Wunused-label -Wunused-local-typedefs @gol
408 -Wunused-parameter -Wno-unused-result @gol
409 -Wunused-value -Wunused-variable @gol
410 -Wno-varargs -Wvariadic-macros @gol
411 -Wvector-operation-performance @gol
412 -Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than @gol
413 -Wvolatile-register-var -Wwrite-strings @gol
414 -Wzero-length-bounds}
416 @item Static Analyzer Options
419 -fanalyzer-call-summaries @gol
420 -fanalyzer-checker=@var{name} @gol
421 -fno-analyzer-feasibility @gol
422 -fanalyzer-fine-grained @gol
423 -fanalyzer-state-merge @gol
424 -fanalyzer-state-purge @gol
425 -fanalyzer-transitivity @gol
426 -fanalyzer-verbose-edges @gol
427 -fanalyzer-verbose-state-changes @gol
428 -fanalyzer-verbosity=@var{level} @gol
430 -fdump-analyzer-stderr @gol
431 -fdump-analyzer-callgraph @gol
432 -fdump-analyzer-exploded-graph @gol
433 -fdump-analyzer-exploded-nodes @gol
434 -fdump-analyzer-exploded-nodes-2 @gol
435 -fdump-analyzer-exploded-nodes-3 @gol
436 -fdump-analyzer-exploded-paths @gol
437 -fdump-analyzer-feasibility @gol
438 -fdump-analyzer-json @gol
439 -fdump-analyzer-state-purge @gol
440 -fdump-analyzer-supergraph @gol
441 -Wno-analyzer-double-fclose @gol
442 -Wno-analyzer-double-free @gol
443 -Wno-analyzer-exposure-through-output-file @gol
444 -Wno-analyzer-file-leak @gol
445 -Wno-analyzer-free-of-non-heap @gol
446 -Wno-analyzer-malloc-leak @gol
447 -Wno-analyzer-mismatching-deallocation @gol
448 -Wno-analyzer-null-argument @gol
449 -Wno-analyzer-null-dereference @gol
450 -Wno-analyzer-possible-null-argument @gol
451 -Wno-analyzer-possible-null-dereference @gol
452 -Wno-analyzer-shift-count-negative @gol
453 -Wno-analyzer-shift-count-overflow @gol
454 -Wno-analyzer-stale-setjmp-buffer @gol
455 -Wno-analyzer-tainted-allocation-size @gol
456 -Wno-analyzer-tainted-array-index @gol
457 -Wno-analyzer-tainted-divisor @gol
458 -Wno-analyzer-tainted-offset @gol
459 -Wno-analyzer-tainted-size @gol
460 -Wanalyzer-too-complex @gol
461 -Wno-analyzer-unsafe-call-within-signal-handler @gol
462 -Wno-analyzer-use-after-free @gol
463 -Wno-analyzer-use-of-pointer-in-stale-stack-frame @gol
464 -Wno-analyzer-use-of-uninitialized-value @gol
465 -Wno-analyzer-write-to-const @gol
466 -Wno-analyzer-write-to-string-literal @gol
469 @item C and Objective-C-only Warning Options
470 @gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol
471 -Wmissing-parameter-type -Wmissing-prototypes -Wnested-externs @gol
472 -Wold-style-declaration -Wold-style-definition @gol
473 -Wstrict-prototypes -Wtraditional -Wtraditional-conversion @gol
474 -Wdeclaration-after-statement -Wpointer-sign}
476 @item Debugging Options
477 @xref{Debugging Options,,Options for Debugging Your Program}.
478 @gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version} @gol
479 -gbtf -gctf -gctf@var{level} @gol
480 -ggdb -grecord-gcc-switches -gno-record-gcc-switches @gol
481 -gstabs -gstabs+ -gstrict-dwarf -gno-strict-dwarf @gol
482 -gas-loc-support -gno-as-loc-support @gol
483 -gas-locview-support -gno-as-locview-support @gol
484 -gcolumn-info -gno-column-info -gdwarf32 -gdwarf64 @gol
485 -gstatement-frontiers -gno-statement-frontiers @gol
486 -gvariable-location-views -gno-variable-location-views @gol
487 -ginternal-reset-location-views -gno-internal-reset-location-views @gol
488 -ginline-points -gno-inline-points @gol
489 -gvms -gxcoff -gxcoff+ -gz@r{[}=@var{type}@r{]} @gol
490 -gsplit-dwarf -gdescribe-dies -gno-describe-dies @gol
491 -fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section @gol
492 -fno-eliminate-unused-debug-types @gol
493 -femit-struct-debug-baseonly -femit-struct-debug-reduced @gol
494 -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} @gol
495 -fno-eliminate-unused-debug-symbols -femit-class-debug-always @gol
496 -fno-merge-debug-strings -fno-dwarf2-cfi-asm @gol
497 -fvar-tracking -fvar-tracking-assignments}
499 @item Optimization Options
500 @xref{Optimize Options,,Options that Control Optimization}.
501 @gccoptlist{-faggressive-loop-optimizations @gol
502 -falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
503 -falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
504 -falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
505 -falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
506 -fno-allocation-dce -fallow-store-data-races @gol
507 -fassociative-math -fauto-profile -fauto-profile[=@var{path}] @gol
508 -fauto-inc-dec -fbranch-probabilities @gol
510 -fcombine-stack-adjustments -fconserve-stack @gol
511 -fcompare-elim -fcprop-registers -fcrossjumping @gol
512 -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules @gol
513 -fcx-limited-range @gol
514 -fdata-sections -fdce -fdelayed-branch @gol
515 -fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively @gol
516 -fdevirtualize-at-ltrans -fdse @gol
517 -fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects @gol
518 -ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style} @gol
520 -fforward-propagate -ffp-contract=@var{style} -ffunction-sections @gol
521 -fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity @gol
522 -fgcse-sm -fhoist-adjacent-loads -fif-conversion @gol
523 -fif-conversion2 -findirect-inlining @gol
524 -finline-functions -finline-functions-called-once -finline-limit=@var{n} @gol
525 -finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone @gol
526 -fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const @gol
527 -fipa-reference -fipa-reference-addressable @gol
528 -fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm} @gol
529 -flive-patching=@var{level} @gol
530 -fira-region=@var{region} -fira-hoist-pressure @gol
531 -fira-loop-pressure -fno-ira-share-save-slots @gol
532 -fno-ira-share-spill-slots @gol
533 -fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute @gol
534 -fivopts -fkeep-inline-functions -fkeep-static-functions @gol
535 -fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage @gol
536 -floop-block -floop-interchange -floop-strip-mine @gol
537 -floop-unroll-and-jam -floop-nest-optimize @gol
538 -floop-parallelize-all -flra-remat -flto -flto-compression-level @gol
539 -flto-partition=@var{alg} -fmerge-all-constants @gol
540 -fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves @gol
541 -fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg @gol
542 -fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse @gol
543 -fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole @gol
544 -fno-peephole2 -fno-printf-return-value -fno-sched-interblock @gol
545 -fno-sched-spec -fno-signed-zeros @gol
546 -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss @gol
547 -fomit-frame-pointer -foptimize-sibling-calls @gol
548 -fpartial-inlining -fpeel-loops -fpredictive-commoning @gol
549 -fprefetch-loop-arrays @gol
550 -fprofile-correction @gol
551 -fprofile-use -fprofile-use=@var{path} -fprofile-partial-training @gol
552 -fprofile-values -fprofile-reorder-functions @gol
553 -freciprocal-math -free -frename-registers -freorder-blocks @gol
554 -freorder-blocks-algorithm=@var{algorithm} @gol
555 -freorder-blocks-and-partition -freorder-functions @gol
556 -frerun-cse-after-loop -freschedule-modulo-scheduled-loops @gol
557 -frounding-math -fsave-optimization-record @gol
558 -fsched2-use-superblocks -fsched-pressure @gol
559 -fsched-spec-load -fsched-spec-load-dangerous @gol
560 -fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}] @gol
561 -fsched-group-heuristic -fsched-critical-path-heuristic @gol
562 -fsched-spec-insn-heuristic -fsched-rank-heuristic @gol
563 -fsched-last-insn-heuristic -fsched-dep-count-heuristic @gol
564 -fschedule-fusion @gol
565 -fschedule-insns -fschedule-insns2 -fsection-anchors @gol
566 -fselective-scheduling -fselective-scheduling2 @gol
567 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops @gol
568 -fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate @gol
569 -fsignaling-nans @gol
570 -fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops@gol
572 -fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt @gol
573 -fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing @gol
574 -fthread-jumps -ftracer -ftree-bit-ccp @gol
575 -ftree-builtin-call-dce -ftree-ccp -ftree-ch @gol
576 -ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts @gol
577 -ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting @gol
578 -ftree-loop-if-convert -ftree-loop-im @gol
579 -ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns @gol
580 -ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize @gol
581 -ftree-loop-vectorize @gol
582 -ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta @gol
583 -ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra @gol
584 -ftree-switch-conversion -ftree-tail-merge @gol
585 -ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init @gol
586 -funconstrained-commons -funit-at-a-time -funroll-all-loops @gol
587 -funroll-loops -funsafe-math-optimizations -funswitch-loops @gol
588 -fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt @gol
589 -fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs @gol
590 --param @var{name}=@var{value}
591 -O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz}
593 @item Program Instrumentation Options
594 @xref{Instrumentation Options,,Program Instrumentation Options}.
595 @gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage @gol
596 -fprofile-abs-path @gol
597 -fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path} @gol
598 -fprofile-info-section -fprofile-info-section=@var{name} @gol
599 -fprofile-note=@var{path} -fprofile-prefix-path=@var{path} @gol
600 -fprofile-update=@var{method} -fprofile-filter-files=@var{regex} @gol
601 -fprofile-exclude-files=@var{regex} @gol
602 -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} @gol
603 -fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} @gol
604 -fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... @gol
605 -fsanitize-undefined-trap-on-error -fbounds-check @gol
606 -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} @gol
607 -fharden-compares -fharden-conditional-branches @gol
608 -fstack-protector -fstack-protector-all -fstack-protector-strong @gol
609 -fstack-protector-explicit -fstack-check @gol
610 -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol
611 -fno-stack-limit -fsplit-stack @gol
612 -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} @gol
613 -fvtv-counts -fvtv-debug @gol
614 -finstrument-functions @gol
615 -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} @gol
616 -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}} @gol
617 -fprofile-prefix-map=@var{old}=@var{new}
619 @item Preprocessor Options
620 @xref{Preprocessor Options,,Options Controlling the Preprocessor}.
621 @gccoptlist{-A@var{question}=@var{answer} @gol
622 -A-@var{question}@r{[}=@var{answer}@r{]} @gol
623 -C -CC -D@var{macro}@r{[}=@var{defn}@r{]} @gol
624 -dD -dI -dM -dN -dU @gol
625 -fdebug-cpp -fdirectives-only -fdollars-in-identifiers @gol
626 -fexec-charset=@var{charset} -fextended-identifiers @gol
627 -finput-charset=@var{charset} -flarge-source-files @gol
628 -fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth} @gol
629 -fno-canonical-system-headers -fpch-deps -fpch-preprocess @gol
630 -fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion @gol
631 -fwide-exec-charset=@var{charset} -fworking-directory @gol
632 -H -imacros @var{file} -include @var{file} @gol
633 -M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules @gol
634 -no-integrated-cpp -P -pthread -remap @gol
635 -traditional -traditional-cpp -trigraphs @gol
636 -U@var{macro} -undef @gol
637 -Wp,@var{option} -Xpreprocessor @var{option}}
639 @item Assembler Options
640 @xref{Assembler Options,,Passing Options to the Assembler}.
641 @gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
644 @xref{Link Options,,Options for Linking}.
645 @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} @gol
646 -nostartfiles -nodefaultlibs -nolibc -nostdlib @gol
647 -e @var{entry} --entry=@var{entry} @gol
648 -pie -pthread -r -rdynamic @gol
649 -s -static -static-pie -static-libgcc -static-libstdc++ @gol
650 -static-libasan -static-libtsan -static-liblsan -static-libubsan @gol
651 -shared -shared-libgcc -symbolic @gol
652 -T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol
653 -u @var{symbol} -z @var{keyword}}
655 @item Directory Options
656 @xref{Directory Options,,Options for Directory Search}.
657 @gccoptlist{-B@var{prefix} -I@var{dir} -I- @gol
658 -idirafter @var{dir} @gol
659 -imacros @var{file} -imultilib @var{dir} @gol
660 -iplugindir=@var{dir} -iprefix @var{file} @gol
661 -iquote @var{dir} -isysroot @var{dir} -isystem @var{dir} @gol
662 -iwithprefix @var{dir} -iwithprefixbefore @var{dir} @gol
663 -L@var{dir} -no-canonical-prefixes --no-sysroot-suffix @gol
664 -nostdinc -nostdinc++ --sysroot=@var{dir}}
666 @item Code Generation Options
667 @xref{Code Gen Options,,Options for Code Generation Conventions}.
668 @gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} @gol
669 -ffixed-@var{reg} -fexceptions @gol
670 -fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables @gol
671 -fasynchronous-unwind-tables @gol
673 -finhibit-size-directive -fcommon -fno-ident @gol
674 -fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt @gol
675 -fno-jump-tables -fno-bit-tests @gol
676 -frecord-gcc-switches @gol
677 -freg-struct-return -fshort-enums -fshort-wchar @gol
678 -fverbose-asm -fpack-struct[=@var{n}] @gol
679 -fleading-underscore -ftls-model=@var{model} @gol
680 -fstack-reuse=@var{reuse_level} @gol
681 -ftrampolines -ftrapv -fwrapv @gol
682 -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} @gol
683 -fstrict-volatile-bitfields -fsync-libcalls}
685 @item Developer Options
686 @xref{Developer Options,,GCC Developer Options}.
687 @gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol
688 -dumpfullversion -fcallgraph-info@r{[}=su,da@r{]}
689 -fchecking -fchecking=@var{n}
690 -fdbg-cnt-list @gol -fdbg-cnt=@var{counter-value-list} @gol
691 -fdisable-ipa-@var{pass_name} @gol
692 -fdisable-rtl-@var{pass_name} @gol
693 -fdisable-rtl-@var{pass-name}=@var{range-list} @gol
694 -fdisable-tree-@var{pass_name} @gol
695 -fdisable-tree-@var{pass-name}=@var{range-list} @gol
696 -fdump-debug -fdump-earlydebug @gol
697 -fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links @gol
698 -fdump-final-insns@r{[}=@var{file}@r{]} @gol
699 -fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline @gol
701 -fdump-lang-@var{switch} @gol
702 -fdump-lang-@var{switch}-@var{options} @gol
703 -fdump-lang-@var{switch}-@var{options}=@var{filename} @gol
705 -fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename} @gol
706 -fdump-statistics @gol
708 -fdump-tree-@var{switch} @gol
709 -fdump-tree-@var{switch}-@var{options} @gol
710 -fdump-tree-@var{switch}-@var{options}=@var{filename} @gol
711 -fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second @gol
712 -fenable-@var{kind}-@var{pass} @gol
713 -fenable-@var{kind}-@var{pass}=@var{range-list} @gol
714 -fira-verbose=@var{n} @gol
715 -flto-report -flto-report-wpa -fmem-report-wpa @gol
716 -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report @gol
717 -fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]} @gol
718 -fprofile-report @gol
719 -frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
720 -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose @gol
721 -fstats -fstack-usage -ftime-report -ftime-report-details @gol
722 -fvar-tracking-assignments-toggle -gtoggle @gol
723 -print-file-name=@var{library} -print-libgcc-file-name @gol
724 -print-multi-directory -print-multi-lib -print-multi-os-directory @gol
725 -print-prog-name=@var{program} -print-search-dirs -Q @gol
726 -print-sysroot -print-sysroot-headers-suffix @gol
727 -save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}
729 @item Machine-Dependent Options
730 @xref{Submodel Options,,Machine-Dependent Options}.
731 @c This list is ordered alphanumerically by subsection name.
732 @c Try and put the significant identifier (CPU or system) first,
733 @c so users have a clue at guessing where the ones they want will be.
735 @emph{AArch64 Options}
736 @gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian @gol
737 -mgeneral-regs-only @gol
738 -mcmodel=tiny -mcmodel=small -mcmodel=large @gol
739 -mstrict-align -mno-strict-align @gol
740 -momit-leaf-frame-pointer @gol
741 -mtls-dialect=desc -mtls-dialect=traditional @gol
742 -mtls-size=@var{size} @gol
743 -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 @gol
744 -mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div @gol
745 -mpc-relative-literal-loads @gol
746 -msign-return-address=@var{scope} @gol
747 -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}
748 +@var{b-key}]|@var{bti} @gol
749 -mharden-sls=@var{opts} @gol
750 -march=@var{name} -mcpu=@var{name} -mtune=@var{name} @gol
751 -moverride=@var{string} -mverbose-cost-dump @gol
752 -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg} @gol
753 -mstack-protector-guard-offset=@var{offset} -mtrack-speculation @gol
756 @emph{Adapteva Epiphany Options}
757 @gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs @gol
758 -mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf @gol
759 -msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num} @gol
760 -mround-nearest -mlong-calls -mshort-calls -msmall16 @gol
761 -mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num} @gol
762 -msplit-vecmove-early -m1reg-@var{reg}}
764 @emph{AMD GCN Options}
765 @gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}}
768 @gccoptlist{-mbarrel-shifter -mjli-always @gol
769 -mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700 @gol
770 -mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr @gol
771 -mea -mno-mpy -mmul32x16 -mmul64 -matomic @gol
772 -mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap @gol
773 -mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape @gol
774 -mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof @gol
775 -mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved @gol
776 -mrgf-banked-regs -mlpc-width=@var{width} -G @var{num} @gol
777 -mvolatile-cache -mtp-regno=@var{regno} @gol
778 -malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc @gol
779 -mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi @gol
780 -mexpand-adddi -mindexed-loads -mlra -mlra-priority-none @gol
781 -mlra-priority-compact -mlra-priority-noncompact -mmillicode @gol
782 -mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level} @gol
783 -mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame @gol
784 -munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo} @gol
785 -mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index}
788 @gccoptlist{-mapcs-frame -mno-apcs-frame @gol
789 -mabi=@var{name} @gol
790 -mapcs-stack-check -mno-apcs-stack-check @gol
791 -mapcs-reentrant -mno-apcs-reentrant @gol
792 -mgeneral-regs-only @gol
793 -msched-prolog -mno-sched-prolog @gol
794 -mlittle-endian -mbig-endian @gol
796 -mfloat-abi=@var{name} @gol
797 -mfp16-format=@var{name}
798 -mthumb-interwork -mno-thumb-interwork @gol
799 -mcpu=@var{name} -march=@var{name} -mfpu=@var{name} @gol
800 -mtune=@var{name} -mprint-tune-info @gol
801 -mstructure-size-boundary=@var{n} @gol
802 -mabort-on-noreturn @gol
803 -mlong-calls -mno-long-calls @gol
804 -msingle-pic-base -mno-single-pic-base @gol
805 -mpic-register=@var{reg} @gol
806 -mnop-fun-dllimport @gol
807 -mpoke-function-name @gol
808 -mthumb -marm -mflip-thumb @gol
809 -mtpcs-frame -mtpcs-leaf-frame @gol
810 -mcaller-super-interworking -mcallee-super-interworking @gol
811 -mtp=@var{name} -mtls-dialect=@var{dialect} @gol
812 -mword-relocations @gol
813 -mfix-cortex-m3-ldrd @gol
814 -munaligned-access @gol
815 -mneon-for-64bits @gol
816 -mslow-flash-data @gol
817 -masm-syntax-unified @gol
819 -mverbose-cost-dump @gol
822 -mfix-cmse-cve-2021-35465 @gol
826 @gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args @gol
827 -mbranch-cost=@var{cost} @gol
828 -mcall-prologues -mgas-isr-prologues -mint8 @gol
829 -mdouble=@var{bits} -mlong-double=@var{bits} @gol
830 -mn_flash=@var{size} -mno-interrupts @gol
831 -mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack @gol
832 -mfract-convert-truncate @gol
833 -mshort-calls -nodevicelib -nodevicespecs @gol
834 -Waddr-space-convert -Wmisspelled-isr}
836 @emph{Blackfin Options}
837 @gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} @gol
838 -msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer @gol
839 -mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly @gol
840 -mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library @gol
841 -mno-id-shared-library -mshared-library-id=@var{n} @gol
842 -mleaf-id-shared-library -mno-leaf-id-shared-library @gol
843 -msep-data -mno-sep-data -mlong-calls -mno-long-calls @gol
844 -mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram @gol
848 @gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu} @gol
849 -msim -msdata=@var{sdata-type}}
852 @gccoptlist{-mcpu=@var{cpu} -march=@var{cpu} -mtune=@var{cpu} @gol
853 -mmax-stack-frame=@var{n} -melinux-stacksize=@var{n} @gol
854 -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects @gol
855 -mstack-align -mdata-align -mconst-align @gol
856 -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue -mno-gotplt @gol
857 -melf -maout -melinux -mlinux -sim -sim2 @gol
858 -mmul-bug-workaround -mno-mul-bug-workaround}
861 @gccoptlist{-mmac @gol
862 -mcr16cplus -mcr16c @gol
863 -msim -mint32 -mbit-ops
864 -mdata-model=@var{model}}
867 @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} @gol
868 -mbig-endian -EB -mlittle-endian -EL @gol
869 -mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu @gol
870 -mfloat-abi=@var{name} @gol
871 -melrw -mistack -mmp -mcp -mcache -msecurity -mtrust @gol
872 -mdsp -medsp -mvdsp @gol
873 -mdiv -msmart -mhigh-registers -manchor @gol
874 -mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt @gol
875 -mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim}
877 @emph{Darwin Options}
878 @gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal @gol
879 -arch_only -bind_at_load -bundle -bundle_loader @gol
880 -client_name -compatibility_version -current_version @gol
882 -dependency-file -dylib_file -dylinker_install_name @gol
883 -dynamic -dynamiclib -exported_symbols_list @gol
884 -filelist -flat_namespace -force_cpusubtype_ALL @gol
885 -force_flat_namespace -headerpad_max_install_names @gol
887 -image_base -init -install_name -keep_private_externs @gol
888 -multi_module -multiply_defined -multiply_defined_unused @gol
889 -noall_load -no_dead_strip_inits_and_terms @gol
890 -nofixprebinding -nomultidefs -noprebind -noseglinkedit @gol
891 -pagezero_size -prebind -prebind_all_twolevel_modules @gol
892 -private_bundle -read_only_relocs -sectalign @gol
893 -sectobjectsymbols -whyload -seg1addr @gol
894 -sectcreate -sectobjectsymbols -sectorder @gol
895 -segaddr -segs_read_only_addr -segs_read_write_addr @gol
896 -seg_addr_table -seg_addr_table_filename -seglinkedit @gol
897 -segprot -segs_read_only_addr -segs_read_write_addr @gol
898 -single_module -static -sub_library -sub_umbrella @gol
899 -twolevel_namespace -umbrella -undefined @gol
900 -unexported_symbols_list -weak_reference_mismatches @gol
901 -whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version} @gol
902 -mkernel -mone-byte-bool}
904 @emph{DEC Alpha Options}
905 @gccoptlist{-mno-fp-regs -msoft-float @gol
906 -mieee -mieee-with-inexact -mieee-conformant @gol
907 -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} @gol
908 -mtrap-precision=@var{mode} -mbuild-constants @gol
909 -mcpu=@var{cpu-type} -mtune=@var{cpu-type} @gol
910 -mbwx -mmax -mfix -mcix @gol
911 -mfloat-vax -mfloat-ieee @gol
912 -mexplicit-relocs -msmall-data -mlarge-data @gol
913 -msmall-text -mlarge-text @gol
914 -mmemory-latency=@var{time}}
917 @gccoptlist{-mbig-endian -mlittle-endian -mkernel=@var{version}
918 -mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re
919 -mjmpext -mjmp32 -malu32 -mcpu=@var{version}}
922 @gccoptlist{-msmall-model -mno-lsim}
925 @gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm}
928 @gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 @gol
929 -mhard-float -msoft-float @gol
930 -malloc-cc -mfixed-cc -mdword -mno-dword @gol
931 -mdouble -mno-double @gol
932 -mmedia -mno-media -mmuladd -mno-muladd @gol
933 -mfdpic -minline-plt -mgprel-ro -multilib-library-pic @gol
934 -mlinked-fp -mlong-calls -malign-labels @gol
935 -mlibrary-pic -macc-4 -macc-8 @gol
936 -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move @gol
937 -moptimize-membar -mno-optimize-membar @gol
938 -mscc -mno-scc -mcond-exec -mno-cond-exec @gol
939 -mvliw-branch -mno-vliw-branch @gol
940 -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec @gol
941 -mno-nested-cond-exec -mtomcat-stats @gol
945 @emph{GNU/Linux Options}
946 @gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid @gol
947 -tno-android-cc -tno-android-ld}
949 @emph{H8/300 Options}
950 @gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300}
953 @gccoptlist{-march=@var{architecture-type} @gol
954 -mcaller-copies -mdisable-fpregs -mdisable-indexing @gol
955 -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld @gol
956 -mfixed-range=@var{register-range} @gol
957 -mjump-in-delay -mlinker-opt -mlong-calls @gol
958 -mlong-load-store -mno-disable-fpregs @gol
959 -mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol
960 -mno-jump-in-delay -mno-long-load-store @gol
961 -mno-portable-runtime -mno-soft-float @gol
962 -mno-space-regs -msoft-float -mpa-risc-1-0 @gol
963 -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol
964 -mschedule=@var{cpu-type} -mspace-regs -msio -mwsio @gol
965 -munix=@var{unix-std} -nolibdld -static -threads}
968 @gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol
969 -mvolatile-asm-stop -mregister-names -msdata -mno-sdata @gol
970 -mconstant-gp -mauto-pic -mfused-madd @gol
971 -minline-float-divide-min-latency @gol
972 -minline-float-divide-max-throughput @gol
973 -mno-inline-float-divide @gol
974 -minline-int-divide-min-latency @gol
975 -minline-int-divide-max-throughput @gol
976 -mno-inline-int-divide @gol
977 -minline-sqrt-min-latency -minline-sqrt-max-throughput @gol
978 -mno-inline-sqrt @gol
979 -mdwarf2-asm -mearly-stop-bits @gol
980 -mfixed-range=@var{register-range} -mtls-size=@var{tls-size} @gol
981 -mtune=@var{cpu-type} -milp32 -mlp64 @gol
982 -msched-br-data-spec -msched-ar-data-spec -msched-control-spec @gol
983 -msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec @gol
984 -msched-spec-ldc -msched-spec-control-ldc @gol
985 -msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns @gol
986 -msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path @gol
987 -msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost @gol
988 -msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}}
991 @gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled @gol
992 -msign-extend-enabled -muser-enabled}
994 @emph{M32R/D Options}
995 @gccoptlist{-m32r2 -m32rx -m32r @gol
997 -malign-loops -mno-align-loops @gol
998 -missue-rate=@var{number} @gol
999 -mbranch-cost=@var{number} @gol
1000 -mmodel=@var{code-size-model-type} @gol
1001 -msdata=@var{sdata-type} @gol
1002 -mno-flush-func -mflush-func=@var{name} @gol
1003 -mno-flush-trap -mflush-trap=@var{number} @gol
1007 @gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
1009 @emph{M680x0 Options}
1010 @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune} @gol
1011 -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol
1012 -m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407 @gol
1013 -mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020 @gol
1014 -mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort @gol
1015 -mno-short -mhard-float -m68881 -msoft-float -mpcrel @gol
1016 -malign-int -mstrict-align -msep-data -mno-sep-data @gol
1017 -mshared-library-id=n -mid-shared-library -mno-id-shared-library @gol
1018 -mxgot -mno-xgot -mlong-jump-table-offsets}
1020 @emph{MCore Options}
1021 @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol
1022 -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol
1023 -m4byte-functions -mno-4byte-functions -mcallgraph-data @gol
1024 -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol
1025 -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
1028 @gccoptlist{-mabsdiff -mall-opts -maverage -mbased=@var{n} -mbitops @gol
1029 -mc=@var{n} -mclip -mconfig=@var{name} -mcop -mcop32 -mcop64 -mivc2 @gol
1030 -mdc -mdiv -meb -mel -mio-volatile -ml -mleadz -mm -mminmax @gol
1031 -mmult -mno-opts -mrepeat -ms -msatur -msdram -msim -msimnovec -mtf @gol
1034 @emph{MicroBlaze Options}
1035 @gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu} @gol
1036 -mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift @gol
1037 -mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss @gol
1038 -mxl-multiply-high -mxl-float-convert -mxl-float-sqrt @gol
1039 -mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model} @gol
1040 -mpic-data-is-text-relative}
1043 @gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} @gol
1044 -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5 @gol
1045 -mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6 @gol
1046 -mips16 -mno-mips16 -mflip-mips16 @gol
1047 -minterlink-compressed -mno-interlink-compressed @gol
1048 -minterlink-mips16 -mno-interlink-mips16 @gol
1049 -mabi=@var{abi} -mabicalls -mno-abicalls @gol
1050 -mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot @gol
1051 -mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float @gol
1052 -mno-float -msingle-float -mdouble-float @gol
1053 -modd-spreg -mno-odd-spreg @gol
1054 -mabs=@var{mode} -mnan=@var{encoding} @gol
1055 -mdsp -mno-dsp -mdspr2 -mno-dspr2 @gol
1056 -mmcu -mmno-mcu @gol
1058 -mvirt -mno-virt @gol
1061 -mginv -mno-ginv @gol
1062 -mmicromips -mno-micromips @gol
1064 -mloongson-mmi -mno-loongson-mmi @gol
1065 -mloongson-ext -mno-loongson-ext @gol
1066 -mloongson-ext2 -mno-loongson-ext2 @gol
1067 -mfpu=@var{fpu-type} @gol
1068 -msmartmips -mno-smartmips @gol
1069 -mpaired-single -mno-paired-single -mdmx -mno-mdmx @gol
1070 -mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc @gol
1071 -mlong64 -mlong32 -msym32 -mno-sym32 @gol
1072 -G@var{num} -mlocal-sdata -mno-local-sdata @gol
1073 -mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt @gol
1074 -membedded-data -mno-embedded-data @gol
1075 -muninit-const-in-rodata -mno-uninit-const-in-rodata @gol
1076 -mcode-readable=@var{setting} @gol
1077 -msplit-addresses -mno-split-addresses @gol
1078 -mexplicit-relocs -mno-explicit-relocs @gol
1079 -mcheck-zero-division -mno-check-zero-division @gol
1080 -mdivide-traps -mdivide-breaks @gol
1081 -mload-store-pairs -mno-load-store-pairs @gol
1082 -munaligned-access -mno-unaligned-access @gol
1083 -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls @gol
1084 -mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp @gol
1085 -mfix-24k -mno-fix-24k @gol
1086 -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 @gol
1087 -mfix-r5900 -mno-fix-r5900 @gol
1088 -mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000 @gol
1089 -mfix-vr4120 -mno-fix-vr4120 @gol
1090 -mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1 @gol
1091 -mflush-func=@var{func} -mno-flush-func @gol
1092 -mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely @gol
1093 -mcompact-branches=@var{policy} @gol
1094 -mfp-exceptions -mno-fp-exceptions @gol
1095 -mvr4130-align -mno-vr4130-align -msynci -mno-synci @gol
1096 -mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4 @gol
1097 -mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address @gol
1098 -mframe-header-opt -mno-frame-header-opt}
1101 @gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu @gol
1102 -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols @gol
1103 -melf -mbranch-predict -mno-branch-predict -mbase-addresses @gol
1104 -mno-base-addresses -msingle-exit -mno-single-exit}
1106 @emph{MN10300 Options}
1107 @gccoptlist{-mmult-bug -mno-mult-bug @gol
1108 -mno-am33 -mam33 -mam33-2 -mam34 @gol
1109 -mtune=@var{cpu-type} @gol
1110 -mreturn-pointer-on-d0 @gol
1111 -mno-crt0 -mrelax -mliw -msetlb}
1113 @emph{Moxie Options}
1114 @gccoptlist{-meb -mel -mmul.x -mno-crt0}
1116 @emph{MSP430 Options}
1117 @gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax @gol
1119 -mcode-region= -mdata-region= @gol
1120 -msilicon-errata= -msilicon-errata-warn= @gol
1121 -mhwmult= -minrt -mtiny-printf -mmax-inline-shift=}
1123 @emph{NDS32 Options}
1124 @gccoptlist{-mbig-endian -mlittle-endian @gol
1125 -mreduced-regs -mfull-regs @gol
1126 -mcmov -mno-cmov @gol
1127 -mext-perf -mno-ext-perf @gol
1128 -mext-perf2 -mno-ext-perf2 @gol
1129 -mext-string -mno-ext-string @gol
1130 -mv3push -mno-v3push @gol
1131 -m16bit -mno-16bit @gol
1132 -misr-vector-size=@var{num} @gol
1133 -mcache-block-size=@var{num} @gol
1134 -march=@var{arch} @gol
1135 -mcmodel=@var{code-model} @gol
1136 -mctor-dtor -mrelax}
1138 @emph{Nios II Options}
1139 @gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt @gol
1140 -mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp} @gol
1142 -mno-bypass-cache -mbypass-cache @gol
1143 -mno-cache-volatile -mcache-volatile @gol
1144 -mno-fast-sw-div -mfast-sw-div @gol
1145 -mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div @gol
1146 -mcustom-@var{insn}=@var{N} -mno-custom-@var{insn} @gol
1147 -mcustom-fpu-cfg=@var{name} @gol
1148 -mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name} @gol
1149 -march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx}
1151 @emph{Nvidia PTX Options}
1152 @gccoptlist{-m64 -mmainkernel -moptimize}
1154 @emph{OpenRISC Options}
1155 @gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div @gol
1156 -msoft-mul -msoft-div @gol
1157 -msoft-float -mhard-float -mdouble-float -munordered-float @gol
1158 -mcmov -mror -mrori -msext -msfimm -mshftimm @gol
1159 -mcmodel=@var{code-model}}
1161 @emph{PDP-11 Options}
1162 @gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 @gol
1163 -mint32 -mno-int16 -mint16 -mno-int32 @gol
1164 -msplit -munix-asm -mdec-asm -mgnu-asm -mlra}
1166 @emph{picoChip Options}
1167 @gccoptlist{-mae=@var{ae_type} -mvliw-lookahead=@var{N} @gol
1168 -msymbol-as-address -mno-inefficient-warnings}
1170 @emph{PowerPC Options}
1171 See RS/6000 and PowerPC Options.
1174 @gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop @gol
1175 -mabi=@var{variant} @gol}
1177 @emph{RISC-V Options}
1178 @gccoptlist{-mbranch-cost=@var{N-instruction} @gol
1180 -mabi=@var{ABI-string} @gol
1181 -mfdiv -mno-fdiv @gol
1183 -march=@var{ISA-string} @gol
1184 -mtune=@var{processor-string} @gol
1185 -mpreferred-stack-boundary=@var{num} @gol
1186 -msmall-data-limit=@var{N-bytes} @gol
1187 -msave-restore -mno-save-restore @gol
1188 -mshorten-memrefs -mno-shorten-memrefs @gol
1189 -mstrict-align -mno-strict-align @gol
1190 -mcmodel=medlow -mcmodel=medany @gol
1191 -mexplicit-relocs -mno-explicit-relocs @gol
1192 -mrelax -mno-relax @gol
1193 -mriscv-attribute -mmo-riscv-attribute @gol
1194 -malign-data=@var{type} @gol
1195 -mbig-endian -mlittle-endian @gol
1196 -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol
1197 -mstack-protector-guard-offset=@var{offset}}
1200 @gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs @gol
1201 -mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14 @gol
1202 -m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts}
1204 @emph{RS/6000 and PowerPC Options}
1205 @gccoptlist{-mcpu=@var{cpu-type} @gol
1206 -mtune=@var{cpu-type} @gol
1207 -mcmodel=@var{code-model} @gol
1209 -maltivec -mno-altivec @gol
1210 -mpowerpc-gpopt -mno-powerpc-gpopt @gol
1211 -mpowerpc-gfxopt -mno-powerpc-gfxopt @gol
1212 -mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd @gol
1213 -mfprnd -mno-fprnd @gol
1214 -mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp @gol
1215 -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc @gol
1216 -m64 -m32 -mxl-compat -mno-xl-compat -mpe @gol
1217 -malign-power -malign-natural @gol
1218 -msoft-float -mhard-float -mmultiple -mno-multiple @gol
1219 -mupdate -mno-update @gol
1220 -mavoid-indexed-addresses -mno-avoid-indexed-addresses @gol
1221 -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol
1222 -mstrict-align -mno-strict-align -mrelocatable @gol
1223 -mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol
1224 -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol
1225 -mdynamic-no-pic -mswdiv -msingle-pic-base @gol
1226 -mprioritize-restricted-insns=@var{priority} @gol
1227 -msched-costly-dep=@var{dependence_type} @gol
1228 -minsert-sched-nops=@var{scheme} @gol
1229 -mcall-aixdesc -mcall-eabi -mcall-freebsd @gol
1230 -mcall-linux -mcall-netbsd -mcall-openbsd @gol
1231 -mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi @gol
1232 -mtraceback=@var{traceback_type} @gol
1233 -maix-struct-return -msvr4-struct-return @gol
1234 -mabi=@var{abi-type} -msecure-plt -mbss-plt @gol
1235 -mlongcall -mno-longcall -mpltseq -mno-pltseq @gol
1236 -mblock-move-inline-limit=@var{num} @gol
1237 -mblock-compare-inline-limit=@var{num} @gol
1238 -mblock-compare-inline-loop-limit=@var{num} @gol
1239 -mno-block-ops-unaligned-vsx @gol
1240 -mstring-compare-inline-limit=@var{num} @gol
1241 -misel -mno-isel @gol
1242 -mvrsave -mno-vrsave @gol
1243 -mmulhw -mno-mulhw @gol
1244 -mdlmzb -mno-dlmzb @gol
1245 -mprototype -mno-prototype @gol
1246 -msim -mmvme -mads -myellowknife -memb -msdata @gol
1247 -msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num} @gol
1248 -mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision @gol
1249 -mno-recip-precision @gol
1250 -mveclibabi=@var{type} -mfriz -mno-friz @gol
1251 -mpointers-to-nested-functions -mno-pointers-to-nested-functions @gol
1252 -msave-toc-indirect -mno-save-toc-indirect @gol
1253 -mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector @gol
1254 -mcrypto -mno-crypto -mhtm -mno-htm @gol
1255 -mquad-memory -mno-quad-memory @gol
1256 -mquad-memory-atomic -mno-quad-memory-atomic @gol
1257 -mcompat-align-parm -mno-compat-align-parm @gol
1258 -mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware @gol
1259 -mgnu-attribute -mno-gnu-attribute @gol
1260 -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol
1261 -mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed @gol
1262 -mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect @gol
1263 -mprivileged -mno-privileged}
1266 @gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu@gol
1268 -mbig-endian-data -mlittle-endian-data @gol
1271 -mas100-syntax -mno-as100-syntax@gol
1273 -mmax-constant-size=@gol
1276 -mallow-string-insns -mno-allow-string-insns@gol
1278 -mno-warn-multiple-fast-interrupts@gol
1279 -msave-acc-in-interrupts}
1281 @emph{S/390 and zSeries Options}
1282 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
1283 -mhard-float -msoft-float -mhard-dfp -mno-hard-dfp @gol
1284 -mlong-double-64 -mlong-double-128 @gol
1285 -mbackchain -mno-backchain -mpacked-stack -mno-packed-stack @gol
1286 -msmall-exec -mno-small-exec -mmvcle -mno-mvcle @gol
1287 -m64 -m31 -mdebug -mno-debug -mesa -mzarch @gol
1288 -mhtm -mvx -mzvector @gol
1289 -mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip @gol
1290 -mfused-madd -mno-fused-madd @gol
1291 -mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard @gol
1292 -mhotpatch=@var{halfwords},@var{halfwords}}
1294 @emph{Score Options}
1295 @gccoptlist{-meb -mel @gol
1299 -mscore5 -mscore5u -mscore7 -mscore7d}
1302 @gccoptlist{-m1 -m2 -m2e @gol
1303 -m2a-nofpu -m2a-single-only -m2a-single -m2a @gol
1305 -m4-nofpu -m4-single-only -m4-single -m4 @gol
1306 -m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al @gol
1307 -mb -ml -mdalign -mrelax @gol
1308 -mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave @gol
1309 -mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct @gol
1310 -mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy} @gol
1311 -mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} @gol
1312 -maccumulate-outgoing-args @gol
1313 -matomic-model=@var{atomic-model} @gol
1314 -mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch @gol
1315 -mcbranch-force-delay-slot @gol
1316 -mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra @gol
1317 -mpretend-cmove -mtas}
1319 @emph{Solaris 2 Options}
1320 @gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text @gol
1323 @emph{SPARC Options}
1324 @gccoptlist{-mcpu=@var{cpu-type} @gol
1325 -mtune=@var{cpu-type} @gol
1326 -mcmodel=@var{code-model} @gol
1327 -mmemory-model=@var{mem-model} @gol
1328 -m32 -m64 -mapp-regs -mno-app-regs @gol
1329 -mfaster-structs -mno-faster-structs -mflat -mno-flat @gol
1330 -mfpu -mno-fpu -mhard-float -msoft-float @gol
1331 -mhard-quad-float -msoft-quad-float @gol
1332 -mstack-bias -mno-stack-bias @gol
1333 -mstd-struct-return -mno-std-struct-return @gol
1334 -munaligned-doubles -mno-unaligned-doubles @gol
1335 -muser-mode -mno-user-mode @gol
1336 -mv8plus -mno-v8plus -mvis -mno-vis @gol
1337 -mvis2 -mno-vis2 -mvis3 -mno-vis3 @gol
1338 -mvis4 -mno-vis4 -mvis4b -mno-vis4b @gol
1339 -mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld @gol
1340 -mpopc -mno-popc -msubxc -mno-subxc @gol
1341 -mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc @gol
1344 @emph{System V Options}
1345 @gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
1347 @emph{TILE-Gx Options}
1348 @gccoptlist{-mcpu=CPU -m32 -m64 -mbig-endian -mlittle-endian @gol
1349 -mcmodel=@var{code-model}}
1351 @emph{TILEPro Options}
1352 @gccoptlist{-mcpu=@var{cpu} -m32}
1355 @gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep @gol
1356 -mprolog-function -mno-prolog-function -mspace @gol
1357 -mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol
1358 -mapp-regs -mno-app-regs @gol
1359 -mdisable-callt -mno-disable-callt @gol
1360 -mv850e2v3 -mv850e2 -mv850e1 -mv850es @gol
1361 -mv850e -mv850 -mv850e3v5 @gol
1372 @gccoptlist{-mg -mgnu -munix -mlra}
1374 @emph{Visium Options}
1375 @gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float @gol
1376 -mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode}
1379 @gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64 @gol
1380 -mpointer-size=@var{size}}
1382 @emph{VxWorks Options}
1383 @gccoptlist{-mrtp -non-static -Bstatic -Bdynamic @gol
1384 -Xbind-lazy -Xbind-now}
1387 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
1388 -mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default @gol
1389 -mfpmath=@var{unit} @gol
1390 -masm=@var{dialect} -mno-fancy-math-387 @gol
1391 -mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float @gol
1392 -mno-wide-multiply -mrtd -malign-double @gol
1393 -mpreferred-stack-boundary=@var{num} @gol
1394 -mincoming-stack-boundary=@var{num} @gol
1395 -mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait @gol
1396 -mrecip -mrecip=@var{opt} @gol
1397 -mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt} @gol
1398 -mmove-max=@var{bits} -mstore-max=@var{bits} @gol
1399 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx @gol
1400 -mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl @gol
1401 -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes @gol
1402 -mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd @gol
1403 -mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves @gol
1404 -msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop @gol
1405 -madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp @gol
1406 -mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg @gol
1407 -mshstk -mmanual-endbr -mforce-indirect-call -mavx512vbmi2 -mavx512bf16 -menqcmd @gol
1408 -mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq @gol
1409 -mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid @gol
1410 -mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk@gol
1411 -mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni@gol
1413 -mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops @gol
1414 -minline-stringops-dynamically -mstringop-strategy=@var{alg} @gol
1416 -mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy} @gol
1417 -mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
1418 -m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128 @gol
1419 -mregparm=@var{num} -msseregparm @gol
1420 -mveclibabi=@var{type} -mvect8-ret-in-mem @gol
1421 -mpc32 -mpc64 -mpc80 -mstackrealign @gol
1422 -momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs @gol
1423 -mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} @gol
1424 -m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num} @gol
1425 -msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv @gol
1426 -minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name} @gol
1427 -mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
1428 -malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
1429 -mstack-protector-guard-reg=@var{reg} @gol
1430 -mstack-protector-guard-offset=@var{offset} @gol
1431 -mstack-protector-guard-symbol=@var{symbol} @gol
1432 -mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop @gol
1433 -mindirect-branch=@var{choice} -mfunction-return=@var{choice} @gol
1434 -mindirect-branch-register -mharden-sls=@var{choice} @gol
1435 -mindirect-branch-cs-prefix -mneeded}
1437 @emph{x86 Windows Options}
1438 @gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
1439 -mnop-fun-dllimport -mthread @gol
1440 -municode -mwin32 -mwindows -fno-set-stack-executable}
1442 @emph{Xstormy16 Options}
1445 @emph{Xtensa Options}
1446 @gccoptlist{-mconst16 -mno-const16 @gol
1447 -mfused-madd -mno-fused-madd @gol
1449 -mserialize-volatile -mno-serialize-volatile @gol
1450 -mtext-section-literals -mno-text-section-literals @gol
1451 -mauto-litpools -mno-auto-litpools @gol
1452 -mtarget-align -mno-target-align @gol
1453 -mlongcalls -mno-longcalls @gol
1454 -mabi=@var{abi-type}}
1456 @emph{zSeries Options}
1457 See S/390 and zSeries Options.
1461 @node Overall Options
1462 @section Options Controlling the Kind of Output
1464 Compilation can involve up to four stages: preprocessing, compilation
1465 proper, assembly and linking, always in that order. GCC is capable of
1466 preprocessing and compiling several files either into several
1467 assembler input files, or into one assembler input file; then each
1468 assembler input file produces an object file, and linking combines all
1469 the object files (those newly compiled, and those specified as input)
1470 into an executable file.
1472 @cindex file name suffix
1473 For any given input file, the file name suffix determines what kind of
1474 compilation is done:
1478 C source code that must be preprocessed.
1481 C source code that should not be preprocessed.
1484 C++ source code that should not be preprocessed.
1487 Objective-C source code. Note that you must link with the @file{libobjc}
1488 library to make an Objective-C program work.
1491 Objective-C source code that should not be preprocessed.
1495 Objective-C++ source code. Note that you must link with the @file{libobjc}
1496 library to make an Objective-C++ program work. Note that @samp{.M} refers
1497 to a literal capital M@.
1499 @item @var{file}.mii
1500 Objective-C++ source code that should not be preprocessed.
1503 C, C++, Objective-C or Objective-C++ header file to be turned into a
1504 precompiled header (default), or C, C++ header file to be turned into an
1505 Ada spec (via the @option{-fdump-ada-spec} switch).
1508 @itemx @var{file}.cp
1509 @itemx @var{file}.cxx
1510 @itemx @var{file}.cpp
1511 @itemx @var{file}.CPP
1512 @itemx @var{file}.c++
1514 C++ source code that must be preprocessed. Note that in @samp{.cxx},
1515 the last two letters must both be literally @samp{x}. Likewise,
1516 @samp{.C} refers to a literal capital C@.
1520 Objective-C++ source code that must be preprocessed.
1522 @item @var{file}.mii
1523 Objective-C++ source code that should not be preprocessed.
1527 @itemx @var{file}.hp
1528 @itemx @var{file}.hxx
1529 @itemx @var{file}.hpp
1530 @itemx @var{file}.HPP
1531 @itemx @var{file}.h++
1532 @itemx @var{file}.tcc
1533 C++ header file to be turned into a precompiled header or Ada spec.
1536 @itemx @var{file}.for
1537 @itemx @var{file}.ftn
1538 Fixed form Fortran source code that should not be preprocessed.
1541 @itemx @var{file}.FOR
1542 @itemx @var{file}.fpp
1543 @itemx @var{file}.FPP
1544 @itemx @var{file}.FTN
1545 Fixed form Fortran source code that must be preprocessed (with the traditional
1548 @item @var{file}.f90
1549 @itemx @var{file}.f95
1550 @itemx @var{file}.f03
1551 @itemx @var{file}.f08
1552 Free form Fortran source code that should not be preprocessed.
1554 @item @var{file}.F90
1555 @itemx @var{file}.F95
1556 @itemx @var{file}.F03
1557 @itemx @var{file}.F08
1558 Free form Fortran source code that must be preprocessed (with the
1559 traditional preprocessor).
1571 D documentation code (Ddoc).
1573 @item @var{file}.ads
1574 Ada source code file that contains a library unit declaration (a
1575 declaration of a package, subprogram, or generic, or a generic
1576 instantiation), or a library unit renaming declaration (a package,
1577 generic, or subprogram renaming declaration). Such files are also
1580 @item @var{file}.adb
1581 Ada source code file containing a library unit body (a subprogram or
1582 package body). Such files are also called @dfn{bodies}.
1584 @c GCC also knows about some suffixes for languages not yet included:
1592 @itemx @var{file}.sx
1593 Assembler code that must be preprocessed.
1596 An object file to be fed straight into linking.
1597 Any file name with no recognized suffix is treated this way.
1601 You can specify the input language explicitly with the @option{-x} option:
1604 @item -x @var{language}
1605 Specify explicitly the @var{language} for the following input files
1606 (rather than letting the compiler choose a default based on the file
1607 name suffix). This option applies to all following input files until
1608 the next @option{-x} option. Possible values for @var{language} are:
1610 c c-header cpp-output
1611 c++ c++-header c++-system-header c++-user-header c++-cpp-output
1612 objective-c objective-c-header objective-c-cpp-output
1613 objective-c++ objective-c++-header objective-c++-cpp-output
1614 assembler assembler-with-cpp
1617 f77 f77-cpp-input f95 f95-cpp-input
1622 Turn off any specification of a language, so that subsequent files are
1623 handled according to their file name suffixes (as they are if @option{-x}
1624 has not been used at all).
1627 If you only want some of the stages of compilation, you can use
1628 @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
1629 one of the options @option{-c}, @option{-S}, or @option{-E} to say where
1630 @command{gcc} is to stop. Note that some combinations (for example,
1631 @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
1636 Compile or assemble the source files, but do not link. The linking
1637 stage simply is not done. The ultimate output is in the form of an
1638 object file for each source file.
1640 By default, the object file name for a source file is made by replacing
1641 the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
1643 Unrecognized input files, not requiring compilation or assembly, are
1648 Stop after the stage of compilation proper; do not assemble. The output
1649 is in the form of an assembler code file for each non-assembler input
1652 By default, the assembler file name for a source file is made by
1653 replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
1655 Input files that don't require compilation are ignored.
1659 Stop after the preprocessing stage; do not run the compiler proper. The
1660 output is in the form of preprocessed source code, which is sent to the
1663 Input files that don't require preprocessing are ignored.
1665 @cindex output file option
1668 Place the primary output in file @var{file}. This applies to whatever
1669 sort of output is being produced, whether it be an executable file, an
1670 object file, an assembler file or preprocessed C code.
1672 If @option{-o} is not specified, the default is to put an executable
1673 file in @file{a.out}, the object file for
1674 @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
1675 assembler file in @file{@var{source}.s}, a precompiled header file in
1676 @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
1679 Though @option{-o} names only the primary output, it also affects the
1680 naming of auxiliary and dump outputs. See the examples below. Unless
1681 overridden, both auxiliary outputs and dump outputs are placed in the
1682 same directory as the primary output. In auxiliary outputs, the suffix
1683 of the input file is replaced with that of the auxiliary output file
1684 type; in dump outputs, the suffix of the dump file is appended to the
1685 input file suffix. In compilation commands, the base name of both
1686 auxiliary and dump outputs is that of the primary output; in compile and
1687 link commands, the primary output name, minus the executable suffix, is
1688 combined with the input file name. If both share the same base name,
1689 disregarding the suffix, the result of the combination is that base
1690 name, otherwise, they are concatenated, separated by a dash.
1696 will use @file{foo.o} as the primary output, and place aux outputs and
1697 dumps next to it, e.g., aux file @file{foo.dwo} for
1698 @option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for
1699 @option{-fdump-rtl-final}.
1701 If a non-linker output file is explicitly specified, aux and dump files
1702 by default take the same base name:
1705 gcc -c foo.c -o dir/foobar.o ...
1708 will name aux outputs @file{dir/foobar.*} and dump outputs
1709 @file{dir/foobar.c.*}.
1711 A linker output will instead prefix aux and dump outputs:
1714 gcc foo.c bar.c -o dir/foobar ...
1717 will generally name aux outputs @file{dir/foobar-foo.*} and
1718 @file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and
1719 @file{dir/foobar-bar.c.*}.
1721 The one exception to the above is when the executable shares the base
1722 name with the single input:
1725 gcc foo.c -o dir/foo ...
1728 in which case aux outputs are named @file{dir/foo.*} and dump outputs
1729 named @file{dir/foo.c.*}.
1731 The location and the names of auxiliary and dump outputs can be adjusted
1732 by the options @option{-dumpbase}, @option{-dumpbase-ext},
1733 @option{-dumpdir}, @option{-save-temps=cwd}, and
1734 @option{-save-temps=obj}.
1737 @item -dumpbase @var{dumpbase}
1739 This option sets the base name for auxiliary and dump output files. It
1740 does not affect the name of the primary output file. Intermediate
1741 outputs, when preserved, are not regarded as primary outputs, but as
1745 gcc -save-temps -S foo.c
1748 saves the (no longer) temporary preprocessed file in @file{foo.i}, and
1749 then compiles to the (implied) output file @file{foo.s}, whereas:
1752 gcc -save-temps -dumpbase save-foo -c foo.c
1755 preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now
1756 an intermediate, thus auxiliary output), and then assembles to the
1757 (implied) output file @file{foo.o}.
1759 Absent this option, dump and aux files take their names from the input
1760 file, or from the (non-linker) output file, if one is explicitly
1761 specified: dump output files (e.g. those requested by @option{-fdump-*}
1762 options) with the input name suffix, and aux output files (those
1763 requested by other non-dump options, e.g. @code{-save-temps},
1764 @code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it.
1766 Similar suffix differentiation of dump and aux outputs can be attained
1767 for explicitly-given @option{-dumpbase basename.suf} by also specifying
1768 @option{-dumpbase-ext .suf}.
1770 If @var{dumpbase} is explicitly specified with any directory component,
1771 any @var{dumppfx} specification (e.g. @option{-dumpdir} or
1772 @option{-save-temps=*}) is ignored, and instead of appending to it,
1773 @var{dumpbase} fully overrides it:
1776 gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
1777 -dumpdir pfx- -save-temps=cwd ...
1780 creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding
1781 @file{dir/} in @option{-o}, the @file{./} prefix implied by
1782 @option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}.
1784 When @option{-dumpbase} is specified in a command that compiles multiple
1785 inputs, or that compiles and then links, it may be combined with
1786 @var{dumppfx}, as specified under @option{-dumpdir}. Then, each input
1787 file is compiled using the combined @var{dumppfx}, and default values
1788 for @var{dumpbase} and @var{auxdropsuf} are computed for each input
1792 gcc foo.c bar.c -c -dumpbase main ...
1795 creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids
1796 overwriting the auxiliary and dump outputs by using the @var{dumpbase}
1797 as a prefix, creating auxiliary and dump outputs named @file{main-foo.*}
1798 and @file{main-bar.*}.
1800 An empty string specified as @var{dumpbase} avoids the influence of the
1801 output basename in the naming of auxiliary and dump outputs during
1802 compilation, computing default values :
1805 gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
1808 will name aux outputs @file{dir/foo.*} and dump outputs
1809 @file{dir/foo.c.*}. Note how their basenames are taken from the input
1810 name, but the directory still defaults to that of the output.
1812 The empty-string dumpbase does not prevent the use of the output
1813 basename for outputs during linking:
1816 gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
1819 The compilation of the source files will name auxiliary outputs
1820 @file{dir/foo.*} and @file{dir/bar.*}, and dump outputs
1821 @file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during
1822 linking will use @file{dir/foobar.} as the prefix for dumps and
1826 @item -dumpbase-ext @var{auxdropsuf}
1827 @opindex dumpbase-ext
1828 When forming the name of an auxiliary (but not a dump) output file, drop
1829 trailing @var{auxdropsuf} from @var{dumpbase} before appending any
1830 suffixes. If not specified, this option defaults to the suffix of a
1831 default @var{dumpbase}, i.e., the suffix of the input file when
1832 @option{-dumpbase} is not present in the command line, or @var{dumpbase}
1833 is combined with @var{dumppfx}.
1836 gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
1839 creates @file{dir/foo.o} as the main output, and generates auxiliary
1840 outputs in @file{dir/x-foo.*}, taking the location of the primary
1841 output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump
1842 outputs retain the suffix: @file{dir/x-foo.c.*}.
1844 This option is disregarded if it does not match the suffix of a
1845 specified @var{dumpbase}, except as an alternative to the executable
1846 suffix when appending the linker output base name to @var{dumppfx}, as
1850 gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
1853 creates @file{main.out} as the primary output, and avoids overwriting
1854 the auxiliary and dump outputs by using the executable name minus
1855 @var{auxdropsuf} as a prefix, creating auxiliary outputs named
1856 @file{main-foo.*} and @file{main-bar.*} and dump outputs named
1857 @file{main-foo.c.*} and @file{main-bar.c.*}.
1860 @item -dumpdir @var{dumppfx}
1862 When forming the name of an auxiliary or dump output file, use
1863 @var{dumppfx} as a prefix:
1866 gcc -dumpdir pfx- -c foo.c ...
1869 creates @file{foo.o} as the primary output, and auxiliary outputs named
1870 @file{pfx-foo.*}, combining the given @var{dumppfx} with the default
1871 @var{dumpbase} derived from the default primary output, derived in turn
1872 from the input name. Dump outputs also take the input name suffix:
1875 If @var{dumppfx} is to be used as a directory name, it must end with a
1876 directory separator:
1879 gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
1882 creates @file{obj/bar.o} as the primary output, and auxiliary outputs
1883 named @file{dir/bar.*}, combining the given @var{dumppfx} with the
1884 default @var{dumpbase} derived from the primary output name. Dump
1885 outputs also take the input name suffix: @file{dir/bar.c.*}.
1887 It defaults to the location of the output file, unless the output
1888 file is a special file like @code{/dev/null}. Options
1889 @option{-save-temps=cwd} and @option{-save-temps=obj} override this
1890 default, just like an explicit @option{-dumpdir} option. In case
1891 multiple such options are given, the last one prevails:
1894 gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
1897 outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because
1898 @option{-save-temps=*} overrides the @var{dumppfx} given by the earlier
1899 @option{-dumpdir} option. It does not matter that @option{=obj} is the
1900 default for @option{-save-temps}, nor that the output directory is
1901 implicitly the current directory. Dump outputs are named
1904 When compiling from multiple input files, if @option{-dumpbase} is
1905 specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash
1906 are appended to (or override, if containing any directory components) an
1907 explicit or defaulted @var{dumppfx}, so that each of the multiple
1908 compilations gets differently-named aux and dump outputs.
1911 gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
1914 outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and
1915 @file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}.
1916 Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*}
1917 and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the
1918 single-input compilation:
1921 gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
1924 that, applying @option{-dumpbase} to a single source, does not compute
1925 and append a separate @var{dumpbase} per input file. Its auxiliary and
1926 dump outputs go in @file{dir/pfx-main.*}.
1928 When compiling and then linking from multiple input files, a defaulted
1929 or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}-
1930 transformation above (e.g. the compilation of @file{foo.c} and
1931 @file{bar.c} above, but without @option{-c}). If neither
1932 @option{-dumpdir} nor @option{-dumpbase} are given, the linker output
1933 base name, minus @var{auxdropsuf}, if specified, or the executable
1934 suffix otherwise, plus a dash is appended to the default @var{dumppfx}
1935 instead. Note, however, that unlike earlier cases of linking:
1938 gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
1941 does not append the output name @file{main} to @var{dumppfx}, because
1942 @option{-dumpdir} is explicitly specified. The goal is that the
1943 explicitly-specified @var{dumppfx} may contain the specified output name
1944 as part of the prefix, if desired; only an explicitly-specified
1945 @option{-dumpbase} would be combined with it, in order to avoid simply
1946 discarding a meaningful option.
1948 When compiling and then linking from a single input file, the linker
1949 output base name will only be appended to the default @var{dumppfx} as
1950 above if it does not share the base name with the single input file
1951 name. This has been covered in single-input linking cases above, but
1952 not with an explicit @option{-dumpdir} that inhibits the combination,
1953 even if overridden by @option{-save-temps=*}:
1956 gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
1959 Auxiliary outputs are named @file{foo.*}, and dump outputs
1960 @file{foo.c.*}, in the current working directory as ultimately requested
1961 by @option{-save-temps=cwd}.
1963 Summing it all up for an intuitive though slightly imprecise data flow:
1964 the primary output name is broken into a directory part and a basename
1965 part; @var{dumppfx} is set to the former, unless overridden by
1966 @option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set
1967 to the latter, unless overriden by @option{-dumpbase}. If there are
1968 multiple inputs or linking, this @var{dumpbase} may be combined with
1969 @var{dumppfx} and taken from each input file. Auxiliary output names
1970 for each input are formed by combining @var{dumppfx}, @var{dumpbase}
1971 minus suffix, and the auxiliary output suffix; dump output names are
1972 only different in that the suffix from @var{dumpbase} is retained.
1974 When it comes to auxiliary and dump outputs created during LTO
1975 recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as
1976 given or as derived from the linker output name but not from inputs,
1977 even in cases in which this combination would not otherwise be used as
1978 such, is passed down with a trailing period replacing the compiler-added
1979 dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper};
1980 being involved in linking, this program does not normally get any
1981 @option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them.
1983 When running sub-compilers, @command{lto-wrapper} appends LTO stage
1984 names to the received @var{dumppfx}, ensures it contains a directory
1985 component so that it overrides any @option{-dumpdir}, and passes that as
1986 @option{-dumpbase} to sub-compilers.
1990 Print (on standard error output) the commands executed to run the stages
1991 of compilation. Also print the version number of the compiler driver
1992 program and of the preprocessor and the compiler proper.
1996 Like @option{-v} except the commands are not executed and arguments
1997 are quoted unless they contain only alphanumeric characters or @code{./-_}.
1998 This is useful for shell scripts to capture the driver-generated command lines.
2002 Print (on the standard output) a description of the command-line options
2003 understood by @command{gcc}. If the @option{-v} option is also specified
2004 then @option{--help} is also passed on to the various processes
2005 invoked by @command{gcc}, so that they can display the command-line options
2006 they accept. If the @option{-Wextra} option has also been specified
2007 (prior to the @option{--help} option), then command-line options that
2008 have no documentation associated with them are also displayed.
2011 @opindex target-help
2012 Print (on the standard output) a description of target-specific command-line
2013 options for each tool. For some targets extra target-specific
2014 information may also be printed.
2016 @item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
2017 Print (on the standard output) a description of the command-line
2018 options understood by the compiler that fit into all specified classes
2019 and qualifiers. These are the supported classes:
2022 @item @samp{optimizers}
2023 Display all of the optimization options supported by the
2026 @item @samp{warnings}
2027 Display all of the options controlling warning messages
2028 produced by the compiler.
2031 Display target-specific options. Unlike the
2032 @option{--target-help} option however, target-specific options of the
2033 linker and assembler are not displayed. This is because those
2034 tools do not currently support the extended @option{--help=} syntax.
2037 Display the values recognized by the @option{--param}
2040 @item @var{language}
2041 Display the options supported for @var{language}, where
2042 @var{language} is the name of one of the languages supported in this
2043 version of GCC@. If an option is supported by all languages, one needs
2044 to select @samp{common} class.
2047 Display the options that are common to all languages.
2050 These are the supported qualifiers:
2053 @item @samp{undocumented}
2054 Display only those options that are undocumented.
2057 Display options taking an argument that appears after an equal
2058 sign in the same continuous piece of text, such as:
2059 @samp{--help=target}.
2061 @item @samp{separate}
2062 Display options taking an argument that appears as a separate word
2063 following the original option, such as: @samp{-o output-file}.
2066 Thus for example to display all the undocumented target-specific
2067 switches supported by the compiler, use:
2070 --help=target,undocumented
2073 The sense of a qualifier can be inverted by prefixing it with the
2074 @samp{^} character, so for example to display all binary warning
2075 options (i.e., ones that are either on or off and that do not take an
2076 argument) that have a description, use:
2079 --help=warnings,^joined,^undocumented
2082 The argument to @option{--help=} should not consist solely of inverted
2085 Combining several classes is possible, although this usually
2086 restricts the output so much that there is nothing to display. One
2087 case where it does work, however, is when one of the classes is
2088 @var{target}. For example, to display all the target-specific
2089 optimization options, use:
2092 --help=target,optimizers
2095 The @option{--help=} option can be repeated on the command line. Each
2096 successive use displays its requested class of options, skipping
2097 those that have already been displayed. If @option{--help} is also
2098 specified anywhere on the command line then this takes precedence
2099 over any @option{--help=} option.
2101 If the @option{-Q} option appears on the command line before the
2102 @option{--help=} option, then the descriptive text displayed by
2103 @option{--help=} is changed. Instead of describing the displayed
2104 options, an indication is given as to whether the option is enabled,
2105 disabled or set to a specific value (assuming that the compiler
2106 knows this at the point where the @option{--help=} option is used).
2108 Here is a truncated example from the ARM port of @command{gcc}:
2111 % gcc -Q -mabi=2 --help=target -c
2112 The following options are target specific:
2114 -mabort-on-noreturn [disabled]
2118 The output is sensitive to the effects of previous command-line
2119 options, so for example it is possible to find out which optimizations
2120 are enabled at @option{-O2} by using:
2123 -Q -O2 --help=optimizers
2126 Alternatively you can discover which binary optimizations are enabled
2127 by @option{-O3} by using:
2130 gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
2131 gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
2132 diff /tmp/O2-opts /tmp/O3-opts | grep enabled
2137 Display the version number and copyrights of the invoked GCC@.
2139 @item -pass-exit-codes
2140 @opindex pass-exit-codes
2141 Normally the @command{gcc} program exits with the code of 1 if any
2142 phase of the compiler returns a non-success return code. If you specify
2143 @option{-pass-exit-codes}, the @command{gcc} program instead returns with
2144 the numerically highest error produced by any phase returning an error
2145 indication. The C, C++, and Fortran front ends return 4 if an internal
2146 compiler error is encountered.
2150 Use pipes rather than temporary files for communication between the
2151 various stages of compilation. This fails to work on some systems where
2152 the assembler is unable to read from a pipe; but the GNU assembler has
2155 @item -specs=@var{file}
2157 Process @var{file} after the compiler reads in the standard @file{specs}
2158 file, in order to override the defaults which the @command{gcc} driver
2159 program uses when determining what switches to pass to @command{cc1},
2160 @command{cc1plus}, @command{as}, @command{ld}, etc. More than one
2161 @option{-specs=@var{file}} can be specified on the command line, and they
2162 are processed in order, from left to right. @xref{Spec Files}, for
2163 information about the format of the @var{file}.
2167 Invoke all subcommands under a wrapper program. The name of the
2168 wrapper program and its parameters are passed as a comma separated
2172 gcc -c t.c -wrapper gdb,--args
2176 This invokes all subprograms of @command{gcc} under
2177 @samp{gdb --args}, thus the invocation of @command{cc1} is
2178 @samp{gdb --args cc1 @dots{}}.
2180 @item -ffile-prefix-map=@var{old}=@var{new}
2181 @opindex ffile-prefix-map
2182 When compiling files residing in directory @file{@var{old}}, record
2183 any references to them in the result of the compilation as if the
2184 files resided in directory @file{@var{new}} instead. Specifying this
2185 option is equivalent to specifying all the individual
2186 @option{-f*-prefix-map} options. This can be used to make reproducible
2187 builds that are location independent. See also
2188 @option{-fmacro-prefix-map}, @option{-fdebug-prefix-map} and
2189 @option{-fprofile-prefix-map}.
2191 @item -fplugin=@var{name}.so
2193 Load the plugin code in file @var{name}.so, assumed to be a
2194 shared object to be dlopen'd by the compiler. The base name of
2195 the shared object file is used to identify the plugin for the
2196 purposes of argument parsing (See
2197 @option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below).
2198 Each plugin should define the callback functions specified in the
2201 @item -fplugin-arg-@var{name}-@var{key}=@var{value}
2202 @opindex fplugin-arg
2203 Define an argument called @var{key} with a value of @var{value}
2204 for the plugin called @var{name}.
2206 @item -fdump-ada-spec@r{[}-slim@r{]}
2207 @opindex fdump-ada-spec
2208 For C and C++ source and include files, generate corresponding Ada specs.
2209 @xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
2210 GNAT User's Guide}, which provides detailed documentation on this feature.
2212 @item -fada-spec-parent=@var{unit}
2213 @opindex fada-spec-parent
2214 In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate
2215 Ada specs as child units of parent @var{unit}.
2217 @item -fdump-go-spec=@var{file}
2218 @opindex fdump-go-spec
2219 For input files in any language, generate corresponding Go
2220 declarations in @var{file}. This generates Go @code{const},
2221 @code{type}, @code{var}, and @code{func} declarations which may be a
2222 useful way to start writing a Go interface to code written in some
2225 @include @value{srcdir}/../libiberty/at-file.texi
2229 @section Compiling C++ Programs
2231 @cindex suffixes for C++ source
2232 @cindex C++ source file suffixes
2233 C++ source files conventionally use one of the suffixes @samp{.C},
2234 @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
2235 @samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
2236 @samp{.H}, or (for shared template code) @samp{.tcc}; and
2237 preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
2238 files with these names and compiles them as C++ programs even if you
2239 call the compiler the same way as for compiling C programs (usually
2240 with the name @command{gcc}).
2244 However, the use of @command{gcc} does not add the C++ library.
2245 @command{g++} is a program that calls GCC and automatically specifies linking
2246 against the C++ library. It treats @samp{.c},
2247 @samp{.h} and @samp{.i} files as C++ source files instead of C source
2248 files unless @option{-x} is used. This program is also useful when
2249 precompiling a C header file with a @samp{.h} extension for use in C++
2250 compilations. On many systems, @command{g++} is also installed with
2251 the name @command{c++}.
2253 @cindex invoking @command{g++}
2254 When you compile C++ programs, you may specify many of the same
2255 command-line options that you use for compiling programs in any
2256 language; or command-line options meaningful for C and related
2257 languages; or options that are meaningful only for C++ programs.
2258 @xref{C Dialect Options,,Options Controlling C Dialect}, for
2259 explanations of options for languages related to C@.
2260 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
2261 explanations of options that are meaningful only for C++ programs.
2263 @node C Dialect Options
2264 @section Options Controlling C Dialect
2265 @cindex dialect options
2266 @cindex language dialect options
2267 @cindex options, dialect
2269 The following options control the dialect of C (or languages derived
2270 from C, such as C++, Objective-C and Objective-C++) that the compiler
2274 @cindex ANSI support
2278 In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
2279 equivalent to @option{-std=c++98}.
2281 This turns off certain features of GCC that are incompatible with ISO
2282 C90 (when compiling C code), or of standard C++ (when compiling C++ code),
2283 such as the @code{asm} and @code{typeof} keywords, and
2284 predefined macros such as @code{unix} and @code{vax} that identify the
2285 type of system you are using. It also enables the undesirable and
2286 rarely used ISO trigraph feature. For the C compiler,
2287 it disables recognition of C++ style @samp{//} comments as well as
2288 the @code{inline} keyword.
2290 The alternate keywords @code{__asm__}, @code{__extension__},
2291 @code{__inline__} and @code{__typeof__} continue to work despite
2292 @option{-ansi}. You would not want to use them in an ISO C program, of
2293 course, but it is useful to put them in header files that might be included
2294 in compilations done with @option{-ansi}. Alternate predefined macros
2295 such as @code{__unix__} and @code{__vax__} are also available, with or
2296 without @option{-ansi}.
2298 The @option{-ansi} option does not cause non-ISO programs to be
2299 rejected gratuitously. For that, @option{-Wpedantic} is required in
2300 addition to @option{-ansi}. @xref{Warning Options}.
2302 The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
2303 option is used. Some header files may notice this macro and refrain
2304 from declaring certain functions or defining certain macros that the
2305 ISO standard doesn't call for; this is to avoid interfering with any
2306 programs that might use these names for other things.
2308 Functions that are normally built in but do not have semantics
2309 defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
2310 functions when @option{-ansi} is used. @xref{Other Builtins,,Other
2311 built-in functions provided by GCC}, for details of the functions
2316 Determine the language standard. @xref{Standards,,Language Standards
2317 Supported by GCC}, for details of these standard versions. This option
2318 is currently only supported when compiling C or C++.
2320 The compiler can accept several base standards, such as @samp{c90} or
2321 @samp{c++98}, and GNU dialects of those standards, such as
2322 @samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the
2323 compiler accepts all programs following that standard plus those
2324 using GNU extensions that do not contradict it. For example,
2325 @option{-std=c90} turns off certain features of GCC that are
2326 incompatible with ISO C90, such as the @code{asm} and @code{typeof}
2327 keywords, but not other GNU extensions that do not have a meaning in
2328 ISO C90, such as omitting the middle term of a @code{?:}
2329 expression. On the other hand, when a GNU dialect of a standard is
2330 specified, all features supported by the compiler are enabled, even when
2331 those features change the meaning of the base standard. As a result, some
2332 strict-conforming programs may be rejected. The particular standard
2333 is used by @option{-Wpedantic} to identify which features are GNU
2334 extensions given that version of the standard. For example
2335 @option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//}
2336 comments, while @option{-std=gnu99 -Wpedantic} does not.
2338 A value for this option must be provided; possible values are
2344 Support all ISO C90 programs (certain GNU extensions that conflict
2345 with ISO C90 are disabled). Same as @option{-ansi} for C code.
2347 @item iso9899:199409
2348 ISO C90 as modified in amendment 1.
2354 ISO C99. This standard is substantially completely supported, modulo
2355 bugs and floating-point issues
2356 (mainly but not entirely relating to optional C99 features from
2357 Annexes F and G). See
2358 @w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The
2359 names @samp{c9x} and @samp{iso9899:199x} are deprecated.
2364 ISO C11, the 2011 revision of the ISO C standard. This standard is
2365 substantially completely supported, modulo bugs, floating-point issues
2366 (mainly but not entirely relating to optional C11 features from
2367 Annexes F and G) and the optional Annexes K (Bounds-checking
2368 interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
2374 ISO C17, the 2017 revision of the ISO C standard
2375 (published in 2018). This standard is
2376 same as C11 except for corrections of defects (all of which are also
2377 applied with @option{-std=c11}) and a new value of
2378 @code{__STDC_VERSION__}, and so is supported to the same extent as C11.
2381 The next version of the ISO C standard, still under development. The
2382 support for this version is experimental and incomplete.
2386 GNU dialect of ISO C90 (including some C99 features).
2390 GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
2394 GNU dialect of ISO C11.
2395 The name @samp{gnu1x} is deprecated.
2399 GNU dialect of ISO C17. This is the default for C code.
2402 The next version of the ISO C standard, still under development, plus
2403 GNU extensions. The support for this version is experimental and
2408 The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
2409 additional defect reports. Same as @option{-ansi} for C++ code.
2413 GNU dialect of @option{-std=c++98}.
2417 The 2011 ISO C++ standard plus amendments.
2418 The name @samp{c++0x} is deprecated.
2422 GNU dialect of @option{-std=c++11}.
2423 The name @samp{gnu++0x} is deprecated.
2427 The 2014 ISO C++ standard plus amendments.
2428 The name @samp{c++1y} is deprecated.
2432 GNU dialect of @option{-std=c++14}.
2433 The name @samp{gnu++1y} is deprecated.
2437 The 2017 ISO C++ standard plus amendments.
2438 The name @samp{c++1z} is deprecated.
2442 GNU dialect of @option{-std=c++17}.
2443 This is the default for C++ code.
2444 The name @samp{gnu++1z} is deprecated.
2448 The 2020 ISO C++ standard plus amendments.
2449 Support is experimental, and could change in incompatible ways in
2451 The name @samp{c++2a} is deprecated.
2455 GNU dialect of @option{-std=c++20}.
2456 Support is experimental, and could change in incompatible ways in
2458 The name @samp{gnu++2a} is deprecated.
2462 The next revision of the ISO C++ standard, planned for
2463 2023. Support is highly experimental, and will almost certainly
2464 change in incompatible ways in future releases.
2468 GNU dialect of @option{-std=c++2b}. Support is highly experimental,
2469 and will almost certainly change in incompatible ways in future
2473 @item -aux-info @var{filename}
2475 Output to the given filename prototyped declarations for all functions
2476 declared and/or defined in a translation unit, including those in header
2477 files. This option is silently ignored in any language other than C@.
2479 Besides declarations, the file indicates, in comments, the origin of
2480 each declaration (source file and line), whether the declaration was
2481 implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
2482 @samp{O} for old, respectively, in the first character after the line
2483 number and the colon), and whether it came from a declaration or a
2484 definition (@samp{C} or @samp{F}, respectively, in the following
2485 character). In the case of function definitions, a K&R-style list of
2486 arguments followed by their declarations is also provided, inside
2487 comments, after the declaration.
2489 @item -fallow-parameterless-variadic-functions
2490 @opindex fallow-parameterless-variadic-functions
2491 Accept variadic functions without named parameters.
2493 Although it is possible to define such a function, this is not very
2494 useful as it is not possible to read the arguments. This is only
2495 supported for C as this construct is allowed by C++.
2500 Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
2501 keyword, so that code can use these words as identifiers. You can use
2502 the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
2503 instead. In C, @option{-ansi} implies @option{-fno-asm}.
2505 In C++, @code{inline} is a standard keyword and is not affected by
2506 this switch. You may want to use the @option{-fno-gnu-keywords} flag
2507 instead, which disables @code{typeof} but not @code{asm} and
2508 @code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
2509 this switch only affects the @code{asm} and @code{typeof} keywords,
2510 since @code{inline} is a standard keyword in ISO C99.
2513 @itemx -fno-builtin-@var{function}
2514 @opindex fno-builtin
2516 @cindex built-in functions
2517 Don't recognize built-in functions that do not begin with
2518 @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
2519 functions provided by GCC}, for details of the functions affected,
2520 including those which are not built-in functions when @option{-ansi} or
2521 @option{-std} options for strict ISO C conformance are used because they
2522 do not have an ISO standard meaning.
2524 GCC normally generates special code to handle certain built-in functions
2525 more efficiently; for instance, calls to @code{alloca} may become single
2526 instructions which adjust the stack directly, and calls to @code{memcpy}
2527 may become inline copy loops. The resulting code is often both smaller
2528 and faster, but since the function calls no longer appear as such, you
2529 cannot set a breakpoint on those calls, nor can you change the behavior
2530 of the functions by linking with a different library. In addition,
2531 when a function is recognized as a built-in function, GCC may use
2532 information about that function to warn about problems with calls to
2533 that function, or to generate more efficient code, even if the
2534 resulting code still contains calls to that function. For example,
2535 warnings are given with @option{-Wformat} for bad calls to
2536 @code{printf} when @code{printf} is built in and @code{strlen} is
2537 known not to modify global memory.
2539 With the @option{-fno-builtin-@var{function}} option
2540 only the built-in function @var{function} is
2541 disabled. @var{function} must not begin with @samp{__builtin_}. If a
2542 function is named that is not built-in in this version of GCC, this
2543 option is ignored. There is no corresponding
2544 @option{-fbuiltin-@var{function}} option; if you wish to enable
2545 built-in functions selectively when using @option{-fno-builtin} or
2546 @option{-ffreestanding}, you may define macros such as:
2549 #define abs(n) __builtin_abs ((n))
2550 #define strcpy(d, s) __builtin_strcpy ((d), (s))
2553 @item -fcond-mismatch
2554 @opindex fcond-mismatch
2555 Allow conditional expressions with mismatched types in the second and
2556 third arguments. The value of such an expression is void. This option
2557 is not supported for C++.
2559 @item -ffreestanding
2560 @opindex ffreestanding
2561 @cindex hosted environment
2563 Assert that compilation targets a freestanding environment. This
2564 implies @option{-fno-builtin}. A freestanding environment
2565 is one in which the standard library may not exist, and program startup may
2566 not necessarily be at @code{main}. The most obvious example is an OS kernel.
2567 This is equivalent to @option{-fno-hosted}.
2569 @xref{Standards,,Language Standards Supported by GCC}, for details of
2570 freestanding and hosted environments.
2575 Enable parsing of function definitions marked with @code{__GIMPLE}.
2576 This is an experimental feature that allows unit testing of GIMPLE
2581 When the option @option{-fgnu-tm} is specified, the compiler
2582 generates code for the Linux variant of Intel's current Transactional
2583 Memory ABI specification document (Revision 1.1, May 6 2009). This is
2584 an experimental feature whose interface may change in future versions
2585 of GCC, as the official specification changes. Please note that not
2586 all architectures are supported for this feature.
2588 For more information on GCC's support for transactional memory,
2589 @xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
2590 Transactional Memory Library}.
2592 Note that the transactional memory feature is not supported with
2593 non-call exceptions (@option{-fnon-call-exceptions}).
2595 @item -fgnu89-inline
2596 @opindex fgnu89-inline
2597 The option @option{-fgnu89-inline} tells GCC to use the traditional
2598 GNU semantics for @code{inline} functions when in C99 mode.
2599 @xref{Inline,,An Inline Function is As Fast As a Macro}.
2600 Using this option is roughly equivalent to adding the
2601 @code{gnu_inline} function attribute to all inline functions
2602 (@pxref{Function Attributes}).
2604 The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
2605 C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
2606 specifies the default behavior).
2607 This option is not supported in @option{-std=c90} or
2608 @option{-std=gnu90} mode.
2610 The preprocessor macros @code{__GNUC_GNU_INLINE__} and
2611 @code{__GNUC_STDC_INLINE__} may be used to check which semantics are
2612 in effect for @code{inline} functions. @xref{Common Predefined
2613 Macros,,,cpp,The C Preprocessor}.
2617 @cindex hosted environment
2619 Assert that compilation targets a hosted environment. This implies
2620 @option{-fbuiltin}. A hosted environment is one in which the
2621 entire standard library is available, and in which @code{main} has a return
2622 type of @code{int}. Examples are nearly everything except a kernel.
2623 This is equivalent to @option{-fno-freestanding}.
2625 @item -flax-vector-conversions
2626 @opindex flax-vector-conversions
2627 Allow implicit conversions between vectors with differing numbers of
2628 elements and/or incompatible element types. This option should not be
2631 @item -fms-extensions
2632 @opindex fms-extensions
2633 Accept some non-standard constructs used in Microsoft header files.
2635 In C++ code, this allows member names in structures to be similar
2636 to previous types declarations.
2645 Some cases of unnamed fields in structures and unions are only
2646 accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
2647 fields within structs/unions}, for details.
2649 Note that this option is off for all targets except for x86
2650 targets using ms-abi.
2652 @item -foffload=disable
2653 @itemx -foffload=default
2654 @itemx -foffload=@var{target-list}
2656 @cindex Offloading targets
2657 @cindex OpenACC offloading targets
2658 @cindex OpenMP offloading targets
2659 Specify for which OpenMP and OpenACC offload targets code should be generated.
2660 The default behavior, equivalent to @option{-foffload=default}, is to generate
2661 code for all supported offload targets. The @option{-foffload=disable} form
2662 generates code only for the host fallback, while
2663 @option{-foffload=@var{target-list}} generates code only for the specified
2664 comma-separated list of offload targets.
2666 Offload targets are specified in GCC's internal target-triplet format. You can
2667 run the compiler with @option{-v} to show the list of configured offload targets
2668 under @code{OFFLOAD_TARGET_NAMES}.
2670 @item -foffload-options=@var{options}
2671 @itemx -foffload-options=@var{target-triplet-list}=@var{options}
2672 @opindex foffload-options
2673 @cindex Offloading options
2674 @cindex OpenACC offloading options
2675 @cindex OpenMP offloading options
2677 With @option{-foffload-options=@var{options}}, GCC passes the specified
2678 @var{options} to the compilers for all enabled offloading targets. You can
2679 specify options that apply only to a specific target or targets by using
2680 the @option{-foffload-options=@var{target-list}=@var{options}} form. The
2681 @var{target-list} is a comma-separated list in the same format as for the
2682 @option{-foffload=} option.
2684 Typical command lines are
2687 -foffload-options=-lgfortran -foffload-options=-lm
2688 -foffload-options="-lgfortran -lm" -foffload-options=nvptx-none=-latomic
2689 -foffload-options=amdgcn-amdhsa=-march=gfx906 -foffload-options=-lm
2694 @cindex OpenACC accelerator programming
2695 Enable handling of OpenACC directives @code{#pragma acc} in C/C++ and
2696 @code{!$acc} in Fortran. When @option{-fopenacc} is specified, the
2697 compiler generates accelerated code according to the OpenACC Application
2698 Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option
2699 implies @option{-pthread}, and thus is only supported on targets that
2700 have support for @option{-pthread}.
2702 @item -fopenacc-dim=@var{geom}
2703 @opindex fopenacc-dim
2704 @cindex OpenACC accelerator programming
2705 Specify default compute dimensions for parallel offload regions that do
2706 not explicitly specify. The @var{geom} value is a triple of
2707 ':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size
2708 can be omitted, to use a target-specific default value.
2712 @cindex OpenMP parallel
2713 Enable handling of OpenMP directives @code{#pragma omp} in C/C++ and
2714 @code{!$omp} in Fortran. When @option{-fopenmp} is specified, the
2715 compiler generates parallel code according to the OpenMP Application
2716 Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option
2717 implies @option{-pthread}, and thus is only supported on targets that
2718 have support for @option{-pthread}. @option{-fopenmp} implies
2719 @option{-fopenmp-simd}.
2722 @opindex fopenmp-simd
2725 Enable handling of OpenMP's SIMD directives with @code{#pragma omp}
2726 in C/C++ and @code{!$omp} in Fortran. Other OpenMP directives
2729 @item -fpermitted-flt-eval-methods=@var{style}
2730 @opindex fpermitted-flt-eval-methods
2731 @opindex fpermitted-flt-eval-methods=c11
2732 @opindex fpermitted-flt-eval-methods=ts-18661-3
2733 ISO/IEC TS 18661-3 defines new permissible values for
2734 @code{FLT_EVAL_METHOD} that indicate that operations and constants with
2735 a semantic type that is an interchange or extended format should be
2736 evaluated to the precision and range of that type. These new values are
2737 a superset of those permitted under C99/C11, which does not specify the
2738 meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code
2739 conforming to C11 may not have been written expecting the possibility of
2742 @option{-fpermitted-flt-eval-methods} specifies whether the compiler
2743 should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11,
2744 or the extended set of values specified in ISO/IEC TS 18661-3.
2746 @var{style} is either @code{c11} or @code{ts-18661-3} as appropriate.
2748 The default when in a standards compliant mode (@option{-std=c11} or similar)
2749 is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU
2750 dialect (@option{-std=gnu11} or similar) is
2751 @option{-fpermitted-flt-eval-methods=ts-18661-3}.
2753 @item -fplan9-extensions
2754 @opindex fplan9-extensions
2755 Accept some non-standard constructs used in Plan 9 code.
2757 This enables @option{-fms-extensions}, permits passing pointers to
2758 structures with anonymous fields to functions that expect pointers to
2759 elements of the type of the field, and permits referring to anonymous
2760 fields declared using a typedef. @xref{Unnamed Fields,,Unnamed
2761 struct/union fields within structs/unions}, for details. This is only
2762 supported for C, not C++.
2764 @item -fsigned-bitfields
2765 @itemx -funsigned-bitfields
2766 @itemx -fno-signed-bitfields
2767 @itemx -fno-unsigned-bitfields
2768 @opindex fsigned-bitfields
2769 @opindex funsigned-bitfields
2770 @opindex fno-signed-bitfields
2771 @opindex fno-unsigned-bitfields
2772 These options control whether a bit-field is signed or unsigned, when the
2773 declaration does not use either @code{signed} or @code{unsigned}. By
2774 default, such a bit-field is signed, because this is consistent: the
2775 basic integer types such as @code{int} are signed types.
2778 @opindex fsigned-char
2779 Let the type @code{char} be signed, like @code{signed char}.
2781 Note that this is equivalent to @option{-fno-unsigned-char}, which is
2782 the negative form of @option{-funsigned-char}. Likewise, the option
2783 @option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
2785 @item -funsigned-char
2786 @opindex funsigned-char
2787 Let the type @code{char} be unsigned, like @code{unsigned char}.
2789 Each kind of machine has a default for what @code{char} should
2790 be. It is either like @code{unsigned char} by default or like
2791 @code{signed char} by default.
2793 Ideally, a portable program should always use @code{signed char} or
2794 @code{unsigned char} when it depends on the signedness of an object.
2795 But many programs have been written to use plain @code{char} and
2796 expect it to be signed, or expect it to be unsigned, depending on the
2797 machines they were written for. This option, and its inverse, let you
2798 make such a program work with the opposite default.
2800 The type @code{char} is always a distinct type from each of
2801 @code{signed char} or @code{unsigned char}, even though its behavior
2802 is always just like one of those two.
2804 @item -fsso-struct=@var{endianness}
2805 @opindex fsso-struct
2806 Set the default scalar storage order of structures and unions to the
2807 specified endianness. The accepted values are @samp{big-endian},
2808 @samp{little-endian} and @samp{native} for the native endianness of
2809 the target (the default). This option is not supported for C++.
2811 @strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate
2812 code that is not binary compatible with code generated without it if the
2813 specified endianness is not the native endianness of the target.
2816 @node C++ Dialect Options
2817 @section Options Controlling C++ Dialect
2819 @cindex compiler options, C++
2820 @cindex C++ options, command-line
2821 @cindex options, C++
2822 This section describes the command-line options that are only meaningful
2823 for C++ programs. You can also use most of the GNU compiler options
2824 regardless of what language your program is in. For example, you
2825 might compile a file @file{firstClass.C} like this:
2828 g++ -g -fstrict-enums -O -c firstClass.C
2832 In this example, only @option{-fstrict-enums} is an option meant
2833 only for C++ programs; you can use the other options with any
2834 language supported by GCC@.
2836 Some options for compiling C programs, such as @option{-std}, are also
2837 relevant for C++ programs.
2838 @xref{C Dialect Options,,Options Controlling C Dialect}.
2840 Here is a list of options that are @emph{only} for compiling C++ programs:
2844 @item -fabi-version=@var{n}
2845 @opindex fabi-version
2846 Use version @var{n} of the C++ ABI@. The default is version 0.
2848 Version 0 refers to the version conforming most closely to
2849 the C++ ABI specification. Therefore, the ABI obtained using version 0
2850 will change in different versions of G++ as ABI bugs are fixed.
2852 Version 1 is the version of the C++ ABI that first appeared in G++ 3.2.
2854 Version 2 is the version of the C++ ABI that first appeared in G++
2855 3.4, and was the default through G++ 4.9.
2857 Version 3 corrects an error in mangling a constant address as a
2860 Version 4, which first appeared in G++ 4.5, implements a standard
2861 mangling for vector types.
2863 Version 5, which first appeared in G++ 4.6, corrects the mangling of
2864 attribute const/volatile on function pointer types, decltype of a
2865 plain decl, and use of a function parameter in the declaration of
2868 Version 6, which first appeared in G++ 4.7, corrects the promotion
2869 behavior of C++11 scoped enums and the mangling of template argument
2870 packs, const/static_cast, prefix ++ and --, and a class scope function
2871 used as a template argument.
2873 Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a
2874 builtin type and corrects the mangling of lambdas in default argument
2877 Version 8, which first appeared in G++ 4.9, corrects the substitution
2878 behavior of function types with function-cv-qualifiers.
2880 Version 9, which first appeared in G++ 5.2, corrects the alignment of
2883 Version 10, which first appeared in G++ 6.1, adds mangling of
2884 attributes that affect type identity, such as ia32 calling convention
2885 attributes (e.g.@: @samp{stdcall}).
2887 Version 11, which first appeared in G++ 7, corrects the mangling of
2888 sizeof... expressions and operator names. For multiple entities with
2889 the same name within a function, that are declared in different scopes,
2890 the mangling now changes starting with the twelfth occurrence. It also
2891 implies @option{-fnew-inheriting-ctors}.
2893 Version 12, which first appeared in G++ 8, corrects the calling
2894 conventions for empty classes on the x86_64 target and for classes
2895 with only deleted copy/move constructors. It accidentally changes the
2896 calling convention for classes with a deleted copy constructor and a
2897 trivial move constructor.
2899 Version 13, which first appeared in G++ 8.2, fixes the accidental
2900 change in version 12.
2902 Version 14, which first appeared in G++ 10, corrects the mangling of
2903 the nullptr expression.
2905 Version 15, which first appeared in G++ 11, changes the mangling of
2906 @code{__alignof__} to be distinct from that of @code{alignof}, and
2907 dependent operator names.
2909 See also @option{-Wabi}.
2911 @item -fabi-compat-version=@var{n}
2912 @opindex fabi-compat-version
2913 On targets that support strong aliases, G++
2914 works around mangling changes by creating an alias with the correct
2915 mangled name when defining a symbol with an incorrect mangled name.
2916 This switch specifies which ABI version to use for the alias.
2918 With @option{-fabi-version=0} (the default), this defaults to 11 (GCC 7
2919 compatibility). If another ABI version is explicitly selected, this
2920 defaults to 0. For compatibility with GCC versions 3.2 through 4.9,
2921 use @option{-fabi-compat-version=2}.
2923 If this option is not provided but @option{-Wabi=@var{n}} is, that
2924 version is used for compatibility aliases. If this option is provided
2925 along with @option{-Wabi} (without the version), the version from this
2926 option is used for the warning.
2928 @item -fno-access-control
2929 @opindex fno-access-control
2930 @opindex faccess-control
2931 Turn off all access checking. This switch is mainly useful for working
2932 around bugs in the access control code.
2935 @opindex faligned-new
2936 Enable support for C++17 @code{new} of types that require more
2937 alignment than @code{void* ::operator new(std::size_t)} provides. A
2938 numeric argument such as @code{-faligned-new=32} can be used to
2939 specify how much alignment (in bytes) is provided by that function,
2940 but few users will need to override the default of
2941 @code{alignof(std::max_align_t)}.
2943 This flag is enabled by default for @option{-std=c++17}.
2948 @opindex fno-char8_t
2949 Enable support for @code{char8_t} as adopted for C++20. This includes
2950 the addition of a new @code{char8_t} fundamental type, changes to the
2951 types of UTF-8 string and character literals, new signatures for
2952 user-defined literals, associated standard library updates, and new
2953 @code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
2955 This option enables functions to be overloaded for ordinary and UTF-8
2959 int f(const char *); // #1
2960 int f(const char8_t *); // #2
2961 int v1 = f("text"); // Calls #1
2962 int v2 = f(u8"text"); // Calls #2
2966 and introduces new signatures for user-defined literals:
2969 int operator""_udl1(char8_t);
2970 int v3 = u8'x'_udl1;
2971 int operator""_udl2(const char8_t*, std::size_t);
2972 int v4 = u8"text"_udl2;
2973 template<typename T, T...> int operator""_udl3();
2974 int v5 = u8"text"_udl3;
2978 The change to the types of UTF-8 string and character literals introduces
2979 incompatibilities with ISO C++11 and later standards. For example, the
2980 following code is well-formed under ISO C++11, but is ill-formed when
2981 @option{-fchar8_t} is specified.
2984 char ca[] = u8"xx"; // error: char-array initialized from wide
2986 const char *cp = u8"xx";// error: invalid conversion from
2987 // `const char8_t*' to `const char*'
2989 auto v = f(u8"xx"); // error: invalid conversion from
2990 // `const char8_t*' to `const char*'
2991 std::string s@{u8"xx"@}; // error: no matching function for call to
2992 // `std::basic_string<char>::basic_string()'
2993 using namespace std::literals;
2994 s = u8"xx"s; // error: conversion from
2995 // `basic_string<char8_t>' to non-scalar
2996 // type `basic_string<char>' requested
3001 Check that the pointer returned by @code{operator new} is non-null
3002 before attempting to modify the storage allocated. This check is
3003 normally unnecessary because the C++ standard specifies that
3004 @code{operator new} only returns @code{0} if it is declared
3005 @code{throw()}, in which case the compiler always checks the
3006 return value even without this option. In all other cases, when
3007 @code{operator new} has a non-empty exception specification, memory
3008 exhaustion is signalled by throwing @code{std::bad_alloc}. See also
3009 @samp{new (nothrow)}.
3012 @itemx -fconcepts-ts
3014 @opindex fconcepts-ts
3015 Below @option{-std=c++20}, @option{-fconcepts} enables support for the
3016 C++ Extensions for Concepts Technical Specification, ISO 19217 (2015).
3018 With @option{-std=c++20} and above, Concepts are part of the language
3019 standard, so @option{-fconcepts} defaults to on. But the standard
3020 specification of Concepts differs significantly from the TS, so some
3021 constructs that were allowed in the TS but didn't make it into the
3022 standard can still be enabled by @option{-fconcepts-ts}.
3024 @item -fconstexpr-depth=@var{n}
3025 @opindex fconstexpr-depth
3026 Set the maximum nested evaluation depth for C++11 constexpr functions
3027 to @var{n}. A limit is needed to detect endless recursion during
3028 constant expression evaluation. The minimum specified by the standard
3031 @item -fconstexpr-cache-depth=@var{n}
3032 @opindex fconstexpr-cache-depth
3033 Set the maximum level of nested evaluation depth for C++11 constexpr
3034 functions that will be cached to @var{n}. This is a heuristic that
3035 trades off compilation speed (when the cache avoids repeated
3036 calculations) against memory consumption (when the cache grows very
3037 large from highly recursive evaluations). The default is 8. Very few
3038 users are likely to want to adjust it, but if your code does heavy
3039 constexpr calculations you might want to experiment to find which
3040 value works best for you.
3042 @item -fconstexpr-fp-except
3043 @opindex fconstexpr-fp-except
3044 Annex F of the C standard specifies that IEC559 floating point
3045 exceptions encountered at compile time should not stop compilation.
3046 C++ compilers have historically not followed this guidance, instead
3047 treating floating point division by zero as non-constant even though
3048 it has a well defined value. This flag tells the compiler to give
3049 Annex F priority over other rules saying that a particular operation
3053 constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except
3056 @item -fconstexpr-loop-limit=@var{n}
3057 @opindex fconstexpr-loop-limit
3058 Set the maximum number of iterations for a loop in C++14 constexpr functions
3059 to @var{n}. A limit is needed to detect infinite loops during
3060 constant expression evaluation. The default is 262144 (1<<18).
3062 @item -fconstexpr-ops-limit=@var{n}
3063 @opindex fconstexpr-ops-limit
3064 Set the maximum number of operations during a single constexpr evaluation.
3065 Even when number of iterations of a single loop is limited with the above limit,
3066 if there are several nested loops and each of them has many iterations but still
3067 smaller than the above limit, or if in a body of some loop or even outside
3068 of a loop too many expressions need to be evaluated, the resulting constexpr
3069 evaluation might take too long.
3070 The default is 33554432 (1<<25).
3073 @opindex fcoroutines
3074 Enable support for the C++ coroutines extension (experimental).
3076 @item -fno-elide-constructors
3077 @opindex fno-elide-constructors
3078 @opindex felide-constructors
3079 The C++ standard allows an implementation to omit creating a temporary
3080 that is only used to initialize another object of the same type.
3081 Specifying this option disables that optimization, and forces G++ to
3082 call the copy constructor in all cases. This option also causes G++
3083 to call trivial member functions which otherwise would be expanded inline.
3085 In C++17, the compiler is required to omit these temporaries, but this
3086 option still affects trivial member functions.
3088 @item -fno-enforce-eh-specs
3089 @opindex fno-enforce-eh-specs
3090 @opindex fenforce-eh-specs
3091 Don't generate code to check for violation of exception specifications
3092 at run time. This option violates the C++ standard, but may be useful
3093 for reducing code size in production builds, much like defining
3094 @code{NDEBUG}. This does not give user code permission to throw
3095 exceptions in violation of the exception specifications; the compiler
3096 still optimizes based on the specifications, so throwing an
3097 unexpected exception results in undefined behavior at run time.
3099 @item -fextern-tls-init
3100 @itemx -fno-extern-tls-init
3101 @opindex fextern-tls-init
3102 @opindex fno-extern-tls-init
3103 The C++11 and OpenMP standards allow @code{thread_local} and
3104 @code{threadprivate} variables to have dynamic (runtime)
3105 initialization. To support this, any use of such a variable goes
3106 through a wrapper function that performs any necessary initialization.
3107 When the use and definition of the variable are in the same
3108 translation unit, this overhead can be optimized away, but when the
3109 use is in a different translation unit there is significant overhead
3110 even if the variable doesn't actually need dynamic initialization. If
3111 the programmer can be sure that no use of the variable in a
3112 non-defining TU needs to trigger dynamic initialization (either
3113 because the variable is statically initialized, or a use of the
3114 variable in the defining TU will be executed before any uses in
3115 another TU), they can avoid this overhead with the
3116 @option{-fno-extern-tls-init} option.
3118 On targets that support symbol aliases, the default is
3119 @option{-fextern-tls-init}. On targets that do not support symbol
3120 aliases, the default is @option{-fno-extern-tls-init}.
3122 @item -fno-gnu-keywords
3123 @opindex fno-gnu-keywords
3124 @opindex fgnu-keywords
3125 Do not recognize @code{typeof} as a keyword, so that code can use this
3126 word as an identifier. You can use the keyword @code{__typeof__} instead.
3127 This option is implied by the strict ISO C++ dialects: @option{-ansi},
3128 @option{-std=c++98}, @option{-std=c++11}, etc.
3130 @item -fimplicit-constexpr
3131 @opindex fimplicit-constexpr
3132 Make inline functions implicitly constexpr, if they satisfy the
3133 requirements for a constexpr function. This option can be used in
3134 C++14 mode or later. This can result in initialization changing from
3135 dynamic to static and other optimizations.
3137 @item -fno-implicit-templates
3138 @opindex fno-implicit-templates
3139 @opindex fimplicit-templates
3140 Never emit code for non-inline templates that are instantiated
3141 implicitly (i.e.@: by use); only emit code for explicit instantiations.
3142 If you use this option, you must take care to structure your code to
3143 include all the necessary explicit instantiations to avoid getting
3144 undefined symbols at link time.
3145 @xref{Template Instantiation}, for more information.
3147 @item -fno-implicit-inline-templates
3148 @opindex fno-implicit-inline-templates
3149 @opindex fimplicit-inline-templates
3150 Don't emit code for implicit instantiations of inline templates, either.
3151 The default is to handle inlines differently so that compiles with and
3152 without optimization need the same set of explicit instantiations.
3154 @item -fno-implement-inlines
3155 @opindex fno-implement-inlines
3156 @opindex fimplement-inlines
3157 To save space, do not emit out-of-line copies of inline functions
3158 controlled by @code{#pragma implementation}. This causes linker
3159 errors if these functions are not inlined everywhere they are called.
3162 @itemx -fno-modules-ts
3163 @opindex fmodules-ts
3164 @opindex fno-modules-ts
3165 Enable support for C++20 modules (@pxref{C++ Modules}). The
3166 @option{-fno-modules-ts} is usually not needed, as that is the
3167 default. Even though this is a C++20 feature, it is not currently
3168 implicitly enabled by selecting that standard version.
3170 @item -fmodule-header
3171 @itemx -fmodule-header=user
3172 @itemx -fmodule-header=system
3173 @opindex fmodule-header
3174 Compile a header file to create an importable header unit.
3176 @item -fmodule-implicit-inline
3177 @opindex fmodule-implicit-inline
3178 Member functions defined in their class definitions are not implicitly
3179 inline for modular code. This is different to traditional C++
3180 behavior, for good reasons. However, it may result in a difficulty
3181 during code porting. This option makes such function definitions
3182 implicitly inline. It does however generate an ABI incompatibility,
3183 so you must use it everywhere or nowhere. (Such definitions outside
3184 of a named module remain implicitly inline, regardless.)
3186 @item -fno-module-lazy
3187 @opindex fno-module-lazy
3188 @opindex fmodule-lazy
3189 Disable lazy module importing and module mapper creation.
3191 @item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
3192 @itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...}
3193 @itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]}
3194 @itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]}
3195 @itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]}
3196 @itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]}
3197 @vindex CXX_MODULE_MAPPER @r{environment variable}
3198 @opindex fmodule-mapper
3199 An oracle to query for module name to filename mappings. If
3200 unspecified the @env{CXX_MODULE_MAPPER} environment variable is used,
3201 and if that is unset, an in-process default is provided.
3204 @opindex fmodule-only
3205 Only emit the Compiled Module Interface, inhibiting any object file.
3207 @item -fms-extensions
3208 @opindex fms-extensions
3209 Disable Wpedantic warnings about constructs used in MFC, such as implicit
3210 int and getting a pointer to member function via non-standard syntax.
3212 @item -fnew-inheriting-ctors
3213 @opindex fnew-inheriting-ctors
3214 Enable the P0136 adjustment to the semantics of C++11 constructor
3215 inheritance. This is part of C++17 but also considered to be a Defect
3216 Report against C++11 and C++14. This flag is enabled by default
3217 unless @option{-fabi-version=10} or lower is specified.
3219 @item -fnew-ttp-matching
3220 @opindex fnew-ttp-matching
3221 Enable the P0522 resolution to Core issue 150, template template
3222 parameters and default arguments: this allows a template with default
3223 template arguments as an argument for a template template parameter
3224 with fewer template parameters. This flag is enabled by default for
3225 @option{-std=c++17}.
3227 @item -fno-nonansi-builtins
3228 @opindex fno-nonansi-builtins
3229 @opindex fnonansi-builtins
3230 Disable built-in declarations of functions that are not mandated by
3231 ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
3232 @code{index}, @code{bzero}, @code{conjf}, and other related functions.
3235 @opindex fnothrow-opt
3236 Treat a @code{throw()} exception specification as if it were a
3237 @code{noexcept} specification to reduce or eliminate the text size
3238 overhead relative to a function with no exception specification. If
3239 the function has local variables of types with non-trivial
3240 destructors, the exception specification actually makes the
3241 function smaller because the EH cleanups for those variables can be
3242 optimized away. The semantic effect is that an exception thrown out of
3243 a function with such an exception specification results in a call
3244 to @code{terminate} rather than @code{unexpected}.
3246 @item -fno-operator-names
3247 @opindex fno-operator-names
3248 @opindex foperator-names
3249 Do not treat the operator name keywords @code{and}, @code{bitand},
3250 @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
3251 synonyms as keywords.
3253 @item -fno-optional-diags
3254 @opindex fno-optional-diags
3255 @opindex foptional-diags
3256 Disable diagnostics that the standard says a compiler does not need to
3257 issue. Currently, the only such diagnostic issued by G++ is the one for
3258 a name having multiple meanings within a class.
3261 @opindex fpermissive
3262 Downgrade some diagnostics about nonconformant code from errors to
3263 warnings. Thus, using @option{-fpermissive} allows some
3264 nonconforming code to compile.
3266 @item -fno-pretty-templates
3267 @opindex fno-pretty-templates
3268 @opindex fpretty-templates
3269 When an error message refers to a specialization of a function
3270 template, the compiler normally prints the signature of the
3271 template followed by the template arguments and any typedefs or
3272 typenames in the signature (e.g.@: @code{void f(T) [with T = int]}
3273 rather than @code{void f(int)}) so that it's clear which template is
3274 involved. When an error message refers to a specialization of a class
3275 template, the compiler omits any template arguments that match
3276 the default template arguments for that template. If either of these
3277 behaviors make it harder to understand the error message rather than
3278 easier, you can use @option{-fno-pretty-templates} to disable them.
3283 Disable generation of information about every class with virtual
3284 functions for use by the C++ run-time type identification features
3285 (@code{dynamic_cast} and @code{typeid}). If you don't use those parts
3286 of the language, you can save some space by using this flag. Note that
3287 exception handling uses the same information, but G++ generates it as
3288 needed. The @code{dynamic_cast} operator can still be used for casts that
3289 do not require run-time type information, i.e.@: casts to @code{void *} or to
3290 unambiguous base classes.
3292 Mixing code compiled with @option{-frtti} with that compiled with
3293 @option{-fno-rtti} may not work. For example, programs may
3294 fail to link if a class compiled with @option{-fno-rtti} is used as a base
3295 for a class compiled with @option{-frtti}.
3297 @item -fsized-deallocation
3298 @opindex fsized-deallocation
3299 Enable the built-in global declarations
3301 void operator delete (void *, std::size_t) noexcept;
3302 void operator delete[] (void *, std::size_t) noexcept;
3304 as introduced in C++14. This is useful for user-defined replacement
3305 deallocation functions that, for example, use the size of the object
3306 to make deallocation faster. Enabled by default under
3307 @option{-std=c++14} and above. The flag @option{-Wsized-deallocation}
3308 warns about places that might want to add a definition.
3310 @item -fstrict-enums
3311 @opindex fstrict-enums
3312 Allow the compiler to optimize using the assumption that a value of
3313 enumerated type can only be one of the values of the enumeration (as
3314 defined in the C++ standard; basically, a value that can be
3315 represented in the minimum number of bits needed to represent all the
3316 enumerators). This assumption may not be valid if the program uses a
3317 cast to convert an arbitrary integer value to the enumerated type.
3319 @item -fstrong-eval-order
3320 @opindex fstrong-eval-order
3321 Evaluate member access, array subscripting, and shift expressions in
3322 left-to-right order, and evaluate assignment in right-to-left order,
3323 as adopted for C++17. Enabled by default with @option{-std=c++17}.
3324 @option{-fstrong-eval-order=some} enables just the ordering of member
3325 access and shift expressions, and is the default without
3326 @option{-std=c++17}.
3328 @item -ftemplate-backtrace-limit=@var{n}
3329 @opindex ftemplate-backtrace-limit
3330 Set the maximum number of template instantiation notes for a single
3331 warning or error to @var{n}. The default value is 10.
3333 @item -ftemplate-depth=@var{n}
3334 @opindex ftemplate-depth
3335 Set the maximum instantiation depth for template classes to @var{n}.
3336 A limit on the template instantiation depth is needed to detect
3337 endless recursions during template class instantiation. ANSI/ISO C++
3338 conforming programs must not rely on a maximum depth greater than 17
3339 (changed to 1024 in C++11). The default value is 900, as the compiler
3340 can run out of stack space before hitting 1024 in some situations.
3342 @item -fno-threadsafe-statics
3343 @opindex fno-threadsafe-statics
3344 @opindex fthreadsafe-statics
3345 Do not emit the extra code to use the routines specified in the C++
3346 ABI for thread-safe initialization of local statics. You can use this
3347 option to reduce code size slightly in code that doesn't need to be
3350 @item -fuse-cxa-atexit
3351 @opindex fuse-cxa-atexit
3352 Register destructors for objects with static storage duration with the
3353 @code{__cxa_atexit} function rather than the @code{atexit} function.
3354 This option is required for fully standards-compliant handling of static
3355 destructors, but only works if your C library supports
3356 @code{__cxa_atexit}.
3358 @item -fno-use-cxa-get-exception-ptr
3359 @opindex fno-use-cxa-get-exception-ptr
3360 @opindex fuse-cxa-get-exception-ptr
3361 Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
3362 causes @code{std::uncaught_exception} to be incorrect, but is necessary
3363 if the runtime routine is not available.
3365 @item -fvisibility-inlines-hidden
3366 @opindex fvisibility-inlines-hidden
3367 This switch declares that the user does not attempt to compare
3368 pointers to inline functions or methods where the addresses of the two functions
3369 are taken in different shared objects.
3371 The effect of this is that GCC may, effectively, mark inline methods with
3372 @code{__attribute__ ((visibility ("hidden")))} so that they do not
3373 appear in the export table of a DSO and do not require a PLT indirection
3374 when used within the DSO@. Enabling this option can have a dramatic effect
3375 on load and link times of a DSO as it massively reduces the size of the
3376 dynamic export table when the library makes heavy use of templates.
3378 The behavior of this switch is not quite the same as marking the
3379 methods as hidden directly, because it does not affect static variables
3380 local to the function or cause the compiler to deduce that
3381 the function is defined in only one shared object.
3383 You may mark a method as having a visibility explicitly to negate the
3384 effect of the switch for that method. For example, if you do want to
3385 compare pointers to a particular inline method, you might mark it as
3386 having default visibility. Marking the enclosing class with explicit
3387 visibility has no effect.
3389 Explicitly instantiated inline methods are unaffected by this option
3390 as their linkage might otherwise cross a shared library boundary.
3391 @xref{Template Instantiation}.
3393 @item -fvisibility-ms-compat
3394 @opindex fvisibility-ms-compat
3395 This flag attempts to use visibility settings to make GCC's C++
3396 linkage model compatible with that of Microsoft Visual Studio.
3398 The flag makes these changes to GCC's linkage model:
3402 It sets the default visibility to @code{hidden}, like
3403 @option{-fvisibility=hidden}.
3406 Types, but not their members, are not hidden by default.
3409 The One Definition Rule is relaxed for types without explicit
3410 visibility specifications that are defined in more than one
3411 shared object: those declarations are permitted if they are
3412 permitted when this option is not used.
3415 In new code it is better to use @option{-fvisibility=hidden} and
3416 export those classes that are intended to be externally visible.
3417 Unfortunately it is possible for code to rely, perhaps accidentally,
3418 on the Visual Studio behavior.
3420 Among the consequences of these changes are that static data members
3421 of the same type with the same name but defined in different shared
3422 objects are different, so changing one does not change the other;
3423 and that pointers to function members defined in different shared
3424 objects may not compare equal. When this flag is given, it is a
3425 violation of the ODR to define types with the same name differently.
3430 Do not use weak symbol support, even if it is provided by the linker.
3431 By default, G++ uses weak symbols if they are available. This
3432 option exists only for testing, and should not be used by end-users;
3433 it results in inferior code and has no benefits. This option may
3434 be removed in a future release of G++.
3436 @item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
3437 @opindex fext-numeric-literals
3438 @opindex fno-ext-numeric-literals
3439 Accept imaginary, fixed-point, or machine-defined
3440 literal number suffixes as GNU extensions.
3441 When this option is turned off these suffixes are treated
3442 as C++11 user-defined literal numeric suffixes.
3443 This is on by default for all pre-C++11 dialects and all GNU dialects:
3444 @option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
3445 @option{-std=gnu++14}.
3446 This option is off by default
3447 for ISO C++11 onwards (@option{-std=c++11}, ...).
3451 Do not search for header files in the standard directories specific to
3452 C++, but do still search the other standard directories. (This option
3453 is used when building the C++ library.)
3455 @item -flang-info-include-translate
3456 @itemx -flang-info-include-translate-not
3457 @itemx -flang-info-include-translate=@var{header}
3458 @opindex flang-info-include-translate
3459 @opindex flang-info-include-translate-not
3460 Inform of include translation events. The first will note accepted
3461 include translations, the second will note declined include
3462 translations. The @var{header} form will inform of include
3463 translations relating to that specific header. If @var{header} is of
3464 the form @code{"user"} or @code{<system>} it will be resolved to a
3465 specific user or system header using the include path.
3467 @item -flang-info-module-cmi
3468 @itemx -flang-info-module-cmi=@var{module}
3469 @opindex flang-info-module-cmi
3470 Inform of Compiled Module Interface pathnames. The first will note
3471 all read CMI pathnames. The @var{module} form will not reading a
3472 specific module's CMI. @var{module} may be a named module or a
3473 header-unit (the latter indicated by either being a pathname containing
3474 directory separators or enclosed in @code{<>} or @code{""}).
3476 @item -stdlib=@var{libstdc++,libc++}
3478 When G++ is configured to support this option, it allows specification of
3479 alternate C++ runtime libraries. Two options are available: @var{libstdc++}
3480 (the default, native C++ runtime for G++) and @var{libc++} which is the
3481 C++ runtime installed on some operating systems (e.g. Darwin versions from
3482 Darwin11 onwards). The option switches G++ to use the headers from the
3483 specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
3484 when a C++ runtime is required for linking.
3487 In addition, these warning options have meanings only for C++ programs:
3490 @item -Wabi-tag @r{(C++ and Objective-C++ only)}
3492 Warn when a type with an ABI tag is used in a context that does not
3493 have that ABI tag. See @ref{C++ Attributes} for more information
3496 @item -Wcomma-subscript @r{(C++ and Objective-C++ only)}
3497 @opindex Wcomma-subscript
3498 @opindex Wno-comma-subscript
3499 Warn about uses of a comma expression within a subscripting expression.
3500 This usage was deprecated in C++20 and is going to be removed in C++23.
3501 However, a comma expression wrapped in @code{( )} is not deprecated. Example:
3505 void f(int *a, int b, int c) @{
3506 a[b,c]; // deprecated in C++20, invalid in C++23
3512 In C++23 it is valid to have comma separated expressions in a subscript
3513 when an overloaded subscript operator is found and supports the right
3514 number and types of arguments. G++ will accept the formerly valid syntax
3515 for code that is not valid in C++23 but used to be valid but deprecated
3516 in C++20 with a pedantic warning that can be disabled with
3517 @option{-Wno-comma-subscript}.
3519 Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated},
3520 and with @option{-std=c++23} regardless of @option{-Wno-deprecated}.
3522 @item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
3523 @opindex Wctad-maybe-unsupported
3524 @opindex Wno-ctad-maybe-unsupported
3525 Warn when performing class template argument deduction (CTAD) on a type with
3526 no explicitly written deduction guides. This warning will point out cases
3527 where CTAD succeeded only because the compiler synthesized the implicit
3528 deduction guides, which might not be what the programmer intended. Certain
3529 style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3530 types that are designed to support CTAD. This warning can be suppressed with
3531 the following pattern:
3534 struct allow_ctad_t; // any name works
3535 template <typename T> struct S @{
3538 S(allow_ctad_t) -> S<void>; // guide with incomplete parameter type will never be considered
3541 @item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
3542 @opindex Wctor-dtor-privacy
3543 @opindex Wno-ctor-dtor-privacy
3544 Warn when a class seems unusable because all the constructors or
3545 destructors in that class are private, and it has neither friends nor
3546 public static member functions. Also warn if there are no non-private
3547 methods, and there's at least one private member function that isn't
3548 a constructor or destructor.
3550 @item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
3551 @opindex Wdelete-non-virtual-dtor
3552 @opindex Wno-delete-non-virtual-dtor
3553 Warn when @code{delete} is used to destroy an instance of a class that
3554 has virtual functions and non-virtual destructor. It is unsafe to delete
3555 an instance of a derived class through a pointer to a base class if the
3556 base class does not have a virtual destructor. This warning is enabled
3559 @item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
3560 @opindex Wdeprecated-copy
3561 @opindex Wno-deprecated-copy
3562 Warn that the implicit declaration of a copy constructor or copy
3563 assignment operator is deprecated if the class has a user-provided
3564 copy constructor or copy assignment operator, in C++11 and up. This
3565 warning is enabled by @option{-Wextra}. With
3566 @option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3567 user-provided destructor.
3569 @item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
3570 @opindex Wdeprecated-enum-enum-conversion
3571 @opindex Wno-deprecated-enum-enum-conversion
3572 Disable the warning about the case when the usual arithmetic conversions
3573 are applied on operands where one is of enumeration type and the other is
3574 of a different enumeration type. This conversion was deprecated in C++20.
3583 @option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3584 @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3585 by @option{-Wenum-conversion}.
3587 @item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
3588 @opindex Wdeprecated-enum-float-conversion
3589 @opindex Wno-deprecated-enum-float-conversion
3590 Disable the warning about the case when the usual arithmetic conversions
3591 are applied on operands where one is of enumeration type and the other is
3592 of a floating-point type. This conversion was deprecated in C++20. For
3601 @option{-Wdeprecated-enum-float-conversion} is enabled by default with
3602 @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3603 by @option{-Wenum-conversion}.
3605 @item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
3606 @opindex Winit-list-lifetime
3607 @opindex Wno-init-list-lifetime
3608 Do not warn about uses of @code{std::initializer_list} that are likely
3609 to result in dangling pointers. Since the underlying array for an
3610 @code{initializer_list} is handled like a normal C++ temporary object,
3611 it is easy to inadvertently keep a pointer to the array past the end
3612 of the array's lifetime. For example:
3616 If a function returns a temporary @code{initializer_list}, or a local
3617 @code{initializer_list} variable, the array's lifetime ends at the end
3618 of the return statement, so the value returned has a dangling pointer.
3621 If a new-expression creates an @code{initializer_list}, the array only
3622 lives until the end of the enclosing full-expression, so the
3623 @code{initializer_list} in the heap has a dangling pointer.
3626 When an @code{initializer_list} variable is assigned from a
3627 brace-enclosed initializer list, the temporary array created for the
3628 right side of the assignment only lives until the end of the
3629 full-expression, so at the next statement the @code{initializer_list}
3630 variable has a dangling pointer.
3633 // li's initial underlying array lives as long as li
3634 std::initializer_list<int> li = @{ 1,2,3 @};
3635 // assignment changes li to point to a temporary array
3637 // now the temporary is gone and li has a dangling pointer
3638 int i = li.begin()[0] // undefined behavior
3642 When a list constructor stores the @code{begin} pointer from the
3643 @code{initializer_list} argument, this doesn't extend the lifetime of
3644 the array, so if a class variable is constructed from a temporary
3645 @code{initializer_list}, the pointer is left dangling by the end of
3646 the variable declaration statement.
3650 @item -Winvalid-imported-macros
3651 @opindex Winvalid-imported-macros
3652 @opindex Wno-invalid-imported-macros
3653 Verify all imported macro definitions are valid at the end of
3654 compilation. This is not enabled by default, as it requires
3655 additional processing to determine. It may be useful when preparing
3656 sets of header-units to ensure consistent macros.
3658 @item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
3659 @opindex Wliteral-suffix
3660 @opindex Wno-literal-suffix
3661 Do not warn when a string or character literal is followed by a
3662 ud-suffix which does not begin with an underscore. As a conforming
3663 extension, GCC treats such suffixes as separate preprocessing tokens
3664 in order to maintain backwards compatibility with code that uses
3665 formatting macros from @code{<inttypes.h>}. For example:
3668 #define __STDC_FORMAT_MACROS
3669 #include <inttypes.h>
3674 printf("My int64: %" PRId64"\n", i64);
3678 In this case, @code{PRId64} is treated as a separate preprocessing token.
3680 This option also controls warnings when a user-defined literal
3681 operator is declared with a literal suffix identifier that doesn't
3682 begin with an underscore. Literal suffix identifiers that don't begin
3683 with an underscore are reserved for future standardization.
3685 These warnings are enabled by default.
3687 @item -Wno-narrowing @r{(C++ and Objective-C++ only)}
3689 @opindex Wno-narrowing
3690 For C++11 and later standards, narrowing conversions are diagnosed by default,
3691 as required by the standard. A narrowing conversion from a constant produces
3692 an error, and a narrowing conversion from a non-constant produces a warning,
3693 but @option{-Wno-narrowing} suppresses the diagnostic.
3694 Note that this does not affect the meaning of well-formed code;
3695 narrowing conversions are still considered ill-formed in SFINAE contexts.
3697 With @option{-Wnarrowing} in C++98, warn when a narrowing
3698 conversion prohibited by C++11 occurs within
3702 int i = @{ 2.2 @}; // error: narrowing from double to int
3705 This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
3707 @item -Wnoexcept @r{(C++ and Objective-C++ only)}
3709 @opindex Wno-noexcept
3710 Warn when a noexcept-expression evaluates to false because of a call
3711 to a function that does not have a non-throwing exception
3712 specification (i.e. @code{throw()} or @code{noexcept}) but is known by
3713 the compiler to never throw an exception.
3715 @item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
3716 @opindex Wnoexcept-type
3717 @opindex Wno-noexcept-type
3718 Warn if the C++17 feature making @code{noexcept} part of a function
3719 type changes the mangled name of a symbol relative to C++14. Enabled
3720 by @option{-Wabi} and @option{-Wc++17-compat}.
3725 template <class T> void f(T t) @{ t(); @};
3727 void h() @{ f(g); @}
3731 In C++14, @code{f} calls @code{f<void(*)()>}, but in
3732 C++17 it calls @code{f<void(*)()noexcept>}.
3734 @item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
3735 @opindex Wclass-memaccess
3736 @opindex Wno-class-memaccess
3737 Warn when the destination of a call to a raw memory function such as
3738 @code{memset} or @code{memcpy} is an object of class type, and when writing
3739 into such an object might bypass the class non-trivial or deleted constructor
3740 or copy assignment, violate const-correctness or encapsulation, or corrupt
3741 virtual table pointers. Modifying the representation of such objects may
3742 violate invariants maintained by member functions of the class. For example,
3743 the call to @code{memset} below is undefined because it modifies a non-trivial
3744 class object and is, therefore, diagnosed. The safe way to either initialize
3745 or clear the storage of objects of such types is by using the appropriate
3746 constructor or assignment operator, if one is available.
3748 std::string str = "abc";
3749 memset (&str, 0, sizeof str);
3751 The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
3752 Explicitly casting the pointer to the class object to @code{void *} or
3753 to a type that can be safely accessed by the raw memory function suppresses
3756 @item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
3757 @opindex Wnon-virtual-dtor
3758 @opindex Wno-non-virtual-dtor
3759 Warn when a class has virtual functions and an accessible non-virtual
3760 destructor itself or in an accessible polymorphic base class, in which
3761 case it is possible but unsafe to delete an instance of a derived
3762 class through a pointer to the class itself or base class. This
3763 warning is automatically enabled if @option{-Weffc++} is specified.
3765 @item -Wregister @r{(C++ and Objective-C++ only)}
3767 @opindex Wno-register
3768 Warn on uses of the @code{register} storage class specifier, except
3769 when it is part of the GNU @ref{Explicit Register Variables} extension.
3770 The use of the @code{register} keyword as storage class specifier has
3771 been deprecated in C++11 and removed in C++17.
3772 Enabled by default with @option{-std=c++17}.
3774 @item -Wreorder @r{(C++ and Objective-C++ only)}
3776 @opindex Wno-reorder
3777 @cindex reordering, warning
3778 @cindex warning for reordering of member initializers
3779 Warn when the order of member initializers given in the code does not
3780 match the order in which they must be executed. For instance:
3786 A(): j (0), i (1) @{ @}
3791 The compiler rearranges the member initializers for @code{i}
3792 and @code{j} to match the declaration order of the members, emitting
3793 a warning to that effect. This warning is enabled by @option{-Wall}.
3795 @item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
3796 @opindex Wpessimizing-move
3797 @opindex Wno-pessimizing-move
3798 This warning warns when a call to @code{std::move} prevents copy
3799 elision. A typical scenario when copy elision can occur is when returning in
3800 a function with a class return type, when the expression being returned is the
3801 name of a non-volatile automatic object, and is not a function parameter, and
3802 has the same type as the function return type.
3812 return std::move (t);
3816 But in this example, the @code{std::move} call prevents copy elision.
3818 This warning is enabled by @option{-Wall}.
3820 @item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
3821 @opindex Wredundant-move
3822 @opindex Wno-redundant-move
3823 This warning warns about redundant calls to @code{std::move}; that is, when
3824 a move operation would have been performed even without the @code{std::move}
3825 call. This happens because the compiler is forced to treat the object as if
3826 it were an rvalue in certain situations such as returning a local variable,
3827 where copy elision isn't applicable. Consider:
3836 return std::move (t);
3840 Here, the @code{std::move} call is redundant. Because G++ implements Core
3841 Issue 1579, another example is:
3844 struct T @{ // convertible to U
3854 return std::move (t);
3857 In this example, copy elision isn't applicable because the type of the
3858 expression being returned and the function return type differ, yet G++
3859 treats the return value as if it were designated by an rvalue.
3861 This warning is enabled by @option{-Wextra}.
3863 @item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
3864 @opindex Wrange-loop-construct
3865 @opindex Wno-range-loop-construct
3866 This warning warns when a C++ range-based for-loop is creating an unnecessary
3867 copy. This can happen when the range declaration is not a reference, but
3868 probably should be. For example:
3871 struct S @{ char arr[128]; @};
3874 for (const auto x : arr) @{ @dots{} @}
3878 It does not warn when the type being copied is a trivially-copyable type whose
3879 size is less than 64 bytes.
3881 This warning also warns when a loop variable in a range-based for-loop is
3882 initialized with a value of a different type resulting in a copy. For example:
3887 for (const double &x : arr) @{ @dots{} @}
3891 In the example above, in every iteration of the loop a temporary value of
3892 type @code{double} is created and destroyed, to which the reference
3893 @code{const double &} is bound.
3895 This warning is enabled by @option{-Wall}.
3897 @item -Wredundant-tags @r{(C++ and Objective-C++ only)}
3898 @opindex Wredundant-tags
3899 @opindex Wno-redundant-tags
3900 Warn about redundant class-key and enum-key in references to class types
3901 and enumerated types in contexts where the key can be eliminated without
3902 causing an ambiguity. For example:
3906 struct foo *p; // warn that keyword struct can be eliminated
3910 On the other hand, in this example there is no warning:
3914 void foo (); // "hides" struct foo
3915 void bar (struct foo&); // no warning, keyword struct is necessary
3918 @item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
3919 @opindex Wsubobject-linkage
3920 @opindex Wno-subobject-linkage
3922 if a class type has a base or a field whose type uses the anonymous
3923 namespace or depends on a type with no linkage. If a type A depends on
3924 a type B with no or internal linkage, defining it in multiple
3925 translation units would be an ODR violation because the meaning of B
3926 is different in each translation unit. If A only appears in a single
3927 translation unit, the best way to silence the warning is to give it
3928 internal linkage by putting it in an anonymous namespace as well. The
3929 compiler doesn't give this warning for types defined in the main .C
3930 file, as those are unlikely to have multiple definitions.
3931 @option{-Wsubobject-linkage} is enabled by default.
3933 @item -Weffc++ @r{(C++ and Objective-C++ only)}
3936 Warn about violations of the following style guidelines from Scott Meyers'
3937 @cite{Effective C++} series of books:
3941 Define a copy constructor and an assignment operator for classes
3942 with dynamically-allocated memory.
3945 Prefer initialization to assignment in constructors.
3948 Have @code{operator=} return a reference to @code{*this}.
3951 Don't try to return a reference when you must return an object.
3954 Distinguish between prefix and postfix forms of increment and
3955 decrement operators.
3958 Never overload @code{&&}, @code{||}, or @code{,}.
3962 This option also enables @option{-Wnon-virtual-dtor}, which is also
3963 one of the effective C++ recommendations. However, the check is
3964 extended to warn about the lack of virtual destructor in accessible
3965 non-polymorphic bases classes too.
3967 When selecting this option, be aware that the standard library
3968 headers do not obey all of these guidelines; use @samp{grep -v}
3969 to filter out those warnings.
3971 @item -Wno-exceptions @r{(C++ and Objective-C++ only)}
3972 @opindex Wexceptions
3973 @opindex Wno-exceptions
3974 Disable the warning about the case when an exception handler is shadowed by
3975 another handler, which can point out a wrong ordering of exception handlers.
3977 @item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
3978 @opindex Wstrict-null-sentinel
3979 @opindex Wno-strict-null-sentinel
3980 Warn about the use of an uncasted @code{NULL} as sentinel. When
3981 compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
3982 to @code{__null}. Although it is a null pointer constant rather than a
3983 null pointer, it is guaranteed to be of the same size as a pointer.
3984 But this use is not portable across different compilers.
3986 @item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
3987 @opindex Wno-non-template-friend
3988 @opindex Wnon-template-friend
3989 Disable warnings when non-template friend functions are declared
3990 within a template. In very old versions of GCC that predate implementation
3991 of the ISO standard, declarations such as
3992 @samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
3993 could be interpreted as a particular specialization of a template
3994 function; the warning exists to diagnose compatibility problems,
3995 and is enabled by default.
3997 @item -Wold-style-cast @r{(C++ and Objective-C++ only)}
3998 @opindex Wold-style-cast
3999 @opindex Wno-old-style-cast
4000 Warn if an old-style (C-style) cast to a non-void type is used within
4001 a C++ program. The new-style casts (@code{dynamic_cast},
4002 @code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4003 less vulnerable to unintended effects and much easier to search for.
4005 @item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4006 @opindex Woverloaded-virtual
4007 @opindex Wno-overloaded-virtual
4008 @cindex overloaded virtual function, warning
4009 @cindex warning for overloaded virtual function
4010 Warn when a function declaration hides virtual functions from a
4011 base class. For example, in:
4018 struct B: public A @{
4023 the @code{A} class version of @code{f} is hidden in @code{B}, and code
4034 @item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
4035 @opindex Wno-pmf-conversions
4036 @opindex Wpmf-conversions
4037 Disable the diagnostic for converting a bound pointer to member function
4040 @item -Wsign-promo @r{(C++ and Objective-C++ only)}
4041 @opindex Wsign-promo
4042 @opindex Wno-sign-promo
4043 Warn when overload resolution chooses a promotion from unsigned or
4044 enumerated type to a signed type, over a conversion to an unsigned type of
4045 the same size. Previous versions of G++ tried to preserve
4046 unsignedness, but the standard mandates the current behavior.
4048 @item -Wtemplates @r{(C++ and Objective-C++ only)}
4050 @opindex Wno-templates
4051 Warn when a primary template declaration is encountered. Some coding
4052 rules disallow templates, and this may be used to enforce that rule.
4053 The warning is inactive inside a system header file, such as the STL, so
4054 one can still use the STL. One may also instantiate or specialize
4057 @item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
4058 @opindex Wmismatched-new-delete
4059 @opindex Wno-mismatched-new-delete
4060 Warn for mismatches between calls to @code{operator new} or @code{operator
4061 delete} and the corresponding call to the allocation or deallocation function.
4062 This includes invocations of C++ @code{operator delete} with pointers
4063 returned from either mismatched forms of @code{operator new}, or from other
4064 functions that allocate objects for which the @code{operator delete} isn't
4065 a suitable deallocator, as well as calls to other deallocation functions
4066 with pointers returned from @code{operator new} for which the deallocation
4067 function isn't suitable.
4069 For example, the @code{delete} expression in the function below is diagnosed
4070 because it doesn't match the array form of the @code{new} expression
4071 the pointer argument was returned from. Similarly, the call to @code{free}
4077 int *a = new int[n];
4078 delete a; // warning: mismatch in array forms of expressions
4080 char *p = new char[n];
4081 free (p); // warning: mismatch between new and free
4085 The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4086 involving allocation and deallocation functions other than @code{operator
4087 new} and @code{operator delete}.
4089 @option{-Wmismatched-new-delete} is included in @option{-Wall}.
4091 @item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
4092 @opindex Wmismatched-tags
4093 @opindex Wno-mismatched-tags
4094 Warn for declarations of structs, classes, and class templates and their
4095 specializations with a class-key that does not match either the definition
4096 or the first declaration if no definition is provided.
4098 For example, the declaration of @code{struct Object} in the argument list
4099 of @code{draw} triggers the warning. To avoid it, either remove the redundant
4100 class-key @code{struct} or replace it with @code{class} to match its definition.
4104 virtual ~Object () = 0;
4106 void draw (struct Object*);
4109 It is not wrong to declare a class with the class-key @code{struct} as
4110 the example above shows. The @option{-Wmismatched-tags} option is intended
4111 to help achieve a consistent style of class declarations. In code that is
4112 intended to be portable to Windows-based compilers the warning helps prevent
4113 unresolved references due to the difference in the mangling of symbols
4114 declared with different class-keys. The option can be used either on its
4115 own or in conjunction with @option{-Wredundant-tags}.
4117 @item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
4118 @opindex Wmultiple-inheritance
4119 @opindex Wno-multiple-inheritance
4120 Warn when a class is defined with multiple direct base classes. Some
4121 coding rules disallow multiple inheritance, and this may be used to
4122 enforce that rule. The warning is inactive inside a system header file,
4123 such as the STL, so one can still use the STL. One may also define
4124 classes that indirectly use multiple inheritance.
4126 @item -Wvirtual-inheritance
4127 @opindex Wvirtual-inheritance
4128 @opindex Wno-virtual-inheritance
4129 Warn when a class is defined with a virtual direct base class. Some
4130 coding rules disallow multiple inheritance, and this may be used to
4131 enforce that rule. The warning is inactive inside a system header file,
4132 such as the STL, so one can still use the STL. One may also define
4133 classes that indirectly use virtual inheritance.
4135 @item -Wno-virtual-move-assign
4136 @opindex Wvirtual-move-assign
4137 @opindex Wno-virtual-move-assign
4138 Suppress warnings about inheriting from a virtual base with a
4139 non-trivial C++11 move assignment operator. This is dangerous because
4140 if the virtual base is reachable along more than one path, it is
4141 moved multiple times, which can mean both objects end up in the
4142 moved-from state. If the move assignment operator is written to avoid
4143 moving from a moved-from object, this warning can be disabled.
4146 @opindex Wnamespaces
4147 @opindex Wno-namespaces
4148 Warn when a namespace definition is opened. Some coding rules disallow
4149 namespaces, and this may be used to enforce that rule. The warning is
4150 inactive inside a system header file, such as the STL, so one can still
4151 use the STL. One may also use using directives and qualified names.
4153 @item -Wno-terminate @r{(C++ and Objective-C++ only)}
4155 @opindex Wno-terminate
4156 Disable the warning about a throw-expression that will immediately
4157 result in a call to @code{terminate}.
4159 @item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
4160 @opindex Wvexing-parse
4161 @opindex Wno-vexing-parse
4162 Warn about the most vexing parse syntactic ambiguity. This warns about
4163 the cases when a declaration looks like a variable definition, but the
4164 C++ language requires it to be interpreted as a function declaration.
4169 int i(); // extern int i (void);
4170 int n(int(a)); // extern int n (int);
4177 struct S @{ S(int); @};
4179 S x(int(a)); // extern struct S x (int);
4180 S y(int()); // extern struct S y (int (*) (void));
4181 S z(); // extern struct S z (void);
4185 The warning will suggest options how to deal with such an ambiguity; e.g.,
4186 it can suggest removing the parentheses or using braces instead.
4188 This warning is enabled by default.
4190 @item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
4191 @opindex Wno-class-conversion
4192 @opindex Wclass-conversion
4193 Do not warn when a conversion function converts an
4194 object to the same type, to a base class of that type, or to void; such
4195 a conversion function will never be called.
4197 @item -Wvolatile @r{(C++ and Objective-C++ only)}
4199 @opindex Wno-volatile
4200 Warn about deprecated uses of the @code{volatile} qualifier. This includes
4201 postfix and prefix @code{++} and @code{--} expressions of
4202 @code{volatile}-qualified types, using simple assignments where the left
4203 operand is a @code{volatile}-qualified non-class type for their value,
4204 compound assignments where the left operand is a @code{volatile}-qualified
4205 non-class type, @code{volatile}-qualified function return type,
4206 @code{volatile}-qualified parameter type, and structured bindings of a
4207 @code{volatile}-qualified type. This usage was deprecated in C++20.
4209 Enabled by default with @option{-std=c++20}.
4211 @item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)}
4212 @opindex Wzero-as-null-pointer-constant
4213 @opindex Wno-zero-as-null-pointer-constant
4214 Warn when a literal @samp{0} is used as null pointer constant. This can
4215 be useful to facilitate the conversion to @code{nullptr} in C++11.
4218 @opindex Waligned-new
4219 @opindex Wno-aligned-new
4220 Warn about a new-expression of a type that requires greater alignment
4221 than the @code{alignof(std::max_align_t)} but uses an allocation
4222 function without an explicit alignment parameter. This option is
4223 enabled by @option{-Wall}.
4225 Normally this only warns about global allocation functions, but
4226 @option{-Waligned-new=all} also warns about class member allocation
4229 @item -Wno-placement-new
4230 @itemx -Wplacement-new=@var{n}
4231 @opindex Wplacement-new
4232 @opindex Wno-placement-new
4233 Warn about placement new expressions with undefined behavior, such as
4234 constructing an object in a buffer that is smaller than the type of
4235 the object. For example, the placement new expression below is diagnosed
4236 because it attempts to construct an array of 64 integers in a buffer only
4242 This warning is enabled by default.
4245 @item -Wplacement-new=1
4246 This is the default warning level of @option{-Wplacement-new}. At this
4247 level the warning is not issued for some strictly undefined constructs that
4248 GCC allows as extensions for compatibility with legacy code. For example,
4249 the following @code{new} expression is not diagnosed at this level even
4250 though it has undefined behavior according to the C++ standard because
4251 it writes past the end of the one-element array.
4253 struct S @{ int n, a[1]; @};
4254 S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4255 new (s->a)int [32]();
4258 @item -Wplacement-new=2
4259 At this level, in addition to diagnosing all the same constructs as at level
4260 1, a diagnostic is also issued for placement new expressions that construct
4261 an object in the last member of structure whose type is an array of a single
4262 element and whose size is less than the size of the object being constructed.
4263 While the previous example would be diagnosed, the following construct makes
4264 use of the flexible member array extension to avoid the warning at level 2.
4266 struct S @{ int n, a[]; @};
4267 S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4268 new (s->a)int [32]();
4274 @itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
4275 @opindex Wcatch-value
4276 @opindex Wno-catch-value
4277 Warn about catch handlers that do not catch via reference.
4278 With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4279 warn about polymorphic class types that are caught by value.
4280 With @option{-Wcatch-value=2} warn about all class types that are caught
4281 by value. With @option{-Wcatch-value=3} warn about all types that are
4282 not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4284 @item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
4285 @opindex Wconditionally-supported
4286 @opindex Wno-conditionally-supported
4287 Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4289 @item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
4290 @opindex Wdelete-incomplete
4291 @opindex Wno-delete-incomplete
4292 Do not warn when deleting a pointer to incomplete type, which may cause
4293 undefined behavior at runtime. This warning is enabled by default.
4295 @item -Wextra-semi @r{(C++, Objective-C++ only)}
4296 @opindex Wextra-semi
4297 @opindex Wno-extra-semi
4298 Warn about redundant semicolons after in-class function definitions.
4300 @item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
4301 @opindex Winaccessible-base
4302 @opindex Wno-inaccessible-base
4303 This option controls warnings
4304 when a base class is inaccessible in a class derived from it due to
4305 ambiguity. The warning is enabled by default.
4306 Note that the warning for ambiguous virtual
4307 bases is enabled by the @option{-Wextra} option.
4310 struct A @{ int a; @};
4314 struct C : B, A @{ @};
4318 @item -Wno-inherited-variadic-ctor
4319 @opindex Winherited-variadic-ctor
4320 @opindex Wno-inherited-variadic-ctor
4321 Suppress warnings about use of C++11 inheriting constructors when the
4322 base class inherited from has a C variadic constructor; the warning is
4323 on by default because the ellipsis is not inherited.
4325 @item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
4326 @opindex Wno-invalid-offsetof
4327 @opindex Winvalid-offsetof
4328 Suppress warnings from applying the @code{offsetof} macro to a non-POD
4329 type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4330 to a non-standard-layout type is undefined. In existing C++ implementations,
4331 however, @code{offsetof} typically gives meaningful results.
4332 This flag is for users who are aware that they are
4333 writing nonportable code and who have deliberately chosen to ignore the
4336 The restrictions on @code{offsetof} may be relaxed in a future version
4337 of the C++ standard.
4339 @item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
4340 @opindex Wsized-deallocation
4341 @opindex Wno-sized-deallocation
4342 Warn about a definition of an unsized deallocation function
4344 void operator delete (void *) noexcept;
4345 void operator delete[] (void *) noexcept;
4347 without a definition of the corresponding sized deallocation function
4349 void operator delete (void *, std::size_t) noexcept;
4350 void operator delete[] (void *, std::size_t) noexcept;
4352 or vice versa. Enabled by @option{-Wextra} along with
4353 @option{-fsized-deallocation}.
4355 @item -Wsuggest-final-types
4356 @opindex Wno-suggest-final-types
4357 @opindex Wsuggest-final-types
4358 Warn about types with virtual methods where code quality would be improved
4359 if the type were declared with the C++11 @code{final} specifier,
4361 declared in an anonymous namespace. This allows GCC to more aggressively
4362 devirtualize the polymorphic calls. This warning is more effective with
4363 link-time optimization,
4364 where the information about the class hierarchy graph is
4367 @item -Wsuggest-final-methods
4368 @opindex Wno-suggest-final-methods
4369 @opindex Wsuggest-final-methods
4370 Warn about virtual methods where code quality would be improved if the method
4371 were declared with the C++11 @code{final} specifier,
4372 or, if possible, its type were
4373 declared in an anonymous namespace or with the @code{final} specifier.
4375 more effective with link-time optimization, where the information about the
4376 class hierarchy graph is more complete. It is recommended to first consider
4377 suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4380 @item -Wsuggest-override
4381 @opindex Wsuggest-override
4382 @opindex Wno-suggest-override
4383 Warn about overriding virtual functions that are not marked with the
4384 @code{override} keyword.
4386 @item -Wuseless-cast @r{(C++ and Objective-C++ only)}
4387 @opindex Wuseless-cast
4388 @opindex Wno-useless-cast
4389 Warn when an expression is casted to its own type.
4391 @item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
4392 @opindex Wconversion-null
4393 @opindex Wno-conversion-null
4394 Do not warn for conversions between @code{NULL} and non-pointer
4395 types. @option{-Wconversion-null} is enabled by default.
4399 @node Objective-C and Objective-C++ Dialect Options
4400 @section Options Controlling Objective-C and Objective-C++ Dialects
4402 @cindex compiler options, Objective-C and Objective-C++
4403 @cindex Objective-C and Objective-C++ options, command-line
4404 @cindex options, Objective-C and Objective-C++
4405 (NOTE: This manual does not describe the Objective-C and Objective-C++
4406 languages themselves. @xref{Standards,,Language Standards
4407 Supported by GCC}, for references.)
4409 This section describes the command-line options that are only meaningful
4410 for Objective-C and Objective-C++ programs. You can also use most of
4411 the language-independent GNU compiler options.
4412 For example, you might compile a file @file{some_class.m} like this:
4415 gcc -g -fgnu-runtime -O -c some_class.m
4419 In this example, @option{-fgnu-runtime} is an option meant only for
4420 Objective-C and Objective-C++ programs; you can use the other options with
4421 any language supported by GCC@.
4423 Note that since Objective-C is an extension of the C language, Objective-C
4424 compilations may also use options specific to the C front-end (e.g.,
4425 @option{-Wtraditional}). Similarly, Objective-C++ compilations may use
4426 C++-specific options (e.g., @option{-Wabi}).
4428 Here is a list of options that are @emph{only} for compiling Objective-C
4429 and Objective-C++ programs:
4432 @item -fconstant-string-class=@var{class-name}
4433 @opindex fconstant-string-class
4434 Use @var{class-name} as the name of the class to instantiate for each
4435 literal string specified with the syntax @code{@@"@dots{}"}. The default
4436 class name is @code{NXConstantString} if the GNU runtime is being used, and
4437 @code{NSConstantString} if the NeXT runtime is being used (see below). The
4438 @option{-fconstant-cfstrings} option, if also present, overrides the
4439 @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals
4440 to be laid out as constant CoreFoundation strings.
4443 @opindex fgnu-runtime
4444 Generate object code compatible with the standard GNU Objective-C
4445 runtime. This is the default for most types of systems.
4447 @item -fnext-runtime
4448 @opindex fnext-runtime
4449 Generate output compatible with the NeXT runtime. This is the default
4450 for NeXT-based systems, including Darwin and Mac OS X@. The macro
4451 @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
4454 @item -fno-nil-receivers
4455 @opindex fno-nil-receivers
4456 @opindex fnil-receivers
4457 Assume that all Objective-C message dispatches (@code{[receiver
4458 message:arg]}) in this translation unit ensure that the receiver is
4459 not @code{nil}. This allows for more efficient entry points in the
4460 runtime to be used. This option is only available in conjunction with
4461 the NeXT runtime and ABI version 0 or 1.
4463 @item -fobjc-abi-version=@var{n}
4464 @opindex fobjc-abi-version
4465 Use version @var{n} of the Objective-C ABI for the selected runtime.
4466 This option is currently supported only for the NeXT runtime. In that
4467 case, Version 0 is the traditional (32-bit) ABI without support for
4468 properties and other Objective-C 2.0 additions. Version 1 is the
4469 traditional (32-bit) ABI with support for properties and other
4470 Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
4471 nothing is specified, the default is Version 0 on 32-bit target
4472 machines, and Version 2 on 64-bit target machines.
4474 @item -fobjc-call-cxx-cdtors
4475 @opindex fobjc-call-cxx-cdtors
4476 For each Objective-C class, check if any of its instance variables is a
4477 C++ object with a non-trivial default constructor. If so, synthesize a
4478 special @code{- (id) .cxx_construct} instance method which runs
4479 non-trivial default constructors on any such instance variables, in order,
4480 and then return @code{self}. Similarly, check if any instance variable
4481 is a C++ object with a non-trivial destructor, and if so, synthesize a
4482 special @code{- (void) .cxx_destruct} method which runs
4483 all such default destructors, in reverse order.
4485 The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
4486 methods thusly generated only operate on instance variables
4487 declared in the current Objective-C class, and not those inherited
4488 from superclasses. It is the responsibility of the Objective-C
4489 runtime to invoke all such methods in an object's inheritance
4490 hierarchy. The @code{- (id) .cxx_construct} methods are invoked
4491 by the runtime immediately after a new object instance is allocated;
4492 the @code{- (void) .cxx_destruct} methods are invoked immediately
4493 before the runtime deallocates an object instance.
4495 As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
4496 support for invoking the @code{- (id) .cxx_construct} and
4497 @code{- (void) .cxx_destruct} methods.
4499 @item -fobjc-direct-dispatch
4500 @opindex fobjc-direct-dispatch
4501 Allow fast jumps to the message dispatcher. On Darwin this is
4502 accomplished via the comm page.
4504 @item -fobjc-exceptions
4505 @opindex fobjc-exceptions
4506 Enable syntactic support for structured exception handling in
4507 Objective-C, similar to what is offered by C++. This option
4508 is required to use the Objective-C keywords @code{@@try},
4509 @code{@@throw}, @code{@@catch}, @code{@@finally} and
4510 @code{@@synchronized}. This option is available with both the GNU
4511 runtime and the NeXT runtime (but not available in conjunction with
4512 the NeXT runtime on Mac OS X 10.2 and earlier).
4516 Enable garbage collection (GC) in Objective-C and Objective-C++
4517 programs. This option is only available with the NeXT runtime; the
4518 GNU runtime has a different garbage collection implementation that
4519 does not require special compiler flags.
4521 @item -fobjc-nilcheck
4522 @opindex fobjc-nilcheck
4523 For the NeXT runtime with version 2 of the ABI, check for a nil
4524 receiver in method invocations before doing the actual method call.
4525 This is the default and can be disabled using
4526 @option{-fno-objc-nilcheck}. Class methods and super calls are never
4527 checked for nil in this way no matter what this flag is set to.
4528 Currently this flag does nothing when the GNU runtime, or an older
4529 version of the NeXT runtime ABI, is used.
4531 @item -fobjc-std=objc1
4533 Conform to the language syntax of Objective-C 1.0, the language
4534 recognized by GCC 4.0. This only affects the Objective-C additions to
4535 the C/C++ language; it does not affect conformance to C/C++ standards,
4536 which is controlled by the separate C/C++ dialect option flags. When
4537 this option is used with the Objective-C or Objective-C++ compiler,
4538 any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
4539 This is useful if you need to make sure that your Objective-C code can
4540 be compiled with older versions of GCC@.
4542 @item -freplace-objc-classes
4543 @opindex freplace-objc-classes
4544 Emit a special marker instructing @command{ld(1)} not to statically link in
4545 the resulting object file, and allow @command{dyld(1)} to load it in at
4546 run time instead. This is used in conjunction with the Fix-and-Continue
4547 debugging mode, where the object file in question may be recompiled and
4548 dynamically reloaded in the course of program execution, without the need
4549 to restart the program itself. Currently, Fix-and-Continue functionality
4550 is only available in conjunction with the NeXT runtime on Mac OS X 10.3
4555 When compiling for the NeXT runtime, the compiler ordinarily replaces calls
4556 to @code{objc_getClass("@dots{}")} (when the name of the class is known at
4557 compile time) with static class references that get initialized at load time,
4558 which improves run-time performance. Specifying the @option{-fzero-link} flag
4559 suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
4560 to be retained. This is useful in Zero-Link debugging mode, since it allows
4561 for individual class implementations to be modified during program execution.
4562 The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
4563 regardless of command-line options.
4565 @item -fno-local-ivars
4566 @opindex fno-local-ivars
4567 @opindex flocal-ivars
4568 By default instance variables in Objective-C can be accessed as if
4569 they were local variables from within the methods of the class they're
4570 declared in. This can lead to shadowing between instance variables
4571 and other variables declared either locally inside a class method or
4572 globally with the same name. Specifying the @option{-fno-local-ivars}
4573 flag disables this behavior thus avoiding variable shadowing issues.
4575 @item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
4576 @opindex fivar-visibility
4577 Set the default instance variable visibility to the specified option
4578 so that instance variables declared outside the scope of any access
4579 modifier directives default to the specified visibility.
4583 Dump interface declarations for all classes seen in the source file to a
4584 file named @file{@var{sourcename}.decl}.
4586 @item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
4587 @opindex Wassign-intercept
4588 @opindex Wno-assign-intercept
4589 Warn whenever an Objective-C assignment is being intercepted by the
4592 @item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
4593 @opindex Wproperty-assign-default
4594 @opindex Wno-property-assign-default
4595 Do not warn if a property for an Objective-C object has no assign
4596 semantics specified.
4598 @item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
4599 @opindex Wno-protocol
4601 If a class is declared to implement a protocol, a warning is issued for
4602 every method in the protocol that is not implemented by the class. The
4603 default behavior is to issue a warning for every method not explicitly
4604 implemented in the class, even if a method implementation is inherited
4605 from the superclass. If you use the @option{-Wno-protocol} option, then
4606 methods inherited from the superclass are considered to be implemented,
4607 and no warning is issued for them.
4609 @item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
4610 @opindex Wobjc-root-class
4611 Warn if a class interface lacks a superclass. Most classes will inherit
4612 from @code{NSObject} (or @code{Object}) for example. When declaring
4613 classes intended to be root classes, the warning can be suppressed by
4614 marking their interfaces with @code{__attribute__((objc_root_class))}.
4616 @item -Wselector @r{(Objective-C and Objective-C++ only)}
4618 @opindex Wno-selector
4619 Warn if multiple methods of different types for the same selector are
4620 found during compilation. The check is performed on the list of methods
4621 in the final stage of compilation. Additionally, a check is performed
4622 for each selector appearing in a @code{@@selector(@dots{})}
4623 expression, and a corresponding method for that selector has been found
4624 during compilation. Because these checks scan the method table only at
4625 the end of compilation, these warnings are not produced if the final
4626 stage of compilation is not reached, for example because an error is
4627 found during compilation, or because the @option{-fsyntax-only} option is
4630 @item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
4631 @opindex Wstrict-selector-match
4632 @opindex Wno-strict-selector-match
4633 Warn if multiple methods with differing argument and/or return types are
4634 found for a given selector when attempting to send a message using this
4635 selector to a receiver of type @code{id} or @code{Class}. When this flag
4636 is off (which is the default behavior), the compiler omits such warnings
4637 if any differences found are confined to types that share the same size
4640 @item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
4641 @opindex Wundeclared-selector
4642 @opindex Wno-undeclared-selector
4643 Warn if a @code{@@selector(@dots{})} expression referring to an
4644 undeclared selector is found. A selector is considered undeclared if no
4645 method with that name has been declared before the
4646 @code{@@selector(@dots{})} expression, either explicitly in an
4647 @code{@@interface} or @code{@@protocol} declaration, or implicitly in
4648 an @code{@@implementation} section. This option always performs its
4649 checks as soon as a @code{@@selector(@dots{})} expression is found,
4650 while @option{-Wselector} only performs its checks in the final stage of
4651 compilation. This also enforces the coding style convention
4652 that methods and selectors must be declared before being used.
4654 @item -print-objc-runtime-info
4655 @opindex print-objc-runtime-info
4656 Generate C header describing the largest structure that is passed by
4661 @node Diagnostic Message Formatting Options
4662 @section Options to Control Diagnostic Messages Formatting
4663 @cindex options to control diagnostics formatting
4664 @cindex diagnostic messages
4665 @cindex message formatting
4667 Traditionally, diagnostic messages have been formatted irrespective of
4668 the output device's aspect (e.g.@: its width, @dots{}). You can use the
4669 options described below
4670 to control the formatting algorithm for diagnostic messages,
4671 e.g.@: how many characters per line, how often source location
4672 information should be reported. Note that some language front ends may not
4673 honor these options.
4676 @item -fmessage-length=@var{n}
4677 @opindex fmessage-length
4678 Try to format error messages so that they fit on lines of about
4679 @var{n} characters. If @var{n} is zero, then no line-wrapping is
4680 done; each error message appears on a single line. This is the
4681 default for all front ends.
4683 Note - this option also affects the display of the @samp{#error} and
4684 @samp{#warning} pre-processor directives, and the @samp{deprecated}
4685 function/type/variable attribute. It does not however affect the
4686 @samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
4688 @item -fdiagnostics-plain-output
4689 This option requests that diagnostic output look as plain as possible, which
4690 may be useful when running @command{dejagnu} or other utilities that need to
4691 parse diagnostics output and prefer that it remain more stable over time.
4692 @option{-fdiagnostics-plain-output} is currently equivalent to the following
4694 @gccoptlist{-fno-diagnostics-show-caret @gol
4695 -fno-diagnostics-show-line-numbers @gol
4696 -fdiagnostics-color=never @gol
4697 -fdiagnostics-urls=never @gol
4698 -fdiagnostics-path-format=separate-events}
4699 In the future, if GCC changes the default appearance of its diagnostics, the
4700 corresponding option to disable the new behavior will be added to this list.
4702 @item -fdiagnostics-show-location=once
4703 @opindex fdiagnostics-show-location
4704 Only meaningful in line-wrapping mode. Instructs the diagnostic messages
4705 reporter to emit source location information @emph{once}; that is, in
4706 case the message is too long to fit on a single physical line and has to
4707 be wrapped, the source location won't be emitted (as prefix) again,
4708 over and over, in subsequent continuation lines. This is the default
4711 @item -fdiagnostics-show-location=every-line
4712 Only meaningful in line-wrapping mode. Instructs the diagnostic
4713 messages reporter to emit the same source location information (as
4714 prefix) for physical lines that result from the process of breaking
4715 a message which is too long to fit on a single line.
4717 @item -fdiagnostics-color[=@var{WHEN}]
4718 @itemx -fno-diagnostics-color
4719 @opindex fdiagnostics-color
4720 @cindex highlight, color
4721 @vindex GCC_COLORS @r{environment variable}
4722 Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
4723 or @samp{auto}. The default depends on how the compiler has been configured,
4724 it can be any of the above @var{WHEN} options or also @samp{never}
4725 if @env{GCC_COLORS} environment variable isn't present in the environment,
4726 and @samp{auto} otherwise.
4727 @samp{auto} makes GCC use color only when the standard error is a terminal,
4728 and when not executing in an emacs shell.
4729 The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
4730 aliases for @option{-fdiagnostics-color=always} and
4731 @option{-fdiagnostics-color=never}, respectively.
4733 The colors are defined by the environment variable @env{GCC_COLORS}.
4734 Its value is a colon-separated list of capabilities and Select Graphic
4735 Rendition (SGR) substrings. SGR commands are interpreted by the
4736 terminal or terminal emulator. (See the section in the documentation
4737 of your text terminal for permitted values and their meanings as
4738 character attributes.) These substring values are integers in decimal
4739 representation and can be concatenated with semicolons.
4740 Common values to concatenate include
4742 @samp{4} for underline,
4744 @samp{7} for inverse,
4745 @samp{39} for default foreground color,
4746 @samp{30} to @samp{37} for foreground colors,
4747 @samp{90} to @samp{97} for 16-color mode foreground colors,
4748 @samp{38;5;0} to @samp{38;5;255}
4749 for 88-color and 256-color modes foreground colors,
4750 @samp{49} for default background color,
4751 @samp{40} to @samp{47} for background colors,
4752 @samp{100} to @samp{107} for 16-color mode background colors,
4753 and @samp{48;5;0} to @samp{48;5;255}
4754 for 88-color and 256-color modes background colors.
4756 The default @env{GCC_COLORS} is
4758 error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
4759 quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
4760 diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
4764 where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
4765 @samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
4766 @samp{01} is bold, and @samp{31} is red.
4767 Setting @env{GCC_COLORS} to the empty string disables colors.
4768 Supported capabilities are as follows.
4772 @vindex error GCC_COLORS @r{capability}
4773 SGR substring for error: markers.
4776 @vindex warning GCC_COLORS @r{capability}
4777 SGR substring for warning: markers.
4780 @vindex note GCC_COLORS @r{capability}
4781 SGR substring for note: markers.
4784 @vindex path GCC_COLORS @r{capability}
4785 SGR substring for colorizing paths of control-flow events as printed
4786 via @option{-fdiagnostics-path-format=}, such as the identifiers of
4787 individual events and lines indicating interprocedural calls and returns.
4790 @vindex range1 GCC_COLORS @r{capability}
4791 SGR substring for first additional range.
4794 @vindex range2 GCC_COLORS @r{capability}
4795 SGR substring for second additional range.
4798 @vindex locus GCC_COLORS @r{capability}
4799 SGR substring for location information, @samp{file:line} or
4800 @samp{file:line:column} etc.
4803 @vindex quote GCC_COLORS @r{capability}
4804 SGR substring for information printed within quotes.
4807 @vindex fixit-insert GCC_COLORS @r{capability}
4808 SGR substring for fix-it hints suggesting text to
4809 be inserted or replaced.
4812 @vindex fixit-delete GCC_COLORS @r{capability}
4813 SGR substring for fix-it hints suggesting text to
4816 @item diff-filename=
4817 @vindex diff-filename GCC_COLORS @r{capability}
4818 SGR substring for filename headers within generated patches.
4821 @vindex diff-hunk GCC_COLORS @r{capability}
4822 SGR substring for the starts of hunks within generated patches.
4825 @vindex diff-delete GCC_COLORS @r{capability}
4826 SGR substring for deleted lines within generated patches.
4829 @vindex diff-insert GCC_COLORS @r{capability}
4830 SGR substring for inserted lines within generated patches.
4833 @vindex type-diff GCC_COLORS @r{capability}
4834 SGR substring for highlighting mismatching types within template
4835 arguments in the C++ frontend.
4838 @item -fdiagnostics-urls[=@var{WHEN}]
4839 @opindex fdiagnostics-urls
4841 @vindex GCC_URLS @r{environment variable}
4842 @vindex TERM_URLS @r{environment variable}
4843 Use escape sequences to embed URLs in diagnostics. For example, when
4844 @option{-fdiagnostics-show-option} emits text showing the command-line
4845 option controlling a diagnostic, embed a URL for documentation of that
4848 @var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
4849 @samp{auto} makes GCC use URL escape sequences only when the standard error
4850 is a terminal, and when not executing in an emacs shell or any graphical
4851 terminal which is known to be incompatible with this feature, see below.
4853 The default depends on how the compiler has been configured.
4854 It can be any of the above @var{WHEN} options.
4856 GCC can also be configured (via the
4857 @option{--with-diagnostics-urls=auto-if-env} configure-time option)
4858 so that the default is affected by environment variables.
4859 Under such a configuration, GCC defaults to using @samp{auto}
4860 if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
4861 present and non-empty in the environment of the compiler, or @samp{never}
4864 However, even with @option{-fdiagnostics-urls=always} the behavior is
4865 dependent on those environment variables:
4866 If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
4867 diagnostics. If set to @samp{st}, URLs use ST escape sequences.
4868 If set to @samp{bel}, the default, URLs use BEL escape sequences.
4869 Any other non-empty value enables the feature.
4870 If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
4871 Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
4872 BEL is an ASCII character, CTRL-G that usually sounds like a beep.
4874 At this time GCC tries to detect also a few terminals that are known to
4875 not implement the URL feature, and have bugs or at least had bugs in
4876 some versions that are still in use, where the URL escapes are likely
4877 to misbehave, i.e. print garbage on the screen.
4878 That list is currently xfce4-terminal, certain known to be buggy
4879 gnome-terminal versions, the linux console, and mingw.
4880 This check can be skipped with the @option{-fdiagnostics-urls=always}.
4882 @item -fno-diagnostics-show-option
4883 @opindex fno-diagnostics-show-option
4884 @opindex fdiagnostics-show-option
4885 By default, each diagnostic emitted includes text indicating the
4886 command-line option that directly controls the diagnostic (if such an
4887 option is known to the diagnostic machinery). Specifying the
4888 @option{-fno-diagnostics-show-option} flag suppresses that behavior.
4890 @item -fno-diagnostics-show-caret
4891 @opindex fno-diagnostics-show-caret
4892 @opindex fdiagnostics-show-caret
4893 By default, each diagnostic emitted includes the original source line
4894 and a caret @samp{^} indicating the column. This option suppresses this
4895 information. The source line is truncated to @var{n} characters, if
4896 the @option{-fmessage-length=n} option is given. When the output is done
4897 to the terminal, the width is limited to the width given by the
4898 @env{COLUMNS} environment variable or, if not set, to the terminal width.
4900 @item -fno-diagnostics-show-labels
4901 @opindex fno-diagnostics-show-labels
4902 @opindex fdiagnostics-show-labels
4903 By default, when printing source code (via @option{-fdiagnostics-show-caret}),
4904 diagnostics can label ranges of source code with pertinent information, such
4905 as the types of expressions:
4908 printf ("foo %s bar", long_i + long_j);
4914 This option suppresses the printing of these labels (in the example above,
4915 the vertical bars and the ``char *'' and ``long int'' text).
4917 @item -fno-diagnostics-show-cwe
4918 @opindex fno-diagnostics-show-cwe
4919 @opindex fdiagnostics-show-cwe
4920 Diagnostic messages can optionally have an associated
4921 @url{https://cwe.mitre.org/index.html, CWE} identifier.
4922 GCC itself only provides such metadata for some of the @option{-fanalyzer}
4923 diagnostics. GCC plugins may also provide diagnostics with such metadata.
4924 By default, if this information is present, it will be printed with
4925 the diagnostic. This option suppresses the printing of this metadata.
4927 @item -fno-diagnostics-show-line-numbers
4928 @opindex fno-diagnostics-show-line-numbers
4929 @opindex fdiagnostics-show-line-numbers
4930 By default, when printing source code (via @option{-fdiagnostics-show-caret}),
4931 a left margin is printed, showing line numbers. This option suppresses this
4934 @item -fdiagnostics-minimum-margin-width=@var{width}
4935 @opindex fdiagnostics-minimum-margin-width
4936 This option controls the minimum width of the left margin printed by
4937 @option{-fdiagnostics-show-line-numbers}. It defaults to 6.
4939 @item -fdiagnostics-parseable-fixits
4940 @opindex fdiagnostics-parseable-fixits
4941 Emit fix-it hints in a machine-parseable format, suitable for consumption
4942 by IDEs. For each fix-it, a line will be printed after the relevant
4943 diagnostic, starting with the string ``fix-it:''. For example:
4946 fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
4949 The location is expressed as a half-open range, expressed as a count of
4950 bytes, starting at byte 1 for the initial column. In the above example,
4951 bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
4955 00000000011111111112222222222
4956 12345678901234567890123456789
4957 gtk_widget_showall (dlg);
4962 The filename and replacement string escape backslash as ``\\", tab as ``\t'',
4963 newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
4964 (e.g. vertical tab as ``\013'').
4966 An empty replacement string indicates that the given range is to be removed.
4967 An empty range (e.g. ``45:3-45:3'') indicates that the string is to
4968 be inserted at the given position.
4970 @item -fdiagnostics-generate-patch
4971 @opindex fdiagnostics-generate-patch
4972 Print fix-it hints to stderr in unified diff format, after any diagnostics
4973 are printed. For example:
4980 void show_cb(GtkDialog *dlg)
4982 - gtk_widget_showall(dlg);
4983 + gtk_widget_show_all(dlg);
4988 The diff may or may not be colorized, following the same rules
4989 as for diagnostics (see @option{-fdiagnostics-color}).
4991 @item -fdiagnostics-show-template-tree
4992 @opindex fdiagnostics-show-template-tree
4994 In the C++ frontend, when printing diagnostics showing mismatching
4995 template types, such as:
4998 could not convert 'std::map<int, std::vector<double> >()'
4999 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5002 the @option{-fdiagnostics-show-template-tree} flag enables printing a
5003 tree-like structure showing the common and differing parts of the types,
5013 The parts that differ are highlighted with color (``double'' and
5014 ``float'' in this case).
5016 @item -fno-elide-type
5017 @opindex fno-elide-type
5018 @opindex felide-type
5019 By default when the C++ frontend prints diagnostics showing mismatching
5020 template types, common parts of the types are printed as ``[...]'' to
5021 simplify the error message. For example:
5024 could not convert 'std::map<int, std::vector<double> >()'
5025 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5028 Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5029 This flag also affects the output of the
5030 @option{-fdiagnostics-show-template-tree} flag.
5032 @item -fdiagnostics-path-format=@var{KIND}
5033 @opindex fdiagnostics-path-format
5034 Specify how to print paths of control-flow events for diagnostics that
5035 have such a path associated with them.
5037 @var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5040 @samp{none} means to not print diagnostic paths.
5042 @samp{separate-events} means to print a separate ``note'' diagnostic for
5043 each event within the diagnostic. For example:
5046 test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5047 test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5048 test.c:27:3: note: (2) when 'i < count'
5049 test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5052 @samp{inline-events} means to print the events ``inline'' within the source
5053 code. This view attempts to consolidate the events into runs of
5054 sufficiently-close events, printing them as labelled ranges within the source.
5056 For example, the same events as above might be printed as:
5061 | 25 | list = PyList_New(0);
5064 | | (1) when 'PyList_New' fails, returning NULL
5066 | 27 | for (i = 0; i < count; i++) @{
5069 | | (2) when 'i < count'
5070 | 28 | item = PyLong_FromLong(random());
5071 | 29 | PyList_Append(list, item);
5072 | | ~~~~~~~~~~~~~~~~~~~~~~~~~
5074 | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5078 Interprocedural control flow is shown by grouping the events by stack frame,
5079 and using indentation to show how stack frames are nested, pushed, and popped.
5089 | | (1) entering 'test'
5090 | 134 | boxed_int *obj = make_boxed_int (i);
5091 | | ~~~~~~~~~~~~~~~~~~
5093 | | (2) calling 'make_boxed_int'
5095 +--> 'make_boxed_int': events 3-4
5100 | | (3) entering 'make_boxed_int'
5101 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5102 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5104 | | (4) calling 'wrapped_malloc'
5106 +--> 'wrapped_malloc': events 5-6
5111 | | (5) entering 'wrapped_malloc'
5112 | 8 | return malloc (size);
5115 | | (6) calling 'malloc'
5121 | 138 | free_boxed_int (obj);
5122 | | ^~~~~~~~~~~~~~~~~~~~
5124 | | (7) calling 'free_boxed_int'
5129 @item -fdiagnostics-show-path-depths
5130 @opindex fdiagnostics-show-path-depths
5131 This option provides additional information when printing control-flow paths
5132 associated with a diagnostic.
5134 If this is option is provided then the stack depth will be printed for
5135 each run of events within @option{-fdiagnostics-path-format=separate-events}.
5137 This is intended for use by GCC developers and plugin developers when
5138 debugging diagnostics that report interprocedural control flow.
5140 @item -fno-show-column
5141 @opindex fno-show-column
5142 @opindex fshow-column
5143 Do not print column numbers in diagnostics. This may be necessary if
5144 diagnostics are being scanned by a program that does not understand the
5145 column numbers, such as @command{dejagnu}.
5147 @item -fdiagnostics-column-unit=@var{UNIT}
5148 @opindex fdiagnostics-column-unit
5149 Select the units for the column number. This affects traditional diagnostics
5150 (in the absence of @option{-fno-show-column}), as well as JSON format
5151 diagnostics if requested.
5153 The default @var{UNIT}, @samp{display}, considers the number of display
5154 columns occupied by each character. This may be larger than the number
5155 of bytes required to encode the character, in the case of tab
5156 characters, or it may be smaller, in the case of multibyte characters.
5157 For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5158 display column, and its UTF-8 encoding requires two bytes; the character
5159 ``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5160 its UTF-8 encoding requires four bytes.
5162 Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5163 count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5165 @item -fdiagnostics-column-origin=@var{ORIGIN}
5166 @opindex fdiagnostics-column-origin
5167 Select the origin for column numbers, i.e. the column number assigned to the
5168 first column. The default value of 1 corresponds to traditional GCC
5169 behavior and to the GNU style guide. Some utilities may perform better with an
5170 origin of 0; any non-negative value may be specified.
5172 @item -fdiagnostics-escape-format=@var{FORMAT}
5173 @opindex fdiagnostics-escape-format
5174 When GCC prints pertinent source lines for a diagnostic it normally attempts
5175 to print the source bytes directly. However, some diagnostics relate to encoding
5176 issues in the source file, such as malformed UTF-8, or issues with Unicode
5177 normalization. These diagnostics are flagged so that GCC will escape bytes
5178 that are not printable ASCII when printing their pertinent source lines.
5180 This option controls how such bytes should be escaped.
5182 The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5183 are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5184 correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5185 displayed as hexadecimal in the form @samp{<XX>}.
5187 For example, a source line containing the string @samp{before} followed by the
5188 Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
5189 0xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
5190 the string @samp{after} will be printed for such a diagnostic as:
5193 before<U+03C0><BF>after
5196 Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
5197 in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
5198 Unicode characters. For the example above, the following will be printed:
5201 before<CF><80><BF>after
5204 @item -fdiagnostics-format=@var{FORMAT}
5205 @opindex fdiagnostics-format
5206 Select a different format for printing diagnostics.
5207 @var{FORMAT} is @samp{text} or @samp{json}.
5208 The default is @samp{text}.
5210 The @samp{json} format consists of a top-level JSON array containing JSON
5211 objects representing the diagnostics.
5213 The JSON is emitted as one line, without formatting; the examples below
5214 have been formatted for clarity.
5216 Diagnostics can have child diagnostics. For example, this error and note:
5219 misleading-indentation.c:15:3: warning: this 'if' clause does not
5220 guard... [-Wmisleading-indentation]
5223 misleading-indentation.c:17:5: note: ...this statement, but the latter
5224 is misleadingly indented as if it were guarded by the 'if'
5230 might be printed in JSON form (after formatting) like this:
5239 "display-column": 3,
5242 "file": "misleading-indentation.c",
5246 "display-column": 4,
5249 "file": "misleading-indentation.c",
5254 "message": "this \u2018if\u2019 clause does not guard...",
5255 "option": "-Wmisleading-indentation",
5256 "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation",
5263 "display-column": 5,
5266 "file": "misleading-indentation.c",
5271 "escape-source": false,
5272 "message": "...this statement, but the latter is @dots{}"
5275 "escape-source": false,
5282 where the @code{note} is a child of the @code{warning}.
5284 A diagnostic has a @code{kind}. If this is @code{warning}, then there is
5285 an @code{option} key describing the command-line option controlling the
5288 A diagnostic can contain zero or more locations. Each location has an
5289 optional @code{label} string and up to three positions within it: a
5290 @code{caret} position and optional @code{start} and @code{finish} positions.
5291 A position is described by a @code{file} name, a @code{line} number, and
5292 three numbers indicating a column position:
5296 @code{display-column} counts display columns, accounting for tabs and
5297 multibyte characters.
5300 @code{byte-column} counts raw bytes.
5303 @code{column} is equal to one of
5304 the previous two, as dictated by the @option{-fdiagnostics-column-unit}
5308 All three columns are relative to the origin specified by
5309 @option{-fdiagnostics-column-origin}, which is typically equal to 1 but may
5310 be set, for instance, to 0 for compatibility with other utilities that
5311 number columns from 0. The column origin is recorded in the JSON output in
5312 the @code{column-origin} tag. In the remaining examples below, the extra
5313 column number outputs have been omitted for brevity.
5315 For example, this error:
5318 bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka
5319 'struct s'@} and 'T' @{aka 'struct t'@})
5320 64 | return callee_4a () + callee_4b ();
5321 | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
5323 | | T @{aka struct t@}
5324 | S @{aka struct s@}
5328 has three locations. Its primary location is at the ``+'' token at column
5329 23. It has two secondary locations, describing the left and right-hand sides
5330 of the expression, which have labels. It might be printed in JSON form as:
5339 "column": 23, "file": "bad-binary-ops.c", "line": 64
5344 "column": 10, "file": "bad-binary-ops.c", "line": 64
5347 "column": 21, "file": "bad-binary-ops.c", "line": 64
5349 "label": "S @{aka struct s@}"
5353 "column": 25, "file": "bad-binary-ops.c", "line": 64
5356 "column": 36, "file": "bad-binary-ops.c", "line": 64
5358 "label": "T @{aka struct t@}"
5361 "escape-source": false,
5362 "message": "invalid operands to binary + @dots{}"
5366 If a diagnostic contains fix-it hints, it has a @code{fixits} array,
5367 consisting of half-open intervals, similar to the output of
5368 @option{-fdiagnostics-parseable-fixits}. For example, this diagnostic
5369 with a replacement fix-it hint:
5372 demo.c:8:15: error: 'struct s' has no member named 'colour'; did you
5374 8 | return ptr->colour;
5380 might be printed in JSON form as:
5415 "escape-source": false,
5416 "message": "\u2018struct s\u2019 has no member named @dots{}"
5421 where the fix-it hint suggests replacing the text from @code{start} up
5422 to but not including @code{next} with @code{string}'s value. Deletions
5423 are expressed via an empty value for @code{string}, insertions by
5424 having @code{start} equal @code{next}.
5426 If the diagnostic has a path of control-flow events associated with it,
5427 it has a @code{path} array of objects representing the events. Each
5428 event object has a @code{description} string, a @code{location} object,
5429 along with a @code{function} string and a @code{depth} number for
5430 representing interprocedural paths. The @code{function} represents the
5431 current function at that event, and the @code{depth} represents the
5432 stack depth relative to some baseline: the higher, the more frames are
5435 For example, the intraprocedural example shown for
5436 @option{-fdiagnostics-path-format=} might have this JSON for its path:
5442 "description": "when 'PyList_New' fails, returning NULL",
5452 "description": "when 'i < count'",
5462 "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1",
5473 Diagnostics have a boolean attribute @code{escape-source}, hinting whether
5474 non-ASCII bytes should be escaped when printing the pertinent lines of
5475 source code (@code{true} for diagnostics involving source encoding issues).
5479 @node Warning Options
5480 @section Options to Request or Suppress Warnings
5481 @cindex options to control warnings
5482 @cindex warning messages
5483 @cindex messages, warning
5484 @cindex suppressing warnings
5486 Warnings are diagnostic messages that report constructions that
5487 are not inherently erroneous but that are risky or suggest there
5488 may have been an error.
5490 The following language-independent options do not enable specific
5491 warnings but control the kinds of diagnostics produced by GCC@.
5494 @cindex syntax checking
5496 @opindex fsyntax-only
5497 Check the code for syntax errors, but don't do anything beyond that.
5499 @item -fmax-errors=@var{n}
5500 @opindex fmax-errors
5501 Limits the maximum number of error messages to @var{n}, at which point
5502 GCC bails out rather than attempting to continue processing the source
5503 code. If @var{n} is 0 (the default), there is no limit on the number
5504 of error messages produced. If @option{-Wfatal-errors} is also
5505 specified, then @option{-Wfatal-errors} takes precedence over this
5510 Inhibit all warning messages.
5515 Make all warnings into errors.
5520 Make the specified warning into an error. The specifier for a warning
5521 is appended; for example @option{-Werror=switch} turns the warnings
5522 controlled by @option{-Wswitch} into errors. This switch takes a
5523 negative form, to be used to negate @option{-Werror} for specific
5524 warnings; for example @option{-Wno-error=switch} makes
5525 @option{-Wswitch} warnings not be errors, even when @option{-Werror}
5528 The warning message for each controllable warning includes the
5529 option that controls the warning. That option can then be used with
5530 @option{-Werror=} and @option{-Wno-error=} as described above.
5531 (Printing of the option in the warning message can be disabled using the
5532 @option{-fno-diagnostics-show-option} flag.)
5534 Note that specifying @option{-Werror=}@var{foo} automatically implies
5535 @option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
5538 @item -Wfatal-errors
5539 @opindex Wfatal-errors
5540 @opindex Wno-fatal-errors
5541 This option causes the compiler to abort compilation on the first error
5542 occurred rather than trying to keep going and printing further error
5547 You can request many specific warnings with options beginning with
5548 @samp{-W}, for example @option{-Wimplicit} to request warnings on
5549 implicit declarations. Each of these specific warning options also
5550 has a negative form beginning @samp{-Wno-} to turn off warnings; for
5551 example, @option{-Wno-implicit}. This manual lists only one of the
5552 two forms, whichever is not the default. For further
5553 language-specific options also refer to @ref{C++ Dialect Options} and
5554 @ref{Objective-C and Objective-C++ Dialect Options}.
5555 Additional warnings can be produced by enabling the static analyzer;
5556 @xref{Static Analyzer Options}.
5558 Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
5559 options, such as @option{-Wunused}, which may turn on further options,
5560 such as @option{-Wunused-value}. The combined effect of positive and
5561 negative forms is that more specific options have priority over less
5562 specific ones, independently of their position in the command-line. For
5563 options of the same specificity, the last one takes effect. Options
5564 enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
5565 as if they appeared at the end of the command-line.
5567 When an unrecognized warning option is requested (e.g.,
5568 @option{-Wunknown-warning}), GCC emits a diagnostic stating
5569 that the option is not recognized. However, if the @option{-Wno-} form
5570 is used, the behavior is slightly different: no diagnostic is
5571 produced for @option{-Wno-unknown-warning} unless other diagnostics
5572 are being produced. This allows the use of new @option{-Wno-} options
5573 with old compilers, but if something goes wrong, the compiler
5574 warns that an unrecognized option is present.
5576 The effectiveness of some warnings depends on optimizations also being
5577 enabled. For example @option{-Wsuggest-final-types} is more effective
5578 with link-time optimization and @option{-Wmaybe-uninitialized} does not
5579 warn at all unless optimization is enabled.
5586 @opindex Wno-pedantic
5587 Issue all the warnings demanded by strict ISO C and ISO C++;
5588 reject all programs that use forbidden extensions, and some other
5589 programs that do not follow ISO C and ISO C++. For ISO C, follows the
5590 version of the ISO C standard specified by any @option{-std} option used.
5592 Valid ISO C and ISO C++ programs should compile properly with or without
5593 this option (though a rare few require @option{-ansi} or a
5594 @option{-std} option specifying the required version of ISO C)@. However,
5595 without this option, certain GNU extensions and traditional C and C++
5596 features are supported as well. With this option, they are rejected.
5598 @option{-Wpedantic} does not cause warning messages for use of the
5599 alternate keywords whose names begin and end with @samp{__}. This alternate
5600 format can also be used to disable warnings for non-ISO @samp{__intN} types,
5601 i.e. @samp{__intN__}.
5602 Pedantic warnings are also disabled in the expression that follows
5603 @code{__extension__}. However, only system header files should use
5604 these escape routes; application programs should avoid them.
5605 @xref{Alternate Keywords}.
5607 Some users try to use @option{-Wpedantic} to check programs for strict ISO
5608 C conformance. They soon find that it does not do quite what they want:
5609 it finds some non-ISO practices, but not all---only those for which
5610 ISO C @emph{requires} a diagnostic, and some others for which
5611 diagnostics have been added.
5613 A feature to report any failure to conform to ISO C might be useful in
5614 some instances, but would require considerable additional work and would
5615 be quite different from @option{-Wpedantic}. We don't have plans to
5616 support such a feature in the near future.
5618 Where the standard specified with @option{-std} represents a GNU
5619 extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
5620 corresponding @dfn{base standard}, the version of ISO C on which the GNU
5621 extended dialect is based. Warnings from @option{-Wpedantic} are given
5622 where they are required by the base standard. (It does not make sense
5623 for such warnings to be given only for features not in the specified GNU
5624 C dialect, since by definition the GNU dialects of C include all
5625 features the compiler supports with the given option, and there would be
5626 nothing to warn about.)
5628 @item -pedantic-errors
5629 @opindex pedantic-errors
5630 Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
5631 requires a diagnostic, in some cases where there is undefined behavior
5632 at compile-time and in some other cases that do not prevent compilation
5633 of programs that are valid according to the standard. This is not
5634 equivalent to @option{-Werror=pedantic}, since there are errors enabled
5635 by this option and not enabled by the latter and vice versa.
5640 This enables all the warnings about constructions that some users
5641 consider questionable, and that are easy to avoid (or modify to
5642 prevent the warning), even in conjunction with macros. This also
5643 enables some language-specific warnings described in @ref{C++ Dialect
5644 Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
5646 @option{-Wall} turns on the following warning flags:
5648 @gccoptlist{-Waddress @gol
5649 -Warray-bounds=1 @r{(only with} @option{-O2}@r{)} @gol
5650 -Warray-compare @gol
5651 -Warray-parameter=2 @r{(C and Objective-C only)} @gol
5653 -Wbool-operation @gol
5654 -Wc++11-compat -Wc++14-compat @gol
5655 -Wcatch-value @r{(C++ and Objective-C++ only)} @gol
5656 -Wchar-subscripts @gol
5658 -Wduplicate-decl-specifier @r{(C and Objective-C only)} @gol
5659 -Wenum-compare @r{(in C/ObjC; this is on by default in C++)} @gol
5661 -Wformat-overflow @gol
5662 -Wformat-truncation @gol
5663 -Wint-in-bool-context @gol
5664 -Wimplicit @r{(C and Objective-C only)} @gol
5665 -Wimplicit-int @r{(C and Objective-C only)} @gol
5666 -Wimplicit-function-declaration @r{(C and Objective-C only)} @gol
5667 -Winit-self @r{(only for C++)} @gol
5668 -Wlogical-not-parentheses @gol
5669 -Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} @gol
5670 -Wmaybe-uninitialized @gol
5671 -Wmemset-elt-size @gol
5672 -Wmemset-transposed-args @gol
5673 -Wmisleading-indentation @r{(only for C/C++)} @gol
5674 -Wmismatched-dealloc @gol
5675 -Wmismatched-new-delete @r{(only for C/C++)} @gol
5676 -Wmissing-attributes @gol
5677 -Wmissing-braces @r{(only for C/ObjC)} @gol
5678 -Wmultistatement-macros @gol
5679 -Wnarrowing @r{(only for C++)} @gol
5681 -Wnonnull-compare @gol
5684 -Wpessimizing-move @r{(only for C++)} @gol
5686 -Wrange-loop-construct @r{(only for C++)} @gol
5690 -Wsequence-point @gol
5691 -Wsign-compare @r{(only in C++)} @gol
5692 -Wsizeof-array-div @gol
5693 -Wsizeof-pointer-div @gol
5694 -Wsizeof-pointer-memaccess @gol
5695 -Wstrict-aliasing @gol
5696 -Wstrict-overflow=1 @gol
5698 -Wtautological-compare @gol
5700 -Wuninitialized @gol
5701 -Wunknown-pragmas @gol
5702 -Wunused-function @gol
5705 -Wunused-variable @gol
5706 -Wvla-parameter @r{(C and Objective-C only)} @gol
5707 -Wvolatile-register-var @gol
5708 -Wzero-length-bounds}
5710 Note that some warning flags are not implied by @option{-Wall}. Some of
5711 them warn about constructions that users generally do not consider
5712 questionable, but which occasionally you might wish to check for;
5713 others warn about constructions that are necessary or hard to avoid in
5714 some cases, and there is no simple way to modify the code to suppress
5715 the warning. Some of them are enabled by @option{-Wextra} but many of
5716 them must be enabled individually.
5722 This enables some extra warning flags that are not enabled by
5723 @option{-Wall}. (This option used to be called @option{-W}. The older
5724 name is still supported, but the newer name is more descriptive.)
5726 @gccoptlist{-Wclobbered @gol
5727 -Wcast-function-type @gol
5728 -Wdeprecated-copy @r{(C++ only)} @gol
5730 -Wenum-conversion @r{(C only)} @gol
5731 -Wignored-qualifiers @gol
5732 -Wimplicit-fallthrough=3 @gol
5733 -Wmissing-field-initializers @gol
5734 -Wmissing-parameter-type @r{(C only)} @gol
5735 -Wold-style-declaration @r{(C only)} @gol
5736 -Woverride-init @gol
5737 -Wsign-compare @r{(C only)} @gol
5738 -Wstring-compare @gol
5739 -Wredundant-move @r{(only for C++)} @gol
5741 -Wuninitialized @gol
5742 -Wshift-negative-value @r{(in C++03 and in C99 and newer)} @gol
5743 -Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)} @gol
5744 -Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
5747 The option @option{-Wextra} also prints warning messages for the
5753 A pointer is compared against integer zero with @code{<}, @code{<=},
5754 @code{>}, or @code{>=}.
5757 (C++ only) An enumerator and a non-enumerator both appear in a
5758 conditional expression.
5761 (C++ only) Ambiguous virtual bases.
5764 (C++ only) Subscripting an array that has been declared @code{register}.
5767 (C++ only) Taking the address of a variable that has been declared
5771 (C++ only) A base class is not initialized in the copy constructor
5776 @item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
5780 Warn about code affected by ABI changes. This includes code that may
5781 not be compatible with the vendor-neutral C++ ABI as well as the psABI
5782 for the particular target.
5784 Since G++ now defaults to updating the ABI with each major release,
5785 normally @option{-Wabi} warns only about C++ ABI compatibility
5786 problems if there is a check added later in a release series for an
5787 ABI issue discovered since the initial release. @option{-Wabi} warns
5788 about more things if an older ABI version is selected (with
5789 @option{-fabi-version=@var{n}}).
5791 @option{-Wabi} can also be used with an explicit version number to
5792 warn about C++ ABI compatibility with a particular @option{-fabi-version}
5793 level, e.g.@: @option{-Wabi=2} to warn about changes relative to
5794 @option{-fabi-version=2}.
5796 If an explicit version number is provided and
5797 @option{-fabi-compat-version} is not specified, the version number
5798 from this option is used for compatibility aliases. If no explicit
5799 version number is provided with this option, but
5800 @option{-fabi-compat-version} is specified, that version number is
5801 used for C++ ABI warnings.
5803 Although an effort has been made to warn about
5804 all such cases, there are probably some cases that are not warned about,
5805 even though G++ is generating incompatible code. There may also be
5806 cases where warnings are emitted even though the code that is generated
5809 You should rewrite your code to avoid these warnings if you are
5810 concerned about the fact that code generated by G++ may not be binary
5811 compatible with code generated by other compilers.
5813 Known incompatibilities in @option{-fabi-version=2} (which was the
5814 default from GCC 3.4 to 4.9) include:
5819 A template with a non-type template parameter of reference type was
5820 mangled incorrectly:
5823 template <int &> struct S @{@};
5827 This was fixed in @option{-fabi-version=3}.
5830 SIMD vector types declared using @code{__attribute ((vector_size))} were
5831 mangled in a non-standard way that does not allow for overloading of
5832 functions taking vectors of different sizes.
5834 The mangling was changed in @option{-fabi-version=4}.
5837 @code{__attribute ((const))} and @code{noreturn} were mangled as type
5838 qualifiers, and @code{decltype} of a plain declaration was folded away.
5840 These mangling issues were fixed in @option{-fabi-version=5}.
5843 Scoped enumerators passed as arguments to a variadic function are
5844 promoted like unscoped enumerators, causing @code{va_arg} to complain.
5845 On most targets this does not actually affect the parameter passing
5846 ABI, as there is no way to pass an argument smaller than @code{int}.
5848 Also, the ABI changed the mangling of template argument packs,
5849 @code{const_cast}, @code{static_cast}, prefix increment/decrement, and
5850 a class scope function used as a template argument.
5852 These issues were corrected in @option{-fabi-version=6}.
5855 Lambdas in default argument scope were mangled incorrectly, and the
5856 ABI changed the mangling of @code{nullptr_t}.
5858 These issues were corrected in @option{-fabi-version=7}.
5861 When mangling a function type with function-cv-qualifiers, the
5862 un-qualified function type was incorrectly treated as a substitution
5865 This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
5868 @code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
5869 unaligned accesses. Note that this did not affect the ABI of a
5870 function with a @code{nullptr_t} parameter, as parameters have a
5873 This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
5876 Target-specific attributes that affect the identity of a type, such as
5877 ia32 calling conventions on a function type (stdcall, regparm, etc.),
5878 did not affect the mangled name, leading to name collisions when
5879 function pointers were used as template arguments.
5881 This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
5885 This option also enables warnings about psABI-related changes.
5886 The known psABI changes at this point include:
5891 For SysV/x86-64, unions with @code{long double} members are
5892 passed in memory as specified in psABI. Prior to GCC 4.4, this was not
5893 the case. For example:
5903 @code{union U} is now always passed in memory.
5907 @item -Wchar-subscripts
5908 @opindex Wchar-subscripts
5909 @opindex Wno-char-subscripts
5910 Warn if an array subscript has type @code{char}. This is a common cause
5911 of error, as programmers often forget that this type is signed on some
5913 This warning is enabled by @option{-Wall}.
5915 @item -Wno-coverage-mismatch
5916 @opindex Wno-coverage-mismatch
5917 @opindex Wcoverage-mismatch
5918 Warn if feedback profiles do not match when using the
5919 @option{-fprofile-use} option.
5920 If a source file is changed between compiling with @option{-fprofile-generate}
5921 and with @option{-fprofile-use}, the files with the profile feedback can fail
5922 to match the source file and GCC cannot use the profile feedback
5923 information. By default, this warning is enabled and is treated as an
5924 error. @option{-Wno-coverage-mismatch} can be used to disable the
5925 warning or @option{-Wno-error=coverage-mismatch} can be used to
5926 disable the error. Disabling the error for this warning can result in
5927 poorly optimized code and is useful only in the
5928 case of very minor changes such as bug fixes to an existing code-base.
5929 Completely disabling the warning is not recommended.
5931 @item -Wno-coverage-invalid-line-number
5932 @opindex Wno-coverage-invalid-line-number
5933 @opindex Wcoverage-invalid-line-number
5934 Warn in case a function ends earlier than it begins due
5935 to an invalid linenum macros. The warning is emitted only
5936 with @option{--coverage} enabled.
5938 By default, this warning is enabled and is treated as an
5939 error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
5940 warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
5943 @item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
5946 Suppress warning messages emitted by @code{#warning} directives.
5948 @item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
5949 @opindex Wdouble-promotion
5950 @opindex Wno-double-promotion
5951 Give a warning when a value of type @code{float} is implicitly
5952 promoted to @code{double}. CPUs with a 32-bit ``single-precision''
5953 floating-point unit implement @code{float} in hardware, but emulate
5954 @code{double} in software. On such a machine, doing computations
5955 using @code{double} values is much more expensive because of the
5956 overhead required for software emulation.
5958 It is easy to accidentally do computations with @code{double} because
5959 floating-point literals are implicitly of type @code{double}. For
5963 float area(float radius)
5965 return 3.14159 * radius * radius;
5969 the compiler performs the entire computation with @code{double}
5970 because the floating-point literal is a @code{double}.
5972 @item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
5973 @opindex Wduplicate-decl-specifier
5974 @opindex Wno-duplicate-decl-specifier
5975 Warn if a declaration has duplicate @code{const}, @code{volatile},
5976 @code{restrict} or @code{_Atomic} specifier. This warning is enabled by
5980 @itemx -Wformat=@var{n}
5983 @opindex ffreestanding
5984 @opindex fno-builtin
5986 Check calls to @code{printf} and @code{scanf}, etc., to make sure that
5987 the arguments supplied have types appropriate to the format string
5988 specified, and that the conversions specified in the format string make
5989 sense. This includes standard functions, and others specified by format
5990 attributes (@pxref{Function Attributes}), in the @code{printf},
5991 @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
5992 not in the C standard) families (or other target-specific families).
5993 Which functions are checked without format attributes having been
5994 specified depends on the standard version selected, and such checks of
5995 functions without the attribute specified are disabled by
5996 @option{-ffreestanding} or @option{-fno-builtin}.
5998 The formats are checked against the format features supported by GNU
5999 libc version 2.2. These include all ISO C90 and C99 features, as well
6000 as features from the Single Unix Specification and some BSD and GNU
6001 extensions. Other library implementations may not support all these
6002 features; GCC does not support warning about features that go beyond a
6003 particular library's limitations. However, if @option{-Wpedantic} is used
6004 with @option{-Wformat}, warnings are given about format features not
6005 in the selected standard version (but not for @code{strfmon} formats,
6006 since those are not in any version of the C standard). @xref{C Dialect
6007 Options,,Options Controlling C Dialect}.
6014 Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6015 @option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6016 @option{-Wformat} also checks for null format arguments for several
6017 functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6018 aspects of this level of format checking can be disabled by the
6019 options: @option{-Wno-format-contains-nul},
6020 @option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6021 @option{-Wformat} is enabled by @option{-Wall}.
6025 Enable @option{-Wformat} plus additional format checks. Currently
6026 equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6030 @item -Wno-format-contains-nul
6031 @opindex Wno-format-contains-nul
6032 @opindex Wformat-contains-nul
6033 If @option{-Wformat} is specified, do not warn about format strings that
6036 @item -Wno-format-extra-args
6037 @opindex Wno-format-extra-args
6038 @opindex Wformat-extra-args
6039 If @option{-Wformat} is specified, do not warn about excess arguments to a
6040 @code{printf} or @code{scanf} format function. The C standard specifies
6041 that such arguments are ignored.
6043 Where the unused arguments lie between used arguments that are
6044 specified with @samp{$} operand number specifications, normally
6045 warnings are still given, since the implementation could not know what
6046 type to pass to @code{va_arg} to skip the unused arguments. However,
6047 in the case of @code{scanf} formats, this option suppresses the
6048 warning if the unused arguments are all pointers, since the Single
6049 Unix Specification says that such unused arguments are allowed.
6051 @item -Wformat-overflow
6052 @itemx -Wformat-overflow=@var{level}
6053 @opindex Wformat-overflow
6054 @opindex Wno-format-overflow
6055 Warn about calls to formatted input/output functions such as @code{sprintf}
6056 and @code{vsprintf} that might overflow the destination buffer. When the
6057 exact number of bytes written by a format directive cannot be determined
6058 at compile-time it is estimated based on heuristics that depend on the
6059 @var{level} argument and on optimization. While enabling optimization
6060 will in most cases improve the accuracy of the warning, it may also
6061 result in false positives.
6064 @item -Wformat-overflow
6065 @itemx -Wformat-overflow=1
6066 @opindex Wformat-overflow
6067 @opindex Wno-format-overflow
6068 Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6069 employs a conservative approach that warns only about calls that most
6070 likely overflow the buffer. At this level, numeric arguments to format
6071 directives with unknown values are assumed to have the value of one, and
6072 strings of unknown length to be empty. Numeric arguments that are known
6073 to be bounded to a subrange of their type, or string arguments whose output
6074 is bounded either by their directive's precision or by a finite set of
6075 string literals, are assumed to take on the value within the range that
6076 results in the most bytes on output. For example, the call to @code{sprintf}
6077 below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6078 the terminating NUL character (@code{'\0'}) appended by the function
6079 to the destination buffer will be written past its end. Increasing
6080 the size of the buffer by a single byte is sufficient to avoid the
6081 warning, though it may not be sufficient to avoid the overflow.
6084 void f (int a, int b)
6087 sprintf (buf, "a = %i, b = %i\n", a, b);
6091 @item -Wformat-overflow=2
6092 Level @var{2} warns also about calls that might overflow the destination
6093 buffer given an argument of sufficient length or magnitude. At level
6094 @var{2}, unknown numeric arguments are assumed to have the minimum
6095 representable value for signed types with a precision greater than 1, and
6096 the maximum representable value otherwise. Unknown string arguments whose
6097 length cannot be assumed to be bounded either by the directive's precision,
6098 or by a finite set of string literals they may evaluate to, or the character
6099 array they may point to, are assumed to be 1 character long.
6101 At level @var{2}, the call in the example above is again diagnosed, but
6102 this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6103 @code{%i} directive will write some of its digits beyond the end of
6104 the destination buffer. To make the call safe regardless of the values
6105 of the two variables, the size of the destination buffer must be increased
6106 to at least 34 bytes. GCC includes the minimum size of the buffer in
6107 an informational note following the warning.
6109 An alternative to increasing the size of the destination buffer is to
6110 constrain the range of formatted values. The maximum length of string
6111 arguments can be bounded by specifying the precision in the format
6112 directive. When numeric arguments of format directives can be assumed
6113 to be bounded by less than the precision of their type, choosing
6114 an appropriate length modifier to the format specifier will reduce
6115 the required buffer size. For example, if @var{a} and @var{b} in the
6116 example above can be assumed to be within the precision of
6117 the @code{short int} type then using either the @code{%hi} format
6118 directive or casting the argument to @code{short} reduces the maximum
6119 required size of the buffer to 24 bytes.
6122 void f (int a, int b)
6125 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
6130 @item -Wno-format-zero-length
6131 @opindex Wno-format-zero-length
6132 @opindex Wformat-zero-length
6133 If @option{-Wformat} is specified, do not warn about zero-length formats.
6134 The C standard specifies that zero-length formats are allowed.
6136 @item -Wformat-nonliteral
6137 @opindex Wformat-nonliteral
6138 @opindex Wno-format-nonliteral
6139 If @option{-Wformat} is specified, also warn if the format string is not a
6140 string literal and so cannot be checked, unless the format function
6141 takes its format arguments as a @code{va_list}.
6143 @item -Wformat-security
6144 @opindex Wformat-security
6145 @opindex Wno-format-security
6146 If @option{-Wformat} is specified, also warn about uses of format
6147 functions that represent possible security problems. At present, this
6148 warns about calls to @code{printf} and @code{scanf} functions where the
6149 format string is not a string literal and there are no format arguments,
6150 as in @code{printf (foo);}. This may be a security hole if the format
6151 string came from untrusted input and contains @samp{%n}. (This is
6152 currently a subset of what @option{-Wformat-nonliteral} warns about, but
6153 in future warnings may be added to @option{-Wformat-security} that are not
6154 included in @option{-Wformat-nonliteral}.)
6156 @item -Wformat-signedness
6157 @opindex Wformat-signedness
6158 @opindex Wno-format-signedness
6159 If @option{-Wformat} is specified, also warn if the format string
6160 requires an unsigned argument and the argument is signed and vice versa.
6162 @item -Wformat-truncation
6163 @itemx -Wformat-truncation=@var{level}
6164 @opindex Wformat-truncation
6165 @opindex Wno-format-truncation
6166 Warn about calls to formatted input/output functions such as @code{snprintf}
6167 and @code{vsnprintf} that might result in output truncation. When the exact
6168 number of bytes written by a format directive cannot be determined at
6169 compile-time it is estimated based on heuristics that depend on
6170 the @var{level} argument and on optimization. While enabling optimization
6171 will in most cases improve the accuracy of the warning, it may also result
6172 in false positives. Except as noted otherwise, the option uses the same
6173 logic @option{-Wformat-overflow}.
6176 @item -Wformat-truncation
6177 @itemx -Wformat-truncation=1
6178 @opindex Wformat-truncation
6179 @opindex Wno-format-truncation
6180 Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
6181 employs a conservative approach that warns only about calls to bounded
6182 functions whose return value is unused and that will most likely result
6183 in output truncation.
6185 @item -Wformat-truncation=2
6186 Level @var{2} warns also about calls to bounded functions whose return
6187 value is used and that might result in truncation given an argument of
6188 sufficient length or magnitude.
6192 @opindex Wformat-y2k
6193 @opindex Wno-format-y2k
6194 If @option{-Wformat} is specified, also warn about @code{strftime}
6195 formats that may yield only a two-digit year.
6199 @opindex Wno-nonnull
6200 Warn about passing a null pointer for arguments marked as
6201 requiring a non-null value by the @code{nonnull} function attribute.
6203 @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
6204 can be disabled with the @option{-Wno-nonnull} option.
6206 @item -Wnonnull-compare
6207 @opindex Wnonnull-compare
6208 @opindex Wno-nonnull-compare
6209 Warn when comparing an argument marked with the @code{nonnull}
6210 function attribute against null inside the function.
6212 @option{-Wnonnull-compare} is included in @option{-Wall}. It
6213 can be disabled with the @option{-Wno-nonnull-compare} option.
6215 @item -Wnull-dereference
6216 @opindex Wnull-dereference
6217 @opindex Wno-null-dereference
6218 Warn if the compiler detects paths that trigger erroneous or
6219 undefined behavior due to dereferencing a null pointer. This option
6220 is only active when @option{-fdelete-null-pointer-checks} is active,
6221 which is enabled by optimizations in most targets. The precision of
6222 the warnings depends on the optimization options used.
6224 @item -Winfinite-recursion
6225 @opindex Winfinite-recursion
6226 @opindex Wno-infinite-recursion
6227 Warn about infinitely recursive calls. The warning is effective at all
6228 optimization levels but requires optimization in order to detect infinite
6229 recursion in calls between two or more functions.
6230 @option{-Winfinite-recursion} is included in @option{-Wall}.
6232 @item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
6234 @opindex Wno-init-self
6235 Warn about uninitialized variables that are initialized with themselves.
6236 Note this option can only be used with the @option{-Wuninitialized} option.
6238 For example, GCC warns about @code{i} being uninitialized in the
6239 following snippet only when @option{-Winit-self} has been specified:
6250 This warning is enabled by @option{-Wall} in C++.
6252 @item -Wno-implicit-int @r{(C and Objective-C only)}
6253 @opindex Wimplicit-int
6254 @opindex Wno-implicit-int
6255 This option controls warnings when a declaration does not specify a type.
6256 This warning is enabled by default in C99 and later dialects of C,
6257 and also by @option{-Wall}.
6259 @item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
6260 @opindex Wimplicit-function-declaration
6261 @opindex Wno-implicit-function-declaration
6262 This option controls warnings when a function is used before being declared.
6263 This warning is enabled by default in C99 and later dialects of C,
6264 and also by @option{-Wall}.
6265 The warning is made into an error by @option{-pedantic-errors}.
6267 @item -Wimplicit @r{(C and Objective-C only)}
6269 @opindex Wno-implicit
6270 Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
6271 This warning is enabled by @option{-Wall}.
6273 @item -Wimplicit-fallthrough
6274 @opindex Wimplicit-fallthrough
6275 @opindex Wno-implicit-fallthrough
6276 @option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
6277 and @option{-Wno-implicit-fallthrough} is the same as
6278 @option{-Wimplicit-fallthrough=0}.
6280 @item -Wimplicit-fallthrough=@var{n}
6281 @opindex Wimplicit-fallthrough=
6282 Warn when a switch case falls through. For example:
6300 This warning does not warn when the last statement of a case cannot
6301 fall through, e.g. when there is a return statement or a call to function
6302 declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
6303 also takes into account control flow statements, such as ifs, and only
6304 warns when appropriate. E.g.@:
6314 @} else if (i < 1) @{
6324 Since there are occasions where a switch case fall through is desirable,
6325 GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
6326 to be used along with a null statement to suppress this warning that
6327 would normally occur:
6335 __attribute__ ((fallthrough));
6342 C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
6343 warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
6344 or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
6345 Instead of these attributes, it is also possible to add a fallthrough comment
6346 to silence the warning. The whole body of the C or C++ style comment should
6347 match the given regular expressions listed below. The option argument @var{n}
6348 specifies what kind of comments are accepted:
6352 @item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
6354 @item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
6355 expression, any comment is used as fallthrough comment.
6357 @item @option{-Wimplicit-fallthrough=2} case insensitively matches
6358 @code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
6360 @item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
6361 following regular expressions:
6365 @item @code{-fallthrough}
6367 @item @code{@@fallthrough@@}
6369 @item @code{lint -fallthrough[ \t]*}
6371 @item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
6373 @item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6375 @item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6379 @item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
6380 following regular expressions:
6384 @item @code{-fallthrough}
6386 @item @code{@@fallthrough@@}
6388 @item @code{lint -fallthrough[ \t]*}
6390 @item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
6394 @item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
6395 fallthrough comments, only attributes disable the warning.
6399 The comment needs to be followed after optional whitespace and other comments
6400 by @code{case} or @code{default} keywords or by a user label that precedes some
6401 @code{case} or @code{default} label.
6416 The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
6418 @item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
6419 @opindex Wif-not-aligned
6420 @opindex Wno-if-not-aligned
6421 Control if warnings triggered by the @code{warn_if_not_aligned} attribute
6422 should be issued. These warnings are enabled by default.
6424 @item -Wignored-qualifiers @r{(C and C++ only)}
6425 @opindex Wignored-qualifiers
6426 @opindex Wno-ignored-qualifiers
6427 Warn if the return type of a function has a type qualifier
6428 such as @code{const}. For ISO C such a type qualifier has no effect,
6429 since the value returned by a function is not an lvalue.
6430 For C++, the warning is only emitted for scalar types or @code{void}.
6431 ISO C prohibits qualified @code{void} return types on function
6432 definitions, so such return types always receive a warning
6433 even without this option.
6435 This warning is also enabled by @option{-Wextra}.
6437 @item -Wno-ignored-attributes @r{(C and C++ only)}
6438 @opindex Wignored-attributes
6439 @opindex Wno-ignored-attributes
6440 This option controls warnings when an attribute is ignored.
6441 This is different from the
6442 @option{-Wattributes} option in that it warns whenever the compiler decides
6443 to drop an attribute, not that the attribute is either unknown, used in a
6444 wrong place, etc. This warning is enabled by default.
6449 Warn if the type of @code{main} is suspicious. @code{main} should be
6450 a function with external linkage, returning int, taking either zero
6451 arguments, two, or three arguments of appropriate types. This warning
6452 is enabled by default in C++ and is enabled by either @option{-Wall}
6453 or @option{-Wpedantic}.
6455 @item -Wmisleading-indentation @r{(C and C++ only)}
6456 @opindex Wmisleading-indentation
6457 @opindex Wno-misleading-indentation
6458 Warn when the indentation of the code does not reflect the block structure.
6459 Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
6460 @code{for} clauses with a guarded statement that does not use braces,
6461 followed by an unguarded statement with the same indentation.
6463 In the following example, the call to ``bar'' is misleadingly indented as
6464 if it were guarded by the ``if'' conditional.
6467 if (some_condition ())
6469 bar (); /* Gotcha: this is not guarded by the "if". */
6472 In the case of mixed tabs and spaces, the warning uses the
6473 @option{-ftabstop=} option to determine if the statements line up
6476 The warning is not issued for code involving multiline preprocessor logic
6477 such as the following example.
6482 #if SOME_CONDITION_THAT_DOES_NOT_HOLD
6488 The warning is not issued after a @code{#line} directive, since this
6489 typically indicates autogenerated code, and no assumptions can be made
6490 about the layout of the file that the directive references.
6492 This warning is enabled by @option{-Wall} in C and C++.
6494 @item -Wmissing-attributes
6495 @opindex Wmissing-attributes
6496 @opindex Wno-missing-attributes
6497 Warn when a declaration of a function is missing one or more attributes
6498 that a related function is declared with and whose absence may adversely
6499 affect the correctness or efficiency of generated code. For example,
6500 the warning is issued for declarations of aliases that use attributes
6501 to specify less restrictive requirements than those of their targets.
6502 This typically represents a potential optimization opportunity.
6503 By contrast, the @option{-Wattribute-alias=2} option controls warnings
6504 issued when the alias is more restrictive than the target, which could
6505 lead to incorrect code generation.
6506 Attributes considered include @code{alloc_align}, @code{alloc_size},
6507 @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
6508 @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
6509 @code{returns_nonnull}, and @code{returns_twice}.
6511 In C++, the warning is issued when an explicit specialization of a primary
6512 template declared with attribute @code{alloc_align}, @code{alloc_size},
6513 @code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
6514 or @code{nonnull} is declared without it. Attributes @code{deprecated},
6515 @code{error}, and @code{warning} suppress the warning.
6516 (@pxref{Function Attributes}).
6518 You can use the @code{copy} attribute to apply the same
6519 set of attributes to a declaration as that on another declaration without
6520 explicitly enumerating the attributes. This attribute can be applied
6521 to declarations of functions (@pxref{Common Function Attributes}),
6522 variables (@pxref{Common Variable Attributes}), or types
6523 (@pxref{Common Type Attributes}).
6525 @option{-Wmissing-attributes} is enabled by @option{-Wall}.
6527 For example, since the declaration of the primary function template
6528 below makes use of both attribute @code{malloc} and @code{alloc_size}
6529 the declaration of the explicit specialization of the template is
6530 diagnosed because it is missing one of the attributes.
6534 T* __attribute__ ((malloc, alloc_size (1)))
6538 void* __attribute__ ((malloc)) // missing alloc_size
6539 allocate<void> (size_t);
6542 @item -Wmissing-braces
6543 @opindex Wmissing-braces
6544 @opindex Wno-missing-braces
6545 Warn if an aggregate or union initializer is not fully bracketed. In
6546 the following example, the initializer for @code{a} is not fully
6547 bracketed, but that for @code{b} is fully bracketed.
6550 int a[2][2] = @{ 0, 1, 2, 3 @};
6551 int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
6554 This warning is enabled by @option{-Wall}.
6556 @item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
6557 @opindex Wmissing-include-dirs
6558 @opindex Wno-missing-include-dirs
6559 Warn if a user-supplied include directory does not exist. This opions is disabled
6560 by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
6561 enabled by default by warning for -I and -J, only.
6563 @item -Wno-missing-profile
6564 @opindex Wmissing-profile
6565 @opindex Wno-missing-profile
6566 This option controls warnings if feedback profiles are missing when using the
6567 @option{-fprofile-use} option.
6568 This option diagnoses those cases where a new function or a new file is added
6569 between compiling with @option{-fprofile-generate} and with
6570 @option{-fprofile-use}, without regenerating the profiles.
6571 In these cases, the profile feedback data files do not contain any
6572 profile feedback information for
6573 the newly added function or file respectively. Also, in the case when profile
6574 count data (.gcda) files are removed, GCC cannot use any profile feedback
6575 information. In all these cases, warnings are issued to inform you that a
6576 profile generation step is due.
6577 Ignoring the warning can result in poorly optimized code.
6578 @option{-Wno-missing-profile} can be used to
6579 disable the warning, but this is not recommended and should be done only
6580 when non-existent profile data is justified.
6582 @item -Wmismatched-dealloc
6583 @opindex Wmismatched-dealloc
6584 @opindex Wno-mismatched-dealloc
6586 Warn for calls to deallocation functions with pointer arguments returned
6587 from from allocations functions for which the former isn't a suitable
6588 deallocator. A pair of functions can be associated as matching allocators
6589 and deallocators by use of attribute @code{malloc}. Unless disabled by
6590 the @option{-fno-builtin} option the standard functions @code{calloc},
6591 @code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
6592 forms of C++ @code{operator new} and @code{operator delete} are implicitly
6593 associated as matching allocators and deallocators. In the following
6594 example @code{mydealloc} is the deallocator for pointers returned from
6598 void mydealloc (void*);
6600 __attribute__ ((malloc (mydealloc, 1))) void*
6605 void *p = myalloc (32);
6606 // @dots{}use p@dots{}
6607 free (p); // warning: not a matching deallocator for myalloc
6608 mydealloc (p); // ok
6612 In C++, the related option @option{-Wmismatched-new-delete} diagnoses
6613 mismatches involving either @code{operator new} or @code{operator delete}.
6615 Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
6617 @item -Wmultistatement-macros
6618 @opindex Wmultistatement-macros
6619 @opindex Wno-multistatement-macros
6620 Warn about unsafe multiple statement macros that appear to be guarded
6621 by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
6622 @code{while}, in which only the first statement is actually guarded after
6623 the macro is expanded.
6628 #define DOIT x++; y++
6633 will increment @code{y} unconditionally, not just when @code{c} holds.
6634 The can usually be fixed by wrapping the macro in a do-while loop:
6636 #define DOIT do @{ x++; y++; @} while (0)
6641 This warning is enabled by @option{-Wall} in C and C++.
6644 @opindex Wparentheses
6645 @opindex Wno-parentheses
6646 Warn if parentheses are omitted in certain contexts, such
6647 as when there is an assignment in a context where a truth value
6648 is expected, or when operators are nested whose precedence people
6649 often get confused about.
6651 Also warn if a comparison like @code{x<=y<=z} appears; this is
6652 equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
6653 interpretation from that of ordinary mathematical notation.
6655 Also warn for dangerous uses of the GNU extension to
6656 @code{?:} with omitted middle operand. When the condition
6657 in the @code{?}: operator is a boolean expression, the omitted value is
6658 always 1. Often programmers expect it to be a value computed
6659 inside the conditional expression instead.
6661 For C++ this also warns for some cases of unnecessary parentheses in
6662 declarations, which can indicate an attempt at a function call instead
6666 // Declares a local variable called mymutex.
6667 std::unique_lock<std::mutex> (mymutex);
6668 // User meant std::unique_lock<std::mutex> lock (mymutex);
6672 This warning is enabled by @option{-Wall}.
6674 @item -Wsequence-point
6675 @opindex Wsequence-point
6676 @opindex Wno-sequence-point
6677 Warn about code that may have undefined semantics because of violations
6678 of sequence point rules in the C and C++ standards.
6680 The C and C++ standards define the order in which expressions in a C/C++
6681 program are evaluated in terms of @dfn{sequence points}, which represent
6682 a partial ordering between the execution of parts of the program: those
6683 executed before the sequence point, and those executed after it. These
6684 occur after the evaluation of a full expression (one which is not part
6685 of a larger expression), after the evaluation of the first operand of a
6686 @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
6687 function is called (but after the evaluation of its arguments and the
6688 expression denoting the called function), and in certain other places.
6689 Other than as expressed by the sequence point rules, the order of
6690 evaluation of subexpressions of an expression is not specified. All
6691 these rules describe only a partial order rather than a total order,
6692 since, for example, if two functions are called within one expression
6693 with no sequence point between them, the order in which the functions
6694 are called is not specified. However, the standards committee have
6695 ruled that function calls do not overlap.
6697 It is not specified when between sequence points modifications to the
6698 values of objects take effect. Programs whose behavior depends on this
6699 have undefined behavior; the C and C++ standards specify that ``Between
6700 the previous and next sequence point an object shall have its stored
6701 value modified at most once by the evaluation of an expression.
6702 Furthermore, the prior value shall be read only to determine the value
6703 to be stored.''. If a program breaks these rules, the results on any
6704 particular implementation are entirely unpredictable.
6706 Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
6707 = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
6708 diagnosed by this option, and it may give an occasional false positive
6709 result, but in general it has been found fairly effective at detecting
6710 this sort of problem in programs.
6712 The C++17 standard will define the order of evaluation of operands in
6713 more cases: in particular it requires that the right-hand side of an
6714 assignment be evaluated before the left-hand side, so the above
6715 examples are no longer undefined. But this option will still warn
6716 about them, to help people avoid writing code that is undefined in C
6717 and earlier revisions of C++.
6719 The standard is worded confusingly, therefore there is some debate
6720 over the precise meaning of the sequence point rules in subtle cases.
6721 Links to discussions of the problem, including proposed formal
6722 definitions, may be found on the GCC readings page, at
6723 @uref{https://gcc.gnu.org/@/readings.html}.
6725 This warning is enabled by @option{-Wall} for C and C++.
6727 @item -Wno-return-local-addr
6728 @opindex Wno-return-local-addr
6729 @opindex Wreturn-local-addr
6730 Do not warn about returning a pointer (or in C++, a reference) to a
6731 variable that goes out of scope after the function returns.
6734 @opindex Wreturn-type
6735 @opindex Wno-return-type
6736 Warn whenever a function is defined with a return type that defaults
6737 to @code{int}. Also warn about any @code{return} statement with no
6738 return value in a function whose return type is not @code{void}
6739 (falling off the end of the function body is considered returning
6742 For C only, warn about a @code{return} statement with an expression in a
6743 function whose return type is @code{void}, unless the expression type is
6744 also @code{void}. As a GNU extension, the latter case is accepted
6745 without a warning unless @option{-Wpedantic} is used. Attempting
6746 to use the return value of a non-@code{void} function other than @code{main}
6747 that flows off the end by reaching the closing curly brace that terminates
6748 the function is undefined.
6750 Unlike in C, in C++, flowing off the end of a non-@code{void} function other
6751 than @code{main} results in undefined behavior even when the value of
6752 the function is not used.
6754 This warning is enabled by default in C++ and by @option{-Wall} otherwise.
6756 @item -Wno-shift-count-negative
6757 @opindex Wshift-count-negative
6758 @opindex Wno-shift-count-negative
6759 Controls warnings if a shift count is negative.
6760 This warning is enabled by default.
6762 @item -Wno-shift-count-overflow
6763 @opindex Wshift-count-overflow
6764 @opindex Wno-shift-count-overflow
6765 Controls warnings if a shift count is greater than or equal to the bit width
6766 of the type. This warning is enabled by default.
6768 @item -Wshift-negative-value
6769 @opindex Wshift-negative-value
6770 @opindex Wno-shift-negative-value
6771 Warn if left shifting a negative value. This warning is enabled by
6772 @option{-Wextra} in C99 and C++11 modes (and newer).
6774 @item -Wno-shift-overflow
6775 @itemx -Wshift-overflow=@var{n}
6776 @opindex Wshift-overflow
6777 @opindex Wno-shift-overflow
6778 These options control warnings about left shift overflows.
6781 @item -Wshift-overflow=1
6782 This is the warning level of @option{-Wshift-overflow} and is enabled
6783 by default in C99 and C++11 modes (and newer). This warning level does
6784 not warn about left-shifting 1 into the sign bit. (However, in C, such
6785 an overflow is still rejected in contexts where an integer constant expression
6786 is required.) No warning is emitted in C++20 mode (and newer), as signed left
6789 @item -Wshift-overflow=2
6790 This warning level also warns about left-shifting 1 into the sign bit,
6791 unless C++14 mode (or newer) is active.
6797 Warn whenever a @code{switch} statement has an index of enumerated type
6798 and lacks a @code{case} for one or more of the named codes of that
6799 enumeration. (The presence of a @code{default} label prevents this
6800 warning.) @code{case} labels outside the enumeration range also
6801 provoke warnings when this option is used (even if there is a
6802 @code{default} label).
6803 This warning is enabled by @option{-Wall}.
6805 @item -Wswitch-default
6806 @opindex Wswitch-default
6807 @opindex Wno-switch-default
6808 Warn whenever a @code{switch} statement does not have a @code{default}
6812 @opindex Wswitch-enum
6813 @opindex Wno-switch-enum
6814 Warn whenever a @code{switch} statement has an index of enumerated type
6815 and lacks a @code{case} for one or more of the named codes of that
6816 enumeration. @code{case} labels outside the enumeration range also
6817 provoke warnings when this option is used. The only difference
6818 between @option{-Wswitch} and this option is that this option gives a
6819 warning about an omitted enumeration code even if there is a
6820 @code{default} label.
6822 @item -Wno-switch-bool
6823 @opindex Wswitch-bool
6824 @opindex Wno-switch-bool
6825 Do not warn when a @code{switch} statement has an index of boolean type
6826 and the case values are outside the range of a boolean type.
6827 It is possible to suppress this warning by casting the controlling
6828 expression to a type other than @code{bool}. For example:
6831 switch ((int) (a == 4))
6837 This warning is enabled by default for C and C++ programs.
6839 @item -Wno-switch-outside-range
6840 @opindex Wswitch-outside-range
6841 @opindex Wno-switch-outside-range
6842 This option controls warnings when a @code{switch} case has a value
6843 that is outside of its
6844 respective type range. This warning is enabled by default for
6847 @item -Wno-switch-unreachable
6848 @opindex Wswitch-unreachable
6849 @opindex Wno-switch-unreachable
6850 Do not warn when a @code{switch} statement contains statements between the
6851 controlling expression and the first case label, which will never be
6852 executed. For example:
6864 @option{-Wswitch-unreachable} does not warn if the statement between the
6865 controlling expression and the first case label is just a declaration:
6878 This warning is enabled by default for C and C++ programs.
6880 @item -Wsync-nand @r{(C and C++ only)}
6882 @opindex Wno-sync-nand
6883 Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
6884 built-in functions are used. These functions changed semantics in GCC 4.4.
6886 @item -Wunused-but-set-parameter
6887 @opindex Wunused-but-set-parameter
6888 @opindex Wno-unused-but-set-parameter
6889 Warn whenever a function parameter is assigned to, but otherwise unused
6890 (aside from its declaration).
6892 To suppress this warning use the @code{unused} attribute
6893 (@pxref{Variable Attributes}).
6895 This warning is also enabled by @option{-Wunused} together with
6898 @item -Wunused-but-set-variable
6899 @opindex Wunused-but-set-variable
6900 @opindex Wno-unused-but-set-variable
6901 Warn whenever a local variable is assigned to, but otherwise unused
6902 (aside from its declaration).
6903 This warning is enabled by @option{-Wall}.
6905 To suppress this warning use the @code{unused} attribute
6906 (@pxref{Variable Attributes}).
6908 This warning is also enabled by @option{-Wunused}, which is enabled
6911 @item -Wunused-function
6912 @opindex Wunused-function
6913 @opindex Wno-unused-function
6914 Warn whenever a static function is declared but not defined or a
6915 non-inline static function is unused.
6916 This warning is enabled by @option{-Wall}.
6918 @item -Wunused-label
6919 @opindex Wunused-label
6920 @opindex Wno-unused-label
6921 Warn whenever a label is declared but not used.
6922 This warning is enabled by @option{-Wall}.
6924 To suppress this warning use the @code{unused} attribute
6925 (@pxref{Variable Attributes}).
6927 @item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
6928 @opindex Wunused-local-typedefs
6929 @opindex Wno-unused-local-typedefs
6930 Warn when a typedef locally defined in a function is not used.
6931 This warning is enabled by @option{-Wall}.
6933 @item -Wunused-parameter
6934 @opindex Wunused-parameter
6935 @opindex Wno-unused-parameter
6936 Warn whenever a function parameter is unused aside from its declaration.
6938 To suppress this warning use the @code{unused} attribute
6939 (@pxref{Variable Attributes}).
6941 @item -Wno-unused-result
6942 @opindex Wunused-result
6943 @opindex Wno-unused-result
6944 Do not warn if a caller of a function marked with attribute
6945 @code{warn_unused_result} (@pxref{Function Attributes}) does not use
6946 its return value. The default is @option{-Wunused-result}.
6948 @item -Wunused-variable
6949 @opindex Wunused-variable
6950 @opindex Wno-unused-variable
6951 Warn whenever a local or static variable is unused aside from its
6952 declaration. This option implies @option{-Wunused-const-variable=1} for C,
6953 but not for C++. This warning is enabled by @option{-Wall}.
6955 To suppress this warning use the @code{unused} attribute
6956 (@pxref{Variable Attributes}).
6958 @item -Wunused-const-variable
6959 @itemx -Wunused-const-variable=@var{n}
6960 @opindex Wunused-const-variable
6961 @opindex Wno-unused-const-variable
6962 Warn whenever a constant static variable is unused aside from its declaration.
6963 @option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable}
6964 for C, but not for C++. In C this declares variable storage, but in C++ this
6965 is not an error since const variables take the place of @code{#define}s.
6967 To suppress this warning use the @code{unused} attribute
6968 (@pxref{Variable Attributes}).
6971 @item -Wunused-const-variable=1
6972 This is the warning level that is enabled by @option{-Wunused-variable} for
6973 C. It warns only about unused static const variables defined in the main
6974 compilation unit, but not about static const variables declared in any
6977 @item -Wunused-const-variable=2
6978 This warning level also warns for unused constant static variables in
6979 headers (excluding system headers). This is the warning level of
6980 @option{-Wunused-const-variable} and must be explicitly requested since
6981 in C++ this isn't an error and in C it might be harder to clean up all
6985 @item -Wunused-value
6986 @opindex Wunused-value
6987 @opindex Wno-unused-value
6988 Warn whenever a statement computes a result that is explicitly not
6989 used. To suppress this warning cast the unused expression to
6990 @code{void}. This includes an expression-statement or the left-hand
6991 side of a comma expression that contains no side effects. For example,
6992 an expression such as @code{x[i,j]} causes a warning, while
6993 @code{x[(void)i,j]} does not.
6995 This warning is enabled by @option{-Wall}.
7000 All the above @option{-Wunused} options combined.
7002 In order to get a warning about an unused function parameter, you must
7003 either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
7004 @option{-Wunused}), or separately specify @option{-Wunused-parameter}.
7006 @item -Wuninitialized
7007 @opindex Wuninitialized
7008 @opindex Wno-uninitialized
7009 Warn if an object with automatic or allocated storage duration is used
7010 without having been initialized. In C++, also warn if a non-static
7011 reference or non-static @code{const} member appears in a class without
7014 In addition, passing a pointer (or in C++, a reference) to an uninitialized
7015 object to a @code{const}-qualified argument of a built-in function known to
7016 read the object is also diagnosed by this warning.
7017 (@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
7019 If you want to warn about code that uses the uninitialized value of the
7020 variable in its own initializer, use the @option{-Winit-self} option.
7022 These warnings occur for individual uninitialized elements of
7023 structure, union or array variables as well as for variables that are
7024 uninitialized as a whole. They do not occur for variables or elements
7025 declared @code{volatile}. Because these warnings depend on
7026 optimization, the exact variables or elements for which there are
7027 warnings depend on the precise optimization options and version of GCC
7030 Note that there may be no warning about a variable that is used only
7031 to compute a value that itself is never used, because such
7032 computations may be deleted by data flow analysis before the warnings
7035 In C++, this warning also warns about using uninitialized objects in
7036 member-initializer-lists. For example, GCC warns about @code{b} being
7037 uninitialized in the following snippet:
7047 @item -Wno-invalid-memory-model
7048 @opindex Winvalid-memory-model
7049 @opindex Wno-invalid-memory-model
7050 This option controls warnings
7051 for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
7052 and the C11 atomic generic functions with a memory consistency argument
7053 that is either invalid for the operation or outside the range of values
7054 of the @code{memory_order} enumeration. For example, since the
7055 @code{__atomic_store} and @code{__atomic_store_n} built-ins are only
7056 defined for the relaxed, release, and sequentially consistent memory
7057 orders the following code is diagnosed:
7062 __atomic_store_n (i, 0, memory_order_consume);
7066 @option{-Winvalid-memory-model} is enabled by default.
7068 @item -Wmaybe-uninitialized
7069 @opindex Wmaybe-uninitialized
7070 @opindex Wno-maybe-uninitialized
7071 For an object with automatic or allocated storage duration, if there exists
7072 a path from the function entry to a use of the object that is initialized,
7073 but there exist some other paths for which the object is not initialized,
7074 the compiler emits a warning if it cannot prove the uninitialized paths
7075 are not executed at run time.
7077 In addition, passing a pointer (or in C++, a reference) to an uninitialized
7078 object to a @code{const}-qualified function argument is also diagnosed by
7079 this warning. (@option{-Wuninitialized} is issued for built-in functions
7080 known to read the object.) Annotating the function with attribute
7081 @code{access (none)} indicates that the argument isn't used to access
7082 the object and avoids the warning (@pxref{Common Function Attributes}).
7084 These warnings are only possible in optimizing compilation, because otherwise
7085 GCC does not keep track of the state of variables.
7087 These warnings are made optional because GCC may not be able to determine when
7088 the code is correct in spite of appearing to have an error. Here is one
7089 example of how this can happen:
7109 If the value of @code{y} is always 1, 2 or 3, then @code{x} is
7110 always initialized, but GCC doesn't know this. To suppress the
7111 warning, you need to provide a default case with assert(0) or
7114 @cindex @code{longjmp} warnings
7115 This option also warns when a non-volatile automatic variable might be
7116 changed by a call to @code{longjmp}.
7117 The compiler sees only the calls to @code{setjmp}. It cannot know
7118 where @code{longjmp} will be called; in fact, a signal handler could
7119 call it at any point in the code. As a result, you may get a warning
7120 even when there is in fact no problem because @code{longjmp} cannot
7121 in fact be called at the place that would cause a problem.
7123 Some spurious warnings can be avoided if you declare all the functions
7124 you use that never return as @code{noreturn}. @xref{Function
7127 This warning is enabled by @option{-Wall} or @option{-Wextra}.
7129 @item -Wunknown-pragmas
7130 @opindex Wunknown-pragmas
7131 @opindex Wno-unknown-pragmas
7132 @cindex warning for unknown pragmas
7133 @cindex unknown pragmas, warning
7134 @cindex pragmas, warning of unknown
7135 Warn when a @code{#pragma} directive is encountered that is not understood by
7136 GCC@. If this command-line option is used, warnings are even issued
7137 for unknown pragmas in system header files. This is not the case if
7138 the warnings are only enabled by the @option{-Wall} command-line option.
7141 @opindex Wno-pragmas
7143 Do not warn about misuses of pragmas, such as incorrect parameters,
7144 invalid syntax, or conflicts between pragmas. See also
7145 @option{-Wunknown-pragmas}.
7147 @item -Wno-prio-ctor-dtor
7148 @opindex Wno-prio-ctor-dtor
7149 @opindex Wprio-ctor-dtor
7150 Do not warn if a priority from 0 to 100 is used for constructor or destructor.
7151 The use of constructor and destructor attributes allow you to assign a
7152 priority to the constructor/destructor to control its order of execution
7153 before @code{main} is called or after it returns. The priority values must be
7154 greater than 100 as the compiler reserves priority values between 0--100 for
7157 @item -Wstrict-aliasing
7158 @opindex Wstrict-aliasing
7159 @opindex Wno-strict-aliasing
7160 This option is only active when @option{-fstrict-aliasing} is active.
7161 It warns about code that might break the strict aliasing rules that the
7162 compiler is using for optimization. The warning does not catch all
7163 cases, but does attempt to catch the more common pitfalls. It is
7164 included in @option{-Wall}.
7165 It is equivalent to @option{-Wstrict-aliasing=3}
7167 @item -Wstrict-aliasing=n
7168 @opindex Wstrict-aliasing=n
7169 This option is only active when @option{-fstrict-aliasing} is active.
7170 It warns about code that might break the strict aliasing rules that the
7171 compiler is using for optimization.
7172 Higher levels correspond to higher accuracy (fewer false positives).
7173 Higher levels also correspond to more effort, similar to the way @option{-O}
7175 @option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
7177 Level 1: Most aggressive, quick, least accurate.
7178 Possibly useful when higher levels
7179 do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
7180 false negatives. However, it has many false positives.
7181 Warns for all pointer conversions between possibly incompatible types,
7182 even if never dereferenced. Runs in the front end only.
7184 Level 2: Aggressive, quick, not too precise.
7185 May still have many false positives (not as many as level 1 though),
7186 and few false negatives (but possibly more than level 1).
7187 Unlike level 1, it only warns when an address is taken. Warns about
7188 incomplete types. Runs in the front end only.
7190 Level 3 (default for @option{-Wstrict-aliasing}):
7191 Should have very few false positives and few false
7192 negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
7193 Takes care of the common pun+dereference pattern in the front end:
7194 @code{*(int*)&some_float}.
7195 If optimization is enabled, it also runs in the back end, where it deals
7196 with multiple statement cases using flow-sensitive points-to information.
7197 Only warns when the converted pointer is dereferenced.
7198 Does not warn about incomplete types.
7200 @item -Wstrict-overflow
7201 @itemx -Wstrict-overflow=@var{n}
7202 @opindex Wstrict-overflow
7203 @opindex Wno-strict-overflow
7204 This option is only active when signed overflow is undefined.
7205 It warns about cases where the compiler optimizes based on the
7206 assumption that signed overflow does not occur. Note that it does not
7207 warn about all cases where the code might overflow: it only warns
7208 about cases where the compiler implements some optimization. Thus
7209 this warning depends on the optimization level.
7211 An optimization that assumes that signed overflow does not occur is
7212 perfectly safe if the values of the variables involved are such that
7213 overflow never does, in fact, occur. Therefore this warning can
7214 easily give a false positive: a warning about code that is not
7215 actually a problem. To help focus on important issues, several
7216 warning levels are defined. No warnings are issued for the use of
7217 undefined signed overflow when estimating how many iterations a loop
7218 requires, in particular when determining whether a loop will be
7222 @item -Wstrict-overflow=1
7223 Warn about cases that are both questionable and easy to avoid. For
7224 example the compiler simplifies
7225 @code{x + 1 > x} to @code{1}. This level of
7226 @option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
7227 are not, and must be explicitly requested.
7229 @item -Wstrict-overflow=2
7230 Also warn about other cases where a comparison is simplified to a
7231 constant. For example: @code{abs (x) >= 0}. This can only be
7232 simplified when signed integer overflow is undefined, because
7233 @code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
7234 zero. @option{-Wstrict-overflow} (with no level) is the same as
7235 @option{-Wstrict-overflow=2}.
7237 @item -Wstrict-overflow=3
7238 Also warn about other cases where a comparison is simplified. For
7239 example: @code{x + 1 > 1} is simplified to @code{x > 0}.
7241 @item -Wstrict-overflow=4
7242 Also warn about other simplifications not covered by the above cases.
7243 For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
7245 @item -Wstrict-overflow=5
7246 Also warn about cases where the compiler reduces the magnitude of a
7247 constant involved in a comparison. For example: @code{x + 2 > y} is
7248 simplified to @code{x + 1 >= y}. This is reported only at the
7249 highest warning level because this simplification applies to many
7250 comparisons, so this warning level gives a very large number of
7254 @item -Wstring-compare
7255 @opindex Wstring-compare
7256 @opindex Wno-string-compare
7257 Warn for calls to @code{strcmp} and @code{strncmp} whose result is
7258 determined to be either zero or non-zero in tests for such equality
7259 owing to the length of one argument being greater than the size of
7260 the array the other argument is stored in (or the bound in the case
7261 of @code{strncmp}). Such calls could be mistakes. For example,
7262 the call to @code{strcmp} below is diagnosed because its result is
7263 necessarily non-zero irrespective of the contents of the array @code{a}.
7269 strcpy (d, "string");
7271 if (0 == strcmp (a, d)) // cannot be true
7272 puts ("a and d are the same");
7276 @option{-Wstring-compare} is enabled by @option{-Wextra}.
7278 @item -Wno-stringop-overflow
7279 @item -Wstringop-overflow
7280 @itemx -Wstringop-overflow=@var{type}
7281 @opindex Wstringop-overflow
7282 @opindex Wno-stringop-overflow
7283 Warn for calls to string manipulation functions such as @code{memcpy} and
7284 @code{strcpy} that are determined to overflow the destination buffer. The
7285 optional argument is one greater than the type of Object Size Checking to
7286 perform to determine the size of the destination. @xref{Object Size Checking}.
7287 The argument is meaningful only for functions that operate on character arrays
7288 but not for raw memory functions like @code{memcpy} which always make use
7289 of Object Size type-0. The option also warns for calls that specify a size
7290 in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
7291 The option produces the best results with optimization enabled but can detect
7292 a small subset of simple buffer overflows even without optimization in
7293 calls to the GCC built-in functions like @code{__builtin_memcpy} that
7294 correspond to the standard functions. In any case, the option warns about
7295 just a subset of buffer overflows detected by the corresponding overflow
7296 checking built-ins. For example, the option issues a warning for
7297 the @code{strcpy} call below because it copies at least 5 characters
7298 (the string @code{"blue"} including the terminating NUL) into the buffer
7302 enum Color @{ blue, purple, yellow @};
7303 const char* f (enum Color clr)
7305 static char buf [4];
7309 case blue: str = "blue"; break;
7310 case purple: str = "purple"; break;
7311 case yellow: str = "yellow"; break;
7314 return strcpy (buf, str); // warning here
7318 Option @option{-Wstringop-overflow=2} is enabled by default.
7321 @item -Wstringop-overflow
7322 @itemx -Wstringop-overflow=1
7323 @opindex Wstringop-overflow
7324 @opindex Wno-stringop-overflow
7325 The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
7326 to determine the sizes of destination objects. At this setting the option
7327 does not warn for writes past the end of subobjects of larger objects accessed
7328 by pointers unless the size of the largest surrounding object is known. When
7329 the destination may be one of several objects it is assumed to be the largest
7330 one of them. On Linux systems, when optimization is enabled at this setting
7331 the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
7332 is defined to a non-zero value.
7334 @item -Wstringop-overflow=2
7335 The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
7336 to determine the sizes of destination objects. At this setting the option
7337 warns about overflows when writing to members of the largest complete
7338 objects whose exact size is known. However, it does not warn for excessive
7339 writes to the same members of unknown objects referenced by pointers since
7340 they may point to arrays containing unknown numbers of elements. This is
7341 the default setting of the option.
7343 @item -Wstringop-overflow=3
7344 The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
7345 to determine the sizes of destination objects. At this setting the option
7346 warns about overflowing the smallest object or data member. This is the
7347 most restrictive setting of the option that may result in warnings for safe
7350 @item -Wstringop-overflow=4
7351 The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
7352 to determine the sizes of destination objects. At this setting the option
7353 warns about overflowing any data members, and when the destination is
7354 one of several objects it uses the size of the largest of them to decide
7355 whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
7356 setting of the option may result in warnings for benign code.
7359 @item -Wno-stringop-overread
7360 @opindex Wstringop-overread
7361 @opindex Wno-stringop-overread
7362 Warn for calls to string manipulation functions such as @code{memchr}, or
7363 @code{strcpy} that are determined to read past the end of the source
7366 Option @option{-Wstringop-overread} is enabled by default.
7368 @item -Wno-stringop-truncation
7369 @opindex Wstringop-truncation
7370 @opindex Wno-stringop-truncation
7371 Do not warn for calls to bounded string manipulation functions
7372 such as @code{strncat},
7373 @code{strncpy}, and @code{stpncpy} that may either truncate the copied string
7374 or leave the destination unchanged.
7376 In the following example, the call to @code{strncat} specifies a bound that
7377 is less than the length of the source string. As a result, the copy of
7378 the source will be truncated and so the call is diagnosed. To avoid the
7379 warning use @code{bufsize - strlen (buf) - 1)} as the bound.
7382 void append (char *buf, size_t bufsize)
7384 strncat (buf, ".txt", 3);
7388 As another example, the following call to @code{strncpy} results in copying
7389 to @code{d} just the characters preceding the terminating NUL, without
7390 appending the NUL to the end. Assuming the result of @code{strncpy} is
7391 necessarily a NUL-terminated string is a common mistake, and so the call
7392 is diagnosed. To avoid the warning when the result is not expected to be
7393 NUL-terminated, call @code{memcpy} instead.
7396 void copy (char *d, const char *s)
7398 strncpy (d, s, strlen (s));
7402 In the following example, the call to @code{strncpy} specifies the size
7403 of the destination buffer as the bound. If the length of the source
7404 string is equal to or greater than this size the result of the copy will
7405 not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
7406 the warning, specify @code{sizeof buf - 1} as the bound and set the last
7407 element of the buffer to @code{NUL}.
7410 void copy (const char *s)
7413 strncpy (buf, s, sizeof buf);
7418 In situations where a character array is intended to store a sequence
7419 of bytes with no terminating @code{NUL} such an array may be annotated
7420 with attribute @code{nonstring} to avoid this warning. Such arrays,
7421 however, are not suitable arguments to functions that expect
7422 @code{NUL}-terminated strings. To help detect accidental misuses of
7423 such arrays GCC issues warnings unless it can prove that the use is
7424 safe. @xref{Common Variable Attributes}.
7426 @item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}
7427 @opindex Wsuggest-attribute=
7428 @opindex Wno-suggest-attribute=
7429 Warn for cases where adding an attribute may be beneficial. The
7430 attributes currently supported are listed below.
7433 @item -Wsuggest-attribute=pure
7434 @itemx -Wsuggest-attribute=const
7435 @itemx -Wsuggest-attribute=noreturn
7436 @itemx -Wmissing-noreturn
7437 @itemx -Wsuggest-attribute=malloc
7438 @opindex Wsuggest-attribute=pure
7439 @opindex Wno-suggest-attribute=pure
7440 @opindex Wsuggest-attribute=const
7441 @opindex Wno-suggest-attribute=const
7442 @opindex Wsuggest-attribute=noreturn
7443 @opindex Wno-suggest-attribute=noreturn
7444 @opindex Wmissing-noreturn
7445 @opindex Wno-missing-noreturn
7446 @opindex Wsuggest-attribute=malloc
7447 @opindex Wno-suggest-attribute=malloc
7449 Warn about functions that might be candidates for attributes
7450 @code{pure}, @code{const} or @code{noreturn} or @code{malloc}. The compiler
7451 only warns for functions visible in other compilation units or (in the case of
7452 @code{pure} and @code{const}) if it cannot prove that the function returns
7453 normally. A function returns normally if it doesn't contain an infinite loop or
7454 return abnormally by throwing, calling @code{abort} or trapping. This analysis
7455 requires option @option{-fipa-pure-const}, which is enabled by default at
7456 @option{-O} and higher. Higher optimization levels improve the accuracy
7459 @item -Wsuggest-attribute=format
7460 @itemx -Wmissing-format-attribute
7461 @opindex Wsuggest-attribute=format
7462 @opindex Wmissing-format-attribute
7463 @opindex Wno-suggest-attribute=format
7464 @opindex Wno-missing-format-attribute
7468 Warn about function pointers that might be candidates for @code{format}
7469 attributes. Note these are only possible candidates, not absolute ones.
7470 GCC guesses that function pointers with @code{format} attributes that
7471 are used in assignment, initialization, parameter passing or return
7472 statements should have a corresponding @code{format} attribute in the
7473 resulting type. I.e.@: the left-hand side of the assignment or
7474 initialization, the type of the parameter variable, or the return type
7475 of the containing function respectively should also have a @code{format}
7476 attribute to avoid the warning.
7478 GCC also warns about function definitions that might be
7479 candidates for @code{format} attributes. Again, these are only
7480 possible candidates. GCC guesses that @code{format} attributes
7481 might be appropriate for any function that calls a function like
7482 @code{vprintf} or @code{vscanf}, but this might not always be the
7483 case, and some functions for which @code{format} attributes are
7484 appropriate may not be detected.
7486 @item -Wsuggest-attribute=cold
7487 @opindex Wsuggest-attribute=cold
7488 @opindex Wno-suggest-attribute=cold
7490 Warn about functions that might be candidates for @code{cold} attribute. This
7491 is based on static detection and generally only warns about functions which
7492 always leads to a call to another @code{cold} function such as wrappers of
7493 C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
7497 @opindex Wno-alloc-zero
7498 @opindex Walloc-zero
7499 Warn about calls to allocation functions decorated with attribute
7500 @code{alloc_size} that specify zero bytes, including those to the built-in
7501 forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
7502 @code{malloc}, and @code{realloc}. Because the behavior of these functions
7503 when called with a zero size differs among implementations (and in the case
7504 of @code{realloc} has been deprecated) relying on it may result in subtle
7505 portability bugs and should be avoided.
7507 @item -Walloc-size-larger-than=@var{byte-size}
7508 @opindex Walloc-size-larger-than=
7509 @opindex Wno-alloc-size-larger-than
7510 Warn about calls to functions decorated with attribute @code{alloc_size}
7511 that attempt to allocate objects larger than the specified number of bytes,
7512 or where the result of the size computation in an integer type with infinite
7513 precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
7514 @option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
7515 Warnings controlled by the option can be disabled either by specifying
7516 @var{byte-size} of @samp{SIZE_MAX} or more or by
7517 @option{-Wno-alloc-size-larger-than}.
7518 @xref{Function Attributes}.
7520 @item -Wno-alloc-size-larger-than
7521 @opindex Wno-alloc-size-larger-than
7522 Disable @option{-Walloc-size-larger-than=} warnings. The option is
7523 equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
7529 This option warns on all uses of @code{alloca} in the source.
7531 @item -Walloca-larger-than=@var{byte-size}
7532 @opindex Walloca-larger-than=
7533 @opindex Wno-alloca-larger-than
7534 This option warns on calls to @code{alloca} with an integer argument whose
7535 value is either zero, or that is not bounded by a controlling predicate
7536 that limits its value to at most @var{byte-size}. It also warns for calls
7537 to @code{alloca} where the bound value is unknown. Arguments of non-integer
7538 types are considered unbounded even if they appear to be constrained to
7541 For example, a bounded case of @code{alloca} could be:
7544 void func (size_t n)
7555 In the above example, passing @code{-Walloca-larger-than=1000} would not
7556 issue a warning because the call to @code{alloca} is known to be at most
7557 1000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
7558 the compiler would emit a warning.
7560 Unbounded uses, on the other hand, are uses of @code{alloca} with no
7561 controlling predicate constraining its integer argument. For example:
7566 void *p = alloca (n);
7571 If @code{-Walloca-larger-than=500} were passed, the above would trigger
7572 a warning, but this time because of the lack of bounds checking.
7574 Note, that even seemingly correct code involving signed integers could
7578 void func (signed int n)
7588 In the above example, @var{n} could be negative, causing a larger than
7589 expected argument to be implicitly cast into the @code{alloca} call.
7591 This option also warns when @code{alloca} is used in a loop.
7593 @option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
7594 but is usually only effective when @option{-ftree-vrp} is active (default
7595 for @option{-O2} and above).
7597 See also @option{-Wvla-larger-than=}@samp{byte-size}.
7599 @item -Wno-alloca-larger-than
7600 @opindex Wno-alloca-larger-than
7601 Disable @option{-Walloca-larger-than=} warnings. The option is
7602 equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
7604 @item -Warith-conversion
7605 @opindex Warith-conversion
7606 @opindex Wno-arith-conversion
7607 Do warn about implicit conversions from arithmetic operations even
7608 when conversion of the operands to the same type cannot change their
7609 values. This affects warnings from @option{-Wconversion},
7610 @option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
7614 void f (char c, int i)
7616 c = c + i; // warns with @option{-Wconversion}
7617 c = c + 1; // only warns with @option{-Warith-conversion}
7622 @item -Warray-bounds
7623 @itemx -Warray-bounds=@var{n}
7624 @opindex Wno-array-bounds
7625 @opindex Warray-bounds
7626 This option is only active when @option{-ftree-vrp} is active
7627 (default for @option{-O2} and above). It warns about subscripts to arrays
7628 that are always out of bounds. This warning is enabled by @option{-Wall}.
7631 @item -Warray-bounds=1
7632 This is the warning level of @option{-Warray-bounds} and is enabled
7633 by @option{-Wall}; higher levels are not, and must be explicitly requested.
7635 @item -Warray-bounds=2
7636 This warning level also warns about out of bounds access for
7637 arrays at the end of a struct and for arrays accessed through
7638 pointers. This warning level may give a larger number of
7639 false positives and is deactivated by default.
7642 @item -Warray-compare
7643 @opindex Warray-compare
7644 @opindex Wno-array-compare
7645 Warn about equality and relational comparisons between two operands of array
7646 type. This comparison was deprecated in C++20. For example:
7651 bool same = arr1 == arr2;
7654 @option{-Warray-compare} is enabled by @option{-Wall}.
7656 @item -Warray-parameter
7657 @itemx -Warray-parameter=@var{n}
7658 @opindex Wno-array-parameter
7659 Warn about redeclarations of functions involving arguments of array or
7660 pointer types of inconsistent kinds or forms, and enable the detection
7661 of out-of-bounds accesses to such parameters by warnings such as
7662 @option{-Warray-bounds}.
7664 If the first function declaration uses the array form the bound specified
7665 in the array is assumed to be the minimum number of elements expected to
7666 be provided in calls to the function and the maximum number of elements
7667 accessed by it. Failing to provide arguments of sufficient size or accessing
7668 more than the maximum number of elements may be diagnosed by warnings such
7669 as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies
7670 involving array parameters declared using the @code{T[static N]} form.
7672 For example, the warning triggers for the following redeclarations because
7673 the first one allows an array of any size to be passed to @code{f} while
7674 the second one with the keyword @code{static} specifies that the array
7675 argument must have at least four elements.
7678 void f (int[static 4]);
7679 void f (int[]); // warning (inconsistent array form)
7683 int *p = (int *)malloc (4);
7684 f (p); // warning (array too small)
7689 At level 2 the warning also triggers for redeclarations involving any other
7690 inconsistency in array or pointer argument forms denoting array sizes.
7691 Pointers and arrays of unspecified bound are considered equivalent and do
7692 not trigger a warning.
7696 void g (int[]); // no warning
7697 void g (int[8]); // warning (inconsistent array bound)
7700 @option{-Warray-parameter=2} is included in @option{-Wall}. The
7701 @option{-Wvla-parameter} option triggers warnings for similar inconsistencies
7702 involving Variable Length Array arguments.
7704 @item -Wattribute-alias=@var{n}
7705 @itemx -Wno-attribute-alias
7706 @opindex Wattribute-alias
7707 @opindex Wno-attribute-alias
7708 Warn about declarations using the @code{alias} and similar attributes whose
7709 target is incompatible with the type of the alias.
7710 @xref{Function Attributes,,Declaring Attributes of Functions}.
7713 @item -Wattribute-alias=1
7714 The default warning level of the @option{-Wattribute-alias} option diagnoses
7715 incompatibilities between the type of the alias declaration and that of its
7716 target. Such incompatibilities are typically indicative of bugs.
7718 @item -Wattribute-alias=2
7720 At this level @option{-Wattribute-alias} also diagnoses cases where
7721 the attributes of the alias declaration are more restrictive than the
7722 attributes applied to its target. These mismatches can potentially
7723 result in incorrect code generation. In other cases they may be
7724 benign and could be resolved simply by adding the missing attribute to
7725 the target. For comparison, see the @option{-Wmissing-attributes}
7726 option, which controls diagnostics when the alias declaration is less
7727 restrictive than the target, rather than more restrictive.
7729 Attributes considered include @code{alloc_align}, @code{alloc_size},
7730 @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
7731 @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
7732 @code{returns_nonnull}, and @code{returns_twice}.
7735 @option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
7736 This is the default. You can disable these warnings with either
7737 @option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
7739 @item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{]}
7740 @opindex Wbidi-chars=
7741 @opindex Wbidi-chars
7742 @opindex Wno-bidi-chars
7743 Warn about possibly misleading UTF-8 bidirectional control characters in
7744 comments, string literals, character constants, and identifiers. Such
7745 characters can change left-to-right writing direction into right-to-left
7746 (and vice versa), which can cause confusion between the logical order and
7747 visual order. This may be dangerous; for instance, it may seem that a piece
7748 of code is not commented out, whereas it in fact is.
7750 There are three levels of warning supported by GCC@. The default is
7751 @option{-Wbidi-chars=unpaired}, which warns about improperly terminated
7752 bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
7753 @option{-Wbidi-chars=any} warns about any use of bidirectional control
7756 @item -Wbool-compare
7757 @opindex Wno-bool-compare
7758 @opindex Wbool-compare
7759 Warn about boolean expression compared with an integer value different from
7760 @code{true}/@code{false}. For instance, the following comparison is
7765 if ((n > 1) == 2) @{ @dots{} @}
7767 This warning is enabled by @option{-Wall}.
7769 @item -Wbool-operation
7770 @opindex Wno-bool-operation
7771 @opindex Wbool-operation
7772 Warn about suspicious operations on expressions of a boolean type. For
7773 instance, bitwise negation of a boolean is very likely a bug in the program.
7774 For C, this warning also warns about incrementing or decrementing a boolean,
7775 which rarely makes sense. (In C++, decrementing a boolean is always invalid.
7776 Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
7778 This warning is enabled by @option{-Wall}.
7780 @item -Wduplicated-branches
7781 @opindex Wno-duplicated-branches
7782 @opindex Wduplicated-branches
7783 Warn when an if-else has identical branches. This warning detects cases like
7790 It doesn't warn when both branches contain just a null statement. This warning
7791 also warn for conditional operators:
7793 int i = x ? *p : *p;
7796 @item -Wduplicated-cond
7797 @opindex Wno-duplicated-cond
7798 @opindex Wduplicated-cond
7799 Warn about duplicated conditions in an if-else-if chain. For instance,
7800 warn for the following code:
7802 if (p->q != NULL) @{ @dots{} @}
7803 else if (p->q != NULL) @{ @dots{} @}
7806 @item -Wframe-address
7807 @opindex Wno-frame-address
7808 @opindex Wframe-address
7809 Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
7810 is called with an argument greater than 0. Such calls may return indeterminate
7811 values or crash the program. The warning is included in @option{-Wall}.
7813 @item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
7814 @opindex Wno-discarded-qualifiers
7815 @opindex Wdiscarded-qualifiers
7816 Do not warn if type qualifiers on pointers are being discarded.
7817 Typically, the compiler warns if a @code{const char *} variable is
7818 passed to a function that takes a @code{char *} parameter. This option
7819 can be used to suppress such a warning.
7821 @item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
7822 @opindex Wno-discarded-array-qualifiers
7823 @opindex Wdiscarded-array-qualifiers
7824 Do not warn if type qualifiers on arrays which are pointer targets
7825 are being discarded. Typically, the compiler warns if a
7826 @code{const int (*)[]} variable is passed to a function that
7827 takes a @code{int (*)[]} parameter. This option can be used to
7828 suppress such a warning.
7830 @item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
7831 @opindex Wno-incompatible-pointer-types
7832 @opindex Wincompatible-pointer-types
7833 Do not warn when there is a conversion between pointers that have incompatible
7834 types. This warning is for cases not covered by @option{-Wno-pointer-sign},
7835 which warns for pointer argument passing or assignment with different
7838 @item -Wno-int-conversion @r{(C and Objective-C only)}
7839 @opindex Wno-int-conversion
7840 @opindex Wint-conversion
7841 Do not warn about incompatible integer to pointer and pointer to integer
7842 conversions. This warning is about implicit conversions; for explicit
7843 conversions the warnings @option{-Wno-int-to-pointer-cast} and
7844 @option{-Wno-pointer-to-int-cast} may be used.
7846 @item -Wzero-length-bounds
7847 @opindex Wzero-length-bounds
7848 @opindex Wzero-length-bounds
7849 Warn about accesses to elements of zero-length array members that might
7850 overlap other members of the same object. Declaring interior zero-length
7851 arrays is discouraged because accesses to them are undefined. See
7854 For example, the first two stores in function @code{bad} are diagnosed
7855 because the array elements overlap the subsequent members @code{b} and
7856 @code{c}. The third store is diagnosed by @option{-Warray-bounds}
7857 because it is beyond the bounds of the enclosing object.
7860 struct X @{ int a[0]; int b, c; @};
7865 x.a[0] = 0; // -Wzero-length-bounds
7866 x.a[1] = 1; // -Wzero-length-bounds
7867 x.a[2] = 2; // -Warray-bounds
7871 Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
7873 @item -Wno-div-by-zero
7874 @opindex Wno-div-by-zero
7875 @opindex Wdiv-by-zero
7876 Do not warn about compile-time integer division by zero. Floating-point
7877 division by zero is not warned about, as it can be a legitimate way of
7878 obtaining infinities and NaNs.
7880 @item -Wsystem-headers
7881 @opindex Wsystem-headers
7882 @opindex Wno-system-headers
7883 @cindex warnings from system headers
7884 @cindex system headers, warnings from
7885 Print warning messages for constructs found in system header files.
7886 Warnings from system headers are normally suppressed, on the assumption
7887 that they usually do not indicate real problems and would only make the
7888 compiler output harder to read. Using this command-line option tells
7889 GCC to emit warnings from system headers as if they occurred in user
7890 code. However, note that using @option{-Wall} in conjunction with this
7891 option does @emph{not} warn about unknown pragmas in system
7892 headers---for that, @option{-Wunknown-pragmas} must also be used.
7894 @item -Wtautological-compare
7895 @opindex Wtautological-compare
7896 @opindex Wno-tautological-compare
7897 Warn if a self-comparison always evaluates to true or false. This
7898 warning detects various mistakes such as:
7902 if (i > i) @{ @dots{} @}
7905 This warning also warns about bitwise comparisons that always evaluate
7906 to true or false, for instance:
7908 if ((a & 16) == 10) @{ @dots{} @}
7910 will always be false.
7912 This warning is enabled by @option{-Wall}.
7915 @opindex Wtrampolines
7916 @opindex Wno-trampolines
7917 Warn about trampolines generated for pointers to nested functions.
7918 A trampoline is a small piece of data or code that is created at run
7919 time on the stack when the address of a nested function is taken, and is
7920 used to call the nested function indirectly. For some targets, it is
7921 made up of data only and thus requires no special treatment. But, for
7922 most targets, it is made up of code and thus requires the stack to be
7923 made executable in order for the program to work properly.
7926 @opindex Wfloat-equal
7927 @opindex Wno-float-equal
7928 Warn if floating-point values are used in equality comparisons.
7930 The idea behind this is that sometimes it is convenient (for the
7931 programmer) to consider floating-point values as approximations to
7932 infinitely precise real numbers. If you are doing this, then you need
7933 to compute (by analyzing the code, or in some other way) the maximum or
7934 likely maximum error that the computation introduces, and allow for it
7935 when performing comparisons (and when producing output, but that's a
7936 different problem). In particular, instead of testing for equality, you
7937 should check to see whether the two values have ranges that overlap; and
7938 this is done with the relational operators, so equality comparisons are
7941 @item -Wtraditional @r{(C and Objective-C only)}
7942 @opindex Wtraditional
7943 @opindex Wno-traditional
7944 Warn about certain constructs that behave differently in traditional and
7945 ISO C@. Also warn about ISO C constructs that have no traditional C
7946 equivalent, and/or problematic constructs that should be avoided.
7950 Macro parameters that appear within string literals in the macro body.
7951 In traditional C macro replacement takes place within string literals,
7952 but in ISO C it does not.
7955 In traditional C, some preprocessor directives did not exist.
7956 Traditional preprocessors only considered a line to be a directive
7957 if the @samp{#} appeared in column 1 on the line. Therefore
7958 @option{-Wtraditional} warns about directives that traditional C
7959 understands but ignores because the @samp{#} does not appear as the
7960 first character on the line. It also suggests you hide directives like
7961 @code{#pragma} not understood by traditional C by indenting them. Some
7962 traditional implementations do not recognize @code{#elif}, so this option
7963 suggests avoiding it altogether.
7966 A function-like macro that appears without arguments.
7969 The unary plus operator.
7972 The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
7973 constant suffixes. (Traditional C does support the @samp{L} suffix on integer
7974 constants.) Note, these suffixes appear in macros defined in the system
7975 headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
7976 Use of these macros in user code might normally lead to spurious
7977 warnings, however GCC's integrated preprocessor has enough context to
7978 avoid warning in these cases.
7981 A function declared external in one block and then used after the end of
7985 A @code{switch} statement has an operand of type @code{long}.
7988 A non-@code{static} function declaration follows a @code{static} one.
7989 This construct is not accepted by some traditional C compilers.
7992 The ISO type of an integer constant has a different width or
7993 signedness from its traditional type. This warning is only issued if
7994 the base of the constant is ten. I.e.@: hexadecimal or octal values, which
7995 typically represent bit patterns, are not warned about.
7998 Usage of ISO string concatenation is detected.
8001 Initialization of automatic aggregates.
8004 Identifier conflicts with labels. Traditional C lacks a separate
8005 namespace for labels.
8008 Initialization of unions. If the initializer is zero, the warning is
8009 omitted. This is done under the assumption that the zero initializer in
8010 user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
8011 initializer warnings and relies on default initialization to zero in the
8015 Conversions by prototypes between fixed/floating-point values and vice
8016 versa. The absence of these prototypes when compiling with traditional
8017 C causes serious problems. This is a subset of the possible
8018 conversion warnings; for the full set use @option{-Wtraditional-conversion}.
8021 Use of ISO C style function definitions. This warning intentionally is
8022 @emph{not} issued for prototype declarations or variadic functions
8023 because these ISO C features appear in your code when using
8024 libiberty's traditional C compatibility macros, @code{PARAMS} and
8025 @code{VPARAMS}. This warning is also bypassed for nested functions
8026 because that feature is already a GCC extension and thus not relevant to
8027 traditional C compatibility.
8030 @item -Wtraditional-conversion @r{(C and Objective-C only)}
8031 @opindex Wtraditional-conversion
8032 @opindex Wno-traditional-conversion
8033 Warn if a prototype causes a type conversion that is different from what
8034 would happen to the same argument in the absence of a prototype. This
8035 includes conversions of fixed point to floating and vice versa, and
8036 conversions changing the width or signedness of a fixed-point argument
8037 except when the same as the default promotion.
8039 @item -Wdeclaration-after-statement @r{(C and Objective-C only)}
8040 @opindex Wdeclaration-after-statement
8041 @opindex Wno-declaration-after-statement
8042 Warn when a declaration is found after a statement in a block. This
8043 construct, known from C++, was introduced with ISO C99 and is by default
8044 allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
8049 Warn whenever a local variable or type declaration shadows another
8050 variable, parameter, type, class member (in C++), or instance variable
8051 (in Objective-C) or whenever a built-in function is shadowed. Note
8052 that in C++, the compiler warns if a local variable shadows an
8053 explicit typedef, but not if it shadows a struct/class/enum.
8054 If this warning is enabled, it includes also all instances of
8055 local shadowing. This means that @option{-Wno-shadow=local}
8056 and @option{-Wno-shadow=compatible-local} are ignored when
8057 @option{-Wshadow} is used.
8058 Same as @option{-Wshadow=global}.
8060 @item -Wno-shadow-ivar @r{(Objective-C only)}
8061 @opindex Wno-shadow-ivar
8062 @opindex Wshadow-ivar
8063 Do not warn whenever a local variable shadows an instance variable in an
8066 @item -Wshadow=global
8067 @opindex Wshadow=global
8068 Warn for any shadowing.
8069 Same as @option{-Wshadow}.
8071 @item -Wshadow=local
8072 @opindex Wshadow=local
8073 Warn when a local variable shadows another local variable or parameter.
8075 @item -Wshadow=compatible-local
8076 @opindex Wshadow=compatible-local
8077 Warn when a local variable shadows another local variable or parameter
8078 whose type is compatible with that of the shadowing variable. In C++,
8079 type compatibility here means the type of the shadowing variable can be
8080 converted to that of the shadowed variable. The creation of this flag
8081 (in addition to @option{-Wshadow=local}) is based on the idea that when
8082 a local variable shadows another one of incompatible type, it is most
8083 likely intentional, not a bug or typo, as shown in the following example:
8087 for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
8089 for (int i = 0; i < N; ++i)
8098 Since the two variable @code{i} in the example above have incompatible types,
8099 enabling only @option{-Wshadow=compatible-local} does not emit a warning.
8100 Because their types are incompatible, if a programmer accidentally uses one
8101 in place of the other, type checking is expected to catch that and emit an
8102 error or warning. Use of this flag instead of @option{-Wshadow=local} can
8103 possibly reduce the number of warnings triggered by intentional shadowing.
8104 Note that this also means that shadowing @code{const char *i} by
8105 @code{char *i} does not emit a warning.
8107 This warning is also enabled by @option{-Wshadow=local}.
8109 @item -Wlarger-than=@var{byte-size}
8110 @opindex Wlarger-than=
8111 @opindex Wlarger-than-@var{byte-size}
8112 Warn whenever an object is defined whose size exceeds @var{byte-size}.
8113 @option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8114 Warnings controlled by the option can be disabled either by specifying
8115 @var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
8117 Also warn for calls to bounded functions such as @code{memchr} or
8118 @code{strnlen} that specify a bound greater than the largest possible
8119 object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
8120 can only be disabled by @option{-Wno-larger-than}.
8122 @item -Wno-larger-than
8123 @opindex Wno-larger-than
8124 Disable @option{-Wlarger-than=} warnings. The option is equivalent
8125 to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
8127 @item -Wframe-larger-than=@var{byte-size}
8128 @opindex Wframe-larger-than=
8129 @opindex Wno-frame-larger-than
8130 Warn if the size of a function frame exceeds @var{byte-size}.
8131 The computation done to determine the stack frame size is approximate
8132 and not conservative.
8133 The actual requirements may be somewhat greater than @var{byte-size}
8134 even if you do not get a warning. In addition, any space allocated
8135 via @code{alloca}, variable-length arrays, or related constructs
8136 is not included by the compiler when determining
8137 whether or not to issue a warning.
8138 @option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8139 Warnings controlled by the option can be disabled either by specifying
8140 @var{byte-size} of @samp{SIZE_MAX} or more or by
8141 @option{-Wno-frame-larger-than}.
8143 @item -Wno-frame-larger-than
8144 @opindex Wno-frame-larger-than
8145 Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
8146 to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
8148 @item -Wfree-nonheap-object
8149 @opindex Wfree-nonheap-object
8150 @opindex Wno-free-nonheap-object
8151 Warn when attempting to deallocate an object that was either not allocated
8152 on the heap, or by using a pointer that was not returned from a prior call
8153 to the corresponding allocation function. For example, because the call
8154 to @code{stpcpy} returns a pointer to the terminating nul character and
8155 not to the begginning of the object, the call to @code{free} below is
8161 p = stpcpy (p, "abc");
8163 free (p); // warning
8167 @option{-Wfree-nonheap-object} is included in @option{-Wall}.
8169 @item -Wstack-usage=@var{byte-size}
8170 @opindex Wstack-usage
8171 @opindex Wno-stack-usage
8172 Warn if the stack usage of a function might exceed @var{byte-size}.
8173 The computation done to determine the stack usage is conservative.
8174 Any space allocated via @code{alloca}, variable-length arrays, or related
8175 constructs is included by the compiler when determining whether or not to
8178 The message is in keeping with the output of @option{-fstack-usage}.
8182 If the stack usage is fully static but exceeds the specified amount, it's:
8185 warning: stack usage is 1120 bytes
8188 If the stack usage is (partly) dynamic but bounded, it's:
8191 warning: stack usage might be 1648 bytes
8194 If the stack usage is (partly) dynamic and not bounded, it's:
8197 warning: stack usage might be unbounded
8201 @option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
8202 Warnings controlled by the option can be disabled either by specifying
8203 @var{byte-size} of @samp{SIZE_MAX} or more or by
8204 @option{-Wno-stack-usage}.
8206 @item -Wno-stack-usage
8207 @opindex Wno-stack-usage
8208 Disable @option{-Wstack-usage=} warnings. The option is equivalent
8209 to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
8211 @item -Wunsafe-loop-optimizations
8212 @opindex Wunsafe-loop-optimizations
8213 @opindex Wno-unsafe-loop-optimizations
8214 Warn if the loop cannot be optimized because the compiler cannot
8215 assume anything on the bounds of the loop indices. With
8216 @option{-funsafe-loop-optimizations} warn if the compiler makes
8219 @item -Wno-pedantic-ms-format @r{(MinGW targets only)}
8220 @opindex Wno-pedantic-ms-format
8221 @opindex Wpedantic-ms-format
8222 When used in combination with @option{-Wformat}
8223 and @option{-pedantic} without GNU extensions, this option
8224 disables the warnings about non-ISO @code{printf} / @code{scanf} format
8225 width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
8226 which depend on the MS runtime.
8228 @item -Wpointer-arith
8229 @opindex Wpointer-arith
8230 @opindex Wno-pointer-arith
8231 Warn about anything that depends on the ``size of'' a function type or
8232 of @code{void}. GNU C assigns these types a size of 1, for
8233 convenience in calculations with @code{void *} pointers and pointers
8234 to functions. In C++, warn also when an arithmetic operation involves
8235 @code{NULL}. This warning is also enabled by @option{-Wpedantic}.
8237 @item -Wno-pointer-compare
8238 @opindex Wpointer-compare
8239 @opindex Wno-pointer-compare
8240 Do not warn if a pointer is compared with a zero character constant.
8242 means that the pointer was meant to be dereferenced. For example:
8245 const char *p = foo ();
8250 Note that the code above is invalid in C++11.
8252 This warning is enabled by default.
8257 Warn about unsupported features in ThreadSanitizer.
8259 ThreadSanitizer does not support @code{std::atomic_thread_fence} and
8260 can report false positives.
8262 This warning is enabled by default.
8265 @opindex Wtype-limits
8266 @opindex Wno-type-limits
8267 Warn if a comparison is always true or always false due to the limited
8268 range of the data type, but do not warn for constant expressions. For
8269 example, warn if an unsigned variable is compared against zero with
8270 @code{<} or @code{>=}. This warning is also enabled by
8273 @item -Wabsolute-value @r{(C and Objective-C only)}
8274 @opindex Wabsolute-value
8275 @opindex Wno-absolute-value
8276 Warn for calls to standard functions that compute the absolute value
8277 of an argument when a more appropriate standard function is available.
8278 For example, calling @code{abs(3.14)} triggers the warning because the
8279 appropriate function to call to compute the absolute value of a double
8280 argument is @code{fabs}. The option also triggers warnings when the
8281 argument in a call to such a function has an unsigned type. This
8282 warning can be suppressed with an explicit type cast and it is also
8283 enabled by @option{-Wextra}.
8285 @include cppwarnopts.texi
8287 @item -Wbad-function-cast @r{(C and Objective-C only)}
8288 @opindex Wbad-function-cast
8289 @opindex Wno-bad-function-cast
8290 Warn when a function call is cast to a non-matching type.
8291 For example, warn if a call to a function returning an integer type
8292 is cast to a pointer type.
8294 @item -Wc90-c99-compat @r{(C and Objective-C only)}
8295 @opindex Wc90-c99-compat
8296 @opindex Wno-c90-c99-compat
8297 Warn about features not present in ISO C90, but present in ISO C99.
8298 For instance, warn about use of variable length arrays, @code{long long}
8299 type, @code{bool} type, compound literals, designated initializers, and so
8300 on. This option is independent of the standards mode. Warnings are disabled
8301 in the expression that follows @code{__extension__}.
8303 @item -Wc99-c11-compat @r{(C and Objective-C only)}
8304 @opindex Wc99-c11-compat
8305 @opindex Wno-c99-c11-compat
8306 Warn about features not present in ISO C99, but present in ISO C11.
8307 For instance, warn about use of anonymous structures and unions,
8308 @code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
8309 @code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
8310 and so on. This option is independent of the standards mode. Warnings are
8311 disabled in the expression that follows @code{__extension__}.
8313 @item -Wc11-c2x-compat @r{(C and Objective-C only)}
8314 @opindex Wc11-c2x-compat
8315 @opindex Wno-c11-c2x-compat
8316 Warn about features not present in ISO C11, but present in ISO C2X.
8317 For instance, warn about omitting the string in @code{_Static_assert},
8318 use of @samp{[[]]} syntax for attributes, use of decimal
8319 floating-point types, and so on. This option is independent of the
8320 standards mode. Warnings are disabled in the expression that follows
8321 @code{__extension__}.
8323 @item -Wc++-compat @r{(C and Objective-C only)}
8324 @opindex Wc++-compat
8325 @opindex Wno-c++-compat
8326 Warn about ISO C constructs that are outside of the common subset of
8327 ISO C and ISO C++, e.g.@: request for implicit conversion from
8328 @code{void *} to a pointer to non-@code{void} type.
8330 @item -Wc++11-compat @r{(C++ and Objective-C++ only)}
8331 @opindex Wc++11-compat
8332 @opindex Wno-c++11-compat
8333 Warn about C++ constructs whose meaning differs between ISO C++ 1998
8334 and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
8335 in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
8336 enabled by @option{-Wall}.
8338 @item -Wc++14-compat @r{(C++ and Objective-C++ only)}
8339 @opindex Wc++14-compat
8340 @opindex Wno-c++14-compat
8341 Warn about C++ constructs whose meaning differs between ISO C++ 2011
8342 and ISO C++ 2014. This warning is enabled by @option{-Wall}.
8344 @item -Wc++17-compat @r{(C++ and Objective-C++ only)}
8345 @opindex Wc++17-compat
8346 @opindex Wno-c++17-compat
8347 Warn about C++ constructs whose meaning differs between ISO C++ 2014
8348 and ISO C++ 2017. This warning is enabled by @option{-Wall}.
8350 @item -Wc++20-compat @r{(C++ and Objective-C++ only)}
8351 @opindex Wc++20-compat
8352 @opindex Wno-c++20-compat
8353 Warn about C++ constructs whose meaning differs between ISO C++ 2017
8354 and ISO C++ 2020. This warning is enabled by @option{-Wall}.
8356 @item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
8357 @opindex Wc++11-extensions
8358 @opindex Wno-c++11-extensions
8359 Do not warn about C++11 constructs in code being compiled using
8360 an older C++ standard. Even without this option, some C++11 constructs
8361 will only be diagnosed if @option{-Wpedantic} is used.
8363 @item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
8364 @opindex Wc++14-extensions
8365 @opindex Wno-c++14-extensions
8366 Do not warn about C++14 constructs in code being compiled using
8367 an older C++ standard. Even without this option, some C++14 constructs
8368 will only be diagnosed if @option{-Wpedantic} is used.
8370 @item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
8371 @opindex Wc++17-extensions
8372 @opindex Wno-c++17-extensions
8373 Do not warn about C++17 constructs in code being compiled using
8374 an older C++ standard. Even without this option, some C++17 constructs
8375 will only be diagnosed if @option{-Wpedantic} is used.
8377 @item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
8378 @opindex Wc++20-extensions
8379 @opindex Wno-c++20-extensions
8380 Do not warn about C++20 constructs in code being compiled using
8381 an older C++ standard. Even without this option, some C++20 constructs
8382 will only be diagnosed if @option{-Wpedantic} is used.
8384 @item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
8385 @opindex Wc++23-extensions
8386 @opindex Wno-c++23-extensions
8387 Do not warn about C++23 constructs in code being compiled using
8388 an older C++ standard. Even without this option, some C++23 constructs
8389 will only be diagnosed if @option{-Wpedantic} is used.
8393 @opindex Wno-cast-qual
8394 Warn whenever a pointer is cast so as to remove a type qualifier from
8395 the target type. For example, warn if a @code{const char *} is cast
8396 to an ordinary @code{char *}.
8398 Also warn when making a cast that introduces a type qualifier in an
8399 unsafe way. For example, casting @code{char **} to @code{const char **}
8400 is unsafe, as in this example:
8403 /* p is char ** value. */
8404 const char **q = (const char **) p;
8405 /* Assignment of readonly string to const char * is OK. */
8407 /* Now char** pointer points to read-only memory. */
8412 @opindex Wcast-align
8413 @opindex Wno-cast-align
8414 Warn whenever a pointer is cast such that the required alignment of the
8415 target is increased. For example, warn if a @code{char *} is cast to
8416 an @code{int *} on machines where integers can only be accessed at
8417 two- or four-byte boundaries.
8419 @item -Wcast-align=strict
8420 @opindex Wcast-align=strict
8421 Warn whenever a pointer is cast such that the required alignment of the
8422 target is increased. For example, warn if a @code{char *} is cast to
8423 an @code{int *} regardless of the target machine.
8425 @item -Wcast-function-type
8426 @opindex Wcast-function-type
8427 @opindex Wno-cast-function-type
8428 Warn when a function pointer is cast to an incompatible function pointer.
8429 In a cast involving function types with a variable argument list only
8430 the types of initial arguments that are provided are considered.
8431 Any parameter of pointer-type matches any other pointer-type. Any benign
8432 differences in integral types are ignored, like @code{int} vs.@: @code{long}
8433 on ILP32 targets. Likewise type qualifiers are ignored. The function
8434 type @code{void (*) (void)} is special and matches everything, which can
8435 be used to suppress this warning.
8436 In a cast involving pointer to member types this warning warns whenever
8437 the type cast is changing the pointer to member type.
8438 This warning is enabled by @option{-Wextra}.
8440 @item -Wwrite-strings
8441 @opindex Wwrite-strings
8442 @opindex Wno-write-strings
8443 When compiling C, give string constants the type @code{const
8444 char[@var{length}]} so that copying the address of one into a
8445 non-@code{const} @code{char *} pointer produces a warning. These
8446 warnings help you find at compile time code that can try to write
8447 into a string constant, but only if you have been very careful about
8448 using @code{const} in declarations and prototypes. Otherwise, it is
8449 just a nuisance. This is why we did not make @option{-Wall} request
8452 When compiling C++, warn about the deprecated conversion from string
8453 literals to @code{char *}. This warning is enabled by default for C++
8458 @opindex Wno-clobbered
8459 Warn for variables that might be changed by @code{longjmp} or
8460 @code{vfork}. This warning is also enabled by @option{-Wextra}.
8463 @opindex Wconversion
8464 @opindex Wno-conversion
8465 Warn for implicit conversions that may alter a value. This includes
8466 conversions between real and integer, like @code{abs (x)} when
8467 @code{x} is @code{double}; conversions between signed and unsigned,
8468 like @code{unsigned ui = -1}; and conversions to smaller types, like
8469 @code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
8470 ((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
8471 changed by the conversion like in @code{abs (2.0)}. Warnings about
8472 conversions between signed and unsigned integers can be disabled by
8473 using @option{-Wno-sign-conversion}.
8475 For C++, also warn for confusing overload resolution for user-defined
8476 conversions; and conversions that never use a type conversion
8477 operator: conversions to @code{void}, the same type, a base class or a
8478 reference to them. Warnings about conversions between signed and
8479 unsigned integers are disabled by default in C++ unless
8480 @option{-Wsign-conversion} is explicitly enabled.
8482 Warnings about conversion from arithmetic on a small type back to that
8483 type are only given with @option{-Warith-conversion}.
8485 @item -Wdangling-else
8486 @opindex Wdangling-else
8487 @opindex Wno-dangling-else
8488 Warn about constructions where there may be confusion to which
8489 @code{if} statement an @code{else} branch belongs. Here is an example of
8504 In C/C++, every @code{else} branch belongs to the innermost possible
8505 @code{if} statement, which in this example is @code{if (b)}. This is
8506 often not what the programmer expected, as illustrated in the above
8507 example by indentation the programmer chose. When there is the
8508 potential for this confusion, GCC issues a warning when this flag
8509 is specified. To eliminate the warning, add explicit braces around
8510 the innermost @code{if} statement so there is no way the @code{else}
8511 can belong to the enclosing @code{if}. The resulting code
8528 This warning is enabled by @option{-Wparentheses}.
8532 @opindex Wno-date-time
8533 Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
8534 are encountered as they might prevent bit-wise-identical reproducible
8538 @opindex Wempty-body
8539 @opindex Wno-empty-body
8540 Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
8541 while} statement. This warning is also enabled by @option{-Wextra}.
8543 @item -Wno-endif-labels
8544 @opindex Wendif-labels
8545 @opindex Wno-endif-labels
8546 Do not warn about stray tokens after @code{#else} and @code{#endif}.
8548 @item -Wenum-compare
8549 @opindex Wenum-compare
8550 @opindex Wno-enum-compare
8551 Warn about a comparison between values of different enumerated types.
8552 In C++ enumerated type mismatches in conditional expressions are also
8553 diagnosed and the warning is enabled by default. In C this warning is
8554 enabled by @option{-Wall}.
8556 @item -Wenum-conversion
8557 @opindex Wenum-conversion
8558 @opindex Wno-enum-conversion
8559 Warn when a value of enumerated type is implicitly converted to a
8560 different enumerated type. This warning is enabled by @option{-Wextra}
8563 @item -Wjump-misses-init @r{(C, Objective-C only)}
8564 @opindex Wjump-misses-init
8565 @opindex Wno-jump-misses-init
8566 Warn if a @code{goto} statement or a @code{switch} statement jumps
8567 forward across the initialization of a variable, or jumps backward to a
8568 label after the variable has been initialized. This only warns about
8569 variables that are initialized when they are declared. This warning is
8570 only supported for C and Objective-C; in C++ this sort of branch is an
8573 @option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
8574 can be disabled with the @option{-Wno-jump-misses-init} option.
8576 @item -Wsign-compare
8577 @opindex Wsign-compare
8578 @opindex Wno-sign-compare
8579 @cindex warning for comparison of signed and unsigned values
8580 @cindex comparison of signed and unsigned values, warning
8581 @cindex signed and unsigned values, comparison warning
8582 Warn when a comparison between signed and unsigned values could produce
8583 an incorrect result when the signed value is converted to unsigned.
8584 In C++, this warning is also enabled by @option{-Wall}. In C, it is
8585 also enabled by @option{-Wextra}.
8587 @item -Wsign-conversion
8588 @opindex Wsign-conversion
8589 @opindex Wno-sign-conversion
8590 Warn for implicit conversions that may change the sign of an integer
8591 value, like assigning a signed integer expression to an unsigned
8592 integer variable. An explicit cast silences the warning. In C, this
8593 option is enabled also by @option{-Wconversion}.
8595 @item -Wfloat-conversion
8596 @opindex Wfloat-conversion
8597 @opindex Wno-float-conversion
8598 Warn for implicit conversions that reduce the precision of a real value.
8599 This includes conversions from real to integer, and from higher precision
8600 real to lower precision real values. This option is also enabled by
8601 @option{-Wconversion}.
8603 @item -Wno-scalar-storage-order
8604 @opindex Wno-scalar-storage-order
8605 @opindex Wscalar-storage-order
8606 Do not warn on suspicious constructs involving reverse scalar storage order.
8608 @item -Wsizeof-array-div
8609 @opindex Wsizeof-array-div
8610 @opindex Wno-sizeof-array-div
8611 Warn about divisions of two sizeof operators when the first one is applied
8612 to an array and the divisor does not equal the size of the array element.
8613 In such a case, the computation will not yield the number of elements in the
8614 array, which is likely what the user intended. This warning warns e.g. about
8619 return sizeof (arr) / sizeof (short);
8623 This warning is enabled by @option{-Wall}.
8625 @item -Wsizeof-pointer-div
8626 @opindex Wsizeof-pointer-div
8627 @opindex Wno-sizeof-pointer-div
8628 Warn for suspicious divisions of two sizeof expressions that divide
8629 the pointer size by the element size, which is the usual way to compute
8630 the array size but won't work out correctly with pointers. This warning
8631 warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
8632 not an array, but a pointer. This warning is enabled by @option{-Wall}.
8634 @item -Wsizeof-pointer-memaccess
8635 @opindex Wsizeof-pointer-memaccess
8636 @opindex Wno-sizeof-pointer-memaccess
8637 Warn for suspicious length parameters to certain string and memory built-in
8638 functions if the argument uses @code{sizeof}. This warning triggers for
8639 example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
8640 an array, but a pointer, and suggests a possible fix, or about
8641 @code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
8642 also warns about calls to bounded string copy functions like @code{strncat}
8643 or @code{strncpy} that specify as the bound a @code{sizeof} expression of
8644 the source array. For example, in the following function the call to
8645 @code{strncat} specifies the size of the source string as the bound. That
8646 is almost certainly a mistake and so the call is diagnosed.
8648 void make_file (const char *name)
8650 char path[PATH_MAX];
8651 strncpy (path, name, sizeof path - 1);
8652 strncat (path, ".text", sizeof ".text");
8657 The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
8659 @item -Wno-sizeof-array-argument
8660 @opindex Wsizeof-array-argument
8661 @opindex Wno-sizeof-array-argument
8662 Do not warn when the @code{sizeof} operator is applied to a parameter that is
8663 declared as an array in a function definition. This warning is enabled by
8664 default for C and C++ programs.
8666 @item -Wmemset-elt-size
8667 @opindex Wmemset-elt-size
8668 @opindex Wno-memset-elt-size
8669 Warn for suspicious calls to the @code{memset} built-in function, if the
8670 first argument references an array, and the third argument is a number
8671 equal to the number of elements, but not equal to the size of the array
8672 in memory. This indicates that the user has omitted a multiplication by
8673 the element size. This warning is enabled by @option{-Wall}.
8675 @item -Wmemset-transposed-args
8676 @opindex Wmemset-transposed-args
8677 @opindex Wno-memset-transposed-args
8678 Warn for suspicious calls to the @code{memset} built-in function where
8679 the second argument is not zero and the third argument is zero. For
8680 example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
8681 @code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
8682 is only emitted if the third argument is a literal zero. Otherwise, if
8683 it is an expression that is folded to zero, or a cast of zero to some
8684 type, it is far less likely that the arguments have been mistakenly
8685 transposed and no warning is emitted. This warning is enabled
8690 @opindex Wno-address
8691 Warn about suspicious uses of address expressions. These include comparing
8692 the address of a function or a declared object to the null pointer constant
8698 if (!func) // warning: expression evaluates to false
8702 comparisons of a pointer to a string literal, such as in
8704 void f (const char *x)
8706 if (x == "abc") // warning: expression evaluates to false
8710 and tests of the results of pointer addition or subtraction for equality
8713 void f (const int *p, int i)
8715 return p + i == NULL;
8718 Such uses typically indicate a programmer error: the address of most
8719 functions and objects necessarily evaluates to true (the exception are
8720 weak symbols), so their use in a conditional might indicate missing
8721 parentheses in a function call or a missing dereference in an array
8722 expression. The subset of the warning for object pointers can be
8723 suppressed by casting the pointer operand to an integer type such
8724 as @code{inptr_t} or @code{uinptr_t}.
8725 Comparisons against string literals result in unspecified behavior
8726 and are not portable, and suggest the intent was to call @code{strcmp}.
8727 The warning is suppressed if the suspicious expression is the result
8729 @option{-Waddress} warning is enabled by @option{-Wall}.
8731 @item -Wno-address-of-packed-member
8732 @opindex Waddress-of-packed-member
8733 @opindex Wno-address-of-packed-member
8734 Do not warn when the address of packed member of struct or union is taken,
8735 which usually results in an unaligned pointer value. This is
8739 @opindex Wlogical-op
8740 @opindex Wno-logical-op
8741 Warn about suspicious uses of logical operators in expressions.
8742 This includes using logical operators in contexts where a
8743 bit-wise operator is likely to be expected. Also warns when
8744 the operands of a logical operator are the same:
8747 if (a < 0 && a < 0) @{ @dots{} @}
8750 @item -Wlogical-not-parentheses
8751 @opindex Wlogical-not-parentheses
8752 @opindex Wno-logical-not-parentheses
8753 Warn about logical not used on the left hand side operand of a comparison.
8754 This option does not warn if the right operand is considered to be a boolean
8755 expression. Its purpose is to detect suspicious code like the following:
8759 if (!a > 1) @{ @dots{} @}
8762 It is possible to suppress the warning by wrapping the LHS into
8765 if ((!a) > 1) @{ @dots{} @}
8768 This warning is enabled by @option{-Wall}.
8770 @item -Waggregate-return
8771 @opindex Waggregate-return
8772 @opindex Wno-aggregate-return
8773 Warn if any functions that return structures or unions are defined or
8774 called. (In languages where you can return an array, this also elicits
8777 @item -Wno-aggressive-loop-optimizations
8778 @opindex Wno-aggressive-loop-optimizations
8779 @opindex Waggressive-loop-optimizations
8780 Warn if in a loop with constant number of iterations the compiler detects
8781 undefined behavior in some statement during one or more of the iterations.
8783 @item -Wno-attributes
8784 @opindex Wno-attributes
8785 @opindex Wattributes
8786 Do not warn if an unexpected @code{__attribute__} is used, such as
8787 unrecognized attributes, function attributes applied to variables,
8788 etc. This does not stop errors for incorrect use of supported
8791 Additionally, using @option{-Wno-attributes=}, it is possible to suppress
8792 warnings about unknown scoped attributes (in C++11 and C2X). For example,
8793 @option{-Wno-attributes=vendor::attr} disables warning about the following
8797 [[vendor::attr]] void f();
8800 It is also possible to disable warning about all attributes in a namespace
8801 using @option{-Wno-attributes=vendor::} which prevents warning about both
8802 of these declarations:
8805 [[vendor::safe]] void f();
8806 [[vendor::unsafe]] void f2();
8809 Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
8811 @item -Wno-builtin-declaration-mismatch
8812 @opindex Wno-builtin-declaration-mismatch
8813 @opindex Wbuiltin-declaration-mismatch
8814 Warn if a built-in function is declared with an incompatible signature
8815 or as a non-function, or when a built-in function declared with a type
8816 that does not include a prototype is called with arguments whose promoted
8817 types do not match those expected by the function. When @option{-Wextra}
8818 is specified, also warn when a built-in function that takes arguments is
8819 declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
8820 warning is enabled by default. To avoid the warning include the appropriate
8821 header to bring the prototypes of built-in functions into scope.
8823 For example, the call to @code{memset} below is diagnosed by the warning
8824 because the function expects a value of type @code{size_t} as its argument
8825 but the type of @code{32} is @code{int}. With @option{-Wextra},
8826 the declaration of the function is diagnosed as well.
8828 extern void* memset ();
8831 memset (d, '\0', 32);
8835 @item -Wno-builtin-macro-redefined
8836 @opindex Wno-builtin-macro-redefined
8837 @opindex Wbuiltin-macro-redefined
8838 Do not warn if certain built-in macros are redefined. This suppresses
8839 warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
8840 @code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
8842 @item -Wstrict-prototypes @r{(C and Objective-C only)}
8843 @opindex Wstrict-prototypes
8844 @opindex Wno-strict-prototypes
8845 Warn if a function is declared or defined without specifying the
8846 argument types. (An old-style function definition is permitted without
8847 a warning if preceded by a declaration that specifies the argument
8850 @item -Wold-style-declaration @r{(C and Objective-C only)}
8851 @opindex Wold-style-declaration
8852 @opindex Wno-old-style-declaration
8853 Warn for obsolescent usages, according to the C Standard, in a
8854 declaration. For example, warn if storage-class specifiers like
8855 @code{static} are not the first things in a declaration. This warning
8856 is also enabled by @option{-Wextra}.
8858 @item -Wold-style-definition @r{(C and Objective-C only)}
8859 @opindex Wold-style-definition
8860 @opindex Wno-old-style-definition
8861 Warn if an old-style function definition is used. A warning is given
8862 even if there is a previous prototype. A definition using @samp{()}
8863 is not considered an old-style definition in C2X mode, because it is
8864 equivalent to @samp{(void)} in that case, but is considered an
8865 old-style definition for older standards.
8867 @item -Wmissing-parameter-type @r{(C and Objective-C only)}
8868 @opindex Wmissing-parameter-type
8869 @opindex Wno-missing-parameter-type
8870 A function parameter is declared without a type specifier in K&R-style
8877 This warning is also enabled by @option{-Wextra}.
8879 @item -Wmissing-prototypes @r{(C and Objective-C only)}
8880 @opindex Wmissing-prototypes
8881 @opindex Wno-missing-prototypes
8882 Warn if a global function is defined without a previous prototype
8883 declaration. This warning is issued even if the definition itself
8884 provides a prototype. Use this option to detect global functions
8885 that do not have a matching prototype declaration in a header file.
8886 This option is not valid for C++ because all function declarations
8887 provide prototypes and a non-matching declaration declares an
8888 overload rather than conflict with an earlier declaration.
8889 Use @option{-Wmissing-declarations} to detect missing declarations in C++.
8891 @item -Wmissing-declarations
8892 @opindex Wmissing-declarations
8893 @opindex Wno-missing-declarations
8894 Warn if a global function is defined without a previous declaration.
8895 Do so even if the definition itself provides a prototype.
8896 Use this option to detect global functions that are not declared in
8897 header files. In C, no warnings are issued for functions with previous
8898 non-prototype declarations; use @option{-Wmissing-prototypes} to detect
8899 missing prototypes. In C++, no warnings are issued for function templates,
8900 or for inline functions, or for functions in anonymous namespaces.
8902 @item -Wmissing-field-initializers
8903 @opindex Wmissing-field-initializers
8904 @opindex Wno-missing-field-initializers
8908 Warn if a structure's initializer has some fields missing. For
8909 example, the following code causes such a warning, because
8910 @code{x.h} is implicitly zero:
8913 struct s @{ int f, g, h; @};
8914 struct s x = @{ 3, 4 @};
8917 This option does not warn about designated initializers, so the following
8918 modification does not trigger a warning:
8921 struct s @{ int f, g, h; @};
8922 struct s x = @{ .f = 3, .g = 4 @};
8925 In C this option does not warn about the universal zero initializer
8929 struct s @{ int f, g, h; @};
8930 struct s x = @{ 0 @};
8933 Likewise, in C++ this option does not warn about the empty @{ @}
8934 initializer, for example:
8937 struct s @{ int f, g, h; @};
8941 This warning is included in @option{-Wextra}. To get other @option{-Wextra}
8942 warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
8944 @item -Wno-missing-requires
8945 @opindex Wmissing-requires
8946 @opindex Wno-missing-requires
8948 By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
8951 bool satisfied = requires @{ C<T> @};
8954 Here @samp{satisfied} will be true if @samp{C<T>} is a valid
8955 expression, which it is for all T. Presumably the user meant to write
8958 bool satisfied = requires @{ requires C<T> @};
8961 so @samp{satisfied} is only true if concept @samp{C} is satisfied for
8964 This warning can be disabled with @option{-Wno-missing-requires}.
8966 @item -Wno-multichar
8967 @opindex Wno-multichar
8969 Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
8970 Usually they indicate a typo in the user's code, as they have
8971 implementation-defined values, and should not be used in portable code.
8973 @item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
8974 @opindex Wnormalized=
8975 @opindex Wnormalized
8976 @opindex Wno-normalized
8979 @cindex character set, input normalization
8980 In ISO C and ISO C++, two identifiers are different if they are
8981 different sequences of characters. However, sometimes when characters
8982 outside the basic ASCII character set are used, you can have two
8983 different character sequences that look the same. To avoid confusion,
8984 the ISO 10646 standard sets out some @dfn{normalization rules} which
8985 when applied ensure that two sequences that look the same are turned into
8986 the same sequence. GCC can warn you if you are using identifiers that
8987 have not been normalized; this option controls that warning.
8989 There are four levels of warning supported by GCC@. The default is
8990 @option{-Wnormalized=nfc}, which warns about any identifier that is
8991 not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
8992 recommended form for most uses. It is equivalent to
8993 @option{-Wnormalized}.
8995 Unfortunately, there are some characters allowed in identifiers by
8996 ISO C and ISO C++ that, when turned into NFC, are not allowed in
8997 identifiers. That is, there's no way to use these symbols in portable
8998 ISO C or C++ and have all your identifiers in NFC@.
8999 @option{-Wnormalized=id} suppresses the warning for these characters.
9000 It is hoped that future versions of the standards involved will correct
9001 this, which is why this option is not the default.
9003 You can switch the warning off for all characters by writing
9004 @option{-Wnormalized=none} or @option{-Wno-normalized}. You should
9005 only do this if you are using some other normalization scheme (like
9006 ``D''), because otherwise you can easily create bugs that are
9007 literally impossible to see.
9009 Some characters in ISO 10646 have distinct meanings but look identical
9010 in some fonts or display methodologies, especially once formatting has
9011 been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
9012 LETTER N'', displays just like a regular @code{n} that has been
9013 placed in a superscript. ISO 10646 defines the @dfn{NFKC}
9014 normalization scheme to convert all these into a standard form as
9015 well, and GCC warns if your code is not in NFKC if you use
9016 @option{-Wnormalized=nfkc}. This warning is comparable to warning
9017 about every identifier that contains the letter O because it might be
9018 confused with the digit 0, and so is not the default, but may be
9019 useful as a local coding convention if the programming environment
9020 cannot be fixed to display these characters distinctly.
9022 @item -Wno-attribute-warning
9023 @opindex Wno-attribute-warning
9024 @opindex Wattribute-warning
9025 Do not warn about usage of functions (@pxref{Function Attributes})
9026 declared with @code{warning} attribute. By default, this warning is
9027 enabled. @option{-Wno-attribute-warning} can be used to disable the
9028 warning or @option{-Wno-error=attribute-warning} can be used to
9029 disable the error when compiled with @option{-Werror} flag.
9031 @item -Wno-deprecated
9032 @opindex Wno-deprecated
9033 @opindex Wdeprecated
9034 Do not warn about usage of deprecated features. @xref{Deprecated Features}.
9036 @item -Wno-deprecated-declarations
9037 @opindex Wno-deprecated-declarations
9038 @opindex Wdeprecated-declarations
9039 Do not warn about uses of functions (@pxref{Function Attributes}),
9040 variables (@pxref{Variable Attributes}), and types (@pxref{Type
9041 Attributes}) marked as deprecated by using the @code{deprecated}
9045 @opindex Wno-overflow
9047 Do not warn about compile-time overflow in constant expressions.
9052 Warn about One Definition Rule violations during link-time optimization.
9055 @item -Wopenacc-parallelism
9056 @opindex Wopenacc-parallelism
9057 @opindex Wno-openacc-parallelism
9058 @cindex OpenACC accelerator programming
9059 Warn about potentially suboptimal choices related to OpenACC parallelism.
9062 @opindex Wopenmp-simd
9063 @opindex Wno-openmp-simd
9064 Warn if the vectorizer cost model overrides the OpenMP
9065 simd directive set by user. The @option{-fsimd-cost-model=unlimited}
9066 option can be used to relax the cost model.
9068 @item -Woverride-init @r{(C and Objective-C only)}
9069 @opindex Woverride-init
9070 @opindex Wno-override-init
9074 Warn if an initialized field without side effects is overridden when
9075 using designated initializers (@pxref{Designated Inits, , Designated
9078 This warning is included in @option{-Wextra}. To get other
9079 @option{-Wextra} warnings without this one, use @option{-Wextra
9080 -Wno-override-init}.
9082 @item -Wno-override-init-side-effects @r{(C and Objective-C only)}
9083 @opindex Woverride-init-side-effects
9084 @opindex Wno-override-init-side-effects
9085 Do not warn if an initialized field with side effects is overridden when
9086 using designated initializers (@pxref{Designated Inits, , Designated
9087 Initializers}). This warning is enabled by default.
9092 Warn if a structure is given the packed attribute, but the packed
9093 attribute has no effect on the layout or size of the structure.
9094 Such structures may be mis-aligned for little benefit. For
9095 instance, in this code, the variable @code{f.x} in @code{struct bar}
9096 is misaligned even though @code{struct bar} does not itself
9097 have the packed attribute:
9104 @} __attribute__((packed));
9112 @item -Wnopacked-bitfield-compat
9113 @opindex Wpacked-bitfield-compat
9114 @opindex Wno-packed-bitfield-compat
9115 The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
9116 on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
9117 the change can lead to differences in the structure layout. GCC
9118 informs you when the offset of such a field has changed in GCC 4.4.
9119 For example there is no longer a 4-bit padding between field @code{a}
9120 and @code{b} in this structure:
9127 @} __attribute__ ((packed));
9130 This warning is enabled by default. Use
9131 @option{-Wno-packed-bitfield-compat} to disable this warning.
9133 @item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
9134 @opindex Wpacked-not-aligned
9135 @opindex Wno-packed-not-aligned
9136 Warn if a structure field with explicitly specified alignment in a
9137 packed struct or union is misaligned. For example, a warning will
9138 be issued on @code{struct S}, like, @code{warning: alignment 1 of
9139 'struct S' is less than 8}, in this code:
9143 struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
9144 struct __attribute__ ((packed)) S @{
9150 This warning is enabled by @option{-Wall}.
9155 Warn if padding is included in a structure, either to align an element
9156 of the structure or to align the whole structure. Sometimes when this
9157 happens it is possible to rearrange the fields of the structure to
9158 reduce the padding and so make the structure smaller.
9160 @item -Wredundant-decls
9161 @opindex Wredundant-decls
9162 @opindex Wno-redundant-decls
9163 Warn if anything is declared more than once in the same scope, even in
9164 cases where multiple declaration is valid and changes nothing.
9168 @opindex Wno-restrict
9169 Warn when an object referenced by a @code{restrict}-qualified parameter
9170 (or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
9171 argument, or when copies between such objects overlap. For example,
9172 the call to the @code{strcpy} function below attempts to truncate the string
9173 by replacing its initial characters with the last four. However, because
9174 the call writes the terminating NUL into @code{a[4]}, the copies overlap and
9175 the call is diagnosed.
9180 char a[] = "abcd1234";
9185 The @option{-Wrestrict} option detects some instances of simple overlap
9186 even without optimization but works best at @option{-O2} and above. It
9187 is included in @option{-Wall}.
9189 @item -Wnested-externs @r{(C and Objective-C only)}
9190 @opindex Wnested-externs
9191 @opindex Wno-nested-externs
9192 Warn if an @code{extern} declaration is encountered within a function.
9197 Warn if a function that is declared as inline cannot be inlined.
9198 Even with this option, the compiler does not warn about failures to
9199 inline functions declared in system headers.
9201 The compiler uses a variety of heuristics to determine whether or not
9202 to inline a function. For example, the compiler takes into account
9203 the size of the function being inlined and the amount of inlining
9204 that has already been done in the current function. Therefore,
9205 seemingly insignificant changes in the source program can cause the
9206 warnings produced by @option{-Winline} to appear or disappear.
9208 @item -Winterference-size
9209 @opindex Winterference-size
9210 Warn about use of C++17 @code{std::hardware_destructive_interference_size}
9211 without specifying its value with @option{--param destructive-interference-size}.
9212 Also warn about questionable values for that option.
9214 This variable is intended to be used for controlling class layout, to
9215 avoid false sharing in concurrent code:
9218 struct independent_fields @{
9219 alignas(std::hardware_destructive_interference_size) std::atomic<int> one;
9220 alignas(std::hardware_destructive_interference_size) std::atomic<int> two;
9224 Here @samp{one} and @samp{two} are intended to be far enough apart
9225 that stores to one won't require accesses to the other to reload the
9228 By default, @option{--param destructive-interference-size} and
9229 @option{--param constructive-interference-size} are set based on the
9230 current @option{-mtune} option, typically to the L1 cache line size
9231 for the particular target CPU, sometimes to a range if tuning for a
9232 generic target. So all translation units that depend on ABI
9233 compatibility for the use of these variables must be compiled with
9234 the same @option{-mtune} (or @option{-mcpu}).
9236 If ABI stability is important, such as if the use is in a header for a
9237 library, you should probably not use the hardware interference size
9238 variables at all. Alternatively, you can force a particular value
9239 with @option{--param}.
9241 If you are confident that your use of the variable does not affect ABI
9242 outside a single build of your project, you can turn off the warning
9243 with @option{-Wno-interference-size}.
9245 @item -Wint-in-bool-context
9246 @opindex Wint-in-bool-context
9247 @opindex Wno-int-in-bool-context
9248 Warn for suspicious use of integer values where boolean values are expected,
9249 such as conditional expressions (?:) using non-boolean integer constants in
9250 boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
9251 integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
9252 for all kinds of multiplications regardless of the data type.
9253 This warning is enabled by @option{-Wall}.
9255 @item -Wno-int-to-pointer-cast
9256 @opindex Wno-int-to-pointer-cast
9257 @opindex Wint-to-pointer-cast
9258 Suppress warnings from casts to pointer type of an integer of a
9259 different size. In C++, casting to a pointer type of smaller size is
9260 an error. @option{Wint-to-pointer-cast} is enabled by default.
9263 @item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
9264 @opindex Wno-pointer-to-int-cast
9265 @opindex Wpointer-to-int-cast
9266 Suppress warnings from casts from a pointer to an integer type of a
9270 @opindex Winvalid-pch
9271 @opindex Wno-invalid-pch
9272 Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
9273 the search path but cannot be used.
9277 @opindex Wno-long-long
9278 Warn if @code{long long} type is used. This is enabled by either
9279 @option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
9280 modes. To inhibit the warning messages, use @option{-Wno-long-long}.
9282 @item -Wvariadic-macros
9283 @opindex Wvariadic-macros
9284 @opindex Wno-variadic-macros
9285 Warn if variadic macros are used in ISO C90 mode, or if the GNU
9286 alternate syntax is used in ISO C99 mode. This is enabled by either
9287 @option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
9288 messages, use @option{-Wno-variadic-macros}.
9292 @opindex Wno-varargs
9293 Do not warn upon questionable usage of the macros used to handle variable
9294 arguments like @code{va_start}. These warnings are enabled by default.
9296 @item -Wvector-operation-performance
9297 @opindex Wvector-operation-performance
9298 @opindex Wno-vector-operation-performance
9299 Warn if vector operation is not implemented via SIMD capabilities of the
9300 architecture. Mainly useful for the performance tuning.
9301 Vector operation can be implemented @code{piecewise}, which means that the
9302 scalar operation is performed on every vector element;
9303 @code{in parallel}, which means that the vector operation is implemented
9304 using scalars of wider type, which normally is more performance efficient;
9305 and @code{as a single scalar}, which means that vector fits into a
9311 Warn if a variable-length array is used in the code.
9312 @option{-Wno-vla} prevents the @option{-Wpedantic} warning of
9313 the variable-length array.
9315 @item -Wvla-larger-than=@var{byte-size}
9316 @opindex Wvla-larger-than=
9317 @opindex Wno-vla-larger-than
9318 If this option is used, the compiler warns for declarations of
9319 variable-length arrays whose size is either unbounded, or bounded
9320 by an argument that allows the array size to exceed @var{byte-size}
9321 bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
9322 works, but with variable-length arrays.
9324 Note that GCC may optimize small variable-length arrays of a known
9325 value into plain arrays, so this warning may not get triggered for
9328 @option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
9329 is typically only effective when @option{-ftree-vrp} is active (default
9330 for @option{-O2} and above).
9332 See also @option{-Walloca-larger-than=@var{byte-size}}.
9334 @item -Wno-vla-larger-than
9335 @opindex Wno-vla-larger-than
9336 Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
9337 to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
9339 @item -Wvla-parameter
9340 @opindex Wno-vla-parameter
9341 Warn about redeclarations of functions involving arguments of Variable
9342 Length Array types of inconsistent kinds or forms, and enable the detection
9343 of out-of-bounds accesses to such parameters by warnings such as
9344 @option{-Warray-bounds}.
9346 If the first function declaration uses the VLA form the bound specified
9347 in the array is assumed to be the minimum number of elements expected to
9348 be provided in calls to the function and the maximum number of elements
9349 accessed by it. Failing to provide arguments of sufficient size or
9350 accessing more than the maximum number of elements may be diagnosed.
9352 For example, the warning triggers for the following redeclarations because
9353 the first one allows an array of any size to be passed to @code{f} while
9354 the second one specifies that the array argument must have at least @code{n}
9355 elements. In addition, calling @code{f} with the assotiated VLA bound
9356 parameter in excess of the actual VLA bound triggers a warning as well.
9359 void f (int n, int[n]);
9360 void f (int, int[]); // warning: argument 2 previously declared as a VLA
9367 f (sizeof a, a); // warning: access to a by f may be out of bounds
9373 @option{-Wvla-parameter} is included in @option{-Wall}. The
9374 @option{-Warray-parameter} option triggers warnings for similar problems
9375 involving ordinary array arguments.
9377 @item -Wvolatile-register-var
9378 @opindex Wvolatile-register-var
9379 @opindex Wno-volatile-register-var
9380 Warn if a register variable is declared volatile. The volatile
9381 modifier does not inhibit all optimizations that may eliminate reads
9382 and/or writes to register variables. This warning is enabled by
9385 @item -Wdisabled-optimization
9386 @opindex Wdisabled-optimization
9387 @opindex Wno-disabled-optimization
9388 Warn if a requested optimization pass is disabled. This warning does
9389 not generally indicate that there is anything wrong with your code; it
9390 merely indicates that GCC's optimizers are unable to handle the code
9391 effectively. Often, the problem is that your code is too big or too
9392 complex; GCC refuses to optimize programs when the optimization
9393 itself is likely to take inordinate amounts of time.
9395 @item -Wpointer-sign @r{(C and Objective-C only)}
9396 @opindex Wpointer-sign
9397 @opindex Wno-pointer-sign
9398 Warn for pointer argument passing or assignment with different signedness.
9399 This option is only supported for C and Objective-C@. It is implied by
9400 @option{-Wall} and by @option{-Wpedantic}, which can be disabled with
9401 @option{-Wno-pointer-sign}.
9403 @item -Wstack-protector
9404 @opindex Wstack-protector
9405 @opindex Wno-stack-protector
9406 This option is only active when @option{-fstack-protector} is active. It
9407 warns about functions that are not protected against stack smashing.
9409 @item -Woverlength-strings
9410 @opindex Woverlength-strings
9411 @opindex Wno-overlength-strings
9412 Warn about string constants that are longer than the ``minimum
9413 maximum'' length specified in the C standard. Modern compilers
9414 generally allow string constants that are much longer than the
9415 standard's minimum limit, but very portable programs should avoid
9416 using longer strings.
9418 The limit applies @emph{after} string constant concatenation, and does
9419 not count the trailing NUL@. In C90, the limit was 509 characters; in
9420 C99, it was raised to 4095. C++98 does not specify a normative
9421 minimum maximum, so we do not diagnose overlength strings in C++@.
9423 This option is implied by @option{-Wpedantic}, and can be disabled with
9424 @option{-Wno-overlength-strings}.
9426 @item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
9427 @opindex Wunsuffixed-float-constants
9428 @opindex Wno-unsuffixed-float-constants
9430 Issue a warning for any floating constant that does not have
9431 a suffix. When used together with @option{-Wsystem-headers} it
9432 warns about such constants in system header files. This can be useful
9433 when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
9434 from the decimal floating-point extension to C99.
9436 @item -Wno-lto-type-mismatch
9437 @opindex Wlto-type-mismatch
9438 @opindex Wno-lto-type-mismatch
9440 During the link-time optimization, do not warn about type mismatches in
9441 global declarations from different compilation units.
9442 Requires @option{-flto} to be enabled. Enabled by default.
9444 @item -Wno-designated-init @r{(C and Objective-C only)}
9445 @opindex Wdesignated-init
9446 @opindex Wno-designated-init
9447 Suppress warnings when a positional initializer is used to initialize
9448 a structure that has been marked with the @code{designated_init}
9453 @node Static Analyzer Options
9454 @section Options That Control Static Analysis
9460 @opindex fno-analyzer
9461 This option enables an static analysis of program flow which looks
9462 for ``interesting'' interprocedural paths through the
9463 code, and issues warnings for problems found on them.
9465 This analysis is much more expensive than other GCC warnings.
9467 Enabling this option effectively enables the following warnings:
9470 -Wanalyzer-double-fclose @gol
9471 -Wanalyzer-double-free @gol
9472 -Wanalyzer-exposure-through-output-file @gol
9473 -Wanalyzer-file-leak @gol
9474 -Wanalyzer-free-of-non-heap @gol
9475 -Wanalyzer-malloc-leak @gol
9476 -Wanalyzer-mismatching-deallocation @gol
9477 -Wanalyzer-possible-null-argument @gol
9478 -Wanalyzer-possible-null-dereference @gol
9479 -Wanalyzer-null-argument @gol
9480 -Wanalyzer-null-dereference @gol
9481 -Wanalyzer-shift-count-negative @gol
9482 -Wanalyzer-shift-count-overflow @gol
9483 -Wanalyzer-stale-setjmp-buffer @gol
9484 -Wanalyzer-tainted-allocation-size @gol
9485 -Wanalyzer-tainted-array-index @gol
9486 -Wanalyzer-tainted-divisor @gol
9487 -Wanalyzer-tainted-offset @gol
9488 -Wanalyzer-tainted-size @gol
9489 -Wanalyzer-unsafe-call-within-signal-handler @gol
9490 -Wanalyzer-use-after-free @gol
9491 -Wanalyzer-use-of-uninitialized-value @gol
9492 -Wanalyzer-use-of-pointer-in-stale-stack-frame @gol
9493 -Wanalyzer-write-to-const @gol
9494 -Wanalyzer-write-to-string-literal @gol
9497 This option is only available if GCC was configured with analyzer
9500 @item -Wanalyzer-too-complex
9501 @opindex Wanalyzer-too-complex
9502 @opindex Wno-analyzer-too-complex
9503 If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
9504 to attempt to explore the control flow and data flow in the program,
9505 but these can be defeated by sufficiently complicated code.
9507 By default, the analysis silently stops if the code is too
9508 complicated for the analyzer to fully explore and it reaches an internal
9509 limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
9511 @item -Wno-analyzer-double-fclose
9512 @opindex Wanalyzer-double-fclose
9513 @opindex Wno-analyzer-double-fclose
9514 This warning requires @option{-fanalyzer}, which enables it; use
9515 @option{-Wno-analyzer-double-fclose} to disable it.
9517 This diagnostic warns for paths through the code in which a @code{FILE *}
9518 can have @code{fclose} called on it more than once.
9520 @item -Wno-analyzer-double-free
9521 @opindex Wanalyzer-double-free
9522 @opindex Wno-analyzer-double-free
9523 This warning requires @option{-fanalyzer}, which enables it; use
9524 @option{-Wno-analyzer-double-free} to disable it.
9526 This diagnostic warns for paths through the code in which a pointer
9527 can have a deallocator called on it more than once, either @code{free},
9528 or a deallocator referenced by attribute @code{malloc}.
9530 @item -Wno-analyzer-exposure-through-output-file
9531 @opindex Wanalyzer-exposure-through-output-file
9532 @opindex Wno-analyzer-exposure-through-output-file
9533 This warning requires @option{-fanalyzer}, which enables it; use
9534 @option{-Wno-analyzer-exposure-through-output-file}
9537 This diagnostic warns for paths through the code in which a
9538 security-sensitive value is written to an output file
9539 (such as writing a password to a log file).
9541 @item -Wno-analyzer-file-leak
9542 @opindex Wanalyzer-file-leak
9543 @opindex Wno-analyzer-file-leak
9544 This warning requires @option{-fanalyzer}, which enables it; use
9545 @option{-Wno-analyzer-file-leak}
9548 This diagnostic warns for paths through the code in which a
9549 @code{<stdio.h>} @code{FILE *} stream object is leaked.
9551 @item -Wno-analyzer-free-of-non-heap
9552 @opindex Wanalyzer-free-of-non-heap
9553 @opindex Wno-analyzer-free-of-non-heap
9554 This warning requires @option{-fanalyzer}, which enables it; use
9555 @option{-Wno-analyzer-free-of-non-heap}
9558 This diagnostic warns for paths through the code in which @code{free}
9559 is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
9561 @item -Wno-analyzer-malloc-leak
9562 @opindex Wanalyzer-malloc-leak
9563 @opindex Wno-analyzer-malloc-leak
9564 This warning requires @option{-fanalyzer}, which enables it; use
9565 @option{-Wno-analyzer-malloc-leak}
9568 This diagnostic warns for paths through the code in which a
9569 pointer allocated via an allocator is leaked: either @code{malloc},
9570 or a function marked with attribute @code{malloc}.
9572 @item -Wno-analyzer-mismatching-deallocation
9573 @opindex Wanalyzer-mismatching-deallocation
9574 @opindex Wno-analyzer-mismatching-deallocation
9575 This warning requires @option{-fanalyzer}, which enables it; use
9576 @option{-Wno-analyzer-mismatching-deallocation}
9579 This diagnostic warns for paths through the code in which the
9580 wrong deallocation function is called on a pointer value, based on
9581 which function was used to allocate the pointer value. The diagnostic
9582 will warn about mismatches between @code{free}, scalar @code{delete}
9583 and vector @code{delete[]}, and those marked as allocator/deallocator
9584 pairs using attribute @code{malloc}.
9586 @item -Wno-analyzer-possible-null-argument
9587 @opindex Wanalyzer-possible-null-argument
9588 @opindex Wno-analyzer-possible-null-argument
9589 This warning requires @option{-fanalyzer}, which enables it; use
9590 @option{-Wno-analyzer-possible-null-argument} to disable it.
9592 This diagnostic warns for paths through the code in which a
9593 possibly-NULL value is passed to a function argument marked
9594 with @code{__attribute__((nonnull))} as requiring a non-NULL
9597 @item -Wno-analyzer-possible-null-dereference
9598 @opindex Wanalyzer-possible-null-dereference
9599 @opindex Wno-analyzer-possible-null-dereference
9600 This warning requires @option{-fanalyzer}, which enables it; use
9601 @option{-Wno-analyzer-possible-null-dereference} to disable it.
9603 This diagnostic warns for paths through the code in which a
9604 possibly-NULL value is dereferenced.
9606 @item -Wno-analyzer-null-argument
9607 @opindex Wanalyzer-null-argument
9608 @opindex Wno-analyzer-null-argument
9609 This warning requires @option{-fanalyzer}, which enables it; use
9610 @option{-Wno-analyzer-null-argument} to disable it.
9612 This diagnostic warns for paths through the code in which a
9613 value known to be NULL is passed to a function argument marked
9614 with @code{__attribute__((nonnull))} as requiring a non-NULL
9617 @item -Wno-analyzer-null-dereference
9618 @opindex Wanalyzer-null-dereference
9619 @opindex Wno-analyzer-null-dereference
9620 This warning requires @option{-fanalyzer}, which enables it; use
9621 @option{-Wno-analyzer-null-dereference} to disable it.
9623 This diagnostic warns for paths through the code in which a
9624 value known to be NULL is dereferenced.
9626 @item -Wno-analyzer-shift-count-negative
9627 @opindex Wanalyzer-shift-count-negative
9628 @opindex Wno-analyzer-shift-count-negative
9629 This warning requires @option{-fanalyzer}, which enables it; use
9630 @option{-Wno-analyzer-shift-count-negative} to disable it.
9632 This diagnostic warns for paths through the code in which a
9633 shift is attempted with a negative count. It is analogous to
9634 the @option{-Wshift-count-negative} diagnostic implemented in
9635 the C/C++ front ends, but is implemented based on analyzing
9636 interprocedural paths, rather than merely parsing the syntax tree.
9637 However, the analyzer does not prioritize detection of such paths, so
9638 false negatives are more likely relative to other warnings.
9640 @item -Wno-analyzer-shift-count-overflow
9641 @opindex Wanalyzer-shift-count-overflow
9642 @opindex Wno-analyzer-shift-count-overflow
9643 This warning requires @option{-fanalyzer}, which enables it; use
9644 @option{-Wno-analyzer-shift-count-overflow} to disable it.
9646 This diagnostic warns for paths through the code in which a
9647 shift is attempted with a count greater than or equal to the
9648 precision of the operand's type. It is analogous to
9649 the @option{-Wshift-count-overflow} diagnostic implemented in
9650 the C/C++ front ends, but is implemented based on analyzing
9651 interprocedural paths, rather than merely parsing the syntax tree.
9652 However, the analyzer does not prioritize detection of such paths, so
9653 false negatives are more likely relative to other warnings.
9655 @item -Wno-analyzer-stale-setjmp-buffer
9656 @opindex Wanalyzer-stale-setjmp-buffer
9657 @opindex Wno-analyzer-stale-setjmp-buffer
9658 This warning requires @option{-fanalyzer}, which enables it; use
9659 @option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
9661 This diagnostic warns for paths through the code in which
9662 @code{longjmp} is called to rewind to a @code{jmp_buf} relating
9663 to a @code{setjmp} call in a function that has returned.
9665 When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
9666 location, it records the stack frame. The stack frame becomes invalid
9667 when the function containing the @code{setjmp} call returns. Attempting
9668 to rewind to it via @code{longjmp} would reference a stack frame that
9669 no longer exists, and likely lead to a crash (or worse).
9671 @item -Wno-analyzer-tainted-allocation-size
9672 @opindex Wanalyzer-tainted-allocation-size
9673 @opindex Wno-analyzer-tainted-allocation-size
9674 This warning requires both @option{-fanalyzer} and
9675 @option{-fanalyzer-checker=taint} to enable it;
9676 use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
9678 This diagnostic warns for paths through the code in which a value
9679 that could be under an attacker's control is used as the size
9680 of an allocation without being sanitized, so that an attacker could
9681 inject an excessively large allocation and potentially cause a denial
9684 See @url{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
9686 @item -Wno-analyzer-tainted-array-index
9687 @opindex Wanalyzer-tainted-array-index
9688 @opindex Wno-analyzer-tainted-array-index
9689 This warning requires both @option{-fanalyzer} and
9690 @option{-fanalyzer-checker=taint} to enable it;
9691 use @option{-Wno-analyzer-tainted-array-index} to disable it.
9693 This diagnostic warns for paths through the code in which a value
9694 that could be under an attacker's control is used as the index
9695 of an array access without being sanitized, so that an attacker
9696 could inject an out-of-bounds access.
9698 See @url{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
9700 @item -Wno-analyzer-tainted-divisor
9701 @opindex Wanalyzer-tainted-divisor
9702 @opindex Wno-analyzer-tainted-divisor
9703 This warning requires both @option{-fanalyzer} and
9704 @option{-fanalyzer-checker=taint} to enable it;
9705 use @option{-Wno-analyzer-tainted-divisor} to disable it.
9707 This diagnostic warns for paths through the code in which a value
9708 that could be under an attacker's control is used as the divisor
9709 in a division or modulus operation without being sanitized, so that
9710 an attacker could inject a division-by-zero.
9712 @item -Wno-analyzer-tainted-offset
9713 @opindex Wanalyzer-tainted-offset
9714 @opindex Wno-analyzer-tainted-offset
9715 This warning requires both @option{-fanalyzer} and
9716 @option{-fanalyzer-checker=taint} to enable it;
9717 use @option{-Wno-analyzer-tainted-offset} to disable it.
9719 This diagnostic warns for paths through the code in which a value
9720 that could be under an attacker's control is used as a pointer offset
9721 without being sanitized, so that an attacker could inject an out-of-bounds
9724 See @url{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
9726 @item -Wno-analyzer-tainted-size
9727 @opindex Wanalyzer-tainted-size
9728 @opindex Wno-analyzer-tainted-size
9729 This warning requires both @option{-fanalyzer} and
9730 @option{-fanalyzer-checker=taint} to enable it;
9731 use @option{-Wno-analyzer-tainted-size} to disable it.
9733 This diagnostic warns for paths through the code in which a value
9734 that could be under an attacker's control is used as the size of
9735 an operation such as @code{memset} without being sanitized, so that an
9736 attacker could inject an out-of-bounds access.
9738 @item -Wno-analyzer-unsafe-call-within-signal-handler
9739 @opindex Wanalyzer-unsafe-call-within-signal-handler
9740 @opindex Wno-analyzer-unsafe-call-within-signal-handler
9741 This warning requires @option{-fanalyzer}, which enables it; use
9742 @option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
9744 This diagnostic warns for paths through the code in which a
9745 function known to be async-signal-unsafe (such as @code{fprintf}) is
9746 called from a signal handler.
9748 @item -Wno-analyzer-use-after-free
9749 @opindex Wanalyzer-use-after-free
9750 @opindex Wno-analyzer-use-after-free
9751 This warning requires @option{-fanalyzer}, which enables it; use
9752 @option{-Wno-analyzer-use-after-free} to disable it.
9754 This diagnostic warns for paths through the code in which a
9755 pointer is used after a deallocator is called on it: either @code{free},
9756 or a deallocator referenced by attribute @code{malloc}.
9758 @item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
9759 @opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
9760 @opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
9761 This warning requires @option{-fanalyzer}, which enables it; use
9762 @option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
9765 This diagnostic warns for paths through the code in which a pointer
9766 is dereferenced that points to a variable in a stale stack frame.
9768 @item -Wno-analyzer-write-to-const
9769 @opindex Wanalyzer-write-to-const
9770 @opindex Wno-analyzer-write-to-const
9771 This warning requires @option{-fanalyzer}, which enables it; use
9772 @option{-Wno-analyzer-write-to-const}
9775 This diagnostic warns for paths through the code in which the analyzer
9776 detects an attempt to write through a pointer to a @code{const} object.
9777 However, the analyzer does not prioritize detection of such paths, so
9778 false negatives are more likely relative to other warnings.
9780 @item -Wno-analyzer-write-to-string-literal
9781 @opindex Wanalyzer-write-to-string-literal
9782 @opindex Wno-analyzer-write-to-string-literal
9783 This warning requires @option{-fanalyzer}, which enables it; use
9784 @option{-Wno-analyzer-write-to-string-literal}
9787 This diagnostic warns for paths through the code in which the analyzer
9788 detects an attempt to write through a pointer to a string literal.
9789 However, the analyzer does not prioritize detection of such paths, so
9790 false negatives are more likely relative to other warnings.
9792 @item -Wno-analyzer-use-of-uninitialized-value
9793 @opindex Wanalyzer-use-of-uninitialized-value
9794 @opindex Wno-analyzer-use-of-uninitialized-value
9795 This warning requires @option{-fanalyzer}, which enables it; use
9796 @option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
9798 This diagnostic warns for paths through the code in which an uninitialized
9803 Pertinent parameters for controlling the exploration are:
9804 @option{--param analyzer-bb-explosion-factor=@var{value}},
9805 @option{--param analyzer-max-enodes-per-program-point=@var{value}},
9806 @option{--param analyzer-max-recursion-depth=@var{value}}, and
9807 @option{--param analyzer-min-snodes-for-call-summary=@var{value}}.
9809 The following options control the analyzer.
9813 @item -fanalyzer-call-summaries
9814 @opindex fanalyzer-call-summaries
9815 @opindex fno-analyzer-call-summaries
9816 Simplify interprocedural analysis by computing the effect of certain calls,
9817 rather than exploring all paths through the function from callsite to each
9820 If enabled, call summaries are only used for functions with more than one
9821 call site, and that are sufficiently complicated (as per
9822 @option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
9824 @item -fanalyzer-checker=@var{name}
9825 @opindex fanalyzer-checker
9826 Restrict the analyzer to run just the named checker, and enable it.
9828 Some checkers are disabled by default (even with @option{-fanalyzer}),
9829 such as the @code{taint} checker that implements
9830 @option{-Wanalyzer-tainted-array-index}, and this option is required
9833 @item -fno-analyzer-feasibility
9834 @opindex fanalyzer-feasibility
9835 @opindex fno-analyzer-feasibility
9836 This option is intended for analyzer developers.
9838 By default the analyzer verifies that there is a feasible control flow path
9839 for each diagnostic it emits: that the conditions that hold are not mutually
9840 exclusive. Diagnostics for which no feasible path can be found are rejected.
9841 This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
9842 debugging issues in this code.
9844 @item -fanalyzer-fine-grained
9845 @opindex fanalyzer-fine-grained
9846 @opindex fno-analyzer-fine-grained
9847 This option is intended for analyzer developers.
9849 Internally the analyzer builds an ``exploded graph'' that combines
9850 control flow graphs with data flow information.
9852 By default, an edge in this graph can contain the effects of a run
9853 of multiple statements within a basic block. With
9854 @option{-fanalyzer-fine-grained}, each statement gets its own edge.
9856 @item -fanalyzer-show-duplicate-count
9857 @opindex fanalyzer-show-duplicate-count
9858 @opindex fno-analyzer-show-duplicate-count
9859 This option is intended for analyzer developers: if multiple diagnostics
9860 have been detected as being duplicates of each other, it emits a note when
9861 reporting the best diagnostic, giving the number of additional diagnostics
9862 that were suppressed by the deduplication logic.
9864 @item -fno-analyzer-state-merge
9865 @opindex fanalyzer-state-merge
9866 @opindex fno-analyzer-state-merge
9867 This option is intended for analyzer developers.
9869 By default the analyzer attempts to simplify analysis by merging
9870 sufficiently similar states at each program point as it builds its
9871 ``exploded graph''. With @option{-fno-analyzer-state-merge} this
9872 merging can be suppressed, for debugging state-handling issues.
9874 @item -fno-analyzer-state-purge
9875 @opindex fanalyzer-state-purge
9876 @opindex fno-analyzer-state-purge
9877 This option is intended for analyzer developers.
9879 By default the analyzer attempts to simplify analysis by purging
9880 aspects of state at a program point that appear to no longer be relevant
9881 e.g. the values of locals that aren't accessed later in the function
9882 and which aren't relevant to leak analysis.
9884 With @option{-fno-analyzer-state-purge} this purging of state can
9885 be suppressed, for debugging state-handling issues.
9887 @item -fanalyzer-transitivity
9888 @opindex fanalyzer-transitivity
9889 @opindex fno-analyzer-transitivity
9890 This option enables transitivity of constraints within the analyzer.
9892 @item -fanalyzer-verbose-edges
9893 This option is intended for analyzer developers. It enables more
9894 verbose, lower-level detail in the descriptions of control flow
9895 within diagnostic paths.
9897 @item -fanalyzer-verbose-state-changes
9898 This option is intended for analyzer developers. It enables more
9899 verbose, lower-level detail in the descriptions of events relating
9900 to state machines within diagnostic paths.
9902 @item -fanalyzer-verbosity=@var{level}
9903 This option controls the complexity of the control flow paths that are
9904 emitted for analyzer diagnostics.
9906 The @var{level} can be one of:
9910 At this level, interprocedural call and return events are displayed,
9911 along with the most pertinent state-change events relating to
9912 a diagnostic. For example, for a double-@code{free} diagnostic,
9913 both calls to @code{free} will be shown.
9916 As per the previous level, but also show events for the entry
9920 As per the previous level, but also show events relating to
9921 control flow that are significant to triggering the issue
9922 (e.g. ``true path taken'' at a conditional).
9924 This level is the default.
9927 As per the previous level, but show all control flow events, not
9928 just significant ones.
9931 This level is intended for analyzer developers; it adds various
9932 other events intended for debugging the analyzer.
9936 @item -fdump-analyzer
9937 @opindex fdump-analyzer
9938 Dump internal details about what the analyzer is doing to
9939 @file{@var{file}.analyzer.txt}.
9940 This option is overridden by @option{-fdump-analyzer-stderr}.
9942 @item -fdump-analyzer-stderr
9943 @opindex fdump-analyzer-stderr
9944 Dump internal details about what the analyzer is doing to stderr.
9945 This option overrides @option{-fdump-analyzer}.
9947 @item -fdump-analyzer-callgraph
9948 @opindex fdump-analyzer-callgraph
9949 Dump a representation of the call graph suitable for viewing with
9950 GraphViz to @file{@var{file}.callgraph.dot}.
9952 @item -fdump-analyzer-exploded-graph
9953 @opindex fdump-analyzer-exploded-graph
9954 Dump a representation of the ``exploded graph'' suitable for viewing with
9955 GraphViz to @file{@var{file}.eg.dot}.
9956 Nodes are color-coded based on state-machine states to emphasize
9959 @item -fdump-analyzer-exploded-nodes
9960 @opindex dump-analyzer-exploded-nodes
9961 Emit diagnostics showing where nodes in the ``exploded graph'' are
9962 in relation to the program source.
9964 @item -fdump-analyzer-exploded-nodes-2
9965 @opindex dump-analyzer-exploded-nodes-2
9966 Dump a textual representation of the ``exploded graph'' to
9967 @file{@var{file}.eg.txt}.
9969 @item -fdump-analyzer-exploded-nodes-3
9970 @opindex dump-analyzer-exploded-nodes-3
9971 Dump a textual representation of the ``exploded graph'' to
9972 one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
9973 This is typically a large number of dump files.
9975 @item -fdump-analyzer-exploded-paths
9976 @opindex fdump-analyzer-exploded-paths
9977 Dump a textual representation of the ``exploded path'' for each
9978 diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
9980 @item -fdump-analyzer-feasibility
9981 @opindex dump-analyzer-feasibility
9982 Dump internal details about the analyzer's search for feasible paths.
9983 The details are written in a form suitable for viewing with GraphViz
9984 to filenames of the form @file{@var{file}.*.fg.dot} and
9985 @file{@var{file}.*.tg.dot}.
9987 @item -fdump-analyzer-json
9988 @opindex fdump-analyzer-json
9989 Dump a compressed JSON representation of analyzer internals to
9990 @file{@var{file}.analyzer.json.gz}. The precise format is subject
9993 @item -fdump-analyzer-state-purge
9994 @opindex fdump-analyzer-state-purge
9995 As per @option{-fdump-analyzer-supergraph}, dump a representation of the
9996 ``supergraph'' suitable for viewing with GraphViz, but annotate the
9997 graph with information on what state will be purged at each node.
9998 The graph is written to @file{@var{file}.state-purge.dot}.
10000 @item -fdump-analyzer-supergraph
10001 @opindex fdump-analyzer-supergraph
10002 Dump representations of the ``supergraph'' suitable for viewing with
10003 GraphViz to @file{@var{file}.supergraph.dot} and to
10004 @file{@var{file}.supergraph-eg.dot}. These show all of the
10005 control flow graphs in the program, with interprocedural edges for
10006 calls and returns. The second dump contains annotations showing nodes
10007 in the ``exploded graph'' and diagnostics associated with them.
10011 @node Debugging Options
10012 @section Options for Debugging Your Program
10013 @cindex options, debugging
10014 @cindex debugging information options
10016 To tell GCC to emit extra information for use by a debugger, in almost
10017 all cases you need only to add @option{-g} to your other options. Some debug
10018 formats can co-exist (like DWARF with CTF) when each of them is enabled
10019 explicitly by adding the respective command line option to your other options.
10021 GCC allows you to use @option{-g} with
10022 @option{-O}. The shortcuts taken by optimized code may occasionally
10023 be surprising: some variables you declared may not exist
10024 at all; flow of control may briefly move where you did not expect it;
10025 some statements may not be executed because they compute constant
10026 results or their values are already at hand; some statements may
10027 execute in different places because they have been moved out of loops.
10028 Nevertheless it is possible to debug optimized output. This makes
10029 it reasonable to use the optimizer for programs that might have bugs.
10031 If you are not using some other optimization option, consider
10032 using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
10033 With no @option{-O} option at all, some compiler passes that collect
10034 information useful for debugging do not run at all, so that
10035 @option{-Og} may result in a better debugging experience.
10040 Produce debugging information in the operating system's native format
10041 (stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
10044 On most systems that use stabs format, @option{-g} enables use of extra
10045 debugging information that only GDB can use; this extra information
10046 makes debugging work better in GDB but probably makes other debuggers
10048 refuse to read the program. If you want to control for certain whether
10049 to generate the extra information, use @option{-gstabs+}, @option{-gstabs},
10050 @option{-gxcoff+}, @option{-gxcoff}, or @option{-gvms} (see below).
10054 Produce debugging information for use by GDB@. This means to use the
10055 most expressive format available (DWARF, stabs, or the native format
10056 if neither of those are supported), including GDB extensions if at all
10060 @itemx -gdwarf-@var{version}
10062 Produce debugging information in DWARF format (if that is supported).
10063 The value of @var{version} may be either 2, 3, 4 or 5; the default
10064 version for most targets is 5 (with the exception of VxWorks, TPF and
10065 Darwin/Mac OS X, which default to version 2, and AIX, which defaults
10068 Note that with DWARF Version 2, some ports require and always
10069 use some non-conflicting DWARF 3 extensions in the unwind tables.
10071 Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
10072 for maximum benefit. Version 5 requires GDB 8.0 or higher.
10074 GCC no longer supports DWARF Version 1, which is substantially
10075 different than Version 2 and later. For historical reasons, some
10076 other DWARF-related options such as
10077 @option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
10078 in their names, but apply to all currently-supported versions of DWARF.
10082 Request BTF debug information. BTF is the default debugging format for the
10083 eBPF target. On other targets, like x86, BTF debug information can be
10084 generated along with DWARF debug information when both of the debug formats are
10085 enabled explicitly via their respective command line options.
10088 @itemx -gctf@var{level}
10090 Request CTF debug information and use level to specify how much CTF debug
10091 information should be produced. If @option{-gctf} is specified
10092 without a value for level, the default level of CTF debug information is 2.
10094 CTF debug information can be generated along with DWARF debug information when
10095 both of the debug formats are enabled explicitly via their respective command
10098 Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
10099 negates @option{-gctf}.
10101 Level 1 produces CTF information for tracebacks only. This includes callsite
10102 information, but does not include type information.
10104 Level 2 produces type information for entities (functions, data objects etc.)
10105 at file-scope or global-scope only.
10109 Produce debugging information in stabs format (if that is supported),
10110 without GDB extensions. This is the format used by DBX on most BSD
10111 systems. On MIPS, Alpha and System V Release 4 systems this option
10112 produces stabs debugging output that is not understood by DBX@.
10113 On System V Release 4 systems this option requires the GNU assembler.
10117 Produce debugging information in stabs format (if that is supported),
10118 using GNU extensions understood only by the GNU debugger (GDB)@. The
10119 use of these extensions is likely to make other debuggers crash or
10120 refuse to read the program.
10124 Produce debugging information in XCOFF format (if that is supported).
10125 This is the format used by the DBX debugger on IBM RS/6000 systems.
10129 Produce debugging information in XCOFF format (if that is supported),
10130 using GNU extensions understood only by the GNU debugger (GDB)@. The
10131 use of these extensions is likely to make other debuggers crash or
10132 refuse to read the program, and may cause assemblers other than the GNU
10133 assembler (GAS) to fail with an error.
10137 Produce debugging information in Alpha/VMS debug format (if that is
10138 supported). This is the format used by DEBUG on Alpha/VMS systems.
10140 @item -g@var{level}
10141 @itemx -ggdb@var{level}
10142 @itemx -gstabs@var{level}
10143 @itemx -gxcoff@var{level}
10144 @itemx -gvms@var{level}
10145 Request debugging information and also use @var{level} to specify how
10146 much information. The default level is 2.
10148 Level 0 produces no debug information at all. Thus, @option{-g0} negates
10151 Level 1 produces minimal information, enough for making backtraces in
10152 parts of the program that you don't plan to debug. This includes
10153 descriptions of functions and external variables, and line number
10154 tables, but no information about local variables.
10156 Level 3 includes extra information, such as all the macro definitions
10157 present in the program. Some debuggers support macro expansion when
10158 you use @option{-g3}.
10160 If you use multiple @option{-g} options, with or without level numbers,
10161 the last such option is the one that is effective.
10163 @option{-gdwarf} does not accept a concatenated debug level, to avoid
10164 confusion with @option{-gdwarf-@var{level}}.
10165 Instead use an additional @option{-g@var{level}} option to change the
10166 debug level for DWARF.
10168 @item -fno-eliminate-unused-debug-symbols
10169 @opindex feliminate-unused-debug-symbols
10170 @opindex fno-eliminate-unused-debug-symbols
10171 By default, no debug information is produced for symbols that are not actually
10172 used. Use this option if you want debug information for all symbols.
10174 @item -femit-class-debug-always
10175 @opindex femit-class-debug-always
10176 Instead of emitting debugging information for a C++ class in only one
10177 object file, emit it in all object files using the class. This option
10178 should be used only with debuggers that are unable to handle the way GCC
10179 normally emits debugging information for classes because using this
10180 option increases the size of debugging information by as much as a
10183 @item -fno-merge-debug-strings
10184 @opindex fmerge-debug-strings
10185 @opindex fno-merge-debug-strings
10186 Direct the linker to not merge together strings in the debugging
10187 information that are identical in different object files. Merging is
10188 not supported by all assemblers or linkers. Merging decreases the size
10189 of the debug information in the output file at the cost of increasing
10190 link processing time. Merging is enabled by default.
10192 @item -fdebug-prefix-map=@var{old}=@var{new}
10193 @opindex fdebug-prefix-map
10194 When compiling files residing in directory @file{@var{old}}, record
10195 debugging information describing them as if the files resided in
10196 directory @file{@var{new}} instead. This can be used to replace a
10197 build-time path with an install-time path in the debug info. It can
10198 also be used to change an absolute path to a relative path by using
10199 @file{.} for @var{new}. This can give more reproducible builds, which
10200 are location independent, but may require an extra command to tell GDB
10201 where to find the source files. See also @option{-ffile-prefix-map}.
10203 @item -fvar-tracking
10204 @opindex fvar-tracking
10205 Run variable tracking pass. It computes where variables are stored at each
10206 position in code. Better debugging information is then generated
10207 (if the debugging information format supports this information).
10209 It is enabled by default when compiling with optimization (@option{-Os},
10210 @option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
10211 the debug info format supports it.
10213 @item -fvar-tracking-assignments
10214 @opindex fvar-tracking-assignments
10215 @opindex fno-var-tracking-assignments
10216 Annotate assignments to user variables early in the compilation and
10217 attempt to carry the annotations over throughout the compilation all the
10218 way to the end, in an attempt to improve debug information while
10219 optimizing. Use of @option{-gdwarf-4} is recommended along with it.
10221 It can be enabled even if var-tracking is disabled, in which case
10222 annotations are created and maintained, but discarded at the end.
10223 By default, this flag is enabled together with @option{-fvar-tracking},
10224 except when selective scheduling is enabled.
10226 @item -gsplit-dwarf
10227 @opindex gsplit-dwarf
10228 If DWARF debugging information is enabled, separate as much debugging
10229 information as possible into a separate output file with the extension
10230 @file{.dwo}. This option allows the build system to avoid linking files with
10231 debug information. To be useful, this option requires a debugger capable of
10232 reading @file{.dwo} files.
10238 If DWARF debugging information is enabled, the @option{-gdwarf32} selects
10239 the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
10240 DWARF format. The default is target specific, on most targets it is
10241 @option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
10242 can't support more than 2GiB of debug information in any of the DWARF
10243 debug information sections. The 64-bit DWARF format allows larger debug
10244 information and might not be well supported by all consumers yet.
10246 @item -gdescribe-dies
10247 @opindex gdescribe-dies
10248 Add description attributes to some DWARF DIEs that have no name attribute,
10249 such as artificial variables, external references and call site
10254 Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
10256 @item -ggnu-pubnames
10257 @opindex ggnu-pubnames
10258 Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
10259 suitable for conversion into a GDB@ index. This option is only useful
10260 with a linker that can produce GDB@ index version 7.
10262 @item -fdebug-types-section
10263 @opindex fdebug-types-section
10264 @opindex fno-debug-types-section
10265 When using DWARF Version 4 or higher, type DIEs can be put into
10266 their own @code{.debug_types} section instead of making them part of the
10267 @code{.debug_info} section. It is more efficient to put them in a separate
10268 comdat section since the linker can then remove duplicates.
10269 But not all DWARF consumers support @code{.debug_types} sections yet
10270 and on some objects @code{.debug_types} produces larger instead of smaller
10271 debugging information.
10273 @item -grecord-gcc-switches
10274 @itemx -gno-record-gcc-switches
10275 @opindex grecord-gcc-switches
10276 @opindex gno-record-gcc-switches
10277 This switch causes the command-line options used to invoke the
10278 compiler that may affect code generation to be appended to the
10279 DW_AT_producer attribute in DWARF debugging information. The options
10280 are concatenated with spaces separating them from each other and from
10281 the compiler version.
10282 It is enabled by default.
10283 See also @option{-frecord-gcc-switches} for another
10284 way of storing compiler options into the object file.
10286 @item -gstrict-dwarf
10287 @opindex gstrict-dwarf
10288 Disallow using extensions of later DWARF standard version than selected
10289 with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
10290 DWARF extensions from later standard versions is allowed.
10292 @item -gno-strict-dwarf
10293 @opindex gno-strict-dwarf
10294 Allow using extensions of later DWARF standard version than selected with
10295 @option{-gdwarf-@var{version}}.
10297 @item -gas-loc-support
10298 @opindex gas-loc-support
10299 Inform the compiler that the assembler supports @code{.loc} directives.
10300 It may then use them for the assembler to generate DWARF2+ line number
10303 This is generally desirable, because assembler-generated line-number
10304 tables are a lot more compact than those the compiler can generate
10307 This option will be enabled by default if, at GCC configure time, the
10308 assembler was found to support such directives.
10310 @item -gno-as-loc-support
10311 @opindex gno-as-loc-support
10312 Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
10313 line number tables are to be generated.
10315 @item -gas-locview-support
10316 @opindex gas-locview-support
10317 Inform the compiler that the assembler supports @code{view} assignment
10318 and reset assertion checking in @code{.loc} directives.
10320 This option will be enabled by default if, at GCC configure time, the
10321 assembler was found to support them.
10323 @item -gno-as-locview-support
10324 Force GCC to assign view numbers internally, if
10325 @option{-gvariable-location-views} are explicitly requested.
10327 @item -gcolumn-info
10328 @itemx -gno-column-info
10329 @opindex gcolumn-info
10330 @opindex gno-column-info
10331 Emit location column information into DWARF debugging information, rather
10332 than just file and line.
10333 This option is enabled by default.
10335 @item -gstatement-frontiers
10336 @itemx -gno-statement-frontiers
10337 @opindex gstatement-frontiers
10338 @opindex gno-statement-frontiers
10339 This option causes GCC to create markers in the internal representation
10340 at the beginning of statements, and to keep them roughly in place
10341 throughout compilation, using them to guide the output of @code{is_stmt}
10342 markers in the line number table. This is enabled by default when
10343 compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
10344 @dots{}), and outputting DWARF 2 debug information at the normal level.
10346 @item -gvariable-location-views
10347 @itemx -gvariable-location-views=incompat5
10348 @itemx -gno-variable-location-views
10349 @opindex gvariable-location-views
10350 @opindex gvariable-location-views=incompat5
10351 @opindex gno-variable-location-views
10352 Augment variable location lists with progressive view numbers implied
10353 from the line number table. This enables debug information consumers to
10354 inspect state at certain points of the program, even if no instructions
10355 associated with the corresponding source locations are present at that
10356 point. If the assembler lacks support for view numbers in line number
10357 tables, this will cause the compiler to emit the line number table,
10358 which generally makes them somewhat less compact. The augmented line
10359 number tables and location lists are fully backward-compatible, so they
10360 can be consumed by debug information consumers that are not aware of
10361 these augmentations, but they won't derive any benefit from them either.
10363 This is enabled by default when outputting DWARF 2 debug information at
10364 the normal level, as long as there is assembler support,
10365 @option{-fvar-tracking-assignments} is enabled and
10366 @option{-gstrict-dwarf} is not. When assembler support is not
10367 available, this may still be enabled, but it will force GCC to output
10368 internal line number tables, and if
10369 @option{-ginternal-reset-location-views} is not enabled, that will most
10370 certainly lead to silently mismatching location views.
10372 There is a proposed representation for view numbers that is not backward
10373 compatible with the location list format introduced in DWARF 5, that can
10374 be enabled with @option{-gvariable-location-views=incompat5}. This
10375 option may be removed in the future, is only provided as a reference
10376 implementation of the proposed representation. Debug information
10377 consumers are not expected to support this extended format, and they
10378 would be rendered unable to decode location lists using it.
10380 @item -ginternal-reset-location-views
10381 @itemx -gno-internal-reset-location-views
10382 @opindex ginternal-reset-location-views
10383 @opindex gno-internal-reset-location-views
10384 Attempt to determine location views that can be omitted from location
10385 view lists. This requires the compiler to have very accurate insn
10386 length estimates, which isn't always the case, and it may cause
10387 incorrect view lists to be generated silently when using an assembler
10388 that does not support location view lists. The GNU assembler will flag
10389 any such error as a @code{view number mismatch}. This is only enabled
10390 on ports that define a reliable estimation function.
10392 @item -ginline-points
10393 @itemx -gno-inline-points
10394 @opindex ginline-points
10395 @opindex gno-inline-points
10396 Generate extended debug information for inlined functions. Location
10397 view tracking markers are inserted at inlined entry points, so that
10398 address and view numbers can be computed and output in debug
10399 information. This can be enabled independently of location views, in
10400 which case the view numbers won't be output, but it can only be enabled
10401 along with statement frontiers, and it is only enabled by default if
10402 location views are enabled.
10404 @item -gz@r{[}=@var{type}@r{]}
10406 Produce compressed debug sections in DWARF format, if that is supported.
10407 If @var{type} is not given, the default type depends on the capabilities
10408 of the assembler and linker used. @var{type} may be one of
10409 @samp{none} (don't compress debug sections), @samp{zlib} (use zlib
10410 compression in ELF gABI format), or @samp{zlib-gnu} (use zlib
10411 compression in traditional GNU format). If the linker doesn't support
10412 writing compressed debug sections, the option is rejected. Otherwise,
10413 if the assembler does not support them, @option{-gz} is silently ignored
10414 when producing object files.
10416 @item -femit-struct-debug-baseonly
10417 @opindex femit-struct-debug-baseonly
10418 Emit debug information for struct-like types
10419 only when the base name of the compilation source file
10420 matches the base name of file in which the struct is defined.
10422 This option substantially reduces the size of debugging information,
10423 but at significant potential loss in type information to the debugger.
10424 See @option{-femit-struct-debug-reduced} for a less aggressive option.
10425 See @option{-femit-struct-debug-detailed} for more detailed control.
10427 This option works only with DWARF debug output.
10429 @item -femit-struct-debug-reduced
10430 @opindex femit-struct-debug-reduced
10431 Emit debug information for struct-like types
10432 only when the base name of the compilation source file
10433 matches the base name of file in which the type is defined,
10434 unless the struct is a template or defined in a system header.
10436 This option significantly reduces the size of debugging information,
10437 with some potential loss in type information to the debugger.
10438 See @option{-femit-struct-debug-baseonly} for a more aggressive option.
10439 See @option{-femit-struct-debug-detailed} for more detailed control.
10441 This option works only with DWARF debug output.
10443 @item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
10444 @opindex femit-struct-debug-detailed
10445 Specify the struct-like types
10446 for which the compiler generates debug information.
10447 The intent is to reduce duplicate struct debug information
10448 between different object files within the same program.
10450 This option is a detailed version of
10451 @option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
10452 which serves for most needs.
10454 A specification has the syntax@*
10455 [@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
10457 The optional first word limits the specification to
10458 structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
10459 A struct type is used directly when it is the type of a variable, member.
10460 Indirect uses arise through pointers to structs.
10461 That is, when use of an incomplete struct is valid, the use is indirect.
10463 @samp{struct one direct; struct two * indirect;}.
10465 The optional second word limits the specification to
10466 ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
10467 Generic structs are a bit complicated to explain.
10468 For C++, these are non-explicit specializations of template classes,
10469 or non-template classes within the above.
10470 Other programming languages have generics,
10471 but @option{-femit-struct-debug-detailed} does not yet implement them.
10473 The third word specifies the source files for those
10474 structs for which the compiler should emit debug information.
10475 The values @samp{none} and @samp{any} have the normal meaning.
10476 The value @samp{base} means that
10477 the base of name of the file in which the type declaration appears
10478 must match the base of the name of the main compilation file.
10479 In practice, this means that when compiling @file{foo.c}, debug information
10480 is generated for types declared in that file and @file{foo.h},
10481 but not other header files.
10482 The value @samp{sys} means those types satisfying @samp{base}
10483 or declared in system or compiler headers.
10485 You may need to experiment to determine the best settings for your application.
10487 The default is @option{-femit-struct-debug-detailed=all}.
10489 This option works only with DWARF debug output.
10491 @item -fno-dwarf2-cfi-asm
10492 @opindex fdwarf2-cfi-asm
10493 @opindex fno-dwarf2-cfi-asm
10494 Emit DWARF unwind info as compiler generated @code{.eh_frame} section
10495 instead of using GAS @code{.cfi_*} directives.
10497 @item -fno-eliminate-unused-debug-types
10498 @opindex feliminate-unused-debug-types
10499 @opindex fno-eliminate-unused-debug-types
10500 Normally, when producing DWARF output, GCC avoids producing debug symbol
10501 output for types that are nowhere used in the source file being compiled.
10502 Sometimes it is useful to have GCC emit debugging
10503 information for all types declared in a compilation
10504 unit, regardless of whether or not they are actually used
10505 in that compilation unit, for example
10506 if, in the debugger, you want to cast a value to a type that is
10507 not actually used in your program (but is declared). More often,
10508 however, this results in a significant amount of wasted space.
10511 @node Optimize Options
10512 @section Options That Control Optimization
10513 @cindex optimize options
10514 @cindex options, optimization
10516 These options control various sorts of optimizations.
10518 Without any optimization option, the compiler's goal is to reduce the
10519 cost of compilation and to make debugging produce the expected
10520 results. Statements are independent: if you stop the program with a
10521 breakpoint between statements, you can then assign a new value to any
10522 variable or change the program counter to any other statement in the
10523 function and get exactly the results you expect from the source
10526 Turning on optimization flags makes the compiler attempt to improve
10527 the performance and/or code size at the expense of compilation time
10528 and possibly the ability to debug the program.
10530 The compiler performs optimization based on the knowledge it has of the
10531 program. Compiling multiple files at once to a single output file mode allows
10532 the compiler to use information gained from all of the files when compiling
10535 Not all optimizations are controlled directly by a flag. Only
10536 optimizations that have a flag are listed in this section.
10538 Most optimizations are completely disabled at @option{-O0} or if an
10539 @option{-O} level is not set on the command line, even if individual
10540 optimization flags are specified. Similarly, @option{-Og} suppresses
10541 many optimization passes.
10543 Depending on the target and how GCC was configured, a slightly different
10544 set of optimizations may be enabled at each @option{-O} level than
10545 those listed here. You can invoke GCC with @option{-Q --help=optimizers}
10546 to find out the exact set of optimizations that are enabled at each level.
10547 @xref{Overall Options}, for examples.
10554 Optimize. Optimizing compilation takes somewhat more time, and a lot
10555 more memory for a large function.
10557 With @option{-O}, the compiler tries to reduce code size and execution
10558 time, without performing any optimizations that take a great deal of
10561 @c Note that in addition to the default_options_table list in opts.c,
10562 @c several optimization flags default to true but control optimization
10563 @c passes that are explicitly disabled at -O0.
10565 @option{-O} turns on the following optimization flags:
10567 @c Please keep the following list alphabetized.
10568 @gccoptlist{-fauto-inc-dec @gol
10569 -fbranch-count-reg @gol
10570 -fcombine-stack-adjustments @gol
10571 -fcompare-elim @gol
10572 -fcprop-registers @gol
10575 -fdelayed-branch @gol
10577 -fforward-propagate @gol
10578 -fguess-branch-probability @gol
10579 -fif-conversion @gol
10580 -fif-conversion2 @gol
10581 -finline-functions-called-once @gol
10584 -fipa-pure-const @gol
10585 -fipa-reference @gol
10586 -fipa-reference-addressable @gol
10587 -fmerge-constants @gol
10588 -fmove-loop-invariants @gol
10589 -fmove-loop-stores@gol
10590 -fomit-frame-pointer @gol
10591 -freorder-blocks @gol
10593 -fshrink-wrap-separate @gol
10594 -fsplit-wide-types @gol
10595 -fssa-backprop @gol
10597 -ftree-bit-ccp @gol
10600 -ftree-coalesce-vars @gol
10601 -ftree-copy-prop @gol
10603 -ftree-dominator-opts @gol
10605 -ftree-forwprop @gol
10607 -ftree-phiprop @gol
10609 -ftree-scev-cprop @gol
10618 Optimize even more. GCC performs nearly all supported optimizations
10619 that do not involve a space-speed tradeoff.
10620 As compared to @option{-O}, this option increases both compilation time
10621 and the performance of the generated code.
10623 @option{-O2} turns on all optimization flags specified by @option{-O1}. It
10624 also turns on the following optimization flags:
10626 @c Please keep the following list alphabetized!
10627 @gccoptlist{-falign-functions -falign-jumps @gol
10628 -falign-labels -falign-loops @gol
10629 -fcaller-saves @gol
10630 -fcode-hoisting @gol
10631 -fcrossjumping @gol
10632 -fcse-follow-jumps -fcse-skip-blocks @gol
10633 -fdelete-null-pointer-checks @gol
10634 -fdevirtualize -fdevirtualize-speculatively @gol
10635 -fexpensive-optimizations @gol
10636 -ffinite-loops @gol
10637 -fgcse -fgcse-lm @gol
10638 -fhoist-adjacent-loads @gol
10639 -finline-functions @gol
10640 -finline-small-functions @gol
10641 -findirect-inlining @gol
10642 -fipa-bit-cp -fipa-cp -fipa-icf @gol
10643 -fipa-ra -fipa-sra -fipa-vrp @gol
10644 -fisolate-erroneous-paths-dereference @gol
10646 -foptimize-sibling-calls @gol
10647 -foptimize-strlen @gol
10648 -fpartial-inlining @gol
10650 -freorder-blocks-algorithm=stc @gol
10651 -freorder-blocks-and-partition -freorder-functions @gol
10652 -frerun-cse-after-loop @gol
10653 -fschedule-insns -fschedule-insns2 @gol
10654 -fsched-interblock -fsched-spec @gol
10655 -fstore-merging @gol
10656 -fstrict-aliasing @gol
10657 -fthread-jumps @gol
10658 -ftree-builtin-call-dce @gol
10659 -ftree-loop-vectorize @gol
10661 -ftree-slp-vectorize @gol
10662 -ftree-switch-conversion -ftree-tail-merge @gol
10664 -fvect-cost-model=very-cheap}
10666 Please note the warning under @option{-fgcse} about
10667 invoking @option{-O2} on programs that use computed gotos.
10671 Optimize yet more. @option{-O3} turns on all optimizations specified
10672 by @option{-O2} and also turns on the following optimization flags:
10674 @c Please keep the following list alphabetized!
10675 @gccoptlist{-fgcse-after-reload @gol
10677 -floop-interchange @gol
10678 -floop-unroll-and-jam @gol
10680 -fpredictive-commoning @gol
10683 -ftree-loop-distribution @gol
10684 -ftree-partial-pre @gol
10685 -funswitch-loops @gol
10686 -fvect-cost-model=dynamic @gol
10687 -fversion-loops-for-strides}
10691 Reduce compilation time and make debugging produce the expected
10692 results. This is the default.
10696 Optimize for size. @option{-Os} enables all @option{-O2} optimizations
10697 except those that often increase code size:
10699 @gccoptlist{-falign-functions -falign-jumps @gol
10700 -falign-labels -falign-loops @gol
10701 -fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
10703 It also enables @option{-finline-functions}, causes the compiler to tune for
10704 code size rather than execution speed, and performs further optimizations
10705 designed to reduce code size.
10709 Disregard strict standards compliance. @option{-Ofast} enables all
10710 @option{-O3} optimizations. It also enables optimizations that are not
10711 valid for all standard-compliant programs.
10712 It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
10713 and the Fortran-specific @option{-fstack-arrays}, unless
10714 @option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
10715 It turns off @option{-fsemantic-interposition}.
10719 Optimize debugging experience. @option{-Og} should be the optimization
10720 level of choice for the standard edit-compile-debug cycle, offering
10721 a reasonable level of optimization while maintaining fast compilation
10722 and a good debugging experience. It is a better choice than @option{-O0}
10723 for producing debuggable code because some compiler passes
10724 that collect debug information are disabled at @option{-O0}.
10726 Like @option{-O0}, @option{-Og} completely disables a number of
10727 optimization passes so that individual options controlling them have
10728 no effect. Otherwise @option{-Og} enables all @option{-O1}
10729 optimization flags except for those that may interfere with debugging:
10731 @gccoptlist{-fbranch-count-reg -fdelayed-branch @gol
10732 -fdse -fif-conversion -fif-conversion2 @gol
10733 -finline-functions-called-once @gol
10734 -fmove-loop-invariants -fmove-loop-stores -fssa-phiopt @gol
10735 -ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
10739 Optimize aggressively for size rather than speed. This may increase
10740 the number of instructions executed if those instructions require
10741 fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
10742 including enabling most @option{-O2} optimizations.
10746 If you use multiple @option{-O} options, with or without level numbers,
10747 the last such option is the one that is effective.
10749 Options of the form @option{-f@var{flag}} specify machine-independent
10750 flags. Most flags have both positive and negative forms; the negative
10751 form of @option{-ffoo} is @option{-fno-foo}. In the table
10752 below, only one of the forms is listed---the one you typically
10753 use. You can figure out the other form by either removing @samp{no-}
10756 The following options control specific optimizations. They are either
10757 activated by @option{-O} options or are related to ones that are. You
10758 can use the following flags in the rare cases when ``fine-tuning'' of
10759 optimizations to be performed is desired.
10762 @item -fno-defer-pop
10763 @opindex fno-defer-pop
10764 @opindex fdefer-pop
10765 For machines that must pop arguments after a function call, always pop
10766 the arguments as soon as each function returns.
10767 At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
10768 this allows the compiler to let arguments accumulate on the stack for several
10769 function calls and pop them all at once.
10771 @item -fforward-propagate
10772 @opindex fforward-propagate
10773 Perform a forward propagation pass on RTL@. The pass tries to combine two
10774 instructions and checks if the result can be simplified. If loop unrolling
10775 is active, two passes are performed and the second is scheduled after
10778 This option is enabled by default at optimization levels @option{-O1},
10779 @option{-O2}, @option{-O3}, @option{-Os}.
10781 @item -ffp-contract=@var{style}
10782 @opindex ffp-contract
10783 @option{-ffp-contract=off} disables floating-point expression contraction.
10784 @option{-ffp-contract=fast} enables floating-point expression contraction
10785 such as forming of fused multiply-add operations if the target has
10786 native support for them.
10787 @option{-ffp-contract=on} enables floating-point expression contraction
10788 if allowed by the language standard. This is currently not implemented
10789 and treated equal to @option{-ffp-contract=off}.
10791 The default is @option{-ffp-contract=fast}.
10793 @item -fomit-frame-pointer
10794 @opindex fomit-frame-pointer
10795 Omit the frame pointer in functions that don't need one. This avoids the
10796 instructions to save, set up and restore the frame pointer; on many targets
10797 it also makes an extra register available.
10799 On some targets this flag has no effect because the standard calling sequence
10800 always uses a frame pointer, so it cannot be omitted.
10802 Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
10803 is used in all functions. Several targets always omit the frame pointer in
10806 Enabled by default at @option{-O1} and higher.
10808 @item -foptimize-sibling-calls
10809 @opindex foptimize-sibling-calls
10810 Optimize sibling and tail recursive calls.
10812 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
10814 @item -foptimize-strlen
10815 @opindex foptimize-strlen
10816 Optimize various standard C string functions (e.g.@: @code{strlen},
10817 @code{strchr} or @code{strcpy}) and
10818 their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
10820 Enabled at levels @option{-O2}, @option{-O3}.
10823 @opindex fno-inline
10825 Do not expand any functions inline apart from those marked with
10826 the @code{always_inline} attribute. This is the default when not
10829 Single functions can be exempted from inlining by marking them
10830 with the @code{noinline} attribute.
10832 @item -finline-small-functions
10833 @opindex finline-small-functions
10834 Integrate functions into their callers when their body is smaller than expected
10835 function call code (so overall size of program gets smaller). The compiler
10836 heuristically decides which functions are simple enough to be worth integrating
10837 in this way. This inlining applies to all functions, even those not declared
10840 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
10842 @item -findirect-inlining
10843 @opindex findirect-inlining
10844 Inline also indirect calls that are discovered to be known at compile
10845 time thanks to previous inlining. This option has any effect only
10846 when inlining itself is turned on by the @option{-finline-functions}
10847 or @option{-finline-small-functions} options.
10849 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
10851 @item -finline-functions
10852 @opindex finline-functions
10853 Consider all functions for inlining, even if they are not declared inline.
10854 The compiler heuristically decides which functions are worth integrating
10857 If all calls to a given function are integrated, and the function is
10858 declared @code{static}, then the function is normally not output as
10859 assembler code in its own right.
10861 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
10862 by @option{-fprofile-use} and @option{-fauto-profile}.
10864 @item -finline-functions-called-once
10865 @opindex finline-functions-called-once
10866 Consider all @code{static} functions called once for inlining into their
10867 caller even if they are not marked @code{inline}. If a call to a given
10868 function is integrated, then the function is not output as assembler code
10871 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
10872 but not @option{-Og}.
10874 @item -fearly-inlining
10875 @opindex fearly-inlining
10876 Inline functions marked by @code{always_inline} and functions whose body seems
10877 smaller than the function call overhead early before doing
10878 @option{-fprofile-generate} instrumentation and real inlining pass. Doing so
10879 makes profiling significantly cheaper and usually inlining faster on programs
10880 having large chains of nested wrapper functions.
10882 Enabled by default.
10886 Perform interprocedural scalar replacement of aggregates, removal of
10887 unused parameters and replacement of parameters passed by reference
10888 by parameters passed by value.
10890 Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
10892 @item -finline-limit=@var{n}
10893 @opindex finline-limit
10894 By default, GCC limits the size of functions that can be inlined. This flag
10895 allows coarse control of this limit. @var{n} is the size of functions that
10896 can be inlined in number of pseudo instructions.
10898 Inlining is actually controlled by a number of parameters, which may be
10899 specified individually by using @option{--param @var{name}=@var{value}}.
10900 The @option{-finline-limit=@var{n}} option sets some of these parameters
10904 @item max-inline-insns-single
10905 is set to @var{n}/2.
10906 @item max-inline-insns-auto
10907 is set to @var{n}/2.
10910 See below for a documentation of the individual
10911 parameters controlling inlining and for the defaults of these parameters.
10913 @emph{Note:} there may be no value to @option{-finline-limit} that results
10914 in default behavior.
10916 @emph{Note:} pseudo instruction represents, in this particular context, an
10917 abstract measurement of function's size. In no way does it represent a count
10918 of assembly instructions and as such its exact meaning might change from one
10919 release to an another.
10921 @item -fno-keep-inline-dllexport
10922 @opindex fno-keep-inline-dllexport
10923 @opindex fkeep-inline-dllexport
10924 This is a more fine-grained version of @option{-fkeep-inline-functions},
10925 which applies only to functions that are declared using the @code{dllexport}
10926 attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
10929 @item -fkeep-inline-functions
10930 @opindex fkeep-inline-functions
10931 In C, emit @code{static} functions that are declared @code{inline}
10932 into the object file, even if the function has been inlined into all
10933 of its callers. This switch does not affect functions using the
10934 @code{extern inline} extension in GNU C90@. In C++, emit any and all
10935 inline functions into the object file.
10937 @item -fkeep-static-functions
10938 @opindex fkeep-static-functions
10939 Emit @code{static} functions into the object file, even if the function
10942 @item -fkeep-static-consts
10943 @opindex fkeep-static-consts
10944 Emit variables declared @code{static const} when optimization isn't turned
10945 on, even if the variables aren't referenced.
10947 GCC enables this option by default. If you want to force the compiler to
10948 check if a variable is referenced, regardless of whether or not
10949 optimization is turned on, use the @option{-fno-keep-static-consts} option.
10951 @item -fmerge-constants
10952 @opindex fmerge-constants
10953 Attempt to merge identical constants (string constants and floating-point
10954 constants) across compilation units.
10956 This option is the default for optimized compilation if the assembler and
10957 linker support it. Use @option{-fno-merge-constants} to inhibit this
10960 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
10962 @item -fmerge-all-constants
10963 @opindex fmerge-all-constants
10964 Attempt to merge identical constants and identical variables.
10966 This option implies @option{-fmerge-constants}. In addition to
10967 @option{-fmerge-constants} this considers e.g.@: even constant initialized
10968 arrays or initialized constant variables with integral or floating-point
10969 types. Languages like C or C++ require each variable, including multiple
10970 instances of the same variable in recursive calls, to have distinct locations,
10971 so using this option results in non-conforming
10974 @item -fmodulo-sched
10975 @opindex fmodulo-sched
10976 Perform swing modulo scheduling immediately before the first scheduling
10977 pass. This pass looks at innermost loops and reorders their
10978 instructions by overlapping different iterations.
10980 @item -fmodulo-sched-allow-regmoves
10981 @opindex fmodulo-sched-allow-regmoves
10982 Perform more aggressive SMS-based modulo scheduling with register moves
10983 allowed. By setting this flag certain anti-dependences edges are
10984 deleted, which triggers the generation of reg-moves based on the
10985 life-range analysis. This option is effective only with
10986 @option{-fmodulo-sched} enabled.
10988 @item -fno-branch-count-reg
10989 @opindex fno-branch-count-reg
10990 @opindex fbranch-count-reg
10991 Disable the optimization pass that scans for opportunities to use
10992 ``decrement and branch'' instructions on a count register instead of
10993 instruction sequences that decrement a register, compare it against zero, and
10994 then branch based upon the result. This option is only meaningful on
10995 architectures that support such instructions, which include x86, PowerPC,
10996 IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
10997 doesn't remove the decrement and branch instructions from the generated
10998 instruction stream introduced by other optimization passes.
11000 The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
11001 except for @option{-Og}.
11003 @item -fno-function-cse
11004 @opindex fno-function-cse
11005 @opindex ffunction-cse
11006 Do not put function addresses in registers; make each instruction that
11007 calls a constant function contain the function's address explicitly.
11009 This option results in less efficient code, but some strange hacks
11010 that alter the assembler output may be confused by the optimizations
11011 performed when this option is not used.
11013 The default is @option{-ffunction-cse}
11015 @item -fno-zero-initialized-in-bss
11016 @opindex fno-zero-initialized-in-bss
11017 @opindex fzero-initialized-in-bss
11018 If the target supports a BSS section, GCC by default puts variables that
11019 are initialized to zero into BSS@. This can save space in the resulting
11022 This option turns off this behavior because some programs explicitly
11023 rely on variables going to the data section---e.g., so that the
11024 resulting executable can find the beginning of that section and/or make
11025 assumptions based on that.
11027 The default is @option{-fzero-initialized-in-bss}.
11029 @item -fthread-jumps
11030 @opindex fthread-jumps
11031 Perform optimizations that check to see if a jump branches to a
11032 location where another comparison subsumed by the first is found. If
11033 so, the first branch is redirected to either the destination of the
11034 second branch or a point immediately following it, depending on whether
11035 the condition is known to be true or false.
11037 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
11039 @item -fsplit-wide-types
11040 @opindex fsplit-wide-types
11041 When using a type that occupies multiple registers, such as @code{long
11042 long} on a 32-bit system, split the registers apart and allocate them
11043 independently. This normally generates better code for those types,
11044 but may make debugging more difficult.
11046 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
11049 @item -fsplit-wide-types-early
11050 @opindex fsplit-wide-types-early
11051 Fully split wide types early, instead of very late.
11052 This option has no effect unless @option{-fsplit-wide-types} is turned on.
11054 This is the default on some targets.
11056 @item -fcse-follow-jumps
11057 @opindex fcse-follow-jumps
11058 In common subexpression elimination (CSE), scan through jump instructions
11059 when the target of the jump is not reached by any other path. For
11060 example, when CSE encounters an @code{if} statement with an
11061 @code{else} clause, CSE follows the jump when the condition
11064 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11066 @item -fcse-skip-blocks
11067 @opindex fcse-skip-blocks
11068 This is similar to @option{-fcse-follow-jumps}, but causes CSE to
11069 follow jumps that conditionally skip over blocks. When CSE
11070 encounters a simple @code{if} statement with no else clause,
11071 @option{-fcse-skip-blocks} causes CSE to follow the jump around the
11072 body of the @code{if}.
11074 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11076 @item -frerun-cse-after-loop
11077 @opindex frerun-cse-after-loop
11078 Re-run common subexpression elimination after loop optimizations are
11081 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11085 Perform a global common subexpression elimination pass.
11086 This pass also performs global constant and copy propagation.
11088 @emph{Note:} When compiling a program using computed gotos, a GCC
11089 extension, you may get better run-time performance if you disable
11090 the global common subexpression elimination pass by adding
11091 @option{-fno-gcse} to the command line.
11093 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11097 When @option{-fgcse-lm} is enabled, global common subexpression elimination
11098 attempts to move loads that are only killed by stores into themselves. This
11099 allows a loop containing a load/store sequence to be changed to a load outside
11100 the loop, and a copy/store within the loop.
11102 Enabled by default when @option{-fgcse} is enabled.
11106 When @option{-fgcse-sm} is enabled, a store motion pass is run after
11107 global common subexpression elimination. This pass attempts to move
11108 stores out of loops. When used in conjunction with @option{-fgcse-lm},
11109 loops containing a load/store sequence can be changed to a load before
11110 the loop and a store after the loop.
11112 Not enabled at any optimization level.
11116 When @option{-fgcse-las} is enabled, the global common subexpression
11117 elimination pass eliminates redundant loads that come after stores to the
11118 same memory location (both partial and full redundancies).
11120 Not enabled at any optimization level.
11122 @item -fgcse-after-reload
11123 @opindex fgcse-after-reload
11124 When @option{-fgcse-after-reload} is enabled, a redundant load elimination
11125 pass is performed after reload. The purpose of this pass is to clean up
11126 redundant spilling.
11128 Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
11130 @item -faggressive-loop-optimizations
11131 @opindex faggressive-loop-optimizations
11132 This option tells the loop optimizer to use language constraints to
11133 derive bounds for the number of iterations of a loop. This assumes that
11134 loop code does not invoke undefined behavior by for example causing signed
11135 integer overflows or out-of-bound array accesses. The bounds for the
11136 number of iterations of a loop are used to guide loop unrolling and peeling
11137 and loop exit test optimizations.
11138 This option is enabled by default.
11140 @item -funconstrained-commons
11141 @opindex funconstrained-commons
11142 This option tells the compiler that variables declared in common blocks
11143 (e.g.@: Fortran) may later be overridden with longer trailing arrays. This
11144 prevents certain optimizations that depend on knowing the array bounds.
11146 @item -fcrossjumping
11147 @opindex fcrossjumping
11148 Perform cross-jumping transformation.
11149 This transformation unifies equivalent code and saves code size. The
11150 resulting code may or may not perform better than without cross-jumping.
11152 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11154 @item -fauto-inc-dec
11155 @opindex fauto-inc-dec
11156 Combine increments or decrements of addresses with memory accesses.
11157 This pass is always skipped on architectures that do not have
11158 instructions to support this. Enabled by default at @option{-O1} and
11159 higher on architectures that support this.
11163 Perform dead code elimination (DCE) on RTL@.
11164 Enabled by default at @option{-O1} and higher.
11168 Perform dead store elimination (DSE) on RTL@.
11169 Enabled by default at @option{-O1} and higher.
11171 @item -fif-conversion
11172 @opindex fif-conversion
11173 Attempt to transform conditional jumps into branch-less equivalents. This
11174 includes use of conditional moves, min, max, set flags and abs instructions, and
11175 some tricks doable by standard arithmetics. The use of conditional execution
11176 on chips where it is available is controlled by @option{-fif-conversion2}.
11178 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
11179 not with @option{-Og}.
11181 @item -fif-conversion2
11182 @opindex fif-conversion2
11183 Use conditional execution (where available) to transform conditional jumps into
11184 branch-less equivalents.
11186 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
11187 not with @option{-Og}.
11189 @item -fdeclone-ctor-dtor
11190 @opindex fdeclone-ctor-dtor
11191 The C++ ABI requires multiple entry points for constructors and
11192 destructors: one for a base subobject, one for a complete object, and
11193 one for a virtual destructor that calls operator delete afterwards.
11194 For a hierarchy with virtual bases, the base and complete variants are
11195 clones, which means two copies of the function. With this option, the
11196 base and complete variants are changed to be thunks that call a common
11199 Enabled by @option{-Os}.
11201 @item -fdelete-null-pointer-checks
11202 @opindex fdelete-null-pointer-checks
11203 Assume that programs cannot safely dereference null pointers, and that
11204 no code or data element resides at address zero.
11205 This option enables simple constant
11206 folding optimizations at all optimization levels. In addition, other
11207 optimization passes in GCC use this flag to control global dataflow
11208 analyses that eliminate useless checks for null pointers; these assume
11209 that a memory access to address zero always results in a trap, so
11210 that if a pointer is checked after it has already been dereferenced,
11213 Note however that in some environments this assumption is not true.
11214 Use @option{-fno-delete-null-pointer-checks} to disable this optimization
11215 for programs that depend on that behavior.
11217 This option is enabled by default on most targets. On Nios II ELF, it
11218 defaults to off. On AVR, CR16, and MSP430, this option is completely disabled.
11220 Passes that use the dataflow information
11221 are enabled independently at different optimization levels.
11223 @item -fdevirtualize
11224 @opindex fdevirtualize
11225 Attempt to convert calls to virtual functions to direct calls. This
11226 is done both within a procedure and interprocedurally as part of
11227 indirect inlining (@option{-findirect-inlining}) and interprocedural constant
11228 propagation (@option{-fipa-cp}).
11229 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11231 @item -fdevirtualize-speculatively
11232 @opindex fdevirtualize-speculatively
11233 Attempt to convert calls to virtual functions to speculative direct calls.
11234 Based on the analysis of the type inheritance graph, determine for a given call
11235 the set of likely targets. If the set is small, preferably of size 1, change
11236 the call into a conditional deciding between direct and indirect calls. The
11237 speculative calls enable more optimizations, such as inlining. When they seem
11238 useless after further optimization, they are converted back into original form.
11240 @item -fdevirtualize-at-ltrans
11241 @opindex fdevirtualize-at-ltrans
11242 Stream extra information needed for aggressive devirtualization when running
11243 the link-time optimizer in local transformation mode.
11244 This option enables more devirtualization but
11245 significantly increases the size of streamed data. For this reason it is
11246 disabled by default.
11248 @item -fexpensive-optimizations
11249 @opindex fexpensive-optimizations
11250 Perform a number of minor optimizations that are relatively expensive.
11252 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11256 Attempt to remove redundant extension instructions. This is especially
11257 helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
11258 registers after writing to their lower 32-bit half.
11260 Enabled for Alpha, AArch64 and x86 at levels @option{-O2},
11261 @option{-O3}, @option{-Os}.
11263 @item -fno-lifetime-dse
11264 @opindex fno-lifetime-dse
11265 @opindex flifetime-dse
11266 In C++ the value of an object is only affected by changes within its
11267 lifetime: when the constructor begins, the object has an indeterminate
11268 value, and any changes during the lifetime of the object are dead when
11269 the object is destroyed. Normally dead store elimination will take
11270 advantage of this; if your code relies on the value of the object
11271 storage persisting beyond the lifetime of the object, you can use this
11272 flag to disable this optimization. To preserve stores before the
11273 constructor starts (e.g.@: because your operator new clears the object
11274 storage) but still treat the object as dead after the destructor, you
11275 can use @option{-flifetime-dse=1}. The default behavior can be
11276 explicitly selected with @option{-flifetime-dse=2}.
11277 @option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
11279 @item -flive-range-shrinkage
11280 @opindex flive-range-shrinkage
11281 Attempt to decrease register pressure through register live range
11282 shrinkage. This is helpful for fast processors with small or moderate
11283 size register sets.
11285 @item -fira-algorithm=@var{algorithm}
11286 @opindex fira-algorithm
11287 Use the specified coloring algorithm for the integrated register
11288 allocator. The @var{algorithm} argument can be @samp{priority}, which
11289 specifies Chow's priority coloring, or @samp{CB}, which specifies
11290 Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
11291 for all architectures, but for those targets that do support it, it is
11292 the default because it generates better code.
11294 @item -fira-region=@var{region}
11295 @opindex fira-region
11296 Use specified regions for the integrated register allocator. The
11297 @var{region} argument should be one of the following:
11302 Use all loops as register allocation regions.
11303 This can give the best results for machines with a small and/or
11304 irregular register set.
11307 Use all loops except for loops with small register pressure
11308 as the regions. This value usually gives
11309 the best results in most cases and for most architectures,
11310 and is enabled by default when compiling with optimization for speed
11311 (@option{-O}, @option{-O2}, @dots{}).
11314 Use all functions as a single region.
11315 This typically results in the smallest code size, and is enabled by default for
11316 @option{-Os} or @option{-O0}.
11320 @item -fira-hoist-pressure
11321 @opindex fira-hoist-pressure
11322 Use IRA to evaluate register pressure in the code hoisting pass for
11323 decisions to hoist expressions. This option usually results in smaller
11324 code, but it can slow the compiler down.
11326 This option is enabled at level @option{-Os} for all targets.
11328 @item -fira-loop-pressure
11329 @opindex fira-loop-pressure
11330 Use IRA to evaluate register pressure in loops for decisions to move
11331 loop invariants. This option usually results in generation
11332 of faster and smaller code on machines with large register files (>= 32
11333 registers), but it can slow the compiler down.
11335 This option is enabled at level @option{-O3} for some targets.
11337 @item -fno-ira-share-save-slots
11338 @opindex fno-ira-share-save-slots
11339 @opindex fira-share-save-slots
11340 Disable sharing of stack slots used for saving call-used hard
11341 registers living through a call. Each hard register gets a
11342 separate stack slot, and as a result function stack frames are
11345 @item -fno-ira-share-spill-slots
11346 @opindex fno-ira-share-spill-slots
11347 @opindex fira-share-spill-slots
11348 Disable sharing of stack slots allocated for pseudo-registers. Each
11349 pseudo-register that does not get a hard register gets a separate
11350 stack slot, and as a result function stack frames are larger.
11353 @opindex flra-remat
11354 Enable CFG-sensitive rematerialization in LRA. Instead of loading
11355 values of spilled pseudos, LRA tries to rematerialize (recalculate)
11356 values if it is profitable.
11358 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11360 @item -fdelayed-branch
11361 @opindex fdelayed-branch
11362 If supported for the target machine, attempt to reorder instructions
11363 to exploit instruction slots available after delayed branch
11366 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
11367 but not at @option{-Og}.
11369 @item -fschedule-insns
11370 @opindex fschedule-insns
11371 If supported for the target machine, attempt to reorder instructions to
11372 eliminate execution stalls due to required data being unavailable. This
11373 helps machines that have slow floating point or memory load instructions
11374 by allowing other instructions to be issued until the result of the load
11375 or floating-point instruction is required.
11377 Enabled at levels @option{-O2}, @option{-O3}.
11379 @item -fschedule-insns2
11380 @opindex fschedule-insns2
11381 Similar to @option{-fschedule-insns}, but requests an additional pass of
11382 instruction scheduling after register allocation has been done. This is
11383 especially useful on machines with a relatively small number of
11384 registers and where memory load instructions take more than one cycle.
11386 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11388 @item -fno-sched-interblock
11389 @opindex fno-sched-interblock
11390 @opindex fsched-interblock
11391 Disable instruction scheduling across basic blocks, which
11392 is normally enabled when scheduling before register allocation, i.e.@:
11393 with @option{-fschedule-insns} or at @option{-O2} or higher.
11395 @item -fno-sched-spec
11396 @opindex fno-sched-spec
11397 @opindex fsched-spec
11398 Disable speculative motion of non-load instructions, which
11399 is normally enabled when scheduling before register allocation, i.e.@:
11400 with @option{-fschedule-insns} or at @option{-O2} or higher.
11402 @item -fsched-pressure
11403 @opindex fsched-pressure
11404 Enable register pressure sensitive insn scheduling before register
11405 allocation. This only makes sense when scheduling before register
11406 allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
11407 @option{-O2} or higher. Usage of this option can improve the
11408 generated code and decrease its size by preventing register pressure
11409 increase above the number of available hard registers and subsequent
11410 spills in register allocation.
11412 @item -fsched-spec-load
11413 @opindex fsched-spec-load
11414 Allow speculative motion of some load instructions. This only makes
11415 sense when scheduling before register allocation, i.e.@: with
11416 @option{-fschedule-insns} or at @option{-O2} or higher.
11418 @item -fsched-spec-load-dangerous
11419 @opindex fsched-spec-load-dangerous
11420 Allow speculative motion of more load instructions. This only makes
11421 sense when scheduling before register allocation, i.e.@: with
11422 @option{-fschedule-insns} or at @option{-O2} or higher.
11424 @item -fsched-stalled-insns
11425 @itemx -fsched-stalled-insns=@var{n}
11426 @opindex fsched-stalled-insns
11427 Define how many insns (if any) can be moved prematurely from the queue
11428 of stalled insns into the ready list during the second scheduling pass.
11429 @option{-fno-sched-stalled-insns} means that no insns are moved
11430 prematurely, @option{-fsched-stalled-insns=0} means there is no limit
11431 on how many queued insns can be moved prematurely.
11432 @option{-fsched-stalled-insns} without a value is equivalent to
11433 @option{-fsched-stalled-insns=1}.
11435 @item -fsched-stalled-insns-dep
11436 @itemx -fsched-stalled-insns-dep=@var{n}
11437 @opindex fsched-stalled-insns-dep
11438 Define how many insn groups (cycles) are examined for a dependency
11439 on a stalled insn that is a candidate for premature removal from the queue
11440 of stalled insns. This has an effect only during the second scheduling pass,
11441 and only if @option{-fsched-stalled-insns} is used.
11442 @option{-fno-sched-stalled-insns-dep} is equivalent to
11443 @option{-fsched-stalled-insns-dep=0}.
11444 @option{-fsched-stalled-insns-dep} without a value is equivalent to
11445 @option{-fsched-stalled-insns-dep=1}.
11447 @item -fsched2-use-superblocks
11448 @opindex fsched2-use-superblocks
11449 When scheduling after register allocation, use superblock scheduling.
11450 This allows motion across basic block boundaries,
11451 resulting in faster schedules. This option is experimental, as not all machine
11452 descriptions used by GCC model the CPU closely enough to avoid unreliable
11453 results from the algorithm.
11455 This only makes sense when scheduling after register allocation, i.e.@: with
11456 @option{-fschedule-insns2} or at @option{-O2} or higher.
11458 @item -fsched-group-heuristic
11459 @opindex fsched-group-heuristic
11460 Enable the group heuristic in the scheduler. This heuristic favors
11461 the instruction that belongs to a schedule group. This is enabled
11462 by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
11463 or @option{-fschedule-insns2} or at @option{-O2} or higher.
11465 @item -fsched-critical-path-heuristic
11466 @opindex fsched-critical-path-heuristic
11467 Enable the critical-path heuristic in the scheduler. This heuristic favors
11468 instructions on the critical path. This is enabled by default when
11469 scheduling is enabled, i.e.@: with @option{-fschedule-insns}
11470 or @option{-fschedule-insns2} or at @option{-O2} or higher.
11472 @item -fsched-spec-insn-heuristic
11473 @opindex fsched-spec-insn-heuristic
11474 Enable the speculative instruction heuristic in the scheduler. This
11475 heuristic favors speculative instructions with greater dependency weakness.
11476 This is enabled by default when scheduling is enabled, i.e.@:
11477 with @option{-fschedule-insns} or @option{-fschedule-insns2}
11478 or at @option{-O2} or higher.
11480 @item -fsched-rank-heuristic
11481 @opindex fsched-rank-heuristic
11482 Enable the rank heuristic in the scheduler. This heuristic favors
11483 the instruction belonging to a basic block with greater size or frequency.
11484 This is enabled by default when scheduling is enabled, i.e.@:
11485 with @option{-fschedule-insns} or @option{-fschedule-insns2} or
11486 at @option{-O2} or higher.
11488 @item -fsched-last-insn-heuristic
11489 @opindex fsched-last-insn-heuristic
11490 Enable the last-instruction heuristic in the scheduler. This heuristic
11491 favors the instruction that is less dependent on the last instruction
11492 scheduled. This is enabled by default when scheduling is enabled,
11493 i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
11494 at @option{-O2} or higher.
11496 @item -fsched-dep-count-heuristic
11497 @opindex fsched-dep-count-heuristic
11498 Enable the dependent-count heuristic in the scheduler. This heuristic
11499 favors the instruction that has more instructions depending on it.
11500 This is enabled by default when scheduling is enabled, i.e.@:
11501 with @option{-fschedule-insns} or @option{-fschedule-insns2} or
11502 at @option{-O2} or higher.
11504 @item -freschedule-modulo-scheduled-loops
11505 @opindex freschedule-modulo-scheduled-loops
11506 Modulo scheduling is performed before traditional scheduling. If a loop
11507 is modulo scheduled, later scheduling passes may change its schedule.
11508 Use this option to control that behavior.
11510 @item -fselective-scheduling
11511 @opindex fselective-scheduling
11512 Schedule instructions using selective scheduling algorithm. Selective
11513 scheduling runs instead of the first scheduler pass.
11515 @item -fselective-scheduling2
11516 @opindex fselective-scheduling2
11517 Schedule instructions using selective scheduling algorithm. Selective
11518 scheduling runs instead of the second scheduler pass.
11520 @item -fsel-sched-pipelining
11521 @opindex fsel-sched-pipelining
11522 Enable software pipelining of innermost loops during selective scheduling.
11523 This option has no effect unless one of @option{-fselective-scheduling} or
11524 @option{-fselective-scheduling2} is turned on.
11526 @item -fsel-sched-pipelining-outer-loops
11527 @opindex fsel-sched-pipelining-outer-loops
11528 When pipelining loops during selective scheduling, also pipeline outer loops.
11529 This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
11531 @item -fsemantic-interposition
11532 @opindex fsemantic-interposition
11533 Some object formats, like ELF, allow interposing of symbols by the
11535 This means that for symbols exported from the DSO, the compiler cannot perform
11536 interprocedural propagation, inlining and other optimizations in anticipation
11537 that the function or variable in question may change. While this feature is
11538 useful, for example, to rewrite memory allocation functions by a debugging
11539 implementation, it is expensive in the terms of code quality.
11540 With @option{-fno-semantic-interposition} the compiler assumes that
11541 if interposition happens for functions the overwriting function will have
11542 precisely the same semantics (and side effects).
11543 Similarly if interposition happens
11544 for variables, the constructor of the variable will be the same. The flag
11545 has no effect for functions explicitly declared inline
11546 (where it is never allowed for interposition to change semantics)
11547 and for symbols explicitly declared weak.
11549 @item -fshrink-wrap
11550 @opindex fshrink-wrap
11551 Emit function prologues only before parts of the function that need it,
11552 rather than at the top of the function. This flag is enabled by default at
11553 @option{-O} and higher.
11555 @item -fshrink-wrap-separate
11556 @opindex fshrink-wrap-separate
11557 Shrink-wrap separate parts of the prologue and epilogue separately, so that
11558 those parts are only executed when needed.
11559 This option is on by default, but has no effect unless @option{-fshrink-wrap}
11560 is also turned on and the target supports this.
11562 @item -fcaller-saves
11563 @opindex fcaller-saves
11564 Enable allocation of values to registers that are clobbered by
11565 function calls, by emitting extra instructions to save and restore the
11566 registers around such calls. Such allocation is done only when it
11567 seems to result in better code.
11569 This option is always enabled by default on certain machines, usually
11570 those which have no call-preserved registers to use instead.
11572 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11574 @item -fcombine-stack-adjustments
11575 @opindex fcombine-stack-adjustments
11576 Tracks stack adjustments (pushes and pops) and stack memory references
11577 and then tries to find ways to combine them.
11579 Enabled by default at @option{-O1} and higher.
11583 Use caller save registers for allocation if those registers are not used by
11584 any called function. In that case it is not necessary to save and restore
11585 them around calls. This is only possible if called functions are part of
11586 same compilation unit as current function and they are compiled before it.
11588 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
11589 is disabled if generated code will be instrumented for profiling
11590 (@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
11591 exactly (this happens on targets that do not expose prologues
11592 and epilogues in RTL).
11594 @item -fconserve-stack
11595 @opindex fconserve-stack
11596 Attempt to minimize stack usage. The compiler attempts to use less
11597 stack space, even if that makes the program slower. This option
11598 implies setting the @option{large-stack-frame} parameter to 100
11599 and the @option{large-stack-frame-growth} parameter to 400.
11601 @item -ftree-reassoc
11602 @opindex ftree-reassoc
11603 Perform reassociation on trees. This flag is enabled by default
11604 at @option{-O1} and higher.
11606 @item -fcode-hoisting
11607 @opindex fcode-hoisting
11608 Perform code hoisting. Code hoisting tries to move the
11609 evaluation of expressions executed on all paths to the function exit
11610 as early as possible. This is especially useful as a code size
11611 optimization, but it often helps for code speed as well.
11612 This flag is enabled by default at @option{-O2} and higher.
11616 Perform partial redundancy elimination (PRE) on trees. This flag is
11617 enabled by default at @option{-O2} and @option{-O3}.
11619 @item -ftree-partial-pre
11620 @opindex ftree-partial-pre
11621 Make partial redundancy elimination (PRE) more aggressive. This flag is
11622 enabled by default at @option{-O3}.
11624 @item -ftree-forwprop
11625 @opindex ftree-forwprop
11626 Perform forward propagation on trees. This flag is enabled by default
11627 at @option{-O1} and higher.
11631 Perform full redundancy elimination (FRE) on trees. The difference
11632 between FRE and PRE is that FRE only considers expressions
11633 that are computed on all paths leading to the redundant computation.
11634 This analysis is faster than PRE, though it exposes fewer redundancies.
11635 This flag is enabled by default at @option{-O1} and higher.
11637 @item -ftree-phiprop
11638 @opindex ftree-phiprop
11639 Perform hoisting of loads from conditional pointers on trees. This
11640 pass is enabled by default at @option{-O1} and higher.
11642 @item -fhoist-adjacent-loads
11643 @opindex fhoist-adjacent-loads
11644 Speculatively hoist loads from both branches of an if-then-else if the
11645 loads are from adjacent locations in the same structure and the target
11646 architecture has a conditional move instruction. This flag is enabled
11647 by default at @option{-O2} and higher.
11649 @item -ftree-copy-prop
11650 @opindex ftree-copy-prop
11651 Perform copy propagation on trees. This pass eliminates unnecessary
11652 copy operations. This flag is enabled by default at @option{-O1} and
11655 @item -fipa-pure-const
11656 @opindex fipa-pure-const
11657 Discover which functions are pure or constant.
11658 Enabled by default at @option{-O1} and higher.
11660 @item -fipa-reference
11661 @opindex fipa-reference
11662 Discover which static variables do not escape the
11664 Enabled by default at @option{-O1} and higher.
11666 @item -fipa-reference-addressable
11667 @opindex fipa-reference-addressable
11668 Discover read-only, write-only and non-addressable static variables.
11669 Enabled by default at @option{-O1} and higher.
11671 @item -fipa-stack-alignment
11672 @opindex fipa-stack-alignment
11673 Reduce stack alignment on call sites if possible.
11674 Enabled by default.
11678 Perform interprocedural pointer analysis and interprocedural modification
11679 and reference analysis. This option can cause excessive memory and
11680 compile-time usage on large compilation units. It is not enabled by
11681 default at any optimization level.
11683 @item -fipa-profile
11684 @opindex fipa-profile
11685 Perform interprocedural profile propagation. The functions called only from
11686 cold functions are marked as cold. Also functions executed once (such as
11687 @code{cold}, @code{noreturn}, static constructors or destructors) are
11688 identified. Cold functions and loop less parts of functions executed once are
11689 then optimized for size.
11690 Enabled by default at @option{-O1} and higher.
11693 @opindex fipa-modref
11694 Perform interprocedural mod/ref analysis. This optimization analyzes the side
11695 effects of functions (memory locations that are modified or referenced) and
11696 enables better optimization across the function call boundary. This flag is
11697 enabled by default at @option{-O1} and higher.
11701 Perform interprocedural constant propagation.
11702 This optimization analyzes the program to determine when values passed
11703 to functions are constants and then optimizes accordingly.
11704 This optimization can substantially increase performance
11705 if the application has constants passed to functions.
11706 This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
11707 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
11709 @item -fipa-cp-clone
11710 @opindex fipa-cp-clone
11711 Perform function cloning to make interprocedural constant propagation stronger.
11712 When enabled, interprocedural constant propagation performs function cloning
11713 when externally visible function can be called with constant arguments.
11714 Because this optimization can create multiple copies of functions,
11715 it may significantly increase code size
11716 (see @option{--param ipa-cp-unit-growth=@var{value}}).
11717 This flag is enabled by default at @option{-O3}.
11718 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
11721 @opindex fipa-bit-cp
11722 When enabled, perform interprocedural bitwise constant
11723 propagation. This flag is enabled by default at @option{-O2} and
11724 by @option{-fprofile-use} and @option{-fauto-profile}.
11725 It requires that @option{-fipa-cp} is enabled.
11729 When enabled, perform interprocedural propagation of value
11730 ranges. This flag is enabled by default at @option{-O2}. It requires
11731 that @option{-fipa-cp} is enabled.
11735 Perform Identical Code Folding for functions and read-only variables.
11736 The optimization reduces code size and may disturb unwind stacks by replacing
11737 a function by equivalent one with a different name. The optimization works
11738 more effectively with link-time optimization enabled.
11740 Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
11741 works on different levels and thus the optimizations are not same - there are
11742 equivalences that are found only by GCC and equivalences found only by Gold.
11744 This flag is enabled by default at @option{-O2} and @option{-Os}.
11746 @item -flive-patching=@var{level}
11747 @opindex flive-patching
11748 Control GCC's optimizations to produce output suitable for live-patching.
11750 If the compiler's optimization uses a function's body or information extracted
11751 from its body to optimize/change another function, the latter is called an
11752 impacted function of the former. If a function is patched, its impacted
11753 functions should be patched too.
11755 The impacted functions are determined by the compiler's interprocedural
11756 optimizations. For example, a caller is impacted when inlining a function
11758 cloning a function and changing its caller to call this new clone,
11759 or extracting a function's pureness/constness information to optimize
11760 its direct or indirect callers, etc.
11762 Usually, the more IPA optimizations enabled, the larger the number of
11763 impacted functions for each function. In order to control the number of
11764 impacted functions and more easily compute the list of impacted function,
11765 IPA optimizations can be partially enabled at two different levels.
11767 The @var{level} argument should be one of the following:
11773 Only enable inlining and cloning optimizations, which includes inlining,
11774 cloning, interprocedural scalar replacement of aggregates and partial inlining.
11775 As a result, when patching a function, all its callers and its clones'
11776 callers are impacted, therefore need to be patched as well.
11778 @option{-flive-patching=inline-clone} disables the following optimization flags:
11779 @gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra @gol
11780 -fipa-icf -fipa-icf-functions -fipa-icf-variables @gol
11781 -fipa-bit-cp -fipa-vrp -fipa-pure-const -fipa-reference-addressable @gol
11782 -fipa-stack-alignment -fipa-modref}
11784 @item inline-only-static
11786 Only enable inlining of static functions.
11787 As a result, when patching a static function, all its callers are impacted
11788 and so need to be patched as well.
11790 In addition to all the flags that @option{-flive-patching=inline-clone}
11792 @option{-flive-patching=inline-only-static} disables the following additional
11793 optimization flags:
11794 @gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
11798 When @option{-flive-patching} is specified without any value, the default value
11799 is @var{inline-clone}.
11801 This flag is disabled by default.
11803 Note that @option{-flive-patching} is not supported with link-time optimization
11806 @item -fisolate-erroneous-paths-dereference
11807 @opindex fisolate-erroneous-paths-dereference
11808 Detect paths that trigger erroneous or undefined behavior due to
11809 dereferencing a null pointer. Isolate those paths from the main control
11810 flow and turn the statement with erroneous or undefined behavior into a trap.
11811 This flag is enabled by default at @option{-O2} and higher and depends on
11812 @option{-fdelete-null-pointer-checks} also being enabled.
11814 @item -fisolate-erroneous-paths-attribute
11815 @opindex fisolate-erroneous-paths-attribute
11816 Detect paths that trigger erroneous or undefined behavior due to a null value
11817 being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
11818 attribute. Isolate those paths from the main control flow and turn the
11819 statement with erroneous or undefined behavior into a trap. This is not
11820 currently enabled, but may be enabled by @option{-O2} in the future.
11823 @opindex ftree-sink
11824 Perform forward store motion on trees. This flag is
11825 enabled by default at @option{-O1} and higher.
11827 @item -ftree-bit-ccp
11828 @opindex ftree-bit-ccp
11829 Perform sparse conditional bit constant propagation on trees and propagate
11830 pointer alignment information.
11831 This pass only operates on local scalar variables and is enabled by default
11832 at @option{-O1} and higher, except for @option{-Og}.
11833 It requires that @option{-ftree-ccp} is enabled.
11837 Perform sparse conditional constant propagation (CCP) on trees. This
11838 pass only operates on local scalar variables and is enabled by default
11839 at @option{-O1} and higher.
11841 @item -fssa-backprop
11842 @opindex fssa-backprop
11843 Propagate information about uses of a value up the definition chain
11844 in order to simplify the definitions. For example, this pass strips
11845 sign operations if the sign of a value never matters. The flag is
11846 enabled by default at @option{-O1} and higher.
11849 @opindex fssa-phiopt
11850 Perform pattern matching on SSA PHI nodes to optimize conditional
11851 code. This pass is enabled by default at @option{-O1} and higher,
11852 except for @option{-Og}.
11854 @item -ftree-switch-conversion
11855 @opindex ftree-switch-conversion
11856 Perform conversion of simple initializations in a switch to
11857 initializations from a scalar array. This flag is enabled by default
11858 at @option{-O2} and higher.
11860 @item -ftree-tail-merge
11861 @opindex ftree-tail-merge
11862 Look for identical code sequences. When found, replace one with a jump to the
11863 other. This optimization is known as tail merging or cross jumping. This flag
11864 is enabled by default at @option{-O2} and higher. The compilation time
11866 be limited using @option{max-tail-merge-comparisons} parameter and
11867 @option{max-tail-merge-iterations} parameter.
11871 Perform dead code elimination (DCE) on trees. This flag is enabled by
11872 default at @option{-O1} and higher.
11874 @item -ftree-builtin-call-dce
11875 @opindex ftree-builtin-call-dce
11876 Perform conditional dead code elimination (DCE) for calls to built-in functions
11877 that may set @code{errno} but are otherwise free of side effects. This flag is
11878 enabled by default at @option{-O2} and higher if @option{-Os} is not also
11881 @item -ffinite-loops
11882 @opindex ffinite-loops
11883 @opindex fno-finite-loops
11884 Assume that a loop with an exit will eventually take the exit and not loop
11885 indefinitely. This allows the compiler to remove loops that otherwise have
11886 no side-effects, not considering eventual endless looping as such.
11888 This option is enabled by default at @option{-O2} for C++ with -std=c++11
11891 @item -ftree-dominator-opts
11892 @opindex ftree-dominator-opts
11893 Perform a variety of simple scalar cleanups (constant/copy
11894 propagation, redundancy elimination, range propagation and expression
11895 simplification) based on a dominator tree traversal. This also
11896 performs jump threading (to reduce jumps to jumps). This flag is
11897 enabled by default at @option{-O1} and higher.
11901 Perform dead store elimination (DSE) on trees. A dead store is a store into
11902 a memory location that is later overwritten by another store without
11903 any intervening loads. In this case the earlier store can be deleted. This
11904 flag is enabled by default at @option{-O1} and higher.
11908 Perform loop header copying on trees. This is beneficial since it increases
11909 effectiveness of code motion optimizations. It also saves one jump. This flag
11910 is enabled by default at @option{-O1} and higher. It is not enabled
11911 for @option{-Os}, since it usually increases code size.
11913 @item -ftree-loop-optimize
11914 @opindex ftree-loop-optimize
11915 Perform loop optimizations on trees. This flag is enabled by default
11916 at @option{-O1} and higher.
11918 @item -ftree-loop-linear
11919 @itemx -floop-strip-mine
11920 @itemx -floop-block
11921 @opindex ftree-loop-linear
11922 @opindex floop-strip-mine
11923 @opindex floop-block
11924 Perform loop nest optimizations. Same as
11925 @option{-floop-nest-optimize}. To use this code transformation, GCC has
11926 to be configured with @option{--with-isl} to enable the Graphite loop
11927 transformation infrastructure.
11929 @item -fgraphite-identity
11930 @opindex fgraphite-identity
11931 Enable the identity transformation for graphite. For every SCoP we generate
11932 the polyhedral representation and transform it back to gimple. Using
11933 @option{-fgraphite-identity} we can check the costs or benefits of the
11934 GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
11935 are also performed by the code generator isl, like index splitting and
11936 dead code elimination in loops.
11938 @item -floop-nest-optimize
11939 @opindex floop-nest-optimize
11940 Enable the isl based loop nest optimizer. This is a generic loop nest
11941 optimizer based on the Pluto optimization algorithms. It calculates a loop
11942 structure optimized for data-locality and parallelism. This option
11945 @item -floop-parallelize-all
11946 @opindex floop-parallelize-all
11947 Use the Graphite data dependence analysis to identify loops that can
11948 be parallelized. Parallelize all the loops that can be analyzed to
11949 not contain loop carried dependences without checking that it is
11950 profitable to parallelize the loops.
11952 @item -ftree-coalesce-vars
11953 @opindex ftree-coalesce-vars
11954 While transforming the program out of the SSA representation, attempt to
11955 reduce copying by coalescing versions of different user-defined
11956 variables, instead of just compiler temporaries. This may severely
11957 limit the ability to debug an optimized program compiled with
11958 @option{-fno-var-tracking-assignments}. In the negated form, this flag
11959 prevents SSA coalescing of user variables. This option is enabled by
11960 default if optimization is enabled, and it does very little otherwise.
11962 @item -ftree-loop-if-convert
11963 @opindex ftree-loop-if-convert
11964 Attempt to transform conditional jumps in the innermost loops to
11965 branch-less equivalents. The intent is to remove control-flow from
11966 the innermost loops in order to improve the ability of the
11967 vectorization pass to handle these loops. This is enabled by default
11968 if vectorization is enabled.
11970 @item -ftree-loop-distribution
11971 @opindex ftree-loop-distribution
11972 Perform loop distribution. This flag can improve cache performance on
11973 big loop bodies and allow further loop optimizations, like
11974 parallelization or vectorization, to take place. For example, the loop
11990 This flag is enabled by default at @option{-O3}.
11991 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
11993 @item -ftree-loop-distribute-patterns
11994 @opindex ftree-loop-distribute-patterns
11995 Perform loop distribution of patterns that can be code generated with
11996 calls to a library. This flag is enabled by default at @option{-O2} and
11997 higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
11999 This pass distributes the initialization loops and generates a call to
12000 memset zero. For example, the loop
12016 and the initialization loop is transformed into a call to memset zero.
12017 This flag is enabled by default at @option{-O3}.
12018 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12020 @item -floop-interchange
12021 @opindex floop-interchange
12022 Perform loop interchange outside of graphite. This flag can improve cache
12023 performance on loop nest and allow further loop optimizations, like
12024 vectorization, to take place. For example, the loop
12026 for (int i = 0; i < N; i++)
12027 for (int j = 0; j < N; j++)
12028 for (int k = 0; k < N; k++)
12029 c[i][j] = c[i][j] + a[i][k]*b[k][j];
12033 for (int i = 0; i < N; i++)
12034 for (int k = 0; k < N; k++)
12035 for (int j = 0; j < N; j++)
12036 c[i][j] = c[i][j] + a[i][k]*b[k][j];
12038 This flag is enabled by default at @option{-O3}.
12039 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12041 @item -floop-unroll-and-jam
12042 @opindex floop-unroll-and-jam
12043 Apply unroll and jam transformations on feasible loops. In a loop
12044 nest this unrolls the outer loop by some factor and fuses the resulting
12045 multiple inner loops. This flag is enabled by default at @option{-O3}.
12046 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12048 @item -ftree-loop-im
12049 @opindex ftree-loop-im
12050 Perform loop invariant motion on trees. This pass moves only invariants that
12051 are hard to handle at RTL level (function calls, operations that expand to
12052 nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
12053 operands of conditions that are invariant out of the loop, so that we can use
12054 just trivial invariantness analysis in loop unswitching. The pass also includes
12057 @item -ftree-loop-ivcanon
12058 @opindex ftree-loop-ivcanon
12059 Create a canonical counter for number of iterations in loops for which
12060 determining number of iterations requires complicated analysis. Later
12061 optimizations then may determine the number easily. Useful especially
12062 in connection with unrolling.
12064 @item -ftree-scev-cprop
12065 @opindex ftree-scev-cprop
12066 Perform final value replacement. If a variable is modified in a loop
12067 in such a way that its value when exiting the loop can be determined using
12068 only its initial value and the number of loop iterations, replace uses of
12069 the final value by such a computation, provided it is sufficiently cheap.
12070 This reduces data dependencies and may allow further simplifications.
12071 Enabled by default at @option{-O1} and higher.
12075 Perform induction variable optimizations (strength reduction, induction
12076 variable merging and induction variable elimination) on trees.
12078 @item -ftree-parallelize-loops=n
12079 @opindex ftree-parallelize-loops
12080 Parallelize loops, i.e., split their iteration space to run in n threads.
12081 This is only possible for loops whose iterations are independent
12082 and can be arbitrarily reordered. The optimization is only
12083 profitable on multiprocessor machines, for loops that are CPU-intensive,
12084 rather than constrained e.g.@: by memory bandwidth. This option
12085 implies @option{-pthread}, and thus is only supported on targets
12086 that have support for @option{-pthread}.
12090 Perform function-local points-to analysis on trees. This flag is
12091 enabled by default at @option{-O1} and higher, except for @option{-Og}.
12095 Perform scalar replacement of aggregates. This pass replaces structure
12096 references with scalars to prevent committing structures to memory too
12097 early. This flag is enabled by default at @option{-O1} and higher,
12098 except for @option{-Og}.
12100 @item -fstore-merging
12101 @opindex fstore-merging
12102 Perform merging of narrow stores to consecutive memory addresses. This pass
12103 merges contiguous stores of immediate values narrower than a word into fewer
12104 wider stores to reduce the number of instructions. This is enabled by default
12105 at @option{-O2} and higher as well as @option{-Os}.
12109 Perform temporary expression replacement during the SSA->normal phase. Single
12110 use/single def temporaries are replaced at their use location with their
12111 defining expression. This results in non-GIMPLE code, but gives the expanders
12112 much more complex trees to work on resulting in better RTL generation. This is
12113 enabled by default at @option{-O1} and higher.
12116 @opindex ftree-slsr
12117 Perform straight-line strength reduction on trees. This recognizes related
12118 expressions involving multiplications and replaces them by less expensive
12119 calculations when possible. This is enabled by default at @option{-O1} and
12122 @item -ftree-vectorize
12123 @opindex ftree-vectorize
12124 Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
12125 and @option{-ftree-slp-vectorize} if not explicitly specified.
12127 @item -ftree-loop-vectorize
12128 @opindex ftree-loop-vectorize
12129 Perform loop vectorization on trees. This flag is enabled by default at
12130 @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
12131 and @option{-fauto-profile}.
12133 @item -ftree-slp-vectorize
12134 @opindex ftree-slp-vectorize
12135 Perform basic block vectorization on trees. This flag is enabled by default at
12136 @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
12137 and @option{-fauto-profile}.
12139 @item -ftrivial-auto-var-init=@var{choice}
12140 @opindex ftrivial-auto-var-init
12141 Initialize automatic variables with either a pattern or with zeroes to increase
12142 the security and predictability of a program by preventing uninitialized memory
12143 disclosure and use.
12144 GCC still considers an automatic variable that doesn't have an explicit
12145 initializer as uninitialized, @option{-Wuninitialized} will still report
12146 warning messages on such automatic variables.
12147 With this option, GCC will also initialize any padding of automatic variables
12148 that have structure or union types to zeroes.
12150 The three values of @var{choice} are:
12154 @samp{uninitialized} doesn't initialize any automatic variables.
12155 This is C and C++'s default.
12158 @samp{pattern} Initialize automatic variables with values which will likely
12159 transform logic bugs into crashes down the line, are easily recognized in a
12160 crash dump and without being values that programmers can rely on for useful
12162 The current value is byte-repeatable pattern with byte "0xFE".
12163 The values used for pattern initialization might be changed in the future.
12166 @samp{zero} Initialize automatic variables with zeroes.
12169 The default is @samp{uninitialized}.
12171 You can control this behavior for a specific variable by using the variable
12172 attribute @code{uninitialized} (@pxref{Variable Attributes}).
12174 @item -fvect-cost-model=@var{model}
12175 @opindex fvect-cost-model
12176 Alter the cost model used for vectorization. The @var{model} argument
12177 should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
12179 With the @samp{unlimited} model the vectorized code-path is assumed
12180 to be profitable while with the @samp{dynamic} model a runtime check
12181 guards the vectorized code-path to enable it only for iteration
12182 counts that will likely execute faster than when executing the original
12183 scalar loop. The @samp{cheap} model disables vectorization of
12184 loops where doing so would be cost prohibitive for example due to
12185 required runtime checks for data dependence or alignment but otherwise
12186 is equal to the @samp{dynamic} model. The @samp{very-cheap} model only
12187 allows vectorization if the vector code would entirely replace the
12188 scalar code that is being vectorized. For example, if each iteration
12189 of a vectorized loop would only be able to handle exactly four iterations
12190 of the scalar loop, the @samp{very-cheap} model would only allow
12191 vectorization if the scalar iteration count is known to be a multiple
12194 The default cost model depends on other optimization flags and is
12195 either @samp{dynamic} or @samp{cheap}.
12197 @item -fsimd-cost-model=@var{model}
12198 @opindex fsimd-cost-model
12199 Alter the cost model used for vectorization of loops marked with the OpenMP
12200 simd directive. The @var{model} argument should be one of
12201 @samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
12202 have the same meaning as described in @option{-fvect-cost-model} and by
12203 default a cost model defined with @option{-fvect-cost-model} is used.
12207 Perform Value Range Propagation on trees. This is similar to the
12208 constant propagation pass, but instead of values, ranges of values are
12209 propagated. This allows the optimizers to remove unnecessary range
12210 checks like array bound checks and null pointer checks. This is
12211 enabled by default at @option{-O2} and higher. Null pointer check
12212 elimination is only done if @option{-fdelete-null-pointer-checks} is
12215 @item -fsplit-paths
12216 @opindex fsplit-paths
12217 Split paths leading to loop backedges. This can improve dead code
12218 elimination and common subexpression elimination. This is enabled by
12219 default at @option{-O3} and above.
12221 @item -fsplit-ivs-in-unroller
12222 @opindex fsplit-ivs-in-unroller
12223 Enables expression of values of induction variables in later iterations
12224 of the unrolled loop using the value in the first iteration. This breaks
12225 long dependency chains, thus improving efficiency of the scheduling passes.
12227 A combination of @option{-fweb} and CSE is often sufficient to obtain the
12228 same effect. However, that is not reliable in cases where the loop body
12229 is more complicated than a single basic block. It also does not work at all
12230 on some architectures due to restrictions in the CSE pass.
12232 This optimization is enabled by default.
12234 @item -fvariable-expansion-in-unroller
12235 @opindex fvariable-expansion-in-unroller
12236 With this option, the compiler creates multiple copies of some
12237 local variables when unrolling a loop, which can result in superior code.
12239 This optimization is enabled by default for PowerPC targets, but disabled
12240 by default otherwise.
12242 @item -fpartial-inlining
12243 @opindex fpartial-inlining
12244 Inline parts of functions. This option has any effect only
12245 when inlining itself is turned on by the @option{-finline-functions}
12246 or @option{-finline-small-functions} options.
12248 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12250 @item -fpredictive-commoning
12251 @opindex fpredictive-commoning
12252 Perform predictive commoning optimization, i.e., reusing computations
12253 (especially memory loads and stores) performed in previous
12254 iterations of loops.
12256 This option is enabled at level @option{-O3}.
12257 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12259 @item -fprefetch-loop-arrays
12260 @opindex fprefetch-loop-arrays
12261 If supported by the target machine, generate instructions to prefetch
12262 memory to improve the performance of loops that access large arrays.
12264 This option may generate better or worse code; results are highly
12265 dependent on the structure of loops within the source code.
12267 Disabled at level @option{-Os}.
12269 @item -fno-printf-return-value
12270 @opindex fno-printf-return-value
12271 @opindex fprintf-return-value
12272 Do not substitute constants for known return value of formatted output
12273 functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
12274 @code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
12275 transformation allows GCC to optimize or even eliminate branches based
12276 on the known return value of these functions called with arguments that
12277 are either constant, or whose values are known to be in a range that
12278 makes determining the exact return value possible. For example, when
12279 @option{-fprintf-return-value} is in effect, both the branch and the
12280 body of the @code{if} statement (but not the call to @code{snprint})
12281 can be optimized away when @code{i} is a 32-bit or smaller integer
12282 because the return value is guaranteed to be at most 8.
12286 if (snprintf (buf, "%08x", i) >= sizeof buf)
12290 The @option{-fprintf-return-value} option relies on other optimizations
12291 and yields best results with @option{-O2} and above. It works in tandem
12292 with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
12293 options. The @option{-fprintf-return-value} option is enabled by default.
12295 @item -fno-peephole
12296 @itemx -fno-peephole2
12297 @opindex fno-peephole
12299 @opindex fno-peephole2
12300 @opindex fpeephole2
12301 Disable any machine-specific peephole optimizations. The difference
12302 between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
12303 are implemented in the compiler; some targets use one, some use the
12304 other, a few use both.
12306 @option{-fpeephole} is enabled by default.
12307 @option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12309 @item -fno-guess-branch-probability
12310 @opindex fno-guess-branch-probability
12311 @opindex fguess-branch-probability
12312 Do not guess branch probabilities using heuristics.
12314 GCC uses heuristics to guess branch probabilities if they are
12315 not provided by profiling feedback (@option{-fprofile-arcs}). These
12316 heuristics are based on the control flow graph. If some branch probabilities
12317 are specified by @code{__builtin_expect}, then the heuristics are
12318 used to guess branch probabilities for the rest of the control flow graph,
12319 taking the @code{__builtin_expect} info into account. The interactions
12320 between the heuristics and @code{__builtin_expect} can be complex, and in
12321 some cases, it may be useful to disable the heuristics so that the effects
12322 of @code{__builtin_expect} are easier to understand.
12324 It is also possible to specify expected probability of the expression
12325 with @code{__builtin_expect_with_probability} built-in function.
12327 The default is @option{-fguess-branch-probability} at levels
12328 @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
12330 @item -freorder-blocks
12331 @opindex freorder-blocks
12332 Reorder basic blocks in the compiled function in order to reduce number of
12333 taken branches and improve code locality.
12335 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12337 @item -freorder-blocks-algorithm=@var{algorithm}
12338 @opindex freorder-blocks-algorithm
12339 Use the specified algorithm for basic block reordering. The
12340 @var{algorithm} argument can be @samp{simple}, which does not increase
12341 code size (except sometimes due to secondary effects like alignment),
12342 or @samp{stc}, the ``software trace cache'' algorithm, which tries to
12343 put all often executed code together, minimizing the number of branches
12344 executed by making extra copies of code.
12346 The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
12347 @samp{stc} at levels @option{-O2}, @option{-O3}.
12349 @item -freorder-blocks-and-partition
12350 @opindex freorder-blocks-and-partition
12351 In addition to reordering basic blocks in the compiled function, in order
12352 to reduce number of taken branches, partitions hot and cold basic blocks
12353 into separate sections of the assembly and @file{.o} files, to improve
12354 paging and cache locality performance.
12356 This optimization is automatically turned off in the presence of
12357 exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
12358 section attribute and on any architecture that does not support named
12359 sections. When @option{-fsplit-stack} is used this option is not
12360 enabled by default (to avoid linker errors), but may be enabled
12361 explicitly (if using a working linker).
12363 Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
12365 @item -freorder-functions
12366 @opindex freorder-functions
12367 Reorder functions in the object file in order to
12368 improve code locality. This is implemented by using special
12369 subsections @code{.text.hot} for most frequently executed functions and
12370 @code{.text.unlikely} for unlikely executed functions. Reordering is done by
12371 the linker so object file format must support named sections and linker must
12372 place them in a reasonable way.
12374 This option isn't effective unless you either provide profile feedback
12375 (see @option{-fprofile-arcs} for details) or manually annotate functions with
12376 @code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
12378 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12380 @item -fstrict-aliasing
12381 @opindex fstrict-aliasing
12382 Allow the compiler to assume the strictest aliasing rules applicable to
12383 the language being compiled. For C (and C++), this activates
12384 optimizations based on the type of expressions. In particular, an
12385 object of one type is assumed never to reside at the same address as an
12386 object of a different type, unless the types are almost the same. For
12387 example, an @code{unsigned int} can alias an @code{int}, but not a
12388 @code{void*} or a @code{double}. A character type may alias any other
12391 @anchor{Type-punning}Pay special attention to code like this:
12404 The practice of reading from a different union member than the one most
12405 recently written to (called ``type-punning'') is common. Even with
12406 @option{-fstrict-aliasing}, type-punning is allowed, provided the memory
12407 is accessed through the union type. So, the code above works as
12408 expected. @xref{Structures unions enumerations and bit-fields
12409 implementation}. However, this code might not:
12420 Similarly, access by taking the address, casting the resulting pointer
12421 and dereferencing the result has undefined behavior, even if the cast
12422 uses a union type, e.g.:
12426 return ((union a_union *) &d)->i;
12430 The @option{-fstrict-aliasing} option is enabled at levels
12431 @option{-O2}, @option{-O3}, @option{-Os}.
12433 @item -fipa-strict-aliasing
12434 @opindex fipa-strict-aliasing
12435 Controls whether rules of @option{-fstrict-aliasing} are applied across
12436 function boundaries. Note that if multiple functions gets inlined into a
12437 single function the memory accesses are no longer considered to be crossing a
12440 The @option{-fipa-strict-aliasing} option is enabled by default and is
12441 effective only in combination with @option{-fstrict-aliasing}.
12443 @item -falign-functions
12444 @itemx -falign-functions=@var{n}
12445 @itemx -falign-functions=@var{n}:@var{m}
12446 @itemx -falign-functions=@var{n}:@var{m}:@var{n2}
12447 @itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
12448 @opindex falign-functions
12449 Align the start of functions to the next power-of-two greater than or
12450 equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
12451 least the first @var{m} bytes of the function can be fetched by the CPU
12452 without crossing an @var{n}-byte alignment boundary.
12454 If @var{m} is not specified, it defaults to @var{n}.
12456 Examples: @option{-falign-functions=32} aligns functions to the next
12457 32-byte boundary, @option{-falign-functions=24} aligns to the next
12458 32-byte boundary only if this can be done by skipping 23 bytes or less,
12459 @option{-falign-functions=32:7} aligns to the next
12460 32-byte boundary only if this can be done by skipping 6 bytes or less.
12462 The second pair of @var{n2}:@var{m2} values allows you to specify
12463 a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
12464 the next 64-byte boundary if this can be done by skipping 6 bytes or less,
12465 otherwise aligns to the next 32-byte boundary if this can be done
12466 by skipping 2 bytes or less.
12467 If @var{m2} is not specified, it defaults to @var{n2}.
12469 Some assemblers only support this flag when @var{n} is a power of two;
12470 in that case, it is rounded up.
12472 @option{-fno-align-functions} and @option{-falign-functions=1} are
12473 equivalent and mean that functions are not aligned.
12475 If @var{n} is not specified or is zero, use a machine-dependent default.
12476 The maximum allowed @var{n} option value is 65536.
12478 Enabled at levels @option{-O2}, @option{-O3}.
12480 @item -flimit-function-alignment
12481 If this option is enabled, the compiler tries to avoid unnecessarily
12482 overaligning functions. It attempts to instruct the assembler to align
12483 by the amount specified by @option{-falign-functions}, but not to
12484 skip more bytes than the size of the function.
12486 @item -falign-labels
12487 @itemx -falign-labels=@var{n}
12488 @itemx -falign-labels=@var{n}:@var{m}
12489 @itemx -falign-labels=@var{n}:@var{m}:@var{n2}
12490 @itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
12491 @opindex falign-labels
12492 Align all branch targets to a power-of-two boundary.
12494 Parameters of this option are analogous to the @option{-falign-functions} option.
12495 @option{-fno-align-labels} and @option{-falign-labels=1} are
12496 equivalent and mean that labels are not aligned.
12498 If @option{-falign-loops} or @option{-falign-jumps} are applicable and
12499 are greater than this value, then their values are used instead.
12501 If @var{n} is not specified or is zero, use a machine-dependent default
12502 which is very likely to be @samp{1}, meaning no alignment.
12503 The maximum allowed @var{n} option value is 65536.
12505 Enabled at levels @option{-O2}, @option{-O3}.
12507 @item -falign-loops
12508 @itemx -falign-loops=@var{n}
12509 @itemx -falign-loops=@var{n}:@var{m}
12510 @itemx -falign-loops=@var{n}:@var{m}:@var{n2}
12511 @itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
12512 @opindex falign-loops
12513 Align loops to a power-of-two boundary. If the loops are executed
12514 many times, this makes up for any execution of the dummy padding
12517 If @option{-falign-labels} is greater than this value, then its value
12520 Parameters of this option are analogous to the @option{-falign-functions} option.
12521 @option{-fno-align-loops} and @option{-falign-loops=1} are
12522 equivalent and mean that loops are not aligned.
12523 The maximum allowed @var{n} option value is 65536.
12525 If @var{n} is not specified or is zero, use a machine-dependent default.
12527 Enabled at levels @option{-O2}, @option{-O3}.
12529 @item -falign-jumps
12530 @itemx -falign-jumps=@var{n}
12531 @itemx -falign-jumps=@var{n}:@var{m}
12532 @itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
12533 @itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
12534 @opindex falign-jumps
12535 Align branch targets to a power-of-two boundary, for branch targets
12536 where the targets can only be reached by jumping. In this case,
12537 no dummy operations need be executed.
12539 If @option{-falign-labels} is greater than this value, then its value
12542 Parameters of this option are analogous to the @option{-falign-functions} option.
12543 @option{-fno-align-jumps} and @option{-falign-jumps=1} are
12544 equivalent and mean that loops are not aligned.
12546 If @var{n} is not specified or is zero, use a machine-dependent default.
12547 The maximum allowed @var{n} option value is 65536.
12549 Enabled at levels @option{-O2}, @option{-O3}.
12551 @item -fno-allocation-dce
12552 @opindex fno-allocation-dce
12553 Do not remove unused C++ allocations in dead code elimination.
12555 @item -fallow-store-data-races
12556 @opindex fallow-store-data-races
12557 Allow the compiler to perform optimizations that may introduce new data races
12558 on stores, without proving that the variable cannot be concurrently accessed
12559 by other threads. Does not affect optimization of local data. It is safe to
12560 use this option if it is known that global data will not be accessed by
12563 Examples of optimizations enabled by @option{-fallow-store-data-races} include
12564 hoisting or if-conversions that may cause a value that was already in memory
12565 to be re-written with that same value. Such re-writing is safe in a single
12566 threaded context but may be unsafe in a multi-threaded context. Note that on
12567 some processors, if-conversions may be required in order to enable
12570 Enabled at level @option{-Ofast}.
12572 @item -funit-at-a-time
12573 @opindex funit-at-a-time
12574 This option is left for compatibility reasons. @option{-funit-at-a-time}
12575 has no effect, while @option{-fno-unit-at-a-time} implies
12576 @option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
12578 Enabled by default.
12580 @item -fno-toplevel-reorder
12581 @opindex fno-toplevel-reorder
12582 @opindex ftoplevel-reorder
12583 Do not reorder top-level functions, variables, and @code{asm}
12584 statements. Output them in the same order that they appear in the
12585 input file. When this option is used, unreferenced static variables
12586 are not removed. This option is intended to support existing code
12587 that relies on a particular ordering. For new code, it is better to
12588 use attributes when possible.
12590 @option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
12591 also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
12592 Additionally @option{-fno-toplevel-reorder} implies
12593 @option{-fno-section-anchors}.
12597 Constructs webs as commonly used for register allocation purposes and assign
12598 each web individual pseudo register. This allows the register allocation pass
12599 to operate on pseudos directly, but also strengthens several other optimization
12600 passes, such as CSE, loop optimizer and trivial dead code remover. It can,
12601 however, make debugging impossible, since variables no longer stay in a
12604 Enabled by default with @option{-funroll-loops}.
12606 @item -fwhole-program
12607 @opindex fwhole-program
12608 Assume that the current compilation unit represents the whole program being
12609 compiled. All public functions and variables with the exception of @code{main}
12610 and those merged by attribute @code{externally_visible} become static functions
12611 and in effect are optimized more aggressively by interprocedural optimizers.
12613 This option should not be used in combination with @option{-flto}.
12614 Instead relying on a linker plugin should provide safer and more precise
12617 @item -flto[=@var{n}]
12619 This option runs the standard link-time optimizer. When invoked
12620 with source code, it generates GIMPLE (one of GCC's internal
12621 representations) and writes it to special ELF sections in the object
12622 file. When the object files are linked together, all the function
12623 bodies are read from these ELF sections and instantiated as if they
12624 had been part of the same translation unit.
12626 To use the link-time optimizer, @option{-flto} and optimization
12627 options should be specified at compile time and during the final link.
12628 It is recommended that you compile all the files participating in the
12629 same link with the same options and also specify those options at
12634 gcc -c -O2 -flto foo.c
12635 gcc -c -O2 -flto bar.c
12636 gcc -o myprog -flto -O2 foo.o bar.o
12639 The first two invocations to GCC save a bytecode representation
12640 of GIMPLE into special ELF sections inside @file{foo.o} and
12641 @file{bar.o}. The final invocation reads the GIMPLE bytecode from
12642 @file{foo.o} and @file{bar.o}, merges the two files into a single
12643 internal image, and compiles the result as usual. Since both
12644 @file{foo.o} and @file{bar.o} are merged into a single image, this
12645 causes all the interprocedural analyses and optimizations in GCC to
12646 work across the two files as if they were a single one. This means,
12647 for example, that the inliner is able to inline functions in
12648 @file{bar.o} into functions in @file{foo.o} and vice-versa.
12650 Another (simpler) way to enable link-time optimization is:
12653 gcc -o myprog -flto -O2 foo.c bar.c
12656 The above generates bytecode for @file{foo.c} and @file{bar.c},
12657 merges them together into a single GIMPLE representation and optimizes
12658 them as usual to produce @file{myprog}.
12660 The important thing to keep in mind is that to enable link-time
12661 optimizations you need to use the GCC driver to perform the link step.
12662 GCC automatically performs link-time optimization if any of the
12663 objects involved were compiled with the @option{-flto} command-line option.
12664 You can always override
12665 the automatic decision to do link-time optimization
12666 by passing @option{-fno-lto} to the link command.
12668 To make whole program optimization effective, it is necessary to make
12669 certain whole program assumptions. The compiler needs to know
12670 what functions and variables can be accessed by libraries and runtime
12671 outside of the link-time optimized unit. When supported by the linker,
12672 the linker plugin (see @option{-fuse-linker-plugin}) passes information
12673 to the compiler about used and externally visible symbols. When
12674 the linker plugin is not available, @option{-fwhole-program} should be
12675 used to allow the compiler to make these assumptions, which leads
12676 to more aggressive optimization decisions.
12678 When a file is compiled with @option{-flto} without
12679 @option{-fuse-linker-plugin}, the generated object file is larger than
12680 a regular object file because it contains GIMPLE bytecodes and the usual
12681 final code (see @option{-ffat-lto-objects}). This means that
12682 object files with LTO information can be linked as normal object
12683 files; if @option{-fno-lto} is passed to the linker, no
12684 interprocedural optimizations are applied. Note that when
12685 @option{-fno-fat-lto-objects} is enabled the compile stage is faster
12686 but you cannot perform a regular, non-LTO link on them.
12688 When producing the final binary, GCC only
12689 applies link-time optimizations to those files that contain bytecode.
12690 Therefore, you can mix and match object files and libraries with
12691 GIMPLE bytecodes and final object code. GCC automatically selects
12692 which files to optimize in LTO mode and which files to link without
12693 further processing.
12695 Generally, options specified at link time override those
12696 specified at compile time, although in some cases GCC attempts to infer
12697 link-time options from the settings used to compile the input files.
12699 If you do not specify an optimization level option @option{-O} at
12700 link time, then GCC uses the highest optimization level
12701 used when compiling the object files. Note that it is generally
12702 ineffective to specify an optimization level option only at link time and
12703 not at compile time, for two reasons. First, compiling without
12704 optimization suppresses compiler passes that gather information
12705 needed for effective optimization at link time. Second, some early
12706 optimization passes can be performed only at compile time and
12709 There are some code generation flags preserved by GCC when
12710 generating bytecodes, as they need to be used during the final link.
12711 Currently, the following options and their settings are taken from
12712 the first object file that explicitly specifies them:
12713 @option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
12714 @option{-fgnu-tm} and all the @option{-m} target flags.
12716 The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
12717 @option{-fPIE} are combined based on the following scheme:
12720 @option{-fPIC} + @option{-fpic} = @option{-fpic}
12721 @option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
12722 @option{-fpic/-fPIC} + (no option) = (no option)
12723 @option{-fPIC} + @option{-fPIE} = @option{-fPIE}
12724 @option{-fpic} + @option{-fPIE} = @option{-fpie}
12725 @option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
12728 Certain ABI-changing flags are required to match in all compilation units,
12729 and trying to override this at link time with a conflicting value
12730 is ignored. This includes options such as @option{-freg-struct-return}
12731 and @option{-fpcc-struct-return}.
12733 Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
12734 @option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
12735 are passed through to the link stage and merged conservatively for
12736 conflicting translation units. Specifically
12737 @option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
12738 precedence; and for example @option{-ffp-contract=off} takes precedence
12739 over @option{-ffp-contract=fast}. You can override them at link time.
12741 Diagnostic options such as @option{-Wstringop-overflow} are passed
12742 through to the link stage and their setting matches that of the
12743 compile-step at function granularity. Note that this matters only
12744 for diagnostics emitted during optimization. Note that code
12745 transforms such as inlining can lead to warnings being enabled
12746 or disabled for regions if code not consistent with the setting
12749 When you need to pass options to the assembler via @option{-Wa} or
12750 @option{-Xassembler} make sure to either compile such translation
12751 units with @option{-fno-lto} or consistently use the same assembler
12752 options on all translation units. You can alternatively also
12753 specify assembler options at LTO link time.
12755 To enable debug info generation you need to supply @option{-g} at
12756 compile time. If any of the input files at link time were built
12757 with debug info generation enabled the link will enable debug info
12758 generation as well. Any elaborate debug info settings
12759 like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
12760 at the linker command line and mixing different settings in different
12761 translation units is discouraged.
12763 If LTO encounters objects with C linkage declared with incompatible
12764 types in separate translation units to be linked together (undefined
12765 behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
12766 issued. The behavior is still undefined at run time. Similar
12767 diagnostics may be raised for other languages.
12769 Another feature of LTO is that it is possible to apply interprocedural
12770 optimizations on files written in different languages:
12774 g++ -c -flto bar.cc
12775 gfortran -c -flto baz.f90
12776 g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
12779 Notice that the final link is done with @command{g++} to get the C++
12780 runtime libraries and @option{-lgfortran} is added to get the Fortran
12781 runtime libraries. In general, when mixing languages in LTO mode, you
12782 should use the same link command options as when mixing languages in a
12783 regular (non-LTO) compilation.
12785 If object files containing GIMPLE bytecode are stored in a library archive, say
12786 @file{libfoo.a}, it is possible to extract and use them in an LTO link if you
12787 are using a linker with plugin support. To create static libraries suitable
12788 for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
12789 and @command{ranlib};
12790 to show the symbols of object files with GIMPLE bytecode, use
12791 @command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
12792 and @command{nm} have been compiled with plugin support. At link time, use the
12793 flag @option{-fuse-linker-plugin} to ensure that the library participates in
12794 the LTO optimization process:
12797 gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
12800 With the linker plugin enabled, the linker extracts the needed
12801 GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
12802 to make them part of the aggregated GIMPLE image to be optimized.
12804 If you are not using a linker with plugin support and/or do not
12805 enable the linker plugin, then the objects inside @file{libfoo.a}
12806 are extracted and linked as usual, but they do not participate
12807 in the LTO optimization process. In order to make a static library suitable
12808 for both LTO optimization and usual linkage, compile its object files with
12809 @option{-flto} @option{-ffat-lto-objects}.
12811 Link-time optimizations do not require the presence of the whole program to
12812 operate. If the program does not require any symbols to be exported, it is
12813 possible to combine @option{-flto} and @option{-fwhole-program} to allow
12814 the interprocedural optimizers to use more aggressive assumptions which may
12815 lead to improved optimization opportunities.
12816 Use of @option{-fwhole-program} is not needed when linker plugin is
12817 active (see @option{-fuse-linker-plugin}).
12819 The current implementation of LTO makes no
12820 attempt to generate bytecode that is portable between different
12821 types of hosts. The bytecode files are versioned and there is a
12822 strict version check, so bytecode files generated in one version of
12823 GCC do not work with an older or newer version of GCC.
12825 Link-time optimization does not work well with generation of debugging
12826 information on systems other than those using a combination of ELF and
12829 If you specify the optional @var{n}, the optimization and code
12830 generation done at link time is executed in parallel using @var{n}
12831 parallel jobs by utilizing an installed @command{make} program. The
12832 environment variable @env{MAKE} may be used to override the program
12835 You can also specify @option{-flto=jobserver} to use GNU make's
12836 job server mode to determine the number of parallel jobs. This
12837 is useful when the Makefile calling GCC is already executing in parallel.
12838 You must prepend a @samp{+} to the command recipe in the parent Makefile
12839 for this to work. This option likely only works if @env{MAKE} is
12840 GNU make. Even without the option value, GCC tries to automatically
12841 detect a running GNU make's job server.
12843 Use @option{-flto=auto} to use GNU make's job server, if available,
12844 or otherwise fall back to autodetection of the number of CPU threads
12845 present in your system.
12847 @item -flto-partition=@var{alg}
12848 @opindex flto-partition
12849 Specify the partitioning algorithm used by the link-time optimizer.
12850 The value is either @samp{1to1} to specify a partitioning mirroring
12851 the original source files or @samp{balanced} to specify partitioning
12852 into equally sized chunks (whenever possible) or @samp{max} to create
12853 new partition for every symbol where possible. Specifying @samp{none}
12854 as an algorithm disables partitioning and streaming completely.
12855 The default value is @samp{balanced}. While @samp{1to1} can be used
12856 as an workaround for various code ordering issues, the @samp{max}
12857 partitioning is intended for internal testing only.
12858 The value @samp{one} specifies that exactly one partition should be
12859 used while the value @samp{none} bypasses partitioning and executes
12860 the link-time optimization step directly from the WPA phase.
12862 @item -flto-compression-level=@var{n}
12863 @opindex flto-compression-level
12864 This option specifies the level of compression used for intermediate
12865 language written to LTO object files, and is only meaningful in
12866 conjunction with LTO mode (@option{-flto}). GCC currently supports two
12867 LTO compression algorithms. For zstd, valid values are 0 (no compression)
12868 to 19 (maximum compression), while zlib supports values from 0 to 9.
12869 Values outside this range are clamped to either minimum or maximum
12870 of the supported values. If the option is not given,
12871 a default balanced compression setting is used.
12873 @item -fuse-linker-plugin
12874 @opindex fuse-linker-plugin
12875 Enables the use of a linker plugin during link-time optimization. This
12876 option relies on plugin support in the linker, which is available in gold
12877 or in GNU ld 2.21 or newer.
12879 This option enables the extraction of object files with GIMPLE bytecode out
12880 of library archives. This improves the quality of optimization by exposing
12881 more code to the link-time optimizer. This information specifies what
12882 symbols can be accessed externally (by non-LTO object or during dynamic
12883 linking). Resulting code quality improvements on binaries (and shared
12884 libraries that use hidden visibility) are similar to @option{-fwhole-program}.
12885 See @option{-flto} for a description of the effect of this flag and how to
12888 This option is enabled by default when LTO support in GCC is enabled
12889 and GCC was configured for use with
12890 a linker supporting plugins (GNU ld 2.21 or newer or gold).
12892 @item -ffat-lto-objects
12893 @opindex ffat-lto-objects
12894 Fat LTO objects are object files that contain both the intermediate language
12895 and the object code. This makes them usable for both LTO linking and normal
12896 linking. This option is effective only when compiling with @option{-flto}
12897 and is ignored at link time.
12899 @option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
12900 requires the complete toolchain to be aware of LTO. It requires a linker with
12901 linker plugin support for basic functionality. Additionally,
12902 @command{nm}, @command{ar} and @command{ranlib}
12903 need to support linker plugins to allow a full-featured build environment
12904 (capable of building static libraries etc). GCC provides the @command{gcc-ar},
12905 @command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
12906 to these tools. With non fat LTO makefiles need to be modified to use them.
12908 Note that modern binutils provide plugin auto-load mechanism.
12909 Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
12910 effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
12911 @command{gcc-ranlib}).
12913 The default is @option{-fno-fat-lto-objects} on targets with linker plugin
12916 @item -fcompare-elim
12917 @opindex fcompare-elim
12918 After register allocation and post-register allocation instruction splitting,
12919 identify arithmetic instructions that compute processor flags similar to a
12920 comparison operation based on that arithmetic. If possible, eliminate the
12921 explicit comparison operation.
12923 This pass only applies to certain targets that cannot explicitly represent
12924 the comparison operation before register allocation is complete.
12926 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12928 @item -fcprop-registers
12929 @opindex fcprop-registers
12930 After register allocation and post-register allocation instruction splitting,
12931 perform a copy-propagation pass to try to reduce scheduling dependencies
12932 and occasionally eliminate the copy.
12934 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12936 @item -fprofile-correction
12937 @opindex fprofile-correction
12938 Profiles collected using an instrumented binary for multi-threaded programs may
12939 be inconsistent due to missed counter updates. When this option is specified,
12940 GCC uses heuristics to correct or smooth out such inconsistencies. By
12941 default, GCC emits an error message when an inconsistent profile is detected.
12943 This option is enabled by @option{-fauto-profile}.
12945 @item -fprofile-partial-training
12946 @opindex fprofile-partial-training
12947 With @code{-fprofile-use} all portions of programs not executed during train
12948 run are optimized agressively for size rather than speed. In some cases it is
12949 not practical to train all possible hot paths in the program. (For
12950 example, program may contain functions specific for a given hardware and
12951 trianing may not cover all hardware configurations program is run on.) With
12952 @code{-fprofile-partial-training} profile feedback will be ignored for all
12953 functions not executed during the train run leading them to be optimized as if
12954 they were compiled without profile feedback. This leads to better performance
12955 when train run is not representative but also leads to significantly bigger
12958 @item -fprofile-use
12959 @itemx -fprofile-use=@var{path}
12960 @opindex fprofile-use
12961 Enable profile feedback-directed optimizations,
12962 and the following optimizations, many of which
12963 are generally profitable only with profile feedback available:
12965 @gccoptlist{-fbranch-probabilities -fprofile-values @gol
12966 -funroll-loops -fpeel-loops -ftracer -fvpt @gol
12967 -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp @gol
12968 -fpredictive-commoning -fsplit-loops -funswitch-loops @gol
12969 -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize @gol
12970 -fvect-cost-model=dynamic -ftree-loop-distribute-patterns @gol
12971 -fprofile-reorder-functions}
12973 Before you can use this option, you must first generate profiling information.
12974 @xref{Instrumentation Options}, for information about the
12975 @option{-fprofile-generate} option.
12977 By default, GCC emits an error message if the feedback profiles do not
12978 match the source code. This error can be turned into a warning by using
12979 @option{-Wno-error=coverage-mismatch}. Note this may result in poorly
12980 optimized code. Additionally, by default, GCC also emits a warning message if
12981 the feedback profiles do not exist (see @option{-Wmissing-profile}).
12983 If @var{path} is specified, GCC looks at the @var{path} to find
12984 the profile feedback data files. See @option{-fprofile-dir}.
12986 @item -fauto-profile
12987 @itemx -fauto-profile=@var{path}
12988 @opindex fauto-profile
12989 Enable sampling-based feedback-directed optimizations,
12990 and the following optimizations,
12991 many of which are generally profitable only with profile feedback available:
12993 @gccoptlist{-fbranch-probabilities -fprofile-values @gol
12994 -funroll-loops -fpeel-loops -ftracer -fvpt @gol
12995 -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp @gol
12996 -fpredictive-commoning -fsplit-loops -funswitch-loops @gol
12997 -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize @gol
12998 -fvect-cost-model=dynamic -ftree-loop-distribute-patterns @gol
12999 -fprofile-correction}
13001 @var{path} is the name of a file containing AutoFDO profile information.
13002 If omitted, it defaults to @file{fbdata.afdo} in the current directory.
13004 Producing an AutoFDO profile data file requires running your program
13005 with the @command{perf} utility on a supported GNU/Linux target system.
13006 For more information, see @uref{https://perf.wiki.kernel.org/}.
13010 perf record -e br_inst_retired:near_taken -b -o perf.data \
13014 Then use the @command{create_gcov} tool to convert the raw profile data
13015 to a format that can be used by GCC.@ You must also supply the
13016 unstripped binary for your program to this tool.
13017 See @uref{https://github.com/google/autofdo}.
13021 create_gcov --binary=your_program.unstripped --profile=perf.data \
13022 --gcov=profile.afdo
13026 The following options control compiler behavior regarding floating-point
13027 arithmetic. These options trade off between speed and
13028 correctness. All must be specifically enabled.
13031 @item -ffloat-store
13032 @opindex ffloat-store
13033 Do not store floating-point variables in registers, and inhibit other
13034 options that might change whether a floating-point value is taken from a
13035 register or memory.
13037 @cindex floating-point precision
13038 This option prevents undesirable excess precision on machines such as
13039 the 68000 where the floating registers (of the 68881) keep more
13040 precision than a @code{double} is supposed to have. Similarly for the
13041 x86 architecture. For most programs, the excess precision does only
13042 good, but a few programs rely on the precise definition of IEEE floating
13043 point. Use @option{-ffloat-store} for such programs, after modifying
13044 them to store all pertinent intermediate computations into variables.
13046 @item -fexcess-precision=@var{style}
13047 @opindex fexcess-precision
13048 This option allows further control over excess precision on machines
13049 where floating-point operations occur in a format with more precision or
13050 range than the IEEE standard and interchange floating-point types. By
13051 default, @option{-fexcess-precision=fast} is in effect; this means that
13052 operations may be carried out in a wider precision than the types specified
13053 in the source if that would result in faster code, and it is unpredictable
13054 when rounding to the types specified in the source code takes place.
13055 When compiling C, if @option{-fexcess-precision=standard} is specified then
13056 excess precision follows the rules specified in ISO C99; in particular,
13057 both casts and assignments cause values to be rounded to their
13058 semantic types (whereas @option{-ffloat-store} only affects
13059 assignments). This option is enabled by default for C if a strict
13060 conformance option such as @option{-std=c99} is used.
13061 @option{-ffast-math} enables @option{-fexcess-precision=fast} by default
13062 regardless of whether a strict conformance option is used.
13065 @option{-fexcess-precision=standard} is not implemented for languages
13066 other than C. On the x86, it has no effect if @option{-mfpmath=sse}
13067 or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
13068 semantics apply without excess precision, and in the latter, rounding
13072 @opindex ffast-math
13073 Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
13074 @option{-ffinite-math-only}, @option{-fno-rounding-math},
13075 @option{-fno-signaling-nans}, @option{-fcx-limited-range} and
13076 @option{-fexcess-precision=fast}.
13078 This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
13080 This option is not turned on by any @option{-O} option besides
13081 @option{-Ofast} since it can result in incorrect output for programs
13082 that depend on an exact implementation of IEEE or ISO rules/specifications
13083 for math functions. It may, however, yield faster code for programs
13084 that do not require the guarantees of these specifications.
13086 @item -fno-math-errno
13087 @opindex fno-math-errno
13088 @opindex fmath-errno
13089 Do not set @code{errno} after calling math functions that are executed
13090 with a single instruction, e.g., @code{sqrt}. A program that relies on
13091 IEEE exceptions for math error handling may want to use this flag
13092 for speed while maintaining IEEE arithmetic compatibility.
13094 This option is not turned on by any @option{-O} option since
13095 it can result in incorrect output for programs that depend on
13096 an exact implementation of IEEE or ISO rules/specifications for
13097 math functions. It may, however, yield faster code for programs
13098 that do not require the guarantees of these specifications.
13100 The default is @option{-fmath-errno}.
13102 On Darwin systems, the math library never sets @code{errno}. There is
13103 therefore no reason for the compiler to consider the possibility that
13104 it might, and @option{-fno-math-errno} is the default.
13106 @item -funsafe-math-optimizations
13107 @opindex funsafe-math-optimizations
13109 Allow optimizations for floating-point arithmetic that (a) assume
13110 that arguments and results are valid and (b) may violate IEEE or
13111 ANSI standards. When used at link time, it may include libraries
13112 or startup files that change the default FPU control word or other
13113 similar optimizations.
13115 This option is not turned on by any @option{-O} option since
13116 it can result in incorrect output for programs that depend on
13117 an exact implementation of IEEE or ISO rules/specifications for
13118 math functions. It may, however, yield faster code for programs
13119 that do not require the guarantees of these specifications.
13120 Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
13121 @option{-fassociative-math} and @option{-freciprocal-math}.
13123 The default is @option{-fno-unsafe-math-optimizations}.
13125 @item -fassociative-math
13126 @opindex fassociative-math
13128 Allow re-association of operands in series of floating-point operations.
13129 This violates the ISO C and C++ language standard by possibly changing
13130 computation result. NOTE: re-ordering may change the sign of zero as
13131 well as ignore NaNs and inhibit or create underflow or overflow (and
13132 thus cannot be used on code that relies on rounding behavior like
13133 @code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
13134 and thus may not be used when ordered comparisons are required.
13135 This option requires that both @option{-fno-signed-zeros} and
13136 @option{-fno-trapping-math} be in effect. Moreover, it doesn't make
13137 much sense with @option{-frounding-math}. For Fortran the option
13138 is automatically enabled when both @option{-fno-signed-zeros} and
13139 @option{-fno-trapping-math} are in effect.
13141 The default is @option{-fno-associative-math}.
13143 @item -freciprocal-math
13144 @opindex freciprocal-math
13146 Allow the reciprocal of a value to be used instead of dividing by
13147 the value if this enables optimizations. For example @code{x / y}
13148 can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
13149 is subject to common subexpression elimination. Note that this loses
13150 precision and increases the number of flops operating on the value.
13152 The default is @option{-fno-reciprocal-math}.
13154 @item -ffinite-math-only
13155 @opindex ffinite-math-only
13156 Allow optimizations for floating-point arithmetic that assume
13157 that arguments and results are not NaNs or +-Infs.
13159 This option is not turned on by any @option{-O} option since
13160 it can result in incorrect output for programs that depend on
13161 an exact implementation of IEEE or ISO rules/specifications for
13162 math functions. It may, however, yield faster code for programs
13163 that do not require the guarantees of these specifications.
13165 The default is @option{-fno-finite-math-only}.
13167 @item -fno-signed-zeros
13168 @opindex fno-signed-zeros
13169 @opindex fsigned-zeros
13170 Allow optimizations for floating-point arithmetic that ignore the
13171 signedness of zero. IEEE arithmetic specifies the behavior of
13172 distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
13173 of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
13174 This option implies that the sign of a zero result isn't significant.
13176 The default is @option{-fsigned-zeros}.
13178 @item -fno-trapping-math
13179 @opindex fno-trapping-math
13180 @opindex ftrapping-math
13181 Compile code assuming that floating-point operations cannot generate
13182 user-visible traps. These traps include division by zero, overflow,
13183 underflow, inexact result and invalid operation. This option requires
13184 that @option{-fno-signaling-nans} be in effect. Setting this option may
13185 allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
13187 This option should never be turned on by any @option{-O} option since
13188 it can result in incorrect output for programs that depend on
13189 an exact implementation of IEEE or ISO rules/specifications for
13192 The default is @option{-ftrapping-math}.
13194 @item -frounding-math
13195 @opindex frounding-math
13196 Disable transformations and optimizations that assume default floating-point
13197 rounding behavior. This is round-to-zero for all floating point
13198 to integer conversions, and round-to-nearest for all other arithmetic
13199 truncations. This option should be specified for programs that change
13200 the FP rounding mode dynamically, or that may be executed with a
13201 non-default rounding mode. This option disables constant folding of
13202 floating-point expressions at compile time (which may be affected by
13203 rounding mode) and arithmetic transformations that are unsafe in the
13204 presence of sign-dependent rounding modes.
13206 The default is @option{-fno-rounding-math}.
13208 This option is experimental and does not currently guarantee to
13209 disable all GCC optimizations that are affected by rounding mode.
13210 Future versions of GCC may provide finer control of this setting
13211 using C99's @code{FENV_ACCESS} pragma. This command-line option
13212 will be used to specify the default state for @code{FENV_ACCESS}.
13214 @item -fsignaling-nans
13215 @opindex fsignaling-nans
13216 Compile code assuming that IEEE signaling NaNs may generate user-visible
13217 traps during floating-point operations. Setting this option disables
13218 optimizations that may change the number of exceptions visible with
13219 signaling NaNs. This option implies @option{-ftrapping-math}.
13221 This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
13224 The default is @option{-fno-signaling-nans}.
13226 This option is experimental and does not currently guarantee to
13227 disable all GCC optimizations that affect signaling NaN behavior.
13229 @item -fno-fp-int-builtin-inexact
13230 @opindex fno-fp-int-builtin-inexact
13231 @opindex ffp-int-builtin-inexact
13232 Do not allow the built-in functions @code{ceil}, @code{floor},
13233 @code{round} and @code{trunc}, and their @code{float} and @code{long
13234 double} variants, to generate code that raises the ``inexact''
13235 floating-point exception for noninteger arguments. ISO C99 and C11
13236 allow these functions to raise the ``inexact'' exception, but ISO/IEC
13237 TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
13238 ISO C2X, does not allow these functions to do so.
13240 The default is @option{-ffp-int-builtin-inexact}, allowing the
13241 exception to be raised, unless C2X or a later C standard is selected.
13242 This option does nothing unless @option{-ftrapping-math} is in effect.
13244 Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
13245 generate a call to a library function then the ``inexact'' exception
13246 may be raised if the library implementation does not follow TS 18661.
13248 @item -fsingle-precision-constant
13249 @opindex fsingle-precision-constant
13250 Treat floating-point constants as single precision instead of
13251 implicitly converting them to double-precision constants.
13253 @item -fcx-limited-range
13254 @opindex fcx-limited-range
13255 When enabled, this option states that a range reduction step is not
13256 needed when performing complex division. Also, there is no checking
13257 whether the result of a complex multiplication or division is @code{NaN
13258 + I*NaN}, with an attempt to rescue the situation in that case. The
13259 default is @option{-fno-cx-limited-range}, but is enabled by
13260 @option{-ffast-math}.
13262 This option controls the default setting of the ISO C99
13263 @code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
13266 @item -fcx-fortran-rules
13267 @opindex fcx-fortran-rules
13268 Complex multiplication and division follow Fortran rules. Range
13269 reduction is done as part of complex division, but there is no checking
13270 whether the result of a complex multiplication or division is @code{NaN
13271 + I*NaN}, with an attempt to rescue the situation in that case.
13273 The default is @option{-fno-cx-fortran-rules}.
13277 The following options control optimizations that may improve
13278 performance, but are not enabled by any @option{-O} options. This
13279 section includes experimental options that may produce broken code.
13282 @item -fbranch-probabilities
13283 @opindex fbranch-probabilities
13284 After running a program compiled with @option{-fprofile-arcs}
13285 (@pxref{Instrumentation Options}),
13286 you can compile it a second time using
13287 @option{-fbranch-probabilities}, to improve optimizations based on
13288 the number of times each branch was taken. When a program
13289 compiled with @option{-fprofile-arcs} exits, it saves arc execution
13290 counts to a file called @file{@var{sourcename}.gcda} for each source
13291 file. The information in this data file is very dependent on the
13292 structure of the generated code, so you must use the same source code
13293 and the same optimization options for both compilations.
13295 With @option{-fbranch-probabilities}, GCC puts a
13296 @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
13297 These can be used to improve optimization. Currently, they are only
13298 used in one place: in @file{reorg.c}, instead of guessing which path a
13299 branch is most likely to take, the @samp{REG_BR_PROB} values are used to
13300 exactly determine which path is taken more often.
13302 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13304 @item -fprofile-values
13305 @opindex fprofile-values
13306 If combined with @option{-fprofile-arcs}, it adds code so that some
13307 data about values of expressions in the program is gathered.
13309 With @option{-fbranch-probabilities}, it reads back the data gathered
13310 from profiling values of expressions for usage in optimizations.
13312 Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
13313 @option{-fauto-profile}.
13315 @item -fprofile-reorder-functions
13316 @opindex fprofile-reorder-functions
13317 Function reordering based on profile instrumentation collects
13318 first time of execution of a function and orders these functions
13319 in ascending order.
13321 Enabled with @option{-fprofile-use}.
13325 If combined with @option{-fprofile-arcs}, this option instructs the compiler
13326 to add code to gather information about values of expressions.
13328 With @option{-fbranch-probabilities}, it reads back the data gathered
13329 and actually performs the optimizations based on them.
13330 Currently the optimizations include specialization of division operations
13331 using the knowledge about the value of the denominator.
13333 Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
13335 @item -frename-registers
13336 @opindex frename-registers
13337 Attempt to avoid false dependencies in scheduled code by making use
13338 of registers left over after register allocation. This optimization
13339 most benefits processors with lots of registers. Depending on the
13340 debug information format adopted by the target, however, it can
13341 make debugging impossible, since variables no longer stay in
13342 a ``home register''.
13344 Enabled by default with @option{-funroll-loops}.
13346 @item -fschedule-fusion
13347 @opindex fschedule-fusion
13348 Performs a target dependent pass over the instruction stream to schedule
13349 instructions of same type together because target machine can execute them
13350 more efficiently if they are adjacent to each other in the instruction flow.
13352 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13356 Perform tail duplication to enlarge superblock size. This transformation
13357 simplifies the control flow of the function allowing other optimizations to do
13360 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13362 @item -funroll-loops
13363 @opindex funroll-loops
13364 Unroll loops whose number of iterations can be determined at compile time or
13365 upon entry to the loop. @option{-funroll-loops} implies
13366 @option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
13367 It also turns on complete loop peeling (i.e.@: complete removal of loops with
13368 a small constant number of iterations). This option makes code larger, and may
13369 or may not make it run faster.
13371 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13373 @item -funroll-all-loops
13374 @opindex funroll-all-loops
13375 Unroll all loops, even if their number of iterations is uncertain when
13376 the loop is entered. This usually makes programs run more slowly.
13377 @option{-funroll-all-loops} implies the same options as
13378 @option{-funroll-loops}.
13381 @opindex fpeel-loops
13382 Peels loops for which there is enough information that they do not
13383 roll much (from profile feedback or static analysis). It also turns on
13384 complete loop peeling (i.e.@: complete removal of loops with small constant
13385 number of iterations).
13387 Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
13389 @item -fmove-loop-invariants
13390 @opindex fmove-loop-invariants
13391 Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
13392 at level @option{-O1} and higher, except for @option{-Og}.
13394 @item -fmove-loop-stores
13395 @opindex fmove-loop-stores
13396 Enables the loop store motion pass in the GIMPLE loop optimizer. This
13397 moves invariant stores to after the end of the loop in exchange for
13398 carrying the stored value in a register across the iteration.
13399 Note for this option to have an effect @option{-ftree-loop-im} has to
13400 be enabled as well. Enabled at level @option{-O1} and higher, except
13403 @item -fsplit-loops
13404 @opindex fsplit-loops
13405 Split a loop into two if it contains a condition that's always true
13406 for one side of the iteration space and false for the other.
13408 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13410 @item -funswitch-loops
13411 @opindex funswitch-loops
13412 Move branches with loop invariant conditions out of the loop, with duplicates
13413 of the loop on both branches (modified according to result of the condition).
13415 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13417 @item -fversion-loops-for-strides
13418 @opindex fversion-loops-for-strides
13419 If a loop iterates over an array with a variable stride, create another
13420 version of the loop that assumes the stride is always one. For example:
13423 for (int i = 0; i < n; ++i)
13424 x[i * stride] = @dots{};
13431 for (int i = 0; i < n; ++i)
13434 for (int i = 0; i < n; ++i)
13435 x[i * stride] = @dots{};
13438 This is particularly useful for assumed-shape arrays in Fortran where
13439 (for example) it allows better vectorization assuming contiguous accesses.
13440 This flag is enabled by default at @option{-O3}.
13441 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13443 @item -ffunction-sections
13444 @itemx -fdata-sections
13445 @opindex ffunction-sections
13446 @opindex fdata-sections
13447 Place each function or data item into its own section in the output
13448 file if the target supports arbitrary sections. The name of the
13449 function or the name of the data item determines the section's name
13450 in the output file.
13452 Use these options on systems where the linker can perform optimizations to
13453 improve locality of reference in the instruction space. Most systems using the
13454 ELF object format have linkers with such optimizations. On AIX, the linker
13455 rearranges sections (CSECTs) based on the call graph. The performance impact
13458 Together with a linker garbage collection (linker @option{--gc-sections}
13459 option) these options may lead to smaller statically-linked executables (after
13462 On ELF/DWARF systems these options do not degenerate the quality of the debug
13463 information. There could be issues with other object files/debug info formats.
13465 Only use these options when there are significant benefits from doing so. When
13466 you specify these options, the assembler and linker create larger object and
13467 executable files and are also slower. These options affect code generation.
13468 They prevent optimizations by the compiler and assembler using relative
13469 locations inside a translation unit since the locations are unknown until
13470 link time. An example of such an optimization is relaxing calls to short call
13474 @opindex fstdarg-opt
13475 Optimize the prologue of variadic argument functions with respect to usage of
13478 @item -fsection-anchors
13479 @opindex fsection-anchors
13480 Try to reduce the number of symbolic address calculations by using
13481 shared ``anchor'' symbols to address nearby objects. This transformation
13482 can help to reduce the number of GOT entries and GOT accesses on some
13485 For example, the implementation of the following function @code{foo}:
13488 static int a, b, c;
13489 int foo (void) @{ return a + b + c; @}
13493 usually calculates the addresses of all three variables, but if you
13494 compile it with @option{-fsection-anchors}, it accesses the variables
13495 from a common anchor point instead. The effect is similar to the
13496 following pseudocode (which isn't valid C):
13501 register int *xr = &x;
13502 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
13506 Not all targets support this option.
13508 @item -fzero-call-used-regs=@var{choice}
13509 @opindex fzero-call-used-regs
13510 Zero call-used registers at function return to increase program
13511 security by either mitigating Return-Oriented Programming (ROP)
13512 attacks or preventing information leakage through registers.
13514 The possible values of @var{choice} are the same as for the
13515 @code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
13516 The default is @samp{skip}.
13518 You can control this behavior for a specific function by using the function
13519 attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
13521 @item --param @var{name}=@var{value}
13523 In some places, GCC uses various constants to control the amount of
13524 optimization that is done. For example, GCC does not inline functions
13525 that contain more than a certain number of instructions. You can
13526 control some of these constants on the command line using the
13527 @option{--param} option.
13529 The names of specific parameters, and the meaning of the values, are
13530 tied to the internals of the compiler, and are subject to change
13531 without notice in future releases.
13533 In order to get minimal, maximal and default value of a parameter,
13534 one can use @option{--help=param -Q} options.
13536 In each case, the @var{value} is an integer. The following choices
13537 of @var{name} are recognized for all targets:
13540 @item predictable-branch-outcome
13541 When branch is predicted to be taken with probability lower than this threshold
13542 (in percent), then it is considered well predictable.
13544 @item max-rtl-if-conversion-insns
13545 RTL if-conversion tries to remove conditional branches around a block and
13546 replace them with conditionally executed instructions. This parameter
13547 gives the maximum number of instructions in a block which should be
13548 considered for if-conversion. The compiler will
13549 also use other heuristics to decide whether if-conversion is likely to be
13552 @item max-rtl-if-conversion-predictable-cost
13553 RTL if-conversion will try to remove conditional branches around a block
13554 and replace them with conditionally executed instructions. These parameters
13555 give the maximum permissible cost for the sequence that would be generated
13556 by if-conversion depending on whether the branch is statically determined
13557 to be predictable or not. The units for this parameter are the same as
13558 those for the GCC internal seq_cost metric. The compiler will try to
13559 provide a reasonable default for this parameter using the BRANCH_COST
13562 @item max-crossjump-edges
13563 The maximum number of incoming edges to consider for cross-jumping.
13564 The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
13565 the number of edges incoming to each block. Increasing values mean
13566 more aggressive optimization, making the compilation time increase with
13567 probably small improvement in executable size.
13569 @item min-crossjump-insns
13570 The minimum number of instructions that must be matched at the end
13571 of two blocks before cross-jumping is performed on them. This
13572 value is ignored in the case where all instructions in the block being
13573 cross-jumped from are matched.
13575 @item max-grow-copy-bb-insns
13576 The maximum code size expansion factor when copying basic blocks
13577 instead of jumping. The expansion is relative to a jump instruction.
13579 @item max-goto-duplication-insns
13580 The maximum number of instructions to duplicate to a block that jumps
13581 to a computed goto. To avoid @math{O(N^2)} behavior in a number of
13582 passes, GCC factors computed gotos early in the compilation process,
13583 and unfactors them as late as possible. Only computed jumps at the
13584 end of a basic blocks with no more than max-goto-duplication-insns are
13587 @item max-delay-slot-insn-search
13588 The maximum number of instructions to consider when looking for an
13589 instruction to fill a delay slot. If more than this arbitrary number of
13590 instructions are searched, the time savings from filling the delay slot
13591 are minimal, so stop searching. Increasing values mean more
13592 aggressive optimization, making the compilation time increase with probably
13593 small improvement in execution time.
13595 @item max-delay-slot-live-search
13596 When trying to fill delay slots, the maximum number of instructions to
13597 consider when searching for a block with valid live register
13598 information. Increasing this arbitrarily chosen value means more
13599 aggressive optimization, increasing the compilation time. This parameter
13600 should be removed when the delay slot code is rewritten to maintain the
13601 control-flow graph.
13603 @item max-gcse-memory
13604 The approximate maximum amount of memory in @code{kB} that can be allocated in
13605 order to perform the global common subexpression elimination
13606 optimization. If more memory than specified is required, the
13607 optimization is not done.
13609 @item max-gcse-insertion-ratio
13610 If the ratio of expression insertions to deletions is larger than this value
13611 for any expression, then RTL PRE inserts or removes the expression and thus
13612 leaves partially redundant computations in the instruction stream.
13614 @item max-pending-list-length
13615 The maximum number of pending dependencies scheduling allows
13616 before flushing the current state and starting over. Large functions
13617 with few branches or calls can create excessively large lists which
13618 needlessly consume memory and resources.
13620 @item max-modulo-backtrack-attempts
13621 The maximum number of backtrack attempts the scheduler should make
13622 when modulo scheduling a loop. Larger values can exponentially increase
13625 @item max-inline-functions-called-once-loop-depth
13626 Maximal loop depth of a call considered by inline heuristics that tries to
13627 inline all functions called once.
13629 @item max-inline-functions-called-once-insns
13630 Maximal estimated size of functions produced while inlining functions called
13633 @item max-inline-insns-single
13634 Several parameters control the tree inliner used in GCC@. This number sets the
13635 maximum number of instructions (counted in GCC's internal representation) in a
13636 single function that the tree inliner considers for inlining. This only
13637 affects functions declared inline and methods implemented in a class
13641 @item max-inline-insns-auto
13642 When you use @option{-finline-functions} (included in @option{-O3}),
13643 a lot of functions that would otherwise not be considered for inlining
13644 by the compiler are investigated. To those functions, a different
13645 (more restrictive) limit compared to functions declared inline can
13646 be applied (@option{--param max-inline-insns-auto}).
13648 @item max-inline-insns-small
13649 This is bound applied to calls which are considered relevant with
13650 @option{-finline-small-functions}.
13652 @item max-inline-insns-size
13653 This is bound applied to calls which are optimized for size. Small growth
13654 may be desirable to anticipate optimization oppurtunities exposed by inlining.
13656 @item uninlined-function-insns
13657 Number of instructions accounted by inliner for function overhead such as
13658 function prologue and epilogue.
13660 @item uninlined-function-time
13661 Extra time accounted by inliner for function overhead such as time needed to
13662 execute function prologue and epilogue.
13664 @item inline-heuristics-hint-percent
13665 The scale (in percents) applied to @option{inline-insns-single},
13666 @option{inline-insns-single-O2}, @option{inline-insns-auto}
13667 when inline heuristics hints that inlining is
13668 very profitable (will enable later optimizations).
13670 @item uninlined-thunk-insns
13671 @item uninlined-thunk-time
13672 Same as @option{--param uninlined-function-insns} and
13673 @option{--param uninlined-function-time} but applied to function thunks.
13675 @item inline-min-speedup
13676 When estimated performance improvement of caller + callee runtime exceeds this
13677 threshold (in percent), the function can be inlined regardless of the limit on
13678 @option{--param max-inline-insns-single} and @option{--param
13679 max-inline-insns-auto}.
13681 @item large-function-insns
13682 The limit specifying really large functions. For functions larger than this
13683 limit after inlining, inlining is constrained by
13684 @option{--param large-function-growth}. This parameter is useful primarily
13685 to avoid extreme compilation time caused by non-linear algorithms used by the
13688 @item large-function-growth
13689 Specifies maximal growth of large function caused by inlining in percents.
13690 For example, parameter value 100 limits large function growth to 2.0 times
13693 @item large-unit-insns
13694 The limit specifying large translation unit. Growth caused by inlining of
13695 units larger than this limit is limited by @option{--param inline-unit-growth}.
13696 For small units this might be too tight.
13697 For example, consider a unit consisting of function A
13698 that is inline and B that just calls A three times. If B is small relative to
13699 A, the growth of unit is 300\% and yet such inlining is very sane. For very
13700 large units consisting of small inlineable functions, however, the overall unit
13701 growth limit is needed to avoid exponential explosion of code size. Thus for
13702 smaller units, the size is increased to @option{--param large-unit-insns}
13703 before applying @option{--param inline-unit-growth}.
13706 Maximum number of concurrently open C++ module files when lazy loading.
13708 @item inline-unit-growth
13709 Specifies maximal overall growth of the compilation unit caused by inlining.
13710 For example, parameter value 20 limits unit growth to 1.2 times the original
13711 size. Cold functions (either marked cold via an attribute or by profile
13712 feedback) are not accounted into the unit size.
13714 @item ipa-cp-unit-growth
13715 Specifies maximal overall growth of the compilation unit caused by
13716 interprocedural constant propagation. For example, parameter value 10 limits
13717 unit growth to 1.1 times the original size.
13719 @item ipa-cp-large-unit-insns
13720 The size of translation unit that IPA-CP pass considers large.
13722 @item large-stack-frame
13723 The limit specifying large stack frames. While inlining the algorithm is trying
13724 to not grow past this limit too much.
13726 @item large-stack-frame-growth
13727 Specifies maximal growth of large stack frames caused by inlining in percents.
13728 For example, parameter value 1000 limits large stack frame growth to 11 times
13731 @item max-inline-insns-recursive
13732 @itemx max-inline-insns-recursive-auto
13733 Specifies the maximum number of instructions an out-of-line copy of a
13734 self-recursive inline
13735 function can grow into by performing recursive inlining.
13737 @option{--param max-inline-insns-recursive} applies to functions
13739 For functions not declared inline, recursive inlining
13740 happens only when @option{-finline-functions} (included in @option{-O3}) is
13741 enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
13743 @item max-inline-recursive-depth
13744 @itemx max-inline-recursive-depth-auto
13745 Specifies the maximum recursion depth used for recursive inlining.
13747 @option{--param max-inline-recursive-depth} applies to functions
13748 declared inline. For functions not declared inline, recursive inlining
13749 happens only when @option{-finline-functions} (included in @option{-O3}) is
13750 enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
13752 @item min-inline-recursive-probability
13753 Recursive inlining is profitable only for function having deep recursion
13754 in average and can hurt for function having little recursion depth by
13755 increasing the prologue size or complexity of function body to other
13758 When profile feedback is available (see @option{-fprofile-generate}) the actual
13759 recursion depth can be guessed from the probability that function recurses
13760 via a given call expression. This parameter limits inlining only to call
13761 expressions whose probability exceeds the given threshold (in percents).
13763 @item early-inlining-insns
13764 Specify growth that the early inliner can make. In effect it increases
13765 the amount of inlining for code having a large abstraction penalty.
13767 @item max-early-inliner-iterations
13768 Limit of iterations of the early inliner. This basically bounds
13769 the number of nested indirect calls the early inliner can resolve.
13770 Deeper chains are still handled by late inlining.
13772 @item comdat-sharing-probability
13773 Probability (in percent) that C++ inline function with comdat visibility
13774 are shared across multiple compilation units.
13776 @item modref-max-bases
13777 @item modref-max-refs
13778 @item modref-max-accesses
13779 Specifies the maximal number of base pointers, references and accesses stored
13780 for a single function by mod/ref analysis.
13782 @item modref-max-tests
13783 Specifies the maxmal number of tests alias oracle can perform to disambiguate
13784 memory locations using the mod/ref information. This parameter ought to be
13785 bigger than @option{--param modref-max-bases} and @option{--param
13788 @item modref-max-depth
13789 Specifies the maximum depth of DFS walk used by modref escape analysis.
13790 Setting to 0 disables the analysis completely.
13792 @item modref-max-escape-points
13793 Specifies the maximum number of escape points tracked by modref per SSA-name.
13795 @item modref-max-adjustments
13796 Specifies the maximum number the access range is enlarged during modref dataflow
13799 @item profile-func-internal-id
13800 A parameter to control whether to use function internal id in profile
13801 database lookup. If the value is 0, the compiler uses an id that
13802 is based on function assembler name and filename, which makes old profile
13803 data more tolerant to source changes such as function reordering etc.
13805 @item min-vect-loop-bound
13806 The minimum number of iterations under which loops are not vectorized
13807 when @option{-ftree-vectorize} is used. The number of iterations after
13808 vectorization needs to be greater than the value specified by this option
13809 to allow vectorization.
13811 @item gcse-cost-distance-ratio
13812 Scaling factor in calculation of maximum distance an expression
13813 can be moved by GCSE optimizations. This is currently supported only in the
13814 code hoisting pass. The bigger the ratio, the more aggressive code hoisting
13815 is with simple expressions, i.e., the expressions that have cost
13816 less than @option{gcse-unrestricted-cost}. Specifying 0 disables
13817 hoisting of simple expressions.
13819 @item gcse-unrestricted-cost
13820 Cost, roughly measured as the cost of a single typical machine
13821 instruction, at which GCSE optimizations do not constrain
13822 the distance an expression can travel. This is currently
13823 supported only in the code hoisting pass. The lesser the cost,
13824 the more aggressive code hoisting is. Specifying 0
13825 allows all expressions to travel unrestricted distances.
13827 @item max-hoist-depth
13828 The depth of search in the dominator tree for expressions to hoist.
13829 This is used to avoid quadratic behavior in hoisting algorithm.
13830 The value of 0 does not limit on the search, but may slow down compilation
13833 @item max-tail-merge-comparisons
13834 The maximum amount of similar bbs to compare a bb with. This is used to
13835 avoid quadratic behavior in tree tail merging.
13837 @item max-tail-merge-iterations
13838 The maximum amount of iterations of the pass over the function. This is used to
13839 limit compilation time in tree tail merging.
13841 @item store-merging-allow-unaligned
13842 Allow the store merging pass to introduce unaligned stores if it is legal to
13845 @item max-stores-to-merge
13846 The maximum number of stores to attempt to merge into wider stores in the store
13849 @item max-store-chains-to-track
13850 The maximum number of store chains to track at the same time in the attempt
13851 to merge them into wider stores in the store merging pass.
13853 @item max-stores-to-track
13854 The maximum number of stores to track at the same time in the attemt to
13855 to merge them into wider stores in the store merging pass.
13857 @item max-unrolled-insns
13858 The maximum number of instructions that a loop may have to be unrolled.
13859 If a loop is unrolled, this parameter also determines how many times
13860 the loop code is unrolled.
13862 @item max-average-unrolled-insns
13863 The maximum number of instructions biased by probabilities of their execution
13864 that a loop may have to be unrolled. If a loop is unrolled,
13865 this parameter also determines how many times the loop code is unrolled.
13867 @item max-unroll-times
13868 The maximum number of unrollings of a single loop.
13870 @item max-peeled-insns
13871 The maximum number of instructions that a loop may have to be peeled.
13872 If a loop is peeled, this parameter also determines how many times
13873 the loop code is peeled.
13875 @item max-peel-times
13876 The maximum number of peelings of a single loop.
13878 @item max-peel-branches
13879 The maximum number of branches on the hot path through the peeled sequence.
13881 @item max-completely-peeled-insns
13882 The maximum number of insns of a completely peeled loop.
13884 @item max-completely-peel-times
13885 The maximum number of iterations of a loop to be suitable for complete peeling.
13887 @item max-completely-peel-loop-nest-depth
13888 The maximum depth of a loop nest suitable for complete peeling.
13890 @item max-unswitch-insns
13891 The maximum number of insns of an unswitched loop.
13893 @item max-unswitch-level
13894 The maximum number of branches unswitched in a single loop.
13896 @item lim-expensive
13897 The minimum cost of an expensive expression in the loop invariant motion.
13899 @item min-loop-cond-split-prob
13900 When FDO profile information is available, @option{min-loop-cond-split-prob}
13901 specifies minimum threshold for probability of semi-invariant condition
13902 statement to trigger loop split.
13904 @item iv-consider-all-candidates-bound
13905 Bound on number of candidates for induction variables, below which
13906 all candidates are considered for each use in induction variable
13907 optimizations. If there are more candidates than this,
13908 only the most relevant ones are considered to avoid quadratic time complexity.
13910 @item iv-max-considered-uses
13911 The induction variable optimizations give up on loops that contain more
13912 induction variable uses.
13914 @item iv-always-prune-cand-set-bound
13915 If the number of candidates in the set is smaller than this value,
13916 always try to remove unnecessary ivs from the set
13917 when adding a new one.
13919 @item avg-loop-niter
13920 Average number of iterations of a loop.
13922 @item dse-max-object-size
13923 Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
13924 Larger values may result in larger compilation times.
13926 @item dse-max-alias-queries-per-store
13927 Maximum number of queries into the alias oracle per store.
13928 Larger values result in larger compilation times and may result in more
13929 removed dead stores.
13931 @item scev-max-expr-size
13932 Bound on size of expressions used in the scalar evolutions analyzer.
13933 Large expressions slow the analyzer.
13935 @item scev-max-expr-complexity
13936 Bound on the complexity of the expressions in the scalar evolutions analyzer.
13937 Complex expressions slow the analyzer.
13939 @item max-tree-if-conversion-phi-args
13940 Maximum number of arguments in a PHI supported by TREE if conversion
13941 unless the loop is marked with simd pragma.
13943 @item vect-max-version-for-alignment-checks
13944 The maximum number of run-time checks that can be performed when
13945 doing loop versioning for alignment in the vectorizer.
13947 @item vect-max-version-for-alias-checks
13948 The maximum number of run-time checks that can be performed when
13949 doing loop versioning for alias in the vectorizer.
13951 @item vect-max-peeling-for-alignment
13952 The maximum number of loop peels to enhance access alignment
13953 for vectorizer. Value -1 means no limit.
13955 @item max-iterations-to-track
13956 The maximum number of iterations of a loop the brute-force algorithm
13957 for analysis of the number of iterations of the loop tries to evaluate.
13959 @item hot-bb-count-fraction
13960 The denominator n of fraction 1/n of the maximal execution count of a
13961 basic block in the entire program that a basic block needs to at least
13962 have in order to be considered hot. The default is 10000, which means
13963 that a basic block is considered hot if its execution count is greater
13964 than 1/10000 of the maximal execution count. 0 means that it is never
13965 considered hot. Used in non-LTO mode.
13967 @item hot-bb-count-ws-permille
13968 The number of most executed permilles, ranging from 0 to 1000, of the
13969 profiled execution of the entire program to which the execution count
13970 of a basic block must be part of in order to be considered hot. The
13971 default is 990, which means that a basic block is considered hot if
13972 its execution count contributes to the upper 990 permilles, or 99.0%,
13973 of the profiled execution of the entire program. 0 means that it is
13974 never considered hot. Used in LTO mode.
13976 @item hot-bb-frequency-fraction
13977 The denominator n of fraction 1/n of the execution frequency of the
13978 entry block of a function that a basic block of this function needs
13979 to at least have in order to be considered hot. The default is 1000,
13980 which means that a basic block is considered hot in a function if it
13981 is executed more frequently than 1/1000 of the frequency of the entry
13982 block of the function. 0 means that it is never considered hot.
13984 @item unlikely-bb-count-fraction
13985 The denominator n of fraction 1/n of the number of profiled runs of
13986 the entire program below which the execution count of a basic block
13987 must be in order for the basic block to be considered unlikely executed.
13988 The default is 20, which means that a basic block is considered unlikely
13989 executed if it is executed in fewer than 1/20, or 5%, of the runs of
13990 the program. 0 means that it is always considered unlikely executed.
13992 @item max-predicted-iterations
13993 The maximum number of loop iterations we predict statically. This is useful
13994 in cases where a function contains a single loop with known bound and
13995 another loop with unknown bound.
13996 The known number of iterations is predicted correctly, while
13997 the unknown number of iterations average to roughly 10. This means that the
13998 loop without bounds appears artificially cold relative to the other one.
14000 @item builtin-expect-probability
14001 Control the probability of the expression having the specified value. This
14002 parameter takes a percentage (i.e.@: 0 ... 100) as input.
14004 @item builtin-string-cmp-inline-length
14005 The maximum length of a constant string for a builtin string cmp call
14006 eligible for inlining.
14008 @item align-threshold
14010 Select fraction of the maximal frequency of executions of a basic block in
14011 a function to align the basic block.
14013 @item align-loop-iterations
14015 A loop expected to iterate at least the selected number of iterations is
14018 @item tracer-dynamic-coverage
14019 @itemx tracer-dynamic-coverage-feedback
14021 This value is used to limit superblock formation once the given percentage of
14022 executed instructions is covered. This limits unnecessary code size
14025 The @option{tracer-dynamic-coverage-feedback} parameter
14026 is used only when profile
14027 feedback is available. The real profiles (as opposed to statically estimated
14028 ones) are much less balanced allowing the threshold to be larger value.
14030 @item tracer-max-code-growth
14031 Stop tail duplication once code growth has reached given percentage. This is
14032 a rather artificial limit, as most of the duplicates are eliminated later in
14033 cross jumping, so it may be set to much higher values than is the desired code
14036 @item tracer-min-branch-ratio
14038 Stop reverse growth when the reverse probability of best edge is less than this
14039 threshold (in percent).
14041 @item tracer-min-branch-probability
14042 @itemx tracer-min-branch-probability-feedback
14044 Stop forward growth if the best edge has probability lower than this
14047 Similarly to @option{tracer-dynamic-coverage} two parameters are
14048 provided. @option{tracer-min-branch-probability-feedback} is used for
14049 compilation with profile feedback and @option{tracer-min-branch-probability}
14050 compilation without. The value for compilation with profile feedback
14051 needs to be more conservative (higher) in order to make tracer
14054 @item stack-clash-protection-guard-size
14055 Specify the size of the operating system provided stack guard as
14056 2 raised to @var{num} bytes. Higher values may reduce the
14057 number of explicit probes, but a value larger than the operating system
14058 provided guard will leave code vulnerable to stack clash style attacks.
14060 @item stack-clash-protection-probe-interval
14061 Stack clash protection involves probing stack space as it is allocated. This
14062 param controls the maximum distance between probes into the stack as 2 raised
14063 to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
14064 larger than the operating system provided guard will leave code vulnerable to
14065 stack clash style attacks.
14067 @item max-cse-path-length
14069 The maximum number of basic blocks on path that CSE considers.
14071 @item max-cse-insns
14072 The maximum number of instructions CSE processes before flushing.
14074 @item ggc-min-expand
14076 GCC uses a garbage collector to manage its own memory allocation. This
14077 parameter specifies the minimum percentage by which the garbage
14078 collector's heap should be allowed to expand between collections.
14079 Tuning this may improve compilation speed; it has no effect on code
14082 The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
14083 RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
14084 the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
14085 GCC is not able to calculate RAM on a particular platform, the lower
14086 bound of 30% is used. Setting this parameter and
14087 @option{ggc-min-heapsize} to zero causes a full collection to occur at
14088 every opportunity. This is extremely slow, but can be useful for
14091 @item ggc-min-heapsize
14093 Minimum size of the garbage collector's heap before it begins bothering
14094 to collect garbage. The first collection occurs after the heap expands
14095 by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
14096 tuning this may improve compilation speed, and has no effect on code
14099 The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
14100 tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
14101 with a lower bound of 4096 (four megabytes) and an upper bound of
14102 131072 (128 megabytes). If GCC is not able to calculate RAM on a
14103 particular platform, the lower bound is used. Setting this parameter
14104 very large effectively disables garbage collection. Setting this
14105 parameter and @option{ggc-min-expand} to zero causes a full collection
14106 to occur at every opportunity.
14108 @item max-reload-search-insns
14109 The maximum number of instruction reload should look backward for equivalent
14110 register. Increasing values mean more aggressive optimization, making the
14111 compilation time increase with probably slightly better performance.
14113 @item max-cselib-memory-locations
14114 The maximum number of memory locations cselib should take into account.
14115 Increasing values mean more aggressive optimization, making the compilation time
14116 increase with probably slightly better performance.
14118 @item max-sched-ready-insns
14119 The maximum number of instructions ready to be issued the scheduler should
14120 consider at any given time during the first scheduling pass. Increasing
14121 values mean more thorough searches, making the compilation time increase
14122 with probably little benefit.
14124 @item max-sched-region-blocks
14125 The maximum number of blocks in a region to be considered for
14126 interblock scheduling.
14128 @item max-pipeline-region-blocks
14129 The maximum number of blocks in a region to be considered for
14130 pipelining in the selective scheduler.
14132 @item max-sched-region-insns
14133 The maximum number of insns in a region to be considered for
14134 interblock scheduling.
14136 @item max-pipeline-region-insns
14137 The maximum number of insns in a region to be considered for
14138 pipelining in the selective scheduler.
14140 @item min-spec-prob
14141 The minimum probability (in percents) of reaching a source block
14142 for interblock speculative scheduling.
14144 @item max-sched-extend-regions-iters
14145 The maximum number of iterations through CFG to extend regions.
14146 A value of 0 disables region extensions.
14148 @item max-sched-insn-conflict-delay
14149 The maximum conflict delay for an insn to be considered for speculative motion.
14151 @item sched-spec-prob-cutoff
14152 The minimal probability of speculation success (in percents), so that
14153 speculative insns are scheduled.
14155 @item sched-state-edge-prob-cutoff
14156 The minimum probability an edge must have for the scheduler to save its
14159 @item sched-mem-true-dep-cost
14160 Minimal distance (in CPU cycles) between store and load targeting same
14163 @item selsched-max-lookahead
14164 The maximum size of the lookahead window of selective scheduling. It is a
14165 depth of search for available instructions.
14167 @item selsched-max-sched-times
14168 The maximum number of times that an instruction is scheduled during
14169 selective scheduling. This is the limit on the number of iterations
14170 through which the instruction may be pipelined.
14172 @item selsched-insns-to-rename
14173 The maximum number of best instructions in the ready list that are considered
14174 for renaming in the selective scheduler.
14177 The minimum value of stage count that swing modulo scheduler
14180 @item max-last-value-rtl
14181 The maximum size measured as number of RTLs that can be recorded in an expression
14182 in combiner for a pseudo register as last known value of that register.
14184 @item max-combine-insns
14185 The maximum number of instructions the RTL combiner tries to combine.
14187 @item integer-share-limit
14188 Small integer constants can use a shared data structure, reducing the
14189 compiler's memory usage and increasing its speed. This sets the maximum
14190 value of a shared integer constant.
14192 @item ssp-buffer-size
14193 The minimum size of buffers (i.e.@: arrays) that receive stack smashing
14194 protection when @option{-fstack-protector} is used.
14196 @item min-size-for-stack-sharing
14197 The minimum size of variables taking part in stack slot sharing when not
14200 @item max-jump-thread-duplication-stmts
14201 Maximum number of statements allowed in a block that needs to be
14202 duplicated when threading jumps.
14204 @item max-fields-for-field-sensitive
14205 Maximum number of fields in a structure treated in
14206 a field sensitive manner during pointer analysis.
14208 @item prefetch-latency
14209 Estimate on average number of instructions that are executed before
14210 prefetch finishes. The distance prefetched ahead is proportional
14211 to this constant. Increasing this number may also lead to less
14212 streams being prefetched (see @option{simultaneous-prefetches}).
14214 @item simultaneous-prefetches
14215 Maximum number of prefetches that can run at the same time.
14217 @item l1-cache-line-size
14218 The size of cache line in L1 data cache, in bytes.
14220 @item l1-cache-size
14221 The size of L1 data cache, in kilobytes.
14223 @item l2-cache-size
14224 The size of L2 data cache, in kilobytes.
14226 @item prefetch-dynamic-strides
14227 Whether the loop array prefetch pass should issue software prefetch hints
14228 for strides that are non-constant. In some cases this may be
14229 beneficial, though the fact the stride is non-constant may make it
14230 hard to predict when there is clear benefit to issuing these hints.
14232 Set to 1 if the prefetch hints should be issued for non-constant
14233 strides. Set to 0 if prefetch hints should be issued only for strides that
14234 are known to be constant and below @option{prefetch-minimum-stride}.
14236 @item prefetch-minimum-stride
14237 Minimum constant stride, in bytes, to start using prefetch hints for. If
14238 the stride is less than this threshold, prefetch hints will not be issued.
14240 This setting is useful for processors that have hardware prefetchers, in
14241 which case there may be conflicts between the hardware prefetchers and
14242 the software prefetchers. If the hardware prefetchers have a maximum
14243 stride they can handle, it should be used here to improve the use of
14244 software prefetchers.
14246 A value of -1 means we don't have a threshold and therefore
14247 prefetch hints can be issued for any constant stride.
14249 This setting is only useful for strides that are known and constant.
14251 @item destructive-interference-size
14252 @item constructive-interference-size
14253 The values for the C++17 variables
14254 @code{std::hardware_destructive_interference_size} and
14255 @code{std::hardware_constructive_interference_size}. The destructive
14256 interference size is the minimum recommended offset between two
14257 independent concurrently-accessed objects; the constructive
14258 interference size is the maximum recommended size of contiguous memory
14259 accessed together. Typically both will be the size of an L1 cache
14260 line for the target, in bytes. For a generic target covering a range of L1
14261 cache line sizes, typically the constructive interference size will be
14262 the small end of the range and the destructive size will be the large
14265 The destructive interference size is intended to be used for layout,
14266 and thus has ABI impact. The default value is not expected to be
14267 stable, and on some targets varies with @option{-mtune}, so use of
14268 this variable in a context where ABI stability is important, such as
14269 the public interface of a library, is strongly discouraged; if it is
14270 used in that context, users can stabilize the value using this
14273 The constructive interference size is less sensitive, as it is
14274 typically only used in a @samp{static_assert} to make sure that a type
14275 fits within a cache line.
14277 See also @option{-Winterference-size}.
14279 @item loop-interchange-max-num-stmts
14280 The maximum number of stmts in a loop to be interchanged.
14282 @item loop-interchange-stride-ratio
14283 The minimum ratio between stride of two loops for interchange to be profitable.
14285 @item min-insn-to-prefetch-ratio
14286 The minimum ratio between the number of instructions and the
14287 number of prefetches to enable prefetching in a loop.
14289 @item prefetch-min-insn-to-mem-ratio
14290 The minimum ratio between the number of instructions and the
14291 number of memory references to enable prefetching in a loop.
14293 @item use-canonical-types
14294 Whether the compiler should use the ``canonical'' type system.
14295 Should always be 1, which uses a more efficient internal
14296 mechanism for comparing types in C++ and Objective-C++. However, if
14297 bugs in the canonical type system are causing compilation failures,
14298 set this value to 0 to disable canonical types.
14300 @item switch-conversion-max-branch-ratio
14301 Switch initialization conversion refuses to create arrays that are
14302 bigger than @option{switch-conversion-max-branch-ratio} times the number of
14303 branches in the switch.
14305 @item max-partial-antic-length
14306 Maximum length of the partial antic set computed during the tree
14307 partial redundancy elimination optimization (@option{-ftree-pre}) when
14308 optimizing at @option{-O3} and above. For some sorts of source code
14309 the enhanced partial redundancy elimination optimization can run away,
14310 consuming all of the memory available on the host machine. This
14311 parameter sets a limit on the length of the sets that are computed,
14312 which prevents the runaway behavior. Setting a value of 0 for
14313 this parameter allows an unlimited set length.
14315 @item rpo-vn-max-loop-depth
14316 Maximum loop depth that is value-numbered optimistically.
14317 When the limit hits the innermost
14318 @var{rpo-vn-max-loop-depth} loops and the outermost loop in the
14319 loop nest are value-numbered optimistically and the remaining ones not.
14321 @item sccvn-max-alias-queries-per-access
14322 Maximum number of alias-oracle queries we perform when looking for
14323 redundancies for loads and stores. If this limit is hit the search
14324 is aborted and the load or store is not considered redundant. The
14325 number of queries is algorithmically limited to the number of
14326 stores on all paths from the load to the function entry.
14328 @item ira-max-loops-num
14329 IRA uses regional register allocation by default. If a function
14330 contains more loops than the number given by this parameter, only at most
14331 the given number of the most frequently-executed loops form regions
14332 for regional register allocation.
14334 @item ira-max-conflict-table-size
14335 Although IRA uses a sophisticated algorithm to compress the conflict
14336 table, the table can still require excessive amounts of memory for
14337 huge functions. If the conflict table for a function could be more
14338 than the size in MB given by this parameter, the register allocator
14339 instead uses a faster, simpler, and lower-quality
14340 algorithm that does not require building a pseudo-register conflict table.
14342 @item ira-loop-reserved-regs
14343 IRA can be used to evaluate more accurate register pressure in loops
14344 for decisions to move loop invariants (see @option{-O3}). The number
14345 of available registers reserved for some other purposes is given
14346 by this parameter. Default of the parameter
14347 is the best found from numerous experiments.
14349 @item ira-consider-dup-in-all-alts
14350 Make IRA to consider matching constraint (duplicated operand number)
14351 heavily in all available alternatives for preferred register class.
14352 If it is set as zero, it means IRA only respects the matching
14353 constraint when it's in the only available alternative with an
14354 appropriate register class. Otherwise, it means IRA will check all
14355 available alternatives for preferred register class even if it has
14356 found some choice with an appropriate register class and respect the
14357 found qualified matching constraint.
14359 @item lra-inheritance-ebb-probability-cutoff
14360 LRA tries to reuse values reloaded in registers in subsequent insns.
14361 This optimization is called inheritance. EBB is used as a region to
14362 do this optimization. The parameter defines a minimal fall-through
14363 edge probability in percentage used to add BB to inheritance EBB in
14364 LRA. The default value was chosen
14365 from numerous runs of SPEC2000 on x86-64.
14367 @item loop-invariant-max-bbs-in-loop
14368 Loop invariant motion can be very expensive, both in compilation time and
14369 in amount of needed compile-time memory, with very large loops. Loops
14370 with more basic blocks than this parameter won't have loop invariant
14371 motion optimization performed on them.
14373 @item loop-max-datarefs-for-datadeps
14374 Building data dependencies is expensive for very large loops. This
14375 parameter limits the number of data references in loops that are
14376 considered for data dependence analysis. These large loops are no
14377 handled by the optimizations using loop data dependencies.
14379 @item max-vartrack-size
14380 Sets a maximum number of hash table slots to use during variable
14381 tracking dataflow analysis of any function. If this limit is exceeded
14382 with variable tracking at assignments enabled, analysis for that
14383 function is retried without it, after removing all debug insns from
14384 the function. If the limit is exceeded even without debug insns, var
14385 tracking analysis is completely disabled for the function. Setting
14386 the parameter to zero makes it unlimited.
14388 @item max-vartrack-expr-depth
14389 Sets a maximum number of recursion levels when attempting to map
14390 variable names or debug temporaries to value expressions. This trades
14391 compilation time for more complete debug information. If this is set too
14392 low, value expressions that are available and could be represented in
14393 debug information may end up not being used; setting this higher may
14394 enable the compiler to find more complex debug expressions, but compile
14395 time and memory use may grow.
14397 @item max-debug-marker-count
14398 Sets a threshold on the number of debug markers (e.g.@: begin stmt
14399 markers) to avoid complexity explosion at inlining or expanding to RTL.
14400 If a function has more such gimple stmts than the set limit, such stmts
14401 will be dropped from the inlined copy of a function, and from its RTL
14404 @item min-nondebug-insn-uid
14405 Use uids starting at this parameter for nondebug insns. The range below
14406 the parameter is reserved exclusively for debug insns created by
14407 @option{-fvar-tracking-assignments}, but debug insns may get
14408 (non-overlapping) uids above it if the reserved range is exhausted.
14410 @item ipa-sra-ptr-growth-factor
14411 IPA-SRA replaces a pointer to an aggregate with one or more new
14412 parameters only when their cumulative size is less or equal to
14413 @option{ipa-sra-ptr-growth-factor} times the size of the original
14416 @item ipa-sra-max-replacements
14417 Maximum pieces of an aggregate that IPA-SRA tracks. As a
14418 consequence, it is also the maximum number of replacements of a formal
14421 @item sra-max-scalarization-size-Ospeed
14422 @itemx sra-max-scalarization-size-Osize
14423 The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
14424 replace scalar parts of aggregates with uses of independent scalar
14425 variables. These parameters control the maximum size, in storage units,
14426 of aggregate which is considered for replacement when compiling for
14428 (@option{sra-max-scalarization-size-Ospeed}) or size
14429 (@option{sra-max-scalarization-size-Osize}) respectively.
14431 @item sra-max-propagations
14432 The maximum number of artificial accesses that Scalar Replacement of
14433 Aggregates (SRA) will track, per one local variable, in order to
14434 facilitate copy propagation.
14436 @item tm-max-aggregate-size
14437 When making copies of thread-local variables in a transaction, this
14438 parameter specifies the size in bytes after which variables are
14439 saved with the logging functions as opposed to save/restore code
14440 sequence pairs. This option only applies when using
14443 @item graphite-max-nb-scop-params
14444 To avoid exponential effects in the Graphite loop transforms, the
14445 number of parameters in a Static Control Part (SCoP) is bounded.
14446 A value of zero can be used to lift
14447 the bound. A variable whose value is unknown at compilation time and
14448 defined outside a SCoP is a parameter of the SCoP.
14450 @item loop-block-tile-size
14451 Loop blocking or strip mining transforms, enabled with
14452 @option{-floop-block} or @option{-floop-strip-mine}, strip mine each
14453 loop in the loop nest by a given number of iterations. The strip
14454 length can be changed using the @option{loop-block-tile-size}
14457 @item ipa-jump-function-lookups
14458 Specifies number of statements visited during jump function offset discovery.
14460 @item ipa-cp-value-list-size
14461 IPA-CP attempts to track all possible values and types passed to a function's
14462 parameter in order to propagate them and perform devirtualization.
14463 @option{ipa-cp-value-list-size} is the maximum number of values and types it
14464 stores per one formal parameter of a function.
14466 @item ipa-cp-eval-threshold
14467 IPA-CP calculates its own score of cloning profitability heuristics
14468 and performs those cloning opportunities with scores that exceed
14469 @option{ipa-cp-eval-threshold}.
14471 @item ipa-cp-max-recursive-depth
14472 Maximum depth of recursive cloning for self-recursive function.
14474 @item ipa-cp-min-recursive-probability
14475 Recursive cloning only when the probability of call being executed exceeds
14478 @item ipa-cp-profile-count-base
14479 When using @option{-fprofile-use} option, IPA-CP will consider the measured
14480 execution count of a call graph edge at this percentage position in their
14481 histogram as the basis for its heuristics calculation.
14483 @item ipa-cp-recursive-freq-factor
14484 The number of times interprocedural copy propagation expects recursive
14485 functions to call themselves.
14487 @item ipa-cp-recursion-penalty
14488 Percentage penalty the recursive functions will receive when they
14489 are evaluated for cloning.
14491 @item ipa-cp-single-call-penalty
14492 Percentage penalty functions containing a single call to another
14493 function will receive when they are evaluated for cloning.
14495 @item ipa-max-agg-items
14496 IPA-CP is also capable to propagate a number of scalar values passed
14497 in an aggregate. @option{ipa-max-agg-items} controls the maximum
14498 number of such values per one parameter.
14500 @item ipa-cp-loop-hint-bonus
14501 When IPA-CP determines that a cloning candidate would make the number
14502 of iterations of a loop known, it adds a bonus of
14503 @option{ipa-cp-loop-hint-bonus} to the profitability score of
14506 @item ipa-max-loop-predicates
14507 The maximum number of different predicates IPA will use to describe when
14508 loops in a function have known properties.
14510 @item ipa-max-aa-steps
14511 During its analysis of function bodies, IPA-CP employs alias analysis
14512 in order to track values pointed to by function parameters. In order
14513 not spend too much time analyzing huge functions, it gives up and
14514 consider all memory clobbered after examining
14515 @option{ipa-max-aa-steps} statements modifying memory.
14517 @item ipa-max-switch-predicate-bounds
14518 Maximal number of boundary endpoints of case ranges of switch statement.
14519 For switch exceeding this limit, IPA-CP will not construct cloning cost
14520 predicate, which is used to estimate cloning benefit, for default case
14521 of the switch statement.
14523 @item ipa-max-param-expr-ops
14524 IPA-CP will analyze conditional statement that references some function
14525 parameter to estimate benefit for cloning upon certain constant value.
14526 But if number of operations in a parameter expression exceeds
14527 @option{ipa-max-param-expr-ops}, the expression is treated as complicated
14528 one, and is not handled by IPA analysis.
14530 @item lto-partitions
14531 Specify desired number of partitions produced during WHOPR compilation.
14532 The number of partitions should exceed the number of CPUs used for compilation.
14534 @item lto-min-partition
14535 Size of minimal partition for WHOPR (in estimated instructions).
14536 This prevents expenses of splitting very small programs into too many
14539 @item lto-max-partition
14540 Size of max partition for WHOPR (in estimated instructions).
14541 to provide an upper bound for individual size of partition.
14542 Meant to be used only with balanced partitioning.
14544 @item lto-max-streaming-parallelism
14545 Maximal number of parallel processes used for LTO streaming.
14547 @item cxx-max-namespaces-for-diagnostic-help
14548 The maximum number of namespaces to consult for suggestions when C++
14549 name lookup fails for an identifier.
14551 @item sink-frequency-threshold
14552 The maximum relative execution frequency (in percents) of the target block
14553 relative to a statement's original block to allow statement sinking of a
14554 statement. Larger numbers result in more aggressive statement sinking.
14555 A small positive adjustment is applied for
14556 statements with memory operands as those are even more profitable so sink.
14558 @item max-stores-to-sink
14559 The maximum number of conditional store pairs that can be sunk. Set to 0
14560 if either vectorization (@option{-ftree-vectorize}) or if-conversion
14561 (@option{-ftree-loop-if-convert}) is disabled.
14563 @item case-values-threshold
14564 The smallest number of different values for which it is best to use a
14565 jump-table instead of a tree of conditional branches. If the value is
14566 0, use the default for the machine.
14568 @item jump-table-max-growth-ratio-for-size
14569 The maximum code size growth ratio when expanding
14570 into a jump table (in percent). The parameter is used when
14571 optimizing for size.
14573 @item jump-table-max-growth-ratio-for-speed
14574 The maximum code size growth ratio when expanding
14575 into a jump table (in percent). The parameter is used when
14576 optimizing for speed.
14578 @item tree-reassoc-width
14579 Set the maximum number of instructions executed in parallel in
14580 reassociated tree. This parameter overrides target dependent
14581 heuristics used by default if has non zero value.
14583 @item sched-pressure-algorithm
14584 Choose between the two available implementations of
14585 @option{-fsched-pressure}. Algorithm 1 is the original implementation
14586 and is the more likely to prevent instructions from being reordered.
14587 Algorithm 2 was designed to be a compromise between the relatively
14588 conservative approach taken by algorithm 1 and the rather aggressive
14589 approach taken by the default scheduler. It relies more heavily on
14590 having a regular register file and accurate register pressure classes.
14591 See @file{haifa-sched.c} in the GCC sources for more details.
14593 The default choice depends on the target.
14595 @item max-slsr-cand-scan
14596 Set the maximum number of existing candidates that are considered when
14597 seeking a basis for a new straight-line strength reduction candidate.
14600 Enable buffer overflow detection for global objects. This kind
14601 of protection is enabled by default if you are using
14602 @option{-fsanitize=address} option.
14603 To disable global objects protection use @option{--param asan-globals=0}.
14606 Enable buffer overflow detection for stack objects. This kind of
14607 protection is enabled by default when using @option{-fsanitize=address}.
14608 To disable stack protection use @option{--param asan-stack=0} option.
14610 @item asan-instrument-reads
14611 Enable buffer overflow detection for memory reads. This kind of
14612 protection is enabled by default when using @option{-fsanitize=address}.
14613 To disable memory reads protection use
14614 @option{--param asan-instrument-reads=0}.
14616 @item asan-instrument-writes
14617 Enable buffer overflow detection for memory writes. This kind of
14618 protection is enabled by default when using @option{-fsanitize=address}.
14619 To disable memory writes protection use
14620 @option{--param asan-instrument-writes=0} option.
14622 @item asan-memintrin
14623 Enable detection for built-in functions. This kind of protection
14624 is enabled by default when using @option{-fsanitize=address}.
14625 To disable built-in functions protection use
14626 @option{--param asan-memintrin=0}.
14628 @item asan-use-after-return
14629 Enable detection of use-after-return. This kind of protection
14630 is enabled by default when using the @option{-fsanitize=address} option.
14631 To disable it use @option{--param asan-use-after-return=0}.
14633 Note: By default the check is disabled at run time. To enable it,
14634 add @code{detect_stack_use_after_return=1} to the environment variable
14635 @env{ASAN_OPTIONS}.
14637 @item asan-instrumentation-with-call-threshold
14638 If number of memory accesses in function being instrumented
14639 is greater or equal to this number, use callbacks instead of inline checks.
14640 E.g. to disable inline code use
14641 @option{--param asan-instrumentation-with-call-threshold=0}.
14643 @item hwasan-instrument-stack
14644 Enable hwasan instrumentation of statically sized stack-allocated variables.
14645 This kind of instrumentation is enabled by default when using
14646 @option{-fsanitize=hwaddress} and disabled by default when using
14647 @option{-fsanitize=kernel-hwaddress}.
14648 To disable stack instrumentation use
14649 @option{--param hwasan-instrument-stack=0}, and to enable it use
14650 @option{--param hwasan-instrument-stack=1}.
14652 @item hwasan-random-frame-tag
14653 When using stack instrumentation, decide tags for stack variables using a
14654 deterministic sequence beginning at a random tag for each frame. With this
14655 parameter unset tags are chosen using the same sequence but beginning from 1.
14656 This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
14657 for @option{-fsanitize=kernel-hwaddress}.
14658 To disable it use @option{--param hwasan-random-frame-tag=0}.
14660 @item hwasan-instrument-allocas
14661 Enable hwasan instrumentation of dynamically sized stack-allocated variables.
14662 This kind of instrumentation is enabled by default when using
14663 @option{-fsanitize=hwaddress} and disabled by default when using
14664 @option{-fsanitize=kernel-hwaddress}.
14665 To disable instrumentation of such variables use
14666 @option{--param hwasan-instrument-allocas=0}, and to enable it use
14667 @option{--param hwasan-instrument-allocas=1}.
14669 @item hwasan-instrument-reads
14670 Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
14671 default for both @option{-fsanitize=hwaddress} and
14672 @option{-fsanitize=kernel-hwaddress}.
14673 To disable checking memory reads use
14674 @option{--param hwasan-instrument-reads=0}.
14676 @item hwasan-instrument-writes
14677 Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
14678 default for both @option{-fsanitize=hwaddress} and
14679 @option{-fsanitize=kernel-hwaddress}.
14680 To disable checking memory writes use
14681 @option{--param hwasan-instrument-writes=0}.
14683 @item hwasan-instrument-mem-intrinsics
14684 Enable hwasan instrumentation of builtin functions. Instrumentation of these
14685 builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
14686 and @option{-fsanitize=kernel-hwaddress}.
14687 To disable instrumentation of builtin functions use
14688 @option{--param hwasan-instrument-mem-intrinsics=0}.
14690 @item use-after-scope-direct-emission-threshold
14691 If the size of a local variable in bytes is smaller or equal to this
14692 number, directly poison (or unpoison) shadow memory instead of using
14693 run-time callbacks.
14695 @item tsan-distinguish-volatile
14696 Emit special instrumentation for accesses to volatiles.
14698 @item tsan-instrument-func-entry-exit
14699 Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
14701 @item max-fsm-thread-path-insns
14702 Maximum number of instructions to copy when duplicating blocks on a
14703 finite state automaton jump thread path.
14705 @item max-fsm-thread-length
14706 Maximum number of basic blocks on a jump thread path.
14708 @item threader-debug
14709 threader-debug=[none|all] Enables verbose dumping of the threader solver.
14711 @item parloops-chunk-size
14712 Chunk size of omp schedule for loops parallelized by parloops.
14714 @item parloops-schedule
14715 Schedule type of omp schedule for loops parallelized by parloops (static,
14716 dynamic, guided, auto, runtime).
14718 @item parloops-min-per-thread
14719 The minimum number of iterations per thread of an innermost parallelized
14720 loop for which the parallelized variant is preferred over the single threaded
14721 one. Note that for a parallelized loop nest the
14722 minimum number of iterations of the outermost loop per thread is two.
14724 @item max-ssa-name-query-depth
14725 Maximum depth of recursion when querying properties of SSA names in things
14726 like fold routines. One level of recursion corresponds to following a
14729 @item max-speculative-devirt-maydefs
14730 The maximum number of may-defs we analyze when looking for a must-def
14731 specifying the dynamic type of an object that invokes a virtual call
14732 we may be able to devirtualize speculatively.
14734 @item max-vrp-switch-assertions
14735 The maximum number of assertions to add along the default edge of a switch
14736 statement during VRP.
14738 @item evrp-sparse-threshold
14739 Maximum number of basic blocks before EVRP uses a sparse cache.
14742 Specifies the mode Early VRP should operate in.
14745 Specifies the mode VRP pass 1 should operate in.
14748 Specifies the mode VRP pass 2 should operate in.
14751 Specifies the type of debug output to be issued for ranges.
14753 @item evrp-switch-limit
14754 Specifies the maximum number of switch cases before EVRP ignores a switch.
14756 @item unroll-jam-min-percent
14757 The minimum percentage of memory references that must be optimized
14758 away for the unroll-and-jam transformation to be considered profitable.
14760 @item unroll-jam-max-unroll
14761 The maximum number of times the outer loop should be unrolled by
14762 the unroll-and-jam transformation.
14764 @item max-rtl-if-conversion-unpredictable-cost
14765 Maximum permissible cost for the sequence that would be generated
14766 by the RTL if-conversion pass for a branch that is considered unpredictable.
14768 @item max-variable-expansions-in-unroller
14769 If @option{-fvariable-expansion-in-unroller} is used, the maximum number
14770 of times that an individual variable will be expanded during loop unrolling.
14772 @item partial-inlining-entry-probability
14773 Maximum probability of the entry BB of split region
14774 (in percent relative to entry BB of the function)
14775 to make partial inlining happen.
14777 @item max-tracked-strlens
14778 Maximum number of strings for which strlen optimization pass will
14779 track string lengths.
14781 @item gcse-after-reload-partial-fraction
14782 The threshold ratio for performing partial redundancy
14783 elimination after reload.
14785 @item gcse-after-reload-critical-fraction
14786 The threshold ratio of critical edges execution count that
14787 permit performing redundancy elimination after reload.
14789 @item max-loop-header-insns
14790 The maximum number of insns in loop header duplicated
14791 by the copy loop headers pass.
14793 @item vect-epilogues-nomask
14794 Enable loop epilogue vectorization using smaller vector size.
14796 @item vect-partial-vector-usage
14797 Controls when the loop vectorizer considers using partial vector loads
14798 and stores as an alternative to falling back to scalar code. 0 stops
14799 the vectorizer from ever using partial vector loads and stores. 1 allows
14800 partial vector loads and stores if vectorization removes the need for the
14801 code to iterate. 2 allows partial vector loads and stores in all loops.
14802 The parameter only has an effect on targets that support partial
14803 vector loads and stores.
14805 @item vect-inner-loop-cost-factor
14806 The maximum factor which the loop vectorizer applies to the cost of statements
14807 in an inner loop relative to the loop being vectorized. The factor applied
14808 is the maximum of the estimated number of iterations of the inner loop and
14809 this parameter. The default value of this parameter is 50.
14811 @item avoid-fma-max-bits
14812 Maximum number of bits for which we avoid creating FMAs.
14814 @item sms-loop-average-count-threshold
14815 A threshold on the average loop count considered by the swing modulo scheduler.
14817 @item sms-dfa-history
14818 The number of cycles the swing modulo scheduler considers when checking
14819 conflicts using DFA.
14821 @item graphite-allow-codegen-errors
14822 Whether codegen errors should be ICEs when @option{-fchecking}.
14824 @item sms-max-ii-factor
14825 A factor for tuning the upper bound that swing modulo scheduler
14826 uses for scheduling a loop.
14828 @item lra-max-considered-reload-pseudos
14829 The max number of reload pseudos which are considered during
14830 spilling a non-reload pseudo.
14832 @item max-pow-sqrt-depth
14833 Maximum depth of sqrt chains to use when synthesizing exponentiation
14834 by a real constant.
14836 @item max-dse-active-local-stores
14837 Maximum number of active local stores in RTL dead store elimination.
14839 @item asan-instrument-allocas
14840 Enable asan allocas/VLAs protection.
14842 @item max-iterations-computation-cost
14843 Bound on the cost of an expression to compute the number of iterations.
14845 @item max-isl-operations
14846 Maximum number of isl operations, 0 means unlimited.
14848 @item graphite-max-arrays-per-scop
14849 Maximum number of arrays per scop.
14851 @item max-vartrack-reverse-op-size
14852 Max. size of loc list for which reverse ops should be added.
14854 @item fsm-scale-path-stmts
14855 Scale factor to apply to the number of statements in a threading path
14856 when comparing to the number of (scaled) blocks.
14858 @item uninit-control-dep-attempts
14859 Maximum number of nested calls to search for control dependencies
14860 during uninitialized variable analysis.
14862 @item fsm-scale-path-blocks
14863 Scale factor to apply to the number of blocks in a threading path
14864 when comparing to the number of (scaled) statements.
14866 @item sched-autopref-queue-depth
14867 Hardware autoprefetcher scheduler model control flag.
14868 Number of lookahead cycles the model looks into; at '
14869 ' only enable instruction sorting heuristic.
14871 @item loop-versioning-max-inner-insns
14872 The maximum number of instructions that an inner loop can have
14873 before the loop versioning pass considers it too big to copy.
14875 @item loop-versioning-max-outer-insns
14876 The maximum number of instructions that an outer loop can have
14877 before the loop versioning pass considers it too big to copy,
14878 discounting any instructions in inner loops that directly benefit
14881 @item ssa-name-def-chain-limit
14882 The maximum number of SSA_NAME assignments to follow in determining
14883 a property of a variable such as its value. This limits the number
14884 of iterations or recursive calls GCC performs when optimizing certain
14885 statements or when determining their validity prior to issuing
14888 @item store-merging-max-size
14889 Maximum size of a single store merging region in bytes.
14891 @item hash-table-verification-limit
14892 The number of elements for which hash table verification is done
14893 for each searched element.
14895 @item max-find-base-term-values
14896 Maximum number of VALUEs handled during a single find_base_term call.
14898 @item analyzer-max-enodes-per-program-point
14899 The maximum number of exploded nodes per program point within
14900 the analyzer, before terminating analysis of that point.
14902 @item analyzer-max-constraints
14903 The maximum number of constraints per state.
14905 @item analyzer-min-snodes-for-call-summary
14906 The minimum number of supernodes within a function for the
14907 analyzer to consider summarizing its effects at call sites.
14909 @item analyzer-max-enodes-for-full-dump
14910 The maximum depth of exploded nodes that should appear in a dot dump
14911 before switching to a less verbose format.
14913 @item analyzer-max-recursion-depth
14914 The maximum number of times a callsite can appear in a call stack
14915 within the analyzer, before terminating analysis of a call that would
14918 @item analyzer-max-svalue-depth
14919 The maximum depth of a symbolic value, before approximating
14920 the value as unknown.
14922 @item analyzer-max-infeasible-edges
14923 The maximum number of infeasible edges to reject before declaring
14924 a diagnostic as infeasible.
14926 @item gimple-fe-computed-hot-bb-threshold
14927 The number of executions of a basic block which is considered hot.
14928 The parameter is used only in GIMPLE FE.
14930 @item analyzer-bb-explosion-factor
14931 The maximum number of 'after supernode' exploded nodes within the analyzer
14932 per supernode, before terminating analysis.
14934 @item ranger-logical-depth
14935 Maximum depth of logical expression evaluation ranger will look through
14936 when evaluating outgoing edge ranges.
14938 @item openacc-kernels
14939 Specify mode of OpenACC `kernels' constructs handling.
14940 With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
14941 constructs are decomposed into parts, a sequence of compute
14942 constructs, each then handled individually.
14943 This is work in progress.
14944 With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
14945 constructs are handled by the @samp{parloops} pass, en bloc.
14946 This is the current default.
14948 @item openacc-privatization
14949 Specify mode of OpenACC privatization diagnostics for
14950 @option{-fopt-info-omp-note} and applicable
14951 @option{-fdump-tree-*-details}.
14952 With @option{--param=openacc-privatization=quiet}, don't diagnose.
14953 This is the current default.
14954 With @option{--param=openacc-privatization=noisy}, do diagnose.
14958 The following choices of @var{name} are available on AArch64 targets:
14961 @item aarch64-sve-compare-costs
14962 When vectorizing for SVE, consider using ``unpacked'' vectors for
14963 smaller elements and use the cost model to pick the cheapest approach.
14964 Also use the cost model to choose between SVE and Advanced SIMD vectorization.
14966 Using unpacked vectors includes storing smaller elements in larger
14967 containers and accessing elements with extending loads and truncating
14970 @item aarch64-float-recp-precision
14971 The number of Newton iterations for calculating the reciprocal for float type.
14972 The precision of division is proportional to this param when division
14973 approximation is enabled. The default value is 1.
14975 @item aarch64-double-recp-precision
14976 The number of Newton iterations for calculating the reciprocal for double type.
14977 The precision of division is propotional to this param when division
14978 approximation is enabled. The default value is 2.
14980 @item aarch64-autovec-preference
14981 Force an ISA selection strategy for auto-vectorization. Accepts values from
14985 Use the default heuristics.
14987 Use only Advanced SIMD for auto-vectorization.
14989 Use only SVE for auto-vectorization.
14991 Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
14994 Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
14996 The default value is 0.
14998 @item aarch64-loop-vect-issue-rate-niters
14999 The tuning for some AArch64 CPUs tries to take both latencies and issue
15000 rates into account when deciding whether a loop should be vectorized
15001 using SVE, vectorized using Advanced SIMD, or not vectorized at all.
15002 If this parameter is set to @var{n}, GCC will not use this heuristic
15003 for loops that are known to execute in fewer than @var{n} Advanced
15010 @node Instrumentation Options
15011 @section Program Instrumentation Options
15012 @cindex instrumentation options
15013 @cindex program instrumentation options
15014 @cindex run-time error checking options
15015 @cindex profiling options
15016 @cindex options, program instrumentation
15017 @cindex options, run-time error checking
15018 @cindex options, profiling
15020 GCC supports a number of command-line options that control adding
15021 run-time instrumentation to the code it normally generates.
15022 For example, one purpose of instrumentation is collect profiling
15023 statistics for use in finding program hot spots, code coverage
15024 analysis, or profile-guided optimizations.
15025 Another class of program instrumentation is adding run-time checking
15026 to detect programming errors like invalid pointer
15027 dereferences or out-of-bounds array accesses, as well as deliberately
15028 hostile attacks such as stack smashing or C++ vtable hijacking.
15029 There is also a general hook which can be used to implement other
15030 forms of tracing or function-level instrumentation for debug or
15031 program analysis purposes.
15034 @cindex @command{prof}
15035 @cindex @command{gprof}
15040 Generate extra code to write profile information suitable for the
15041 analysis program @command{prof} (for @option{-p}) or @command{gprof}
15042 (for @option{-pg}). You must use this option when compiling
15043 the source files you want data about, and you must also use it when
15046 You can use the function attribute @code{no_instrument_function} to
15047 suppress profiling of individual functions when compiling with these options.
15048 @xref{Common Function Attributes}.
15050 @item -fprofile-arcs
15051 @opindex fprofile-arcs
15052 Add code so that program flow @dfn{arcs} are instrumented. During
15053 execution the program records how many times each branch and call is
15054 executed and how many times it is taken or returns. On targets that support
15055 constructors with priority support, profiling properly handles constructors,
15056 destructors and C++ constructors (and destructors) of classes which are used
15057 as a type of a global variable.
15060 program exits it saves this data to a file called
15061 @file{@var{auxname}.gcda} for each source file. The data may be used for
15062 profile-directed optimizations (@option{-fbranch-probabilities}), or for
15063 test coverage analysis (@option{-ftest-coverage}). Each object file's
15064 @var{auxname} is generated from the name of the output file, if
15065 explicitly specified and it is not the final executable, otherwise it is
15066 the basename of the source file. In both cases any suffix is removed
15067 (e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
15068 @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
15069 @xref{Cross-profiling}.
15071 @cindex @command{gcov}
15075 This option is used to compile and link code instrumented for coverage
15076 analysis. The option is a synonym for @option{-fprofile-arcs}
15077 @option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
15078 linking). See the documentation for those options for more details.
15083 Compile the source files with @option{-fprofile-arcs} plus optimization
15084 and code generation options. For test coverage analysis, use the
15085 additional @option{-ftest-coverage} option. You do not need to profile
15086 every source file in a program.
15089 Compile the source files additionally with @option{-fprofile-abs-path}
15090 to create absolute path names in the @file{.gcno} files. This allows
15091 @command{gcov} to find the correct sources in projects where compilations
15092 occur with different working directories.
15095 Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
15096 (the latter implies the former).
15099 Run the program on a representative workload to generate the arc profile
15100 information. This may be repeated any number of times. You can run
15101 concurrent instances of your program, and provided that the file system
15102 supports locking, the data files will be correctly updated. Unless
15103 a strict ISO C dialect option is in effect, @code{fork} calls are
15104 detected and correctly handled without double counting.
15106 Moreover, an object file can be recompiled multiple times
15107 and the corresponding @file{.gcda} file merges as long as
15108 the source file and the compiler options are unchanged.
15111 For profile-directed optimizations, compile the source files again with
15112 the same optimization and code generation options plus
15113 @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
15114 Control Optimization}).
15117 For test coverage analysis, use @command{gcov} to produce human readable
15118 information from the @file{.gcno} and @file{.gcda} files. Refer to the
15119 @command{gcov} documentation for further information.
15123 With @option{-fprofile-arcs}, for each function of your program GCC
15124 creates a program flow graph, then finds a spanning tree for the graph.
15125 Only arcs that are not on the spanning tree have to be instrumented: the
15126 compiler adds code to count the number of times that these arcs are
15127 executed. When an arc is the only exit or only entrance to a block, the
15128 instrumentation code can be added to the block; otherwise, a new basic
15129 block must be created to hold the instrumentation code.
15132 @item -ftest-coverage
15133 @opindex ftest-coverage
15134 Produce a notes file that the @command{gcov} code-coverage utility
15135 (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
15136 show program coverage. Each source file's note file is called
15137 @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
15138 above for a description of @var{auxname} and instructions on how to
15139 generate test coverage data. Coverage data matches the source files
15140 more closely if you do not optimize.
15142 @item -fprofile-abs-path
15143 @opindex fprofile-abs-path
15144 Automatically convert relative source file names to absolute path names
15145 in the @file{.gcno} files. This allows @command{gcov} to find the correct
15146 sources in projects where compilations occur with different working
15149 @item -fprofile-dir=@var{path}
15150 @opindex fprofile-dir
15152 Set the directory to search for the profile data files in to @var{path}.
15153 This option affects only the profile data generated by
15154 @option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
15155 and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
15156 and its related options. Both absolute and relative paths can be used.
15157 By default, GCC uses the current directory as @var{path}, thus the
15158 profile data file appears in the same directory as the object file.
15159 In order to prevent the file name clashing, if the object file name is
15160 not an absolute path, we mangle the absolute path of the
15161 @file{@var{sourcename}.gcda} file and use it as the file name of a
15162 @file{.gcda} file. See similar option @option{-fprofile-note}.
15164 When an executable is run in a massive parallel environment, it is recommended
15165 to save profile to different folders. That can be done with variables
15166 in @var{path} that are exported during run-time:
15174 value of environment variable @var{VAR}
15178 @item -fprofile-generate
15179 @itemx -fprofile-generate=@var{path}
15180 @opindex fprofile-generate
15182 Enable options usually used for instrumenting application to produce
15183 profile useful for later recompilation with profile feedback based
15184 optimization. You must use @option{-fprofile-generate} both when
15185 compiling and when linking your program.
15187 The following options are enabled:
15188 @option{-fprofile-arcs}, @option{-fprofile-values},
15189 @option{-finline-functions}, and @option{-fipa-bit-cp}.
15191 If @var{path} is specified, GCC looks at the @var{path} to find
15192 the profile feedback data files. See @option{-fprofile-dir}.
15194 To optimize the program based on the collected profile information, use
15195 @option{-fprofile-use}. @xref{Optimize Options}, for more information.
15197 @item -fprofile-info-section
15198 @itemx -fprofile-info-section=@var{name}
15199 @opindex fprofile-info-section
15201 Register the profile information in the specified section instead of using a
15202 constructor/destructor. The section name is @var{name} if it is specified,
15203 otherwise the section name defaults to @code{.gcov_info}. A pointer to the
15204 profile information generated by @option{-fprofile-arcs} is placed in the
15205 specified section for each translation unit. This option disables the profile
15206 information registration through a constructor and it disables the profile
15207 information processing through a destructor. This option is not intended to be
15208 used in hosted environments such as GNU/Linux. It targets free-standing
15209 environments (for example embedded systems) with limited resources which do not
15210 support constructors/destructors or the C library file I/O.
15212 The linker could collect the input sections in a continuous memory block and
15213 define start and end symbols. A GNU linker script example which defines a
15214 linker output section follows:
15219 PROVIDE (__gcov_info_start = .);
15220 KEEP (*(.gcov_info))
15221 PROVIDE (__gcov_info_end = .);
15225 The program could dump the profiling information registered in this linker set
15226 for example like this:
15231 #include <stdlib.h>
15233 extern const struct gcov_info *__gcov_info_start[];
15234 extern const struct gcov_info *__gcov_info_end[];
15237 filename (const char *f, void *arg)
15243 dump (const void *d, unsigned n, void *arg)
15245 const unsigned char *c = d;
15247 for (unsigned i = 0; i < n; ++i)
15248 printf ("%02x", c[i]);
15252 allocate (unsigned length, void *arg)
15254 return malloc (length);
15258 dump_gcov_info (void)
15260 const struct gcov_info **info = __gcov_info_start;
15261 const struct gcov_info **end = __gcov_info_end;
15263 /* Obfuscate variable to prevent compiler optimizations. */
15264 __asm__ ("" : "+r" (info));
15266 while (info != end)
15269 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
15283 @item -fprofile-note=@var{path}
15284 @opindex fprofile-note
15286 If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
15287 location. If you combine the option with multiple source files,
15288 the @file{.gcno} file will be overwritten.
15290 @item -fprofile-prefix-path=@var{path}
15291 @opindex fprofile-prefix-path
15293 This option can be used in combination with
15294 @option{profile-generate=}@var{profile_dir} and
15295 @option{profile-use=}@var{profile_dir} to inform GCC where is the base
15296 directory of built source tree. By default @var{profile_dir} will contain
15297 files with mangled absolute paths of all object files in the built project.
15298 This is not desirable when directory used to build the instrumented binary
15299 differs from the directory used to build the binary optimized with profile
15300 feedback because the profile data will not be found during the optimized build.
15301 In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
15302 pointing to the base directory of the build can be used to strip the irrelevant
15303 part of the path and keep all file names relative to the main build directory.
15305 @item -fprofile-prefix-map=@var{old}=@var{new}
15306 @opindex fprofile-prefix-map
15307 When compiling files residing in directory @file{@var{old}}, record
15308 profiling information (with @option{--coverage})
15309 describing them as if the files resided in
15310 directory @file{@var{new}} instead.
15311 See also @option{-ffile-prefix-map}.
15313 @item -fprofile-update=@var{method}
15314 @opindex fprofile-update
15316 Alter the update method for an application instrumented for profile
15317 feedback based optimization. The @var{method} argument should be one of
15318 @samp{single}, @samp{atomic} or @samp{prefer-atomic}.
15319 The first one is useful for single-threaded applications,
15320 while the second one prevents profile corruption by emitting thread-safe code.
15322 @strong{Warning:} When an application does not properly join all threads
15323 (or creates an detached thread), a profile file can be still corrupted.
15325 Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
15326 when supported by a target, or to @samp{single} otherwise. The GCC driver
15327 automatically selects @samp{prefer-atomic} when @option{-pthread}
15328 is present in the command line.
15330 @item -fprofile-filter-files=@var{regex}
15331 @opindex fprofile-filter-files
15333 Instrument only functions from files whose name matches
15334 any of the regular expressions (separated by semi-colons).
15336 For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
15337 only @file{main.c} and all C files starting with 'module'.
15339 @item -fprofile-exclude-files=@var{regex}
15340 @opindex fprofile-exclude-files
15342 Instrument only functions from files whose name does not match
15343 any of the regular expressions (separated by semi-colons).
15345 For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
15346 of all files that are located in the @file{/usr/} folder.
15348 @item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
15349 @opindex fprofile-reproducible
15350 Control level of reproducibility of profile gathered by
15351 @code{-fprofile-generate}. This makes it possible to rebuild program
15352 with same outcome which is useful, for example, for distribution
15355 With @option{-fprofile-reproducible=serial} the profile gathered by
15356 @option{-fprofile-generate} is reproducible provided the trained program
15357 behaves the same at each invocation of the train run, it is not
15358 multi-threaded and profile data streaming is always done in the same
15359 order. Note that profile streaming happens at the end of program run but
15360 also before @code{fork} function is invoked.
15362 Note that it is quite common that execution counts of some part of
15363 programs depends, for example, on length of temporary file names or
15364 memory space randomization (that may affect hash-table collision rate).
15365 Such non-reproducible part of programs may be annotated by
15366 @code{no_instrument_function} function attribute. @command{gcov-dump} with
15367 @option{-l} can be used to dump gathered data and verify that they are
15368 indeed reproducible.
15370 With @option{-fprofile-reproducible=parallel-runs} collected profile
15371 stays reproducible regardless the order of streaming of the data into
15372 gcda files. This setting makes it possible to run multiple instances of
15373 instrumented program in parallel (such as with @code{make -j}). This
15374 reduces quality of gathered data, in particular of indirect call
15377 @item -fsanitize=address
15378 @opindex fsanitize=address
15379 Enable AddressSanitizer, a fast memory error detector.
15380 Memory access instructions are instrumented to detect
15381 out-of-bounds and use-after-free bugs.
15382 The option enables @option{-fsanitize-address-use-after-scope}.
15383 See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
15384 more details. The run-time behavior can be influenced using the
15385 @env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
15386 the available options are shown at startup of the instrumented program. See
15387 @url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
15388 for a list of supported options.
15389 The option cannot be combined with @option{-fsanitize=thread} or
15390 @option{-fsanitize=hwaddress}. Note that the only target
15391 @option{-fsanitize=hwaddress} is currently supported on is AArch64.
15393 @item -fsanitize=kernel-address
15394 @opindex fsanitize=kernel-address
15395 Enable AddressSanitizer for Linux kernel.
15396 See @uref{https://github.com/google/kasan} for more details.
15398 @item -fsanitize=hwaddress
15399 @opindex fsanitize=hwaddress
15400 Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
15401 ignore the top byte of a pointer to allow the detection of memory errors with
15402 a low memory overhead.
15403 Memory access instructions are instrumented to detect out-of-bounds and
15404 use-after-free bugs.
15405 The option enables @option{-fsanitize-address-use-after-scope}.
15407 @uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
15408 for more details. The run-time behavior can be influenced using the
15409 @env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
15410 the available options are shown at startup of the instrumented program.
15411 The option cannot be combined with @option{-fsanitize=thread} or
15412 @option{-fsanitize=address}, and is currently only available on AArch64.
15414 @item -fsanitize=kernel-hwaddress
15415 @opindex fsanitize=kernel-hwaddress
15416 Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
15417 Similar to @option{-fsanitize=kernel-address} but using an alternate
15418 instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
15419 instrumentation differences necessary for compiling the Linux kernel.
15420 These differences are to avoid hwasan library initialization calls and to
15421 account for the stack pointer having a different value in its top byte.
15423 @emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
15424 Instrumenting the stack and alloca calls are not on by default but are still
15425 possible by specifying the command-line options
15426 @option{--param hwasan-instrument-stack=1} and
15427 @option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
15428 tag is not implemented for kernel instrumentation.
15430 @item -fsanitize=pointer-compare
15431 @opindex fsanitize=pointer-compare
15432 Instrument comparison operation (<, <=, >, >=) with pointer operands.
15433 The option must be combined with either @option{-fsanitize=kernel-address} or
15434 @option{-fsanitize=address}
15435 The option cannot be combined with @option{-fsanitize=thread}.
15436 Note: By default the check is disabled at run time. To enable it,
15437 add @code{detect_invalid_pointer_pairs=2} to the environment variable
15438 @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
15439 invalid operation only when both pointers are non-null.
15441 @item -fsanitize=pointer-subtract
15442 @opindex fsanitize=pointer-subtract
15443 Instrument subtraction with pointer operands.
15444 The option must be combined with either @option{-fsanitize=kernel-address} or
15445 @option{-fsanitize=address}
15446 The option cannot be combined with @option{-fsanitize=thread}.
15447 Note: By default the check is disabled at run time. To enable it,
15448 add @code{detect_invalid_pointer_pairs=2} to the environment variable
15449 @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
15450 invalid operation only when both pointers are non-null.
15452 @item -fsanitize=thread
15453 @opindex fsanitize=thread
15454 Enable ThreadSanitizer, a fast data race detector.
15455 Memory access instructions are instrumented to detect
15456 data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
15457 details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
15458 environment variable; see
15459 @url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
15461 The option cannot be combined with @option{-fsanitize=address},
15462 @option{-fsanitize=leak}.
15464 Note that sanitized atomic builtins cannot throw exceptions when
15465 operating on invalid memory addresses with non-call exceptions
15466 (@option{-fnon-call-exceptions}).
15468 @item -fsanitize=leak
15469 @opindex fsanitize=leak
15470 Enable LeakSanitizer, a memory leak detector.
15471 This option only matters for linking of executables and
15472 the executable is linked against a library that overrides @code{malloc}
15473 and other allocator functions. See
15474 @uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
15475 details. The run-time behavior can be influenced using the
15476 @env{LSAN_OPTIONS} environment variable.
15477 The option cannot be combined with @option{-fsanitize=thread}.
15479 @item -fsanitize=undefined
15480 @opindex fsanitize=undefined
15481 Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
15482 Various computations are instrumented to detect undefined behavior
15483 at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
15484 @env{UBSAN_OPTIONS} environment variable. Current suboptions are:
15488 @item -fsanitize=shift
15489 @opindex fsanitize=shift
15490 This option enables checking that the result of a shift operation is
15491 not undefined. Note that what exactly is considered undefined differs
15492 slightly between C and C++, as well as between ISO C90 and C99, etc.
15493 This option has two suboptions, @option{-fsanitize=shift-base} and
15494 @option{-fsanitize=shift-exponent}.
15496 @item -fsanitize=shift-exponent
15497 @opindex fsanitize=shift-exponent
15498 This option enables checking that the second argument of a shift operation
15499 is not negative and is smaller than the precision of the promoted first
15502 @item -fsanitize=shift-base
15503 @opindex fsanitize=shift-base
15504 If the second argument of a shift operation is within range, check that the
15505 result of a shift operation is not undefined. Note that what exactly is
15506 considered undefined differs slightly between C and C++, as well as between
15507 ISO C90 and C99, etc.
15509 @item -fsanitize=integer-divide-by-zero
15510 @opindex fsanitize=integer-divide-by-zero
15511 Detect integer division by zero.
15513 @item -fsanitize=unreachable
15514 @opindex fsanitize=unreachable
15515 With this option, the compiler turns the @code{__builtin_unreachable}
15516 call into a diagnostics message call instead. When reaching the
15517 @code{__builtin_unreachable} call, the behavior is undefined.
15519 @item -fsanitize=vla-bound
15520 @opindex fsanitize=vla-bound
15521 This option instructs the compiler to check that the size of a variable
15522 length array is positive.
15524 @item -fsanitize=null
15525 @opindex fsanitize=null
15526 This option enables pointer checking. Particularly, the application
15527 built with this option turned on will issue an error message when it
15528 tries to dereference a NULL pointer, or if a reference (possibly an
15529 rvalue reference) is bound to a NULL pointer, or if a method is invoked
15530 on an object pointed by a NULL pointer.
15532 @item -fsanitize=return
15533 @opindex fsanitize=return
15534 This option enables return statement checking. Programs
15535 built with this option turned on will issue an error message
15536 when the end of a non-void function is reached without actually
15537 returning a value. This option works in C++ only.
15539 @item -fsanitize=signed-integer-overflow
15540 @opindex fsanitize=signed-integer-overflow
15541 This option enables signed integer overflow checking. We check that
15542 the result of @code{+}, @code{*}, and both unary and binary @code{-}
15543 does not overflow in the signed arithmetics. This also detects
15544 @code{INT_MIN / -1} signed division. Note, integer promotion
15545 rules must be taken into account. That is, the following is not an
15548 signed char a = SCHAR_MAX;
15552 @item -fsanitize=bounds
15553 @opindex fsanitize=bounds
15554 This option enables instrumentation of array bounds. Various out of bounds
15555 accesses are detected. Flexible array members, flexible array member-like
15556 arrays, and initializers of variables with static storage are not instrumented.
15558 @item -fsanitize=bounds-strict
15559 @opindex fsanitize=bounds-strict
15560 This option enables strict instrumentation of array bounds. Most out of bounds
15561 accesses are detected, including flexible array members and flexible array
15562 member-like arrays. Initializers of variables with static storage are not
15565 @item -fsanitize=alignment
15566 @opindex fsanitize=alignment
15568 This option enables checking of alignment of pointers when they are
15569 dereferenced, or when a reference is bound to insufficiently aligned target,
15570 or when a method or constructor is invoked on insufficiently aligned object.
15572 @item -fsanitize=object-size
15573 @opindex fsanitize=object-size
15574 This option enables instrumentation of memory references using the
15575 @code{__builtin_object_size} function. Various out of bounds pointer
15576 accesses are detected.
15578 @item -fsanitize=float-divide-by-zero
15579 @opindex fsanitize=float-divide-by-zero
15580 Detect floating-point division by zero. Unlike other similar options,
15581 @option{-fsanitize=float-divide-by-zero} is not enabled by
15582 @option{-fsanitize=undefined}, since floating-point division by zero can
15583 be a legitimate way of obtaining infinities and NaNs.
15585 @item -fsanitize=float-cast-overflow
15586 @opindex fsanitize=float-cast-overflow
15587 This option enables floating-point type to integer conversion checking.
15588 We check that the result of the conversion does not overflow.
15589 Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
15590 not enabled by @option{-fsanitize=undefined}.
15591 This option does not work well with @code{FE_INVALID} exceptions enabled.
15593 @item -fsanitize=nonnull-attribute
15594 @opindex fsanitize=nonnull-attribute
15596 This option enables instrumentation of calls, checking whether null values
15597 are not passed to arguments marked as requiring a non-null value by the
15598 @code{nonnull} function attribute.
15600 @item -fsanitize=returns-nonnull-attribute
15601 @opindex fsanitize=returns-nonnull-attribute
15603 This option enables instrumentation of return statements in functions
15604 marked with @code{returns_nonnull} function attribute, to detect returning
15605 of null values from such functions.
15607 @item -fsanitize=bool
15608 @opindex fsanitize=bool
15610 This option enables instrumentation of loads from bool. If a value other
15611 than 0/1 is loaded, a run-time error is issued.
15613 @item -fsanitize=enum
15614 @opindex fsanitize=enum
15616 This option enables instrumentation of loads from an enum type. If
15617 a value outside the range of values for the enum type is loaded,
15618 a run-time error is issued.
15620 @item -fsanitize=vptr
15621 @opindex fsanitize=vptr
15623 This option enables instrumentation of C++ member function calls, member
15624 accesses and some conversions between pointers to base and derived classes,
15625 to verify the referenced object has the correct dynamic type.
15627 @item -fsanitize=pointer-overflow
15628 @opindex fsanitize=pointer-overflow
15630 This option enables instrumentation of pointer arithmetics. If the pointer
15631 arithmetics overflows, a run-time error is issued.
15633 @item -fsanitize=builtin
15634 @opindex fsanitize=builtin
15636 This option enables instrumentation of arguments to selected builtin
15637 functions. If an invalid value is passed to such arguments, a run-time
15638 error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
15639 or @code{__builtin_clz} invokes undefined behavior and is diagnosed
15644 While @option{-ftrapv} causes traps for signed overflows to be emitted,
15645 @option{-fsanitize=undefined} gives a diagnostic message.
15646 This currently works only for the C family of languages.
15648 @item -fno-sanitize=all
15649 @opindex fno-sanitize=all
15651 This option disables all previously enabled sanitizers.
15652 @option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
15655 @item -fasan-shadow-offset=@var{number}
15656 @opindex fasan-shadow-offset
15657 This option forces GCC to use custom shadow offset in AddressSanitizer checks.
15658 It is useful for experimenting with different shadow memory layouts in
15659 Kernel AddressSanitizer.
15661 @item -fsanitize-sections=@var{s1},@var{s2},...
15662 @opindex fsanitize-sections
15663 Sanitize global variables in selected user-defined sections. @var{si} may
15666 @item -fsanitize-recover@r{[}=@var{opts}@r{]}
15667 @opindex fsanitize-recover
15668 @opindex fno-sanitize-recover
15669 @option{-fsanitize-recover=} controls error recovery mode for sanitizers
15670 mentioned in comma-separated list of @var{opts}. Enabling this option
15671 for a sanitizer component causes it to attempt to continue
15672 running the program as if no error happened. This means multiple
15673 runtime errors can be reported in a single program run, and the exit
15674 code of the program may indicate success even when errors
15675 have been reported. The @option{-fno-sanitize-recover=} option
15676 can be used to alter
15677 this behavior: only the first detected error is reported
15678 and program then exits with a non-zero exit code.
15680 Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
15681 except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
15682 @option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
15683 @option{-fsanitize=bounds-strict},
15684 @option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
15685 For these sanitizers error recovery is turned on by default,
15686 except @option{-fsanitize=address}, for which this feature is experimental.
15687 @option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
15688 accepted, the former enables recovery for all sanitizers that support it,
15689 the latter disables recovery for all sanitizers that support it.
15691 Even if a recovery mode is turned on the compiler side, it needs to be also
15692 enabled on the runtime library side, otherwise the failures are still fatal.
15693 The runtime library defaults to @code{halt_on_error=0} for
15694 ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
15695 AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
15696 setting the @code{halt_on_error} flag in the corresponding environment variable.
15698 Syntax without an explicit @var{opts} parameter is deprecated. It is
15699 equivalent to specifying an @var{opts} list of:
15702 undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
15705 @item -fsanitize-address-use-after-scope
15706 @opindex fsanitize-address-use-after-scope
15707 Enable sanitization of local variables to detect use-after-scope bugs.
15708 The option sets @option{-fstack-reuse} to @samp{none}.
15710 @item -fsanitize-undefined-trap-on-error
15711 @opindex fsanitize-undefined-trap-on-error
15712 The @option{-fsanitize-undefined-trap-on-error} option instructs the compiler to
15713 report undefined behavior using @code{__builtin_trap} rather than
15714 a @code{libubsan} library routine. The advantage of this is that the
15715 @code{libubsan} library is not needed and is not linked in, so this
15716 is usable even in freestanding environments.
15718 @item -fsanitize-coverage=trace-pc
15719 @opindex fsanitize-coverage=trace-pc
15720 Enable coverage-guided fuzzing code instrumentation.
15721 Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
15723 @item -fsanitize-coverage=trace-cmp
15724 @opindex fsanitize-coverage=trace-cmp
15725 Enable dataflow guided fuzzing code instrumentation.
15726 Inserts a call to @code{__sanitizer_cov_trace_cmp1},
15727 @code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
15728 @code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
15729 variable or @code{__sanitizer_cov_trace_const_cmp1},
15730 @code{__sanitizer_cov_trace_const_cmp2},
15731 @code{__sanitizer_cov_trace_const_cmp4} or
15732 @code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
15733 operand constant, @code{__sanitizer_cov_trace_cmpf} or
15734 @code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
15735 @code{__sanitizer_cov_trace_switch} for switch statements.
15737 @item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
15738 @opindex fcf-protection
15739 Enable code instrumentation of control-flow transfers to increase
15740 program security by checking that target addresses of control-flow
15741 transfer instructions (such as indirect function call, function return,
15742 indirect jump) are valid. This prevents diverting the flow of control
15743 to an unexpected target. This is intended to protect against such
15744 threats as Return-oriented Programming (ROP), and similarly
15745 call/jmp-oriented programming (COP/JOP).
15747 The value @code{branch} tells the compiler to implement checking of
15748 validity of control-flow transfer at the point of indirect branch
15749 instructions, i.e.@: call/jmp instructions. The value @code{return}
15750 implements checking of validity at the point of returning from a
15751 function. The value @code{full} is an alias for specifying both
15752 @code{branch} and @code{return}. The value @code{none} turns off
15755 The value @code{check} is used for the final link with link-time
15756 optimization (LTO). An error is issued if LTO object files are
15757 compiled with different @option{-fcf-protection} values. The
15758 value @code{check} is ignored at the compile time.
15760 The macro @code{__CET__} is defined when @option{-fcf-protection} is
15761 used. The first bit of @code{__CET__} is set to 1 for the value
15762 @code{branch} and the second bit of @code{__CET__} is set to 1 for
15765 You can also use the @code{nocf_check} attribute to identify
15766 which functions and calls should be skipped from instrumentation
15767 (@pxref{Function Attributes}).
15769 Currently the x86 GNU/Linux target provides an implementation based
15770 on Intel Control-flow Enforcement Technology (CET) which works for
15771 i686 processor or newer.
15773 @item -fharden-compares
15774 @opindex fharden-compares
15775 For every logical test that survives gimple optimizations and is
15776 @emph{not} the condition in a conditional branch (for example,
15777 conditions tested for conditional moves, or to store in boolean
15778 variables), emit extra code to compute and verify the reversed
15779 condition, and to call @code{__builtin_trap} if the results do not
15780 match. Use with @samp{-fharden-conditional-branches} to cover all
15783 @item -fharden-conditional-branches
15784 @opindex fharden-conditional-branches
15785 For every non-vectorized conditional branch that survives gimple
15786 optimizations, emit extra code to compute and verify the reversed
15787 condition, and to call @code{__builtin_trap} if the result is
15788 unexpected. Use with @samp{-fharden-compares} to cover all
15791 @item -fstack-protector
15792 @opindex fstack-protector
15793 Emit extra code to check for buffer overflows, such as stack smashing
15794 attacks. This is done by adding a guard variable to functions with
15795 vulnerable objects. This includes functions that call @code{alloca}, and
15796 functions with buffers larger than or equal to 8 bytes. The guards are
15797 initialized when a function is entered and then checked when the function
15798 exits. If a guard check fails, an error message is printed and the program
15799 exits. Only variables that are actually allocated on the stack are
15800 considered, optimized away variables or variables allocated in registers
15803 @item -fstack-protector-all
15804 @opindex fstack-protector-all
15805 Like @option{-fstack-protector} except that all functions are protected.
15807 @item -fstack-protector-strong
15808 @opindex fstack-protector-strong
15809 Like @option{-fstack-protector} but includes additional functions to
15810 be protected --- those that have local array definitions, or have
15811 references to local frame addresses. Only variables that are actually
15812 allocated on the stack are considered, optimized away variables or variables
15813 allocated in registers don't count.
15815 @item -fstack-protector-explicit
15816 @opindex fstack-protector-explicit
15817 Like @option{-fstack-protector} but only protects those functions which
15818 have the @code{stack_protect} attribute.
15820 @item -fstack-check
15821 @opindex fstack-check
15822 Generate code to verify that you do not go beyond the boundary of the
15823 stack. You should specify this flag if you are running in an
15824 environment with multiple threads, but you only rarely need to specify it in
15825 a single-threaded environment since stack overflow is automatically
15826 detected on nearly all systems if there is only one stack.
15828 Note that this switch does not actually cause checking to be done; the
15829 operating system or the language runtime must do that. The switch causes
15830 generation of code to ensure that they see the stack being extended.
15832 You can additionally specify a string parameter: @samp{no} means no
15833 checking, @samp{generic} means force the use of old-style checking,
15834 @samp{specific} means use the best checking method and is equivalent
15835 to bare @option{-fstack-check}.
15837 Old-style checking is a generic mechanism that requires no specific
15838 target support in the compiler but comes with the following drawbacks:
15842 Modified allocation strategy for large objects: they are always
15843 allocated dynamically if their size exceeds a fixed threshold. Note this
15844 may change the semantics of some code.
15847 Fixed limit on the size of the static frame of functions: when it is
15848 topped by a particular function, stack checking is not reliable and
15849 a warning is issued by the compiler.
15852 Inefficiency: because of both the modified allocation strategy and the
15853 generic implementation, code performance is hampered.
15856 Note that old-style stack checking is also the fallback method for
15857 @samp{specific} if no target support has been added in the compiler.
15859 @samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
15860 and stack overflows. @samp{specific} is an excellent choice when compiling
15861 Ada code. It is not generally sufficient to protect against stack-clash
15862 attacks. To protect against those you want @samp{-fstack-clash-protection}.
15864 @item -fstack-clash-protection
15865 @opindex fstack-clash-protection
15866 Generate code to prevent stack clash style attacks. When this option is
15867 enabled, the compiler will only allocate one page of stack space at a time
15868 and each page is accessed immediately after allocation. Thus, it prevents
15869 allocations from jumping over any stack guard page provided by the
15872 Most targets do not fully support stack clash protection. However, on
15873 those targets @option{-fstack-clash-protection} will protect dynamic stack
15874 allocations. @option{-fstack-clash-protection} may also provide limited
15875 protection for static stack allocations if the target supports
15876 @option{-fstack-check=specific}.
15878 @item -fstack-limit-register=@var{reg}
15879 @itemx -fstack-limit-symbol=@var{sym}
15880 @itemx -fno-stack-limit
15881 @opindex fstack-limit-register
15882 @opindex fstack-limit-symbol
15883 @opindex fno-stack-limit
15884 Generate code to ensure that the stack does not grow beyond a certain value,
15885 either the value of a register or the address of a symbol. If a larger
15886 stack is required, a signal is raised at run time. For most targets,
15887 the signal is raised before the stack overruns the boundary, so
15888 it is possible to catch the signal without taking special precautions.
15890 For instance, if the stack starts at absolute address @samp{0x80000000}
15891 and grows downwards, you can use the flags
15892 @option{-fstack-limit-symbol=__stack_limit} and
15893 @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
15894 of 128KB@. Note that this may only work with the GNU linker.
15896 You can locally override stack limit checking by using the
15897 @code{no_stack_limit} function attribute (@pxref{Function Attributes}).
15899 @item -fsplit-stack
15900 @opindex fsplit-stack
15901 Generate code to automatically split the stack before it overflows.
15902 The resulting program has a discontiguous stack which can only
15903 overflow if the program is unable to allocate any more memory. This
15904 is most useful when running threaded programs, as it is no longer
15905 necessary to calculate a good stack size to use for each thread. This
15906 is currently only implemented for the x86 targets running
15909 When code compiled with @option{-fsplit-stack} calls code compiled
15910 without @option{-fsplit-stack}, there may not be much stack space
15911 available for the latter code to run. If compiling all code,
15912 including library code, with @option{-fsplit-stack} is not an option,
15913 then the linker can fix up these calls so that the code compiled
15914 without @option{-fsplit-stack} always has a large stack. Support for
15915 this is implemented in the gold linker in GNU binutils release 2.21
15918 @item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
15919 @opindex fvtable-verify
15920 This option is only available when compiling C++ code.
15921 It turns on (or off, if using @option{-fvtable-verify=none}) the security
15922 feature that verifies at run time, for every virtual call, that
15923 the vtable pointer through which the call is made is valid for the type of
15924 the object, and has not been corrupted or overwritten. If an invalid vtable
15925 pointer is detected at run time, an error is reported and execution of the
15926 program is immediately halted.
15928 This option causes run-time data structures to be built at program startup,
15929 which are used for verifying the vtable pointers.
15930 The options @samp{std} and @samp{preinit}
15931 control the timing of when these data structures are built. In both cases the
15932 data structures are built before execution reaches @code{main}. Using
15933 @option{-fvtable-verify=std} causes the data structures to be built after
15934 shared libraries have been loaded and initialized.
15935 @option{-fvtable-verify=preinit} causes them to be built before shared
15936 libraries have been loaded and initialized.
15938 If this option appears multiple times in the command line with different
15939 values specified, @samp{none} takes highest priority over both @samp{std} and
15940 @samp{preinit}; @samp{preinit} takes priority over @samp{std}.
15943 @opindex fvtv-debug
15944 When used in conjunction with @option{-fvtable-verify=std} or
15945 @option{-fvtable-verify=preinit}, causes debug versions of the
15946 runtime functions for the vtable verification feature to be called.
15947 This flag also causes the compiler to log information about which
15948 vtable pointers it finds for each class.
15949 This information is written to a file named @file{vtv_set_ptr_data.log}
15950 in the directory named by the environment variable @env{VTV_LOGS_DIR}
15951 if that is defined or the current working directory otherwise.
15953 Note: This feature @emph{appends} data to the log file. If you want a fresh log
15954 file, be sure to delete any existing one.
15957 @opindex fvtv-counts
15958 This is a debugging flag. When used in conjunction with
15959 @option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
15960 causes the compiler to keep track of the total number of virtual calls
15961 it encounters and the number of verifications it inserts. It also
15962 counts the number of calls to certain run-time library functions
15963 that it inserts and logs this information for each compilation unit.
15964 The compiler writes this information to a file named
15965 @file{vtv_count_data.log} in the directory named by the environment
15966 variable @env{VTV_LOGS_DIR} if that is defined or the current working
15967 directory otherwise. It also counts the size of the vtable pointer sets
15968 for each class, and writes this information to @file{vtv_class_set_sizes.log}
15969 in the same directory.
15971 Note: This feature @emph{appends} data to the log files. To get fresh log
15972 files, be sure to delete any existing ones.
15974 @item -finstrument-functions
15975 @opindex finstrument-functions
15976 Generate instrumentation calls for entry and exit to functions. Just
15977 after function entry and just before function exit, the following
15978 profiling functions are called with the address of the current
15979 function and its call site. (On some platforms,
15980 @code{__builtin_return_address} does not work beyond the current
15981 function, so the call site information may not be available to the
15982 profiling functions otherwise.)
15985 void __cyg_profile_func_enter (void *this_fn,
15987 void __cyg_profile_func_exit (void *this_fn,
15991 The first argument is the address of the start of the current function,
15992 which may be looked up exactly in the symbol table.
15994 This instrumentation is also done for functions expanded inline in other
15995 functions. The profiling calls indicate where, conceptually, the
15996 inline function is entered and exited. This means that addressable
15997 versions of such functions must be available. If all your uses of a
15998 function are expanded inline, this may mean an additional expansion of
15999 code size. If you use @code{extern inline} in your C code, an
16000 addressable version of such functions must be provided. (This is
16001 normally the case anyway, but if you get lucky and the optimizer always
16002 expands the functions inline, you might have gotten away without
16003 providing static copies.)
16005 A function may be given the attribute @code{no_instrument_function}, in
16006 which case this instrumentation is not done. This can be used, for
16007 example, for the profiling functions listed above, high-priority
16008 interrupt routines, and any functions from which the profiling functions
16009 cannot safely be called (perhaps signal handlers, if the profiling
16010 routines generate output or allocate memory).
16011 @xref{Common Function Attributes}.
16013 @item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
16014 @opindex finstrument-functions-exclude-file-list
16016 Set the list of functions that are excluded from instrumentation (see
16017 the description of @option{-finstrument-functions}). If the file that
16018 contains a function definition matches with one of @var{file}, then
16019 that function is not instrumented. The match is done on substrings:
16020 if the @var{file} parameter is a substring of the file name, it is
16021 considered to be a match.
16026 -finstrument-functions-exclude-file-list=/bits/stl,include/sys
16030 excludes any inline function defined in files whose pathnames
16031 contain @file{/bits/stl} or @file{include/sys}.
16033 If, for some reason, you want to include letter @samp{,} in one of
16034 @var{sym}, write @samp{\,}. For example,
16035 @option{-finstrument-functions-exclude-file-list='\,\,tmp'}
16036 (note the single quote surrounding the option).
16038 @item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
16039 @opindex finstrument-functions-exclude-function-list
16041 This is similar to @option{-finstrument-functions-exclude-file-list},
16042 but this option sets the list of function names to be excluded from
16043 instrumentation. The function name to be matched is its user-visible
16044 name, such as @code{vector<int> blah(const vector<int> &)}, not the
16045 internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
16046 match is done on substrings: if the @var{sym} parameter is a substring
16047 of the function name, it is considered to be a match. For C99 and C++
16048 extended identifiers, the function name must be given in UTF-8, not
16049 using universal character names.
16051 @item -fpatchable-function-entry=@var{N}[,@var{M}]
16052 @opindex fpatchable-function-entry
16053 Generate @var{N} NOPs right at the beginning
16054 of each function, with the function entry point before the @var{M}th NOP.
16055 If @var{M} is omitted, it defaults to @code{0} so the
16056 function entry points to the address just at the first NOP.
16057 The NOP instructions reserve extra space which can be used to patch in
16058 any desired instrumentation at run time, provided that the code segment
16059 is writable. The amount of space is controllable indirectly via
16060 the number of NOPs; the NOP instruction used corresponds to the instruction
16061 emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
16062 is target-specific and may also depend on the architecture variant and/or
16063 other compilation options.
16065 For run-time identification, the starting addresses of these areas,
16066 which correspond to their respective function entries minus @var{M},
16067 are additionally collected in the @code{__patchable_function_entries}
16068 section of the resulting binary.
16070 Note that the value of @code{__attribute__ ((patchable_function_entry
16071 (N,M)))} takes precedence over command-line option
16072 @option{-fpatchable-function-entry=N,M}. This can be used to increase
16073 the area size or to remove it completely on a single function.
16074 If @code{N=0}, no pad location is recorded.
16076 The NOP instructions are inserted at---and maybe before, depending on
16077 @var{M}---the function entry address, even before the prologue.
16079 The maximum value of @var{N} and @var{M} is 65535.
16083 @node Preprocessor Options
16084 @section Options Controlling the Preprocessor
16085 @cindex preprocessor options
16086 @cindex options, preprocessor
16088 These options control the C preprocessor, which is run on each C source
16089 file before actual compilation.
16091 If you use the @option{-E} option, nothing is done except preprocessing.
16092 Some of these options make sense only together with @option{-E} because
16093 they cause the preprocessor output to be unsuitable for actual
16096 In addition to the options listed here, there are a number of options
16097 to control search paths for include files documented in
16098 @ref{Directory Options}.
16099 Options to control preprocessor diagnostics are listed in
16100 @ref{Warning Options}.
16103 @include cppopts.texi
16105 @item -Wp,@var{option}
16107 You can use @option{-Wp,@var{option}} to bypass the compiler driver
16108 and pass @var{option} directly through to the preprocessor. If
16109 @var{option} contains commas, it is split into multiple options at the
16110 commas. However, many options are modified, translated or interpreted
16111 by the compiler driver before being passed to the preprocessor, and
16112 @option{-Wp} forcibly bypasses this phase. The preprocessor's direct
16113 interface is undocumented and subject to change, so whenever possible
16114 you should avoid using @option{-Wp} and let the driver handle the
16117 @item -Xpreprocessor @var{option}
16118 @opindex Xpreprocessor
16119 Pass @var{option} as an option to the preprocessor. You can use this to
16120 supply system-specific preprocessor options that GCC does not
16123 If you want to pass an option that takes an argument, you must use
16124 @option{-Xpreprocessor} twice, once for the option and once for the argument.
16126 @item -no-integrated-cpp
16127 @opindex no-integrated-cpp
16128 Perform preprocessing as a separate pass before compilation.
16129 By default, GCC performs preprocessing as an integrated part of
16130 input tokenization and parsing.
16131 If this option is provided, the appropriate language front end
16132 (@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
16133 and Objective-C, respectively) is instead invoked twice,
16134 once for preprocessing only and once for actual compilation
16135 of the preprocessed input.
16136 This option may be useful in conjunction with the @option{-B} or
16137 @option{-wrapper} options to specify an alternate preprocessor or
16138 perform additional processing of the program source between
16139 normal preprocessing and compilation.
16141 @item -flarge-source-files
16142 @opindex flarge-source-files
16143 Adjust GCC to expect large source files, at the expense of slower
16144 compilation and higher memory usage.
16146 Specifically, GCC normally tracks both column numbers and line numbers
16147 within source files and it normally prints both of these numbers in
16148 diagnostics. However, once it has processed a certain number of source
16149 lines, it stops tracking column numbers and only tracks line numbers.
16150 This means that diagnostics for later lines do not include column numbers.
16151 It also means that options like @option{-Wmisleading-indentation} cease to work
16152 at that point, although the compiler prints a note if this happens.
16153 Passing @option{-flarge-source-files} significantly increases the number
16154 of source lines that GCC can process before it stops tracking columns.
16158 @node Assembler Options
16159 @section Passing Options to the Assembler
16161 @c prevent bad page break with this line
16162 You can pass options to the assembler.
16165 @item -Wa,@var{option}
16167 Pass @var{option} as an option to the assembler. If @var{option}
16168 contains commas, it is split into multiple options at the commas.
16170 @item -Xassembler @var{option}
16171 @opindex Xassembler
16172 Pass @var{option} as an option to the assembler. You can use this to
16173 supply system-specific assembler options that GCC does not
16176 If you want to pass an option that takes an argument, you must use
16177 @option{-Xassembler} twice, once for the option and once for the argument.
16182 @section Options for Linking
16183 @cindex link options
16184 @cindex options, linking
16186 These options come into play when the compiler links object files into
16187 an executable output file. They are meaningless if the compiler is
16188 not doing a link step.
16192 @item @var{object-file-name}
16193 A file name that does not end in a special recognized suffix is
16194 considered to name an object file or library. (Object files are
16195 distinguished from libraries by the linker according to the file
16196 contents.) If linking is done, these object files are used as input
16205 If any of these options is used, then the linker is not run, and
16206 object file names should not be used as arguments. @xref{Overall
16209 @item -flinker-output=@var{type}
16210 @opindex flinker-output
16211 This option controls code generation of the link-time optimizer. By
16212 default the linker output is automatically determined by the linker
16213 plugin. For debugging the compiler and if incremental linking with a
16214 non-LTO object file is desired, it may be useful to control the type
16217 If @var{type} is @samp{exec}, code generation produces a static
16218 binary. In this case @option{-fpic} and @option{-fpie} are both
16221 If @var{type} is @samp{dyn}, code generation produces a shared
16222 library. In this case @option{-fpic} or @option{-fPIC} is preserved,
16223 but not enabled automatically. This allows to build shared libraries
16224 without position-independent code on architectures where this is
16225 possible, i.e.@: on x86.
16227 If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
16228 executable. This results in similar optimizations as @samp{exec}
16229 except that @option{-fpie} is not disabled if specified at compilation
16232 If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
16233 done. The sections containing intermediate code for link-time optimization are
16234 merged, pre-optimized, and output to the resulting object file. In addition, if
16235 @option{-ffat-lto-objects} is specified, binary code is produced for future
16236 non-LTO linking. The object file produced by incremental linking is smaller
16237 than a static library produced from the same object files. At link time the
16238 result of incremental linking also loads faster than a static
16239 library assuming that the majority of objects in the library are used.
16241 Finally @samp{nolto-rel} configures the compiler for incremental linking where
16242 code generation is forced, a final binary is produced, and the intermediate
16243 code for later link-time optimization is stripped. When multiple object files
16244 are linked together the resulting code is better optimized than with
16245 link-time optimizations disabled (for example, cross-module inlining
16246 happens), but most of benefits of whole program optimizations are lost.
16248 During the incremental link (by @option{-r}) the linker plugin defaults to
16249 @option{rel}. With current interfaces to GNU Binutils it is however not
16250 possible to incrementally link LTO objects and non-LTO objects into a single
16251 mixed object file. If any of object files in incremental link cannot
16252 be used for link-time optimization, the linker plugin issues a warning and
16253 uses @samp{nolto-rel}. To maintain whole program optimization, it is
16254 recommended to link such objects into static library instead. Alternatively it
16255 is possible to use H.J. Lu's binutils with support for mixed objects.
16258 @opindex fuse-ld=bfd
16259 Use the @command{bfd} linker instead of the default linker.
16261 @item -fuse-ld=gold
16262 @opindex fuse-ld=gold
16263 Use the @command{gold} linker instead of the default linker.
16266 @opindex fuse-ld=lld
16267 Use the LLVM @command{lld} linker instead of the default linker.
16270 @item -l@var{library}
16271 @itemx -l @var{library}
16273 Search the library named @var{library} when linking. (The second
16274 alternative with the library as a separate argument is only for
16275 POSIX compliance and is not recommended.)
16277 The @option{-l} option is passed directly to the linker by GCC. Refer
16278 to your linker documentation for exact details. The general
16279 description below applies to the GNU linker.
16281 The linker searches a standard list of directories for the library.
16282 The directories searched include several standard system directories
16283 plus any that you specify with @option{-L}.
16285 Static libraries are archives of object files, and have file names
16286 like @file{lib@var{library}.a}. Some targets also support shared
16287 libraries, which typically have names like @file{lib@var{library}.so}.
16288 If both static and shared libraries are found, the linker gives
16289 preference to linking with the shared library unless the
16290 @option{-static} option is used.
16292 It makes a difference where in the command you write this option; the
16293 linker searches and processes libraries and object files in the order they
16294 are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
16295 after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
16296 to functions in @samp{z}, those functions may not be loaded.
16300 You need this special case of the @option{-l} option in order to
16301 link an Objective-C or Objective-C++ program.
16303 @item -nostartfiles
16304 @opindex nostartfiles
16305 Do not use the standard system startup files when linking.
16306 The standard system libraries are used normally, unless @option{-nostdlib},
16307 @option{-nolibc}, or @option{-nodefaultlibs} is used.
16309 @item -nodefaultlibs
16310 @opindex nodefaultlibs
16311 Do not use the standard system libraries when linking.
16312 Only the libraries you specify are passed to the linker, and options
16313 specifying linkage of the system libraries, such as @option{-static-libgcc}
16314 or @option{-shared-libgcc}, are ignored.
16315 The standard startup files are used normally, unless @option{-nostartfiles}
16318 The compiler may generate calls to @code{memcmp},
16319 @code{memset}, @code{memcpy} and @code{memmove}.
16320 These entries are usually resolved by entries in
16321 libc. These entry points should be supplied through some other
16322 mechanism when this option is specified.
16326 Do not use the C library or system libraries tightly coupled with it when
16327 linking. Still link with the startup files, @file{libgcc} or toolchain
16328 provided language support libraries such as @file{libgnat}, @file{libgfortran}
16329 or @file{libstdc++} unless options preventing their inclusion are used as
16330 well. This typically removes @option{-lc} from the link command line, as well
16331 as system libraries that normally go with it and become meaningless when
16332 absence of a C library is assumed, for example @option{-lpthread} or
16333 @option{-lm} in some configurations. This is intended for bare-board
16334 targets when there is indeed no C library available.
16338 Do not use the standard system startup files or libraries when linking.
16339 No startup files and only the libraries you specify are passed to
16340 the linker, and options specifying linkage of the system libraries, such as
16341 @option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
16343 The compiler may generate calls to @code{memcmp}, @code{memset},
16344 @code{memcpy} and @code{memmove}.
16345 These entries are usually resolved by entries in
16346 libc. These entry points should be supplied through some other
16347 mechanism when this option is specified.
16349 @cindex @option{-lgcc}, use with @option{-nostdlib}
16350 @cindex @option{-nostdlib} and unresolved references
16351 @cindex unresolved references and @option{-nostdlib}
16352 @cindex @option{-lgcc}, use with @option{-nodefaultlibs}
16353 @cindex @option{-nodefaultlibs} and unresolved references
16354 @cindex unresolved references and @option{-nodefaultlibs}
16355 One of the standard libraries bypassed by @option{-nostdlib} and
16356 @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
16357 which GCC uses to overcome shortcomings of particular machines, or special
16358 needs for some languages.
16359 (@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
16360 Collection (GCC) Internals},
16361 for more discussion of @file{libgcc.a}.)
16362 In most cases, you need @file{libgcc.a} even when you want to avoid
16363 other standard libraries. In other words, when you specify @option{-nostdlib}
16364 or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
16365 This ensures that you have no unresolved references to internal GCC
16366 library subroutines.
16367 (An example of such an internal subroutine is @code{__main}, used to ensure C++
16368 constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
16369 GNU Compiler Collection (GCC) Internals}.)
16371 @item -e @var{entry}
16372 @itemx --entry=@var{entry}
16376 Specify that the program entry point is @var{entry}. The argument is
16377 interpreted by the linker; the GNU linker accepts either a symbol name
16382 Produce a dynamically linked position independent executable on targets
16383 that support it. For predictable results, you must also specify the same
16384 set of options used for compilation (@option{-fpie}, @option{-fPIE},
16385 or model suboptions) when you specify this linker option.
16389 Don't produce a dynamically linked position independent executable.
16392 @opindex static-pie
16393 Produce a static position independent executable on targets that support
16394 it. A static position independent executable is similar to a static
16395 executable, but can be loaded at any address without a dynamic linker.
16396 For predictable results, you must also specify the same set of options
16397 used for compilation (@option{-fpie}, @option{-fPIE}, or model
16398 suboptions) when you specify this linker option.
16402 Link with the POSIX threads library. This option is supported on
16403 GNU/Linux targets, most other Unix derivatives, and also on
16404 x86 Cygwin and MinGW targets. On some targets this option also sets
16405 flags for the preprocessor, so it should be used consistently for both
16406 compilation and linking.
16410 Produce a relocatable object as output. This is also known as partial
16415 Pass the flag @option{-export-dynamic} to the ELF linker, on targets
16416 that support it. This instructs the linker to add all symbols, not
16417 only used ones, to the dynamic symbol table. This option is needed
16418 for some uses of @code{dlopen} or to allow obtaining backtraces
16419 from within a program.
16423 Remove all symbol table and relocation information from the executable.
16427 On systems that support dynamic linking, this overrides @option{-pie}
16428 and prevents linking with the shared libraries. On other systems, this
16429 option has no effect.
16433 Produce a shared object which can then be linked with other objects to
16434 form an executable. Not all systems support this option. For predictable
16435 results, you must also specify the same set of options used for compilation
16436 (@option{-fpic}, @option{-fPIC}, or model suboptions) when
16437 you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
16438 needs to build supplementary stub code for constructors to work. On
16439 multi-libbed systems, @samp{gcc -shared} must select the correct support
16440 libraries to link against. Failing to supply the correct flags may lead
16441 to subtle defects. Supplying them in cases where they are not necessary
16444 @item -shared-libgcc
16445 @itemx -static-libgcc
16446 @opindex shared-libgcc
16447 @opindex static-libgcc
16448 On systems that provide @file{libgcc} as a shared library, these options
16449 force the use of either the shared or static version, respectively.
16450 If no shared version of @file{libgcc} was built when the compiler was
16451 configured, these options have no effect.
16453 There are several situations in which an application should use the
16454 shared @file{libgcc} instead of the static version. The most common
16455 of these is when the application wishes to throw and catch exceptions
16456 across different shared libraries. In that case, each of the libraries
16457 as well as the application itself should use the shared @file{libgcc}.
16459 Therefore, the G++ driver automatically adds @option{-shared-libgcc}
16460 whenever you build a shared library or a main executable, because C++
16461 programs typically use exceptions, so this is the right thing to do.
16463 If, instead, you use the GCC driver to create shared libraries, you may
16464 find that they are not always linked with the shared @file{libgcc}.
16465 If GCC finds, at its configuration time, that you have a non-GNU linker
16466 or a GNU linker that does not support option @option{--eh-frame-hdr},
16467 it links the shared version of @file{libgcc} into shared libraries
16468 by default. Otherwise, it takes advantage of the linker and optimizes
16469 away the linking with the shared version of @file{libgcc}, linking with
16470 the static version of libgcc by default. This allows exceptions to
16471 propagate through such shared libraries, without incurring relocation
16472 costs at library load time.
16474 However, if a library or main executable is supposed to throw or catch
16475 exceptions, you must link it using the G++ driver, or using the option
16476 @option{-shared-libgcc}, such that it is linked with the shared
16479 @item -static-libasan
16480 @opindex static-libasan
16481 When the @option{-fsanitize=address} option is used to link a program,
16482 the GCC driver automatically links against @option{libasan}. If
16483 @file{libasan} is available as a shared library, and the @option{-static}
16484 option is not used, then this links against the shared version of
16485 @file{libasan}. The @option{-static-libasan} option directs the GCC
16486 driver to link @file{libasan} statically, without necessarily linking
16487 other libraries statically.
16489 @item -static-libtsan
16490 @opindex static-libtsan
16491 When the @option{-fsanitize=thread} option is used to link a program,
16492 the GCC driver automatically links against @option{libtsan}. If
16493 @file{libtsan} is available as a shared library, and the @option{-static}
16494 option is not used, then this links against the shared version of
16495 @file{libtsan}. The @option{-static-libtsan} option directs the GCC
16496 driver to link @file{libtsan} statically, without necessarily linking
16497 other libraries statically.
16499 @item -static-liblsan
16500 @opindex static-liblsan
16501 When the @option{-fsanitize=leak} option is used to link a program,
16502 the GCC driver automatically links against @option{liblsan}. If
16503 @file{liblsan} is available as a shared library, and the @option{-static}
16504 option is not used, then this links against the shared version of
16505 @file{liblsan}. The @option{-static-liblsan} option directs the GCC
16506 driver to link @file{liblsan} statically, without necessarily linking
16507 other libraries statically.
16509 @item -static-libubsan
16510 @opindex static-libubsan
16511 When the @option{-fsanitize=undefined} option is used to link a program,
16512 the GCC driver automatically links against @option{libubsan}. If
16513 @file{libubsan} is available as a shared library, and the @option{-static}
16514 option is not used, then this links against the shared version of
16515 @file{libubsan}. The @option{-static-libubsan} option directs the GCC
16516 driver to link @file{libubsan} statically, without necessarily linking
16517 other libraries statically.
16519 @item -static-libstdc++
16520 @opindex static-libstdc++
16521 When the @command{g++} program is used to link a C++ program, it
16522 normally automatically links against @option{libstdc++}. If
16523 @file{libstdc++} is available as a shared library, and the
16524 @option{-static} option is not used, then this links against the
16525 shared version of @file{libstdc++}. That is normally fine. However, it
16526 is sometimes useful to freeze the version of @file{libstdc++} used by
16527 the program without going all the way to a fully static link. The
16528 @option{-static-libstdc++} option directs the @command{g++} driver to
16529 link @file{libstdc++} statically, without necessarily linking other
16530 libraries statically.
16534 Bind references to global symbols when building a shared object. Warn
16535 about any unresolved references (unless overridden by the link editor
16536 option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
16539 @item -T @var{script}
16541 @cindex linker script
16542 Use @var{script} as the linker script. This option is supported by most
16543 systems using the GNU linker. On some targets, such as bare-board
16544 targets without an operating system, the @option{-T} option may be required
16545 when linking to avoid references to undefined symbols.
16547 @item -Xlinker @var{option}
16549 Pass @var{option} as an option to the linker. You can use this to
16550 supply system-specific linker options that GCC does not recognize.
16552 If you want to pass an option that takes a separate argument, you must use
16553 @option{-Xlinker} twice, once for the option and once for the argument.
16554 For example, to pass @option{-assert definitions}, you must write
16555 @option{-Xlinker -assert -Xlinker definitions}. It does not work to write
16556 @option{-Xlinker "-assert definitions"}, because this passes the entire
16557 string as a single argument, which is not what the linker expects.
16559 When using the GNU linker, it is usually more convenient to pass
16560 arguments to linker options using the @option{@var{option}=@var{value}}
16561 syntax than as separate arguments. For example, you can specify
16562 @option{-Xlinker -Map=output.map} rather than
16563 @option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
16564 this syntax for command-line options.
16566 @item -Wl,@var{option}
16568 Pass @var{option} as an option to the linker. If @var{option} contains
16569 commas, it is split into multiple options at the commas. You can use this
16570 syntax to pass an argument to the option.
16571 For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
16572 linker. When using the GNU linker, you can also get the same effect with
16573 @option{-Wl,-Map=output.map}.
16575 @item -u @var{symbol}
16577 Pretend the symbol @var{symbol} is undefined, to force linking of
16578 library modules to define it. You can use @option{-u} multiple times with
16579 different symbols to force loading of additional library modules.
16581 @item -z @var{keyword}
16583 @option{-z} is passed directly on to the linker along with the keyword
16584 @var{keyword}. See the section in the documentation of your linker for
16585 permitted values and their meanings.
16588 @node Directory Options
16589 @section Options for Directory Search
16590 @cindex directory options
16591 @cindex options, directory search
16592 @cindex search path
16594 These options specify directories to search for header files, for
16595 libraries and for parts of the compiler:
16598 @include cppdiropts.texi
16600 @item -iplugindir=@var{dir}
16601 @opindex iplugindir=
16602 Set the directory to search for plugins that are passed
16603 by @option{-fplugin=@var{name}} instead of
16604 @option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
16605 to be used by the user, but only passed by the driver.
16609 Add directory @var{dir} to the list of directories to be searched
16612 @item -B@var{prefix}
16614 This option specifies where to find the executables, libraries,
16615 include files, and data files of the compiler itself.
16617 The compiler driver program runs one or more of the subprograms
16618 @command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
16619 @var{prefix} as a prefix for each program it tries to run, both with and
16620 without @samp{@var{machine}/@var{version}/} for the corresponding target
16621 machine and compiler version.
16623 For each subprogram to be run, the compiler driver first tries the
16624 @option{-B} prefix, if any. If that name is not found, or if @option{-B}
16625 is not specified, the driver tries two standard prefixes,
16626 @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
16627 those results in a file name that is found, the unmodified program
16628 name is searched for using the directories specified in your
16629 @env{PATH} environment variable.
16631 The compiler checks to see if the path provided by @option{-B}
16632 refers to a directory, and if necessary it adds a directory
16633 separator character at the end of the path.
16635 @option{-B} prefixes that effectively specify directory names also apply
16636 to libraries in the linker, because the compiler translates these
16637 options into @option{-L} options for the linker. They also apply to
16638 include files in the preprocessor, because the compiler translates these
16639 options into @option{-isystem} options for the preprocessor. In this case,
16640 the compiler appends @samp{include} to the prefix.
16642 The runtime support file @file{libgcc.a} can also be searched for using
16643 the @option{-B} prefix, if needed. If it is not found there, the two
16644 standard prefixes above are tried, and that is all. The file is left
16645 out of the link if it is not found by those means.
16647 Another way to specify a prefix much like the @option{-B} prefix is to use
16648 the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
16651 As a special kludge, if the path provided by @option{-B} is
16652 @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
16653 9, then it is replaced by @file{[dir/]include}. This is to help
16654 with boot-strapping the compiler.
16656 @item -no-canonical-prefixes
16657 @opindex no-canonical-prefixes
16658 Do not expand any symbolic links, resolve references to @samp{/../}
16659 or @samp{/./}, or make the path absolute when generating a relative
16662 @item --sysroot=@var{dir}
16664 Use @var{dir} as the logical root directory for headers and libraries.
16665 For example, if the compiler normally searches for headers in
16666 @file{/usr/include} and libraries in @file{/usr/lib}, it instead
16667 searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
16669 If you use both this option and the @option{-isysroot} option, then
16670 the @option{--sysroot} option applies to libraries, but the
16671 @option{-isysroot} option applies to header files.
16673 The GNU linker (beginning with version 2.16) has the necessary support
16674 for this option. If your linker does not support this option, the
16675 header file aspect of @option{--sysroot} still works, but the
16676 library aspect does not.
16678 @item --no-sysroot-suffix
16679 @opindex no-sysroot-suffix
16680 For some targets, a suffix is added to the root directory specified
16681 with @option{--sysroot}, depending on the other options used, so that
16682 headers may for example be found in
16683 @file{@var{dir}/@var{suffix}/usr/include} instead of
16684 @file{@var{dir}/usr/include}. This option disables the addition of
16689 @node Code Gen Options
16690 @section Options for Code Generation Conventions
16691 @cindex code generation conventions
16692 @cindex options, code generation
16693 @cindex run-time options
16695 These machine-independent options control the interface conventions
16696 used in code generation.
16698 Most of them have both positive and negative forms; the negative form
16699 of @option{-ffoo} is @option{-fno-foo}. In the table below, only
16700 one of the forms is listed---the one that is not the default. You
16701 can figure out the other form by either removing @samp{no-} or adding
16705 @item -fstack-reuse=@var{reuse-level}
16706 @opindex fstack_reuse
16707 This option controls stack space reuse for user declared local/auto variables
16708 and compiler generated temporaries. @var{reuse_level} can be @samp{all},
16709 @samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
16710 local variables and temporaries, @samp{named_vars} enables the reuse only for
16711 user defined local variables with names, and @samp{none} disables stack reuse
16712 completely. The default value is @samp{all}. The option is needed when the
16713 program extends the lifetime of a scoped local variable or a compiler generated
16714 temporary beyond the end point defined by the language. When a lifetime of
16715 a variable ends, and if the variable lives in memory, the optimizing compiler
16716 has the freedom to reuse its stack space with other temporaries or scoped
16717 local variables whose live range does not overlap with it. Legacy code extending
16718 local lifetime is likely to break with the stack reuse optimization.
16737 if (*p == 10) // out of scope use of local1
16748 A(int k) : i(k), j(k) @{ @}
16755 void foo(const A& ar)
16762 foo(A(10)); // temp object's lifetime ends when foo returns
16768 ap->i+= 10; // ap references out of scope temp whose space
16769 // is reused with a. What is the value of ap->i?
16774 The lifetime of a compiler generated temporary is well defined by the C++
16775 standard. When a lifetime of a temporary ends, and if the temporary lives
16776 in memory, the optimizing compiler has the freedom to reuse its stack
16777 space with other temporaries or scoped local variables whose live range
16778 does not overlap with it. However some of the legacy code relies on
16779 the behavior of older compilers in which temporaries' stack space is
16780 not reused, the aggressive stack reuse can lead to runtime errors. This
16781 option is used to control the temporary stack reuse optimization.
16785 This option generates traps for signed overflow on addition, subtraction,
16786 multiplication operations.
16787 The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
16788 @option{-ftrapv} @option{-fwrapv} on the command-line results in
16789 @option{-fwrapv} being effective. Note that only active options override, so
16790 using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
16791 results in @option{-ftrapv} being effective.
16795 This option instructs the compiler to assume that signed arithmetic
16796 overflow of addition, subtraction and multiplication wraps around
16797 using twos-complement representation. This flag enables some optimizations
16798 and disables others.
16799 The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
16800 @option{-ftrapv} @option{-fwrapv} on the command-line results in
16801 @option{-fwrapv} being effective. Note that only active options override, so
16802 using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
16803 results in @option{-ftrapv} being effective.
16805 @item -fwrapv-pointer
16806 @opindex fwrapv-pointer
16807 This option instructs the compiler to assume that pointer arithmetic
16808 overflow on addition and subtraction wraps around using twos-complement
16809 representation. This flag disables some optimizations which assume
16810 pointer overflow is invalid.
16812 @item -fstrict-overflow
16813 @opindex fstrict-overflow
16814 This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
16815 negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
16818 @opindex fexceptions
16819 Enable exception handling. Generates extra code needed to propagate
16820 exceptions. For some targets, this implies GCC generates frame
16821 unwind information for all functions, which can produce significant data
16822 size overhead, although it does not affect execution. If you do not
16823 specify this option, GCC enables it by default for languages like
16824 C++ that normally require exception handling, and disables it for
16825 languages like C that do not normally require it. However, you may need
16826 to enable this option when compiling C code that needs to interoperate
16827 properly with exception handlers written in C++. You may also wish to
16828 disable this option if you are compiling older C++ programs that don't
16829 use exception handling.
16831 @item -fnon-call-exceptions
16832 @opindex fnon-call-exceptions
16833 Generate code that allows trapping instructions to throw exceptions.
16834 Note that this requires platform-specific runtime support that does
16835 not exist everywhere. Moreover, it only allows @emph{trapping}
16836 instructions to throw exceptions, i.e.@: memory references or floating-point
16837 instructions. It does not allow exceptions to be thrown from
16838 arbitrary signal handlers such as @code{SIGALRM}. This enables
16839 @option{-fexceptions}.
16841 @item -fdelete-dead-exceptions
16842 @opindex fdelete-dead-exceptions
16843 Consider that instructions that may throw exceptions but don't otherwise
16844 contribute to the execution of the program can be optimized away.
16845 This does not affect calls to functions except those with the
16846 @code{pure} or @code{const} attributes.
16847 This option is enabled by default for the Ada and C++ compilers, as permitted by
16848 the language specifications.
16849 Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
16851 @item -funwind-tables
16852 @opindex funwind-tables
16853 Similar to @option{-fexceptions}, except that it just generates any needed
16854 static data, but does not affect the generated code in any other way.
16855 You normally do not need to enable this option; instead, a language processor
16856 that needs this handling enables it on your behalf.
16858 @item -fasynchronous-unwind-tables
16859 @opindex fasynchronous-unwind-tables
16860 Generate unwind table in DWARF format, if supported by target machine. The
16861 table is exact at each instruction boundary, so it can be used for stack
16862 unwinding from asynchronous events (such as debugger or garbage collector).
16864 @item -fno-gnu-unique
16865 @opindex fno-gnu-unique
16866 @opindex fgnu-unique
16867 On systems with recent GNU assembler and C library, the C++ compiler
16868 uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
16869 of template static data members and static local variables in inline
16870 functions are unique even in the presence of @code{RTLD_LOCAL}; this
16871 is necessary to avoid problems with a library used by two different
16872 @code{RTLD_LOCAL} plugins depending on a definition in one of them and
16873 therefore disagreeing with the other one about the binding of the
16874 symbol. But this causes @code{dlclose} to be ignored for affected
16875 DSOs; if your program relies on reinitialization of a DSO via
16876 @code{dlclose} and @code{dlopen}, you can use
16877 @option{-fno-gnu-unique}.
16879 @item -fpcc-struct-return
16880 @opindex fpcc-struct-return
16881 Return ``short'' @code{struct} and @code{union} values in memory like
16882 longer ones, rather than in registers. This convention is less
16883 efficient, but it has the advantage of allowing intercallability between
16884 GCC-compiled files and files compiled with other compilers, particularly
16885 the Portable C Compiler (pcc).
16887 The precise convention for returning structures in memory depends
16888 on the target configuration macros.
16890 Short structures and unions are those whose size and alignment match
16891 that of some integer type.
16893 @strong{Warning:} code compiled with the @option{-fpcc-struct-return}
16894 switch is not binary compatible with code compiled with the
16895 @option{-freg-struct-return} switch.
16896 Use it to conform to a non-default application binary interface.
16898 @item -freg-struct-return
16899 @opindex freg-struct-return
16900 Return @code{struct} and @code{union} values in registers when possible.
16901 This is more efficient for small structures than
16902 @option{-fpcc-struct-return}.
16904 If you specify neither @option{-fpcc-struct-return} nor
16905 @option{-freg-struct-return}, GCC defaults to whichever convention is
16906 standard for the target. If there is no standard convention, GCC
16907 defaults to @option{-fpcc-struct-return}, except on targets where GCC is
16908 the principal compiler. In those cases, we can choose the standard, and
16909 we chose the more efficient register return alternative.
16911 @strong{Warning:} code compiled with the @option{-freg-struct-return}
16912 switch is not binary compatible with code compiled with the
16913 @option{-fpcc-struct-return} switch.
16914 Use it to conform to a non-default application binary interface.
16916 @item -fshort-enums
16917 @opindex fshort-enums
16918 Allocate to an @code{enum} type only as many bytes as it needs for the
16919 declared range of possible values. Specifically, the @code{enum} type
16920 is equivalent to the smallest integer type that has enough room.
16922 @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
16923 code that is not binary compatible with code generated without that switch.
16924 Use it to conform to a non-default application binary interface.
16926 @item -fshort-wchar
16927 @opindex fshort-wchar
16928 Override the underlying type for @code{wchar_t} to be @code{short
16929 unsigned int} instead of the default for the target. This option is
16930 useful for building programs to run under WINE@.
16932 @strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
16933 code that is not binary compatible with code generated without that switch.
16934 Use it to conform to a non-default application binary interface.
16938 @opindex fno-common
16939 @cindex tentative definitions
16940 In C code, this option controls the placement of global variables
16941 defined without an initializer, known as @dfn{tentative definitions}
16942 in the C standard. Tentative definitions are distinct from declarations
16943 of a variable with the @code{extern} keyword, which do not allocate storage.
16945 The default is @option{-fno-common}, which specifies that the compiler places
16946 uninitialized global variables in the BSS section of the object file.
16947 This inhibits the merging of tentative definitions by the linker so you get a
16948 multiple-definition error if the same variable is accidentally defined in more
16949 than one compilation unit.
16951 The @option{-fcommon} places uninitialized global variables in a common block.
16952 This allows the linker to resolve all tentative definitions of the same variable
16953 in different compilation units to the same object, or to a non-tentative
16954 definition. This behavior is inconsistent with C++, and on many targets implies
16955 a speed and code size penalty on global variable references. It is mainly
16956 useful to enable legacy code to link without errors.
16961 Ignore the @code{#ident} directive.
16963 @item -finhibit-size-directive
16964 @opindex finhibit-size-directive
16965 Don't output a @code{.size} assembler directive, or anything else that
16966 would cause trouble if the function is split in the middle, and the
16967 two halves are placed at locations far apart in memory. This option is
16968 used when compiling @file{crtstuff.c}; you should not need to use it
16971 @item -fverbose-asm
16972 @opindex fverbose-asm
16973 Put extra commentary information in the generated assembly code to
16974 make it more readable. This option is generally only of use to those
16975 who actually need to read the generated assembly code (perhaps while
16976 debugging the compiler itself).
16978 @option{-fno-verbose-asm}, the default, causes the
16979 extra information to be omitted and is useful when comparing two assembler
16982 The added comments include:
16987 information on the compiler version and command-line options,
16990 the source code lines associated with the assembly instructions,
16991 in the form FILENAME:LINENUMBER:CONTENT OF LINE,
16994 hints on which high-level expressions correspond to
16995 the various assembly instruction operands.
16999 For example, given this C source file:
17007 for (i = 0; i < n; i++)
17014 compiling to (x86_64) assembly via @option{-S} and emitting the result
17015 direct to stdout via @option{-o} @option{-}
17018 gcc -S test.c -fverbose-asm -Os -o -
17021 gives output similar to this:
17025 # GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
17032 .type test, @@function
17036 # test.c:4: int total = 0;
17037 xorl %eax, %eax # <retval>
17038 # test.c:6: for (i = 0; i < n; i++)
17039 xorl %edx, %edx # i
17041 # test.c:6: for (i = 0; i < n; i++)
17042 cmpl %edi, %edx # n, i
17044 # test.c:7: total += i * i;
17045 movl %edx, %ecx # i, tmp92
17046 imull %edx, %ecx # i, tmp92
17047 # test.c:6: for (i = 0; i < n; i++)
17049 # test.c:7: total += i * i;
17050 addl %ecx, %eax # tmp92, <retval>
17058 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
17059 .section .note.GNU-stack,"",@@progbits
17062 The comments are intended for humans rather than machines and hence the
17063 precise format of the comments is subject to change.
17065 @item -frecord-gcc-switches
17066 @opindex frecord-gcc-switches
17067 This switch causes the command line used to invoke the
17068 compiler to be recorded into the object file that is being created.
17069 This switch is only implemented on some targets and the exact format
17070 of the recording is target and binary file format dependent, but it
17071 usually takes the form of a section containing ASCII text. This
17072 switch is related to the @option{-fverbose-asm} switch, but that
17073 switch only records information in the assembler output file as
17074 comments, so it never reaches the object file.
17075 See also @option{-grecord-gcc-switches} for another
17076 way of storing compiler options into the object file.
17080 @cindex global offset table
17082 Generate position-independent code (PIC) suitable for use in a shared
17083 library, if supported for the target machine. Such code accesses all
17084 constant addresses through a global offset table (GOT)@. The dynamic
17085 loader resolves the GOT entries when the program starts (the dynamic
17086 loader is not part of GCC; it is part of the operating system). If
17087 the GOT size for the linked executable exceeds a machine-specific
17088 maximum size, you get an error message from the linker indicating that
17089 @option{-fpic} does not work; in that case, recompile with @option{-fPIC}
17090 instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
17091 on the m68k and RS/6000. The x86 has no such limit.)
17093 Position-independent code requires special support, and therefore works
17094 only on certain machines. For the x86, GCC supports PIC for System V
17095 but not for the Sun 386i. Code generated for the IBM RS/6000 is always
17096 position-independent.
17098 When this flag is set, the macros @code{__pic__} and @code{__PIC__}
17103 If supported for the target machine, emit position-independent code,
17104 suitable for dynamic linking and avoiding any limit on the size of the
17105 global offset table. This option makes a difference on AArch64, m68k,
17106 PowerPC and SPARC@.
17108 Position-independent code requires special support, and therefore works
17109 only on certain machines.
17111 When this flag is set, the macros @code{__pic__} and @code{__PIC__}
17118 These options are similar to @option{-fpic} and @option{-fPIC}, but the
17119 generated position-independent code can be only linked into executables.
17120 Usually these options are used to compile code that will be linked using
17121 the @option{-pie} GCC option.
17123 @option{-fpie} and @option{-fPIE} both define the macros
17124 @code{__pie__} and @code{__PIE__}. The macros have the value 1
17125 for @option{-fpie} and 2 for @option{-fPIE}.
17130 Do not use the PLT for external function calls in position-independent code.
17131 Instead, load the callee address at call sites from the GOT and branch to it.
17132 This leads to more efficient code by eliminating PLT stubs and exposing
17133 GOT loads to optimizations. On architectures such as 32-bit x86 where
17134 PLT stubs expect the GOT pointer in a specific register, this gives more
17135 register allocation freedom to the compiler.
17136 Lazy binding requires use of the PLT;
17137 with @option{-fno-plt} all external symbols are resolved at load time.
17139 Alternatively, the function attribute @code{noplt} can be used to avoid calls
17140 through the PLT for specific external functions.
17142 In position-dependent code, a few targets also convert calls to
17143 functions that are marked to not use the PLT to use the GOT instead.
17145 @item -fno-jump-tables
17146 @opindex fno-jump-tables
17147 @opindex fjump-tables
17148 Do not use jump tables for switch statements even where it would be
17149 more efficient than other code generation strategies. This option is
17150 of use in conjunction with @option{-fpic} or @option{-fPIC} for
17151 building code that forms part of a dynamic linker and cannot
17152 reference the address of a jump table. On some targets, jump tables
17153 do not require a GOT and this option is not needed.
17155 @item -fno-bit-tests
17156 @opindex fno-bit-tests
17157 @opindex fbit-tests
17158 Do not use bit tests for switch statements even where it would be
17159 more efficient than other code generation strategies.
17161 @item -ffixed-@var{reg}
17163 Treat the register named @var{reg} as a fixed register; generated code
17164 should never refer to it (except perhaps as a stack pointer, frame
17165 pointer or in some other fixed role).
17167 @var{reg} must be the name of a register. The register names accepted
17168 are machine-specific and are defined in the @code{REGISTER_NAMES}
17169 macro in the machine description macro file.
17171 This flag does not have a negative form, because it specifies a
17174 @item -fcall-used-@var{reg}
17175 @opindex fcall-used
17176 Treat the register named @var{reg} as an allocable register that is
17177 clobbered by function calls. It may be allocated for temporaries or
17178 variables that do not live across a call. Functions compiled this way
17179 do not save and restore the register @var{reg}.
17181 It is an error to use this flag with the frame pointer or stack pointer.
17182 Use of this flag for other registers that have fixed pervasive roles in
17183 the machine's execution model produces disastrous results.
17185 This flag does not have a negative form, because it specifies a
17188 @item -fcall-saved-@var{reg}
17189 @opindex fcall-saved
17190 Treat the register named @var{reg} as an allocable register saved by
17191 functions. It may be allocated even for temporaries or variables that
17192 live across a call. Functions compiled this way save and restore
17193 the register @var{reg} if they use it.
17195 It is an error to use this flag with the frame pointer or stack pointer.
17196 Use of this flag for other registers that have fixed pervasive roles in
17197 the machine's execution model produces disastrous results.
17199 A different sort of disaster results from the use of this flag for
17200 a register in which function values may be returned.
17202 This flag does not have a negative form, because it specifies a
17205 @item -fpack-struct[=@var{n}]
17206 @opindex fpack-struct
17207 Without a value specified, pack all structure members together without
17208 holes. When a value is specified (which must be a small power of two), pack
17209 structure members according to this value, representing the maximum
17210 alignment (that is, objects with default alignment requirements larger than
17211 this are output potentially unaligned at the next fitting location.
17213 @strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
17214 code that is not binary compatible with code generated without that switch.
17215 Additionally, it makes the code suboptimal.
17216 Use it to conform to a non-default application binary interface.
17218 @item -fleading-underscore
17219 @opindex fleading-underscore
17220 This option and its counterpart, @option{-fno-leading-underscore}, forcibly
17221 change the way C symbols are represented in the object file. One use
17222 is to help link with legacy assembly code.
17224 @strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
17225 generate code that is not binary compatible with code generated without that
17226 switch. Use it to conform to a non-default application binary interface.
17227 Not all targets provide complete support for this switch.
17229 @item -ftls-model=@var{model}
17230 @opindex ftls-model
17231 Alter the thread-local storage model to be used (@pxref{Thread-Local}).
17232 The @var{model} argument should be one of @samp{global-dynamic},
17233 @samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
17234 Note that the choice is subject to optimization: the compiler may use
17235 a more efficient model for symbols not visible outside of the translation
17236 unit, or if @option{-fpic} is not given on the command line.
17238 The default without @option{-fpic} is @samp{initial-exec}; with
17239 @option{-fpic} the default is @samp{global-dynamic}.
17241 @item -ftrampolines
17242 @opindex ftrampolines
17243 For targets that normally need trampolines for nested functions, always
17244 generate them instead of using descriptors. Otherwise, for targets that
17245 do not need them, like for example HP-PA or IA-64, do nothing.
17247 A trampoline is a small piece of code that is created at run time on the
17248 stack when the address of a nested function is taken, and is used to call
17249 the nested function indirectly. Therefore, it requires the stack to be
17250 made executable in order for the program to work properly.
17252 @option{-fno-trampolines} is enabled by default on a language by language
17253 basis to let the compiler avoid generating them, if it computes that this
17254 is safe, and replace them with descriptors. Descriptors are made up of data
17255 only, but the generated code must be prepared to deal with them. As of this
17256 writing, @option{-fno-trampolines} is enabled by default only for Ada.
17258 Moreover, code compiled with @option{-ftrampolines} and code compiled with
17259 @option{-fno-trampolines} are not binary compatible if nested functions are
17260 present. This option must therefore be used on a program-wide basis and be
17261 manipulated with extreme care.
17263 For languages other than Ada, the @code{-ftrampolines} and
17264 @code{-fno-trampolines} options currently have no effect, and
17265 trampolines are always generated on platforms that need them
17266 for nested functions.
17268 @item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
17269 @opindex fvisibility
17270 Set the default ELF image symbol visibility to the specified option---all
17271 symbols are marked with this unless overridden within the code.
17272 Using this feature can very substantially improve linking and
17273 load times of shared object libraries, produce more optimized
17274 code, provide near-perfect API export and prevent symbol clashes.
17275 It is @strong{strongly} recommended that you use this in any shared objects
17278 Despite the nomenclature, @samp{default} always means public; i.e.,
17279 available to be linked against from outside the shared object.
17280 @samp{protected} and @samp{internal} are pretty useless in real-world
17281 usage so the only other commonly used option is @samp{hidden}.
17282 The default if @option{-fvisibility} isn't specified is
17283 @samp{default}, i.e., make every symbol public.
17285 A good explanation of the benefits offered by ensuring ELF
17286 symbols have the correct visibility is given by ``How To Write
17287 Shared Libraries'' by Ulrich Drepper (which can be found at
17288 @w{@uref{https://www.akkadia.org/drepper/}})---however a superior
17289 solution made possible by this option to marking things hidden when
17290 the default is public is to make the default hidden and mark things
17291 public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
17292 and @code{__attribute__ ((visibility("default")))} instead of
17293 @code{__declspec(dllexport)} you get almost identical semantics with
17294 identical syntax. This is a great boon to those working with
17295 cross-platform projects.
17297 For those adding visibility support to existing code, you may find
17298 @code{#pragma GCC visibility} of use. This works by you enclosing
17299 the declarations you wish to set visibility for with (for example)
17300 @code{#pragma GCC visibility push(hidden)} and
17301 @code{#pragma GCC visibility pop}.
17302 Bear in mind that symbol visibility should be viewed @strong{as
17303 part of the API interface contract} and thus all new code should
17304 always specify visibility when it is not the default; i.e., declarations
17305 only for use within the local DSO should @strong{always} be marked explicitly
17306 as hidden as so to avoid PLT indirection overheads---making this
17307 abundantly clear also aids readability and self-documentation of the code.
17308 Note that due to ISO C++ specification requirements, @code{operator new} and
17309 @code{operator delete} must always be of default visibility.
17311 Be aware that headers from outside your project, in particular system
17312 headers and headers from any other library you use, may not be
17313 expecting to be compiled with visibility other than the default. You
17314 may need to explicitly say @code{#pragma GCC visibility push(default)}
17315 before including any such headers.
17317 @code{extern} declarations are not affected by @option{-fvisibility}, so
17318 a lot of code can be recompiled with @option{-fvisibility=hidden} with
17319 no modifications. However, this means that calls to @code{extern}
17320 functions with no explicit visibility use the PLT, so it is more
17321 effective to use @code{__attribute ((visibility))} and/or
17322 @code{#pragma GCC visibility} to tell the compiler which @code{extern}
17323 declarations should be treated as hidden.
17325 Note that @option{-fvisibility} does affect C++ vague linkage
17326 entities. This means that, for instance, an exception class that is
17327 be thrown between DSOs must be explicitly marked with default
17328 visibility so that the @samp{type_info} nodes are unified between
17331 An overview of these techniques, their benefits and how to use them
17332 is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
17334 @item -fstrict-volatile-bitfields
17335 @opindex fstrict-volatile-bitfields
17336 This option should be used if accesses to volatile bit-fields (or other
17337 structure fields, although the compiler usually honors those types
17338 anyway) should use a single access of the width of the
17339 field's type, aligned to a natural alignment if possible. For
17340 example, targets with memory-mapped peripheral registers might require
17341 all such accesses to be 16 bits wide; with this flag you can
17342 declare all peripheral bit-fields as @code{unsigned short} (assuming short
17343 is 16 bits on these targets) to force GCC to use 16-bit accesses
17344 instead of, perhaps, a more efficient 32-bit access.
17346 If this option is disabled, the compiler uses the most efficient
17347 instruction. In the previous example, that might be a 32-bit load
17348 instruction, even though that accesses bytes that do not contain
17349 any portion of the bit-field, or memory-mapped registers unrelated to
17350 the one being updated.
17352 In some cases, such as when the @code{packed} attribute is applied to a
17353 structure field, it may not be possible to access the field with a single
17354 read or write that is correctly aligned for the target machine. In this
17355 case GCC falls back to generating multiple accesses rather than code that
17356 will fault or truncate the result at run time.
17358 Note: Due to restrictions of the C/C++11 memory model, write accesses are
17359 not allowed to touch non bit-field members. It is therefore recommended
17360 to define all bits of the field's type as bit-field members.
17362 The default value of this option is determined by the application binary
17363 interface for the target processor.
17365 @item -fsync-libcalls
17366 @opindex fsync-libcalls
17367 This option controls whether any out-of-line instance of the @code{__sync}
17368 family of functions may be used to implement the C++11 @code{__atomic}
17369 family of functions.
17371 The default value of this option is enabled, thus the only useful form
17372 of the option is @option{-fno-sync-libcalls}. This option is used in
17373 the implementation of the @file{libatomic} runtime library.
17377 @node Developer Options
17378 @section GCC Developer Options
17379 @cindex developer options
17380 @cindex debugging GCC
17381 @cindex debug dump options
17382 @cindex dump options
17383 @cindex compilation statistics
17385 This section describes command-line options that are primarily of
17386 interest to GCC developers, including options to support compiler
17387 testing and investigation of compiler bugs and compile-time
17388 performance problems. This includes options that produce debug dumps
17389 at various points in the compilation; that print statistics such as
17390 memory use and execution time; and that print information about GCC's
17391 configuration, such as where it searches for libraries. You should
17392 rarely need to use any of these options for ordinary compilation and
17395 Many developer options that cause GCC to dump output to a file take an
17396 optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
17397 or @samp{-} to dump to standard output, and @samp{stderr} for standard
17400 If @samp{=@var{filename}} is omitted, a default dump file name is
17401 constructed by concatenating the base dump file name, a pass number,
17402 phase letter, and pass name. The base dump file name is the name of
17403 output file produced by the compiler if explicitly specified and not
17404 an executable; otherwise it is the source file name.
17405 The pass number is determined by the order passes are registered with
17406 the compiler's pass manager.
17407 This is generally the same as the order of execution, but passes
17408 registered by plugins, target-specific passes, or passes that are
17409 otherwise registered late are numbered higher than the pass named
17410 @samp{final}, even if they are executed earlier. The phase letter is
17411 one of @samp{i} (inter-procedural analysis), @samp{l}
17412 (language-specific), @samp{r} (RTL), or @samp{t} (tree).
17413 The files are created in the directory of the output file.
17417 @item -fcallgraph-info
17418 @itemx -fcallgraph-info=@var{MARKERS}
17419 @opindex fcallgraph-info
17420 Makes the compiler output callgraph information for the program, on a
17421 per-object-file basis. The information is generated in the common VCG
17422 format. It can be decorated with additional, per-node and/or per-edge
17423 information, if a list of comma-separated markers is additionally
17424 specified. When the @code{su} marker is specified, the callgraph is
17425 decorated with stack usage information; it is equivalent to
17426 @option{-fstack-usage}. When the @code{da} marker is specified, the
17427 callgraph is decorated with information about dynamically allocated
17430 When compiling with @option{-flto}, no callgraph information is output
17431 along with the object file. At LTO link time, @option{-fcallgraph-info}
17432 may generate multiple callgraph information files next to intermediate
17435 @item -d@var{letters}
17436 @itemx -fdump-rtl-@var{pass}
17437 @itemx -fdump-rtl-@var{pass}=@var{filename}
17439 @opindex fdump-rtl-@var{pass}
17440 Says to make debugging dumps during compilation at times specified by
17441 @var{letters}. This is used for debugging the RTL-based passes of the
17444 Some @option{-d@var{letters}} switches have different meaning when
17445 @option{-E} is used for preprocessing. @xref{Preprocessor Options},
17446 for information about preprocessor-specific dump options.
17448 Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
17449 @option{-d} option @var{letters}. Here are the possible
17450 letters for use in @var{pass} and @var{letters}, and their meanings:
17454 @item -fdump-rtl-alignments
17455 @opindex fdump-rtl-alignments
17456 Dump after branch alignments have been computed.
17458 @item -fdump-rtl-asmcons
17459 @opindex fdump-rtl-asmcons
17460 Dump after fixing rtl statements that have unsatisfied in/out constraints.
17462 @item -fdump-rtl-auto_inc_dec
17463 @opindex fdump-rtl-auto_inc_dec
17464 Dump after auto-inc-dec discovery. This pass is only run on
17465 architectures that have auto inc or auto dec instructions.
17467 @item -fdump-rtl-barriers
17468 @opindex fdump-rtl-barriers
17469 Dump after cleaning up the barrier instructions.
17471 @item -fdump-rtl-bbpart
17472 @opindex fdump-rtl-bbpart
17473 Dump after partitioning hot and cold basic blocks.
17475 @item -fdump-rtl-bbro
17476 @opindex fdump-rtl-bbro
17477 Dump after block reordering.
17479 @item -fdump-rtl-btl1
17480 @itemx -fdump-rtl-btl2
17481 @opindex fdump-rtl-btl2
17482 @opindex fdump-rtl-btl2
17483 @option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
17484 after the two branch
17485 target load optimization passes.
17487 @item -fdump-rtl-bypass
17488 @opindex fdump-rtl-bypass
17489 Dump after jump bypassing and control flow optimizations.
17491 @item -fdump-rtl-combine
17492 @opindex fdump-rtl-combine
17493 Dump after the RTL instruction combination pass.
17495 @item -fdump-rtl-compgotos
17496 @opindex fdump-rtl-compgotos
17497 Dump after duplicating the computed gotos.
17499 @item -fdump-rtl-ce1
17500 @itemx -fdump-rtl-ce2
17501 @itemx -fdump-rtl-ce3
17502 @opindex fdump-rtl-ce1
17503 @opindex fdump-rtl-ce2
17504 @opindex fdump-rtl-ce3
17505 @option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
17506 @option{-fdump-rtl-ce3} enable dumping after the three
17507 if conversion passes.
17509 @item -fdump-rtl-cprop_hardreg
17510 @opindex fdump-rtl-cprop_hardreg
17511 Dump after hard register copy propagation.
17513 @item -fdump-rtl-csa
17514 @opindex fdump-rtl-csa
17515 Dump after combining stack adjustments.
17517 @item -fdump-rtl-cse1
17518 @itemx -fdump-rtl-cse2
17519 @opindex fdump-rtl-cse1
17520 @opindex fdump-rtl-cse2
17521 @option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
17522 the two common subexpression elimination passes.
17524 @item -fdump-rtl-dce
17525 @opindex fdump-rtl-dce
17526 Dump after the standalone dead code elimination passes.
17528 @item -fdump-rtl-dbr
17529 @opindex fdump-rtl-dbr
17530 Dump after delayed branch scheduling.
17532 @item -fdump-rtl-dce1
17533 @itemx -fdump-rtl-dce2
17534 @opindex fdump-rtl-dce1
17535 @opindex fdump-rtl-dce2
17536 @option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
17537 the two dead store elimination passes.
17539 @item -fdump-rtl-eh
17540 @opindex fdump-rtl-eh
17541 Dump after finalization of EH handling code.
17543 @item -fdump-rtl-eh_ranges
17544 @opindex fdump-rtl-eh_ranges
17545 Dump after conversion of EH handling range regions.
17547 @item -fdump-rtl-expand
17548 @opindex fdump-rtl-expand
17549 Dump after RTL generation.
17551 @item -fdump-rtl-fwprop1
17552 @itemx -fdump-rtl-fwprop2
17553 @opindex fdump-rtl-fwprop1
17554 @opindex fdump-rtl-fwprop2
17555 @option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
17556 dumping after the two forward propagation passes.
17558 @item -fdump-rtl-gcse1
17559 @itemx -fdump-rtl-gcse2
17560 @opindex fdump-rtl-gcse1
17561 @opindex fdump-rtl-gcse2
17562 @option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
17563 after global common subexpression elimination.
17565 @item -fdump-rtl-init-regs
17566 @opindex fdump-rtl-init-regs
17567 Dump after the initialization of the registers.
17569 @item -fdump-rtl-initvals
17570 @opindex fdump-rtl-initvals
17571 Dump after the computation of the initial value sets.
17573 @item -fdump-rtl-into_cfglayout
17574 @opindex fdump-rtl-into_cfglayout
17575 Dump after converting to cfglayout mode.
17577 @item -fdump-rtl-ira
17578 @opindex fdump-rtl-ira
17579 Dump after iterated register allocation.
17581 @item -fdump-rtl-jump
17582 @opindex fdump-rtl-jump
17583 Dump after the second jump optimization.
17585 @item -fdump-rtl-loop2
17586 @opindex fdump-rtl-loop2
17587 @option{-fdump-rtl-loop2} enables dumping after the rtl
17588 loop optimization passes.
17590 @item -fdump-rtl-mach
17591 @opindex fdump-rtl-mach
17592 Dump after performing the machine dependent reorganization pass, if that
17595 @item -fdump-rtl-mode_sw
17596 @opindex fdump-rtl-mode_sw
17597 Dump after removing redundant mode switches.
17599 @item -fdump-rtl-rnreg
17600 @opindex fdump-rtl-rnreg
17601 Dump after register renumbering.
17603 @item -fdump-rtl-outof_cfglayout
17604 @opindex fdump-rtl-outof_cfglayout
17605 Dump after converting from cfglayout mode.
17607 @item -fdump-rtl-peephole2
17608 @opindex fdump-rtl-peephole2
17609 Dump after the peephole pass.
17611 @item -fdump-rtl-postreload
17612 @opindex fdump-rtl-postreload
17613 Dump after post-reload optimizations.
17615 @item -fdump-rtl-pro_and_epilogue
17616 @opindex fdump-rtl-pro_and_epilogue
17617 Dump after generating the function prologues and epilogues.
17619 @item -fdump-rtl-sched1
17620 @itemx -fdump-rtl-sched2
17621 @opindex fdump-rtl-sched1
17622 @opindex fdump-rtl-sched2
17623 @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
17624 after the basic block scheduling passes.
17626 @item -fdump-rtl-ree
17627 @opindex fdump-rtl-ree
17628 Dump after sign/zero extension elimination.
17630 @item -fdump-rtl-seqabstr
17631 @opindex fdump-rtl-seqabstr
17632 Dump after common sequence discovery.
17634 @item -fdump-rtl-shorten
17635 @opindex fdump-rtl-shorten
17636 Dump after shortening branches.
17638 @item -fdump-rtl-sibling
17639 @opindex fdump-rtl-sibling
17640 Dump after sibling call optimizations.
17642 @item -fdump-rtl-split1
17643 @itemx -fdump-rtl-split2
17644 @itemx -fdump-rtl-split3
17645 @itemx -fdump-rtl-split4
17646 @itemx -fdump-rtl-split5
17647 @opindex fdump-rtl-split1
17648 @opindex fdump-rtl-split2
17649 @opindex fdump-rtl-split3
17650 @opindex fdump-rtl-split4
17651 @opindex fdump-rtl-split5
17652 These options enable dumping after five rounds of
17653 instruction splitting.
17655 @item -fdump-rtl-sms
17656 @opindex fdump-rtl-sms
17657 Dump after modulo scheduling. This pass is only run on some
17660 @item -fdump-rtl-stack
17661 @opindex fdump-rtl-stack
17662 Dump after conversion from GCC's ``flat register file'' registers to the
17663 x87's stack-like registers. This pass is only run on x86 variants.
17665 @item -fdump-rtl-subreg1
17666 @itemx -fdump-rtl-subreg2
17667 @opindex fdump-rtl-subreg1
17668 @opindex fdump-rtl-subreg2
17669 @option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
17670 the two subreg expansion passes.
17672 @item -fdump-rtl-unshare
17673 @opindex fdump-rtl-unshare
17674 Dump after all rtl has been unshared.
17676 @item -fdump-rtl-vartrack
17677 @opindex fdump-rtl-vartrack
17678 Dump after variable tracking.
17680 @item -fdump-rtl-vregs
17681 @opindex fdump-rtl-vregs
17682 Dump after converting virtual registers to hard registers.
17684 @item -fdump-rtl-web
17685 @opindex fdump-rtl-web
17686 Dump after live range splitting.
17688 @item -fdump-rtl-regclass
17689 @itemx -fdump-rtl-subregs_of_mode_init
17690 @itemx -fdump-rtl-subregs_of_mode_finish
17691 @itemx -fdump-rtl-dfinit
17692 @itemx -fdump-rtl-dfinish
17693 @opindex fdump-rtl-regclass
17694 @opindex fdump-rtl-subregs_of_mode_init
17695 @opindex fdump-rtl-subregs_of_mode_finish
17696 @opindex fdump-rtl-dfinit
17697 @opindex fdump-rtl-dfinish
17698 These dumps are defined but always produce empty files.
17701 @itemx -fdump-rtl-all
17703 @opindex fdump-rtl-all
17704 Produce all the dumps listed above.
17708 Annotate the assembler output with miscellaneous debugging information.
17712 Dump all macro definitions, at the end of preprocessing, in addition to
17717 Produce a core dump whenever an error occurs.
17721 Annotate the assembler output with a comment indicating which
17722 pattern and alternative is used. The length and cost of each instruction are
17727 Dump the RTL in the assembler output as a comment before each instruction.
17728 Also turns on @option{-dp} annotation.
17732 Just generate RTL for a function instead of compiling it. Usually used
17733 with @option{-fdump-rtl-expand}.
17737 @opindex fdump-debug
17738 Dump debugging information generated during the debug
17741 @item -fdump-earlydebug
17742 @opindex fdump-earlydebug
17743 Dump debugging information generated during the early debug
17746 @item -fdump-noaddr
17747 @opindex fdump-noaddr
17748 When doing debugging dumps, suppress address output. This makes it more
17749 feasible to use diff on debugging dumps for compiler invocations with
17750 different compiler binaries and/or different
17751 text / bss / data / heap / stack / dso start locations.
17754 @opindex freport-bug
17755 Collect and dump debug information into a temporary file if an
17756 internal compiler error (ICE) occurs.
17758 @item -fdump-unnumbered
17759 @opindex fdump-unnumbered
17760 When doing debugging dumps, suppress instruction numbers and address output.
17761 This makes it more feasible to use diff on debugging dumps for compiler
17762 invocations with different options, in particular with and without
17765 @item -fdump-unnumbered-links
17766 @opindex fdump-unnumbered-links
17767 When doing debugging dumps (see @option{-d} option above), suppress
17768 instruction numbers for the links to the previous and next instructions
17771 @item -fdump-ipa-@var{switch}
17772 @itemx -fdump-ipa-@var{switch}-@var{options}
17774 Control the dumping at various stages of inter-procedural analysis
17775 language tree to a file. The file name is generated by appending a
17776 switch specific suffix to the source file name, and the file is created
17777 in the same directory as the output file. The following dumps are
17782 Enables all inter-procedural analysis dumps.
17785 Dumps information about call-graph optimization, unused function removal,
17786 and inlining decisions.
17789 Dump after function inlining.
17793 Additionally, the options @option{-optimized}, @option{-missed},
17794 @option{-note}, and @option{-all} can be provided, with the same meaning
17795 as for @option{-fopt-info}, defaulting to @option{-optimized}.
17797 For example, @option{-fdump-ipa-inline-optimized-missed} will emit
17798 information on callsites that were inlined, along with callsites
17799 that were not inlined.
17801 By default, the dump will contain messages about successful
17802 optimizations (equivalent to @option{-optimized}) together with
17803 low-level details about the analysis.
17806 @opindex fdump-lang
17807 Dump language-specific information. The file name is made by appending
17808 @file{.lang} to the source file name.
17810 @item -fdump-lang-all
17811 @itemx -fdump-lang-@var{switch}
17812 @itemx -fdump-lang-@var{switch}-@var{options}
17813 @itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
17814 @opindex fdump-lang-all
17815 @opindex fdump-lang
17816 Control the dumping of language-specific information. The @var{options}
17817 and @var{filename} portions behave as described in the
17818 @option{-fdump-tree} option. The following @var{switch} values are
17824 Enable all language-specific dumps.
17827 Dump class hierarchy information. Virtual table information is emitted
17828 unless '@option{slim}' is specified. This option is applicable to C++ only.
17831 Dump module information. Options @option{lineno} (locations),
17832 @option{graph} (reachability), @option{blocks} (clusters),
17833 @option{uid} (serialization), @option{alias} (mergeable),
17834 @option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
17835 (macros) may provide additional information. This option is
17836 applicable to C++ only.
17839 Dump the raw internal tree data. This option is applicable to C++ only.
17843 @item -fdump-passes
17844 @opindex fdump-passes
17845 Print on @file{stderr} the list of optimization passes that are turned
17846 on and off by the current command-line options.
17848 @item -fdump-statistics-@var{option}
17849 @opindex fdump-statistics
17850 Enable and control dumping of pass statistics in a separate file. The
17851 file name is generated by appending a suffix ending in
17852 @samp{.statistics} to the source file name, and the file is created in
17853 the same directory as the output file. If the @samp{-@var{option}}
17854 form is used, @samp{-stats} causes counters to be summed over the
17855 whole compilation unit while @samp{-details} dumps every event as
17856 the passes generate them. The default with no option is to sum
17857 counters for each function compiled.
17859 @item -fdump-tree-all
17860 @itemx -fdump-tree-@var{switch}
17861 @itemx -fdump-tree-@var{switch}-@var{options}
17862 @itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
17863 @opindex fdump-tree-all
17864 @opindex fdump-tree
17865 Control the dumping at various stages of processing the intermediate
17866 language tree to a file. If the @samp{-@var{options}}
17867 form is used, @var{options} is a list of @samp{-} separated options
17868 which control the details of the dump. Not all options are applicable
17869 to all dumps; those that are not meaningful are ignored. The
17870 following options are available
17874 Print the address of each node. Usually this is not meaningful as it
17875 changes according to the environment and source file. Its primary use
17876 is for tying up a dump file with a debug environment.
17878 If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
17879 in the dump instead of @code{DECL_NAME}. Its primary use is ease of
17880 use working backward from mangled names in the assembly file.
17882 When dumping front-end intermediate representations, inhibit dumping
17883 of members of a scope or body of a function merely because that scope
17884 has been reached. Only dump such items when they are directly reachable
17885 by some other path.
17887 When dumping pretty-printed trees, this option inhibits dumping the
17888 bodies of control structures.
17890 When dumping RTL, print the RTL in slim (condensed) form instead of
17891 the default LISP-like representation.
17893 Print a raw representation of the tree. By default, trees are
17894 pretty-printed into a C-like representation.
17896 Enable more detailed dumps (not honored by every dump option). Also
17897 include information from the optimization passes.
17899 Enable dumping various statistics about the pass (not honored by every dump
17902 Enable showing basic block boundaries (disabled in raw dumps).
17904 For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
17905 dump a representation of the control flow graph suitable for viewing with
17906 GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
17907 the file is pretty-printed as a subgraph, so that GraphViz can render them
17908 all in a single plot.
17910 This option currently only works for RTL dumps, and the RTL is always
17911 dumped in slim form.
17913 Enable showing virtual operands for every statement.
17915 Enable showing line numbers for statements.
17917 Enable showing the unique ID (@code{DECL_UID}) for each variable.
17919 Enable showing the tree dump for each statement.
17921 Enable showing the EH region number holding each statement.
17923 Enable showing scalar evolution analysis details.
17925 Enable showing optimization information (only available in certain
17928 Enable showing missed optimization information (only available in certain
17931 Enable other detailed optimization information (only available in
17934 Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
17935 and @option{lineno}.
17937 Turn on all optimization options, i.e., @option{optimized},
17938 @option{missed}, and @option{note}.
17941 To determine what tree dumps are available or find the dump for a pass
17942 of interest follow the steps below.
17946 Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
17947 look for a code that corresponds to the pass you are interested in.
17948 For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
17949 @code{tree-vrp2} correspond to the three Value Range Propagation passes.
17950 The number at the end distinguishes distinct invocations of the same pass.
17952 To enable the creation of the dump file, append the pass code to
17953 the @option{-fdump-} option prefix and invoke GCC with it. For example,
17954 to enable the dump from the Early Value Range Propagation pass, invoke
17955 GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
17956 specify the name of the dump file. If you don't specify one, GCC
17957 creates as described below.
17959 Find the pass dump in a file whose name is composed of three components
17960 separated by a period: the name of the source file GCC was invoked to
17961 compile, a numeric suffix indicating the pass number followed by the
17962 letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
17963 and finally the pass code. For example, the Early VRP pass dump might
17964 be in a file named @file{myfile.c.038t.evrp} in the current working
17965 directory. Note that the numeric codes are not stable and may change
17966 from one version of GCC to another.
17970 @itemx -fopt-info-@var{options}
17971 @itemx -fopt-info-@var{options}=@var{filename}
17973 Controls optimization dumps from various optimization passes. If the
17974 @samp{-@var{options}} form is used, @var{options} is a list of
17975 @samp{-} separated option keywords to select the dump details and
17978 The @var{options} can be divided into three groups:
17981 options describing what kinds of messages should be emitted,
17983 options describing the verbosity of the dump, and
17985 options describing which optimizations should be included.
17987 The options from each group can be freely mixed as they are
17988 non-overlapping. However, in case of any conflicts,
17989 the later options override the earlier options on the command
17992 The following options control which kinds of messages should be emitted:
17996 Print information when an optimization is successfully applied. It is
17997 up to a pass to decide which information is relevant. For example, the
17998 vectorizer passes print the source location of loops which are
17999 successfully vectorized.
18001 Print information about missed optimizations. Individual passes
18002 control which information to include in the output.
18004 Print verbose information about optimizations, such as certain
18005 transformations, more detailed messages about decisions etc.
18007 Print detailed optimization information. This includes
18008 @samp{optimized}, @samp{missed}, and @samp{note}.
18011 The following option controls the dump verbosity:
18015 By default, only ``high-level'' messages are emitted. This option enables
18016 additional, more detailed, messages, which are likely to only be of interest
18020 One or more of the following option keywords can be used to describe a
18021 group of optimizations:
18025 Enable dumps from all interprocedural optimizations.
18027 Enable dumps from all loop optimizations.
18029 Enable dumps from all inlining optimizations.
18031 Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
18033 Enable dumps from all vectorization optimizations.
18035 Enable dumps from all optimizations. This is a superset of
18036 the optimization groups listed above.
18039 If @var{options} is
18040 omitted, it defaults to @samp{optimized-optall}, which means to dump messages
18041 about successful optimizations from all the passes, omitting messages
18042 that are treated as ``internals''.
18044 If the @var{filename} is provided, then the dumps from all the
18045 applicable optimizations are concatenated into the @var{filename}.
18046 Otherwise the dump is output onto @file{stderr}. Though multiple
18047 @option{-fopt-info} options are accepted, only one of them can include
18048 a @var{filename}. If other filenames are provided then all but the
18049 first such option are ignored.
18051 Note that the output @var{filename} is overwritten
18052 in case of multiple translation units. If a combined output from
18053 multiple translation units is desired, @file{stderr} should be used
18056 In the following example, the optimization info is output to
18065 gcc -O3 -fopt-info-missed=missed.all
18069 outputs missed optimization report from all the passes into
18070 @file{missed.all}, and this one:
18073 gcc -O2 -ftree-vectorize -fopt-info-vec-missed
18077 prints information about missed optimization opportunities from
18078 vectorization passes on @file{stderr}.
18079 Note that @option{-fopt-info-vec-missed} is equivalent to
18080 @option{-fopt-info-missed-vec}. The order of the optimization group
18081 names and message types listed after @option{-fopt-info} does not matter.
18083 As another example,
18085 gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
18089 outputs information about missed optimizations as well as
18090 optimized locations from all the inlining passes into
18096 gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
18100 Here the two output filenames @file{vec.miss} and @file{loop.opt} are
18101 in conflict since only one output file is allowed. In this case, only
18102 the first option takes effect and the subsequent options are
18103 ignored. Thus only @file{vec.miss} is produced which contains
18104 dumps from the vectorizer about missed opportunities.
18106 @item -fsave-optimization-record
18107 @opindex fsave-optimization-record
18108 Write a SRCFILE.opt-record.json.gz file detailing what optimizations
18109 were performed, for those optimizations that support @option{-fopt-info}.
18111 This option is experimental and the format of the data within the
18112 compressed JSON file is subject to change.
18114 It is roughly equivalent to a machine-readable version of
18115 @option{-fopt-info-all}, as a collection of messages with source file,
18116 line number and column number, with the following additional data for
18122 the execution count of the code being optimized, along with metadata about
18123 whether this was from actual profile data, or just an estimate, allowing
18124 consumers to prioritize messages by code hotness,
18127 the function name of the code being optimized, where applicable,
18130 the ``inlining chain'' for the code being optimized, so that when
18131 a function is inlined into several different places (which might
18132 themselves be inlined), the reader can distinguish between the copies,
18135 objects identifying those parts of the message that refer to expressions,
18136 statements or symbol-table nodes, which of these categories they are, and,
18137 when available, their source code location,
18140 the GCC pass that emitted the message, and
18143 the location in GCC's own code from which the message was emitted
18147 Additionally, some messages are logically nested within other
18148 messages, reflecting implementation details of the optimization
18151 @item -fsched-verbose=@var{n}
18152 @opindex fsched-verbose
18153 On targets that use instruction scheduling, this option controls the
18154 amount of debugging output the scheduler prints to the dump files.
18156 For @var{n} greater than zero, @option{-fsched-verbose} outputs the
18157 same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
18158 For @var{n} greater than one, it also output basic block probabilities,
18159 detailed ready list information and unit/insn info. For @var{n} greater
18160 than two, it includes RTL at abort point, control-flow and regions info.
18161 And for @var{n} over four, @option{-fsched-verbose} also includes
18166 @item -fenable-@var{kind}-@var{pass}
18167 @itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
18171 This is a set of options that are used to explicitly disable/enable
18172 optimization passes. These options are intended for use for debugging GCC.
18173 Compiler users should use regular options for enabling/disabling
18178 @item -fdisable-ipa-@var{pass}
18179 Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
18180 statically invoked in the compiler multiple times, the pass name should be
18181 appended with a sequential number starting from 1.
18183 @item -fdisable-rtl-@var{pass}
18184 @itemx -fdisable-rtl-@var{pass}=@var{range-list}
18185 Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
18186 statically invoked in the compiler multiple times, the pass name should be
18187 appended with a sequential number starting from 1. @var{range-list} is a
18188 comma-separated list of function ranges or assembler names. Each range is a number
18189 pair separated by a colon. The range is inclusive in both ends. If the range
18190 is trivial, the number pair can be simplified as a single number. If the
18191 function's call graph node's @var{uid} falls within one of the specified ranges,
18192 the @var{pass} is disabled for that function. The @var{uid} is shown in the
18193 function header of a dump file, and the pass names can be dumped by using
18194 option @option{-fdump-passes}.
18196 @item -fdisable-tree-@var{pass}
18197 @itemx -fdisable-tree-@var{pass}=@var{range-list}
18198 Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
18201 @item -fenable-ipa-@var{pass}
18202 Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
18203 statically invoked in the compiler multiple times, the pass name should be
18204 appended with a sequential number starting from 1.
18206 @item -fenable-rtl-@var{pass}
18207 @itemx -fenable-rtl-@var{pass}=@var{range-list}
18208 Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
18209 description and examples.
18211 @item -fenable-tree-@var{pass}
18212 @itemx -fenable-tree-@var{pass}=@var{range-list}
18213 Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
18214 of option arguments.
18218 Here are some examples showing uses of these options.
18222 # disable ccp1 for all functions
18223 -fdisable-tree-ccp1
18224 # disable complete unroll for function whose cgraph node uid is 1
18225 -fenable-tree-cunroll=1
18226 # disable gcse2 for functions at the following ranges [1,1],
18227 # [300,400], and [400,1000]
18228 # disable gcse2 for functions foo and foo2
18229 -fdisable-rtl-gcse2=foo,foo2
18230 # disable early inlining
18231 -fdisable-tree-einline
18232 # disable ipa inlining
18233 -fdisable-ipa-inline
18234 # enable tree full unroll
18235 -fenable-tree-unroll
18240 @itemx -fchecking=@var{n}
18242 @opindex fno-checking
18243 Enable internal consistency checking. The default depends on
18244 the compiler configuration. @option{-fchecking=2} enables further
18245 internal consistency checking that might affect code generation.
18247 @item -frandom-seed=@var{string}
18248 @opindex frandom-seed
18249 This option provides a seed that GCC uses in place of
18250 random numbers in generating certain symbol names
18251 that have to be different in every compiled file. It is also used to
18252 place unique stamps in coverage data files and the object files that
18253 produce them. You can use the @option{-frandom-seed} option to produce
18254 reproducibly identical object files.
18256 The @var{string} can either be a number (decimal, octal or hex) or an
18257 arbitrary string (in which case it's converted to a number by
18260 The @var{string} should be different for every file you compile.
18263 @opindex save-temps
18264 Store the usual ``temporary'' intermediate files permanently; name them
18265 as auxiliary output files, as specified described under
18266 @option{-dumpbase} and @option{-dumpdir}.
18268 When used in combination with the @option{-x} command-line option,
18269 @option{-save-temps} is sensible enough to avoid overwriting an
18270 input source file with the same extension as an intermediate file.
18271 The corresponding intermediate file may be obtained by renaming the
18272 source file before using @option{-save-temps}.
18274 @item -save-temps=cwd
18275 @opindex save-temps=cwd
18276 Equivalent to @option{-save-temps -dumpdir ./}.
18278 @item -save-temps=obj
18279 @opindex save-temps=obj
18280 Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
18281 @file{outdir/} is the directory of the output file specified after the
18282 @option{-o} option, including any directory separators. If the
18283 @option{-o} option is not used, the @option{-save-temps=obj} switch
18284 behaves like @option{-save-temps=cwd}.
18286 @item -time@r{[}=@var{file}@r{]}
18288 Report the CPU time taken by each subprocess in the compilation
18289 sequence. For C source files, this is the compiler proper and assembler
18290 (plus the linker if linking is done).
18292 Without the specification of an output file, the output looks like this:
18299 The first number on each line is the ``user time'', that is time spent
18300 executing the program itself. The second number is ``system time'',
18301 time spent executing operating system routines on behalf of the program.
18302 Both numbers are in seconds.
18304 With the specification of an output file, the output is appended to the
18305 named file, and it looks like this:
18308 0.12 0.01 cc1 @var{options}
18309 0.00 0.01 as @var{options}
18312 The ``user time'' and the ``system time'' are moved before the program
18313 name, and the options passed to the program are displayed, so that one
18314 can later tell what file was being compiled, and with which options.
18316 @item -fdump-final-insns@r{[}=@var{file}@r{]}
18317 @opindex fdump-final-insns
18318 Dump the final internal representation (RTL) to @var{file}. If the
18319 optional argument is omitted (or if @var{file} is @code{.}), the name
18320 of the dump file is determined by appending @code{.gkd} to the
18321 dump base name, see @option{-dumpbase}.
18323 @item -fcompare-debug@r{[}=@var{opts}@r{]}
18324 @opindex fcompare-debug
18325 @opindex fno-compare-debug
18326 If no error occurs during compilation, run the compiler a second time,
18327 adding @var{opts} and @option{-fcompare-debug-second} to the arguments
18328 passed to the second compilation. Dump the final internal
18329 representation in both compilations, and print an error if they differ.
18331 If the equal sign is omitted, the default @option{-gtoggle} is used.
18333 The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
18334 and nonzero, implicitly enables @option{-fcompare-debug}. If
18335 @env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
18336 then it is used for @var{opts}, otherwise the default @option{-gtoggle}
18339 @option{-fcompare-debug=}, with the equal sign but without @var{opts},
18340 is equivalent to @option{-fno-compare-debug}, which disables the dumping
18341 of the final representation and the second compilation, preventing even
18342 @env{GCC_COMPARE_DEBUG} from taking effect.
18344 To verify full coverage during @option{-fcompare-debug} testing, set
18345 @env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
18346 which GCC rejects as an invalid option in any actual compilation
18347 (rather than preprocessing, assembly or linking). To get just a
18348 warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
18349 not overridden} will do.
18351 @item -fcompare-debug-second
18352 @opindex fcompare-debug-second
18353 This option is implicitly passed to the compiler for the second
18354 compilation requested by @option{-fcompare-debug}, along with options to
18355 silence warnings, and omitting other options that would cause the compiler
18356 to produce output to files or to standard output as a side effect. Dump
18357 files and preserved temporary files are renamed so as to contain the
18358 @code{.gk} additional extension during the second compilation, to avoid
18359 overwriting those generated by the first.
18361 When this option is passed to the compiler driver, it causes the
18362 @emph{first} compilation to be skipped, which makes it useful for little
18363 other than debugging the compiler proper.
18367 Turn off generation of debug info, if leaving out this option
18368 generates it, or turn it on at level 2 otherwise. The position of this
18369 argument in the command line does not matter; it takes effect after all
18370 other options are processed, and it does so only once, no matter how
18371 many times it is given. This is mainly intended to be used with
18372 @option{-fcompare-debug}.
18374 @item -fvar-tracking-assignments-toggle
18375 @opindex fvar-tracking-assignments-toggle
18376 @opindex fno-var-tracking-assignments-toggle
18377 Toggle @option{-fvar-tracking-assignments}, in the same way that
18378 @option{-gtoggle} toggles @option{-g}.
18382 Makes the compiler print out each function name as it is compiled, and
18383 print some statistics about each pass when it finishes.
18385 @item -ftime-report
18386 @opindex ftime-report
18387 Makes the compiler print some statistics about the time consumed by each
18388 pass when it finishes.
18390 @item -ftime-report-details
18391 @opindex ftime-report-details
18392 Record the time consumed by infrastructure parts separately for each pass.
18394 @item -fira-verbose=@var{n}
18395 @opindex fira-verbose
18396 Control the verbosity of the dump file for the integrated register allocator.
18397 The default value is 5. If the value @var{n} is greater or equal to 10,
18398 the dump output is sent to stderr using the same format as @var{n} minus 10.
18401 @opindex flto-report
18402 Prints a report with internal details on the workings of the link-time
18403 optimizer. The contents of this report vary from version to version.
18404 It is meant to be useful to GCC developers when processing object
18405 files in LTO mode (via @option{-flto}).
18407 Disabled by default.
18409 @item -flto-report-wpa
18410 @opindex flto-report-wpa
18411 Like @option{-flto-report}, but only print for the WPA phase of link-time
18415 @opindex fmem-report
18416 Makes the compiler print some statistics about permanent memory
18417 allocation when it finishes.
18419 @item -fmem-report-wpa
18420 @opindex fmem-report-wpa
18421 Makes the compiler print some statistics about permanent memory
18422 allocation for the WPA phase only.
18424 @item -fpre-ipa-mem-report
18425 @opindex fpre-ipa-mem-report
18426 @item -fpost-ipa-mem-report
18427 @opindex fpost-ipa-mem-report
18428 Makes the compiler print some statistics about permanent memory
18429 allocation before or after interprocedural optimization.
18431 @item -fprofile-report
18432 @opindex fprofile-report
18433 Makes the compiler print some statistics about consistency of the
18434 (estimated) profile and effect of individual passes.
18436 @item -fstack-usage
18437 @opindex fstack-usage
18438 Makes the compiler output stack usage information for the program, on a
18439 per-function basis. The filename for the dump is made by appending
18440 @file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
18441 the output file, if explicitly specified and it is not an executable,
18442 otherwise it is the basename of the source file. An entry is made up
18447 The name of the function.
18451 One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
18454 The qualifier @code{static} means that the function manipulates the stack
18455 statically: a fixed number of bytes are allocated for the frame on function
18456 entry and released on function exit; no stack adjustments are otherwise made
18457 in the function. The second field is this fixed number of bytes.
18459 The qualifier @code{dynamic} means that the function manipulates the stack
18460 dynamically: in addition to the static allocation described above, stack
18461 adjustments are made in the body of the function, for example to push/pop
18462 arguments around function calls. If the qualifier @code{bounded} is also
18463 present, the amount of these adjustments is bounded at compile time and
18464 the second field is an upper bound of the total amount of stack used by
18465 the function. If it is not present, the amount of these adjustments is
18466 not bounded at compile time and the second field only represents the
18471 Emit statistics about front-end processing at the end of the compilation.
18472 This option is supported only by the C++ front end, and
18473 the information is generally only useful to the G++ development team.
18475 @item -fdbg-cnt-list
18476 @opindex fdbg-cnt-list
18477 Print the name and the counter upper bound for all debug counters.
18480 @item -fdbg-cnt=@var{counter-value-list}
18482 Set the internal debug counter lower and upper bound. @var{counter-value-list}
18483 is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
18484 [:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
18485 the name of the counter and list of closed intervals.
18486 The @var{lower_bound} is optional and is zero
18487 initialized if not set.
18488 For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
18489 @code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
18490 eleventh invocation.
18491 For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
18493 @item -print-file-name=@var{library}
18494 @opindex print-file-name
18495 Print the full absolute name of the library file @var{library} that
18496 would be used when linking---and don't do anything else. With this
18497 option, GCC does not compile or link anything; it just prints the
18500 @item -print-multi-directory
18501 @opindex print-multi-directory
18502 Print the directory name corresponding to the multilib selected by any
18503 other switches present in the command line. This directory is supposed
18504 to exist in @env{GCC_EXEC_PREFIX}.
18506 @item -print-multi-lib
18507 @opindex print-multi-lib
18508 Print the mapping from multilib directory names to compiler switches
18509 that enable them. The directory name is separated from the switches by
18510 @samp{;}, and each switch starts with an @samp{@@} instead of the
18511 @samp{-}, without spaces between multiple switches. This is supposed to
18512 ease shell processing.
18514 @item -print-multi-os-directory
18515 @opindex print-multi-os-directory
18516 Print the path to OS libraries for the selected
18517 multilib, relative to some @file{lib} subdirectory. If OS libraries are
18518 present in the @file{lib} subdirectory and no multilibs are used, this is
18519 usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
18520 sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
18521 @file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
18522 subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
18524 @item -print-multiarch
18525 @opindex print-multiarch
18526 Print the path to OS libraries for the selected multiarch,
18527 relative to some @file{lib} subdirectory.
18529 @item -print-prog-name=@var{program}
18530 @opindex print-prog-name
18531 Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
18533 @item -print-libgcc-file-name
18534 @opindex print-libgcc-file-name
18535 Same as @option{-print-file-name=libgcc.a}.
18537 This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
18538 but you do want to link with @file{libgcc.a}. You can do:
18541 gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
18544 @item -print-search-dirs
18545 @opindex print-search-dirs
18546 Print the name of the configured installation directory and a list of
18547 program and library directories @command{gcc} searches---and don't do anything else.
18549 This is useful when @command{gcc} prints the error message
18550 @samp{installation problem, cannot exec cpp0: No such file or directory}.
18551 To resolve this you either need to put @file{cpp0} and the other compiler
18552 components where @command{gcc} expects to find them, or you can set the environment
18553 variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
18554 Don't forget the trailing @samp{/}.
18555 @xref{Environment Variables}.
18557 @item -print-sysroot
18558 @opindex print-sysroot
18559 Print the target sysroot directory that is used during
18560 compilation. This is the target sysroot specified either at configure
18561 time or using the @option{--sysroot} option, possibly with an extra
18562 suffix that depends on compilation options. If no target sysroot is
18563 specified, the option prints nothing.
18565 @item -print-sysroot-headers-suffix
18566 @opindex print-sysroot-headers-suffix
18567 Print the suffix added to the target sysroot when searching for
18568 headers, or give an error if the compiler is not configured with such
18569 a suffix---and don't do anything else.
18572 @opindex dumpmachine
18573 Print the compiler's target machine (for example,
18574 @samp{i686-pc-linux-gnu})---and don't do anything else.
18577 @opindex dumpversion
18578 Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
18579 anything else. This is the compiler version used in filesystem paths and
18580 specs. Depending on how the compiler has been configured it can be just
18581 a single number (major version), two numbers separated by a dot (major and
18582 minor version) or three numbers separated by dots (major, minor and patchlevel
18585 @item -dumpfullversion
18586 @opindex dumpfullversion
18587 Print the full compiler version---and don't do anything else. The output is
18588 always three numbers separated by dots, major, minor and patchlevel version.
18592 Print the compiler's built-in specs---and don't do anything else. (This
18593 is used when GCC itself is being built.) @xref{Spec Files}.
18596 @node Submodel Options
18597 @section Machine-Dependent Options
18598 @cindex submodel options
18599 @cindex specifying hardware config
18600 @cindex hardware models and configurations, specifying
18601 @cindex target-dependent options
18602 @cindex machine-dependent options
18604 Each target machine supported by GCC can have its own options---for
18605 example, to allow you to compile for a particular processor variant or
18606 ABI, or to control optimizations specific to that machine. By
18607 convention, the names of machine-specific options start with
18610 Some configurations of the compiler also support additional target-specific
18611 options, usually for compatibility with other compilers on the same
18614 @c This list is ordered alphanumerically by subsection name.
18615 @c It should be the same order and spelling as these options are listed
18616 @c in Machine Dependent Options
18619 * AArch64 Options::
18620 * Adapteva Epiphany Options::
18621 * AMD GCN Options::
18625 * Blackfin Options::
18631 * DEC Alpha Options::
18636 * GNU/Linux Options::
18646 * MicroBlaze Options::
18649 * MN10300 Options::
18653 * Nios II Options::
18654 * Nvidia PTX Options::
18655 * OpenRISC Options::
18657 * picoChip Options::
18658 * PowerPC Options::
18662 * RS/6000 and PowerPC Options::
18664 * S/390 and zSeries Options::
18667 * Solaris 2 Options::
18669 * System V Options::
18670 * TILE-Gx Options::
18671 * TILEPro Options::
18676 * VxWorks Options::
18678 * x86 Windows Options::
18679 * Xstormy16 Options::
18681 * zSeries Options::
18684 @node AArch64 Options
18685 @subsection AArch64 Options
18686 @cindex AArch64 Options
18688 These options are defined for AArch64 implementations:
18692 @item -mabi=@var{name}
18694 Generate code for the specified data model. Permissible values
18695 are @samp{ilp32} for SysV-like data model where int, long int and pointers
18696 are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
18697 but long int and pointers are 64 bits.
18699 The default depends on the specific target configuration. Note that
18700 the LP64 and ILP32 ABIs are not link-compatible; you must compile your
18701 entire program with the same ABI, and link with a compatible set of libraries.
18704 @opindex mbig-endian
18705 Generate big-endian code. This is the default when GCC is configured for an
18706 @samp{aarch64_be-*-*} target.
18708 @item -mgeneral-regs-only
18709 @opindex mgeneral-regs-only
18710 Generate code which uses only the general-purpose registers. This will prevent
18711 the compiler from using floating-point and Advanced SIMD registers but will not
18712 impose any restrictions on the assembler.
18714 @item -mlittle-endian
18715 @opindex mlittle-endian
18716 Generate little-endian code. This is the default when GCC is configured for an
18717 @samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
18719 @item -mcmodel=tiny
18720 @opindex mcmodel=tiny
18721 Generate code for the tiny code model. The program and its statically defined
18722 symbols must be within 1MB of each other. Programs can be statically or
18723 dynamically linked.
18725 @item -mcmodel=small
18726 @opindex mcmodel=small
18727 Generate code for the small code model. The program and its statically defined
18728 symbols must be within 4GB of each other. Programs can be statically or
18729 dynamically linked. This is the default code model.
18731 @item -mcmodel=large
18732 @opindex mcmodel=large
18733 Generate code for the large code model. This makes no assumptions about
18734 addresses and sizes of sections. Programs can be statically linked only. The
18735 @option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
18736 @option{-fpic} and @option{-fPIC}.
18738 @item -mstrict-align
18739 @itemx -mno-strict-align
18740 @opindex mstrict-align
18741 @opindex mno-strict-align
18742 Avoid or allow generating memory accesses that may not be aligned on a natural
18743 object boundary as described in the architecture specification.
18745 @item -momit-leaf-frame-pointer
18746 @itemx -mno-omit-leaf-frame-pointer
18747 @opindex momit-leaf-frame-pointer
18748 @opindex mno-omit-leaf-frame-pointer
18749 Omit or keep the frame pointer in leaf functions. The former behavior is the
18752 @item -mstack-protector-guard=@var{guard}
18753 @itemx -mstack-protector-guard-reg=@var{reg}
18754 @itemx -mstack-protector-guard-offset=@var{offset}
18755 @opindex mstack-protector-guard
18756 @opindex mstack-protector-guard-reg
18757 @opindex mstack-protector-guard-offset
18758 Generate stack protection code using canary at @var{guard}. Supported
18759 locations are @samp{global} for a global canary or @samp{sysreg} for a
18760 canary in an appropriate system register.
18762 With the latter choice the options
18763 @option{-mstack-protector-guard-reg=@var{reg}} and
18764 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
18765 which system register to use as base register for reading the canary,
18766 and from what offset from that base register. There is no default
18767 register or offset as this is entirely for use within the Linux
18770 @item -mtls-dialect=desc
18771 @opindex mtls-dialect=desc
18772 Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
18773 of TLS variables. This is the default.
18775 @item -mtls-dialect=traditional
18776 @opindex mtls-dialect=traditional
18777 Use traditional TLS as the thread-local storage mechanism for dynamic accesses
18780 @item -mtls-size=@var{size}
18782 Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
18783 This option requires binutils 2.26 or newer.
18785 @item -mfix-cortex-a53-835769
18786 @itemx -mno-fix-cortex-a53-835769
18787 @opindex mfix-cortex-a53-835769
18788 @opindex mno-fix-cortex-a53-835769
18789 Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
18790 This involves inserting a NOP instruction between memory instructions and
18791 64-bit integer multiply-accumulate instructions.
18793 @item -mfix-cortex-a53-843419
18794 @itemx -mno-fix-cortex-a53-843419
18795 @opindex mfix-cortex-a53-843419
18796 @opindex mno-fix-cortex-a53-843419
18797 Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
18798 This erratum workaround is made at link time and this will only pass the
18799 corresponding flag to the linker.
18801 @item -mlow-precision-recip-sqrt
18802 @itemx -mno-low-precision-recip-sqrt
18803 @opindex mlow-precision-recip-sqrt
18804 @opindex mno-low-precision-recip-sqrt
18805 Enable or disable the reciprocal square root approximation.
18806 This option only has an effect if @option{-ffast-math} or
18807 @option{-funsafe-math-optimizations} is used as well. Enabling this reduces
18808 precision of reciprocal square root results to about 16 bits for
18809 single precision and to 32 bits for double precision.
18811 @item -mlow-precision-sqrt
18812 @itemx -mno-low-precision-sqrt
18813 @opindex mlow-precision-sqrt
18814 @opindex mno-low-precision-sqrt
18815 Enable or disable the square root approximation.
18816 This option only has an effect if @option{-ffast-math} or
18817 @option{-funsafe-math-optimizations} is used as well. Enabling this reduces
18818 precision of square root results to about 16 bits for
18819 single precision and to 32 bits for double precision.
18820 If enabled, it implies @option{-mlow-precision-recip-sqrt}.
18822 @item -mlow-precision-div
18823 @itemx -mno-low-precision-div
18824 @opindex mlow-precision-div
18825 @opindex mno-low-precision-div
18826 Enable or disable the division approximation.
18827 This option only has an effect if @option{-ffast-math} or
18828 @option{-funsafe-math-optimizations} is used as well. Enabling this reduces
18829 precision of division results to about 16 bits for
18830 single precision and to 32 bits for double precision.
18832 @item -mtrack-speculation
18833 @itemx -mno-track-speculation
18834 Enable or disable generation of additional code to track speculative
18835 execution through conditional branches. The tracking state can then
18836 be used by the compiler when expanding calls to
18837 @code{__builtin_speculation_safe_copy} to permit a more efficient code
18838 sequence to be generated.
18840 @item -moutline-atomics
18841 @itemx -mno-outline-atomics
18842 Enable or disable calls to out-of-line helpers to implement atomic operations.
18843 These helpers will, at runtime, determine if the LSE instructions from
18844 ARMv8.1-A can be used; if not, they will use the load/store-exclusive
18845 instructions that are present in the base ARMv8.0 ISA.
18847 This option is only applicable when compiling for the base ARMv8.0
18848 instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
18849 or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
18850 used directly. The same applies when using @option{-mcpu=} when the
18851 selected cpu supports the @samp{lse} feature.
18852 This option is on by default.
18854 @item -march=@var{name}
18856 Specify the name of the target architecture and, optionally, one or
18857 more feature modifiers. This option has the form
18858 @option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
18860 The table below summarizes the permissible values for @var{arch}
18861 and the features that they enable by default:
18863 @multitable @columnfractions 0.20 0.20 0.60
18864 @headitem @var{arch} value @tab Architecture @tab Includes by default
18865 @item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
18866 @item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
18867 @item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
18868 @item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}
18869 @item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}
18870 @item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}
18871 @item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
18872 @item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64}
18873 @item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
18874 @item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
18875 @item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
18878 The value @samp{native} is available on native AArch64 GNU/Linux and
18879 causes the compiler to pick the architecture of the host system. This
18880 option has no effect if the compiler is unable to recognize the
18881 architecture of the host system,
18883 The permissible values for @var{feature} are listed in the sub-section
18884 on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
18885 Feature Modifiers}. Where conflicting feature modifiers are
18886 specified, the right-most feature is used.
18888 GCC uses @var{name} to determine what kind of instructions it can emit
18889 when generating assembly code. If @option{-march} is specified
18890 without either of @option{-mtune} or @option{-mcpu} also being
18891 specified, the code is tuned to perform well across a range of target
18892 processors implementing the target architecture.
18894 @item -mtune=@var{name}
18896 Specify the name of the target processor for which GCC should tune the
18897 performance of the code. Permissible values for this option are:
18898 @samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
18899 @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
18900 @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
18901 @samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
18902 @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
18903 @samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
18904 @samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
18905 @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{qdf24xx},
18906 @samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
18907 @samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
18908 @samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
18909 @samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
18910 @samp{octeontx2f95mm},
18912 @samp{thunderx}, @samp{thunderxt88},
18913 @samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
18914 @samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
18915 @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
18916 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
18917 @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
18918 @samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x2},
18919 @samp{cortex-a510}, @samp{cortex-a710}, @samp{ampere1}, @samp{native}.
18921 The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
18922 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
18923 @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC
18924 should tune for a big.LITTLE system.
18926 The value @samp{neoverse-512tvb} specifies that GCC should tune
18927 for Neoverse cores that (a) implement SVE and (b) have a total vector
18928 bandwidth of 512 bits per cycle. In other words, the option tells GCC to
18929 tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
18930 instructions a cycle and that can execute an equivalent number of SVE
18931 arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
18932 This is more general than tuning for a specific core like Neoverse V1
18933 but is more specific than the default tuning described below.
18935 Additionally on native AArch64 GNU/Linux systems the value
18936 @samp{native} tunes performance to the host system. This option has no effect
18937 if the compiler is unable to recognize the processor of the host system.
18939 Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
18940 are specified, the code is tuned to perform well across a range
18941 of target processors.
18943 This option cannot be suffixed by feature modifiers.
18945 @item -mcpu=@var{name}
18947 Specify the name of the target processor, optionally suffixed by one
18948 or more feature modifiers. This option has the form
18949 @option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
18950 the permissible values for @var{cpu} are the same as those available
18951 for @option{-mtune}. The permissible values for @var{feature} are
18952 documented in the sub-section on
18953 @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
18954 Feature Modifiers}. Where conflicting feature modifiers are
18955 specified, the right-most feature is used.
18957 GCC uses @var{name} to determine what kind of instructions it can emit when
18958 generating assembly code (as if by @option{-march}) and to determine
18959 the target processor for which to tune for performance (as if
18960 by @option{-mtune}). Where this option is used in conjunction
18961 with @option{-march} or @option{-mtune}, those options take precedence
18962 over the appropriate part of this option.
18964 @option{-mcpu=neoverse-512tvb} is special in that it does not refer
18965 to a specific core, but instead refers to all Neoverse cores that
18966 (a) implement SVE and (b) have a total vector bandwidth of 512 bits
18967 a cycle. Unless overridden by @option{-march},
18968 @option{-mcpu=neoverse-512tvb} generates code that can run on a
18969 Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
18970 these properties. Unless overridden by @option{-mtune},
18971 @option{-mcpu=neoverse-512tvb} tunes code in the same way as for
18972 @option{-mtune=neoverse-512tvb}.
18974 @item -moverride=@var{string}
18976 Override tuning decisions made by the back-end in response to a
18977 @option{-mtune=} switch. The syntax, semantics, and accepted values
18978 for @var{string} in this option are not guaranteed to be consistent
18981 This option is only intended to be useful when developing GCC.
18983 @item -mverbose-cost-dump
18984 @opindex mverbose-cost-dump
18985 Enable verbose cost model dumping in the debug dump files. This option is
18986 provided for use in debugging the compiler.
18988 @item -mpc-relative-literal-loads
18989 @itemx -mno-pc-relative-literal-loads
18990 @opindex mpc-relative-literal-loads
18991 @opindex mno-pc-relative-literal-loads
18992 Enable or disable PC-relative literal loads. With this option literal pools are
18993 accessed using a single instruction and emitted after each function. This
18994 limits the maximum size of functions to 1MB. This is enabled by default for
18995 @option{-mcmodel=tiny}.
18997 @item -msign-return-address=@var{scope}
18998 @opindex msign-return-address
18999 Select the function scope on which return address signing will be applied.
19000 Permissible values are @samp{none}, which disables return address signing,
19001 @samp{non-leaf}, which enables pointer signing for functions which are not leaf
19002 functions, and @samp{all}, which enables pointer signing for all functions. The
19003 default value is @samp{none}. This option has been deprecated by
19004 -mbranch-protection.
19006 @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}
19007 @opindex mbranch-protection
19008 Select the branch protection features to use.
19009 @samp{none} is the default and turns off all types of branch protection.
19010 @samp{standard} turns on all types of branch protection features. If a feature
19011 has additional tuning options, then @samp{standard} sets it to its standard
19013 @samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
19014 level: signing functions that save the return address to memory (non-leaf
19015 functions will practically always do this) using the a-key. The optional
19016 argument @samp{leaf} can be used to extend the signing to include leaf
19017 functions. The optional argument @samp{b-key} can be used to sign the functions
19018 with the B-key instead of the A-key.
19019 @samp{bti} turns on branch target identification mechanism.
19021 @item -mharden-sls=@var{opts}
19022 @opindex mharden-sls
19023 Enable compiler hardening against straight line speculation (SLS).
19024 @var{opts} is a comma-separated list of the following options:
19029 In addition, @samp{-mharden-sls=all} enables all SLS hardening while
19030 @samp{-mharden-sls=none} disables all SLS hardening.
19032 @item -msve-vector-bits=@var{bits}
19033 @opindex msve-vector-bits
19034 Specify the number of bits in an SVE vector register. This option only has
19035 an effect when SVE is enabled.
19037 GCC supports two forms of SVE code generation: ``vector-length
19038 agnostic'' output that works with any size of vector register and
19039 ``vector-length specific'' output that allows GCC to make assumptions
19040 about the vector length when it is useful for optimization reasons.
19041 The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
19042 @samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
19043 Specifying @samp{scalable} selects vector-length agnostic
19044 output. At present @samp{-msve-vector-bits=128} also generates vector-length
19045 agnostic output for big-endian targets. All other values generate
19046 vector-length specific code. The behavior of these values may change
19047 in future releases and no value except @samp{scalable} should be
19048 relied on for producing code that is portable across different
19049 hardware SVE vector lengths.
19051 The default is @samp{-msve-vector-bits=scalable}, which produces
19052 vector-length agnostic code.
19055 @subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
19056 @anchor{aarch64-feature-modifiers}
19057 @cindex @option{-march} feature modifiers
19058 @cindex @option{-mcpu} feature modifiers
19059 Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
19060 the following and their inverses @option{no@var{feature}}:
19064 Enable CRC extension. This is on by default for
19065 @option{-march=armv8.1-a}.
19067 Enable Crypto extension. This also enables Advanced SIMD and floating-point
19070 Enable floating-point instructions. This is on by default for all possible
19071 values for options @option{-march} and @option{-mcpu}.
19073 Enable Advanced SIMD instructions. This also enables floating-point
19074 instructions. This is on by default for all possible values for options
19075 @option{-march} and @option{-mcpu}.
19077 Enable Scalable Vector Extension instructions. This also enables Advanced
19078 SIMD and floating-point instructions.
19080 Enable Large System Extension instructions. This is on by default for
19081 @option{-march=armv8.1-a}.
19083 Enable Round Double Multiply Accumulate instructions. This is on by default
19084 for @option{-march=armv8.1-a}.
19086 Enable FP16 extension. This also enables floating-point instructions.
19088 Enable FP16 fmla extension. This also enables FP16 extensions and
19089 floating-point instructions. This option is enabled by default for @option{-march=armv8.4-a}. Use of this option with architectures prior to Armv8.2-A is not supported.
19092 Enable the RcPc extension. This does not change code generation from GCC,
19093 but is passed on to the assembler, enabling inline asm statements to use
19094 instructions from the RcPc extension.
19096 Enable the Dot Product extension. This also enables Advanced SIMD instructions.
19098 Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
19101 Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
19103 Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
19104 instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
19106 Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
19107 Use of this option with architectures prior to Armv8.2-A is not supported.
19109 Enable the Statistical Profiling extension. This option is only to enable the
19110 extension at the assembler level and does not affect code generation.
19112 Enable the Armv8.5-a Random Number instructions. This option is only to
19113 enable the extension at the assembler level and does not affect code
19116 Enable the Armv8.5-a Memory Tagging Extensions.
19117 Use of this option with architectures prior to Armv8.5-A is not supported.
19119 Enable the Armv8-a Speculation Barrier instruction. This option is only to
19120 enable the extension at the assembler level and does not affect code
19121 generation. This option is enabled by default for @option{-march=armv8.5-a}.
19123 Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
19124 is only to enable the extension at the assembler level and does not affect code
19125 generation. This option is enabled by default for @option{-march=armv8.5-a}.
19127 Enable the Armv8-a Execution and Data Prediction Restriction instructions.
19128 This option is only to enable the extension at the assembler level and does
19129 not affect code generation. This option is enabled by default for
19130 @option{-march=armv8.5-a}.
19132 Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
19135 Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
19137 Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
19139 Enable SVE2 aes instructions. This also enables SVE2 instructions.
19141 Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
19143 Enable the Transactional Memory Extension.
19145 Enable 8-bit Integer Matrix Multiply instructions. This also enables
19146 Advanced SIMD and floating-point instructions. This option is enabled by
19147 default for @option{-march=armv8.6-a}. Use of this option with architectures
19148 prior to Armv8.2-A is not supported.
19150 Enable 32-bit Floating point Matrix Multiply instructions. This also enables
19151 SVE instructions. Use of this option with architectures prior to Armv8.2-A is
19154 Enable 64-bit Floating point Matrix Multiply instructions. This also enables
19155 SVE instructions. Use of this option with architectures prior to Armv8.2-A is
19158 Enable brain half-precision floating-point instructions. This also enables
19159 Advanced SIMD and floating-point instructions. This option is enabled by
19160 default for @option{-march=armv8.6-a}. Use of this option with architectures
19161 prior to Armv8.2-A is not supported.
19163 Enable the 64-byte atomic load and store instructions for accelerators.
19164 This option is enabled by default for @option{-march=armv8.7-a}.
19166 Enable the instructions to accelerate memory operations like @code{memcpy},
19167 @code{memmove}, @code{memset}. This option is enabled by default for
19168 @option{-march=armv8.8-a}
19170 Enable the Flag Manipulation instructions Extension.
19172 Enable the Pointer Authentication Extension.
19176 Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
19177 which implies @option{fp}.
19178 Conversely, @option{nofp} implies @option{nosimd}, which implies
19179 @option{nocrypto}, @option{noaes} and @option{nosha2}.
19181 @node Adapteva Epiphany Options
19182 @subsection Adapteva Epiphany Options
19184 These @samp{-m} options are defined for Adapteva Epiphany:
19187 @item -mhalf-reg-file
19188 @opindex mhalf-reg-file
19189 Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
19190 That allows code to run on hardware variants that lack these registers.
19192 @item -mprefer-short-insn-regs
19193 @opindex mprefer-short-insn-regs
19194 Preferentially allocate registers that allow short instruction generation.
19195 This can result in increased instruction count, so this may either reduce or
19196 increase overall code size.
19198 @item -mbranch-cost=@var{num}
19199 @opindex mbranch-cost
19200 Set the cost of branches to roughly @var{num} ``simple'' instructions.
19201 This cost is only a heuristic and is not guaranteed to produce
19202 consistent results across releases.
19206 Enable the generation of conditional moves.
19208 @item -mnops=@var{num}
19210 Emit @var{num} NOPs before every other generated instruction.
19212 @item -mno-soft-cmpsf
19213 @opindex mno-soft-cmpsf
19214 @opindex msoft-cmpsf
19215 For single-precision floating-point comparisons, emit an @code{fsub} instruction
19216 and test the flags. This is faster than a software comparison, but can
19217 get incorrect results in the presence of NaNs, or when two different small
19218 numbers are compared such that their difference is calculated as zero.
19219 The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
19220 software comparisons.
19222 @item -mstack-offset=@var{num}
19223 @opindex mstack-offset
19224 Set the offset between the top of the stack and the stack pointer.
19225 E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
19226 can be used by leaf functions without stack allocation.
19227 Values other than @samp{8} or @samp{16} are untested and unlikely to work.
19228 Note also that this option changes the ABI; compiling a program with a
19229 different stack offset than the libraries have been compiled with
19230 generally does not work.
19231 This option can be useful if you want to evaluate if a different stack
19232 offset would give you better code, but to actually use a different stack
19233 offset to build working programs, it is recommended to configure the
19234 toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
19236 @item -mno-round-nearest
19237 @opindex mno-round-nearest
19238 @opindex mround-nearest
19239 Make the scheduler assume that the rounding mode has been set to
19240 truncating. The default is @option{-mround-nearest}.
19243 @opindex mlong-calls
19244 If not otherwise specified by an attribute, assume all calls might be beyond
19245 the offset range of the @code{b} / @code{bl} instructions, and therefore load the
19246 function address into a register before performing a (otherwise direct) call.
19247 This is the default.
19249 @item -mshort-calls
19250 @opindex short-calls
19251 If not otherwise specified by an attribute, assume all direct calls are
19252 in the range of the @code{b} / @code{bl} instructions, so use these instructions
19253 for direct calls. The default is @option{-mlong-calls}.
19257 Assume addresses can be loaded as 16-bit unsigned values. This does not
19258 apply to function addresses for which @option{-mlong-calls} semantics
19261 @item -mfp-mode=@var{mode}
19263 Set the prevailing mode of the floating-point unit.
19264 This determines the floating-point mode that is provided and expected
19265 at function call and return time. Making this mode match the mode you
19266 predominantly need at function start can make your programs smaller and
19267 faster by avoiding unnecessary mode switches.
19269 @var{mode} can be set to one the following values:
19273 Any mode at function entry is valid, and retained or restored when
19274 the function returns, and when it calls other functions.
19275 This mode is useful for compiling libraries or other compilation units
19276 you might want to incorporate into different programs with different
19277 prevailing FPU modes, and the convenience of being able to use a single
19278 object file outweighs the size and speed overhead for any extra
19279 mode switching that might be needed, compared with what would be needed
19280 with a more specific choice of prevailing FPU mode.
19283 This is the mode used for floating-point calculations with
19284 truncating (i.e.@: round towards zero) rounding mode. That includes
19285 conversion from floating point to integer.
19287 @item round-nearest
19288 This is the mode used for floating-point calculations with
19289 round-to-nearest-or-even rounding mode.
19292 This is the mode used to perform integer calculations in the FPU, e.g.@:
19293 integer multiply, or integer multiply-and-accumulate.
19296 The default is @option{-mfp-mode=caller}
19298 @item -mno-split-lohi
19299 @itemx -mno-postinc
19300 @itemx -mno-postmodify
19301 @opindex mno-split-lohi
19302 @opindex msplit-lohi
19303 @opindex mno-postinc
19305 @opindex mno-postmodify
19306 @opindex mpostmodify
19307 Code generation tweaks that disable, respectively, splitting of 32-bit
19308 loads, generation of post-increment addresses, and generation of
19309 post-modify addresses. The defaults are @option{msplit-lohi},
19310 @option{-mpost-inc}, and @option{-mpost-modify}.
19312 @item -mnovect-double
19313 @opindex mno-vect-double
19314 @opindex mvect-double
19315 Change the preferred SIMD mode to SImode. The default is
19316 @option{-mvect-double}, which uses DImode as preferred SIMD mode.
19318 @item -max-vect-align=@var{num}
19319 @opindex max-vect-align
19320 The maximum alignment for SIMD vector mode types.
19321 @var{num} may be 4 or 8. The default is 8.
19322 Note that this is an ABI change, even though many library function
19323 interfaces are unaffected if they don't use SIMD vector modes
19324 in places that affect size and/or alignment of relevant types.
19326 @item -msplit-vecmove-early
19327 @opindex msplit-vecmove-early
19328 Split vector moves into single word moves before reload. In theory this
19329 can give better register allocation, but so far the reverse seems to be
19330 generally the case.
19332 @item -m1reg-@var{reg}
19334 Specify a register to hold the constant @minus{}1, which makes loading small negative
19335 constants and certain bitmasks faster.
19336 Allowable values for @var{reg} are @samp{r43} and @samp{r63},
19337 which specify use of that register as a fixed register,
19338 and @samp{none}, which means that no register is used for this
19339 purpose. The default is @option{-m1reg-none}.
19343 @node AMD GCN Options
19344 @subsection AMD GCN Options
19345 @cindex AMD GCN Options
19347 These options are defined specifically for the AMD GCN port.
19351 @item -march=@var{gpu}
19353 @itemx -mtune=@var{gpu}
19355 Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
19361 Compile for GCN3 Fiji devices (gfx803).
19364 Compile for GCN5 Vega 10 devices (gfx900).
19367 Compile for GCN5 Vega 20 devices (gfx906).
19371 @item -msram-ecc=on
19372 @itemx -msram-ecc=off
19373 @itemx -msram-ecc=any
19375 Compile binaries suitable for devices with the SRAM-ECC feature enabled,
19376 disabled, or either mode. This feature can be enabled per-process on some
19377 devices. The compiled code must match the device mode. The default is
19378 @samp{any}, for devices that support it.
19380 @item -mstack-size=@var{bytes}
19381 @opindex mstack-size
19382 Specify how many @var{bytes} of stack space will be requested for each GPU
19383 thread (wave-front). Beware that there may be many threads and limited memory
19384 available. The size of the stack allocation may also have an impact on
19385 run-time performance. The default is 32KB when using OpenACC or OpenMP, and
19390 Compile binaries suitable for devices with the XNACK feature enabled. Some
19391 devices always require XNACK and some allow the user to configure XNACK. The
19392 compiled code must match the device mode. The default is @samp{-mno-xnack}.
19393 At present this option is a placeholder for support that is not yet
19399 @subsection ARC Options
19400 @cindex ARC options
19402 The following options control the architecture variant for which code
19405 @c architecture variants
19408 @item -mbarrel-shifter
19409 @opindex mbarrel-shifter
19410 Generate instructions supported by barrel shifter. This is the default
19411 unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
19414 @opindex mjli-alawys
19415 Force to call a function using jli_s instruction. This option is
19416 valid only for ARCv2 architecture.
19418 @item -mcpu=@var{cpu}
19420 Set architecture type, register usage, and instruction scheduling
19421 parameters for @var{cpu}. There are also shortcut alias options
19422 available for backward compatibility and convenience. Supported
19423 values for @var{cpu} are
19429 Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
19433 Compile for ARC601. Alias: @option{-mARC601}.
19438 Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
19439 This is the default when configured with @option{--with-cpu=arc700}@.
19442 Compile for ARC EM.
19445 Compile for ARC HS.
19448 Compile for ARC EM CPU with no hardware extensions.
19451 Compile for ARC EM4 CPU.
19454 Compile for ARC EM4 DMIPS CPU.
19457 Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
19461 Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
19462 double assist instructions.
19465 Compile for ARC HS CPU with no hardware extensions except the atomic
19469 Compile for ARC HS34 CPU.
19472 Compile for ARC HS38 CPU.
19475 Compile for ARC HS38 CPU with all hardware extensions on.
19478 Compile for ARC 600 CPU with @code{norm} instructions enabled.
19480 @item arc600_mul32x16
19481 Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
19482 instructions enabled.
19485 Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
19486 instructions enabled.
19489 Compile for ARC 601 CPU with @code{norm} instructions enabled.
19491 @item arc601_mul32x16
19492 Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
19493 instructions enabled.
19496 Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
19497 instructions enabled.
19500 Compile for ARC 700 on NPS400 chip.
19503 Compile for ARC EM minimalist configuration featuring reduced register
19510 @itemx -mdpfp-compact
19511 @opindex mdpfp-compact
19512 Generate double-precision FPX instructions, tuned for the compact
19516 @opindex mdpfp-fast
19517 Generate double-precision FPX instructions, tuned for the fast
19520 @item -mno-dpfp-lrsr
19521 @opindex mno-dpfp-lrsr
19522 Disable @code{lr} and @code{sr} instructions from using FPX extension
19527 Generate extended arithmetic instructions. Currently only
19528 @code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
19529 supported. Only valid for @option{-mcpu=ARC700}.
19534 Do not generate @code{mpy}-family instructions for ARC700. This option is
19539 Generate 32x16-bit multiply and multiply-accumulate instructions.
19543 Generate @code{mul64} and @code{mulu64} instructions.
19544 Only valid for @option{-mcpu=ARC600}.
19548 Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
19553 @itemx -mspfp-compact
19554 @opindex mspfp-compact
19555 Generate single-precision FPX instructions, tuned for the compact
19559 @opindex mspfp-fast
19560 Generate single-precision FPX instructions, tuned for the fast
19565 Enable generation of ARC SIMD instructions via target-specific
19566 builtins. Only valid for @option{-mcpu=ARC700}.
19569 @opindex msoft-float
19570 This option ignored; it is provided for compatibility purposes only.
19571 Software floating-point code is emitted by default, and this default
19572 can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
19573 @option{-mspfp-fast} for single precision, and @option{-mdpfp},
19574 @option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
19578 Generate @code{swap} instructions.
19582 This enables use of the locked load/store conditional extension to implement
19583 atomic memory built-in functions. Not available for ARC 6xx or ARC
19588 Enable @code{div} and @code{rem} instructions for ARCv2 cores.
19590 @item -mcode-density
19591 @opindex mcode-density
19592 Enable code density instructions for ARC EM.
19593 This option is on by default for ARC HS.
19597 Enable double load/store operations for ARC HS cores.
19599 @item -mtp-regno=@var{regno}
19601 Specify thread pointer register number.
19603 @item -mmpy-option=@var{multo}
19604 @opindex mmpy-option
19605 Compile ARCv2 code with a multiplier design option. You can specify
19606 the option using either a string or numeric value for @var{multo}.
19607 @samp{wlh1} is the default value. The recognized values are:
19612 No multiplier available.
19616 16x16 multiplier, fully pipelined.
19617 The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
19621 32x32 multiplier, fully
19622 pipelined (1 stage). The following instructions are additionally
19623 enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
19627 32x32 multiplier, fully pipelined
19628 (2 stages). The following instructions are additionally enabled: @code{mpy},
19629 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
19633 Two 16x16 multipliers, blocking,
19634 sequential. The following instructions are additionally enabled: @code{mpy},
19635 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
19639 One 16x16 multiplier, blocking,
19640 sequential. The following instructions are additionally enabled: @code{mpy},
19641 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
19645 One 32x4 multiplier, blocking,
19646 sequential. The following instructions are additionally enabled: @code{mpy},
19647 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
19651 ARC HS SIMD support.
19655 ARC HS SIMD support.
19659 ARC HS SIMD support.
19663 This option is only available for ARCv2 cores@.
19665 @item -mfpu=@var{fpu}
19667 Enables support for specific floating-point hardware extensions for ARCv2
19668 cores. Supported values for @var{fpu} are:
19673 Enables support for single-precision floating-point hardware
19677 Enables support for double-precision floating-point hardware
19678 extensions. The single-precision floating-point extension is also
19679 enabled. Not available for ARC EM@.
19682 Enables support for double-precision floating-point hardware
19683 extensions using double-precision assist instructions. The single-precision
19684 floating-point extension is also enabled. This option is
19685 only available for ARC EM@.
19688 Enables support for double-precision floating-point hardware
19689 extensions using double-precision assist instructions.
19690 The single-precision floating-point, square-root, and divide
19691 extensions are also enabled. This option is
19692 only available for ARC EM@.
19695 Enables support for double-precision floating-point hardware
19696 extensions using double-precision assist instructions.
19697 The single-precision floating-point and fused multiply and add
19698 hardware extensions are also enabled. This option is
19699 only available for ARC EM@.
19702 Enables support for double-precision floating-point hardware
19703 extensions using double-precision assist instructions.
19704 All single-precision floating-point hardware extensions are also
19705 enabled. This option is only available for ARC EM@.
19708 Enables support for single-precision floating-point, square-root and divide
19709 hardware extensions@.
19712 Enables support for double-precision floating-point, square-root and divide
19713 hardware extensions. This option
19714 includes option @samp{fpus_div}. Not available for ARC EM@.
19717 Enables support for single-precision floating-point and
19718 fused multiply and add hardware extensions@.
19721 Enables support for double-precision floating-point and
19722 fused multiply and add hardware extensions. This option
19723 includes option @samp{fpus_fma}. Not available for ARC EM@.
19726 Enables support for all single-precision floating-point hardware
19730 Enables support for all single- and double-precision floating-point
19731 hardware extensions. Not available for ARC EM@.
19735 @item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
19736 @opindex mirq-ctrl-saved
19737 Specifies general-purposes registers that the processor automatically
19738 saves/restores on interrupt entry and exit. @var{register-range} is
19739 specified as two registers separated by a dash. The register range
19740 always starts with @code{r0}, the upper limit is @code{fp} register.
19741 @var{blink} and @var{lp_count} are optional. This option is only
19742 valid for ARC EM and ARC HS cores.
19744 @item -mrgf-banked-regs=@var{number}
19745 @opindex mrgf-banked-regs
19746 Specifies the number of registers replicated in second register bank
19747 on entry to fast interrupt. Fast interrupts are interrupts with the
19748 highest priority level P0. These interrupts save only PC and STATUS32
19749 registers to avoid memory transactions during interrupt entry and exit
19750 sequences. Use this option when you are using fast interrupts in an
19751 ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
19753 @item -mlpc-width=@var{width}
19754 @opindex mlpc-width
19755 Specify the width of the @code{lp_count} register. Valid values for
19756 @var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
19757 fixed to 32 bits. If the width is less than 32, the compiler does not
19758 attempt to transform loops in your program to use the zero-delay loop
19759 mechanism unless it is known that the @code{lp_count} register can
19760 hold the required loop-counter value. Depending on the width
19761 specified, the compiler and run-time library might continue to use the
19762 loop mechanism for various needs. This option defines macro
19763 @code{__ARC_LPC_WIDTH__} with the value of @var{width}.
19767 This option instructs the compiler to generate code for a 16-entry
19768 register file. This option defines the @code{__ARC_RF16__}
19769 preprocessor macro.
19771 @item -mbranch-index
19772 @opindex mbranch-index
19773 Enable use of @code{bi} or @code{bih} instructions to implement jump
19778 The following options are passed through to the assembler, and also
19779 define preprocessor macro symbols.
19781 @c Flags used by the assembler, but for which we define preprocessor
19782 @c macro symbols as well.
19785 @opindex mdsp-packa
19786 Passed down to the assembler to enable the DSP Pack A extensions.
19787 Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
19792 Passed down to the assembler to enable the dual Viterbi butterfly
19793 extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
19794 option is deprecated.
19796 @c ARC700 4.10 extension instruction
19799 Passed down to the assembler to enable the locked load/store
19800 conditional extension. Also sets the preprocessor symbol
19805 Passed down to the assembler. Also sets the preprocessor symbol
19806 @code{__Xxmac_d16}. This option is deprecated.
19810 Passed down to the assembler. Also sets the preprocessor symbol
19811 @code{__Xxmac_24}. This option is deprecated.
19813 @c ARC700 4.10 extension instruction
19816 Passed down to the assembler to enable the 64-bit time-stamp counter
19817 extension instruction. Also sets the preprocessor symbol
19818 @code{__Xrtsc}. This option is deprecated.
19820 @c ARC700 4.10 extension instruction
19823 Passed down to the assembler to enable the swap byte ordering
19824 extension instruction. Also sets the preprocessor symbol
19828 @opindex mtelephony
19829 Passed down to the assembler to enable dual- and single-operand
19830 instructions for telephony. Also sets the preprocessor symbol
19831 @code{__Xtelephony}. This option is deprecated.
19835 Passed down to the assembler to enable the XY memory extension. Also
19836 sets the preprocessor symbol @code{__Xxy}.
19840 The following options control how the assembly code is annotated:
19842 @c Assembly annotation options
19846 Annotate assembler instructions with estimated addresses.
19848 @item -mannotate-align
19849 @opindex mannotate-align
19850 Explain what alignment considerations lead to the decision to make an
19851 instruction short or long.
19855 The following options are passed through to the linker:
19857 @c options passed through to the linker
19861 Passed through to the linker, to specify use of the @code{arclinux} emulation.
19862 This option is enabled by default in tool chains built for
19863 @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
19864 when profiling is not requested.
19866 @item -marclinux_prof
19867 @opindex marclinux_prof
19868 Passed through to the linker, to specify use of the
19869 @code{arclinux_prof} emulation. This option is enabled by default in
19870 tool chains built for @w{@code{arc-linux-uclibc}} and
19871 @w{@code{arceb-linux-uclibc}} targets when profiling is requested.
19875 The following options control the semantics of generated code:
19877 @c semantically relevant code generation options
19880 @opindex mlong-calls
19881 Generate calls as register indirect calls, thus providing access
19882 to the full 32-bit address range.
19884 @item -mmedium-calls
19885 @opindex mmedium-calls
19886 Don't use less than 25-bit addressing range for calls, which is the
19887 offset available for an unconditional branch-and-link
19888 instruction. Conditional execution of function calls is suppressed, to
19889 allow use of the 25-bit range, rather than the 21-bit range with
19890 conditional branch-and-link. This is the default for tool chains built
19891 for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
19895 Put definitions of externally-visible data in a small data section if
19896 that data is no bigger than @var{num} bytes. The default value of
19897 @var{num} is 4 for any ARC configuration, or 8 when we have double
19898 load/store operations.
19903 Do not generate sdata references. This is the default for tool chains
19904 built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
19907 @item -mvolatile-cache
19908 @opindex mvolatile-cache
19909 Use ordinarily cached memory accesses for volatile references. This is the
19912 @item -mno-volatile-cache
19913 @opindex mno-volatile-cache
19914 @opindex mvolatile-cache
19915 Enable cache bypass for volatile references.
19919 The following options fine tune code generation:
19920 @c code generation tuning options
19923 @opindex malign-call
19924 Does nothing. Preserved for backward compatibility.
19926 @item -mauto-modify-reg
19927 @opindex mauto-modify-reg
19928 Enable the use of pre/post modify with register displacement.
19930 @item -mbbit-peephole
19931 @opindex mbbit-peephole
19932 Enable bbit peephole2.
19936 This option disables a target-specific pass in @file{arc_reorg} to
19937 generate compare-and-branch (@code{br@var{cc}}) instructions.
19938 It has no effect on
19939 generation of these instructions driven by the combiner pass.
19941 @item -mcase-vector-pcrel
19942 @opindex mcase-vector-pcrel
19943 Use PC-relative switch case tables to enable case table shortening.
19944 This is the default for @option{-Os}.
19946 @item -mcompact-casesi
19947 @opindex mcompact-casesi
19948 Enable compact @code{casesi} pattern. This is the default for @option{-Os},
19949 and only available for ARCv1 cores. This option is deprecated.
19951 @item -mno-cond-exec
19952 @opindex mno-cond-exec
19953 Disable the ARCompact-specific pass to generate conditional
19954 execution instructions.
19956 Due to delay slot scheduling and interactions between operand numbers,
19957 literal sizes, instruction lengths, and the support for conditional execution,
19958 the target-independent pass to generate conditional execution is often lacking,
19959 so the ARC port has kept a special pass around that tries to find more
19960 conditional execution generation opportunities after register allocation,
19961 branch shortening, and delay slot scheduling have been done. This pass
19962 generally, but not always, improves performance and code size, at the cost of
19963 extra compilation time, which is why there is an option to switch it off.
19964 If you have a problem with call instructions exceeding their allowable
19965 offset range because they are conditionalized, you should consider using
19966 @option{-mmedium-calls} instead.
19968 @item -mearly-cbranchsi
19969 @opindex mearly-cbranchsi
19970 Enable pre-reload use of the @code{cbranchsi} pattern.
19972 @item -mexpand-adddi
19973 @opindex mexpand-adddi
19974 Expand @code{adddi3} and @code{subdi3} at RTL generation time into
19975 @code{add.f}, @code{adc} etc. This option is deprecated.
19977 @item -mindexed-loads
19978 @opindex mindexed-loads
19979 Enable the use of indexed loads. This can be problematic because some
19980 optimizers then assume that indexed stores exist, which is not
19985 Enable Local Register Allocation. This is still experimental for ARC,
19986 so by default the compiler uses standard reload
19987 (i.e.@: @option{-mno-lra}).
19989 @item -mlra-priority-none
19990 @opindex mlra-priority-none
19991 Don't indicate any priority for target registers.
19993 @item -mlra-priority-compact
19994 @opindex mlra-priority-compact
19995 Indicate target register priority for r0..r3 / r12..r15.
19997 @item -mlra-priority-noncompact
19998 @opindex mlra-priority-noncompact
19999 Reduce target register priority for r0..r3 / r12..r15.
20002 @opindex mmillicode
20003 When optimizing for size (using @option{-Os}), prologues and epilogues
20004 that have to save or restore a large number of registers are often
20005 shortened by using call to a special function in libgcc; this is
20006 referred to as a @emph{millicode} call. As these calls can pose
20007 performance issues, and/or cause linking issues when linking in a
20008 nonstandard way, this option is provided to turn on or off millicode
20011 @item -mcode-density-frame
20012 @opindex mcode-density-frame
20013 This option enable the compiler to emit @code{enter} and @code{leave}
20014 instructions. These instructions are only valid for CPUs with
20015 code-density feature.
20018 @opindex mmixed-code
20019 Does nothing. Preserved for backward compatibility.
20023 Ths option is deprecated. Enable @samp{q} instruction alternatives.
20024 This is the default for @option{-Os}.
20028 Enable @samp{Rcq} constraint handling.
20029 Most short code generation depends on this.
20030 This is the default.
20034 Enable @samp{Rcw} constraint handling.
20035 Most ccfsm condexec mostly depends on this.
20036 This is the default.
20038 @item -msize-level=@var{level}
20039 @opindex msize-level
20040 Fine-tune size optimization with regards to instruction lengths and alignment.
20041 The recognized values for @var{level} are:
20044 No size optimization. This level is deprecated and treated like @samp{1}.
20047 Short instructions are used opportunistically.
20050 In addition, alignment of loops and of code after barriers are dropped.
20053 In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
20057 This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
20058 the behavior when this is not set is equivalent to level @samp{1}.
20060 @item -mtune=@var{cpu}
20062 Set instruction scheduling parameters for @var{cpu}, overriding any implied
20063 by @option{-mcpu=}.
20065 Supported values for @var{cpu} are
20069 Tune for ARC600 CPU.
20072 Tune for ARC601 CPU.
20075 Tune for ARC700 CPU with standard multiplier block.
20078 Tune for ARC700 CPU with XMAC block.
20081 Tune for ARC725D CPU.
20084 Tune for ARC750D CPU.
20088 @item -mmultcost=@var{num}
20090 Cost to assume for a multiply instruction, with @samp{4} being equal to a
20091 normal instruction.
20093 @item -munalign-prob-threshold=@var{probability}
20094 @opindex munalign-prob-threshold
20095 Does nothing. Preserved for backward compatibility.
20099 The following options are maintained for backward compatibility, but
20100 are now deprecated and will be removed in a future release:
20102 @c Deprecated options
20110 @opindex mbig-endian
20113 Compile code for big-endian targets. Use of these options is now
20114 deprecated. Big-endian code is supported by configuring GCC to build
20115 @w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
20116 for which big endian is the default.
20118 @item -mlittle-endian
20119 @opindex mlittle-endian
20122 Compile code for little-endian targets. Use of these options is now
20123 deprecated. Little-endian code is supported by configuring GCC to build
20124 @w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
20125 for which little endian is the default.
20127 @item -mbarrel_shifter
20128 @opindex mbarrel_shifter
20129 Replaced by @option{-mbarrel-shifter}.
20131 @item -mdpfp_compact
20132 @opindex mdpfp_compact
20133 Replaced by @option{-mdpfp-compact}.
20136 @opindex mdpfp_fast
20137 Replaced by @option{-mdpfp-fast}.
20140 @opindex mdsp_packa
20141 Replaced by @option{-mdsp-packa}.
20145 Replaced by @option{-mea}.
20149 Replaced by @option{-mmac-24}.
20153 Replaced by @option{-mmac-d16}.
20155 @item -mspfp_compact
20156 @opindex mspfp_compact
20157 Replaced by @option{-mspfp-compact}.
20160 @opindex mspfp_fast
20161 Replaced by @option{-mspfp-fast}.
20163 @item -mtune=@var{cpu}
20165 Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
20166 @samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
20167 @samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
20169 @item -multcost=@var{num}
20171 Replaced by @option{-mmultcost}.
20176 @subsection ARM Options
20177 @cindex ARM options
20179 These @samp{-m} options are defined for the ARM port:
20182 @item -mabi=@var{name}
20184 Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
20185 @samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}.
20188 @opindex mapcs-frame
20189 Generate a stack frame that is compliant with the ARM Procedure Call
20190 Standard for all functions, even if this is not strictly necessary for
20191 correct execution of the code. Specifying @option{-fomit-frame-pointer}
20192 with this option causes the stack frames not to be generated for
20193 leaf functions. The default is @option{-mno-apcs-frame}.
20194 This option is deprecated.
20198 This is a synonym for @option{-mapcs-frame} and is deprecated.
20201 @c not currently implemented
20202 @item -mapcs-stack-check
20203 @opindex mapcs-stack-check
20204 Generate code to check the amount of stack space available upon entry to
20205 every function (that actually uses some stack space). If there is
20206 insufficient space available then either the function
20207 @code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
20208 called, depending upon the amount of stack space required. The runtime
20209 system is required to provide these functions. The default is
20210 @option{-mno-apcs-stack-check}, since this produces smaller code.
20212 @c not currently implemented
20213 @item -mapcs-reentrant
20214 @opindex mapcs-reentrant
20215 Generate reentrant, position-independent code. The default is
20216 @option{-mno-apcs-reentrant}.
20219 @item -mthumb-interwork
20220 @opindex mthumb-interwork
20221 Generate code that supports calling between the ARM and Thumb
20222 instruction sets. Without this option, on pre-v5 architectures, the
20223 two instruction sets cannot be reliably used inside one program. The
20224 default is @option{-mno-thumb-interwork}, since slightly larger code
20225 is generated when @option{-mthumb-interwork} is specified. In AAPCS
20226 configurations this option is meaningless.
20228 @item -mno-sched-prolog
20229 @opindex mno-sched-prolog
20230 @opindex msched-prolog
20231 Prevent the reordering of instructions in the function prologue, or the
20232 merging of those instruction with the instructions in the function's
20233 body. This means that all functions start with a recognizable set
20234 of instructions (or in fact one of a choice from a small set of
20235 different function prologues), and this information can be used to
20236 locate the start of functions inside an executable piece of code. The
20237 default is @option{-msched-prolog}.
20239 @item -mfloat-abi=@var{name}
20240 @opindex mfloat-abi
20241 Specifies which floating-point ABI to use. Permissible values
20242 are: @samp{soft}, @samp{softfp} and @samp{hard}.
20244 Specifying @samp{soft} causes GCC to generate output containing
20245 library calls for floating-point operations.
20246 @samp{softfp} allows the generation of code using hardware floating-point
20247 instructions, but still uses the soft-float calling conventions.
20248 @samp{hard} allows generation of floating-point instructions
20249 and uses FPU-specific calling conventions.
20251 The default depends on the specific target configuration. Note that
20252 the hard-float and soft-float ABIs are not link-compatible; you must
20253 compile your entire program with the same ABI, and link with a
20254 compatible set of libraries.
20256 @item -mgeneral-regs-only
20257 @opindex mgeneral-regs-only
20258 Generate code which uses only the general-purpose registers. This will prevent
20259 the compiler from using floating-point and Advanced SIMD registers but will not
20260 impose any restrictions on the assembler.
20262 @item -mlittle-endian
20263 @opindex mlittle-endian
20264 Generate code for a processor running in little-endian mode. This is
20265 the default for all standard configurations.
20268 @opindex mbig-endian
20269 Generate code for a processor running in big-endian mode; the default is
20270 to compile code for a little-endian processor.
20275 When linking a big-endian image select between BE8 and BE32 formats.
20276 The option has no effect for little-endian images and is ignored. The
20277 default is dependent on the selected target architecture. For ARMv6
20278 and later architectures the default is BE8, for older architectures
20279 the default is BE32. BE32 format has been deprecated by ARM.
20281 @item -march=@var{name}@r{[}+extension@dots{}@r{]}
20283 This specifies the name of the target ARM architecture. GCC uses this
20284 name to determine what kind of instructions it can emit when generating
20285 assembly code. This option can be used in conjunction with or instead
20286 of the @option{-mcpu=} option.
20288 Permissible names are:
20290 @samp{armv5t}, @samp{armv5te},
20291 @samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
20292 @samp{armv6z}, @samp{armv6zk},
20293 @samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
20294 @samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
20301 @samp{armv6-m}, @samp{armv6s-m},
20302 @samp{armv7-m}, @samp{armv7e-m},
20303 @samp{armv8-m.base}, @samp{armv8-m.main},
20304 @samp{armv8.1-m.main},
20306 @samp{iwmmxt} and @samp{iwmmxt2}.
20308 Additionally, the following architectures, which lack support for the
20309 Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
20311 Many of the architectures support extensions. These can be added by
20312 appending @samp{+@var{extension}} to the architecture name. Extension
20313 options are processed in order and capabilities accumulate. An extension
20314 will also enable any necessary base extensions
20315 upon which it depends. For example, the @samp{+crypto} extension
20316 will always enable the @samp{+simd} extension. The exception to the
20317 additive construction is for extensions that are prefixed with
20318 @samp{+no@dots{}}: these extensions disable the specified option and
20319 any other extensions that may depend on the presence of that
20322 For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
20323 writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
20324 entirely disabled by the @samp{+nofp} option that follows it.
20326 Most extension names are generically named, but have an effect that is
20327 dependent upon the architecture to which it is applied. For example,
20328 the @samp{+simd} option can be applied to both @samp{armv7-a} and
20329 @samp{armv8-a} architectures, but will enable the original ARMv7-A
20330 Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
20331 variant for @samp{armv8-a}.
20333 The table below lists the supported extensions for each architecture.
20334 Architectures not mentioned do not support any extensions.
20347 The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
20348 used as an alias for this extension.
20351 Disable the floating-point instructions.
20355 The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
20358 The VFPv3 floating-point instructions, with 16 double-precision
20359 registers. The extension @samp{+vfpv3-d16} can be used as an alias
20360 for this extension. Note that floating-point is not supported by the
20361 base ARMv7-M architecture, but is compatible with both the ARMv7-A and
20362 ARMv7-R architectures.
20365 Disable the floating-point instructions.
20371 The multiprocessing extension.
20374 The security extension.
20377 The VFPv3 floating-point instructions, with 16 double-precision
20378 registers. The extension @samp{+vfpv3-d16} can be used as an alias
20379 for this extension.
20382 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
20383 The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
20384 for this extension.
20387 The VFPv3 floating-point instructions, with 32 double-precision
20390 @item +vfpv3-d16-fp16
20391 The VFPv3 floating-point instructions, with 16 double-precision
20392 registers and the half-precision floating-point conversion operations.
20395 The VFPv3 floating-point instructions, with 32 double-precision
20396 registers and the half-precision floating-point conversion operations.
20399 The VFPv4 floating-point instructions, with 16 double-precision
20403 The VFPv4 floating-point instructions, with 32 double-precision
20407 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
20408 the half-precision floating-point conversion operations.
20411 The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
20414 Disable the Advanced SIMD instructions (does not disable floating point).
20417 Disable the floating-point and Advanced SIMD instructions.
20421 The extended version of the ARMv7-A architecture with support for
20425 The VFPv4 floating-point instructions, with 16 double-precision registers.
20426 The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
20429 The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
20430 extension @samp{+neon-vfpv4} can be used as an alias for this extension.
20433 The VFPv3 floating-point instructions, with 16 double-precision
20437 The VFPv3 floating-point instructions, with 32 double-precision
20440 @item +vfpv3-d16-fp16
20441 The VFPv3 floating-point instructions, with 16 double-precision
20442 registers and the half-precision floating-point conversion operations.
20445 The VFPv3 floating-point instructions, with 32 double-precision
20446 registers and the half-precision floating-point conversion operations.
20449 The VFPv4 floating-point instructions, with 16 double-precision
20453 The VFPv4 floating-point instructions, with 32 double-precision
20457 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
20458 The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
20461 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
20462 the half-precision floating-point conversion operations.
20465 Disable the Advanced SIMD instructions (does not disable floating point).
20468 Disable the floating-point and Advanced SIMD instructions.
20474 The Cyclic Redundancy Check (CRC) instructions.
20476 The ARMv8-A Advanced SIMD and floating-point instructions.
20478 The cryptographic instructions.
20480 Disable the cryptographic instructions.
20482 Disable the floating-point, Advanced SIMD and cryptographic instructions.
20484 Speculation Barrier Instruction.
20486 Execution and Data Prediction Restriction Instructions.
20492 The ARMv8.1-A Advanced SIMD and floating-point instructions.
20495 The cryptographic instructions. This also enables the Advanced SIMD and
20496 floating-point instructions.
20499 Disable the cryptographic instructions.
20502 Disable the floating-point, Advanced SIMD and cryptographic instructions.
20505 Speculation Barrier Instruction.
20508 Execution and Data Prediction Restriction Instructions.
20515 The half-precision floating-point data processing instructions.
20516 This also enables the Advanced SIMD and floating-point instructions.
20519 The half-precision floating-point fmla extension. This also enables
20520 the half-precision floating-point extension and Advanced SIMD and
20521 floating-point instructions.
20524 The ARMv8.1-A Advanced SIMD and floating-point instructions.
20527 The cryptographic instructions. This also enables the Advanced SIMD and
20528 floating-point instructions.
20531 Enable the Dot Product extension. This also enables Advanced SIMD instructions.
20534 Disable the cryptographic extension.
20537 Disable the floating-point, Advanced SIMD and cryptographic instructions.
20540 Speculation Barrier Instruction.
20543 Execution and Data Prediction Restriction Instructions.
20546 8-bit Integer Matrix Multiply instructions.
20547 This also enables Advanced SIMD and floating-point instructions.
20550 Brain half-precision floating-point instructions.
20551 This also enables Advanced SIMD and floating-point instructions.
20557 The half-precision floating-point data processing instructions.
20558 This also enables the Advanced SIMD and floating-point instructions as well
20559 as the Dot Product extension and the half-precision floating-point fmla
20563 The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
20564 Dot Product extension.
20567 The cryptographic instructions. This also enables the Advanced SIMD and
20568 floating-point instructions as well as the Dot Product extension.
20571 Disable the cryptographic extension.
20574 Disable the floating-point, Advanced SIMD and cryptographic instructions.
20577 Speculation Barrier Instruction.
20580 Execution and Data Prediction Restriction Instructions.
20583 8-bit Integer Matrix Multiply instructions.
20584 This also enables Advanced SIMD and floating-point instructions.
20587 Brain half-precision floating-point instructions.
20588 This also enables Advanced SIMD and floating-point instructions.
20594 The half-precision floating-point data processing instructions.
20595 This also enables the Advanced SIMD and floating-point instructions as well
20596 as the Dot Product extension and the half-precision floating-point fmla
20600 The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
20601 Dot Product extension.
20604 The cryptographic instructions. This also enables the Advanced SIMD and
20605 floating-point instructions as well as the Dot Product extension.
20608 Disable the cryptographic extension.
20611 Disable the floating-point, Advanced SIMD and cryptographic instructions.
20614 8-bit Integer Matrix Multiply instructions.
20615 This also enables Advanced SIMD and floating-point instructions.
20618 Brain half-precision floating-point instructions.
20619 This also enables Advanced SIMD and floating-point instructions.
20625 The half-precision floating-point data processing instructions.
20626 This also enables the Advanced SIMD and floating-point instructions as well
20627 as the Dot Product extension and the half-precision floating-point fmla
20631 The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
20632 Dot Product extension.
20635 The cryptographic instructions. This also enables the Advanced SIMD and
20636 floating-point instructions as well as the Dot Product extension.
20639 Disable the cryptographic extension.
20642 Disable the floating-point, Advanced SIMD and cryptographic instructions.
20645 8-bit Integer Matrix Multiply instructions.
20646 This also enables Advanced SIMD and floating-point instructions.
20649 Brain half-precision floating-point instructions.
20650 This also enables Advanced SIMD and floating-point instructions.
20656 The single-precision VFPv3 floating-point instructions. The extension
20657 @samp{+vfpv3xd} can be used as an alias for this extension.
20660 The VFPv3 floating-point instructions with 16 double-precision registers.
20661 The extension +vfpv3-d16 can be used as an alias for this extension.
20663 @item +vfpv3xd-d16-fp16
20664 The single-precision VFPv3 floating-point instructions with 16 double-precision
20665 registers and the half-precision floating-point conversion operations.
20667 @item +vfpv3-d16-fp16
20668 The VFPv3 floating-point instructions with 16 double-precision
20669 registers and the half-precision floating-point conversion operations.
20672 Disable the floating-point extension.
20675 The ARM-state integer division instructions.
20678 Disable the ARM-state integer division extension.
20684 The single-precision VFPv4 floating-point instructions.
20687 The single-precision FPv5 floating-point instructions.
20690 The single- and double-precision FPv5 floating-point instructions.
20693 Disable the floating-point extensions.
20696 @item armv8.1-m.main
20700 The DSP instructions.
20703 The M-Profile Vector Extension (MVE) integer instructions.
20706 The M-Profile Vector Extension (MVE) integer and single precision
20707 floating-point instructions.
20710 The single-precision floating-point instructions.
20713 The single- and double-precision floating-point instructions.
20716 Disable the floating-point extension.
20718 @item +cdecp0, +cdecp1, ... , +cdecp7
20719 Enable the Custom Datapath Extension (CDE) on selected coprocessors according
20720 to the numbers given in the options in the range 0 to 7.
20726 The DSP instructions.
20729 Disable the DSP extension.
20732 The single-precision floating-point instructions.
20735 The single- and double-precision floating-point instructions.
20738 Disable the floating-point extension.
20740 @item +cdecp0, +cdecp1, ... , +cdecp7
20741 Enable the Custom Datapath Extension (CDE) on selected coprocessors according
20742 to the numbers given in the options in the range 0 to 7.
20748 The Cyclic Redundancy Check (CRC) instructions.
20750 The single-precision FPv5 floating-point instructions.
20752 The ARMv8-A Advanced SIMD and floating-point instructions.
20754 The cryptographic instructions.
20756 Disable the cryptographic instructions.
20758 Disable the floating-point, Advanced SIMD and cryptographic instructions.
20763 @option{-march=native} causes the compiler to auto-detect the architecture
20764 of the build computer. At present, this feature is only supported on
20765 GNU/Linux, and not all architectures are recognized. If the auto-detect
20766 is unsuccessful the option has no effect.
20768 @item -mtune=@var{name}
20770 This option specifies the name of the target ARM processor for
20771 which GCC should tune the performance of the code.
20772 For some ARM implementations better performance can be obtained by using
20774 Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
20775 @samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
20776 @samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
20777 @samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
20778 @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
20779 @samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
20780 @samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
20781 @samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
20782 @samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
20783 @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
20784 @samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
20785 @samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
20786 @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
20787 @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
20788 @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
20789 @samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
20790 @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
20791 @samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
20792 @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
20793 @samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-x1},
20794 @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
20795 @samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
20796 @samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
20797 @samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
20798 @samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{xgene1}.
20800 Additionally, this option can specify that GCC should tune the performance
20801 of the code for a big.LITTLE system. Permissible names are:
20802 @samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
20803 @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20804 @samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
20805 @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
20807 @option{-mtune=generic-@var{arch}} specifies that GCC should tune the
20808 performance for a blend of processors within architecture @var{arch}.
20809 The aim is to generate code that run well on the current most popular
20810 processors, balancing between optimizations that benefit some CPUs in the
20811 range, and avoiding performance pitfalls of other CPUs. The effects of
20812 this option may change in future GCC versions as CPU models come and go.
20814 @option{-mtune} permits the same extension options as @option{-mcpu}, but
20815 the extension options do not affect the tuning of the generated code.
20817 @option{-mtune=native} causes the compiler to auto-detect the CPU
20818 of the build computer. At present, this feature is only supported on
20819 GNU/Linux, and not all architectures are recognized. If the auto-detect is
20820 unsuccessful the option has no effect.
20822 @item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
20824 This specifies the name of the target ARM processor. GCC uses this name
20825 to derive the name of the target ARM architecture (as if specified
20826 by @option{-march}) and the ARM processor type for which to tune for
20827 performance (as if specified by @option{-mtune}). Where this option
20828 is used in conjunction with @option{-march} or @option{-mtune},
20829 those options take precedence over the appropriate part of this option.
20831 Many of the supported CPUs implement optional architectural
20832 extensions. Where this is so the architectural extensions are
20833 normally enabled by default. If implementations that lack the
20834 extension exist, then the extension syntax can be used to disable
20835 those extensions that have been omitted. For floating-point and
20836 Advanced SIMD (Neon) instructions, the settings of the options
20837 @option{-mfloat-abi} and @option{-mfpu} must also be considered:
20838 floating-point and Advanced SIMD instructions will only be used if
20839 @option{-mfloat-abi} is not set to @samp{soft}; and any setting of
20840 @option{-mfpu} other than @samp{auto} will override the available
20841 floating-point and SIMD extension instructions.
20843 For example, @samp{cortex-a9} can be found in three major
20844 configurations: integer only, with just a floating-point unit or with
20845 floating-point and Advanced SIMD. The default is to enable all the
20846 instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
20847 be used to disable just the SIMD or both the SIMD and floating-point
20848 instructions respectively.
20850 Permissible names for this option are the same as those for
20853 The following extension options are common to the listed CPUs:
20857 Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p}.
20860 Disables the floating-point instructions on @samp{arm9e},
20861 @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
20862 @samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
20863 @samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
20864 @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33} and @samp{cortex-m35p}.
20865 Disables the floating-point and SIMD instructions on
20866 @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
20867 @samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
20868 @samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
20869 @samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
20870 @samp{cortex-a53} and @samp{cortex-a55}.
20873 Disables the double-precision component of the floating-point instructions
20874 on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
20875 @samp{cortex-r52plus} and @samp{cortex-m7}.
20878 Disables the SIMD (but not floating-point) instructions on
20879 @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
20880 and @samp{cortex-a9}.
20883 Enables the cryptographic instructions on @samp{cortex-a32},
20884 @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
20885 @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
20886 @samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20887 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
20888 @samp{cortex-a75.cortex-a55}.
20891 Additionally the @samp{generic-armv7-a} pseudo target defaults to
20892 VFPv3 with 16 double-precision registers. It supports the following
20893 extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
20894 @samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
20895 @samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
20896 @samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
20897 the extensions to @option{-march=armv7-a}.
20899 @option{-mcpu=generic-@var{arch}} is also permissible, and is
20900 equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
20901 See @option{-mtune} for more information.
20903 @option{-mcpu=native} causes the compiler to auto-detect the CPU
20904 of the build computer. At present, this feature is only supported on
20905 GNU/Linux, and not all architectures are recognized. If the auto-detect
20906 is unsuccessful the option has no effect.
20908 @item -mfpu=@var{name}
20910 This specifies what floating-point hardware (or hardware emulation) is
20911 available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
20913 @samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
20914 @samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
20915 @samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
20916 @samp{fpv5-d16}, @samp{fpv5-sp-d16},
20917 @samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
20918 Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
20919 is an alias for @samp{vfpv2}.
20921 The setting @samp{auto} is the default and is special. It causes the
20922 compiler to select the floating-point and Advanced SIMD instructions
20923 based on the settings of @option{-mcpu} and @option{-march}.
20925 If the selected floating-point hardware includes the NEON extension
20926 (e.g.@: @option{-mfpu=neon}), note that floating-point
20927 operations are not generated by GCC's auto-vectorization pass unless
20928 @option{-funsafe-math-optimizations} is also specified. This is
20929 because NEON hardware does not fully implement the IEEE 754 standard for
20930 floating-point arithmetic (in particular denormal values are treated as
20931 zero), so the use of NEON instructions may lead to a loss of precision.
20933 You can also set the fpu name at function level by using the @code{target("fpu=")} function attributes (@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
20935 @item -mfp16-format=@var{name}
20936 @opindex mfp16-format
20937 Specify the format of the @code{__fp16} half-precision floating-point type.
20938 Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
20939 the default is @samp{none}, in which case the @code{__fp16} type is not
20940 defined. @xref{Half-Precision}, for more information.
20942 @item -mstructure-size-boundary=@var{n}
20943 @opindex mstructure-size-boundary
20944 The sizes of all structures and unions are rounded up to a multiple
20945 of the number of bits set by this option. Permissible values are 8, 32
20946 and 64. The default value varies for different toolchains. For the COFF
20947 targeted toolchain the default value is 8. A value of 64 is only allowed
20948 if the underlying ABI supports it.
20950 Specifying a larger number can produce faster, more efficient code, but
20951 can also increase the size of the program. Different values are potentially
20952 incompatible. Code compiled with one value cannot necessarily expect to
20953 work with code or libraries compiled with another value, if they exchange
20954 information using structures or unions.
20956 This option is deprecated.
20958 @item -mabort-on-noreturn
20959 @opindex mabort-on-noreturn
20960 Generate a call to the function @code{abort} at the end of a
20961 @code{noreturn} function. It is executed if the function tries to
20965 @itemx -mno-long-calls
20966 @opindex mlong-calls
20967 @opindex mno-long-calls
20968 Tells the compiler to perform function calls by first loading the
20969 address of the function into a register and then performing a subroutine
20970 call on this register. This switch is needed if the target function
20971 lies outside of the 64-megabyte addressing range of the offset-based
20972 version of subroutine call instruction.
20974 Even if this switch is enabled, not all function calls are turned
20975 into long calls. The heuristic is that static functions, functions
20976 that have the @code{short_call} attribute, functions that are inside
20977 the scope of a @code{#pragma no_long_calls} directive, and functions whose
20978 definitions have already been compiled within the current compilation
20979 unit are not turned into long calls. The exceptions to this rule are
20980 that weak function definitions, functions with the @code{long_call}
20981 attribute or the @code{section} attribute, and functions that are within
20982 the scope of a @code{#pragma long_calls} directive are always
20983 turned into long calls.
20985 This feature is not enabled by default. Specifying
20986 @option{-mno-long-calls} restores the default behavior, as does
20987 placing the function calls within the scope of a @code{#pragma
20988 long_calls_off} directive. Note these switches have no effect on how
20989 the compiler generates code to handle function calls via function
20992 @item -msingle-pic-base
20993 @opindex msingle-pic-base
20994 Treat the register used for PIC addressing as read-only, rather than
20995 loading it in the prologue for each function. The runtime system is
20996 responsible for initializing this register with an appropriate value
20997 before execution begins.
20999 @item -mpic-register=@var{reg}
21000 @opindex mpic-register
21001 Specify the register to be used for PIC addressing.
21002 For standard PIC base case, the default is any suitable register
21003 determined by compiler. For single PIC base case, the default is
21004 @samp{R9} if target is EABI based or stack-checking is enabled,
21005 otherwise the default is @samp{R10}.
21007 @item -mpic-data-is-text-relative
21008 @opindex mpic-data-is-text-relative
21009 Assume that the displacement between the text and data segments is fixed
21010 at static link time. This permits using PC-relative addressing
21011 operations to access data known to be in the data segment. For
21012 non-VxWorks RTP targets, this option is enabled by default. When
21013 disabled on such targets, it will enable @option{-msingle-pic-base} by
21016 @item -mpoke-function-name
21017 @opindex mpoke-function-name
21018 Write the name of each function into the text section, directly
21019 preceding the function prologue. The generated code is similar to this:
21023 .ascii "arm_poke_function_name", 0
21026 .word 0xff000000 + (t1 - t0)
21027 arm_poke_function_name
21029 stmfd sp!, @{fp, ip, lr, pc@}
21033 When performing a stack backtrace, code can inspect the value of
21034 @code{pc} stored at @code{fp + 0}. If the trace function then looks at
21035 location @code{pc - 12} and the top 8 bits are set, then we know that
21036 there is a function name embedded immediately preceding this location
21037 and has length @code{((pc[-3]) & 0xff000000)}.
21044 Select between generating code that executes in ARM and Thumb
21045 states. The default for most configurations is to generate code
21046 that executes in ARM state, but the default can be changed by
21047 configuring GCC with the @option{--with-mode=}@var{state}
21050 You can also override the ARM and Thumb mode for each function
21051 by using the @code{target("thumb")} and @code{target("arm")} function attributes
21052 (@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
21055 @opindex mflip-thumb
21056 Switch ARM/Thumb modes on alternating functions.
21057 This option is provided for regression testing of mixed Thumb/ARM code
21058 generation, and is not intended for ordinary use in compiling code.
21061 @opindex mtpcs-frame
21062 Generate a stack frame that is compliant with the Thumb Procedure Call
21063 Standard for all non-leaf functions. (A leaf function is one that does
21064 not call any other functions.) The default is @option{-mno-tpcs-frame}.
21066 @item -mtpcs-leaf-frame
21067 @opindex mtpcs-leaf-frame
21068 Generate a stack frame that is compliant with the Thumb Procedure Call
21069 Standard for all leaf functions. (A leaf function is one that does
21070 not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
21072 @item -mcallee-super-interworking
21073 @opindex mcallee-super-interworking
21074 Gives all externally visible functions in the file being compiled an ARM
21075 instruction set header which switches to Thumb mode before executing the
21076 rest of the function. This allows these functions to be called from
21077 non-interworking code. This option is not valid in AAPCS configurations
21078 because interworking is enabled by default.
21080 @item -mcaller-super-interworking
21081 @opindex mcaller-super-interworking
21082 Allows calls via function pointers (including virtual functions) to
21083 execute correctly regardless of whether the target code has been
21084 compiled for interworking or not. There is a small overhead in the cost
21085 of executing a function pointer if this option is enabled. This option
21086 is not valid in AAPCS configurations because interworking is enabled
21089 @item -mtp=@var{name}
21091 Specify the access model for the thread local storage pointer. The valid
21092 models are @samp{soft}, which generates calls to @code{__aeabi_read_tp},
21093 @samp{cp15}, which fetches the thread pointer from @code{cp15} directly
21094 (supported in the arm6k architecture), and @samp{auto}, which uses the
21095 best available method for the selected processor. The default setting is
21098 @item -mtls-dialect=@var{dialect}
21099 @opindex mtls-dialect
21100 Specify the dialect to use for accessing thread local storage. Two
21101 @var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
21102 @samp{gnu} dialect selects the original GNU scheme for supporting
21103 local and global dynamic TLS models. The @samp{gnu2} dialect
21104 selects the GNU descriptor scheme, which provides better performance
21105 for shared libraries. The GNU descriptor scheme is compatible with
21106 the original scheme, but does require new assembler, linker and
21107 library support. Initial and local exec TLS models are unaffected by
21108 this option and always use the original scheme.
21110 @item -mword-relocations
21111 @opindex mword-relocations
21112 Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
21113 This is enabled by default on targets (uClinux, SymbianOS) where the runtime
21114 loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
21115 is specified. This option conflicts with @option{-mslow-flash-data}.
21117 @item -mfix-cortex-m3-ldrd
21118 @opindex mfix-cortex-m3-ldrd
21119 Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
21120 with overlapping destination and base registers are used. This option avoids
21121 generating these instructions. This option is enabled by default when
21122 @option{-mcpu=cortex-m3} is specified.
21124 @item -munaligned-access
21125 @itemx -mno-unaligned-access
21126 @opindex munaligned-access
21127 @opindex mno-unaligned-access
21128 Enables (or disables) reading and writing of 16- and 32- bit values
21129 from addresses that are not 16- or 32- bit aligned. By default
21130 unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
21131 ARMv8-M Baseline architectures, and enabled for all other
21132 architectures. If unaligned access is not enabled then words in packed
21133 data structures are accessed a byte at a time.
21135 The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
21136 generated object file to either true or false, depending upon the
21137 setting of this option. If unaligned access is enabled then the
21138 preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
21141 @item -mneon-for-64bits
21142 @opindex mneon-for-64bits
21143 This option is deprecated and has no effect.
21145 @item -mslow-flash-data
21146 @opindex mslow-flash-data
21147 Assume loading data from flash is slower than fetching instruction.
21148 Therefore literal load is minimized for better performance.
21149 This option is only supported when compiling for ARMv7 M-profile and
21150 off by default. It conflicts with @option{-mword-relocations}.
21152 @item -masm-syntax-unified
21153 @opindex masm-syntax-unified
21154 Assume inline assembler is using unified asm syntax. The default is
21155 currently off which implies divided syntax. This option has no impact
21156 on Thumb2. However, this may change in future releases of GCC.
21157 Divided syntax should be considered deprecated.
21159 @item -mrestrict-it
21160 @opindex mrestrict-it
21161 Restricts generation of IT blocks to conform to the rules of ARMv8-A.
21162 IT blocks can only contain a single 16-bit instruction from a select
21163 set of instructions. This option is on by default for ARMv8-A Thumb mode.
21165 @item -mprint-tune-info
21166 @opindex mprint-tune-info
21167 Print CPU tuning information as comment in assembler file. This is
21168 an option used only for regression testing of the compiler and not
21169 intended for ordinary use in compiling code. This option is disabled
21172 @item -mverbose-cost-dump
21173 @opindex mverbose-cost-dump
21174 Enable verbose cost model dumping in the debug dump files. This option is
21175 provided for use in debugging the compiler.
21178 @opindex mpure-code
21179 Do not allow constant data to be placed in code sections.
21180 Additionally, when compiling for ELF object format give all text sections the
21181 ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
21182 is only available when generating non-pic code for M-profile targets.
21186 Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
21187 Development Tools Engineering Specification", which can be found on
21188 @url{https://developer.arm.com/documentation/ecm0359818/latest/}.
21190 @item -mfix-cmse-cve-2021-35465
21191 @opindex mfix-cmse-cve-2021-35465
21192 Mitigate against a potential security issue with the @code{VLLDM} instruction
21193 in some M-profile devices when using CMSE (CVE-2021-365465). This option is
21194 enabled by default when the option @option{-mcpu=} is used with
21195 @code{cortex-m33}, @code{cortex-m35p} or @code{cortex-m55}. The option
21196 @option{-mno-fix-cmse-cve-2021-35465} can be used to disable the mitigation.
21202 Select the FDPIC ABI, which uses 64-bit function descriptors to
21203 represent pointers to functions. When the compiler is configured for
21204 @code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
21205 and implies @option{-fPIE} if none of the PIC/PIE-related options is
21206 provided. On other targets, it only enables the FDPIC-specific code
21207 generation features, and the user should explicitly provide the
21208 PIC/PIE-related options as needed.
21210 Note that static linking is not supported because it would still
21211 involve the dynamic linker when the program self-relocates. If such
21212 behavior is acceptable, use -static and -Wl,-dynamic-linker options.
21214 The opposite @option{-mno-fdpic} option is useful (and required) to
21215 build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
21216 toolchain as the one used to build the userland programs.
21221 @subsection AVR Options
21222 @cindex AVR Options
21224 These options are defined for AVR implementations:
21227 @item -mmcu=@var{mcu}
21229 Specify Atmel AVR instruction set architectures (ISA) or MCU type.
21231 The default for this option is@tie{}@samp{avr2}.
21233 GCC supports the following AVR devices and ISAs:
21235 @include avr-mmcu.texi
21240 Assume that all data in static storage can be accessed by LDS / STS
21241 instructions. This option has only an effect on reduced Tiny devices like
21242 ATtiny40. See also the @code{absdata}
21243 @ref{AVR Variable Attributes,variable attribute}.
21245 @item -maccumulate-args
21246 @opindex maccumulate-args
21247 Accumulate outgoing function arguments and acquire/release the needed
21248 stack space for outgoing function arguments once in function
21249 prologue/epilogue. Without this option, outgoing arguments are pushed
21250 before calling a function and popped afterwards.
21252 Popping the arguments after the function call can be expensive on
21253 AVR so that accumulating the stack space might lead to smaller
21254 executables because arguments need not be removed from the
21255 stack after such a function call.
21257 This option can lead to reduced code size for functions that perform
21258 several calls to functions that get their arguments on the stack like
21259 calls to printf-like functions.
21261 @item -mbranch-cost=@var{cost}
21262 @opindex mbranch-cost
21263 Set the branch costs for conditional branch instructions to
21264 @var{cost}. Reasonable values for @var{cost} are small, non-negative
21265 integers. The default branch cost is 0.
21267 @item -mcall-prologues
21268 @opindex mcall-prologues
21269 Functions prologues/epilogues are expanded as calls to appropriate
21270 subroutines. Code size is smaller.
21272 @item -mdouble=@var{bits}
21273 @itemx -mlong-double=@var{bits}
21275 @opindex mlong-double
21276 Set the size (in bits) of the @code{double} or @code{long double} type,
21277 respectively. Possible values for @var{bits} are 32 and 64.
21278 Whether or not a specific value for @var{bits} is allowed depends on
21279 the @code{--with-double=} and @code{--with-long-double=}
21280 @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
21281 and the same applies for the default values of the options.
21283 @item -mgas-isr-prologues
21284 @opindex mgas-isr-prologues
21285 Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
21286 instruction supported by GNU Binutils.
21287 If this option is on, the feature can still be disabled for individual
21288 ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
21289 function attribute. This feature is activated per default
21290 if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
21291 and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
21295 Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
21296 @code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
21297 and @code{long long} is 4 bytes. Please note that this option does not
21298 conform to the C standards, but it results in smaller code
21301 @item -mmain-is-OS_task
21302 @opindex mmain-is-OS_task
21303 Do not save registers in @code{main}. The effect is the same like
21304 attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
21305 to @code{main}. It is activated per default if optimization is on.
21307 @item -mn-flash=@var{num}
21309 Assume that the flash memory has a size of
21310 @var{num} times 64@tie{}KiB.
21312 @item -mno-interrupts
21313 @opindex mno-interrupts
21314 Generated code is not compatible with hardware interrupts.
21315 Code size is smaller.
21319 Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
21320 @code{RCALL} resp.@: @code{RJMP} instruction if applicable.
21321 Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
21322 the assembler's command line and the @option{--relax} option to the
21323 linker's command line.
21325 Jump relaxing is performed by the linker because jump offsets are not
21326 known before code is located. Therefore, the assembler code generated by the
21327 compiler is the same, but the instructions in the executable may
21328 differ from instructions in the assembler code.
21330 Relaxing must be turned on if linker stubs are needed, see the
21331 section on @code{EIND} and linker stubs below.
21335 Assume that the device supports the Read-Modify-Write
21336 instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
21338 @item -mshort-calls
21339 @opindex mshort-calls
21341 Assume that @code{RJMP} and @code{RCALL} can target the whole
21344 This option is used internally for multilib selection. It is
21345 not an optimization option, and you don't need to set it by hand.
21349 Treat the stack pointer register as an 8-bit register,
21350 i.e.@: assume the high byte of the stack pointer is zero.
21351 In general, you don't need to set this option by hand.
21353 This option is used internally by the compiler to select and
21354 build multilibs for architectures @code{avr2} and @code{avr25}.
21355 These architectures mix devices with and without @code{SPH}.
21356 For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25}
21357 the compiler driver adds or removes this option from the compiler
21358 proper's command line, because the compiler then knows if the device
21359 or architecture has an 8-bit stack pointer and thus no @code{SPH}
21364 Use address register @code{X} in a way proposed by the hardware. This means
21365 that @code{X} is only used in indirect, post-increment or
21366 pre-decrement addressing.
21368 Without this option, the @code{X} register may be used in the same way
21369 as @code{Y} or @code{Z} which then is emulated by additional
21371 For example, loading a value with @code{X+const} addressing with a
21372 small non-negative @code{const < 64} to a register @var{Rn} is
21376 adiw r26, const ; X += const
21377 ld @var{Rn}, X ; @var{Rn} = *X
21378 sbiw r26, const ; X -= const
21382 @opindex mtiny-stack
21383 Only change the lower 8@tie{}bits of the stack pointer.
21385 @item -mfract-convert-truncate
21386 @opindex mfract-convert-truncate
21387 Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
21390 @opindex nodevicelib
21391 Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}.
21393 @item -nodevicespecs
21394 @opindex nodevicespecs
21395 Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
21396 command line. The user takes responsibility for supplying the sub-processes
21397 like compiler proper, assembler and linker with appropriate command line
21398 options. This means that the user has to supply her private device specs
21399 file by means of @option{-specs=@var{path-to-specs-file}}. There is no
21400 more need for option @option{-mmcu=@var{mcu}}.
21402 This option can also serve as a replacement for the older way of
21403 specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
21404 which contains a folder named @code{device-specs} which contains a specs file named
21405 @code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
21407 @item -Waddr-space-convert
21408 @opindex Waddr-space-convert
21409 @opindex Wno-addr-space-convert
21410 Warn about conversions between address spaces in the case where the
21411 resulting address space is not contained in the incoming address space.
21413 @item -Wmisspelled-isr
21414 @opindex Wmisspelled-isr
21415 @opindex Wno-misspelled-isr
21416 Warn if the ISR is misspelled, i.e.@: without __vector prefix.
21417 Enabled by default.
21420 @subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
21421 @cindex @code{EIND}
21422 Pointers in the implementation are 16@tie{}bits wide.
21423 The address of a function or label is represented as word address so
21424 that indirect jumps and calls can target any code address in the
21425 range of 64@tie{}Ki words.
21427 In order to facilitate indirect jump on devices with more than 128@tie{}Ki
21428 bytes of program memory space, there is a special function register called
21429 @code{EIND} that serves as most significant part of the target address
21430 when @code{EICALL} or @code{EIJMP} instructions are used.
21432 Indirect jumps and calls on these devices are handled as follows by
21433 the compiler and are subject to some limitations:
21438 The compiler never sets @code{EIND}.
21441 The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
21442 instructions or might read @code{EIND} directly in order to emulate an
21443 indirect call/jump by means of a @code{RET} instruction.
21446 The compiler assumes that @code{EIND} never changes during the startup
21447 code or during the application. In particular, @code{EIND} is not
21448 saved/restored in function or interrupt service routine
21452 For indirect calls to functions and computed goto, the linker
21453 generates @emph{stubs}. Stubs are jump pads sometimes also called
21454 @emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
21455 The stub contains a direct jump to the desired address.
21458 Linker relaxation must be turned on so that the linker generates
21459 the stubs correctly in all situations. See the compiler option
21460 @option{-mrelax} and the linker option @option{--relax}.
21461 There are corner cases where the linker is supposed to generate stubs
21462 but aborts without relaxation and without a helpful error message.
21465 The default linker script is arranged for code with @code{EIND = 0}.
21466 If code is supposed to work for a setup with @code{EIND != 0}, a custom
21467 linker script has to be used in order to place the sections whose
21468 name start with @code{.trampolines} into the segment where @code{EIND}
21472 The startup code from libgcc never sets @code{EIND}.
21473 Notice that startup code is a blend of code from libgcc and AVR-LibC.
21474 For the impact of AVR-LibC on @code{EIND}, see the
21475 @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}.
21478 It is legitimate for user-specific startup code to set up @code{EIND}
21479 early, for example by means of initialization code located in
21480 section @code{.init3}. Such code runs prior to general startup code
21481 that initializes RAM and calls constructors, but after the bit
21482 of startup code from AVR-LibC that sets @code{EIND} to the segment
21483 where the vector table is located.
21485 #include <avr/io.h>
21488 __attribute__((section(".init3"),naked,used,no_instrument_function))
21489 init3_set_eind (void)
21491 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
21492 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
21497 The @code{__trampolines_start} symbol is defined in the linker script.
21500 Stubs are generated automatically by the linker if
21501 the following two conditions are met:
21504 @item The address of a label is taken by means of the @code{gs} modifier
21505 (short for @emph{generate stubs}) like so:
21507 LDI r24, lo8(gs(@var{func}))
21508 LDI r25, hi8(gs(@var{func}))
21510 @item The final location of that label is in a code segment
21511 @emph{outside} the segment where the stubs are located.
21515 The compiler emits such @code{gs} modifiers for code labels in the
21516 following situations:
21518 @item Taking address of a function or code label.
21519 @item Computed goto.
21520 @item If prologue-save function is used, see @option{-mcall-prologues}
21521 command-line option.
21522 @item Switch/case dispatch tables. If you do not want such dispatch
21523 tables you can specify the @option{-fno-jump-tables} command-line option.
21524 @item C and C++ constructors/destructors called during startup/shutdown.
21525 @item If the tools hit a @code{gs()} modifier explained above.
21529 Jumping to non-symbolic addresses like so is @emph{not} supported:
21534 /* Call function at word address 0x2 */
21535 return ((int(*)(void)) 0x2)();
21539 Instead, a stub has to be set up, i.e.@: the function has to be called
21540 through a symbol (@code{func_4} in the example):
21545 extern int func_4 (void);
21547 /* Call function at byte address 0x4 */
21552 and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
21553 Alternatively, @code{func_4} can be defined in the linker script.
21556 @subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
21557 @cindex @code{RAMPD}
21558 @cindex @code{RAMPX}
21559 @cindex @code{RAMPY}
21560 @cindex @code{RAMPZ}
21561 Some AVR devices support memories larger than the 64@tie{}KiB range
21562 that can be accessed with 16-bit pointers. To access memory locations
21563 outside this 64@tie{}KiB range, the content of a @code{RAMP}
21564 register is used as high part of the address:
21565 The @code{X}, @code{Y}, @code{Z} address register is concatenated
21566 with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
21567 register, respectively, to get a wide address. Similarly,
21568 @code{RAMPD} is used together with direct addressing.
21572 The startup code initializes the @code{RAMP} special function
21573 registers with zero.
21576 If a @ref{AVR Named Address Spaces,named address space} other than
21577 generic or @code{__flash} is used, then @code{RAMPZ} is set
21578 as needed before the operation.
21581 If the device supports RAM larger than 64@tie{}KiB and the compiler
21582 needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
21583 is reset to zero after the operation.
21586 If the device comes with a specific @code{RAMP} register, the ISR
21587 prologue/epilogue saves/restores that SFR and initializes it with
21588 zero in case the ISR code might (implicitly) use it.
21591 RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
21592 If you use inline assembler to read from locations outside the
21593 16-bit address range and change one of the @code{RAMP} registers,
21594 you must reset it to zero after the access.
21598 @subsubsection AVR Built-in Macros
21600 GCC defines several built-in macros so that the user code can test
21601 for the presence or absence of features. Almost any of the following
21602 built-in macros are deduced from device capabilities and thus
21603 triggered by the @option{-mmcu=} command-line option.
21605 For even more AVR-specific built-in macros see
21606 @ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
21611 Build-in macro that resolves to a decimal number that identifies the
21612 architecture and depends on the @option{-mmcu=@var{mcu}} option.
21613 Possible values are:
21615 @code{2}, @code{25}, @code{3}, @code{31}, @code{35},
21616 @code{4}, @code{5}, @code{51}, @code{6}
21618 for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
21619 @code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
21624 @code{102}, @code{103}, @code{104},
21625 @code{105}, @code{106}, @code{107}
21627 for @var{mcu}=@code{avrtiny},
21628 @code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
21629 @code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
21630 If @var{mcu} specifies a device, this built-in macro is set
21631 accordingly. For example, with @option{-mmcu=atmega8} the macro is
21632 defined to @code{4}.
21634 @item __AVR_@var{Device}__
21635 Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
21636 the device's name. For example, @option{-mmcu=atmega8} defines the
21637 built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
21638 @code{__AVR_ATtiny261A__}, etc.
21640 The built-in macros' names follow
21641 the scheme @code{__AVR_@var{Device}__} where @var{Device} is
21642 the device name as from the AVR user manual. The difference between
21643 @var{Device} in the built-in macro and @var{device} in
21644 @option{-mmcu=@var{device}} is that the latter is always lowercase.
21646 If @var{device} is not a device but only a core architecture like
21647 @samp{avr51}, this macro is not defined.
21649 @item __AVR_DEVICE_NAME__
21650 Setting @option{-mmcu=@var{device}} defines this built-in macro to
21651 the device's name. For example, with @option{-mmcu=atmega8} the macro
21652 is defined to @code{atmega8}.
21654 If @var{device} is not a device but only a core architecture like
21655 @samp{avr51}, this macro is not defined.
21657 @item __AVR_XMEGA__
21658 The device / architecture belongs to the XMEGA family of devices.
21660 @item __AVR_HAVE_ELPM__
21661 The device has the @code{ELPM} instruction.
21663 @item __AVR_HAVE_ELPMX__
21664 The device has the @code{ELPM R@var{n},Z} and @code{ELPM
21665 R@var{n},Z+} instructions.
21667 @item __AVR_HAVE_MOVW__
21668 The device has the @code{MOVW} instruction to perform 16-bit
21669 register-register moves.
21671 @item __AVR_HAVE_LPMX__
21672 The device has the @code{LPM R@var{n},Z} and
21673 @code{LPM R@var{n},Z+} instructions.
21675 @item __AVR_HAVE_MUL__
21676 The device has a hardware multiplier.
21678 @item __AVR_HAVE_JMP_CALL__
21679 The device has the @code{JMP} and @code{CALL} instructions.
21680 This is the case for devices with more than 8@tie{}KiB of program
21683 @item __AVR_HAVE_EIJMP_EICALL__
21684 @itemx __AVR_3_BYTE_PC__
21685 The device has the @code{EIJMP} and @code{EICALL} instructions.
21686 This is the case for devices with more than 128@tie{}KiB of program memory.
21687 This also means that the program counter
21688 (PC) is 3@tie{}bytes wide.
21690 @item __AVR_2_BYTE_PC__
21691 The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
21692 with up to 128@tie{}KiB of program memory.
21694 @item __AVR_HAVE_8BIT_SP__
21695 @itemx __AVR_HAVE_16BIT_SP__
21696 The stack pointer (SP) register is treated as 8-bit respectively
21697 16-bit register by the compiler.
21698 The definition of these macros is affected by @option{-mtiny-stack}.
21700 @item __AVR_HAVE_SPH__
21702 The device has the SPH (high part of stack pointer) special function
21703 register or has an 8-bit stack pointer, respectively.
21704 The definition of these macros is affected by @option{-mmcu=} and
21705 in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
21708 @item __AVR_HAVE_RAMPD__
21709 @itemx __AVR_HAVE_RAMPX__
21710 @itemx __AVR_HAVE_RAMPY__
21711 @itemx __AVR_HAVE_RAMPZ__
21712 The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
21713 @code{RAMPZ} special function register, respectively.
21715 @item __NO_INTERRUPTS__
21716 This macro reflects the @option{-mno-interrupts} command-line option.
21718 @item __AVR_ERRATA_SKIP__
21719 @itemx __AVR_ERRATA_SKIP_JMP_CALL__
21720 Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
21721 instructions because of a hardware erratum. Skip instructions are
21722 @code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
21723 The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
21726 @item __AVR_ISA_RMW__
21727 The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
21729 @item __AVR_SFR_OFFSET__=@var{offset}
21730 Instructions that can address I/O special function registers directly
21731 like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
21732 address as if addressed by an instruction to access RAM like @code{LD}
21733 or @code{STS}. This offset depends on the device architecture and has
21734 to be subtracted from the RAM address in order to get the
21735 respective I/O@tie{}address.
21737 @item __AVR_SHORT_CALLS__
21738 The @option{-mshort-calls} command line option is set.
21740 @item __AVR_PM_BASE_ADDRESS__=@var{addr}
21741 Some devices support reading from flash memory by means of @code{LD*}
21742 instructions. The flash memory is seen in the data address space
21743 at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
21744 is not defined, this feature is not available. If defined,
21745 the address space is linear and there is no need to put
21746 @code{.rodata} into RAM. This is handled by the default linker
21747 description file, and is currently available for
21748 @code{avrtiny} and @code{avrxmega3}. Even more convenient,
21749 there is no need to use address spaces like @code{__flash} or
21750 features like attribute @code{progmem} and @code{pgm_read_*}.
21752 @item __WITH_AVRLIBC__
21753 The compiler is configured to be used together with AVR-Libc.
21754 See the @option{--with-avrlibc} configure option.
21756 @item __HAVE_DOUBLE_MULTILIB__
21757 Defined if @option{-mdouble=} acts as a multilib option.
21759 @item __HAVE_DOUBLE32__
21760 @itemx __HAVE_DOUBLE64__
21761 Defined if the compiler supports 32-bit double resp. 64-bit double.
21762 The actual layout is specified by option @option{-mdouble=}.
21764 @item __DEFAULT_DOUBLE__
21765 The size in bits of @code{double} if @option{-mdouble=} is not set.
21766 To test the layout of @code{double} in a program, use the built-in
21767 macro @code{__SIZEOF_DOUBLE__}.
21769 @item __HAVE_LONG_DOUBLE32__
21770 @itemx __HAVE_LONG_DOUBLE64__
21771 @itemx __HAVE_LONG_DOUBLE_MULTILIB__
21772 @itemx __DEFAULT_LONG_DOUBLE__
21773 Same as above, but for @code{long double} instead of @code{double}.
21775 @item __WITH_DOUBLE_COMPARISON__
21776 Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
21777 @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
21778 and is defined to @code{2} or @code{3}.
21780 @item __WITH_LIBF7_LIBGCC__
21781 @itemx __WITH_LIBF7_MATH__
21782 @itemx __WITH_LIBF7_MATH_SYMBOLS__
21783 Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
21784 @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
21788 @node Blackfin Options
21789 @subsection Blackfin Options
21790 @cindex Blackfin Options
21793 @item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
21795 Specifies the name of the target Blackfin processor. Currently, @var{cpu}
21796 can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
21797 @samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
21798 @samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
21799 @samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
21800 @samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
21801 @samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
21802 @samp{bf561}, @samp{bf592}.
21804 The optional @var{sirevision} specifies the silicon revision of the target
21805 Blackfin processor. Any workarounds available for the targeted silicon revision
21806 are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
21807 If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
21808 are enabled. The @code{__SILICON_REVISION__} macro is defined to two
21809 hexadecimal digits representing the major and minor numbers in the silicon
21810 revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
21811 is not defined. If @var{sirevision} is @samp{any}, the
21812 @code{__SILICON_REVISION__} is defined to be @code{0xffff}.
21813 If this optional @var{sirevision} is not used, GCC assumes the latest known
21814 silicon revision of the targeted Blackfin processor.
21816 GCC defines a preprocessor macro for the specified @var{cpu}.
21817 For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
21818 provided by libgloss to be linked in if @option{-msim} is not given.
21820 Without this option, @samp{bf532} is used as the processor by default.
21822 Note that support for @samp{bf561} is incomplete. For @samp{bf561},
21823 only the preprocessor macro is defined.
21827 Specifies that the program will be run on the simulator. This causes
21828 the simulator BSP provided by libgloss to be linked in. This option
21829 has effect only for @samp{bfin-elf} toolchain.
21830 Certain other options, such as @option{-mid-shared-library} and
21831 @option{-mfdpic}, imply @option{-msim}.
21833 @item -momit-leaf-frame-pointer
21834 @opindex momit-leaf-frame-pointer
21835 Don't keep the frame pointer in a register for leaf functions. This
21836 avoids the instructions to save, set up and restore frame pointers and
21837 makes an extra register available in leaf functions.
21839 @item -mspecld-anomaly
21840 @opindex mspecld-anomaly
21841 When enabled, the compiler ensures that the generated code does not
21842 contain speculative loads after jump instructions. If this option is used,
21843 @code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
21845 @item -mno-specld-anomaly
21846 @opindex mno-specld-anomaly
21847 @opindex mspecld-anomaly
21848 Don't generate extra code to prevent speculative loads from occurring.
21850 @item -mcsync-anomaly
21851 @opindex mcsync-anomaly
21852 When enabled, the compiler ensures that the generated code does not
21853 contain CSYNC or SSYNC instructions too soon after conditional branches.
21854 If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
21856 @item -mno-csync-anomaly
21857 @opindex mno-csync-anomaly
21858 @opindex mcsync-anomaly
21859 Don't generate extra code to prevent CSYNC or SSYNC instructions from
21860 occurring too soon after a conditional branch.
21864 When enabled, the compiler is free to take advantage of the knowledge that
21865 the entire program fits into the low 64k of memory.
21868 @opindex mno-low64k
21869 Assume that the program is arbitrarily large. This is the default.
21871 @item -mstack-check-l1
21872 @opindex mstack-check-l1
21873 Do stack checking using information placed into L1 scratchpad memory by the
21876 @item -mid-shared-library
21877 @opindex mid-shared-library
21878 Generate code that supports shared libraries via the library ID method.
21879 This allows for execute in place and shared libraries in an environment
21880 without virtual memory management. This option implies @option{-fPIC}.
21881 With a @samp{bfin-elf} target, this option implies @option{-msim}.
21883 @item -mno-id-shared-library
21884 @opindex mno-id-shared-library
21885 @opindex mid-shared-library
21886 Generate code that doesn't assume ID-based shared libraries are being used.
21887 This is the default.
21889 @item -mleaf-id-shared-library
21890 @opindex mleaf-id-shared-library
21891 Generate code that supports shared libraries via the library ID method,
21892 but assumes that this library or executable won't link against any other
21893 ID shared libraries. That allows the compiler to use faster code for jumps
21896 @item -mno-leaf-id-shared-library
21897 @opindex mno-leaf-id-shared-library
21898 @opindex mleaf-id-shared-library
21899 Do not assume that the code being compiled won't link against any ID shared
21900 libraries. Slower code is generated for jump and call insns.
21902 @item -mshared-library-id=n
21903 @opindex mshared-library-id
21904 Specifies the identification number of the ID-based shared library being
21905 compiled. Specifying a value of 0 generates more compact code; specifying
21906 other values forces the allocation of that number to the current
21907 library but is no more space- or time-efficient than omitting this option.
21911 Generate code that allows the data segment to be located in a different
21912 area of memory from the text segment. This allows for execute in place in
21913 an environment without virtual memory management by eliminating relocations
21914 against the text section.
21916 @item -mno-sep-data
21917 @opindex mno-sep-data
21919 Generate code that assumes that the data segment follows the text segment.
21920 This is the default.
21923 @itemx -mno-long-calls
21924 @opindex mlong-calls
21925 @opindex mno-long-calls
21926 Tells the compiler to perform function calls by first loading the
21927 address of the function into a register and then performing a subroutine
21928 call on this register. This switch is needed if the target function
21929 lies outside of the 24-bit addressing range of the offset-based
21930 version of subroutine call instruction.
21932 This feature is not enabled by default. Specifying
21933 @option{-mno-long-calls} restores the default behavior. Note these
21934 switches have no effect on how the compiler generates code to handle
21935 function calls via function pointers.
21939 Link with the fast floating-point library. This library relaxes some of
21940 the IEEE floating-point standard's rules for checking inputs against
21941 Not-a-Number (NAN), in the interest of performance.
21944 @opindex minline-plt
21945 Enable inlining of PLT entries in function calls to functions that are
21946 not known to bind locally. It has no effect without @option{-mfdpic}.
21949 @opindex mmulticore
21950 Build a standalone application for multicore Blackfin processors.
21951 This option causes proper start files and link scripts supporting
21952 multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
21953 It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
21955 This option can be used with @option{-mcorea} or @option{-mcoreb}, which
21956 selects the one-application-per-core programming model. Without
21957 @option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
21958 programming model is used. In this model, the main function of Core B
21959 should be named as @code{coreb_main}.
21961 If this option is not used, the single-core application programming
21966 Build a standalone application for Core A of BF561 when using
21967 the one-application-per-core programming model. Proper start files
21968 and link scripts are used to support Core A, and the macro
21969 @code{__BFIN_COREA} is defined.
21970 This option can only be used in conjunction with @option{-mmulticore}.
21974 Build a standalone application for Core B of BF561 when using
21975 the one-application-per-core programming model. Proper start files
21976 and link scripts are used to support Core B, and the macro
21977 @code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
21978 should be used instead of @code{main}.
21979 This option can only be used in conjunction with @option{-mmulticore}.
21983 Build a standalone application for SDRAM. Proper start files and
21984 link scripts are used to put the application into SDRAM, and the macro
21985 @code{__BFIN_SDRAM} is defined.
21986 The loader should initialize SDRAM before loading the application.
21990 Assume that ICPLBs are enabled at run time. This has an effect on certain
21991 anomaly workarounds. For Linux targets, the default is to assume ICPLBs
21992 are enabled; for standalone applications the default is off.
21996 @subsection C6X Options
21997 @cindex C6X Options
22000 @item -march=@var{name}
22002 This specifies the name of the target architecture. GCC uses this
22003 name to determine what kind of instructions it can emit when generating
22004 assembly code. Permissible names are: @samp{c62x},
22005 @samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
22008 @opindex mbig-endian
22009 Generate code for a big-endian target.
22011 @item -mlittle-endian
22012 @opindex mlittle-endian
22013 Generate code for a little-endian target. This is the default.
22017 Choose startup files and linker script suitable for the simulator.
22019 @item -msdata=default
22020 @opindex msdata=default
22021 Put small global and static data in the @code{.neardata} section,
22022 which is pointed to by register @code{B14}. Put small uninitialized
22023 global and static data in the @code{.bss} section, which is adjacent
22024 to the @code{.neardata} section. Put small read-only data into the
22025 @code{.rodata} section. The corresponding sections used for large
22026 pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
22029 @opindex msdata=all
22030 Put all data, not just small objects, into the sections reserved for
22031 small data, and use addressing relative to the @code{B14} register to
22035 @opindex msdata=none
22036 Make no use of the sections reserved for small data, and use absolute
22037 addresses to access all data. Put all initialized global and static
22038 data in the @code{.fardata} section, and all uninitialized data in the
22039 @code{.far} section. Put all constant data into the @code{.const}
22044 @subsection CRIS Options
22045 @cindex CRIS Options
22047 These options are defined specifically for the CRIS ports.
22050 @item -march=@var{architecture-type}
22051 @itemx -mcpu=@var{architecture-type}
22054 Generate code for the specified architecture. The choices for
22055 @var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
22056 respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
22057 Default is @samp{v0} except for cris-axis-linux-gnu, where the default is
22060 @item -mtune=@var{architecture-type}
22062 Tune to @var{architecture-type} everything applicable about the generated
22063 code, except for the ABI and the set of available instructions. The
22064 choices for @var{architecture-type} are the same as for
22065 @option{-march=@var{architecture-type}}.
22067 @item -mmax-stack-frame=@var{n}
22068 @opindex mmax-stack-frame
22069 Warn when the stack frame of a function exceeds @var{n} bytes.
22075 The options @option{-metrax4} and @option{-metrax100} are synonyms for
22076 @option{-march=v3} and @option{-march=v8} respectively.
22078 @item -mmul-bug-workaround
22079 @itemx -mno-mul-bug-workaround
22080 @opindex mmul-bug-workaround
22081 @opindex mno-mul-bug-workaround
22082 Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
22083 models where it applies. This option is active by default.
22087 Enable CRIS-specific verbose debug-related information in the assembly
22088 code. This option also has the effect of turning off the @samp{#NO_APP}
22089 formatted-code indicator to the assembler at the beginning of the
22094 Do not use condition-code results from previous instruction; always emit
22095 compare and test instructions before use of condition codes.
22097 @item -mno-side-effects
22098 @opindex mno-side-effects
22099 @opindex mside-effects
22100 Do not emit instructions with side effects in addressing modes other than
22103 @item -mstack-align
22104 @itemx -mno-stack-align
22105 @itemx -mdata-align
22106 @itemx -mno-data-align
22107 @itemx -mconst-align
22108 @itemx -mno-const-align
22109 @opindex mstack-align
22110 @opindex mno-stack-align
22111 @opindex mdata-align
22112 @opindex mno-data-align
22113 @opindex mconst-align
22114 @opindex mno-const-align
22115 These options (@samp{no-} options) arrange (eliminate arrangements) for the
22116 stack frame, individual data and constants to be aligned for the maximum
22117 single data access size for the chosen CPU model. The default is to
22118 arrange for 32-bit alignment. ABI details such as structure layout are
22119 not affected by these options.
22127 Similar to the stack- data- and const-align options above, these options
22128 arrange for stack frame, writable data and constants to all be 32-bit,
22129 16-bit or 8-bit aligned. The default is 32-bit alignment.
22131 @item -mno-prologue-epilogue
22132 @itemx -mprologue-epilogue
22133 @opindex mno-prologue-epilogue
22134 @opindex mprologue-epilogue
22135 With @option{-mno-prologue-epilogue}, the normal function prologue and
22136 epilogue which set up the stack frame are omitted and no return
22137 instructions or return sequences are generated in the code. Use this
22138 option only together with visual inspection of the compiled code: no
22139 warnings or errors are generated when call-saved registers must be saved,
22140 or storage for local variables needs to be allocated.
22144 @opindex mno-gotplt
22146 With @option{-fpic} and @option{-fPIC}, don't generate (do generate)
22147 instruction sequences that load addresses for functions from the PLT part
22148 of the GOT rather than (traditional on other architectures) calls to the
22149 PLT@. The default is @option{-mgotplt}.
22153 Legacy no-op option only recognized with the cris-axis-elf and
22154 cris-axis-linux-gnu targets.
22158 Legacy no-op option only recognized with the cris-axis-linux-gnu target.
22162 This option, recognized for the cris-axis-elf, arranges
22163 to link with input-output functions from a simulator library. Code,
22164 initialized data and zero-initialized data are allocated consecutively.
22168 Like @option{-sim}, but pass linker options to locate initialized data at
22169 0x40000000 and zero-initialized data at 0x80000000.
22173 @subsection CR16 Options
22174 @cindex CR16 Options
22176 These options are defined specifically for the CR16 ports.
22182 Enable the use of multiply-accumulate instructions. Disabled by default.
22186 @opindex mcr16cplus
22188 Generate code for CR16C or CR16C+ architecture. CR16C+ architecture
22193 Links the library libsim.a which is in compatible with simulator. Applicable
22194 to ELF compiler only.
22198 Choose integer type as 32-bit wide.
22202 Generates @code{sbit}/@code{cbit} instructions for bit manipulations.
22204 @item -mdata-model=@var{model}
22205 @opindex mdata-model
22206 Choose a data model. The choices for @var{model} are @samp{near},
22207 @samp{far} or @samp{medium}. @samp{medium} is default.
22208 However, @samp{far} is not valid with @option{-mcr16c}, as the
22209 CR16C architecture does not support the far data model.
22212 @node C-SKY Options
22213 @subsection C-SKY Options
22214 @cindex C-SKY Options
22216 GCC supports these options when compiling for C-SKY V2 processors.
22220 @item -march=@var{arch}
22222 Specify the C-SKY target architecture. Valid values for @var{arch} are:
22223 @samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
22224 The default is @samp{ck810}.
22226 @item -mcpu=@var{cpu}
22228 Specify the C-SKY target processor. Valid values for @var{cpu} are:
22229 @samp{ck801}, @samp{ck801t},
22230 @samp{ck802}, @samp{ck802t}, @samp{ck802j},
22231 @samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
22232 @samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
22233 @samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
22234 @samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
22235 @samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
22236 @samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
22237 @samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
22238 @samp{ck803eftr1}, @samp{ck803efhtr1},
22239 @samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
22240 @samp{ck803sef}, @samp{ck803seft},
22241 @samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
22242 @samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
22243 @samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
22244 @samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
22247 @opindex mbig-endian
22250 @itemx -mlittle-endian
22251 @opindex mlittle-endian
22255 Select big- or little-endian code. The default is little-endian.
22257 @item -mfloat-abi=@var{name}
22258 @opindex mfloat-abi
22259 Specifies which floating-point ABI to use. Permissible values
22260 are: @samp{soft}, @samp{softfp} and @samp{hard}.
22262 Specifying @samp{soft} causes GCC to generate output containing
22263 library calls for floating-point operations.
22264 @samp{softfp} allows the generation of code using hardware floating-point
22265 instructions, but still uses the soft-float calling conventions.
22266 @samp{hard} allows generation of floating-point instructions
22267 and uses FPU-specific calling conventions.
22269 The default depends on the specific target configuration. Note that
22270 the hard-float and soft-float ABIs are not link-compatible; you must
22271 compile your entire program with the same ABI, and link with a
22272 compatible set of libraries.
22275 @opindex mhard-float
22276 @itemx -msoft-float
22277 @opindex msoft-float
22279 Select hardware or software floating-point implementations.
22280 The default is soft float.
22282 @item -mdouble-float
22283 @itemx -mno-double-float
22284 @opindex mdouble-float
22285 When @option{-mhard-float} is in effect, enable generation of
22286 double-precision float instructions. This is the default except
22287 when compiling for CK803.
22292 When @option{-mhard-float} is in effect, enable generation of
22293 @code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
22294 This is the default except when compiling for CK803.
22296 @item -mfpu=@var{fpu}
22298 Select the floating-point processor. This option can only be used with
22299 @option{-mhard-float}.
22300 Values for @var{fpu} are
22301 @samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
22302 @samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
22303 @samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
22308 Enable the extended @code{lrw} instruction. This option defaults to on
22309 for CK801 and off otherwise.
22314 Enable interrupt stack instructions; the default is off.
22316 The @option{-mistack} option is required to handle the
22317 @code{interrupt} and @code{isr} function attributes
22318 (@pxref{C-SKY Function Attributes}).
22322 Enable multiprocessor instructions; the default is off.
22326 Enable coprocessor instructions; the default is off.
22330 Enable coprocessor instructions; the default is off.
22334 Enable C-SKY security instructions; the default is off.
22338 Enable C-SKY trust instructions; the default is off.
22346 Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
22347 All of these options default to off.
22352 Generate divide instructions. Default is off.
22357 Generate code for Smart Mode, using only registers numbered 0-7 to allow
22358 use of 16-bit instructions. This option is ignored for CK801 where this
22359 is the required behavior, and it defaults to on for CK802.
22360 For other targets, the default is off.
22362 @item -mhigh-registers
22363 @itemx -mno-high-registers
22364 @opindex mhigh-registers
22365 Generate code using the high registers numbered 16-31. This option
22366 is not supported on CK801, CK802, or CK803, and is enabled by default
22367 for other processors.
22372 Generate code using global anchor symbol addresses.
22375 @itemx -mno-pushpop
22377 Generate code using @code{push} and @code{pop} instructions. This option
22380 @item -mmultiple-stld
22382 @itemx -mno-multiple-stld
22384 @opindex mmultiple-stld
22385 Generate code using @code{stm} and @code{ldm} instructions. This option
22386 isn't supported on CK801 but is enabled by default on other processors.
22389 @itemx -mno-constpool
22390 @opindex mconstpool
22391 Create constant pools in the compiler instead of deferring it to the
22392 assembler. This option is the default and required for correct code
22393 generation on CK801 and CK802, and is optional on other processors.
22396 @item -mno-stack-size
22397 @opindex mstack-size
22398 Emit @code{.stack_size} directives for each function in the assembly
22399 output. This option defaults to off.
22404 Generate code for the C-SKY compiler runtime instead of libgcc. This
22405 option defaults to off.
22407 @item -mbranch-cost=@var{n}
22408 @opindex mbranch-cost=
22409 Set the branch costs to roughly @code{n} instructions. The default is 1.
22411 @item -msched-prolog
22412 @itemx -mno-sched-prolog
22413 @opindex msched-prolog
22414 Permit scheduling of function prologue and epilogue sequences. Using
22415 this option can result in code that is not compliant with the C-SKY V2 ABI
22416 prologue requirements and that cannot be debugged or backtraced.
22417 It is disabled by default.
22421 Links the library libsemi.a which is in compatible with simulator. Applicable
22422 to ELF compiler only.
22426 @node Darwin Options
22427 @subsection Darwin Options
22428 @cindex Darwin options
22430 These options are defined for all architectures running the Darwin operating
22433 FSF GCC on Darwin does not create ``fat'' object files; it creates
22434 an object file for the single architecture that GCC was built to
22435 target. Apple's GCC on Darwin does create ``fat'' files if multiple
22436 @option{-arch} options are used; it does so by running the compiler or
22437 linker multiple times and joining the results together with
22440 The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
22441 @samp{i686}) is determined by the flags that specify the ISA
22442 that GCC is targeting, like @option{-mcpu} or @option{-march}. The
22443 @option{-force_cpusubtype_ALL} option can be used to override this.
22445 The Darwin tools vary in their behavior when presented with an ISA
22446 mismatch. The assembler, @file{as}, only permits instructions to
22447 be used that are valid for the subtype of the file it is generating,
22448 so you cannot put 64-bit instructions in a @samp{ppc750} object file.
22449 The linker for shared libraries, @file{/usr/bin/libtool}, fails
22450 and prints an error if asked to create a shared library with a less
22451 restrictive subtype than its input files (for instance, trying to put
22452 a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
22453 for executables, @command{ld}, quietly gives the executable the most
22454 restrictive subtype of any of its input files.
22459 Add the framework directory @var{dir} to the head of the list of
22460 directories to be searched for header files. These directories are
22461 interleaved with those specified by @option{-I} options and are
22462 scanned in a left-to-right order.
22464 A framework directory is a directory with frameworks in it. A
22465 framework is a directory with a @file{Headers} and/or
22466 @file{PrivateHeaders} directory contained directly in it that ends
22467 in @file{.framework}. The name of a framework is the name of this
22468 directory excluding the @file{.framework}. Headers associated with
22469 the framework are found in one of those two directories, with
22470 @file{Headers} being searched first. A subframework is a framework
22471 directory that is in a framework's @file{Frameworks} directory.
22472 Includes of subframework headers can only appear in a header of a
22473 framework that contains the subframework, or in a sibling subframework
22474 header. Two subframeworks are siblings if they occur in the same
22475 framework. A subframework should not have the same name as a
22476 framework; a warning is issued if this is violated. Currently a
22477 subframework cannot have subframeworks; in the future, the mechanism
22478 may be extended to support this. The standard frameworks can be found
22479 in @file{/System/Library/Frameworks} and
22480 @file{/Library/Frameworks}. An example include looks like
22481 @code{#include <Framework/header.h>}, where @file{Framework} denotes
22482 the name of the framework and @file{header.h} is found in the
22483 @file{PrivateHeaders} or @file{Headers} directory.
22485 @item -iframework@var{dir}
22486 @opindex iframework
22487 Like @option{-F} except the directory is a treated as a system
22488 directory. The main difference between this @option{-iframework} and
22489 @option{-F} is that with @option{-iframework} the compiler does not
22490 warn about constructs contained within header files found via
22491 @var{dir}. This option is valid only for the C family of languages.
22495 Emit debugging information for symbols that are used. For stabs
22496 debugging format, this enables @option{-feliminate-unused-debug-symbols}.
22497 This is by default ON@.
22501 Emit debugging information for all symbols and types.
22503 @item -mmacosx-version-min=@var{version}
22504 The earliest version of MacOS X that this executable will run on
22505 is @var{version}. Typical values of @var{version} include @code{10.1},
22506 @code{10.2}, and @code{10.3.9}.
22508 If the compiler was built to use the system's headers by default,
22509 then the default for this option is the system version on which the
22510 compiler is running, otherwise the default is to make choices that
22511 are compatible with as many systems and code bases as possible.
22515 Enable kernel development mode. The @option{-mkernel} option sets
22516 @option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
22517 @option{-fno-exceptions}, @option{-fno-non-call-exceptions},
22518 @option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
22519 applicable. This mode also sets @option{-mno-altivec},
22520 @option{-msoft-float}, @option{-fno-builtin} and
22521 @option{-mlong-branch} for PowerPC targets.
22523 @item -mone-byte-bool
22524 @opindex mone-byte-bool
22525 Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
22526 By default @code{sizeof(bool)} is @code{4} when compiling for
22527 Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
22528 option has no effect on x86.
22530 @strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
22531 to generate code that is not binary compatible with code generated
22532 without that switch. Using this switch may require recompiling all
22533 other modules in a program, including system libraries. Use this
22534 switch to conform to a non-default data model.
22536 @item -mfix-and-continue
22537 @itemx -ffix-and-continue
22538 @itemx -findirect-data
22539 @opindex mfix-and-continue
22540 @opindex ffix-and-continue
22541 @opindex findirect-data
22542 Generate code suitable for fast turnaround development, such as to
22543 allow GDB to dynamically load @file{.o} files into already-running
22544 programs. @option{-findirect-data} and @option{-ffix-and-continue}
22545 are provided for backwards compatibility.
22549 Loads all members of static archive libraries.
22550 See man ld(1) for more information.
22552 @item -arch_errors_fatal
22553 @opindex arch_errors_fatal
22554 Cause the errors having to do with files that have the wrong architecture
22557 @item -bind_at_load
22558 @opindex bind_at_load
22559 Causes the output file to be marked such that the dynamic linker will
22560 bind all undefined references when the file is loaded or launched.
22564 Produce a Mach-o bundle format file.
22565 See man ld(1) for more information.
22567 @item -bundle_loader @var{executable}
22568 @opindex bundle_loader
22569 This option specifies the @var{executable} that will load the build
22570 output file being linked. See man ld(1) for more information.
22573 @opindex dynamiclib
22574 When passed this option, GCC produces a dynamic library instead of
22575 an executable when linking, using the Darwin @file{libtool} command.
22577 @item -force_cpusubtype_ALL
22578 @opindex force_cpusubtype_ALL
22579 This causes GCC's output file to have the @samp{ALL} subtype, instead of
22580 one controlled by the @option{-mcpu} or @option{-march} option.
22582 @item -allowable_client @var{client_name}
22583 @itemx -client_name
22584 @itemx -compatibility_version
22585 @itemx -current_version
22587 @itemx -dependency-file
22589 @itemx -dylinker_install_name
22591 @itemx -exported_symbols_list
22594 @itemx -flat_namespace
22595 @itemx -force_flat_namespace
22596 @itemx -headerpad_max_install_names
22599 @itemx -install_name
22600 @itemx -keep_private_externs
22601 @itemx -multi_module
22602 @itemx -multiply_defined
22603 @itemx -multiply_defined_unused
22606 @itemx -no_dead_strip_inits_and_terms
22607 @itemx -nofixprebinding
22608 @itemx -nomultidefs
22610 @itemx -noseglinkedit
22611 @itemx -pagezero_size
22613 @itemx -prebind_all_twolevel_modules
22614 @itemx -private_bundle
22616 @itemx -read_only_relocs
22618 @itemx -sectobjectsymbols
22622 @itemx -sectobjectsymbols
22625 @itemx -segs_read_only_addr
22627 @itemx -segs_read_write_addr
22628 @itemx -seg_addr_table
22629 @itemx -seg_addr_table_filename
22630 @itemx -seglinkedit
22632 @itemx -segs_read_only_addr
22633 @itemx -segs_read_write_addr
22634 @itemx -single_module
22636 @itemx -sub_library
22638 @itemx -sub_umbrella
22639 @itemx -twolevel_namespace
22642 @itemx -unexported_symbols_list
22643 @itemx -weak_reference_mismatches
22644 @itemx -whatsloaded
22645 @opindex allowable_client
22646 @opindex client_name
22647 @opindex compatibility_version
22648 @opindex current_version
22649 @opindex dead_strip
22650 @opindex dependency-file
22651 @opindex dylib_file
22652 @opindex dylinker_install_name
22654 @opindex exported_symbols_list
22656 @opindex flat_namespace
22657 @opindex force_flat_namespace
22658 @opindex headerpad_max_install_names
22659 @opindex image_base
22661 @opindex install_name
22662 @opindex keep_private_externs
22663 @opindex multi_module
22664 @opindex multiply_defined
22665 @opindex multiply_defined_unused
22666 @opindex noall_load
22667 @opindex no_dead_strip_inits_and_terms
22668 @opindex nofixprebinding
22669 @opindex nomultidefs
22671 @opindex noseglinkedit
22672 @opindex pagezero_size
22674 @opindex prebind_all_twolevel_modules
22675 @opindex private_bundle
22676 @opindex read_only_relocs
22678 @opindex sectobjectsymbols
22681 @opindex sectcreate
22682 @opindex sectobjectsymbols
22685 @opindex segs_read_only_addr
22686 @opindex segs_read_write_addr
22687 @opindex seg_addr_table
22688 @opindex seg_addr_table_filename
22689 @opindex seglinkedit
22691 @opindex segs_read_only_addr
22692 @opindex segs_read_write_addr
22693 @opindex single_module
22695 @opindex sub_library
22696 @opindex sub_umbrella
22697 @opindex twolevel_namespace
22700 @opindex unexported_symbols_list
22701 @opindex weak_reference_mismatches
22702 @opindex whatsloaded
22703 These options are passed to the Darwin linker. The Darwin linker man page
22704 describes them in detail.
22707 @node DEC Alpha Options
22708 @subsection DEC Alpha Options
22710 These @samp{-m} options are defined for the DEC Alpha implementations:
22713 @item -mno-soft-float
22714 @itemx -msoft-float
22715 @opindex mno-soft-float
22716 @opindex msoft-float
22717 Use (do not use) the hardware floating-point instructions for
22718 floating-point operations. When @option{-msoft-float} is specified,
22719 functions in @file{libgcc.a} are used to perform floating-point
22720 operations. Unless they are replaced by routines that emulate the
22721 floating-point operations, or compiled in such a way as to call such
22722 emulations routines, these routines issue floating-point
22723 operations. If you are compiling for an Alpha without floating-point
22724 operations, you must ensure that the library is built so as not to call
22727 Note that Alpha implementations without floating-point operations are
22728 required to have floating-point registers.
22731 @itemx -mno-fp-regs
22733 @opindex mno-fp-regs
22734 Generate code that uses (does not use) the floating-point register set.
22735 @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
22736 register set is not used, floating-point operands are passed in integer
22737 registers as if they were integers and floating-point results are passed
22738 in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
22739 so any function with a floating-point argument or return value called by code
22740 compiled with @option{-mno-fp-regs} must also be compiled with that
22743 A typical use of this option is building a kernel that does not use,
22744 and hence need not save and restore, any floating-point registers.
22748 The Alpha architecture implements floating-point hardware optimized for
22749 maximum performance. It is mostly compliant with the IEEE floating-point
22750 standard. However, for full compliance, software assistance is
22751 required. This option generates code fully IEEE-compliant code
22752 @emph{except} that the @var{inexact-flag} is not maintained (see below).
22753 If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
22754 defined during compilation. The resulting code is less efficient but is
22755 able to correctly support denormalized numbers and exceptional IEEE
22756 values such as not-a-number and plus/minus infinity. Other Alpha
22757 compilers call this option @option{-ieee_with_no_inexact}.
22759 @item -mieee-with-inexact
22760 @opindex mieee-with-inexact
22761 This is like @option{-mieee} except the generated code also maintains
22762 the IEEE @var{inexact-flag}. Turning on this option causes the
22763 generated code to implement fully-compliant IEEE math. In addition to
22764 @code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
22765 macro. On some Alpha implementations the resulting code may execute
22766 significantly slower than the code generated by default. Since there is
22767 very little code that depends on the @var{inexact-flag}, you should
22768 normally not specify this option. Other Alpha compilers call this
22769 option @option{-ieee_with_inexact}.
22771 @item -mfp-trap-mode=@var{trap-mode}
22772 @opindex mfp-trap-mode
22773 This option controls what floating-point related traps are enabled.
22774 Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
22775 The trap mode can be set to one of four values:
22779 This is the default (normal) setting. The only traps that are enabled
22780 are the ones that cannot be disabled in software (e.g., division by zero
22784 In addition to the traps enabled by @samp{n}, underflow traps are enabled
22788 Like @samp{u}, but the instructions are marked to be safe for software
22789 completion (see Alpha architecture manual for details).
22792 Like @samp{su}, but inexact traps are enabled as well.
22795 @item -mfp-rounding-mode=@var{rounding-mode}
22796 @opindex mfp-rounding-mode
22797 Selects the IEEE rounding mode. Other Alpha compilers call this option
22798 @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
22803 Normal IEEE rounding mode. Floating-point numbers are rounded towards
22804 the nearest machine number or towards the even machine number in case
22808 Round towards minus infinity.
22811 Chopped rounding mode. Floating-point numbers are rounded towards zero.
22814 Dynamic rounding mode. A field in the floating-point control register
22815 (@var{fpcr}, see Alpha architecture reference manual) controls the
22816 rounding mode in effect. The C library initializes this register for
22817 rounding towards plus infinity. Thus, unless your program modifies the
22818 @var{fpcr}, @samp{d} corresponds to round towards plus infinity.
22821 @item -mtrap-precision=@var{trap-precision}
22822 @opindex mtrap-precision
22823 In the Alpha architecture, floating-point traps are imprecise. This
22824 means without software assistance it is impossible to recover from a
22825 floating trap and program execution normally needs to be terminated.
22826 GCC can generate code that can assist operating system trap handlers
22827 in determining the exact location that caused a floating-point trap.
22828 Depending on the requirements of an application, different levels of
22829 precisions can be selected:
22833 Program precision. This option is the default and means a trap handler
22834 can only identify which program caused a floating-point exception.
22837 Function precision. The trap handler can determine the function that
22838 caused a floating-point exception.
22841 Instruction precision. The trap handler can determine the exact
22842 instruction that caused a floating-point exception.
22845 Other Alpha compilers provide the equivalent options called
22846 @option{-scope_safe} and @option{-resumption_safe}.
22848 @item -mieee-conformant
22849 @opindex mieee-conformant
22850 This option marks the generated code as IEEE conformant. You must not
22851 use this option unless you also specify @option{-mtrap-precision=i} and either
22852 @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
22853 is to emit the line @samp{.eflag 48} in the function prologue of the
22854 generated assembly file.
22856 @item -mbuild-constants
22857 @opindex mbuild-constants
22858 Normally GCC examines a 32- or 64-bit integer constant to
22859 see if it can construct it from smaller constants in two or three
22860 instructions. If it cannot, it outputs the constant as a literal and
22861 generates code to load it from the data segment at run time.
22863 Use this option to require GCC to construct @emph{all} integer constants
22864 using code, even if it takes more instructions (the maximum is six).
22866 You typically use this option to build a shared library dynamic
22867 loader. Itself a shared library, it must relocate itself in memory
22868 before it can find the variables and constants in its own data segment.
22886 Indicate whether GCC should generate code to use the optional BWX,
22887 CIX, FIX and MAX instruction sets. The default is to use the instruction
22888 sets supported by the CPU type specified via @option{-mcpu=} option or that
22889 of the CPU on which GCC was built if none is specified.
22892 @itemx -mfloat-ieee
22893 @opindex mfloat-vax
22894 @opindex mfloat-ieee
22895 Generate code that uses (does not use) VAX F and G floating-point
22896 arithmetic instead of IEEE single and double precision.
22898 @item -mexplicit-relocs
22899 @itemx -mno-explicit-relocs
22900 @opindex mexplicit-relocs
22901 @opindex mno-explicit-relocs
22902 Older Alpha assemblers provided no way to generate symbol relocations
22903 except via assembler macros. Use of these macros does not allow
22904 optimal instruction scheduling. GNU binutils as of version 2.12
22905 supports a new syntax that allows the compiler to explicitly mark
22906 which relocations should apply to which instructions. This option
22907 is mostly useful for debugging, as GCC detects the capabilities of
22908 the assembler when it is built and sets the default accordingly.
22911 @itemx -mlarge-data
22912 @opindex msmall-data
22913 @opindex mlarge-data
22914 When @option{-mexplicit-relocs} is in effect, static data is
22915 accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
22916 is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
22917 (the @code{.sdata} and @code{.sbss} sections) and are accessed via
22918 16-bit relocations off of the @code{$gp} register. This limits the
22919 size of the small data area to 64KB, but allows the variables to be
22920 directly accessed via a single instruction.
22922 The default is @option{-mlarge-data}. With this option the data area
22923 is limited to just below 2GB@. Programs that require more than 2GB of
22924 data must use @code{malloc} or @code{mmap} to allocate the data in the
22925 heap instead of in the program's data segment.
22927 When generating code for shared libraries, @option{-fpic} implies
22928 @option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
22931 @itemx -mlarge-text
22932 @opindex msmall-text
22933 @opindex mlarge-text
22934 When @option{-msmall-text} is used, the compiler assumes that the
22935 code of the entire program (or shared library) fits in 4MB, and is
22936 thus reachable with a branch instruction. When @option{-msmall-data}
22937 is used, the compiler can assume that all local symbols share the
22938 same @code{$gp} value, and thus reduce the number of instructions
22939 required for a function call from 4 to 1.
22941 The default is @option{-mlarge-text}.
22943 @item -mcpu=@var{cpu_type}
22945 Set the instruction set and instruction scheduling parameters for
22946 machine type @var{cpu_type}. You can specify either the @samp{EV}
22947 style name or the corresponding chip number. GCC supports scheduling
22948 parameters for the EV4, EV5 and EV6 family of processors and
22949 chooses the default values for the instruction set from the processor
22950 you specify. If you do not specify a processor type, GCC defaults
22951 to the processor on which the compiler was built.
22953 Supported values for @var{cpu_type} are
22959 Schedules as an EV4 and has no instruction set extensions.
22963 Schedules as an EV5 and has no instruction set extensions.
22967 Schedules as an EV5 and supports the BWX extension.
22972 Schedules as an EV5 and supports the BWX and MAX extensions.
22976 Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
22980 Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
22983 Native toolchains also support the value @samp{native},
22984 which selects the best architecture option for the host processor.
22985 @option{-mcpu=native} has no effect if GCC does not recognize
22988 @item -mtune=@var{cpu_type}
22990 Set only the instruction scheduling parameters for machine type
22991 @var{cpu_type}. The instruction set is not changed.
22993 Native toolchains also support the value @samp{native},
22994 which selects the best architecture option for the host processor.
22995 @option{-mtune=native} has no effect if GCC does not recognize
22998 @item -mmemory-latency=@var{time}
22999 @opindex mmemory-latency
23000 Sets the latency the scheduler should assume for typical memory
23001 references as seen by the application. This number is highly
23002 dependent on the memory access patterns used by the application
23003 and the size of the external cache on the machine.
23005 Valid options for @var{time} are
23009 A decimal number representing clock cycles.
23015 The compiler contains estimates of the number of clock cycles for
23016 ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
23017 (also called Dcache, Scache, and Bcache), as well as to main memory.
23018 Note that L3 is only valid for EV5.
23024 @subsection eBPF Options
23025 @cindex eBPF Options
23028 @item -mframe-limit=@var{bytes}
23029 This specifies the hard limit for frame sizes, in bytes. Currently,
23030 the value that can be specified should be less than or equal to
23031 @samp{32767}. Defaults to whatever limit is imposed by the version of
23032 the Linux kernel targeted.
23034 @item -mkernel=@var{version}
23036 This specifies the minimum version of the kernel that will run the
23037 compiled program. GCC uses this version to determine which
23038 instructions to use, what kernel helpers to allow, etc. Currently,
23039 @var{version} can be one of @samp{4.0}, @samp{4.1}, @samp{4.2},
23040 @samp{4.3}, @samp{4.4}, @samp{4.5}, @samp{4.6}, @samp{4.7},
23041 @samp{4.8}, @samp{4.9}, @samp{4.10}, @samp{4.11}, @samp{4.12},
23042 @samp{4.13}, @samp{4.14}, @samp{4.15}, @samp{4.16}, @samp{4.17},
23043 @samp{4.18}, @samp{4.19}, @samp{4.20}, @samp{5.0}, @samp{5.1},
23044 @samp{5.2}, @samp{latest} and @samp{native}.
23047 @opindex mbig-endian
23048 Generate code for a big-endian target.
23050 @item -mlittle-endian
23051 @opindex mlittle-endian
23052 Generate code for a little-endian target. This is the default.
23056 Enable generation of extra conditional-branch instructions.
23057 Enabled for CPU v2 and above.
23061 Enable 32-bit jump instructions. Enabled for CPU v3 and above.
23065 Enable 32-bit ALU instructions. Enabled for CPU v3 and above.
23067 @item -mcpu=@var{version}
23069 This specifies which version of the eBPF ISA to target. Newer versions
23070 may not be supported by all kernels. The default is @samp{v3}.
23072 Supported values for @var{version} are:
23076 The first stable eBPF ISA with no special features or extensions.
23079 Supports the jump extensions, as in @option{-mjmpext}.
23082 All features of v2, plus:
23084 @item 32-bit jump operations, as in @option{-mjmp32}
23085 @item 32-bit ALU operations, as in @option{-malu32}
23092 Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
23093 is implied by @option{-gbtf}.
23097 Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
23098 support is enabled by default when generating BTF debug information for
23102 Generate code for an expanded version of BPF, which relaxes some of
23103 the restrictions imposed by the BPF architecture:
23105 @item Save and restore callee-saved registers at function entry and
23106 exit, respectively.
23111 @subsection FR30 Options
23112 @cindex FR30 Options
23114 These options are defined specifically for the FR30 port.
23118 @item -msmall-model
23119 @opindex msmall-model
23120 Use the small address space model. This can produce smaller code, but
23121 it does assume that all symbolic values and addresses fit into a
23126 Assume that runtime support has been provided and so there is no need
23127 to include the simulator library (@file{libsim.a}) on the linker
23133 @subsection FT32 Options
23134 @cindex FT32 Options
23136 These options are defined specifically for the FT32 port.
23142 Specifies that the program will be run on the simulator. This causes
23143 an alternate runtime startup and library to be linked.
23144 You must not use this option when generating programs that will run on
23145 real hardware; you must provide your own runtime library for whatever
23146 I/O functions are needed.
23150 Enable Local Register Allocation. This is still experimental for FT32,
23151 so by default the compiler uses standard reload.
23155 Do not use div and mod instructions.
23159 Enable use of the extended instructions of the FT32B processor.
23163 Compress all code using the Ft32B code compression scheme.
23167 Do not generate code that reads program memory.
23172 @subsection FRV Options
23173 @cindex FRV Options
23179 Only use the first 32 general-purpose registers.
23184 Use all 64 general-purpose registers.
23189 Use only the first 32 floating-point registers.
23194 Use all 64 floating-point registers.
23197 @opindex mhard-float
23199 Use hardware instructions for floating-point operations.
23202 @opindex msoft-float
23204 Use library routines for floating-point operations.
23209 Dynamically allocate condition code registers.
23214 Do not try to dynamically allocate condition code registers, only
23215 use @code{icc0} and @code{fcc0}.
23220 Change ABI to use double word insns.
23226 Do not use double word instructions.
23231 Use floating-point double instructions.
23234 @opindex mno-double
23236 Do not use floating-point double instructions.
23241 Use media instructions.
23246 Do not use media instructions.
23251 Use multiply and add/subtract instructions.
23254 @opindex mno-muladd
23256 Do not use multiply and add/subtract instructions.
23261 Select the FDPIC ABI, which uses function descriptors to represent
23262 pointers to functions. Without any PIC/PIE-related options, it
23263 implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
23264 assumes GOT entries and small data are within a 12-bit range from the
23265 GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
23266 are computed with 32 bits.
23267 With a @samp{bfin-elf} target, this option implies @option{-msim}.
23270 @opindex minline-plt
23272 Enable inlining of PLT entries in function calls to functions that are
23273 not known to bind locally. It has no effect without @option{-mfdpic}.
23274 It's enabled by default if optimizing for speed and compiling for
23275 shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
23276 optimization option such as @option{-O3} or above is present in the
23282 Assume a large TLS segment when generating thread-local code.
23287 Do not assume a large TLS segment when generating thread-local code.
23292 Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
23293 that is known to be in read-only sections. It's enabled by default,
23294 except for @option{-fpic} or @option{-fpie}: even though it may help
23295 make the global offset table smaller, it trades 1 instruction for 4.
23296 With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
23297 one of which may be shared by multiple symbols, and it avoids the need
23298 for a GOT entry for the referenced symbol, so it's more likely to be a
23299 win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
23301 @item -multilib-library-pic
23302 @opindex multilib-library-pic
23304 Link with the (library, not FD) pic libraries. It's implied by
23305 @option{-mlibrary-pic}, as well as by @option{-fPIC} and
23306 @option{-fpic} without @option{-mfdpic}. You should never have to use
23310 @opindex mlinked-fp
23312 Follow the EABI requirement of always creating a frame pointer whenever
23313 a stack frame is allocated. This option is enabled by default and can
23314 be disabled with @option{-mno-linked-fp}.
23317 @opindex mlong-calls
23319 Use indirect addressing to call functions outside the current
23320 compilation unit. This allows the functions to be placed anywhere
23321 within the 32-bit address space.
23323 @item -malign-labels
23324 @opindex malign-labels
23326 Try to align labels to an 8-byte boundary by inserting NOPs into the
23327 previous packet. This option only has an effect when VLIW packing
23328 is enabled. It doesn't create new packets; it merely adds NOPs to
23331 @item -mlibrary-pic
23332 @opindex mlibrary-pic
23334 Generate position-independent EABI code.
23339 Use only the first four media accumulator registers.
23344 Use all eight media accumulator registers.
23349 Pack VLIW instructions.
23354 Do not pack VLIW instructions.
23357 @opindex mno-eflags
23359 Do not mark ABI switches in e_flags.
23362 @opindex mcond-move
23364 Enable the use of conditional-move instructions (default).
23366 This switch is mainly for debugging the compiler and will likely be removed
23367 in a future version.
23369 @item -mno-cond-move
23370 @opindex mno-cond-move
23372 Disable the use of conditional-move instructions.
23374 This switch is mainly for debugging the compiler and will likely be removed
23375 in a future version.
23380 Enable the use of conditional set instructions (default).
23382 This switch is mainly for debugging the compiler and will likely be removed
23383 in a future version.
23388 Disable the use of conditional set instructions.
23390 This switch is mainly for debugging the compiler and will likely be removed
23391 in a future version.
23394 @opindex mcond-exec
23396 Enable the use of conditional execution (default).
23398 This switch is mainly for debugging the compiler and will likely be removed
23399 in a future version.
23401 @item -mno-cond-exec
23402 @opindex mno-cond-exec
23404 Disable the use of conditional execution.
23406 This switch is mainly for debugging the compiler and will likely be removed
23407 in a future version.
23409 @item -mvliw-branch
23410 @opindex mvliw-branch
23412 Run a pass to pack branches into VLIW instructions (default).
23414 This switch is mainly for debugging the compiler and will likely be removed
23415 in a future version.
23417 @item -mno-vliw-branch
23418 @opindex mno-vliw-branch
23420 Do not run a pass to pack branches into VLIW instructions.
23422 This switch is mainly for debugging the compiler and will likely be removed
23423 in a future version.
23425 @item -mmulti-cond-exec
23426 @opindex mmulti-cond-exec
23428 Enable optimization of @code{&&} and @code{||} in conditional execution
23431 This switch is mainly for debugging the compiler and will likely be removed
23432 in a future version.
23434 @item -mno-multi-cond-exec
23435 @opindex mno-multi-cond-exec
23437 Disable optimization of @code{&&} and @code{||} in conditional execution.
23439 This switch is mainly for debugging the compiler and will likely be removed
23440 in a future version.
23442 @item -mnested-cond-exec
23443 @opindex mnested-cond-exec
23445 Enable nested conditional execution optimizations (default).
23447 This switch is mainly for debugging the compiler and will likely be removed
23448 in a future version.
23450 @item -mno-nested-cond-exec
23451 @opindex mno-nested-cond-exec
23453 Disable nested conditional execution optimizations.
23455 This switch is mainly for debugging the compiler and will likely be removed
23456 in a future version.
23458 @item -moptimize-membar
23459 @opindex moptimize-membar
23461 This switch removes redundant @code{membar} instructions from the
23462 compiler-generated code. It is enabled by default.
23464 @item -mno-optimize-membar
23465 @opindex mno-optimize-membar
23466 @opindex moptimize-membar
23468 This switch disables the automatic removal of redundant @code{membar}
23469 instructions from the generated code.
23471 @item -mtomcat-stats
23472 @opindex mtomcat-stats
23474 Cause gas to print out tomcat statistics.
23476 @item -mcpu=@var{cpu}
23479 Select the processor type for which to generate code. Possible values are
23480 @samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
23481 @samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
23485 @node GNU/Linux Options
23486 @subsection GNU/Linux Options
23488 These @samp{-m} options are defined for GNU/Linux targets:
23493 Use the GNU C library. This is the default except
23494 on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
23495 @samp{*-*-linux-*android*} targets.
23499 Use uClibc C library. This is the default on
23500 @samp{*-*-linux-*uclibc*} targets.
23504 Use the musl C library. This is the default on
23505 @samp{*-*-linux-*musl*} targets.
23509 Use Bionic C library. This is the default on
23510 @samp{*-*-linux-*android*} targets.
23514 Compile code compatible with Android platform. This is the default on
23515 @samp{*-*-linux-*android*} targets.
23517 When compiling, this option enables @option{-mbionic}, @option{-fPIC},
23518 @option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
23519 this option makes the GCC driver pass Android-specific options to the linker.
23520 Finally, this option causes the preprocessor macro @code{__ANDROID__}
23523 @item -tno-android-cc
23524 @opindex tno-android-cc
23525 Disable compilation effects of @option{-mandroid}, i.e., do not enable
23526 @option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
23527 @option{-fno-rtti} by default.
23529 @item -tno-android-ld
23530 @opindex tno-android-ld
23531 Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
23532 linking options to the linker.
23536 @node H8/300 Options
23537 @subsection H8/300 Options
23539 These @samp{-m} options are defined for the H8/300 implementations:
23544 Shorten some address references at link time, when possible; uses the
23545 linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
23546 ld, Using ld}, for a fuller description.
23550 Generate code for the H8/300H@.
23554 Generate code for the H8S@.
23558 Generate code for the H8S and H8/300H in the normal mode. This switch
23559 must be used either with @option{-mh} or @option{-ms}.
23563 Generate code for the H8S/2600. This switch must be used with @option{-ms}.
23567 Extended registers are stored on stack before execution of function
23568 with monitor attribute. Default option is @option{-mexr}.
23569 This option is valid only for H8S targets.
23574 Extended registers are not stored on stack before execution of function
23575 with monitor attribute. Default option is @option{-mno-exr}.
23576 This option is valid only for H8S targets.
23580 Make @code{int} data 32 bits by default.
23583 @opindex malign-300
23584 On the H8/300H and H8S, use the same alignment rules as for the H8/300.
23585 The default for the H8/300H and H8S is to align longs and floats on
23587 @option{-malign-300} causes them to be aligned on 2-byte boundaries.
23588 This option has no effect on the H8/300.
23592 @subsection HPPA Options
23593 @cindex HPPA Options
23595 These @samp{-m} options are defined for the HPPA family of computers:
23598 @item -march=@var{architecture-type}
23600 Generate code for the specified architecture. The choices for
23601 @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
23602 1.1, and @samp{2.0} for PA 2.0 processors. Refer to
23603 @file{/usr/lib/sched.models} on an HP-UX system to determine the proper
23604 architecture option for your machine. Code compiled for lower numbered
23605 architectures runs on higher numbered architectures, but not the
23608 @item -mpa-risc-1-0
23609 @itemx -mpa-risc-1-1
23610 @itemx -mpa-risc-2-0
23611 @opindex mpa-risc-1-0
23612 @opindex mpa-risc-1-1
23613 @opindex mpa-risc-2-0
23614 Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
23616 @item -mcaller-copies
23617 @opindex mcaller-copies
23618 The caller copies function arguments passed by hidden reference. This
23619 option should be used with care as it is not compatible with the default
23620 32-bit runtime. However, only aggregates larger than eight bytes are
23621 passed by hidden reference and the option provides better compatibility
23624 @item -mjump-in-delay
23625 @opindex mjump-in-delay
23626 This option is ignored and provided for compatibility purposes only.
23628 @item -mdisable-fpregs
23629 @opindex mdisable-fpregs
23630 Prevent floating-point registers from being used in any manner. This is
23631 necessary for compiling kernels that perform lazy context switching of
23632 floating-point registers. If you use this option and attempt to perform
23633 floating-point operations, the compiler aborts.
23635 @item -mdisable-indexing
23636 @opindex mdisable-indexing
23637 Prevent the compiler from using indexing address modes. This avoids some
23638 rather obscure problems when compiling MIG generated code under MACH@.
23640 @item -mno-space-regs
23641 @opindex mno-space-regs
23642 @opindex mspace-regs
23643 Generate code that assumes the target has no space registers. This allows
23644 GCC to generate faster indirect calls and use unscaled index address modes.
23646 Such code is suitable for level 0 PA systems and kernels.
23648 @item -mfast-indirect-calls
23649 @opindex mfast-indirect-calls
23650 Generate code that assumes calls never cross space boundaries. This
23651 allows GCC to emit code that performs faster indirect calls.
23653 This option does not work in the presence of shared libraries or nested
23656 @item -mfixed-range=@var{register-range}
23657 @opindex mfixed-range
23658 Generate code treating the given register range as fixed registers.
23659 A fixed register is one that the register allocator cannot use. This is
23660 useful when compiling kernel code. A register range is specified as
23661 two registers separated by a dash. Multiple register ranges can be
23662 specified separated by a comma.
23664 @item -mlong-load-store
23665 @opindex mlong-load-store
23666 Generate 3-instruction load and store sequences as sometimes required by
23667 the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
23670 @item -mportable-runtime
23671 @opindex mportable-runtime
23672 Use the portable calling conventions proposed by HP for ELF systems.
23676 Enable the use of assembler directives only GAS understands.
23678 @item -mschedule=@var{cpu-type}
23680 Schedule code according to the constraints for the machine type
23681 @var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
23682 @samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
23683 to @file{/usr/lib/sched.models} on an HP-UX system to determine the
23684 proper scheduling option for your machine. The default scheduling is
23688 @opindex mlinker-opt
23689 Enable the optimization pass in the HP-UX linker. Note this makes symbolic
23690 debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
23691 linkers in which they give bogus error messages when linking some programs.
23694 @opindex msoft-float
23695 Generate output containing library calls for floating point.
23696 @strong{Warning:} the requisite libraries are not available for all HPPA
23697 targets. Normally the facilities of the machine's usual C compiler are
23698 used, but this cannot be done directly in cross-compilation. You must make
23699 your own arrangements to provide suitable library functions for
23702 @option{-msoft-float} changes the calling convention in the output file;
23703 therefore, it is only useful if you compile @emph{all} of a program with
23704 this option. In particular, you need to compile @file{libgcc.a}, the
23705 library that comes with GCC, with @option{-msoft-float} in order for
23710 Generate the predefine, @code{_SIO}, for server IO@. The default is
23711 @option{-mwsio}. This generates the predefines, @code{__hp9000s700},
23712 @code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
23713 options are available under HP-UX and HI-UX@.
23717 Use options specific to GNU @command{ld}.
23718 This passes @option{-shared} to @command{ld} when
23719 building a shared library. It is the default when GCC is configured,
23720 explicitly or implicitly, with the GNU linker. This option does not
23721 affect which @command{ld} is called; it only changes what parameters
23722 are passed to that @command{ld}.
23723 The @command{ld} that is called is determined by the
23724 @option{--with-ld} configure option, GCC's program search path, and
23725 finally by the user's @env{PATH}. The linker used by GCC can be printed
23726 using @samp{which `gcc -print-prog-name=ld`}. This option is only available
23727 on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
23731 Use options specific to HP @command{ld}.
23732 This passes @option{-b} to @command{ld} when building
23733 a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
23734 links. It is the default when GCC is configured, explicitly or
23735 implicitly, with the HP linker. This option does not affect
23736 which @command{ld} is called; it only changes what parameters are passed to that
23738 The @command{ld} that is called is determined by the @option{--with-ld}
23739 configure option, GCC's program search path, and finally by the user's
23740 @env{PATH}. The linker used by GCC can be printed using @samp{which
23741 `gcc -print-prog-name=ld`}. This option is only available on the 64-bit
23742 HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
23745 @opindex mno-long-calls
23746 @opindex mlong-calls
23747 Generate code that uses long call sequences. This ensures that a call
23748 is always able to reach linker generated stubs. The default is to generate
23749 long calls only when the distance from the call site to the beginning
23750 of the function or translation unit, as the case may be, exceeds a
23751 predefined limit set by the branch type being used. The limits for
23752 normal calls are 7,600,000 and 240,000 bytes, respectively for the
23753 PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
23756 Distances are measured from the beginning of functions when using the
23757 @option{-ffunction-sections} option, or when using the @option{-mgas}
23758 and @option{-mno-portable-runtime} options together under HP-UX with
23761 It is normally not desirable to use this option as it degrades
23762 performance. However, it may be useful in large applications,
23763 particularly when partial linking is used to build the application.
23765 The types of long calls used depends on the capabilities of the
23766 assembler and linker, and the type of code being generated. The
23767 impact on systems that support long absolute calls, and long pic
23768 symbol-difference or pc-relative calls should be relatively small.
23769 However, an indirect call is used on 32-bit ELF systems in pic code
23770 and it is quite long.
23772 @item -munix=@var{unix-std}
23774 Generate compiler predefines and select a startfile for the specified
23775 UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
23776 and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
23777 is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
23778 11.11 and later. The default values are @samp{93} for HP-UX 10.00,
23779 @samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
23782 @option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
23783 @option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
23784 and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
23785 @option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
23786 @code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
23787 @code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
23789 It is @emph{important} to note that this option changes the interfaces
23790 for various library routines. It also affects the operational behavior
23791 of the C library. Thus, @emph{extreme} care is needed in using this
23794 Library code that is intended to operate with more than one UNIX
23795 standard must test, set and restore the variable @code{__xpg4_extended_mask}
23796 as appropriate. Most GNU software doesn't provide this capability.
23800 Suppress the generation of link options to search libdld.sl when the
23801 @option{-static} option is specified on HP-UX 10 and later.
23805 The HP-UX implementation of setlocale in libc has a dependency on
23806 libdld.sl. There isn't an archive version of libdld.sl. Thus,
23807 when the @option{-static} option is specified, special link options
23808 are needed to resolve this dependency.
23810 On HP-UX 10 and later, the GCC driver adds the necessary options to
23811 link with libdld.sl when the @option{-static} option is specified.
23812 This causes the resulting binary to be dynamic. On the 64-bit port,
23813 the linkers generate dynamic binaries by default in any case. The
23814 @option{-nolibdld} option can be used to prevent the GCC driver from
23815 adding these link options.
23819 Add support for multithreading with the @dfn{dce thread} library
23820 under HP-UX@. This option sets flags for both the preprocessor and
23824 @node IA-64 Options
23825 @subsection IA-64 Options
23826 @cindex IA-64 Options
23828 These are the @samp{-m} options defined for the Intel IA-64 architecture.
23832 @opindex mbig-endian
23833 Generate code for a big-endian target. This is the default for HP-UX@.
23835 @item -mlittle-endian
23836 @opindex mlittle-endian
23837 Generate code for a little-endian target. This is the default for AIX5
23843 @opindex mno-gnu-as
23844 Generate (or don't) code for the GNU assembler. This is the default.
23845 @c Also, this is the default if the configure option @option{--with-gnu-as}
23851 @opindex mno-gnu-ld
23852 Generate (or don't) code for the GNU linker. This is the default.
23853 @c Also, this is the default if the configure option @option{--with-gnu-ld}
23858 Generate code that does not use a global pointer register. The result
23859 is not position independent code, and violates the IA-64 ABI@.
23861 @item -mvolatile-asm-stop
23862 @itemx -mno-volatile-asm-stop
23863 @opindex mvolatile-asm-stop
23864 @opindex mno-volatile-asm-stop
23865 Generate (or don't) a stop bit immediately before and after volatile asm
23868 @item -mregister-names
23869 @itemx -mno-register-names
23870 @opindex mregister-names
23871 @opindex mno-register-names
23872 Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
23873 the stacked registers. This may make assembler output more readable.
23879 Disable (or enable) optimizations that use the small data section. This may
23880 be useful for working around optimizer bugs.
23882 @item -mconstant-gp
23883 @opindex mconstant-gp
23884 Generate code that uses a single constant global pointer value. This is
23885 useful when compiling kernel code.
23889 Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
23890 This is useful when compiling firmware code.
23892 @item -minline-float-divide-min-latency
23893 @opindex minline-float-divide-min-latency
23894 Generate code for inline divides of floating-point values
23895 using the minimum latency algorithm.
23897 @item -minline-float-divide-max-throughput
23898 @opindex minline-float-divide-max-throughput
23899 Generate code for inline divides of floating-point values
23900 using the maximum throughput algorithm.
23902 @item -mno-inline-float-divide
23903 @opindex mno-inline-float-divide
23904 Do not generate inline code for divides of floating-point values.
23906 @item -minline-int-divide-min-latency
23907 @opindex minline-int-divide-min-latency
23908 Generate code for inline divides of integer values
23909 using the minimum latency algorithm.
23911 @item -minline-int-divide-max-throughput
23912 @opindex minline-int-divide-max-throughput
23913 Generate code for inline divides of integer values
23914 using the maximum throughput algorithm.
23916 @item -mno-inline-int-divide
23917 @opindex mno-inline-int-divide
23918 @opindex minline-int-divide
23919 Do not generate inline code for divides of integer values.
23921 @item -minline-sqrt-min-latency
23922 @opindex minline-sqrt-min-latency
23923 Generate code for inline square roots
23924 using the minimum latency algorithm.
23926 @item -minline-sqrt-max-throughput
23927 @opindex minline-sqrt-max-throughput
23928 Generate code for inline square roots
23929 using the maximum throughput algorithm.
23931 @item -mno-inline-sqrt
23932 @opindex mno-inline-sqrt
23933 Do not generate inline code for @code{sqrt}.
23936 @itemx -mno-fused-madd
23937 @opindex mfused-madd
23938 @opindex mno-fused-madd
23939 Do (don't) generate code that uses the fused multiply/add or multiply/subtract
23940 instructions. The default is to use these instructions.
23942 @item -mno-dwarf2-asm
23943 @itemx -mdwarf2-asm
23944 @opindex mno-dwarf2-asm
23945 @opindex mdwarf2-asm
23946 Don't (or do) generate assembler code for the DWARF line number debugging
23947 info. This may be useful when not using the GNU assembler.
23949 @item -mearly-stop-bits
23950 @itemx -mno-early-stop-bits
23951 @opindex mearly-stop-bits
23952 @opindex mno-early-stop-bits
23953 Allow stop bits to be placed earlier than immediately preceding the
23954 instruction that triggered the stop bit. This can improve instruction
23955 scheduling, but does not always do so.
23957 @item -mfixed-range=@var{register-range}
23958 @opindex mfixed-range
23959 Generate code treating the given register range as fixed registers.
23960 A fixed register is one that the register allocator cannot use. This is
23961 useful when compiling kernel code. A register range is specified as
23962 two registers separated by a dash. Multiple register ranges can be
23963 specified separated by a comma.
23965 @item -mtls-size=@var{tls-size}
23967 Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
23970 @item -mtune=@var{cpu-type}
23972 Tune the instruction scheduling for a particular CPU, Valid values are
23973 @samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
23974 and @samp{mckinley}.
23980 Generate code for a 32-bit or 64-bit environment.
23981 The 32-bit environment sets int, long and pointer to 32 bits.
23982 The 64-bit environment sets int to 32 bits and long and pointer
23983 to 64 bits. These are HP-UX specific flags.
23985 @item -mno-sched-br-data-spec
23986 @itemx -msched-br-data-spec
23987 @opindex mno-sched-br-data-spec
23988 @opindex msched-br-data-spec
23989 (Dis/En)able data speculative scheduling before reload.
23990 This results in generation of @code{ld.a} instructions and
23991 the corresponding check instructions (@code{ld.c} / @code{chk.a}).
23992 The default setting is disabled.
23994 @item -msched-ar-data-spec
23995 @itemx -mno-sched-ar-data-spec
23996 @opindex msched-ar-data-spec
23997 @opindex mno-sched-ar-data-spec
23998 (En/Dis)able data speculative scheduling after reload.
23999 This results in generation of @code{ld.a} instructions and
24000 the corresponding check instructions (@code{ld.c} / @code{chk.a}).
24001 The default setting is enabled.
24003 @item -mno-sched-control-spec
24004 @itemx -msched-control-spec
24005 @opindex mno-sched-control-spec
24006 @opindex msched-control-spec
24007 (Dis/En)able control speculative scheduling. This feature is
24008 available only during region scheduling (i.e.@: before reload).
24009 This results in generation of the @code{ld.s} instructions and
24010 the corresponding check instructions @code{chk.s}.
24011 The default setting is disabled.
24013 @item -msched-br-in-data-spec
24014 @itemx -mno-sched-br-in-data-spec
24015 @opindex msched-br-in-data-spec
24016 @opindex mno-sched-br-in-data-spec
24017 (En/Dis)able speculative scheduling of the instructions that
24018 are dependent on the data speculative loads before reload.
24019 This is effective only with @option{-msched-br-data-spec} enabled.
24020 The default setting is enabled.
24022 @item -msched-ar-in-data-spec
24023 @itemx -mno-sched-ar-in-data-spec
24024 @opindex msched-ar-in-data-spec
24025 @opindex mno-sched-ar-in-data-spec
24026 (En/Dis)able speculative scheduling of the instructions that
24027 are dependent on the data speculative loads after reload.
24028 This is effective only with @option{-msched-ar-data-spec} enabled.
24029 The default setting is enabled.
24031 @item -msched-in-control-spec
24032 @itemx -mno-sched-in-control-spec
24033 @opindex msched-in-control-spec
24034 @opindex mno-sched-in-control-spec
24035 (En/Dis)able speculative scheduling of the instructions that
24036 are dependent on the control speculative loads.
24037 This is effective only with @option{-msched-control-spec} enabled.
24038 The default setting is enabled.
24040 @item -mno-sched-prefer-non-data-spec-insns
24041 @itemx -msched-prefer-non-data-spec-insns
24042 @opindex mno-sched-prefer-non-data-spec-insns
24043 @opindex msched-prefer-non-data-spec-insns
24044 If enabled, data-speculative instructions are chosen for schedule
24045 only if there are no other choices at the moment. This makes
24046 the use of the data speculation much more conservative.
24047 The default setting is disabled.
24049 @item -mno-sched-prefer-non-control-spec-insns
24050 @itemx -msched-prefer-non-control-spec-insns
24051 @opindex mno-sched-prefer-non-control-spec-insns
24052 @opindex msched-prefer-non-control-spec-insns
24053 If enabled, control-speculative instructions are chosen for schedule
24054 only if there are no other choices at the moment. This makes
24055 the use of the control speculation much more conservative.
24056 The default setting is disabled.
24058 @item -mno-sched-count-spec-in-critical-path
24059 @itemx -msched-count-spec-in-critical-path
24060 @opindex mno-sched-count-spec-in-critical-path
24061 @opindex msched-count-spec-in-critical-path
24062 If enabled, speculative dependencies are considered during
24063 computation of the instructions priorities. This makes the use of the
24064 speculation a bit more conservative.
24065 The default setting is disabled.
24067 @item -msched-spec-ldc
24068 @opindex msched-spec-ldc
24069 Use a simple data speculation check. This option is on by default.
24071 @item -msched-control-spec-ldc
24072 @opindex msched-spec-ldc
24073 Use a simple check for control speculation. This option is on by default.
24075 @item -msched-stop-bits-after-every-cycle
24076 @opindex msched-stop-bits-after-every-cycle
24077 Place a stop bit after every cycle when scheduling. This option is on
24080 @item -msched-fp-mem-deps-zero-cost
24081 @opindex msched-fp-mem-deps-zero-cost
24082 Assume that floating-point stores and loads are not likely to cause a conflict
24083 when placed into the same instruction group. This option is disabled by
24086 @item -msel-sched-dont-check-control-spec
24087 @opindex msel-sched-dont-check-control-spec
24088 Generate checks for control speculation in selective scheduling.
24089 This flag is disabled by default.
24091 @item -msched-max-memory-insns=@var{max-insns}
24092 @opindex msched-max-memory-insns
24093 Limit on the number of memory insns per instruction group, giving lower
24094 priority to subsequent memory insns attempting to schedule in the same
24095 instruction group. Frequently useful to prevent cache bank conflicts.
24096 The default value is 1.
24098 @item -msched-max-memory-insns-hard-limit
24099 @opindex msched-max-memory-insns-hard-limit
24100 Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
24101 disallowing more than that number in an instruction group.
24102 Otherwise, the limit is ``soft'', meaning that non-memory operations
24103 are preferred when the limit is reached, but memory operations may still
24109 @subsection LM32 Options
24110 @cindex LM32 options
24112 These @option{-m} options are defined for the LatticeMico32 architecture:
24115 @item -mbarrel-shift-enabled
24116 @opindex mbarrel-shift-enabled
24117 Enable barrel-shift instructions.
24119 @item -mdivide-enabled
24120 @opindex mdivide-enabled
24121 Enable divide and modulus instructions.
24123 @item -mmultiply-enabled
24124 @opindex multiply-enabled
24125 Enable multiply instructions.
24127 @item -msign-extend-enabled
24128 @opindex msign-extend-enabled
24129 Enable sign extend instructions.
24131 @item -muser-enabled
24132 @opindex muser-enabled
24133 Enable user-defined instructions.
24138 @subsection M32C Options
24139 @cindex M32C options
24142 @item -mcpu=@var{name}
24144 Select the CPU for which code is generated. @var{name} may be one of
24145 @samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
24146 /60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
24147 the M32C/80 series.
24151 Specifies that the program will be run on the simulator. This causes
24152 an alternate runtime library to be linked in which supports, for
24153 example, file I/O@. You must not use this option when generating
24154 programs that will run on real hardware; you must provide your own
24155 runtime library for whatever I/O functions are needed.
24157 @item -memregs=@var{number}
24159 Specifies the number of memory-based pseudo-registers GCC uses
24160 during code generation. These pseudo-registers are used like real
24161 registers, so there is a tradeoff between GCC's ability to fit the
24162 code into available registers, and the performance penalty of using
24163 memory instead of registers. Note that all modules in a program must
24164 be compiled with the same value for this option. Because of that, you
24165 must not use this option with GCC's default runtime libraries.
24169 @node M32R/D Options
24170 @subsection M32R/D Options
24171 @cindex M32R/D options
24173 These @option{-m} options are defined for Renesas M32R/D architectures:
24178 Generate code for the M32R/2@.
24182 Generate code for the M32R/X@.
24186 Generate code for the M32R@. This is the default.
24188 @item -mmodel=small
24189 @opindex mmodel=small
24190 Assume all objects live in the lower 16MB of memory (so that their addresses
24191 can be loaded with the @code{ld24} instruction), and assume all subroutines
24192 are reachable with the @code{bl} instruction.
24193 This is the default.
24195 The addressability of a particular object can be set with the
24196 @code{model} attribute.
24198 @item -mmodel=medium
24199 @opindex mmodel=medium
24200 Assume objects may be anywhere in the 32-bit address space (the compiler
24201 generates @code{seth/add3} instructions to load their addresses), and
24202 assume all subroutines are reachable with the @code{bl} instruction.
24204 @item -mmodel=large
24205 @opindex mmodel=large
24206 Assume objects may be anywhere in the 32-bit address space (the compiler
24207 generates @code{seth/add3} instructions to load their addresses), and
24208 assume subroutines may not be reachable with the @code{bl} instruction
24209 (the compiler generates the much slower @code{seth/add3/jl}
24210 instruction sequence).
24213 @opindex msdata=none
24214 Disable use of the small data area. Variables are put into
24215 one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
24216 @code{section} attribute has been specified).
24217 This is the default.
24219 The small data area consists of sections @code{.sdata} and @code{.sbss}.
24220 Objects may be explicitly put in the small data area with the
24221 @code{section} attribute using one of these sections.
24223 @item -msdata=sdata
24224 @opindex msdata=sdata
24225 Put small global and static data in the small data area, but do not
24226 generate special code to reference them.
24229 @opindex msdata=use
24230 Put small global and static data in the small data area, and generate
24231 special instructions to reference them.
24235 @cindex smaller data references
24236 Put global and static objects less than or equal to @var{num} bytes
24237 into the small data or BSS sections instead of the normal data or BSS
24238 sections. The default value of @var{num} is 8.
24239 The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
24240 for this option to have any effect.
24242 All modules should be compiled with the same @option{-G @var{num}} value.
24243 Compiling with different values of @var{num} may or may not work; if it
24244 doesn't the linker gives an error message---incorrect code is not
24249 Makes the M32R-specific code in the compiler display some statistics
24250 that might help in debugging programs.
24252 @item -malign-loops
24253 @opindex malign-loops
24254 Align all loops to a 32-byte boundary.
24256 @item -mno-align-loops
24257 @opindex mno-align-loops
24258 Do not enforce a 32-byte alignment for loops. This is the default.
24260 @item -missue-rate=@var{number}
24261 @opindex missue-rate=@var{number}
24262 Issue @var{number} instructions per cycle. @var{number} can only be 1
24265 @item -mbranch-cost=@var{number}
24266 @opindex mbranch-cost=@var{number}
24267 @var{number} can only be 1 or 2. If it is 1 then branches are
24268 preferred over conditional code, if it is 2, then the opposite applies.
24270 @item -mflush-trap=@var{number}
24271 @opindex mflush-trap=@var{number}
24272 Specifies the trap number to use to flush the cache. The default is
24273 12. Valid numbers are between 0 and 15 inclusive.
24275 @item -mno-flush-trap
24276 @opindex mno-flush-trap
24277 Specifies that the cache cannot be flushed by using a trap.
24279 @item -mflush-func=@var{name}
24280 @opindex mflush-func=@var{name}
24281 Specifies the name of the operating system function to call to flush
24282 the cache. The default is @samp{_flush_cache}, but a function call
24283 is only used if a trap is not available.
24285 @item -mno-flush-func
24286 @opindex mno-flush-func
24287 Indicates that there is no OS function for flushing the cache.
24291 @node M680x0 Options
24292 @subsection M680x0 Options
24293 @cindex M680x0 options
24295 These are the @samp{-m} options defined for M680x0 and ColdFire processors.
24296 The default settings depend on which architecture was selected when
24297 the compiler was configured; the defaults for the most common choices
24301 @item -march=@var{arch}
24303 Generate code for a specific M680x0 or ColdFire instruction set
24304 architecture. Permissible values of @var{arch} for M680x0
24305 architectures are: @samp{68000}, @samp{68010}, @samp{68020},
24306 @samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
24307 architectures are selected according to Freescale's ISA classification
24308 and the permissible values are: @samp{isaa}, @samp{isaaplus},
24309 @samp{isab} and @samp{isac}.
24311 GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
24312 code for a ColdFire target. The @var{arch} in this macro is one of the
24313 @option{-march} arguments given above.
24315 When used together, @option{-march} and @option{-mtune} select code
24316 that runs on a family of similar processors but that is optimized
24317 for a particular microarchitecture.
24319 @item -mcpu=@var{cpu}
24321 Generate code for a specific M680x0 or ColdFire processor.
24322 The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
24323 @samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
24324 and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
24325 below, which also classifies the CPUs into families:
24327 @multitable @columnfractions 0.20 0.80
24328 @headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
24329 @item @samp{51} @tab @samp{51} @samp{51ac} @samp{51ag} @samp{51cn} @samp{51em} @samp{51je} @samp{51jf} @samp{51jg} @samp{51jm} @samp{51mm} @samp{51qe} @samp{51qm}
24330 @item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
24331 @item @samp{5206e} @tab @samp{5206e}
24332 @item @samp{5208} @tab @samp{5207} @samp{5208}
24333 @item @samp{5211a} @tab @samp{5210a} @samp{5211a}
24334 @item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
24335 @item @samp{5216} @tab @samp{5214} @samp{5216}
24336 @item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
24337 @item @samp{5225} @tab @samp{5224} @samp{5225}
24338 @item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
24339 @item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
24340 @item @samp{5249} @tab @samp{5249}
24341 @item @samp{5250} @tab @samp{5250}
24342 @item @samp{5271} @tab @samp{5270} @samp{5271}
24343 @item @samp{5272} @tab @samp{5272}
24344 @item @samp{5275} @tab @samp{5274} @samp{5275}
24345 @item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
24346 @item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
24347 @item @samp{5307} @tab @samp{5307}
24348 @item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
24349 @item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
24350 @item @samp{5407} @tab @samp{5407}
24351 @item @samp{5475} @tab @samp{5470} @samp{5471} @samp{5472} @samp{5473} @samp{5474} @samp{5475} @samp{547x} @samp{5480} @samp{5481} @samp{5482} @samp{5483} @samp{5484} @samp{5485}
24354 @option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
24355 @var{arch} is compatible with @var{cpu}. Other combinations of
24356 @option{-mcpu} and @option{-march} are rejected.
24358 GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
24359 @var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
24360 where the value of @var{family} is given by the table above.
24362 @item -mtune=@var{tune}
24364 Tune the code for a particular microarchitecture within the
24365 constraints set by @option{-march} and @option{-mcpu}.
24366 The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
24367 @samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
24368 and @samp{cpu32}. The ColdFire microarchitectures
24369 are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
24371 You can also use @option{-mtune=68020-40} for code that needs
24372 to run relatively well on 68020, 68030 and 68040 targets.
24373 @option{-mtune=68020-60} is similar but includes 68060 targets
24374 as well. These two options select the same tuning decisions as
24375 @option{-m68020-40} and @option{-m68020-60} respectively.
24377 GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
24378 when tuning for 680x0 architecture @var{arch}. It also defines
24379 @code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
24380 option is used. If GCC is tuning for a range of architectures,
24381 as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
24382 it defines the macros for every architecture in the range.
24384 GCC also defines the macro @code{__m@var{uarch}__} when tuning for
24385 ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
24386 of the arguments given above.
24392 Generate output for a 68000. This is the default
24393 when the compiler is configured for 68000-based systems.
24394 It is equivalent to @option{-march=68000}.
24396 Use this option for microcontrollers with a 68000 or EC000 core,
24397 including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
24401 Generate output for a 68010. This is the default
24402 when the compiler is configured for 68010-based systems.
24403 It is equivalent to @option{-march=68010}.
24409 Generate output for a 68020. This is the default
24410 when the compiler is configured for 68020-based systems.
24411 It is equivalent to @option{-march=68020}.
24415 Generate output for a 68030. This is the default when the compiler is
24416 configured for 68030-based systems. It is equivalent to
24417 @option{-march=68030}.
24421 Generate output for a 68040. This is the default when the compiler is
24422 configured for 68040-based systems. It is equivalent to
24423 @option{-march=68040}.
24425 This option inhibits the use of 68881/68882 instructions that have to be
24426 emulated by software on the 68040. Use this option if your 68040 does not
24427 have code to emulate those instructions.
24431 Generate output for a 68060. This is the default when the compiler is
24432 configured for 68060-based systems. It is equivalent to
24433 @option{-march=68060}.
24435 This option inhibits the use of 68020 and 68881/68882 instructions that
24436 have to be emulated by software on the 68060. Use this option if your 68060
24437 does not have code to emulate those instructions.
24441 Generate output for a CPU32. This is the default
24442 when the compiler is configured for CPU32-based systems.
24443 It is equivalent to @option{-march=cpu32}.
24445 Use this option for microcontrollers with a
24446 CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
24447 68336, 68340, 68341, 68349 and 68360.
24451 Generate output for a 520X ColdFire CPU@. This is the default
24452 when the compiler is configured for 520X-based systems.
24453 It is equivalent to @option{-mcpu=5206}, and is now deprecated
24454 in favor of that option.
24456 Use this option for microcontroller with a 5200 core, including
24457 the MCF5202, MCF5203, MCF5204 and MCF5206.
24461 Generate output for a 5206e ColdFire CPU@. The option is now
24462 deprecated in favor of the equivalent @option{-mcpu=5206e}.
24466 Generate output for a member of the ColdFire 528X family.
24467 The option is now deprecated in favor of the equivalent
24468 @option{-mcpu=528x}.
24472 Generate output for a ColdFire 5307 CPU@. The option is now deprecated
24473 in favor of the equivalent @option{-mcpu=5307}.
24477 Generate output for a ColdFire 5407 CPU@. The option is now deprecated
24478 in favor of the equivalent @option{-mcpu=5407}.
24482 Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
24483 This includes use of hardware floating-point instructions.
24484 The option is equivalent to @option{-mcpu=547x}, and is now
24485 deprecated in favor of that option.
24489 Generate output for a 68040, without using any of the new instructions.
24490 This results in code that can run relatively efficiently on either a
24491 68020/68881 or a 68030 or a 68040. The generated code does use the
24492 68881 instructions that are emulated on the 68040.
24494 The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
24498 Generate output for a 68060, without using any of the new instructions.
24499 This results in code that can run relatively efficiently on either a
24500 68020/68881 or a 68030 or a 68040. The generated code does use the
24501 68881 instructions that are emulated on the 68060.
24503 The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
24507 @opindex mhard-float
24509 Generate floating-point instructions. This is the default for 68020
24510 and above, and for ColdFire devices that have an FPU@. It defines the
24511 macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
24512 on ColdFire targets.
24515 @opindex msoft-float
24516 Do not generate floating-point instructions; use library calls instead.
24517 This is the default for 68000, 68010, and 68832 targets. It is also
24518 the default for ColdFire devices that have no FPU.
24524 Generate (do not generate) ColdFire hardware divide and remainder
24525 instructions. If @option{-march} is used without @option{-mcpu},
24526 the default is ``on'' for ColdFire architectures and ``off'' for M680x0
24527 architectures. Otherwise, the default is taken from the target CPU
24528 (either the default CPU, or the one specified by @option{-mcpu}). For
24529 example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
24530 @option{-mcpu=5206e}.
24532 GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
24536 Consider type @code{int} to be 16 bits wide, like @code{short int}.
24537 Additionally, parameters passed on the stack are also aligned to a
24538 16-bit boundary even on targets whose API mandates promotion to 32-bit.
24542 Do not consider type @code{int} to be 16 bits wide. This is the default.
24545 @itemx -mno-bitfield
24546 @opindex mnobitfield
24547 @opindex mno-bitfield
24548 Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
24549 and @option{-m5200} options imply @w{@option{-mnobitfield}}.
24553 Do use the bit-field instructions. The @option{-m68020} option implies
24554 @option{-mbitfield}. This is the default if you use a configuration
24555 designed for a 68020.
24559 Use a different function-calling convention, in which functions
24560 that take a fixed number of arguments return with the @code{rtd}
24561 instruction, which pops their arguments while returning. This
24562 saves one instruction in the caller since there is no need to pop
24563 the arguments there.
24565 This calling convention is incompatible with the one normally
24566 used on Unix, so you cannot use it if you need to call libraries
24567 compiled with the Unix compiler.
24569 Also, you must provide function prototypes for all functions that
24570 take variable numbers of arguments (including @code{printf});
24571 otherwise incorrect code is generated for calls to those
24574 In addition, seriously incorrect code results if you call a
24575 function with too many arguments. (Normally, extra arguments are
24576 harmlessly ignored.)
24578 The @code{rtd} instruction is supported by the 68010, 68020, 68030,
24579 68040, 68060 and CPU32 processors, but not by the 68000 or 5200.
24581 The default is @option{-mno-rtd}.
24584 @itemx -mno-align-int
24585 @opindex malign-int
24586 @opindex mno-align-int
24587 Control whether GCC aligns @code{int}, @code{long}, @code{long long},
24588 @code{float}, @code{double}, and @code{long double} variables on a 32-bit
24589 boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
24590 Aligning variables on 32-bit boundaries produces code that runs somewhat
24591 faster on processors with 32-bit busses at the expense of more memory.
24593 @strong{Warning:} if you use the @option{-malign-int} switch, GCC
24594 aligns structures containing the above types differently than
24595 most published application binary interface specifications for the m68k.
24598 Use the pc-relative addressing mode of the 68000 directly, instead of
24599 using a global offset table. At present, this option implies @option{-fpic},
24600 allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
24601 not presently supported with @option{-mpcrel}, though this could be supported for
24602 68020 and higher processors.
24604 @item -mno-strict-align
24605 @itemx -mstrict-align
24606 @opindex mno-strict-align
24607 @opindex mstrict-align
24608 Do not (do) assume that unaligned memory references are handled by
24612 Generate code that allows the data segment to be located in a different
24613 area of memory from the text segment. This allows for execute-in-place in
24614 an environment without virtual memory management. This option implies
24617 @item -mno-sep-data
24618 Generate code that assumes that the data segment follows the text segment.
24619 This is the default.
24621 @item -mid-shared-library
24622 Generate code that supports shared libraries via the library ID method.
24623 This allows for execute-in-place and shared libraries in an environment
24624 without virtual memory management. This option implies @option{-fPIC}.
24626 @item -mno-id-shared-library
24627 Generate code that doesn't assume ID-based shared libraries are being used.
24628 This is the default.
24630 @item -mshared-library-id=n
24631 Specifies the identification number of the ID-based shared library being
24632 compiled. Specifying a value of 0 generates more compact code; specifying
24633 other values forces the allocation of that number to the current
24634 library, but is no more space- or time-efficient than omitting this option.
24640 When generating position-independent code for ColdFire, generate code
24641 that works if the GOT has more than 8192 entries. This code is
24642 larger and slower than code generated without this option. On M680x0
24643 processors, this option is not needed; @option{-fPIC} suffices.
24645 GCC normally uses a single instruction to load values from the GOT@.
24646 While this is relatively efficient, it only works if the GOT
24647 is smaller than about 64k. Anything larger causes the linker
24648 to report an error such as:
24650 @cindex relocation truncated to fit (ColdFire)
24652 relocation truncated to fit: R_68K_GOT16O foobar
24655 If this happens, you should recompile your code with @option{-mxgot}.
24656 It should then work with very large GOTs. However, code generated with
24657 @option{-mxgot} is less efficient, since it takes 4 instructions to fetch
24658 the value of a global symbol.
24660 Note that some linkers, including newer versions of the GNU linker,
24661 can create multiple GOTs and sort GOT entries. If you have such a linker,
24662 you should only need to use @option{-mxgot} when compiling a single
24663 object file that accesses more than 8192 GOT entries. Very few do.
24665 These options have no effect unless GCC is generating
24666 position-independent code.
24668 @item -mlong-jump-table-offsets
24669 @opindex mlong-jump-table-offsets
24670 Use 32-bit offsets in @code{switch} tables. The default is to use
24675 @node MCore Options
24676 @subsection MCore Options
24677 @cindex MCore options
24679 These are the @samp{-m} options defined for the Motorola M*Core
24685 @itemx -mno-hardlit
24687 @opindex mno-hardlit
24688 Inline constants into the code stream if it can be done in two
24689 instructions or less.
24695 Use the divide instruction. (Enabled by default).
24697 @item -mrelax-immediate
24698 @itemx -mno-relax-immediate
24699 @opindex mrelax-immediate
24700 @opindex mno-relax-immediate
24701 Allow arbitrary-sized immediates in bit operations.
24703 @item -mwide-bitfields
24704 @itemx -mno-wide-bitfields
24705 @opindex mwide-bitfields
24706 @opindex mno-wide-bitfields
24707 Always treat bit-fields as @code{int}-sized.
24709 @item -m4byte-functions
24710 @itemx -mno-4byte-functions
24711 @opindex m4byte-functions
24712 @opindex mno-4byte-functions
24713 Force all functions to be aligned to a 4-byte boundary.
24715 @item -mcallgraph-data
24716 @itemx -mno-callgraph-data
24717 @opindex mcallgraph-data
24718 @opindex mno-callgraph-data
24719 Emit callgraph information.
24722 @itemx -mno-slow-bytes
24723 @opindex mslow-bytes
24724 @opindex mno-slow-bytes
24725 Prefer word access when reading byte quantities.
24727 @item -mlittle-endian
24728 @itemx -mbig-endian
24729 @opindex mlittle-endian
24730 @opindex mbig-endian
24731 Generate code for a little-endian target.
24737 Generate code for the 210 processor.
24741 Assume that runtime support has been provided and so omit the
24742 simulator library (@file{libsim.a)} from the linker command line.
24744 @item -mstack-increment=@var{size}
24745 @opindex mstack-increment
24746 Set the maximum amount for a single stack increment operation. Large
24747 values can increase the speed of programs that contain functions
24748 that need a large amount of stack space, but they can also trigger a
24749 segmentation fault if the stack is extended too much. The default
24755 @subsection MeP Options
24756 @cindex MeP options
24762 Enables the @code{abs} instruction, which is the absolute difference
24763 between two registers.
24767 Enables all the optional instructions---average, multiply, divide, bit
24768 operations, leading zero, absolute difference, min/max, clip, and
24774 Enables the @code{ave} instruction, which computes the average of two
24777 @item -mbased=@var{n}
24779 Variables of size @var{n} bytes or smaller are placed in the
24780 @code{.based} section by default. Based variables use the @code{$tp}
24781 register as a base register, and there is a 128-byte limit to the
24782 @code{.based} section.
24786 Enables the bit operation instructions---bit test (@code{btstm}), set
24787 (@code{bsetm}), clear (@code{bclrm}), invert (@code{bnotm}), and
24788 test-and-set (@code{tas}).
24790 @item -mc=@var{name}
24792 Selects which section constant data is placed in. @var{name} may
24793 be @samp{tiny}, @samp{near}, or @samp{far}.
24797 Enables the @code{clip} instruction. Note that @option{-mclip} is not
24798 useful unless you also provide @option{-mminmax}.
24800 @item -mconfig=@var{name}
24802 Selects one of the built-in core configurations. Each MeP chip has
24803 one or more modules in it; each module has a core CPU and a variety of
24804 coprocessors, optional instructions, and peripherals. The
24805 @code{MeP-Integrator} tool, not part of GCC, provides these
24806 configurations through this option; using this option is the same as
24807 using all the corresponding command-line options. The default
24808 configuration is @samp{default}.
24812 Enables the coprocessor instructions. By default, this is a 32-bit
24813 coprocessor. Note that the coprocessor is normally enabled via the
24814 @option{-mconfig=} option.
24818 Enables the 32-bit coprocessor's instructions.
24822 Enables the 64-bit coprocessor's instructions.
24826 Enables IVC2 scheduling. IVC2 is a 64-bit VLIW coprocessor.
24830 Causes constant variables to be placed in the @code{.near} section.
24834 Enables the @code{div} and @code{divu} instructions.
24838 Generate big-endian code.
24842 Generate little-endian code.
24844 @item -mio-volatile
24845 @opindex mio-volatile
24846 Tells the compiler that any variable marked with the @code{io}
24847 attribute is to be considered volatile.
24851 Causes variables to be assigned to the @code{.far} section by default.
24855 Enables the @code{leadz} (leading zero) instruction.
24859 Causes variables to be assigned to the @code{.near} section by default.
24863 Enables the @code{min} and @code{max} instructions.
24867 Enables the multiplication and multiply-accumulate instructions.
24871 Disables all the optional instructions enabled by @option{-mall-opts}.
24875 Enables the @code{repeat} and @code{erepeat} instructions, used for
24876 low-overhead looping.
24880 Causes all variables to default to the @code{.tiny} section. Note
24881 that there is a 65536-byte limit to this section. Accesses to these
24882 variables use the @code{%gp} base register.
24886 Enables the saturation instructions. Note that the compiler does not
24887 currently generate these itself, but this option is included for
24888 compatibility with other tools, like @code{as}.
24892 Link the SDRAM-based runtime instead of the default ROM-based runtime.
24896 Link the simulator run-time libraries.
24900 Link the simulator runtime libraries, excluding built-in support
24901 for reset and exception vectors and tables.
24905 Causes all functions to default to the @code{.far} section. Without
24906 this option, functions default to the @code{.near} section.
24908 @item -mtiny=@var{n}
24910 Variables that are @var{n} bytes or smaller are allocated to the
24911 @code{.tiny} section. These variables use the @code{$gp} base
24912 register. The default for this option is 4, but note that there's a
24913 65536-byte limit to the @code{.tiny} section.
24917 @node MicroBlaze Options
24918 @subsection MicroBlaze Options
24919 @cindex MicroBlaze Options
24924 @opindex msoft-float
24925 Use software emulation for floating point (default).
24928 @opindex mhard-float
24929 Use hardware floating-point instructions.
24933 Do not optimize block moves, use @code{memcpy}.
24935 @item -mno-clearbss
24936 @opindex mno-clearbss
24937 This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
24939 @item -mcpu=@var{cpu-type}
24941 Use features of, and schedule code for, the given CPU.
24942 Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
24943 where @var{X} is a major version, @var{YY} is the minor version, and
24944 @var{Z} is compatibility code. Example values are @samp{v3.00.a},
24945 @samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
24947 @item -mxl-soft-mul
24948 @opindex mxl-soft-mul
24949 Use software multiply emulation (default).
24951 @item -mxl-soft-div
24952 @opindex mxl-soft-div
24953 Use software emulation for divides (default).
24955 @item -mxl-barrel-shift
24956 @opindex mxl-barrel-shift
24957 Use the hardware barrel shifter.
24959 @item -mxl-pattern-compare
24960 @opindex mxl-pattern-compare
24961 Use pattern compare instructions.
24963 @item -msmall-divides
24964 @opindex msmall-divides
24965 Use table lookup optimization for small signed integer divisions.
24967 @item -mxl-stack-check
24968 @opindex mxl-stack-check
24969 This option is deprecated. Use @option{-fstack-check} instead.
24972 @opindex mxl-gp-opt
24973 Use GP-relative @code{.sdata}/@code{.sbss} sections.
24975 @item -mxl-multiply-high
24976 @opindex mxl-multiply-high
24977 Use multiply high instructions for high part of 32x32 multiply.
24979 @item -mxl-float-convert
24980 @opindex mxl-float-convert
24981 Use hardware floating-point conversion instructions.
24983 @item -mxl-float-sqrt
24984 @opindex mxl-float-sqrt
24985 Use hardware floating-point square root instruction.
24988 @opindex mbig-endian
24989 Generate code for a big-endian target.
24991 @item -mlittle-endian
24992 @opindex mlittle-endian
24993 Generate code for a little-endian target.
24996 @opindex mxl-reorder
24997 Use reorder instructions (swap and byte reversed load/store).
24999 @item -mxl-mode-@var{app-model}
25000 Select application model @var{app-model}. Valid models are
25003 normal executable (default), uses startup code @file{crt0.o}.
25006 for use with Xilinx Microprocessor Debugger (XMD) based
25007 software intrusive debug agent called xmdstub. This uses startup file
25008 @file{crt1.o} and sets the start address of the program to 0x800.
25011 for applications that are loaded using a bootloader.
25012 This model uses startup file @file{crt2.o} which does not contain a processor
25013 reset vector handler. This is suitable for transferring control on a
25014 processor reset to the bootloader rather than the application.
25017 for applications that do not require any of the
25018 MicroBlaze vectors. This option may be useful for applications running
25019 within a monitoring application. This model uses @file{crt3.o} as a startup file.
25022 Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
25023 @option{-mxl-mode-@var{app-model}}.
25025 @item -mpic-data-is-text-relative
25026 @opindex mpic-data-is-text-relative
25027 Assume that the displacement between the text and data segments is fixed
25028 at static link time. This allows data to be referenced by offset from start of
25029 text address instead of GOT since PC-relative addressing is not supported.
25034 @subsection MIPS Options
25035 @cindex MIPS options
25041 Generate big-endian code.
25045 Generate little-endian code. This is the default for @samp{mips*el-*-*}
25048 @item -march=@var{arch}
25050 Generate code that runs on @var{arch}, which can be the name of a
25051 generic MIPS ISA, or the name of a particular processor.
25053 @samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
25054 @samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
25055 @samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
25056 @samp{mips64r5} and @samp{mips64r6}.
25057 The processor names are:
25058 @samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
25059 @samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
25060 @samp{5kc}, @samp{5kf},
25062 @samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
25063 @samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
25064 @samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
25065 @samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
25066 @samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
25067 @samp{i6400}, @samp{i6500},
25069 @samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
25070 @samp{gs464e}, @samp{gs264e},
25072 @samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
25073 @samp{m5100}, @samp{m5101},
25074 @samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
25076 @samp{p5600}, @samp{p6600},
25077 @samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
25078 @samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
25079 @samp{r6000}, @samp{r8000},
25080 @samp{rm7000}, @samp{rm9000},
25081 @samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
25084 @samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
25085 @samp{vr5000}, @samp{vr5400}, @samp{vr5500},
25086 @samp{xlr} and @samp{xlp}.
25087 The special value @samp{from-abi} selects the
25088 most compatible architecture for the selected ABI (that is,
25089 @samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
25091 The native Linux/GNU toolchain also supports the value @samp{native},
25092 which selects the best architecture option for the host processor.
25093 @option{-march=native} has no effect if GCC does not recognize
25096 In processor names, a final @samp{000} can be abbreviated as @samp{k}
25097 (for example, @option{-march=r2k}). Prefixes are optional, and
25098 @samp{vr} may be written @samp{r}.
25100 Names of the form @samp{@var{n}f2_1} refer to processors with
25101 FPUs clocked at half the rate of the core, names of the form
25102 @samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
25103 rate as the core, and names of the form @samp{@var{n}f3_2} refer to
25104 processors with FPUs clocked a ratio of 3:2 with respect to the core.
25105 For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
25106 for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
25107 accepted as synonyms for @samp{@var{n}f1_1}.
25109 GCC defines two macros based on the value of this option. The first
25110 is @code{_MIPS_ARCH}, which gives the name of target architecture, as
25111 a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
25112 where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
25113 For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
25114 to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
25116 Note that the @code{_MIPS_ARCH} macro uses the processor names given
25117 above. In other words, it has the full prefix and does not
25118 abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
25119 the macro names the resolved architecture (either @code{"mips1"} or
25120 @code{"mips3"}). It names the default architecture when no
25121 @option{-march} option is given.
25123 @item -mtune=@var{arch}
25125 Optimize for @var{arch}. Among other things, this option controls
25126 the way instructions are scheduled, and the perceived cost of arithmetic
25127 operations. The list of @var{arch} values is the same as for
25130 When this option is not used, GCC optimizes for the processor
25131 specified by @option{-march}. By using @option{-march} and
25132 @option{-mtune} together, it is possible to generate code that
25133 runs on a family of processors, but optimize the code for one
25134 particular member of that family.
25136 @option{-mtune} defines the macros @code{_MIPS_TUNE} and
25137 @code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
25138 @option{-march} ones described above.
25142 Equivalent to @option{-march=mips1}.
25146 Equivalent to @option{-march=mips2}.
25150 Equivalent to @option{-march=mips3}.
25154 Equivalent to @option{-march=mips4}.
25158 Equivalent to @option{-march=mips32}.
25162 Equivalent to @option{-march=mips32r3}.
25166 Equivalent to @option{-march=mips32r5}.
25170 Equivalent to @option{-march=mips32r6}.
25174 Equivalent to @option{-march=mips64}.
25178 Equivalent to @option{-march=mips64r2}.
25182 Equivalent to @option{-march=mips64r3}.
25186 Equivalent to @option{-march=mips64r5}.
25190 Equivalent to @option{-march=mips64r6}.
25195 @opindex mno-mips16
25196 Generate (do not generate) MIPS16 code. If GCC is targeting a
25197 MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
25199 MIPS16 code generation can also be controlled on a per-function basis
25200 by means of @code{mips16} and @code{nomips16} attributes.
25201 @xref{Function Attributes}, for more information.
25203 @item -mflip-mips16
25204 @opindex mflip-mips16
25205 Generate MIPS16 code on alternating functions. This option is provided
25206 for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
25207 not intended for ordinary use in compiling user code.
25209 @item -minterlink-compressed
25210 @itemx -mno-interlink-compressed
25211 @opindex minterlink-compressed
25212 @opindex mno-interlink-compressed
25213 Require (do not require) that code using the standard (uncompressed) MIPS ISA
25214 be link-compatible with MIPS16 and microMIPS code, and vice versa.
25216 For example, code using the standard ISA encoding cannot jump directly
25217 to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
25218 @option{-minterlink-compressed} therefore disables direct jumps unless GCC
25219 knows that the target of the jump is not compressed.
25221 @item -minterlink-mips16
25222 @itemx -mno-interlink-mips16
25223 @opindex minterlink-mips16
25224 @opindex mno-interlink-mips16
25225 Aliases of @option{-minterlink-compressed} and
25226 @option{-mno-interlink-compressed}. These options predate the microMIPS ASE
25227 and are retained for backwards compatibility.
25239 Generate code for the given ABI@.
25241 Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
25242 generates 64-bit code when you select a 64-bit architecture, but you
25243 can use @option{-mgp32} to get 32-bit code instead.
25245 For information about the O64 ABI, see
25246 @uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
25248 GCC supports a variant of the o32 ABI in which floating-point registers
25249 are 64 rather than 32 bits wide. You can select this combination with
25250 @option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
25251 and @code{mfhc1} instructions and is therefore only supported for
25252 MIPS32R2, MIPS32R3 and MIPS32R5 processors.
25254 The register assignments for arguments and return values remain the
25255 same, but each scalar value is passed in a single 64-bit register
25256 rather than a pair of 32-bit registers. For example, scalar
25257 floating-point values are returned in @samp{$f0} only, not a
25258 @samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
25259 remains the same in that the even-numbered double-precision registers
25262 Two additional variants of the o32 ABI are supported to enable
25263 a transition from 32-bit to 64-bit registers. These are FPXX
25264 (@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
25265 The FPXX extension mandates that all code must execute correctly
25266 when run using 32-bit or 64-bit registers. The code can be interlinked
25267 with either FP32 or FP64, but not both.
25268 The FP64A extension is similar to the FP64 extension but forbids the
25269 use of odd-numbered single-precision registers. This can be used
25270 in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
25271 processors and allows both FP32 and FP64A code to interlink and
25272 run in the same process without changing FPU modes.
25275 @itemx -mno-abicalls
25277 @opindex mno-abicalls
25278 Generate (do not generate) code that is suitable for SVR4-style
25279 dynamic objects. @option{-mabicalls} is the default for SVR4-based
25284 Generate (do not generate) code that is fully position-independent,
25285 and that can therefore be linked into shared libraries. This option
25286 only affects @option{-mabicalls}.
25288 All @option{-mabicalls} code has traditionally been position-independent,
25289 regardless of options like @option{-fPIC} and @option{-fpic}. However,
25290 as an extension, the GNU toolchain allows executables to use absolute
25291 accesses for locally-binding symbols. It can also use shorter GP
25292 initialization sequences and generate direct calls to locally-defined
25293 functions. This mode is selected by @option{-mno-shared}.
25295 @option{-mno-shared} depends on binutils 2.16 or higher and generates
25296 objects that can only be linked by the GNU linker. However, the option
25297 does not affect the ABI of the final executable; it only affects the ABI
25298 of relocatable objects. Using @option{-mno-shared} generally makes
25299 executables both smaller and quicker.
25301 @option{-mshared} is the default.
25307 Assume (do not assume) that the static and dynamic linkers
25308 support PLTs and copy relocations. This option only affects
25309 @option{-mno-shared -mabicalls}. For the n64 ABI, this option
25310 has no effect without @option{-msym32}.
25312 You can make @option{-mplt} the default by configuring
25313 GCC with @option{--with-mips-plt}. The default is
25314 @option{-mno-plt} otherwise.
25320 Lift (do not lift) the usual restrictions on the size of the global
25323 GCC normally uses a single instruction to load values from the GOT@.
25324 While this is relatively efficient, it only works if the GOT
25325 is smaller than about 64k. Anything larger causes the linker
25326 to report an error such as:
25328 @cindex relocation truncated to fit (MIPS)
25330 relocation truncated to fit: R_MIPS_GOT16 foobar
25333 If this happens, you should recompile your code with @option{-mxgot}.
25334 This works with very large GOTs, although the code is also
25335 less efficient, since it takes three instructions to fetch the
25336 value of a global symbol.
25338 Note that some linkers can create multiple GOTs. If you have such a
25339 linker, you should only need to use @option{-mxgot} when a single object
25340 file accesses more than 64k's worth of GOT entries. Very few do.
25342 These options have no effect unless GCC is generating position
25347 Assume that general-purpose registers are 32 bits wide.
25351 Assume that general-purpose registers are 64 bits wide.
25355 Assume that floating-point registers are 32 bits wide.
25359 Assume that floating-point registers are 64 bits wide.
25363 Do not assume the width of floating-point registers.
25366 @opindex mhard-float
25367 Use floating-point coprocessor instructions.
25370 @opindex msoft-float
25371 Do not use floating-point coprocessor instructions. Implement
25372 floating-point calculations using library calls instead.
25376 Equivalent to @option{-msoft-float}, but additionally asserts that the
25377 program being compiled does not perform any floating-point operations.
25378 This option is presently supported only by some bare-metal MIPS
25379 configurations, where it may select a special set of libraries
25380 that lack all floating-point support (including, for example, the
25381 floating-point @code{printf} formats).
25382 If code compiled with @option{-mno-float} accidentally contains
25383 floating-point operations, it is likely to suffer a link-time
25384 or run-time failure.
25386 @item -msingle-float
25387 @opindex msingle-float
25388 Assume that the floating-point coprocessor only supports single-precision
25391 @item -mdouble-float
25392 @opindex mdouble-float
25393 Assume that the floating-point coprocessor supports double-precision
25394 operations. This is the default.
25397 @itemx -mno-odd-spreg
25398 @opindex modd-spreg
25399 @opindex mno-odd-spreg
25400 Enable the use of odd-numbered single-precision floating-point registers
25401 for the o32 ABI. This is the default for processors that are known to
25402 support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
25406 @itemx -mabs=legacy
25408 @opindex mabs=legacy
25409 These options control the treatment of the special not-a-number (NaN)
25410 IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
25411 @code{neg.@i{fmt}} machine instructions.
25413 By default or when @option{-mabs=legacy} is used the legacy
25414 treatment is selected. In this case these instructions are considered
25415 arithmetic and avoided where correct operation is required and the
25416 input operand might be a NaN. A longer sequence of instructions that
25417 manipulate the sign bit of floating-point datum manually is used
25418 instead unless the @option{-ffinite-math-only} option has also been
25421 The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
25422 this case these instructions are considered non-arithmetic and therefore
25423 operating correctly in all cases, including in particular where the
25424 input operand is a NaN. These instructions are therefore always used
25425 for the respective operations.
25428 @itemx -mnan=legacy
25430 @opindex mnan=legacy
25431 These options control the encoding of the special not-a-number (NaN)
25432 IEEE 754 floating-point data.
25434 The @option{-mnan=legacy} option selects the legacy encoding. In this
25435 case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
25436 significand field being 0, whereas signaling NaNs (sNaNs) are denoted
25437 by the first bit of their trailing significand field being 1.
25439 The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
25440 this case qNaNs are denoted by the first bit of their trailing
25441 significand field being 1, whereas sNaNs are denoted by the first bit of
25442 their trailing significand field being 0.
25444 The default is @option{-mnan=legacy} unless GCC has been configured with
25445 @option{--with-nan=2008}.
25451 Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
25452 implement atomic memory built-in functions. When neither option is
25453 specified, GCC uses the instructions if the target architecture
25456 @option{-mllsc} is useful if the runtime environment can emulate the
25457 instructions and @option{-mno-llsc} can be useful when compiling for
25458 nonstandard ISAs. You can make either option the default by
25459 configuring GCC with @option{--with-llsc} and @option{--without-llsc}
25460 respectively. @option{--with-llsc} is the default for some
25461 configurations; see the installation documentation for details.
25467 Use (do not use) revision 1 of the MIPS DSP ASE@.
25468 @xref{MIPS DSP Built-in Functions}. This option defines the
25469 preprocessor macro @code{__mips_dsp}. It also defines
25470 @code{__mips_dsp_rev} to 1.
25476 Use (do not use) revision 2 of the MIPS DSP ASE@.
25477 @xref{MIPS DSP Built-in Functions}. This option defines the
25478 preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
25479 It also defines @code{__mips_dsp_rev} to 2.
25482 @itemx -mno-smartmips
25483 @opindex msmartmips
25484 @opindex mno-smartmips
25485 Use (do not use) the MIPS SmartMIPS ASE.
25487 @item -mpaired-single
25488 @itemx -mno-paired-single
25489 @opindex mpaired-single
25490 @opindex mno-paired-single
25491 Use (do not use) paired-single floating-point instructions.
25492 @xref{MIPS Paired-Single Support}. This option requires
25493 hardware floating-point support to be enabled.
25499 Use (do not use) MIPS Digital Media Extension instructions.
25500 This option can only be used when generating 64-bit code and requires
25501 hardware floating-point support to be enabled.
25506 @opindex mno-mips3d
25507 Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
25508 The option @option{-mips3d} implies @option{-mpaired-single}.
25511 @itemx -mno-micromips
25512 @opindex mmicromips
25513 @opindex mno-mmicromips
25514 Generate (do not generate) microMIPS code.
25516 MicroMIPS code generation can also be controlled on a per-function basis
25517 by means of @code{micromips} and @code{nomicromips} attributes.
25518 @xref{Function Attributes}, for more information.
25524 Use (do not use) MT Multithreading instructions.
25530 Use (do not use) the MIPS MCU ASE instructions.
25536 Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
25542 Use (do not use) the MIPS Virtualization (VZ) instructions.
25548 Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
25554 Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
25560 Use (do not use) the MIPS Global INValidate (GINV) instructions.
25562 @item -mloongson-mmi
25563 @itemx -mno-loongson-mmi
25564 @opindex mloongson-mmi
25565 @opindex mno-loongson-mmi
25566 Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
25568 @item -mloongson-ext
25569 @itemx -mno-loongson-ext
25570 @opindex mloongson-ext
25571 @opindex mno-loongson-ext
25572 Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
25574 @item -mloongson-ext2
25575 @itemx -mno-loongson-ext2
25576 @opindex mloongson-ext2
25577 @opindex mno-loongson-ext2
25578 Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
25582 Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
25583 an explanation of the default and the way that the pointer size is
25588 Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
25590 The default size of @code{int}s, @code{long}s and pointers depends on
25591 the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
25592 uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
25593 32-bit @code{long}s. Pointers are the same size as @code{long}s,
25594 or the same size as integer registers, whichever is smaller.
25600 Assume (do not assume) that all symbols have 32-bit values, regardless
25601 of the selected ABI@. This option is useful in combination with
25602 @option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
25603 to generate shorter and faster references to symbolic addresses.
25607 Put definitions of externally-visible data in a small data section
25608 if that data is no bigger than @var{num} bytes. GCC can then generate
25609 more efficient accesses to the data; see @option{-mgpopt} for details.
25611 The default @option{-G} option depends on the configuration.
25613 @item -mlocal-sdata
25614 @itemx -mno-local-sdata
25615 @opindex mlocal-sdata
25616 @opindex mno-local-sdata
25617 Extend (do not extend) the @option{-G} behavior to local data too,
25618 such as to static variables in C@. @option{-mlocal-sdata} is the
25619 default for all configurations.
25621 If the linker complains that an application is using too much small data,
25622 you might want to try rebuilding the less performance-critical parts with
25623 @option{-mno-local-sdata}. You might also want to build large
25624 libraries with @option{-mno-local-sdata}, so that the libraries leave
25625 more room for the main program.
25627 @item -mextern-sdata
25628 @itemx -mno-extern-sdata
25629 @opindex mextern-sdata
25630 @opindex mno-extern-sdata
25631 Assume (do not assume) that externally-defined data is in
25632 a small data section if the size of that data is within the @option{-G} limit.
25633 @option{-mextern-sdata} is the default for all configurations.
25635 If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
25636 @var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
25637 that is no bigger than @var{num} bytes, you must make sure that @var{Var}
25638 is placed in a small data section. If @var{Var} is defined by another
25639 module, you must either compile that module with a high-enough
25640 @option{-G} setting or attach a @code{section} attribute to @var{Var}'s
25641 definition. If @var{Var} is common, you must link the application
25642 with a high-enough @option{-G} setting.
25644 The easiest way of satisfying these restrictions is to compile
25645 and link every module with the same @option{-G} option. However,
25646 you may wish to build a library that supports several different
25647 small data limits. You can do this by compiling the library with
25648 the highest supported @option{-G} setting and additionally using
25649 @option{-mno-extern-sdata} to stop the library from making assumptions
25650 about externally-defined data.
25656 Use (do not use) GP-relative accesses for symbols that are known to be
25657 in a small data section; see @option{-G}, @option{-mlocal-sdata} and
25658 @option{-mextern-sdata}. @option{-mgpopt} is the default for all
25661 @option{-mno-gpopt} is useful for cases where the @code{$gp} register
25662 might not hold the value of @code{_gp}. For example, if the code is
25663 part of a library that might be used in a boot monitor, programs that
25664 call boot monitor routines pass an unknown value in @code{$gp}.
25665 (In such situations, the boot monitor itself is usually compiled
25666 with @option{-G0}.)
25668 @option{-mno-gpopt} implies @option{-mno-local-sdata} and
25669 @option{-mno-extern-sdata}.
25671 @item -membedded-data
25672 @itemx -mno-embedded-data
25673 @opindex membedded-data
25674 @opindex mno-embedded-data
25675 Allocate variables to the read-only data section first if possible, then
25676 next in the small data section if possible, otherwise in data. This gives
25677 slightly slower code than the default, but reduces the amount of RAM required
25678 when executing, and thus may be preferred for some embedded systems.
25680 @item -muninit-const-in-rodata
25681 @itemx -mno-uninit-const-in-rodata
25682 @opindex muninit-const-in-rodata
25683 @opindex mno-uninit-const-in-rodata
25684 Put uninitialized @code{const} variables in the read-only data section.
25685 This option is only meaningful in conjunction with @option{-membedded-data}.
25687 @item -mcode-readable=@var{setting}
25688 @opindex mcode-readable
25689 Specify whether GCC may generate code that reads from executable sections.
25690 There are three possible settings:
25693 @item -mcode-readable=yes
25694 Instructions may freely access executable sections. This is the
25697 @item -mcode-readable=pcrel
25698 MIPS16 PC-relative load instructions can access executable sections,
25699 but other instructions must not do so. This option is useful on 4KSc
25700 and 4KSd processors when the code TLBs have the Read Inhibit bit set.
25701 It is also useful on processors that can be configured to have a dual
25702 instruction/data SRAM interface and that, like the M4K, automatically
25703 redirect PC-relative loads to the instruction RAM.
25705 @item -mcode-readable=no
25706 Instructions must not access executable sections. This option can be
25707 useful on targets that are configured to have a dual instruction/data
25708 SRAM interface but that (unlike the M4K) do not automatically redirect
25709 PC-relative loads to the instruction RAM.
25712 @item -msplit-addresses
25713 @itemx -mno-split-addresses
25714 @opindex msplit-addresses
25715 @opindex mno-split-addresses
25716 Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
25717 relocation operators. This option has been superseded by
25718 @option{-mexplicit-relocs} but is retained for backwards compatibility.
25720 @item -mexplicit-relocs
25721 @itemx -mno-explicit-relocs
25722 @opindex mexplicit-relocs
25723 @opindex mno-explicit-relocs
25724 Use (do not use) assembler relocation operators when dealing with symbolic
25725 addresses. The alternative, selected by @option{-mno-explicit-relocs},
25726 is to use assembler macros instead.
25728 @option{-mexplicit-relocs} is the default if GCC was configured
25729 to use an assembler that supports relocation operators.
25731 @item -mcheck-zero-division
25732 @itemx -mno-check-zero-division
25733 @opindex mcheck-zero-division
25734 @opindex mno-check-zero-division
25735 Trap (do not trap) on integer division by zero.
25737 The default is @option{-mcheck-zero-division}.
25739 @item -mdivide-traps
25740 @itemx -mdivide-breaks
25741 @opindex mdivide-traps
25742 @opindex mdivide-breaks
25743 MIPS systems check for division by zero by generating either a
25744 conditional trap or a break instruction. Using traps results in
25745 smaller code, but is only supported on MIPS II and later. Also, some
25746 versions of the Linux kernel have a bug that prevents trap from
25747 generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
25748 allow conditional traps on architectures that support them and
25749 @option{-mdivide-breaks} to force the use of breaks.
25751 The default is usually @option{-mdivide-traps}, but this can be
25752 overridden at configure time using @option{--with-divide=breaks}.
25753 Divide-by-zero checks can be completely disabled using
25754 @option{-mno-check-zero-division}.
25756 @item -mload-store-pairs
25757 @itemx -mno-load-store-pairs
25758 @opindex mload-store-pairs
25759 @opindex mno-load-store-pairs
25760 Enable (disable) an optimization that pairs consecutive load or store
25761 instructions to enable load/store bonding. This option is enabled by
25762 default but only takes effect when the selected architecture is known
25763 to support bonding.
25765 @item -munaligned-access
25766 @itemx -mno-unaligned-access
25767 @opindex munaligned-access
25768 @opindex mno-unaligned-access
25769 Enable (disable) direct unaligned access for MIPS Release 6.
25770 MIPSr6 requires load/store unaligned-access support,
25771 by hardware or trap&emulate.
25772 So @option{-mno-unaligned-access} may be needed by kernel.
25777 @opindex mno-memcpy
25778 Force (do not force) the use of @code{memcpy} for non-trivial block
25779 moves. The default is @option{-mno-memcpy}, which allows GCC to inline
25780 most constant-sized copies.
25783 @itemx -mno-long-calls
25784 @opindex mlong-calls
25785 @opindex mno-long-calls
25786 Disable (do not disable) use of the @code{jal} instruction. Calling
25787 functions using @code{jal} is more efficient but requires the caller
25788 and callee to be in the same 256 megabyte segment.
25790 This option has no effect on abicalls code. The default is
25791 @option{-mno-long-calls}.
25797 Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
25798 instructions, as provided by the R4650 ISA@.
25804 Enable (disable) use of the @code{madd} and @code{msub} integer
25805 instructions. The default is @option{-mimadd} on architectures
25806 that support @code{madd} and @code{msub} except for the 74k
25807 architecture where it was found to generate slower code.
25810 @itemx -mno-fused-madd
25811 @opindex mfused-madd
25812 @opindex mno-fused-madd
25813 Enable (disable) use of the floating-point multiply-accumulate
25814 instructions, when they are available. The default is
25815 @option{-mfused-madd}.
25817 On the R8000 CPU when multiply-accumulate instructions are used,
25818 the intermediate product is calculated to infinite precision
25819 and is not subject to the FCSR Flush to Zero bit. This may be
25820 undesirable in some circumstances. On other processors the result
25821 is numerically identical to the equivalent computation using
25822 separate multiply, add, subtract and negate instructions.
25826 Tell the MIPS assembler to not run its preprocessor over user
25827 assembler files (with a @samp{.s} suffix) when assembling them.
25830 @itemx -mno-fix-24k
25832 @opindex mno-fix-24k
25833 Work around the 24K E48 (lost data on stores during refill) errata.
25834 The workarounds are implemented by the assembler rather than by GCC@.
25837 @itemx -mno-fix-r4000
25838 @opindex mfix-r4000
25839 @opindex mno-fix-r4000
25840 Work around certain R4000 CPU errata:
25843 A double-word or a variable shift may give an incorrect result if executed
25844 immediately after starting an integer division.
25846 A double-word or a variable shift may give an incorrect result if executed
25847 while an integer multiplication is in progress.
25849 An integer division may give an incorrect result if started in a delay slot
25850 of a taken branch or a jump.
25854 @itemx -mno-fix-r4400
25855 @opindex mfix-r4400
25856 @opindex mno-fix-r4400
25857 Work around certain R4400 CPU errata:
25860 A double-word or a variable shift may give an incorrect result if executed
25861 immediately after starting an integer division.
25865 @itemx -mno-fix-r10000
25866 @opindex mfix-r10000
25867 @opindex mno-fix-r10000
25868 Work around certain R10000 errata:
25871 @code{ll}/@code{sc} sequences may not behave atomically on revisions
25872 prior to 3.0. They may deadlock on revisions 2.6 and earlier.
25875 This option can only be used if the target architecture supports
25876 branch-likely instructions. @option{-mfix-r10000} is the default when
25877 @option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
25881 @itemx -mno-fix-r5900
25882 @opindex mfix-r5900
25883 Do not attempt to schedule the preceding instruction into the delay slot
25884 of a branch instruction placed at the end of a short loop of six
25885 instructions or fewer and always schedule a @code{nop} instruction there
25886 instead. The short loop bug under certain conditions causes loops to
25887 execute only once or twice, due to a hardware bug in the R5900 chip. The
25888 workaround is implemented by the assembler rather than by GCC@.
25891 @itemx -mno-fix-rm7000
25892 @opindex mfix-rm7000
25893 Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
25894 workarounds are implemented by the assembler rather than by GCC@.
25897 @itemx -mno-fix-vr4120
25898 @opindex mfix-vr4120
25899 Work around certain VR4120 errata:
25902 @code{dmultu} does not always produce the correct result.
25904 @code{div} and @code{ddiv} do not always produce the correct result if one
25905 of the operands is negative.
25907 The workarounds for the division errata rely on special functions in
25908 @file{libgcc.a}. At present, these functions are only provided by
25909 the @code{mips64vr*-elf} configurations.
25911 Other VR4120 errata require a NOP to be inserted between certain pairs of
25912 instructions. These errata are handled by the assembler, not by GCC itself.
25915 @opindex mfix-vr4130
25916 Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
25917 workarounds are implemented by the assembler rather than by GCC,
25918 although GCC avoids using @code{mflo} and @code{mfhi} if the
25919 VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
25920 instructions are available instead.
25923 @itemx -mno-fix-sb1
25925 Work around certain SB-1 CPU core errata.
25926 (This flag currently works around the SB-1 revision 2
25927 ``F1'' and ``F2'' floating-point errata.)
25929 @item -mr10k-cache-barrier=@var{setting}
25930 @opindex mr10k-cache-barrier
25931 Specify whether GCC should insert cache barriers to avoid the
25932 side effects of speculation on R10K processors.
25934 In common with many processors, the R10K tries to predict the outcome
25935 of a conditional branch and speculatively executes instructions from
25936 the ``taken'' branch. It later aborts these instructions if the
25937 predicted outcome is wrong. However, on the R10K, even aborted
25938 instructions can have side effects.
25940 This problem only affects kernel stores and, depending on the system,
25941 kernel loads. As an example, a speculatively-executed store may load
25942 the target memory into cache and mark the cache line as dirty, even if
25943 the store itself is later aborted. If a DMA operation writes to the
25944 same area of memory before the ``dirty'' line is flushed, the cached
25945 data overwrites the DMA-ed data. See the R10K processor manual
25946 for a full description, including other potential problems.
25948 One workaround is to insert cache barrier instructions before every memory
25949 access that might be speculatively executed and that might have side
25950 effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
25951 controls GCC's implementation of this workaround. It assumes that
25952 aborted accesses to any byte in the following regions does not have
25957 the memory occupied by the current function's stack frame;
25960 the memory occupied by an incoming stack argument;
25963 the memory occupied by an object with a link-time-constant address.
25966 It is the kernel's responsibility to ensure that speculative
25967 accesses to these regions are indeed safe.
25969 If the input program contains a function declaration such as:
25975 then the implementation of @code{foo} must allow @code{j foo} and
25976 @code{jal foo} to be executed speculatively. GCC honors this
25977 restriction for functions it compiles itself. It expects non-GCC
25978 functions (such as hand-written assembly code) to do the same.
25980 The option has three forms:
25983 @item -mr10k-cache-barrier=load-store
25984 Insert a cache barrier before a load or store that might be
25985 speculatively executed and that might have side effects even
25988 @item -mr10k-cache-barrier=store
25989 Insert a cache barrier before a store that might be speculatively
25990 executed and that might have side effects even if aborted.
25992 @item -mr10k-cache-barrier=none
25993 Disable the insertion of cache barriers. This is the default setting.
25996 @item -mflush-func=@var{func}
25997 @itemx -mno-flush-func
25998 @opindex mflush-func
25999 Specifies the function to call to flush the I and D caches, or to not
26000 call any such function. If called, the function must take the same
26001 arguments as the common @code{_flush_func}, that is, the address of the
26002 memory range for which the cache is being flushed, the size of the
26003 memory range, and the number 3 (to flush both caches). The default
26004 depends on the target GCC was configured for, but commonly is either
26005 @code{_flush_func} or @code{__cpu_flush}.
26007 @item mbranch-cost=@var{num}
26008 @opindex mbranch-cost
26009 Set the cost of branches to roughly @var{num} ``simple'' instructions.
26010 This cost is only a heuristic and is not guaranteed to produce
26011 consistent results across releases. A zero cost redundantly selects
26012 the default, which is based on the @option{-mtune} setting.
26014 @item -mbranch-likely
26015 @itemx -mno-branch-likely
26016 @opindex mbranch-likely
26017 @opindex mno-branch-likely
26018 Enable or disable use of Branch Likely instructions, regardless of the
26019 default for the selected architecture. By default, Branch Likely
26020 instructions may be generated if they are supported by the selected
26021 architecture. An exception is for the MIPS32 and MIPS64 architectures
26022 and processors that implement those architectures; for those, Branch
26023 Likely instructions are not be generated by default because the MIPS32
26024 and MIPS64 architectures specifically deprecate their use.
26026 @item -mcompact-branches=never
26027 @itemx -mcompact-branches=optimal
26028 @itemx -mcompact-branches=always
26029 @opindex mcompact-branches=never
26030 @opindex mcompact-branches=optimal
26031 @opindex mcompact-branches=always
26032 These options control which form of branches will be generated. The
26033 default is @option{-mcompact-branches=optimal}.
26035 The @option{-mcompact-branches=never} option ensures that compact branch
26036 instructions will never be generated.
26038 The @option{-mcompact-branches=always} option ensures that a compact
26039 branch instruction will be generated if available. If a compact branch
26040 instruction is not available, a delay slot form of the branch will be
26043 This option is supported from MIPS Release 6 onwards.
26045 The @option{-mcompact-branches=optimal} option will cause a delay slot
26046 branch to be used if one is available in the current ISA and the delay
26047 slot is successfully filled. If the delay slot is not filled, a compact
26048 branch will be chosen if one is available.
26050 @item -mfp-exceptions
26051 @itemx -mno-fp-exceptions
26052 @opindex mfp-exceptions
26053 Specifies whether FP exceptions are enabled. This affects how
26054 FP instructions are scheduled for some processors.
26055 The default is that FP exceptions are
26058 For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
26059 64-bit code, then we can use both FP pipes. Otherwise, we can only use one
26062 @item -mvr4130-align
26063 @itemx -mno-vr4130-align
26064 @opindex mvr4130-align
26065 The VR4130 pipeline is two-way superscalar, but can only issue two
26066 instructions together if the first one is 8-byte aligned. When this
26067 option is enabled, GCC aligns pairs of instructions that it
26068 thinks should execute in parallel.
26070 This option only has an effect when optimizing for the VR4130.
26071 It normally makes code faster, but at the expense of making it bigger.
26072 It is enabled by default at optimization level @option{-O3}.
26077 Enable (disable) generation of @code{synci} instructions on
26078 architectures that support it. The @code{synci} instructions (if
26079 enabled) are generated when @code{__builtin___clear_cache} is
26082 This option defaults to @option{-mno-synci}, but the default can be
26083 overridden by configuring GCC with @option{--with-synci}.
26085 When compiling code for single processor systems, it is generally safe
26086 to use @code{synci}. However, on many multi-core (SMP) systems, it
26087 does not invalidate the instruction caches on all cores and may lead
26088 to undefined behavior.
26090 @item -mrelax-pic-calls
26091 @itemx -mno-relax-pic-calls
26092 @opindex mrelax-pic-calls
26093 Try to turn PIC calls that are normally dispatched via register
26094 @code{$25} into direct calls. This is only possible if the linker can
26095 resolve the destination at link time and if the destination is within
26096 range for a direct call.
26098 @option{-mrelax-pic-calls} is the default if GCC was configured to use
26099 an assembler and a linker that support the @code{.reloc} assembly
26100 directive and @option{-mexplicit-relocs} is in effect. With
26101 @option{-mno-explicit-relocs}, this optimization can be performed by the
26102 assembler and the linker alone without help from the compiler.
26104 @item -mmcount-ra-address
26105 @itemx -mno-mcount-ra-address
26106 @opindex mmcount-ra-address
26107 @opindex mno-mcount-ra-address
26108 Emit (do not emit) code that allows @code{_mcount} to modify the
26109 calling function's return address. When enabled, this option extends
26110 the usual @code{_mcount} interface with a new @var{ra-address}
26111 parameter, which has type @code{intptr_t *} and is passed in register
26112 @code{$12}. @code{_mcount} can then modify the return address by
26113 doing both of the following:
26116 Returning the new address in register @code{$31}.
26118 Storing the new address in @code{*@var{ra-address}},
26119 if @var{ra-address} is nonnull.
26122 The default is @option{-mno-mcount-ra-address}.
26124 @item -mframe-header-opt
26125 @itemx -mno-frame-header-opt
26126 @opindex mframe-header-opt
26127 Enable (disable) frame header optimization in the o32 ABI. When using the
26128 o32 ABI, calling functions will allocate 16 bytes on the stack for the called
26129 function to write out register arguments. When enabled, this optimization
26130 will suppress the allocation of the frame header if it can be determined that
26133 This optimization is off by default at all optimization levels.
26136 @itemx -mno-lxc1-sxc1
26137 @opindex mlxc1-sxc1
26138 When applicable, enable (disable) the generation of @code{lwxc1},
26139 @code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
26144 When applicable, enable (disable) the generation of 4-operand @code{madd.s},
26145 @code{madd.d} and related instructions. Enabled by default.
26150 @subsection MMIX Options
26151 @cindex MMIX Options
26153 These options are defined for the MMIX:
26157 @itemx -mno-libfuncs
26159 @opindex mno-libfuncs
26160 Specify that intrinsic library functions are being compiled, passing all
26161 values in registers, no matter the size.
26164 @itemx -mno-epsilon
26166 @opindex mno-epsilon
26167 Generate floating-point comparison instructions that compare with respect
26168 to the @code{rE} epsilon register.
26170 @item -mabi=mmixware
26172 @opindex mabi=mmixware
26174 Generate code that passes function parameters and return values that (in
26175 the called function) are seen as registers @code{$0} and up, as opposed to
26176 the GNU ABI which uses global registers @code{$231} and up.
26178 @item -mzero-extend
26179 @itemx -mno-zero-extend
26180 @opindex mzero-extend
26181 @opindex mno-zero-extend
26182 When reading data from memory in sizes shorter than 64 bits, use (do not
26183 use) zero-extending load instructions by default, rather than
26184 sign-extending ones.
26187 @itemx -mno-knuthdiv
26189 @opindex mno-knuthdiv
26190 Make the result of a division yielding a remainder have the same sign as
26191 the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
26192 remainder follows the sign of the dividend. Both methods are
26193 arithmetically valid, the latter being almost exclusively used.
26195 @item -mtoplevel-symbols
26196 @itemx -mno-toplevel-symbols
26197 @opindex mtoplevel-symbols
26198 @opindex mno-toplevel-symbols
26199 Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
26200 code can be used with the @code{PREFIX} assembly directive.
26204 Generate an executable in the ELF format, rather than the default
26205 @samp{mmo} format used by the @command{mmix} simulator.
26207 @item -mbranch-predict
26208 @itemx -mno-branch-predict
26209 @opindex mbranch-predict
26210 @opindex mno-branch-predict
26211 Use (do not use) the probable-branch instructions, when static branch
26212 prediction indicates a probable branch.
26214 @item -mbase-addresses
26215 @itemx -mno-base-addresses
26216 @opindex mbase-addresses
26217 @opindex mno-base-addresses
26218 Generate (do not generate) code that uses @emph{base addresses}. Using a
26219 base address automatically generates a request (handled by the assembler
26220 and the linker) for a constant to be set up in a global register. The
26221 register is used for one or more base address requests within the range 0
26222 to 255 from the value held in the register. The generally leads to short
26223 and fast code, but the number of different data items that can be
26224 addressed is limited. This means that a program that uses lots of static
26225 data may require @option{-mno-base-addresses}.
26227 @item -msingle-exit
26228 @itemx -mno-single-exit
26229 @opindex msingle-exit
26230 @opindex mno-single-exit
26231 Force (do not force) generated code to have a single exit point in each
26235 @node MN10300 Options
26236 @subsection MN10300 Options
26237 @cindex MN10300 options
26239 These @option{-m} options are defined for Matsushita MN10300 architectures:
26244 Generate code to avoid bugs in the multiply instructions for the MN10300
26245 processors. This is the default.
26247 @item -mno-mult-bug
26248 @opindex mno-mult-bug
26249 Do not generate code to avoid bugs in the multiply instructions for the
26250 MN10300 processors.
26254 Generate code using features specific to the AM33 processor.
26258 Do not generate code using features specific to the AM33 processor. This
26263 Generate code using features specific to the AM33/2.0 processor.
26267 Generate code using features specific to the AM34 processor.
26269 @item -mtune=@var{cpu-type}
26271 Use the timing characteristics of the indicated CPU type when
26272 scheduling instructions. This does not change the targeted processor
26273 type. The CPU type must be one of @samp{mn10300}, @samp{am33},
26274 @samp{am33-2} or @samp{am34}.
26276 @item -mreturn-pointer-on-d0
26277 @opindex mreturn-pointer-on-d0
26278 When generating a function that returns a pointer, return the pointer
26279 in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
26280 only in @code{a0}, and attempts to call such functions without a prototype
26281 result in errors. Note that this option is on by default; use
26282 @option{-mno-return-pointer-on-d0} to disable it.
26286 Do not link in the C run-time initialization object file.
26290 Indicate to the linker that it should perform a relaxation optimization pass
26291 to shorten branches, calls and absolute memory addresses. This option only
26292 has an effect when used on the command line for the final link step.
26294 This option makes symbolic debugging impossible.
26298 Allow the compiler to generate @emph{Long Instruction Word}
26299 instructions if the target is the @samp{AM33} or later. This is the
26300 default. This option defines the preprocessor macro @code{__LIW__}.
26304 Do not allow the compiler to generate @emph{Long Instruction Word}
26305 instructions. This option defines the preprocessor macro
26310 Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
26311 instructions if the target is the @samp{AM33} or later. This is the
26312 default. This option defines the preprocessor macro @code{__SETLB__}.
26316 Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
26317 instructions. This option defines the preprocessor macro
26318 @code{__NO_SETLB__}.
26322 @node Moxie Options
26323 @subsection Moxie Options
26324 @cindex Moxie Options
26330 Generate big-endian code. This is the default for @samp{moxie-*-*}
26335 Generate little-endian code.
26339 Generate mul.x and umul.x instructions. This is the default for
26340 @samp{moxiebox-*-*} configurations.
26344 Do not link in the C run-time initialization object file.
26348 @node MSP430 Options
26349 @subsection MSP430 Options
26350 @cindex MSP430 Options
26352 These options are defined for the MSP430:
26358 Force assembly output to always use hex constants. Normally such
26359 constants are signed decimals, but this option is available for
26360 testsuite and/or aesthetic purposes.
26364 Select the MCU to target. This is used to create a C preprocessor
26365 symbol based upon the MCU name, converted to upper case and pre- and
26366 post-fixed with @samp{__}. This in turn is used by the
26367 @file{msp430.h} header file to select an MCU-specific supplementary
26370 The option also sets the ISA to use. If the MCU name is one that is
26371 known to only support the 430 ISA then that is selected, otherwise the
26372 430X ISA is selected. A generic MCU name of @samp{msp430} can also be
26373 used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
26374 name selects the 430X ISA.
26376 In addition an MCU-specific linker script is added to the linker
26377 command line. The script's name is the name of the MCU with
26378 @file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
26379 command line defines the C preprocessor symbol @code{__XXX__} and
26380 cause the linker to search for a script called @file{xxx.ld}.
26382 The ISA and hardware multiply supported for the different MCUs is hard-coded
26383 into GCC. However, an external @samp{devices.csv} file can be used to
26384 extend device support beyond those that have been hard-coded.
26386 GCC searches for the @samp{devices.csv} file using the following methods in the
26387 given precedence order, where the first method takes precendence over the
26388 second which takes precedence over the third.
26391 @item Include path specified with @code{-I} and @code{-L}
26392 @samp{devices.csv} will be searched for in each of the directories specified by
26393 include paths and linker library search paths.
26394 @item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
26395 Define the value of the global environment variable
26396 @samp{MSP430_GCC_INCLUDE_DIR}
26397 to the full path to the directory containing devices.csv, and GCC will search
26398 this directory for devices.csv. If devices.csv is found, this directory will
26399 also be registered as an include path, and linker library path. Header files
26400 and linker scripts in this directory can therefore be used without manually
26401 specifying @code{-I} and @code{-L} on the command line.
26402 @item The @samp{msp430-elf@{,bare@}/include/devices} directory
26403 Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the
26404 toolchain root directory. This directory does not exist in a default
26405 installation, but if the user has created it and copied @samp{devices.csv}
26406 there, then the MCU data will be read. As above, this directory will
26407 also be registered as an include path, and linker library path.
26410 If none of the above search methods find @samp{devices.csv}, then the
26411 hard-coded MCU data is used.
26415 @itemx -mno-warn-mcu
26417 @opindex mno-warn-mcu
26418 This option enables or disables warnings about conflicts between the
26419 MCU name specified by the @option{-mmcu} option and the ISA set by the
26420 @option{-mcpu} option and/or the hardware multiply support set by the
26421 @option{-mhwmult} option. It also toggles warnings about unrecognized
26422 MCU names. This option is on by default.
26426 Specifies the ISA to use. Accepted values are @samp{msp430},
26427 @samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
26428 @option{-mmcu=} option should be used to select the ISA.
26432 Link to the simulator runtime libraries and linker script. Overrides
26433 any scripts that would be selected by the @option{-mmcu=} option.
26437 Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
26441 Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
26445 This option is passed to the assembler and linker, and allows the
26446 linker to perform certain optimizations that cannot be done until
26451 Describes the type of hardware multiply supported by the target.
26452 Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
26453 for the original 16-bit-only multiply supported by early MCUs.
26454 @samp{32bit} for the 16/32-bit multiply supported by later MCUs and
26455 @samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
26456 A value of @samp{auto} can also be given. This tells GCC to deduce
26457 the hardware multiply support based upon the MCU name provided by the
26458 @option{-mmcu} option. If no @option{-mmcu} option is specified or if
26459 the MCU name is not recognized then no hardware multiply support is
26460 assumed. @code{auto} is the default setting.
26462 Hardware multiplies are normally performed by calling a library
26463 routine. This saves space in the generated code. When compiling at
26464 @option{-O3} or higher however the hardware multiplier is invoked
26465 inline. This makes for bigger, but faster code.
26467 The hardware multiply routines disable interrupts whilst running and
26468 restore the previous interrupt state when they finish. This makes
26469 them safe to use inside interrupt handlers as well as in normal code.
26473 Enable the use of a minimum runtime environment - no static
26474 initializers or constructors. This is intended for memory-constrained
26475 devices. The compiler includes special symbols in some objects
26476 that tell the linker and runtime which code fragments are required.
26478 @item -mtiny-printf
26479 @opindex mtiny-printf
26480 Enable reduced code size @code{printf} and @code{puts} library functions.
26481 The @samp{tiny} implementations of these functions are not reentrant, so
26482 must be used with caution in multi-threaded applications.
26484 Support for streams has been removed and the string to be printed will
26485 always be sent to stdout via the @code{write} syscall. The string is not
26486 buffered before it is sent to write.
26488 This option requires Newlib Nano IO, so GCC must be configured with
26489 @samp{--enable-newlib-nano-formatted-io}.
26491 @item -mmax-inline-shift=
26492 @opindex mmax-inline-shift=
26493 This option takes an integer between 0 and 64 inclusive, and sets
26494 the maximum number of inline shift instructions which should be emitted to
26495 perform a shift operation by a constant amount. When this value needs to be
26496 exceeded, an mspabi helper function is used instead. The default value is 4.
26498 This only affects cases where a shift by multiple positions cannot be
26499 completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
26501 Shifts of a 32-bit value are at least twice as costly, so the value passed for
26502 this option is divided by 2 and the resulting value used instead.
26504 @item -mcode-region=
26505 @itemx -mdata-region=
26506 @opindex mcode-region
26507 @opindex mdata-region
26508 These options tell the compiler where to place functions and data that
26509 do not have one of the @code{lower}, @code{upper}, @code{either} or
26510 @code{section} attributes. Possible values are @code{lower},
26511 @code{upper}, @code{either} or @code{any}. The first three behave
26512 like the corresponding attribute. The fourth possible value -
26513 @code{any} - is the default. It leaves placement entirely up to the
26514 linker script and how it assigns the standard sections
26515 (@code{.text}, @code{.data}, etc) to the memory regions.
26517 @item -msilicon-errata=
26518 @opindex msilicon-errata
26519 This option passes on a request to assembler to enable the fixes for
26520 the named silicon errata.
26522 @item -msilicon-errata-warn=
26523 @opindex msilicon-errata-warn
26524 This option passes on a request to the assembler to enable warning
26525 messages when a silicon errata might need to be applied.
26527 @item -mwarn-devices-csv
26528 @itemx -mno-warn-devices-csv
26529 @opindex mwarn-devices-csv
26530 @opindex mno-warn-devices-csv
26531 Warn if @samp{devices.csv} is not found or there are problem parsing it
26536 @node NDS32 Options
26537 @subsection NDS32 Options
26538 @cindex NDS32 Options
26540 These options are defined for NDS32 implementations:
26545 @opindex mbig-endian
26546 Generate code in big-endian mode.
26548 @item -mlittle-endian
26549 @opindex mlittle-endian
26550 Generate code in little-endian mode.
26552 @item -mreduced-regs
26553 @opindex mreduced-regs
26554 Use reduced-set registers for register allocation.
26557 @opindex mfull-regs
26558 Use full-set registers for register allocation.
26562 Generate conditional move instructions.
26566 Do not generate conditional move instructions.
26570 Generate performance extension instructions.
26572 @item -mno-ext-perf
26573 @opindex mno-ext-perf
26574 Do not generate performance extension instructions.
26577 @opindex mext-perf2
26578 Generate performance extension 2 instructions.
26580 @item -mno-ext-perf2
26581 @opindex mno-ext-perf2
26582 Do not generate performance extension 2 instructions.
26585 @opindex mext-string
26586 Generate string extension instructions.
26588 @item -mno-ext-string
26589 @opindex mno-ext-string
26590 Do not generate string extension instructions.
26594 Generate v3 push25/pop25 instructions.
26597 @opindex mno-v3push
26598 Do not generate v3 push25/pop25 instructions.
26602 Generate 16-bit instructions.
26605 @opindex mno-16-bit
26606 Do not generate 16-bit instructions.
26608 @item -misr-vector-size=@var{num}
26609 @opindex misr-vector-size
26610 Specify the size of each interrupt vector, which must be 4 or 16.
26612 @item -mcache-block-size=@var{num}
26613 @opindex mcache-block-size
26614 Specify the size of each cache block,
26615 which must be a power of 2 between 4 and 512.
26617 @item -march=@var{arch}
26619 Specify the name of the target architecture.
26621 @item -mcmodel=@var{code-model}
26623 Set the code model to one of
26626 All the data and read-only data segments must be within 512KB addressing space.
26627 The text segment must be within 16MB addressing space.
26628 @item @samp{medium}
26629 The data segment must be within 512KB while the read-only data segment can be
26630 within 4GB addressing space. The text segment should be still within 16MB
26633 All the text and data segments can be within 4GB addressing space.
26637 @opindex mctor-dtor
26638 Enable constructor/destructor feature.
26642 Guide linker to relax instructions.
26646 @node Nios II Options
26647 @subsection Nios II Options
26648 @cindex Nios II options
26649 @cindex Altera Nios II options
26651 These are the options defined for the Altera Nios II processor.
26657 @cindex smaller data references
26658 Put global and static objects less than or equal to @var{num} bytes
26659 into the small data or BSS sections instead of the normal data or BSS
26660 sections. The default value of @var{num} is 8.
26662 @item -mgpopt=@var{option}
26667 Generate (do not generate) GP-relative accesses. The following
26668 @var{option} names are recognized:
26673 Do not generate GP-relative accesses.
26676 Generate GP-relative accesses for small data objects that are not
26677 external, weak, or uninitialized common symbols.
26678 Also use GP-relative addressing for objects that
26679 have been explicitly placed in a small data section via a @code{section}
26683 As for @samp{local}, but also generate GP-relative accesses for
26684 small data objects that are external, weak, or common. If you use this option,
26685 you must ensure that all parts of your program (including libraries) are
26686 compiled with the same @option{-G} setting.
26689 Generate GP-relative accesses for all data objects in the program. If you
26690 use this option, the entire data and BSS segments
26691 of your program must fit in 64K of memory and you must use an appropriate
26692 linker script to allocate them within the addressable range of the
26696 Generate GP-relative addresses for function pointers as well as data
26697 pointers. If you use this option, the entire text, data, and BSS segments
26698 of your program must fit in 64K of memory and you must use an appropriate
26699 linker script to allocate them within the addressable range of the
26704 @option{-mgpopt} is equivalent to @option{-mgpopt=local}, and
26705 @option{-mno-gpopt} is equivalent to @option{-mgpopt=none}.
26707 The default is @option{-mgpopt} except when @option{-fpic} or
26708 @option{-fPIC} is specified to generate position-independent code.
26709 Note that the Nios II ABI does not permit GP-relative accesses from
26712 You may need to specify @option{-mno-gpopt} explicitly when building
26713 programs that include large amounts of small data, including large
26714 GOT data sections. In this case, the 16-bit offset for GP-relative
26715 addressing may not be large enough to allow access to the entire
26716 small data section.
26718 @item -mgprel-sec=@var{regexp}
26719 @opindex mgprel-sec
26720 This option specifies additional section names that can be accessed via
26721 GP-relative addressing. It is most useful in conjunction with
26722 @code{section} attributes on variable declarations
26723 (@pxref{Common Variable Attributes}) and a custom linker script.
26724 The @var{regexp} is a POSIX Extended Regular Expression.
26726 This option does not affect the behavior of the @option{-G} option, and
26727 the specified sections are in addition to the standard @code{.sdata}
26728 and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}.
26730 @item -mr0rel-sec=@var{regexp}
26731 @opindex mr0rel-sec
26732 This option specifies names of sections that can be accessed via a
26733 16-bit offset from @code{r0}; that is, in the low 32K or high 32K
26734 of the 32-bit address space. It is most useful in conjunction with
26735 @code{section} attributes on variable declarations
26736 (@pxref{Common Variable Attributes}) and a custom linker script.
26737 The @var{regexp} is a POSIX Extended Regular Expression.
26739 In contrast to the use of GP-relative addressing for small data,
26740 zero-based addressing is never generated by default and there are no
26741 conventional section names used in standard linker scripts for sections
26742 in the low or high areas of memory.
26748 Generate little-endian (default) or big-endian (experimental) code,
26751 @item -march=@var{arch}
26753 This specifies the name of the target Nios II architecture. GCC uses this
26754 name to determine what kind of instructions it can emit when generating
26755 assembly code. Permissible names are: @samp{r1}, @samp{r2}.
26757 The preprocessor macro @code{__nios2_arch__} is available to programs,
26758 with value 1 or 2, indicating the targeted ISA level.
26760 @item -mbypass-cache
26761 @itemx -mno-bypass-cache
26762 @opindex mno-bypass-cache
26763 @opindex mbypass-cache
26764 Force all load and store instructions to always bypass cache by
26765 using I/O variants of the instructions. The default is not to
26768 @item -mno-cache-volatile
26769 @itemx -mcache-volatile
26770 @opindex mcache-volatile
26771 @opindex mno-cache-volatile
26772 Volatile memory access bypass the cache using the I/O variants of
26773 the load and store instructions. The default is not to bypass the cache.
26775 @item -mno-fast-sw-div
26776 @itemx -mfast-sw-div
26777 @opindex mno-fast-sw-div
26778 @opindex mfast-sw-div
26779 Do not use table-based fast divide for small numbers. The default
26780 is to use the fast divide at @option{-O3} and above.
26784 @itemx -mno-hw-mulx
26788 @opindex mno-hw-mul
26790 @opindex mno-hw-mulx
26792 @opindex mno-hw-div
26794 Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
26795 instructions by the compiler. The default is to emit @code{mul}
26796 and not emit @code{div} and @code{mulx}.
26802 Enable or disable generation of Nios II R2 BMX (bit manipulation) and
26803 CDX (code density) instructions. Enabling these instructions also
26804 requires @option{-march=r2}. Since these instructions are optional
26805 extensions to the R2 architecture, the default is not to emit them.
26807 @item -mcustom-@var{insn}=@var{N}
26808 @itemx -mno-custom-@var{insn}
26809 @opindex mcustom-@var{insn}
26810 @opindex mno-custom-@var{insn}
26811 Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a
26812 custom instruction with encoding @var{N} when generating code that uses
26813 @var{insn}. For example, @option{-mcustom-fadds=253} generates custom
26814 instruction 253 for single-precision floating-point add operations instead
26815 of the default behavior of using a library call.
26817 The following values of @var{insn} are supported. Except as otherwise
26818 noted, floating-point operations are expected to be implemented with
26819 normal IEEE 754 semantics and correspond directly to the C operators or the
26820 equivalent GCC built-in functions (@pxref{Other Builtins}).
26822 Single-precision floating point:
26825 @item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls}
26826 Binary arithmetic operations.
26832 Unary absolute value.
26834 @item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes}
26835 Comparison operations.
26837 @item @samp{fmins}, @samp{fmaxs}
26838 Floating-point minimum and maximum. These instructions are only
26839 generated if @option{-ffinite-math-only} is specified.
26841 @item @samp{fsqrts}
26842 Unary square root operation.
26844 @item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs}
26845 Floating-point trigonometric and exponential functions. These instructions
26846 are only generated if @option{-funsafe-math-optimizations} is also specified.
26850 Double-precision floating point:
26853 @item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld}
26854 Binary arithmetic operations.
26860 Unary absolute value.
26862 @item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned}
26863 Comparison operations.
26865 @item @samp{fmind}, @samp{fmaxd}
26866 Double-precision minimum and maximum. These instructions are only
26867 generated if @option{-ffinite-math-only} is specified.
26869 @item @samp{fsqrtd}
26870 Unary square root operation.
26872 @item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd}
26873 Double-precision trigonometric and exponential functions. These instructions
26874 are only generated if @option{-funsafe-math-optimizations} is also specified.
26880 @item @samp{fextsd}
26881 Conversion from single precision to double precision.
26883 @item @samp{ftruncds}
26884 Conversion from double precision to single precision.
26886 @item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu}
26887 Conversion from floating point to signed or unsigned integer types, with
26888 truncation towards zero.
26891 Conversion from single-precision floating point to signed integer,
26892 rounding to the nearest integer and ties away from zero.
26893 This corresponds to the @code{__builtin_lroundf} function when
26894 @option{-fno-math-errno} is used.
26896 @item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud}
26897 Conversion from signed or unsigned integer types to floating-point types.
26901 In addition, all of the following transfer instructions for internal
26902 registers X and Y must be provided to use any of the double-precision
26903 floating-point instructions. Custom instructions taking two
26904 double-precision source operands expect the first operand in the
26905 64-bit register X. The other operand (or only operand of a unary
26906 operation) is given to the custom arithmetic instruction with the
26907 least significant half in source register @var{src1} and the most
26908 significant half in @var{src2}. A custom instruction that returns a
26909 double-precision result returns the most significant 32 bits in the
26910 destination register and the other half in 32-bit register Y.
26911 GCC automatically generates the necessary code sequences to write
26912 register X and/or read register Y when double-precision floating-point
26913 instructions are used.
26918 Write @var{src1} into the least significant half of X and @var{src2} into
26919 the most significant half of X.
26922 Write @var{src1} into Y.
26924 @item @samp{frdxhi}, @samp{frdxlo}
26925 Read the most or least (respectively) significant half of X and store it in
26929 Read the value of Y and store it into @var{dest}.
26932 Note that you can gain more local control over generation of Nios II custom
26933 instructions by using the @code{target("custom-@var{insn}=@var{N}")}
26934 and @code{target("no-custom-@var{insn}")} function attributes
26935 (@pxref{Function Attributes})
26936 or pragmas (@pxref{Function Specific Option Pragmas}).
26938 @item -mcustom-fpu-cfg=@var{name}
26939 @opindex mcustom-fpu-cfg
26941 This option enables a predefined, named set of custom instruction encodings
26942 (see @option{-mcustom-@var{insn}} above).
26943 Currently, the following sets are defined:
26945 @option{-mcustom-fpu-cfg=60-1} is equivalent to:
26946 @gccoptlist{-mcustom-fmuls=252 @gol
26947 -mcustom-fadds=253 @gol
26948 -mcustom-fsubs=254 @gol
26949 -fsingle-precision-constant}
26951 @option{-mcustom-fpu-cfg=60-2} is equivalent to:
26952 @gccoptlist{-mcustom-fmuls=252 @gol
26953 -mcustom-fadds=253 @gol
26954 -mcustom-fsubs=254 @gol
26955 -mcustom-fdivs=255 @gol
26956 -fsingle-precision-constant}
26958 @option{-mcustom-fpu-cfg=72-3} is equivalent to:
26959 @gccoptlist{-mcustom-floatus=243 @gol
26960 -mcustom-fixsi=244 @gol
26961 -mcustom-floatis=245 @gol
26962 -mcustom-fcmpgts=246 @gol
26963 -mcustom-fcmples=249 @gol
26964 -mcustom-fcmpeqs=250 @gol
26965 -mcustom-fcmpnes=251 @gol
26966 -mcustom-fmuls=252 @gol
26967 -mcustom-fadds=253 @gol
26968 -mcustom-fsubs=254 @gol
26969 -mcustom-fdivs=255 @gol
26970 -fsingle-precision-constant}
26972 @option{-mcustom-fpu-cfg=fph2} is equivalent to:
26973 @gccoptlist{-mcustom-fabss=224 @gol
26974 -mcustom-fnegs=225 @gol
26975 -mcustom-fcmpnes=226 @gol
26976 -mcustom-fcmpeqs=227 @gol
26977 -mcustom-fcmpges=228 @gol
26978 -mcustom-fcmpgts=229 @gol
26979 -mcustom-fcmples=230 @gol
26980 -mcustom-fcmplts=231 @gol
26981 -mcustom-fmaxs=232 @gol
26982 -mcustom-fmins=233 @gol
26983 -mcustom-round=248 @gol
26984 -mcustom-fixsi=249 @gol
26985 -mcustom-floatis=250 @gol
26986 -mcustom-fsqrts=251 @gol
26987 -mcustom-fmuls=252 @gol
26988 -mcustom-fadds=253 @gol
26989 -mcustom-fsubs=254 @gol
26990 -mcustom-fdivs=255 @gol}
26992 Custom instruction assignments given by individual
26993 @option{-mcustom-@var{insn}=} options override those given by
26994 @option{-mcustom-fpu-cfg=}, regardless of the
26995 order of the options on the command line.
26997 Note that you can gain more local control over selection of a FPU
26998 configuration by using the @code{target("custom-fpu-cfg=@var{name}")}
26999 function attribute (@pxref{Function Attributes})
27000 or pragma (@pxref{Function Specific Option Pragmas}).
27002 The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point
27003 Hardware 2 Component}. Please note that the custom instructions enabled by
27004 @option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated
27005 if @option{-ffinite-math-only} is specified. The custom instruction enabled by
27006 @option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is
27007 specified. In contrast to the other configurations,
27008 @option{-fsingle-precision-constant} is not set.
27012 These additional @samp{-m} options are available for the Altera Nios II
27013 ELF (bare-metal) target:
27019 Link with HAL BSP. This suppresses linking with the GCC-provided C runtime
27020 startup and termination code, and is typically used in conjunction with
27021 @option{-msys-crt0=} to specify the location of the alternate startup code
27022 provided by the HAL BSP.
27026 Link with a limited version of the C library, @option{-lsmallc}, rather than
27029 @item -msys-crt0=@var{startfile}
27031 @var{startfile} is the file name of the startfile (crt0) to use
27032 when linking. This option is only useful in conjunction with @option{-mhal}.
27034 @item -msys-lib=@var{systemlib}
27036 @var{systemlib} is the library name of the library that provides
27037 low-level system calls required by the C library,
27038 e.g.@: @code{read} and @code{write}.
27039 This option is typically used to link with a library provided by a HAL BSP.
27043 @node Nvidia PTX Options
27044 @subsection Nvidia PTX Options
27045 @cindex Nvidia PTX options
27046 @cindex nvptx options
27048 These options are defined for Nvidia PTX:
27054 Ignored, but preserved for backward compatibility. Only 64-bit ABI is
27057 @item -misa=@var{ISA-string}
27059 Generate code for given the specified PTX ISA (e.g.@: @samp{sm_35}). ISA
27060 strings must be lower-case. Valid ISA strings include @samp{sm_30} and
27061 @samp{sm_35}. The default ISA is sm_35.
27063 @item -mptx=@var{version-string}
27065 Generate code for given the specified PTX version (e.g.@: @samp{6.3}).
27066 Valid version strings include @samp{3.1} and @samp{6.3}. The default PTX
27070 @opindex mmainkernel
27071 Link in code for a __main kernel. This is for stand-alone instead of
27072 offloading execution.
27076 Apply partitioned execution optimizations. This is the default when any
27077 level of optimization is selected.
27080 @opindex msoft-stack
27081 Generate code that does not use @code{.local} memory
27082 directly for stack storage. Instead, a per-warp stack pointer is
27083 maintained explicitly. This enables variable-length stack allocation (with
27084 variable-length arrays or @code{alloca}), and when global memory is used for
27085 underlying storage, makes it possible to access automatic variables from other
27086 threads, or with atomic instructions. This code generation variant is used
27087 for OpenMP offloading, but the option is exposed on its own for the purpose
27088 of testing the compiler; to generate code suitable for linking into programs
27089 using OpenMP offloading, use option @option{-mgomp}.
27091 @item -muniform-simt
27092 @opindex muniform-simt
27093 Switch to code generation variant that allows to execute all threads in each
27094 warp, while maintaining memory state and side effects as if only one thread
27095 in each warp was active outside of OpenMP SIMD regions. All atomic operations
27096 and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
27097 current lane index equals the master lane index), and the register being
27098 assigned is copied via a shuffle instruction from the master lane. Outside of
27099 SIMD regions lane 0 is the master; inside, each thread sees itself as the
27100 master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
27101 all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
27102 regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
27103 with current lane index to compute the master lane index.
27107 Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
27108 @option{-muniform-simt} options, and selects corresponding multilib variant.
27112 @node OpenRISC Options
27113 @subsection OpenRISC Options
27114 @cindex OpenRISC Options
27116 These options are defined for OpenRISC:
27120 @item -mboard=@var{name}
27122 Configure a board specific runtime. This will be passed to the linker for
27123 newlib board library linking. The default is @code{or1ksim}.
27127 This option is ignored; it is for compatibility purposes only. This used to
27128 select linker and preprocessor options for use with newlib.
27134 Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
27135 This default is hardware divide.
27141 Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
27142 This default is hardware multiply.
27145 @itemx -mhard-float
27146 @opindex msoft-float
27147 @opindex mhard-float
27148 Select software or hardware for floating point operations.
27149 The default is software.
27151 @item -mdouble-float
27152 @opindex mdouble-float
27153 When @option{-mhard-float} is selected, enables generation of double-precision
27154 floating point instructions. By default functions from @file{libgcc} are used
27155 to perform double-precision floating point operations.
27157 @item -munordered-float
27158 @opindex munordered-float
27159 When @option{-mhard-float} is selected, enables generation of unordered
27160 floating point compare and set flag (@code{lf.sfun*}) instructions. By default
27161 functions from @file{libgcc} are used to perform unordered floating point
27162 compare and set flag operations.
27166 Enable generation of conditional move (@code{l.cmov}) instructions. By
27167 default the equivalent will be generated using set and branch.
27171 Enable generation of rotate right (@code{l.ror}) instructions. By default
27172 functions from @file{libgcc} are used to perform rotate right operations.
27176 Enable generation of rotate right with immediate (@code{l.rori}) instructions.
27177 By default functions from @file{libgcc} are used to perform rotate right with
27178 immediate operations.
27182 Enable generation of sign extension (@code{l.ext*}) instructions. By default
27183 memory loads are used to perform sign extension.
27187 Enable generation of compare and set flag with immediate (@code{l.sf*i})
27188 instructions. By default extra instructions will be generated to store the
27189 immediate to a register first.
27193 Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
27194 @code{l.slli}) instructions. By default extra instructions will be generated
27195 to store the immediate to a register first.
27197 @item -mcmodel=small
27198 @opindex mcmodel=small
27199 Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
27202 @item -mcmodel=large
27203 @opindex mcmodel=large
27204 Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
27209 @node PDP-11 Options
27210 @subsection PDP-11 Options
27211 @cindex PDP-11 Options
27213 These options are defined for the PDP-11:
27218 Use hardware FPP floating point. This is the default. (FIS floating
27219 point on the PDP-11/40 is not supported.) Implies -m45.
27222 @opindex msoft-float
27223 Do not use hardware floating point.
27227 Return floating-point results in ac0 (fr0 in Unix assembler syntax).
27231 Return floating-point results in memory. This is the default.
27235 Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
27239 Generate code for a PDP-11/45. This is the default.
27243 Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
27249 Use 16-bit @code{int}. This is the default.
27255 Use 32-bit @code{int}.
27259 Target has split instruction and data space. Implies -m45.
27263 Use Unix assembler syntax.
27267 Use DEC assembler syntax.
27271 Use GNU assembler syntax. This is the default.
27275 Use the new LRA register allocator. By default, the old ``reload''
27279 @node picoChip Options
27280 @subsection picoChip Options
27281 @cindex picoChip options
27283 These @samp{-m} options are defined for picoChip implementations:
27287 @item -mae=@var{ae_type}
27289 Set the instruction set, register set, and instruction scheduling
27290 parameters for array element type @var{ae_type}. Supported values
27291 for @var{ae_type} are @samp{ANY}, @samp{MUL}, and @samp{MAC}.
27293 @option{-mae=ANY} selects a completely generic AE type. Code
27294 generated with this option runs on any of the other AE types. The
27295 code is not as efficient as it would be if compiled for a specific
27296 AE type, and some types of operation (e.g., multiplication) do not
27297 work properly on all types of AE.
27299 @option{-mae=MUL} selects a MUL AE type. This is the most useful AE type
27300 for compiled code, and is the default.
27302 @option{-mae=MAC} selects a DSP-style MAC AE. Code compiled with this
27303 option may suffer from poor performance of byte (char) manipulation,
27304 since the DSP AE does not provide hardware support for byte load/stores.
27306 @item -msymbol-as-address
27307 Enable the compiler to directly use a symbol name as an address in a
27308 load/store instruction, without first loading it into a
27309 register. Typically, the use of this option generates larger
27310 programs, which run faster than when the option isn't used. However, the
27311 results vary from program to program, so it is left as a user option,
27312 rather than being permanently enabled.
27314 @item -mno-inefficient-warnings
27315 Disables warnings about the generation of inefficient code. These
27316 warnings can be generated, for example, when compiling code that
27317 performs byte-level memory operations on the MAC AE type. The MAC AE has
27318 no hardware support for byte-level memory operations, so all byte
27319 load/stores must be synthesized from word load/store operations. This is
27320 inefficient and a warning is generated to indicate
27321 that you should rewrite the code to avoid byte operations, or to target
27322 an AE type that has the necessary hardware support. This option disables
27327 @node PowerPC Options
27328 @subsection PowerPC Options
27329 @cindex PowerPC options
27331 These are listed under @xref{RS/6000 and PowerPC Options}.
27334 @subsection PRU Options
27335 @cindex PRU Options
27337 These command-line options are defined for PRU target:
27342 Link with a minimum runtime environment, with no support for static
27343 initializers and constructors. Using this option can significantly reduce
27344 the size of the final ELF binary. Beware that the compiler could still
27345 generate code with static initializers and constructors. It is up to the
27346 programmer to ensure that the source program will not use those features.
27348 @item -mmcu=@var{mcu}
27350 Specify the PRU MCU variant to use. Check Newlib for the exact list of
27355 Make GCC pass the @option{--no-relax} command-line option to the linker
27356 instead of the @option{--relax} option.
27360 Allow (or do not allow) GCC to use the LOOP instruction.
27362 @item -mabi=@var{variant}
27364 Specify the ABI variant to output code for. @option{-mabi=ti} selects the
27365 unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
27366 more naturally with certain GCC assumptions. These are the differences:
27369 @item Function Pointer Size
27370 TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
27371 supports only 32-bit data and code pointers.
27373 @item Optional Return Value Pointer
27374 Function return values larger than 64 bits are passed by using a hidden
27375 pointer as the first argument of the function. TI ABI, though, mandates that
27376 the pointer can be NULL in case the caller is not using the returned value.
27377 GNU always passes and expects a valid return value pointer.
27381 The current @option{-mabi=ti} implementation simply raises a compile error
27382 when any of the above code constructs is detected. As a consequence
27383 the standard C library cannot be built and it is omitted when linking with
27386 Relaxation is a GNU feature and for safety reasons is disabled when using
27387 @option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
27388 instructions, so the GNU linker cannot adjust them when shortening adjacent
27389 LDI32 pseudo instructions.
27393 @node RISC-V Options
27394 @subsection RISC-V Options
27395 @cindex RISC-V Options
27397 These command-line options are defined for RISC-V targets:
27400 @item -mbranch-cost=@var{n}
27401 @opindex mbranch-cost
27402 Set the cost of branches to roughly @var{n} instructions.
27407 When generating PIC code, do or don't allow the use of PLTs. Ignored for
27408 non-PIC. The default is @option{-mplt}.
27410 @item -mabi=@var{ABI-string}
27412 Specify integer and floating-point calling convention. @var{ABI-string}
27413 contains two parts: the size of integer types and the registers used for
27414 floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
27415 @samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
27416 32-bit), and that floating-point values up to 64 bits wide are passed in F
27417 registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
27418 allows the compiler to generate code that uses the F and D extensions but only
27419 allows floating-point values up to 32 bits long to be passed in registers; or
27420 @samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
27421 passed in registers.
27423 The default for this argument is system dependent, users who want a specific
27424 calling convention should specify one explicitly. The valid calling
27425 conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
27426 @samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
27427 implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
27428 invalid because the ABI requires 64-bit values be passed in F registers, but F
27429 registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can
27430 only be used with the @samp{rv32e} architecture. This ABI is not well
27431 specified at present, and is subject to change.
27436 Do or don't use hardware floating-point divide and square root instructions.
27437 This requires the F or D extensions for floating-point registers. The default
27438 is to use them if the specified architecture has these instructions.
27443 Do or don't use hardware instructions for integer division. This requires the
27444 M extension. The default is to use them if the specified architecture has
27445 these instructions.
27447 @item -march=@var{ISA-string}
27449 Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be
27450 lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and
27453 When @option{-march=} is not specified, use the setting from @option{-mcpu}.
27455 If both @option{-march} and @option{-mcpu=} are not specified, the default for
27456 this argument is system dependent, users who want a specific architecture
27457 extensions should specify one explicitly.
27459 @item -mcpu=@var{processor-string}
27461 Use architecture of and optimize the output for the given processor, specified
27462 by particular CPU name.
27463 Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21},
27464 @samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76},
27465 @samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76},
27466 @samp{sifive-u54}, and @samp{sifive-u74}.
27468 @item -mtune=@var{processor-string}
27470 Optimize the output for the given processor, specified by microarchitecture or
27471 particular CPU name. Permissible values for this option are: @samp{rocket},
27472 @samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series},
27473 @samp{size}, and all valid options for @option{-mcpu=}.
27475 When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
27476 the default is @samp{rocket} if both are not specified.
27478 The @samp{size} choice is not intended for use by end-users. This is used
27479 when @option{-Os} is specified. It overrides the instruction cost info
27480 provided by @option{-mtune=}, but does not override the pipeline info. This
27481 helps reduce code size while still giving good performance.
27483 @item -mpreferred-stack-boundary=@var{num}
27484 @opindex mpreferred-stack-boundary
27485 Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
27486 byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
27487 the default is 4 (16 bytes or 128-bits).
27489 @strong{Warning:} If you use this switch, then you must build all modules with
27490 the same value, including any libraries. This includes the system libraries
27491 and startup modules.
27493 @item -msmall-data-limit=@var{n}
27494 @opindex msmall-data-limit
27495 Put global and static data smaller than @var{n} bytes into a special section
27498 @item -msave-restore
27499 @itemx -mno-save-restore
27500 @opindex msave-restore
27501 Do or don't use smaller but slower prologue and epilogue code that uses
27502 library function calls. The default is to use fast inline prologues and
27505 @item -mshorten-memrefs
27506 @itemx -mno-shorten-memrefs
27507 @opindex mshorten-memrefs
27508 Do or do not attempt to make more use of compressed load/store instructions by
27509 replacing a load/store of 'base register + large offset' with a new load/store
27510 of 'new base + small offset'. If the new base gets stored in a compressed
27511 register, then the new load/store can be compressed. Currently targets 32-bit
27512 integer load/stores only.
27514 @item -mstrict-align
27515 @itemx -mno-strict-align
27516 @opindex mstrict-align
27517 Do not or do generate unaligned memory accesses. The default is set depending
27518 on whether the processor we are optimizing for supports fast unaligned access
27521 @item -mcmodel=medlow
27522 @opindex mcmodel=medlow
27523 Generate code for the medium-low code model. The program and its statically
27524 defined symbols must lie within a single 2 GiB address range and must lie
27525 between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be
27526 statically or dynamically linked. This is the default code model.
27528 @item -mcmodel=medany
27529 @opindex mcmodel=medany
27530 Generate code for the medium-any code model. The program and its statically
27531 defined symbols must be within any single 2 GiB address range. Programs can be
27532 statically or dynamically linked.
27534 @item -mexplicit-relocs
27535 @itemx -mno-exlicit-relocs
27536 Use or do not use assembler relocation operators when dealing with symbolic
27537 addresses. The alternative is to use assembler macros instead, which may
27538 limit optimization.
27542 Take advantage of linker relaxations to reduce the number of instructions
27543 required to materialize symbol addresses. The default is to take advantage of
27544 linker relaxations.
27546 @item -memit-attribute
27547 @itemx -mno-emit-attribute
27548 Emit (do not emit) RISC-V attribute to record extra information into ELF
27549 objects. This feature requires at least binutils 2.32.
27551 @item -malign-data=@var{type}
27552 @opindex malign-data
27553 Control how GCC aligns variables and constants of array, structure, or union
27554 types. Supported values for @var{type} are @samp{xlen} which uses x register
27555 width as the alignment value, and @samp{natural} which uses natural alignment.
27556 @samp{xlen} is the default.
27559 @opindex mbig-endian
27560 Generate big-endian code. This is the default when GCC is configured for a
27561 @samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
27563 @item -mlittle-endian
27564 @opindex mlittle-endian
27565 Generate little-endian code. This is the default when GCC is configured for a
27566 @samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
27567 @samp{riscv32be-*-*} target.
27569 @item -mstack-protector-guard=@var{guard}
27570 @itemx -mstack-protector-guard-reg=@var{reg}
27571 @itemx -mstack-protector-guard-offset=@var{offset}
27572 @opindex mstack-protector-guard
27573 @opindex mstack-protector-guard-reg
27574 @opindex mstack-protector-guard-offset
27575 Generate stack protection code using canary at @var{guard}. Supported
27576 locations are @samp{global} for a global canary or @samp{tls} for per-thread
27577 canary in the TLS block.
27579 With the latter choice the options
27580 @option{-mstack-protector-guard-reg=@var{reg}} and
27581 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
27582 which register to use as base register for reading the canary,
27583 and from what offset from that base register. There is no default
27584 register or offset as this is entirely for use within the Linux
27589 @subsection RL78 Options
27590 @cindex RL78 Options
27596 Links in additional target libraries to support operation within a
27605 Specifies the type of hardware multiplication and division support to
27606 be used. The simplest is @code{none}, which uses software for both
27607 multiplication and division. This is the default. The @code{g13}
27608 value is for the hardware multiply/divide peripheral found on the
27609 RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
27610 the multiplication and division instructions supported by the RL78/G14
27611 (S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
27612 the value @code{mg10} is an alias for @code{none}.
27614 In addition a C preprocessor macro is defined, based upon the setting
27615 of this option. Possible values are: @code{__RL78_MUL_NONE__},
27616 @code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
27623 Specifies the RL78 core to target. The default is the G14 core, also
27624 known as an S3 core or just RL78. The G13 or S2 core does not have
27625 multiply or divide instructions, instead it uses a hardware peripheral
27626 for these operations. The G10 or S1 core does not have register
27627 banks, so it uses a different calling convention.
27629 If this option is set it also selects the type of hardware multiply
27630 support to use, unless this is overridden by an explicit
27631 @option{-mmul=none} option on the command line. Thus specifying
27632 @option{-mcpu=g13} enables the use of the G13 hardware multiply
27633 peripheral and specifying @option{-mcpu=g10} disables the use of
27634 hardware multiplications altogether.
27636 Note, although the RL78/G14 core is the default target, specifying
27637 @option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
27638 change the behavior of the toolchain since it also enables G14
27639 hardware multiply support. If these options are not specified on the
27640 command line then software multiplication routines will be used even
27641 though the code targets the RL78 core. This is for backwards
27642 compatibility with older toolchains which did not have hardware
27643 multiply and divide support.
27645 In addition a C preprocessor macro is defined, based upon the setting
27646 of this option. Possible values are: @code{__RL78_G10__},
27647 @code{__RL78_G13__} or @code{__RL78_G14__}.
27657 These are aliases for the corresponding @option{-mcpu=} option. They
27658 are provided for backwards compatibility.
27662 Allow the compiler to use all of the available registers. By default
27663 registers @code{r24..r31} are reserved for use in interrupt handlers.
27664 With this option enabled these registers can be used in ordinary
27667 @item -m64bit-doubles
27668 @itemx -m32bit-doubles
27669 @opindex m64bit-doubles
27670 @opindex m32bit-doubles
27671 Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
27672 or 32 bits (@option{-m32bit-doubles}) in size. The default is
27673 @option{-m32bit-doubles}.
27675 @item -msave-mduc-in-interrupts
27676 @itemx -mno-save-mduc-in-interrupts
27677 @opindex msave-mduc-in-interrupts
27678 @opindex mno-save-mduc-in-interrupts
27679 Specifies that interrupt handler functions should preserve the
27680 MDUC registers. This is only necessary if normal code might use
27681 the MDUC registers, for example because it performs multiplication
27682 and division operations. The default is to ignore the MDUC registers
27683 as this makes the interrupt handlers faster. The target option -mg13
27684 needs to be passed for this to work as this feature is only available
27685 on the G13 target (S2 core). The MDUC registers will only be saved
27686 if the interrupt handler performs a multiplication or division
27687 operation or it calls another function.
27691 @node RS/6000 and PowerPC Options
27692 @subsection IBM RS/6000 and PowerPC Options
27693 @cindex RS/6000 and PowerPC Options
27694 @cindex IBM RS/6000 and PowerPC Options
27696 These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
27698 @item -mpowerpc-gpopt
27699 @itemx -mno-powerpc-gpopt
27700 @itemx -mpowerpc-gfxopt
27701 @itemx -mno-powerpc-gfxopt
27704 @itemx -mno-powerpc64
27708 @itemx -mno-popcntb
27710 @itemx -mno-popcntd
27717 @itemx -mno-hard-dfp
27718 @opindex mpowerpc-gpopt
27719 @opindex mno-powerpc-gpopt
27720 @opindex mpowerpc-gfxopt
27721 @opindex mno-powerpc-gfxopt
27722 @opindex mpowerpc64
27723 @opindex mno-powerpc64
27727 @opindex mno-popcntb
27729 @opindex mno-popcntd
27735 @opindex mno-hard-dfp
27736 You use these options to specify which instructions are available on the
27737 processor you are using. The default value of these options is
27738 determined when configuring GCC@. Specifying the
27739 @option{-mcpu=@var{cpu_type}} overrides the specification of these
27740 options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
27741 rather than the options listed above.
27743 Specifying @option{-mpowerpc-gpopt} allows
27744 GCC to use the optional PowerPC architecture instructions in the
27745 General Purpose group, including floating-point square root. Specifying
27746 @option{-mpowerpc-gfxopt} allows GCC to
27747 use the optional PowerPC architecture instructions in the Graphics
27748 group, including floating-point select.
27750 The @option{-mmfcrf} option allows GCC to generate the move from
27751 condition register field instruction implemented on the POWER4
27752 processor and other processors that support the PowerPC V2.01
27754 The @option{-mpopcntb} option allows GCC to generate the popcount and
27755 double-precision FP reciprocal estimate instruction implemented on the
27756 POWER5 processor and other processors that support the PowerPC V2.02
27758 The @option{-mpopcntd} option allows GCC to generate the popcount
27759 instruction implemented on the POWER7 processor and other processors
27760 that support the PowerPC V2.06 architecture.
27761 The @option{-mfprnd} option allows GCC to generate the FP round to
27762 integer instructions implemented on the POWER5+ processor and other
27763 processors that support the PowerPC V2.03 architecture.
27764 The @option{-mcmpb} option allows GCC to generate the compare bytes
27765 instruction implemented on the POWER6 processor and other processors
27766 that support the PowerPC V2.05 architecture.
27767 The @option{-mhard-dfp} option allows GCC to generate the decimal
27768 floating-point instructions implemented on some POWER processors.
27770 The @option{-mpowerpc64} option allows GCC to generate the additional
27771 64-bit instructions that are found in the full PowerPC64 architecture
27772 and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
27773 @option{-mno-powerpc64}.
27775 @item -mcpu=@var{cpu_type}
27777 Set architecture type, register usage, and
27778 instruction scheduling parameters for machine type @var{cpu_type}.
27779 Supported values for @var{cpu_type} are @samp{401}, @samp{403},
27780 @samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
27781 @samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
27782 @samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
27783 @samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
27784 @samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
27785 @samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
27786 @samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
27787 @samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
27788 @samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
27789 @samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64},
27790 @samp{powerpc64le}, @samp{rs64}, and @samp{native}.
27792 @option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
27793 @option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
27794 endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
27795 architecture machine types, with an appropriate, generic processor
27796 model assumed for scheduling purposes.
27798 Specifying @samp{native} as cpu type detects and selects the
27799 architecture option that corresponds to the host processor of the
27800 system performing the compilation.
27801 @option{-mcpu=native} has no effect if GCC does not recognize the
27804 The other options specify a specific processor. Code generated under
27805 those options runs best on that processor, and may not run at all on
27808 The @option{-mcpu} options automatically enable or disable the
27811 @gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple @gol
27812 -mpopcntb -mpopcntd -mpowerpc64 @gol
27813 -mpowerpc-gpopt -mpowerpc-gfxopt @gol
27814 -mmulhw -mdlmzb -mmfpgpr -mvsx @gol
27815 -mcrypto -mhtm -mpower8-fusion -mpower8-vector @gol
27816 -mquad-memory -mquad-memory-atomic -mfloat128 @gol
27817 -mfloat128-hardware -mprefixed -mpcrel -mmma @gol
27820 The particular options set for any particular CPU varies between
27821 compiler versions, depending on what setting seems to produce optimal
27822 code for that CPU; it doesn't necessarily reflect the actual hardware's
27823 capabilities. If you wish to set an individual option to a particular
27824 value, you may specify it after the @option{-mcpu} option, like
27825 @option{-mcpu=970 -mno-altivec}.
27827 On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
27828 not enabled or disabled by the @option{-mcpu} option at present because
27829 AIX does not have full support for these options. You may still
27830 enable or disable them individually if you're sure it'll work in your
27833 @item -mtune=@var{cpu_type}
27835 Set the instruction scheduling parameters for machine type
27836 @var{cpu_type}, but do not set the architecture type or register usage,
27837 as @option{-mcpu=@var{cpu_type}} does. The same
27838 values for @var{cpu_type} are used for @option{-mtune} as for
27839 @option{-mcpu}. If both are specified, the code generated uses the
27840 architecture and registers set by @option{-mcpu}, but the
27841 scheduling parameters set by @option{-mtune}.
27843 @item -mcmodel=small
27844 @opindex mcmodel=small
27845 Generate PowerPC64 code for the small model: The TOC is limited to
27848 @item -mcmodel=medium
27849 @opindex mcmodel=medium
27850 Generate PowerPC64 code for the medium model: The TOC and other static
27851 data may be up to a total of 4G in size. This is the default for 64-bit
27854 @item -mcmodel=large
27855 @opindex mcmodel=large
27856 Generate PowerPC64 code for the large model: The TOC may be up to 4G
27857 in size. Other data and code is only limited by the 64-bit address
27861 @itemx -mno-altivec
27863 @opindex mno-altivec
27864 Generate code that uses (does not use) AltiVec instructions, and also
27865 enable the use of built-in functions that allow more direct access to
27866 the AltiVec instruction set. You may also need to set
27867 @option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
27870 When @option{-maltivec} is used, the element order for AltiVec intrinsics
27871 such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
27872 match array element order corresponding to the endianness of the
27873 target. That is, element zero identifies the leftmost element in a
27874 vector register when targeting a big-endian platform, and identifies
27875 the rightmost element in a vector register when targeting a
27876 little-endian platform.
27881 @opindex mno-vrsave
27882 Generate VRSAVE instructions when generating AltiVec code.
27885 @opindex msecure-plt
27886 Generate code that allows @command{ld} and @command{ld.so}
27887 to build executables and shared
27888 libraries with non-executable @code{.plt} and @code{.got} sections.
27890 32-bit SYSV ABI option.
27894 Generate code that uses a BSS @code{.plt} section that @command{ld.so}
27896 requires @code{.plt} and @code{.got}
27897 sections that are both writable and executable.
27898 This is a PowerPC 32-bit SYSV ABI option.
27904 This switch enables or disables the generation of ISEL instructions.
27910 Generate code that uses (does not use) vector/scalar (VSX)
27911 instructions, and also enable the use of built-in functions that allow
27912 more direct access to the VSX instruction set.
27917 @opindex mno-crypto
27918 Enable the use (disable) of the built-in functions that allow direct
27919 access to the cryptographic instructions that were added in version
27920 2.07 of the PowerPC ISA.
27926 Enable (disable) the use of the built-in functions that allow direct
27927 access to the Hardware Transactional Memory (HTM) instructions that
27928 were added in version 2.07 of the PowerPC ISA.
27930 @item -mpower8-fusion
27931 @itemx -mno-power8-fusion
27932 @opindex mpower8-fusion
27933 @opindex mno-power8-fusion
27934 Generate code that keeps (does not keeps) some integer operations
27935 adjacent so that the instructions can be fused together on power8 and
27938 @item -mpower8-vector
27939 @itemx -mno-power8-vector
27940 @opindex mpower8-vector
27941 @opindex mno-power8-vector
27942 Generate code that uses (does not use) the vector and scalar
27943 instructions that were added in version 2.07 of the PowerPC ISA. Also
27944 enable the use of built-in functions that allow more direct access to
27945 the vector instructions.
27947 @item -mquad-memory
27948 @itemx -mno-quad-memory
27949 @opindex mquad-memory
27950 @opindex mno-quad-memory
27951 Generate code that uses (does not use) the non-atomic quad word memory
27952 instructions. The @option{-mquad-memory} option requires use of
27955 @item -mquad-memory-atomic
27956 @itemx -mno-quad-memory-atomic
27957 @opindex mquad-memory-atomic
27958 @opindex mno-quad-memory-atomic
27959 Generate code that uses (does not use) the atomic quad word memory
27960 instructions. The @option{-mquad-memory-atomic} option requires use of
27964 @itemx -mno-float128
27966 @opindex mno-float128
27967 Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
27968 and use either software emulation for IEEE 128-bit floating point or
27969 hardware instructions.
27971 The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
27972 128-bit floating point support. The IEEE 128-bit floating point is only
27973 supported on Linux.
27975 The default for @option{-mfloat128} is enabled on PowerPC Linux
27976 systems using the VSX instruction set, and disabled on other systems.
27978 If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or
27979 @option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating
27980 point support will also enable the generation of ISA 3.0 IEEE 128-bit
27981 floating point instructions. Otherwise, if you do not specify to
27982 generate ISA 3.0 instructions or you are targeting a 32-bit big endian
27983 system, IEEE 128-bit floating point will be done with software
27986 @item -mfloat128-hardware
27987 @itemx -mno-float128-hardware
27988 @opindex mfloat128-hardware
27989 @opindex mno-float128-hardware
27990 Enable/disable using ISA 3.0 hardware instructions to support the
27991 @var{__float128} data type.
27993 The default for @option{-mfloat128-hardware} is enabled on PowerPC
27994 Linux systems using the ISA 3.0 instruction set, and disabled on other
28001 Generate code for 32-bit or 64-bit environments of Darwin and SVR4
28002 targets (including GNU/Linux). The 32-bit environment sets int, long
28003 and pointer to 32 bits and generates code that runs on any PowerPC
28004 variant. The 64-bit environment sets int to 32 bits and long and
28005 pointer to 64 bits, and generates code for PowerPC64, as for
28006 @option{-mpowerpc64}.
28009 @itemx -mno-fp-in-toc
28010 @itemx -mno-sum-in-toc
28011 @itemx -mminimal-toc
28013 @opindex mno-fp-in-toc
28014 @opindex mno-sum-in-toc
28015 @opindex mminimal-toc
28016 Modify generation of the TOC (Table Of Contents), which is created for
28017 every executable file. The @option{-mfull-toc} option is selected by
28018 default. In that case, GCC allocates at least one TOC entry for
28019 each unique non-automatic variable reference in your program. GCC
28020 also places floating-point constants in the TOC@. However, only
28021 16,384 entries are available in the TOC@.
28023 If you receive a linker error message that saying you have overflowed
28024 the available TOC space, you can reduce the amount of TOC space used
28025 with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
28026 @option{-mno-fp-in-toc} prevents GCC from putting floating-point
28027 constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
28028 generate code to calculate the sum of an address and a constant at
28029 run time instead of putting that sum into the TOC@. You may specify one
28030 or both of these options. Each causes GCC to produce very slightly
28031 slower and larger code at the expense of conserving TOC space.
28033 If you still run out of space in the TOC even when you specify both of
28034 these options, specify @option{-mminimal-toc} instead. This option causes
28035 GCC to make only one TOC entry for every file. When you specify this
28036 option, GCC produces code that is slower and larger but which
28037 uses extremely little TOC space. You may wish to use this option
28038 only on files that contain less frequently-executed code.
28044 Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
28045 @code{long} type, and the infrastructure needed to support them.
28046 Specifying @option{-maix64} implies @option{-mpowerpc64},
28047 while @option{-maix32} disables the 64-bit ABI and
28048 implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
28051 @itemx -mno-xl-compat
28052 @opindex mxl-compat
28053 @opindex mno-xl-compat
28054 Produce code that conforms more closely to IBM XL compiler semantics
28055 when using AIX-compatible ABI@. Pass floating-point arguments to
28056 prototyped functions beyond the register save area (RSA) on the stack
28057 in addition to argument FPRs. Do not assume that most significant
28058 double in 128-bit long double value is properly rounded when comparing
28059 values and converting to double. Use XL symbol names for long double
28062 The AIX calling convention was extended but not initially documented to
28063 handle an obscure K&R C case of calling a function that takes the
28064 address of its arguments with fewer arguments than declared. IBM XL
28065 compilers access floating-point arguments that do not fit in the
28066 RSA from the stack when a subroutine is compiled without
28067 optimization. Because always storing floating-point arguments on the
28068 stack is inefficient and rarely needed, this option is not enabled by
28069 default and only is necessary when calling subroutines compiled by IBM
28070 XL compilers without optimization.
28074 Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
28075 application written to use message passing with special startup code to
28076 enable the application to run. The system must have PE installed in the
28077 standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
28078 must be overridden with the @option{-specs=} option to specify the
28079 appropriate directory location. The Parallel Environment does not
28080 support threads, so the @option{-mpe} option and the @option{-pthread}
28081 option are incompatible.
28083 @item -malign-natural
28084 @itemx -malign-power
28085 @opindex malign-natural
28086 @opindex malign-power
28087 On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
28088 @option{-malign-natural} overrides the ABI-defined alignment of larger
28089 types, such as floating-point doubles, on their natural size-based boundary.
28090 The option @option{-malign-power} instructs GCC to follow the ABI-specified
28091 alignment rules. GCC defaults to the standard alignment defined in the ABI@.
28093 On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
28097 @itemx -mhard-float
28098 @opindex msoft-float
28099 @opindex mhard-float
28100 Generate code that does not use (uses) the floating-point register set.
28101 Software floating-point emulation is provided if you use the
28102 @option{-msoft-float} option, and pass the option to GCC when linking.
28105 @itemx -mno-multiple
28107 @opindex mno-multiple
28108 Generate code that uses (does not use) the load multiple word
28109 instructions and the store multiple word instructions. These
28110 instructions are generated by default on POWER systems, and not
28111 generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
28112 PowerPC systems, since those instructions do not work when the
28113 processor is in little-endian mode. The exceptions are PPC740 and
28114 PPC750 which permit these instructions in little-endian mode.
28119 @opindex mno-update
28120 Generate code that uses (does not use) the load or store instructions
28121 that update the base register to the address of the calculated memory
28122 location. These instructions are generated by default. If you use
28123 @option{-mno-update}, there is a small window between the time that the
28124 stack pointer is updated and the address of the previous frame is
28125 stored, which means code that walks the stack frame across interrupts or
28126 signals may get corrupted data.
28128 @item -mavoid-indexed-addresses
28129 @itemx -mno-avoid-indexed-addresses
28130 @opindex mavoid-indexed-addresses
28131 @opindex mno-avoid-indexed-addresses
28132 Generate code that tries to avoid (not avoid) the use of indexed load
28133 or store instructions. These instructions can incur a performance
28134 penalty on Power6 processors in certain situations, such as when
28135 stepping through large arrays that cross a 16M boundary. This option
28136 is enabled by default when targeting Power6 and disabled otherwise.
28139 @itemx -mno-fused-madd
28140 @opindex mfused-madd
28141 @opindex mno-fused-madd
28142 Generate code that uses (does not use) the floating-point multiply and
28143 accumulate instructions. These instructions are generated by default
28144 if hardware floating point is used. The machine-dependent
28145 @option{-mfused-madd} option is now mapped to the machine-independent
28146 @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
28147 mapped to @option{-ffp-contract=off}.
28153 Generate code that uses (does not use) the half-word multiply and
28154 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
28155 These instructions are generated by default when targeting those
28162 Generate code that uses (does not use) the string-search @samp{dlmzb}
28163 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
28164 generated by default when targeting those processors.
28166 @item -mno-bit-align
28168 @opindex mno-bit-align
28169 @opindex mbit-align
28170 On System V.4 and embedded PowerPC systems do not (do) force structures
28171 and unions that contain bit-fields to be aligned to the base type of the
28174 For example, by default a structure containing nothing but 8
28175 @code{unsigned} bit-fields of length 1 is aligned to a 4-byte
28176 boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
28177 the structure is aligned to a 1-byte boundary and is 1 byte in
28180 @item -mno-strict-align
28181 @itemx -mstrict-align
28182 @opindex mno-strict-align
28183 @opindex mstrict-align
28184 On System V.4 and embedded PowerPC systems do not (do) assume that
28185 unaligned memory references are handled by the system.
28187 @item -mrelocatable
28188 @itemx -mno-relocatable
28189 @opindex mrelocatable
28190 @opindex mno-relocatable
28191 Generate code that allows (does not allow) a static executable to be
28192 relocated to a different address at run time. A simple embedded
28193 PowerPC system loader should relocate the entire contents of
28194 @code{.got2} and 4-byte locations listed in the @code{.fixup} section,
28195 a table of 32-bit addresses generated by this option. For this to
28196 work, all objects linked together must be compiled with
28197 @option{-mrelocatable} or @option{-mrelocatable-lib}.
28198 @option{-mrelocatable} code aligns the stack to an 8-byte boundary.
28200 @item -mrelocatable-lib
28201 @itemx -mno-relocatable-lib
28202 @opindex mrelocatable-lib
28203 @opindex mno-relocatable-lib
28204 Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
28205 @code{.fixup} section to allow static executables to be relocated at
28206 run time, but @option{-mrelocatable-lib} does not use the smaller stack
28207 alignment of @option{-mrelocatable}. Objects compiled with
28208 @option{-mrelocatable-lib} may be linked with objects compiled with
28209 any combination of the @option{-mrelocatable} options.
28215 On System V.4 and embedded PowerPC systems do not (do) assume that
28216 register 2 contains a pointer to a global area pointing to the addresses
28217 used in the program.
28220 @itemx -mlittle-endian
28222 @opindex mlittle-endian
28223 On System V.4 and embedded PowerPC systems compile code for the
28224 processor in little-endian mode. The @option{-mlittle-endian} option is
28225 the same as @option{-mlittle}.
28228 @itemx -mbig-endian
28230 @opindex mbig-endian
28231 On System V.4 and embedded PowerPC systems compile code for the
28232 processor in big-endian mode. The @option{-mbig-endian} option is
28233 the same as @option{-mbig}.
28235 @item -mdynamic-no-pic
28236 @opindex mdynamic-no-pic
28237 On Darwin and Mac OS X systems, compile code so that it is not
28238 relocatable, but that its external references are relocatable. The
28239 resulting code is suitable for applications, but not shared
28242 @item -msingle-pic-base
28243 @opindex msingle-pic-base
28244 Treat the register used for PIC addressing as read-only, rather than
28245 loading it in the prologue for each function. The runtime system is
28246 responsible for initializing this register with an appropriate value
28247 before execution begins.
28249 @item -mprioritize-restricted-insns=@var{priority}
28250 @opindex mprioritize-restricted-insns
28251 This option controls the priority that is assigned to
28252 dispatch-slot restricted instructions during the second scheduling
28253 pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
28254 or @samp{2} to assign no, highest, or second-highest (respectively)
28255 priority to dispatch-slot restricted
28258 @item -msched-costly-dep=@var{dependence_type}
28259 @opindex msched-costly-dep
28260 This option controls which dependences are considered costly
28261 by the target during instruction scheduling. The argument
28262 @var{dependence_type} takes one of the following values:
28266 No dependence is costly.
28269 All dependences are costly.
28271 @item @samp{true_store_to_load}
28272 A true dependence from store to load is costly.
28274 @item @samp{store_to_load}
28275 Any dependence from store to load is costly.
28278 Any dependence for which the latency is greater than or equal to
28279 @var{number} is costly.
28282 @item -minsert-sched-nops=@var{scheme}
28283 @opindex minsert-sched-nops
28284 This option controls which NOP insertion scheme is used during
28285 the second scheduling pass. The argument @var{scheme} takes one of the
28293 Pad with NOPs any dispatch group that has vacant issue slots,
28294 according to the scheduler's grouping.
28296 @item @samp{regroup_exact}
28297 Insert NOPs to force costly dependent insns into
28298 separate groups. Insert exactly as many NOPs as needed to force an insn
28299 to a new group, according to the estimated processor grouping.
28302 Insert NOPs to force costly dependent insns into
28303 separate groups. Insert @var{number} NOPs to force an insn to a new group.
28307 @opindex mcall-sysv
28308 On System V.4 and embedded PowerPC systems compile code using calling
28309 conventions that adhere to the March 1995 draft of the System V
28310 Application Binary Interface, PowerPC processor supplement. This is the
28311 default unless you configured GCC using @samp{powerpc-*-eabiaix}.
28313 @item -mcall-sysv-eabi
28315 @opindex mcall-sysv-eabi
28316 @opindex mcall-eabi
28317 Specify both @option{-mcall-sysv} and @option{-meabi} options.
28319 @item -mcall-sysv-noeabi
28320 @opindex mcall-sysv-noeabi
28321 Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
28323 @item -mcall-aixdesc
28325 On System V.4 and embedded PowerPC systems compile code for the AIX
28329 @opindex mcall-linux
28330 On System V.4 and embedded PowerPC systems compile code for the
28331 Linux-based GNU system.
28333 @item -mcall-freebsd
28334 @opindex mcall-freebsd
28335 On System V.4 and embedded PowerPC systems compile code for the
28336 FreeBSD operating system.
28338 @item -mcall-netbsd
28339 @opindex mcall-netbsd
28340 On System V.4 and embedded PowerPC systems compile code for the
28341 NetBSD operating system.
28343 @item -mcall-openbsd
28344 @opindex mcall-netbsd
28345 On System V.4 and embedded PowerPC systems compile code for the
28346 OpenBSD operating system.
28348 @item -mtraceback=@var{traceback_type}
28349 @opindex mtraceback
28350 Select the type of traceback table. Valid values for @var{traceback_type}
28351 are @samp{full}, @samp{part}, and @samp{no}.
28353 @item -maix-struct-return
28354 @opindex maix-struct-return
28355 Return all structures in memory (as specified by the AIX ABI)@.
28357 @item -msvr4-struct-return
28358 @opindex msvr4-struct-return
28359 Return structures smaller than 8 bytes in registers (as specified by the
28362 @item -mabi=@var{abi-type}
28364 Extend the current ABI with a particular extension, or remove such extension.
28365 Valid values are: @samp{altivec}, @samp{no-altivec},
28366 @samp{ibmlongdouble}, @samp{ieeelongdouble},
28367 @samp{elfv1}, @samp{elfv2},
28368 and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
28370 @item -mabi=ibmlongdouble
28371 @opindex mabi=ibmlongdouble
28372 Change the current ABI to use IBM extended-precision long double.
28373 This is not likely to work if your system defaults to using IEEE
28374 extended-precision long double. If you change the long double type
28375 from IEEE extended-precision, the compiler will issue a warning unless
28376 you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
28379 @item -mabi=ieeelongdouble
28380 @opindex mabi=ieeelongdouble
28381 Change the current ABI to use IEEE extended-precision long double.
28382 This is not likely to work if your system defaults to using IBM
28383 extended-precision long double. If you change the long double type
28384 from IBM extended-precision, the compiler will issue a warning unless
28385 you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
28389 @opindex mabi=elfv1
28390 Change the current ABI to use the ELFv1 ABI.
28391 This is the default ABI for big-endian PowerPC 64-bit Linux.
28392 Overriding the default ABI requires special system support and is
28393 likely to fail in spectacular ways.
28396 @opindex mabi=elfv2
28397 Change the current ABI to use the ELFv2 ABI.
28398 This is the default ABI for little-endian PowerPC 64-bit Linux.
28399 Overriding the default ABI requires special system support and is
28400 likely to fail in spectacular ways.
28402 @item -mgnu-attribute
28403 @itemx -mno-gnu-attribute
28404 @opindex mgnu-attribute
28405 @opindex mno-gnu-attribute
28406 Emit .gnu_attribute assembly directives to set tag/value pairs in a
28407 .gnu.attributes section that specify ABI variations in function
28408 parameters or return values.
28411 @itemx -mno-prototype
28412 @opindex mprototype
28413 @opindex mno-prototype
28414 On System V.4 and embedded PowerPC systems assume that all calls to
28415 variable argument functions are properly prototyped. Otherwise, the
28416 compiler must insert an instruction before every non-prototyped call to
28417 set or clear bit 6 of the condition code register (@code{CR}) to
28418 indicate whether floating-point values are passed in the floating-point
28419 registers in case the function takes variable arguments. With
28420 @option{-mprototype}, only calls to prototyped variable argument functions
28421 set or clear the bit.
28425 On embedded PowerPC systems, assume that the startup module is called
28426 @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
28427 @file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
28432 On embedded PowerPC systems, assume that the startup module is called
28433 @file{crt0.o} and the standard C libraries are @file{libmvme.a} and
28438 On embedded PowerPC systems, assume that the startup module is called
28439 @file{crt0.o} and the standard C libraries are @file{libads.a} and
28442 @item -myellowknife
28443 @opindex myellowknife
28444 On embedded PowerPC systems, assume that the startup module is called
28445 @file{crt0.o} and the standard C libraries are @file{libyk.a} and
28450 On System V.4 and embedded PowerPC systems, specify that you are
28451 compiling for a VxWorks system.
28455 On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
28456 header to indicate that @samp{eabi} extended relocations are used.
28462 On System V.4 and embedded PowerPC systems do (do not) adhere to the
28463 Embedded Applications Binary Interface (EABI), which is a set of
28464 modifications to the System V.4 specifications. Selecting @option{-meabi}
28465 means that the stack is aligned to an 8-byte boundary, a function
28466 @code{__eabi} is called from @code{main} to set up the EABI
28467 environment, and the @option{-msdata} option can use both @code{r2} and
28468 @code{r13} to point to two separate small data areas. Selecting
28469 @option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
28470 no EABI initialization function is called from @code{main}, and the
28471 @option{-msdata} option only uses @code{r13} to point to a single
28472 small data area. The @option{-meabi} option is on by default if you
28473 configured GCC using one of the @samp{powerpc*-*-eabi*} options.
28476 @opindex msdata=eabi
28477 On System V.4 and embedded PowerPC systems, put small initialized
28478 @code{const} global and static data in the @code{.sdata2} section, which
28479 is pointed to by register @code{r2}. Put small initialized
28480 non-@code{const} global and static data in the @code{.sdata} section,
28481 which is pointed to by register @code{r13}. Put small uninitialized
28482 global and static data in the @code{.sbss} section, which is adjacent to
28483 the @code{.sdata} section. The @option{-msdata=eabi} option is
28484 incompatible with the @option{-mrelocatable} option. The
28485 @option{-msdata=eabi} option also sets the @option{-memb} option.
28488 @opindex msdata=sysv
28489 On System V.4 and embedded PowerPC systems, put small global and static
28490 data in the @code{.sdata} section, which is pointed to by register
28491 @code{r13}. Put small uninitialized global and static data in the
28492 @code{.sbss} section, which is adjacent to the @code{.sdata} section.
28493 The @option{-msdata=sysv} option is incompatible with the
28494 @option{-mrelocatable} option.
28496 @item -msdata=default
28498 @opindex msdata=default
28500 On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
28501 compile code the same as @option{-msdata=eabi}, otherwise compile code the
28502 same as @option{-msdata=sysv}.
28505 @opindex msdata=data
28506 On System V.4 and embedded PowerPC systems, put small global
28507 data in the @code{.sdata} section. Put small uninitialized global
28508 data in the @code{.sbss} section. Do not use register @code{r13}
28509 to address small data however. This is the default behavior unless
28510 other @option{-msdata} options are used.
28514 @opindex msdata=none
28516 On embedded PowerPC systems, put all initialized global and static data
28517 in the @code{.data} section, and all uninitialized data in the
28518 @code{.bss} section.
28520 @item -mreadonly-in-sdata
28521 @opindex mreadonly-in-sdata
28522 @opindex mno-readonly-in-sdata
28523 Put read-only objects in the @code{.sdata} section as well. This is the
28526 @item -mblock-move-inline-limit=@var{num}
28527 @opindex mblock-move-inline-limit
28528 Inline all block moves (such as calls to @code{memcpy} or structure
28529 copies) less than or equal to @var{num} bytes. The minimum value for
28530 @var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
28531 targets. The default value is target-specific.
28533 @item -mblock-compare-inline-limit=@var{num}
28534 @opindex mblock-compare-inline-limit
28535 Generate non-looping inline code for all block compares (such as calls
28536 to @code{memcmp} or structure compares) less than or equal to @var{num}
28537 bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
28538 block compare is disabled. The default value is target-specific.
28540 @item -mblock-compare-inline-loop-limit=@var{num}
28541 @opindex mblock-compare-inline-loop-limit
28542 Generate an inline expansion using loop code for all block compares that
28543 are less than or equal to @var{num} bytes, but greater than the limit
28544 for non-loop inline block compare expansion. If the block length is not
28545 constant, at most @var{num} bytes will be compared before @code{memcmp}
28546 is called to compare the remainder of the block. The default value is
28549 @item -mstring-compare-inline-limit=@var{num}
28550 @opindex mstring-compare-inline-limit
28551 Compare at most @var{num} string bytes with inline code.
28552 If the difference or end of string is not found at the
28553 end of the inline compare a call to @code{strcmp} or @code{strncmp} will
28554 take care of the rest of the comparison. The default is 64 bytes.
28558 @cindex smaller data references (PowerPC)
28559 @cindex .sdata/.sdata2 references (PowerPC)
28560 On embedded PowerPC systems, put global and static items less than or
28561 equal to @var{num} bytes into the small data or BSS sections instead of
28562 the normal data or BSS section. By default, @var{num} is 8. The
28563 @option{-G @var{num}} switch is also passed to the linker.
28564 All modules should be compiled with the same @option{-G @var{num}} value.
28567 @itemx -mno-regnames
28569 @opindex mno-regnames
28570 On System V.4 and embedded PowerPC systems do (do not) emit register
28571 names in the assembly language output using symbolic forms.
28574 @itemx -mno-longcall
28576 @opindex mno-longcall
28577 By default assume that all calls are far away so that a longer and more
28578 expensive calling sequence is required. This is required for calls
28579 farther than 32 megabytes (33,554,432 bytes) from the current location.
28580 A short call is generated if the compiler knows
28581 the call cannot be that far away. This setting can be overridden by
28582 the @code{shortcall} function attribute, or by @code{#pragma
28585 Some linkers are capable of detecting out-of-range calls and generating
28586 glue code on the fly. On these systems, long calls are unnecessary and
28587 generate slower code. As of this writing, the AIX linker can do this,
28588 as can the GNU linker for PowerPC/64. It is planned to add this feature
28589 to the GNU linker for 32-bit PowerPC systems as well.
28591 On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
28592 GCC can generate long calls using an inline PLT call sequence (see
28593 @option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
28594 ELFv1 (big-endian) do not support inline PLT calls.
28596 On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
28597 callee, L42}, plus a @dfn{branch island} (glue code). The two target
28598 addresses represent the callee and the branch island. The
28599 Darwin/PPC linker prefers the first address and generates a @code{bl
28600 callee} if the PPC @code{bl} instruction reaches the callee directly;
28601 otherwise, the linker generates @code{bl L42} to call the branch
28602 island. The branch island is appended to the body of the
28603 calling function; it computes the full 32-bit address of the callee
28606 On Mach-O (Darwin) systems, this option directs the compiler emit to
28607 the glue for every direct call, and the Darwin linker decides whether
28608 to use or discard it.
28610 In the future, GCC may ignore all longcall specifications
28611 when the linker is known to generate glue.
28616 @opindex mno-pltseq
28617 Implement (do not implement) -fno-plt and long calls using an inline
28618 PLT call sequence that supports lazy linking and long calls to
28619 functions in dlopen'd shared libraries. Inline PLT calls are only
28620 supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
28621 linkers, and are enabled by default if the support is detected when
28622 configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
28623 configured with @option{--enable-secureplt}. @option{-mpltseq} code
28624 and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
28627 @item -mtls-markers
28628 @itemx -mno-tls-markers
28629 @opindex mtls-markers
28630 @opindex mno-tls-markers
28631 Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
28632 specifying the function argument. The relocation allows the linker to
28633 reliably associate function call with argument setup instructions for
28634 TLS optimization, which in turn allows GCC to better schedule the
28640 This option enables use of the reciprocal estimate and
28641 reciprocal square root estimate instructions with additional
28642 Newton-Raphson steps to increase precision instead of doing a divide or
28643 square root and divide for floating-point arguments. You should use
28644 the @option{-ffast-math} option when using @option{-mrecip} (or at
28645 least @option{-funsafe-math-optimizations},
28646 @option{-ffinite-math-only}, @option{-freciprocal-math} and
28647 @option{-fno-trapping-math}). Note that while the throughput of the
28648 sequence is generally higher than the throughput of the non-reciprocal
28649 instruction, the precision of the sequence can be decreased by up to 2
28650 ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
28653 @item -mrecip=@var{opt}
28654 @opindex mrecip=opt
28655 This option controls which reciprocal estimate instructions
28656 may be used. @var{opt} is a comma-separated list of options, which may
28657 be preceded by a @code{!} to invert the option:
28662 Enable all estimate instructions.
28665 Enable the default instructions, equivalent to @option{-mrecip}.
28668 Disable all estimate instructions, equivalent to @option{-mno-recip}.
28671 Enable the reciprocal approximation instructions for both
28672 single and double precision.
28675 Enable the single-precision reciprocal approximation instructions.
28678 Enable the double-precision reciprocal approximation instructions.
28681 Enable the reciprocal square root approximation instructions for both
28682 single and double precision.
28685 Enable the single-precision reciprocal square root approximation instructions.
28688 Enable the double-precision reciprocal square root approximation instructions.
28692 So, for example, @option{-mrecip=all,!rsqrtd} enables
28693 all of the reciprocal estimate instructions, except for the
28694 @code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
28695 which handle the double-precision reciprocal square root calculations.
28697 @item -mrecip-precision
28698 @itemx -mno-recip-precision
28699 @opindex mrecip-precision
28700 Assume (do not assume) that the reciprocal estimate instructions
28701 provide higher-precision estimates than is mandated by the PowerPC
28702 ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
28703 @option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
28704 The double-precision square root estimate instructions are not generated by
28705 default on low-precision machines, since they do not provide an
28706 estimate that converges after three steps.
28708 @item -mveclibabi=@var{type}
28709 @opindex mveclibabi
28710 Specifies the ABI type to use for vectorizing intrinsics using an
28711 external library. The only type supported at present is @samp{mass},
28712 which specifies to use IBM's Mathematical Acceleration Subsystem
28713 (MASS) libraries for vectorizing intrinsics using external libraries.
28714 GCC currently emits calls to @code{acosd2}, @code{acosf4},
28715 @code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
28716 @code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
28717 @code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
28718 @code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
28719 @code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
28720 @code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
28721 @code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
28722 @code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
28723 @code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
28724 @code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
28725 @code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
28726 @code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
28727 @code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
28728 for power7. Both @option{-ftree-vectorize} and
28729 @option{-funsafe-math-optimizations} must also be enabled. The MASS
28730 libraries must be specified at link time.
28735 Generate (do not generate) the @code{friz} instruction when the
28736 @option{-funsafe-math-optimizations} option is used to optimize
28737 rounding of floating-point values to 64-bit integer and back to floating
28738 point. The @code{friz} instruction does not return the same value if
28739 the floating-point number is too large to fit in an integer.
28741 @item -mpointers-to-nested-functions
28742 @itemx -mno-pointers-to-nested-functions
28743 @opindex mpointers-to-nested-functions
28744 Generate (do not generate) code to load up the static chain register
28745 (@code{r11}) when calling through a pointer on AIX and 64-bit Linux
28746 systems where a function pointer points to a 3-word descriptor giving
28747 the function address, TOC value to be loaded in register @code{r2}, and
28748 static chain value to be loaded in register @code{r11}. The
28749 @option{-mpointers-to-nested-functions} is on by default. You cannot
28750 call through pointers to nested functions or pointers
28751 to functions compiled in other languages that use the static chain if
28752 you use @option{-mno-pointers-to-nested-functions}.
28754 @item -msave-toc-indirect
28755 @itemx -mno-save-toc-indirect
28756 @opindex msave-toc-indirect
28757 Generate (do not generate) code to save the TOC value in the reserved
28758 stack location in the function prologue if the function calls through
28759 a pointer on AIX and 64-bit Linux systems. If the TOC value is not
28760 saved in the prologue, it is saved just before the call through the
28761 pointer. The @option{-mno-save-toc-indirect} option is the default.
28763 @item -mcompat-align-parm
28764 @itemx -mno-compat-align-parm
28765 @opindex mcompat-align-parm
28766 Generate (do not generate) code to pass structure parameters with a
28767 maximum alignment of 64 bits, for compatibility with older versions
28770 Older versions of GCC (prior to 4.9.0) incorrectly did not align a
28771 structure parameter on a 128-bit boundary when that structure contained
28772 a member requiring 128-bit alignment. This is corrected in more
28773 recent versions of GCC. This option may be used to generate code
28774 that is compatible with functions compiled with older versions of
28777 The @option{-mno-compat-align-parm} option is the default.
28779 @item -mstack-protector-guard=@var{guard}
28780 @itemx -mstack-protector-guard-reg=@var{reg}
28781 @itemx -mstack-protector-guard-offset=@var{offset}
28782 @itemx -mstack-protector-guard-symbol=@var{symbol}
28783 @opindex mstack-protector-guard
28784 @opindex mstack-protector-guard-reg
28785 @opindex mstack-protector-guard-offset
28786 @opindex mstack-protector-guard-symbol
28787 Generate stack protection code using canary at @var{guard}. Supported
28788 locations are @samp{global} for global canary or @samp{tls} for per-thread
28789 canary in the TLS block (the default with GNU libc version 2.4 or later).
28791 With the latter choice the options
28792 @option{-mstack-protector-guard-reg=@var{reg}} and
28793 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
28794 which register to use as base register for reading the canary, and from what
28795 offset from that base register. The default for those is as specified in the
28796 relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides
28797 the offset with a symbol reference to a canary in the TLS block.
28803 Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
28804 option requires that the medium code model (@option{-mcmodel=medium})
28805 and prefixed addressing (@option{-mprefixed}) options are enabled.
28808 @itemx -mno-prefixed
28810 @opindex mno-prefixed
28811 Generate (do not generate) addressing modes using prefixed load and
28812 store instructions. The @option{-mprefixed} option requires that
28813 the option @option{-mcpu=power10} (or later) is enabled.
28819 Generate (do not generate) the MMA instructions. The @option{-mma}
28820 option requires that the option @option{-mcpu=power10} (or later)
28823 @item -mrop-protect
28824 @itemx -mno-rop-protect
28825 @opindex mrop-protect
28826 @opindex mno-rop-protect
28827 Generate (do not generate) ROP protection instructions when the target
28828 processor supports them. Currently this option disables the shrink-wrap
28829 optimization (@option{-fshrink-wrap}).
28832 @itemx -mno-privileged
28833 @opindex mprivileged
28834 @opindex mno-privileged
28835 Generate (do not generate) code that will run in privileged state.
28837 @item -mblock-ops-unaligned-vsx
28838 @itemx -mno-block-ops-unaligned-vsx
28839 @opindex block-ops-unaligned-vsx
28840 @opindex no-block-ops-unaligned-vsx
28841 Generate (do not generate) unaligned vsx loads and stores for
28842 inline expansion of @code{memcpy} and @code{memmove}.
28846 @subsection RX Options
28849 These command-line options are defined for RX targets:
28852 @item -m64bit-doubles
28853 @itemx -m32bit-doubles
28854 @opindex m64bit-doubles
28855 @opindex m32bit-doubles
28856 Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
28857 or 32 bits (@option{-m32bit-doubles}) in size. The default is
28858 @option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
28859 works on 32-bit values, which is why the default is
28860 @option{-m32bit-doubles}.
28866 Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
28867 floating-point hardware. The default is enabled for the RX600
28868 series and disabled for the RX200 series.
28870 Floating-point instructions are only generated for 32-bit floating-point
28871 values, however, so the FPU hardware is not used for doubles if the
28872 @option{-m64bit-doubles} option is used.
28874 @emph{Note} If the @option{-fpu} option is enabled then
28875 @option{-funsafe-math-optimizations} is also enabled automatically.
28876 This is because the RX FPU instructions are themselves unsafe.
28878 @item -mcpu=@var{name}
28880 Selects the type of RX CPU to be targeted. Currently three types are
28881 supported, the generic @samp{RX600} and @samp{RX200} series hardware and
28882 the specific @samp{RX610} CPU. The default is @samp{RX600}.
28884 The only difference between @samp{RX600} and @samp{RX610} is that the
28885 @samp{RX610} does not support the @code{MVTIPL} instruction.
28887 The @samp{RX200} series does not have a hardware floating-point unit
28888 and so @option{-nofpu} is enabled by default when this type is
28891 @item -mbig-endian-data
28892 @itemx -mlittle-endian-data
28893 @opindex mbig-endian-data
28894 @opindex mlittle-endian-data
28895 Store data (but not code) in the big-endian format. The default is
28896 @option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
28899 @item -msmall-data-limit=@var{N}
28900 @opindex msmall-data-limit
28901 Specifies the maximum size in bytes of global and static variables
28902 which can be placed into the small data area. Using the small data
28903 area can lead to smaller and faster code, but the size of area is
28904 limited and it is up to the programmer to ensure that the area does
28905 not overflow. Also when the small data area is used one of the RX's
28906 registers (usually @code{r13}) is reserved for use pointing to this
28907 area, so it is no longer available for use by the compiler. This
28908 could result in slower and/or larger code if variables are pushed onto
28909 the stack instead of being held in this register.
28911 Note, common variables (variables that have not been initialized) and
28912 constants are not placed into the small data area as they are assigned
28913 to other sections in the output executable.
28915 The default value is zero, which disables this feature. Note, this
28916 feature is not enabled by default with higher optimization levels
28917 (@option{-O2} etc) because of the potentially detrimental effects of
28918 reserving a register. It is up to the programmer to experiment and
28919 discover whether this feature is of benefit to their program. See the
28920 description of the @option{-mpid} option for a description of how the
28921 actual register to hold the small data area pointer is chosen.
28927 Use the simulator runtime. The default is to use the libgloss
28928 board-specific runtime.
28930 @item -mas100-syntax
28931 @itemx -mno-as100-syntax
28932 @opindex mas100-syntax
28933 @opindex mno-as100-syntax
28934 When generating assembler output use a syntax that is compatible with
28935 Renesas's AS100 assembler. This syntax can also be handled by the GAS
28936 assembler, but it has some restrictions so it is not generated by default.
28938 @item -mmax-constant-size=@var{N}
28939 @opindex mmax-constant-size
28940 Specifies the maximum size, in bytes, of a constant that can be used as
28941 an operand in a RX instruction. Although the RX instruction set does
28942 allow constants of up to 4 bytes in length to be used in instructions,
28943 a longer value equates to a longer instruction. Thus in some
28944 circumstances it can be beneficial to restrict the size of constants
28945 that are used in instructions. Constants that are too big are instead
28946 placed into a constant pool and referenced via register indirection.
28948 The value @var{N} can be between 0 and 4. A value of 0 (the default)
28949 or 4 means that constants of any size are allowed.
28953 Enable linker relaxation. Linker relaxation is a process whereby the
28954 linker attempts to reduce the size of a program by finding shorter
28955 versions of various instructions. Disabled by default.
28957 @item -mint-register=@var{N}
28958 @opindex mint-register
28959 Specify the number of registers to reserve for fast interrupt handler
28960 functions. The value @var{N} can be between 0 and 4. A value of 1
28961 means that register @code{r13} is reserved for the exclusive use
28962 of fast interrupt handlers. A value of 2 reserves @code{r13} and
28963 @code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
28964 @code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
28965 A value of 0, the default, does not reserve any registers.
28967 @item -msave-acc-in-interrupts
28968 @opindex msave-acc-in-interrupts
28969 Specifies that interrupt handler functions should preserve the
28970 accumulator register. This is only necessary if normal code might use
28971 the accumulator register, for example because it performs 64-bit
28972 multiplications. The default is to ignore the accumulator as this
28973 makes the interrupt handlers faster.
28979 Enables the generation of position independent data. When enabled any
28980 access to constant data is done via an offset from a base address
28981 held in a register. This allows the location of constant data to be
28982 determined at run time without requiring the executable to be
28983 relocated, which is a benefit to embedded applications with tight
28984 memory constraints. Data that can be modified is not affected by this
28987 Note, using this feature reserves a register, usually @code{r13}, for
28988 the constant data base address. This can result in slower and/or
28989 larger code, especially in complicated functions.
28991 The actual register chosen to hold the constant data base address
28992 depends upon whether the @option{-msmall-data-limit} and/or the
28993 @option{-mint-register} command-line options are enabled. Starting
28994 with register @code{r13} and proceeding downwards, registers are
28995 allocated first to satisfy the requirements of @option{-mint-register},
28996 then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
28997 is possible for the small data area register to be @code{r8} if both
28998 @option{-mint-register=4} and @option{-mpid} are specified on the
29001 By default this feature is not enabled. The default can be restored
29002 via the @option{-mno-pid} command-line option.
29004 @item -mno-warn-multiple-fast-interrupts
29005 @itemx -mwarn-multiple-fast-interrupts
29006 @opindex mno-warn-multiple-fast-interrupts
29007 @opindex mwarn-multiple-fast-interrupts
29008 Prevents GCC from issuing a warning message if it finds more than one
29009 fast interrupt handler when it is compiling a file. The default is to
29010 issue a warning for each extra fast interrupt handler found, as the RX
29011 only supports one such interrupt.
29013 @item -mallow-string-insns
29014 @itemx -mno-allow-string-insns
29015 @opindex mallow-string-insns
29016 @opindex mno-allow-string-insns
29017 Enables or disables the use of the string manipulation instructions
29018 @code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
29019 @code{SWHILE} and also the @code{RMPA} instruction. These
29020 instructions may prefetch data, which is not safe to do if accessing
29021 an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
29022 for more information).
29024 The default is to allow these instructions, but it is not possible for
29025 GCC to reliably detect all circumstances where a string instruction
29026 might be used to access an I/O register, so their use cannot be
29027 disabled automatically. Instead it is reliant upon the programmer to
29028 use the @option{-mno-allow-string-insns} option if their program
29029 accesses I/O space.
29031 When the instructions are enabled GCC defines the C preprocessor
29032 symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
29033 symbol @code{__RX_DISALLOW_STRING_INSNS__}.
29039 Use only (or not only) @code{JSR} instructions to access functions.
29040 This option can be used when code size exceeds the range of @code{BSR}
29041 instructions. Note that @option{-mno-jsr} does not mean to not use
29042 @code{JSR} but instead means that any type of branch may be used.
29045 @emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
29046 has special significance to the RX port when used with the
29047 @code{interrupt} function attribute. This attribute indicates a
29048 function intended to process fast interrupts. GCC ensures
29049 that it only uses the registers @code{r10}, @code{r11}, @code{r12}
29050 and/or @code{r13} and only provided that the normal use of the
29051 corresponding registers have been restricted via the
29052 @option{-ffixed-@var{reg}} or @option{-mint-register} command-line
29055 @node S/390 and zSeries Options
29056 @subsection S/390 and zSeries Options
29057 @cindex S/390 and zSeries Options
29059 These are the @samp{-m} options defined for the S/390 and zSeries architecture.
29063 @itemx -msoft-float
29064 @opindex mhard-float
29065 @opindex msoft-float
29066 Use (do not use) the hardware floating-point instructions and registers
29067 for floating-point operations. When @option{-msoft-float} is specified,
29068 functions in @file{libgcc.a} are used to perform floating-point
29069 operations. When @option{-mhard-float} is specified, the compiler
29070 generates IEEE floating-point instructions. This is the default.
29073 @itemx -mno-hard-dfp
29075 @opindex mno-hard-dfp
29076 Use (do not use) the hardware decimal-floating-point instructions for
29077 decimal-floating-point operations. When @option{-mno-hard-dfp} is
29078 specified, functions in @file{libgcc.a} are used to perform
29079 decimal-floating-point operations. When @option{-mhard-dfp} is
29080 specified, the compiler generates decimal-floating-point hardware
29081 instructions. This is the default for @option{-march=z9-ec} or higher.
29083 @item -mlong-double-64
29084 @itemx -mlong-double-128
29085 @opindex mlong-double-64
29086 @opindex mlong-double-128
29087 These switches control the size of @code{long double} type. A size
29088 of 64 bits makes the @code{long double} type equivalent to the @code{double}
29089 type. This is the default.
29092 @itemx -mno-backchain
29093 @opindex mbackchain
29094 @opindex mno-backchain
29095 Store (do not store) the address of the caller's frame as backchain pointer
29096 into the callee's stack frame.
29097 A backchain may be needed to allow debugging using tools that do not understand
29098 DWARF call frame information.
29099 When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
29100 at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
29101 the backchain is placed into the topmost word of the 96/160 byte register
29104 In general, code compiled with @option{-mbackchain} is call-compatible with
29105 code compiled with @option{-mno-backchain}; however, use of the backchain
29106 for debugging purposes usually requires that the whole binary is built with
29107 @option{-mbackchain}. Note that the combination of @option{-mbackchain},
29108 @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
29109 to build a linux kernel use @option{-msoft-float}.
29111 The default is to not maintain the backchain.
29113 @item -mpacked-stack
29114 @itemx -mno-packed-stack
29115 @opindex mpacked-stack
29116 @opindex mno-packed-stack
29117 Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
29118 specified, the compiler uses the all fields of the 96/160 byte register save
29119 area only for their default purpose; unused fields still take up stack space.
29120 When @option{-mpacked-stack} is specified, register save slots are densely
29121 packed at the top of the register save area; unused space is reused for other
29122 purposes, allowing for more efficient use of the available stack space.
29123 However, when @option{-mbackchain} is also in effect, the topmost word of
29124 the save area is always used to store the backchain, and the return address
29125 register is always saved two words below the backchain.
29127 As long as the stack frame backchain is not used, code generated with
29128 @option{-mpacked-stack} is call-compatible with code generated with
29129 @option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
29130 S/390 or zSeries generated code that uses the stack frame backchain at run
29131 time, not just for debugging purposes. Such code is not call-compatible
29132 with code compiled with @option{-mpacked-stack}. Also, note that the
29133 combination of @option{-mbackchain},
29134 @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
29135 to build a linux kernel use @option{-msoft-float}.
29137 The default is to not use the packed stack layout.
29140 @itemx -mno-small-exec
29141 @opindex msmall-exec
29142 @opindex mno-small-exec
29143 Generate (or do not generate) code using the @code{bras} instruction
29144 to do subroutine calls.
29145 This only works reliably if the total executable size does not
29146 exceed 64k. The default is to use the @code{basr} instruction instead,
29147 which does not have this limitation.
29153 When @option{-m31} is specified, generate code compliant to the
29154 GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
29155 code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
29156 particular to generate 64-bit instructions. For the @samp{s390}
29157 targets, the default is @option{-m31}, while the @samp{s390x}
29158 targets default to @option{-m64}.
29164 When @option{-mzarch} is specified, generate code using the
29165 instructions available on z/Architecture.
29166 When @option{-mesa} is specified, generate code using the
29167 instructions available on ESA/390. Note that @option{-mesa} is
29168 not possible with @option{-m64}.
29169 When generating code compliant to the GNU/Linux for S/390 ABI,
29170 the default is @option{-mesa}. When generating code compliant
29171 to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
29177 The @option{-mhtm} option enables a set of builtins making use of
29178 instructions available with the transactional execution facility
29179 introduced with the IBM zEnterprise EC12 machine generation
29180 @ref{S/390 System z Built-in Functions}.
29181 @option{-mhtm} is enabled by default when using @option{-march=zEC12}.
29187 When @option{-mvx} is specified, generate code using the instructions
29188 available with the vector extension facility introduced with the IBM
29189 z13 machine generation.
29190 This option changes the ABI for some vector type values with regard to
29191 alignment and calling conventions. In case vector type values are
29192 being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
29193 command will be added to mark the resulting binary with the ABI used.
29194 @option{-mvx} is enabled by default when using @option{-march=z13}.
29197 @itemx -mno-zvector
29199 @opindex mno-zvector
29200 The @option{-mzvector} option enables vector language extensions and
29201 builtins using instructions available with the vector extension
29202 facility introduced with the IBM z13 machine generation.
29203 This option adds support for @samp{vector} to be used as a keyword to
29204 define vector type variables and arguments. @samp{vector} is only
29205 available when GNU extensions are enabled. It will not be expanded
29206 when requesting strict standard compliance e.g.@: with @option{-std=c99}.
29207 In addition to the GCC low-level builtins @option{-mzvector} enables
29208 a set of builtins added for compatibility with AltiVec-style
29209 implementations like Power and Cell. In order to make use of these
29210 builtins the header file @file{vecintrin.h} needs to be included.
29211 @option{-mzvector} is disabled by default.
29217 Generate (or do not generate) code using the @code{mvcle} instruction
29218 to perform block moves. When @option{-mno-mvcle} is specified,
29219 use a @code{mvc} loop instead. This is the default unless optimizing for
29226 Print (or do not print) additional debug information when compiling.
29227 The default is to not print debug information.
29229 @item -march=@var{cpu-type}
29231 Generate code that runs on @var{cpu-type}, which is the name of a
29232 system representing a certain processor type. Possible values for
29233 @var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
29234 @samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
29235 @samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
29236 @samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13}, and @samp{native}.
29238 The default is @option{-march=z900}.
29240 Specifying @samp{native} as cpu type can be used to select the best
29241 architecture option for the host processor.
29242 @option{-march=native} has no effect if GCC does not recognize the
29245 @item -mtune=@var{cpu-type}
29247 Tune to @var{cpu-type} everything applicable about the generated code,
29248 except for the ABI and the set of available instructions.
29249 The list of @var{cpu-type} values is the same as for @option{-march}.
29250 The default is the value used for @option{-march}.
29253 @itemx -mno-tpf-trace
29254 @opindex mtpf-trace
29255 @opindex mno-tpf-trace
29256 Generate code that adds (does not add) in TPF OS specific branches to trace
29257 routines in the operating system. This option is off by default, even
29258 when compiling for the TPF OS@.
29260 @item -mtpf-trace-skip
29261 @itemx -mno-tpf-trace-skip
29262 @opindex mtpf-trace-skip
29263 @opindex mno-tpf-trace-skip
29264 Generate code that changes (does not change) the default branch
29265 targets enabled by @option{-mtpf-trace} to point to specialized trace
29266 routines providing the ability of selectively skipping function trace
29267 entries for the TPF OS. This option is off by default, even when
29268 compiling for the TPF OS and specifying @option{-mtpf-trace}.
29271 @itemx -mno-fused-madd
29272 @opindex mfused-madd
29273 @opindex mno-fused-madd
29274 Generate code that uses (does not use) the floating-point multiply and
29275 accumulate instructions. These instructions are generated by default if
29276 hardware floating point is used.
29278 @item -mwarn-framesize=@var{framesize}
29279 @opindex mwarn-framesize
29280 Emit a warning if the current function exceeds the given frame size. Because
29281 this is a compile-time check it doesn't need to be a real problem when the program
29282 runs. It is intended to identify functions that most probably cause
29283 a stack overflow. It is useful to be used in an environment with limited stack
29284 size e.g.@: the linux kernel.
29286 @item -mwarn-dynamicstack
29287 @opindex mwarn-dynamicstack
29288 Emit a warning if the function calls @code{alloca} or uses dynamically-sized
29289 arrays. This is generally a bad idea with a limited stack size.
29291 @item -mstack-guard=@var{stack-guard}
29292 @itemx -mstack-size=@var{stack-size}
29293 @opindex mstack-guard
29294 @opindex mstack-size
29295 If these options are provided the S/390 back end emits additional instructions in
29296 the function prologue that trigger a trap if the stack size is @var{stack-guard}
29297 bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
29298 If the @var{stack-guard} option is omitted the smallest power of 2 larger than
29299 the frame size of the compiled function is chosen.
29300 These options are intended to be used to help debugging stack overflow problems.
29301 The additionally emitted code causes only little overhead and hence can also be
29302 used in production-like systems without greater performance degradation. The given
29303 values have to be exact powers of 2 and @var{stack-size} has to be greater than
29304 @var{stack-guard} without exceeding 64k.
29305 In order to be efficient the extra code makes the assumption that the stack starts
29306 at an address aligned to the value given by @var{stack-size}.
29307 The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
29309 @item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
29311 If the hotpatch option is enabled, a ``hot-patching'' function
29312 prologue is generated for all functions in the compilation unit.
29313 The funtion label is prepended with the given number of two-byte
29314 NOP instructions (@var{pre-halfwords}, maximum 1000000). After
29315 the label, 2 * @var{post-halfwords} bytes are appended, using the
29316 largest NOP like instructions the architecture allows (maximum
29319 If both arguments are zero, hotpatching is disabled.
29321 This option can be overridden for individual functions with the
29322 @code{hotpatch} attribute.
29325 @node Score Options
29326 @subsection Score Options
29327 @cindex Score Options
29329 These options are defined for Score implementations:
29334 Compile code for big-endian mode. This is the default.
29338 Compile code for little-endian mode.
29342 Disable generation of @code{bcnz} instructions.
29346 Enable generation of unaligned load and store instructions.
29350 Enable the use of multiply-accumulate instructions. Disabled by default.
29354 Specify the SCORE5 as the target architecture.
29358 Specify the SCORE5U of the target architecture.
29362 Specify the SCORE7 as the target architecture. This is the default.
29366 Specify the SCORE7D as the target architecture.
29370 @subsection SH Options
29372 These @samp{-m} options are defined for the SH implementations:
29377 Generate code for the SH1.
29381 Generate code for the SH2.
29384 Generate code for the SH2e.
29388 Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
29389 that the floating-point unit is not used.
29391 @item -m2a-single-only
29392 @opindex m2a-single-only
29393 Generate code for the SH2a-FPU, in such a way that no double-precision
29394 floating-point operations are used.
29397 @opindex m2a-single
29398 Generate code for the SH2a-FPU assuming the floating-point unit is in
29399 single-precision mode by default.
29403 Generate code for the SH2a-FPU assuming the floating-point unit is in
29404 double-precision mode by default.
29408 Generate code for the SH3.
29412 Generate code for the SH3e.
29416 Generate code for the SH4 without a floating-point unit.
29418 @item -m4-single-only
29419 @opindex m4-single-only
29420 Generate code for the SH4 with a floating-point unit that only
29421 supports single-precision arithmetic.
29425 Generate code for the SH4 assuming the floating-point unit is in
29426 single-precision mode by default.
29430 Generate code for the SH4.
29434 Generate code for SH4-100.
29436 @item -m4-100-nofpu
29437 @opindex m4-100-nofpu
29438 Generate code for SH4-100 in such a way that the
29439 floating-point unit is not used.
29441 @item -m4-100-single
29442 @opindex m4-100-single
29443 Generate code for SH4-100 assuming the floating-point unit is in
29444 single-precision mode by default.
29446 @item -m4-100-single-only
29447 @opindex m4-100-single-only
29448 Generate code for SH4-100 in such a way that no double-precision
29449 floating-point operations are used.
29453 Generate code for SH4-200.
29455 @item -m4-200-nofpu
29456 @opindex m4-200-nofpu
29457 Generate code for SH4-200 without in such a way that the
29458 floating-point unit is not used.
29460 @item -m4-200-single
29461 @opindex m4-200-single
29462 Generate code for SH4-200 assuming the floating-point unit is in
29463 single-precision mode by default.
29465 @item -m4-200-single-only
29466 @opindex m4-200-single-only
29467 Generate code for SH4-200 in such a way that no double-precision
29468 floating-point operations are used.
29472 Generate code for SH4-300.
29474 @item -m4-300-nofpu
29475 @opindex m4-300-nofpu
29476 Generate code for SH4-300 without in such a way that the
29477 floating-point unit is not used.
29479 @item -m4-300-single
29480 @opindex m4-300-single
29481 Generate code for SH4-300 in such a way that no double-precision
29482 floating-point operations are used.
29484 @item -m4-300-single-only
29485 @opindex m4-300-single-only
29486 Generate code for SH4-300 in such a way that no double-precision
29487 floating-point operations are used.
29491 Generate code for SH4-340 (no MMU, no FPU).
29495 Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
29500 Generate code for the SH4al-dsp, or for a SH4a in such a way that the
29501 floating-point unit is not used.
29503 @item -m4a-single-only
29504 @opindex m4a-single-only
29505 Generate code for the SH4a, in such a way that no double-precision
29506 floating-point operations are used.
29509 @opindex m4a-single
29510 Generate code for the SH4a assuming the floating-point unit is in
29511 single-precision mode by default.
29515 Generate code for the SH4a.
29519 Same as @option{-m4a-nofpu}, except that it implicitly passes
29520 @option{-dsp} to the assembler. GCC doesn't generate any DSP
29521 instructions at the moment.
29525 Compile code for the processor in big-endian mode.
29529 Compile code for the processor in little-endian mode.
29533 Align doubles at 64-bit boundaries. Note that this changes the calling
29534 conventions, and thus some functions from the standard C library do
29535 not work unless you recompile it first with @option{-mdalign}.
29539 Shorten some address references at link time, when possible; uses the
29540 linker option @option{-relax}.
29544 Use 32-bit offsets in @code{switch} tables. The default is to use
29549 Enable the use of bit manipulation instructions on SH2A.
29553 Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
29554 alignment constraints.
29558 Comply with the calling conventions defined by Renesas.
29561 @opindex mno-renesas
29562 Comply with the calling conventions defined for GCC before the Renesas
29563 conventions were available. This option is the default for all
29564 targets of the SH toolchain.
29567 @opindex mnomacsave
29568 Mark the @code{MAC} register as call-clobbered, even if
29569 @option{-mrenesas} is given.
29575 Control the IEEE compliance of floating-point comparisons, which affects the
29576 handling of cases where the result of a comparison is unordered. By default
29577 @option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
29578 enabled @option{-mno-ieee} is implicitly set, which results in faster
29579 floating-point greater-equal and less-equal comparisons. The implicit settings
29580 can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
29582 @item -minline-ic_invalidate
29583 @opindex minline-ic_invalidate
29584 Inline code to invalidate instruction cache entries after setting up
29585 nested function trampolines.
29586 This option has no effect if @option{-musermode} is in effect and the selected
29587 code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
29589 If the selected code generation option does not allow the use of the @code{icbi}
29590 instruction, and @option{-musermode} is not in effect, the inlined code
29591 manipulates the instruction cache address array directly with an associative
29592 write. This not only requires privileged mode at run time, but it also
29593 fails if the cache line had been mapped via the TLB and has become unmapped.
29597 Dump instruction size and location in the assembly code.
29600 @opindex mpadstruct
29601 This option is deprecated. It pads structures to multiple of 4 bytes,
29602 which is incompatible with the SH ABI@.
29604 @item -matomic-model=@var{model}
29605 @opindex matomic-model=@var{model}
29606 Sets the model of atomic operations and additional parameters as a comma
29607 separated list. For details on the atomic built-in functions see
29608 @ref{__atomic Builtins}. The following models and parameters are supported:
29613 Disable compiler generated atomic sequences and emit library calls for atomic
29614 operations. This is the default if the target is not @code{sh*-*-linux*}.
29617 Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
29618 built-in functions. The generated atomic sequences require additional support
29619 from the interrupt/exception handling code of the system and are only suitable
29620 for SH3* and SH4* single-core systems. This option is enabled by default when
29621 the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
29622 this option also partially utilizes the hardware atomic instructions
29623 @code{movli.l} and @code{movco.l} to create more efficient code, unless
29624 @samp{strict} is specified.
29627 Generate software atomic sequences that use a variable in the thread control
29628 block. This is a variation of the gUSA sequences which can also be used on
29629 SH1* and SH2* targets. The generated atomic sequences require additional
29630 support from the interrupt/exception handling code of the system and are only
29631 suitable for single-core systems. When using this model, the @samp{gbr-offset=}
29632 parameter has to be specified as well.
29635 Generate software atomic sequences that temporarily disable interrupts by
29636 setting @code{SR.IMASK = 1111}. This model works only when the program runs
29637 in privileged mode and is only suitable for single-core systems. Additional
29638 support from the interrupt/exception handling code of the system is not
29639 required. This model is enabled by default when the target is
29640 @code{sh*-*-linux*} and SH1* or SH2*.
29643 Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
29644 instructions only. This is only available on SH4A and is suitable for
29645 multi-core systems. Since the hardware instructions support only 32 bit atomic
29646 variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
29647 Code compiled with this option is also compatible with other software
29648 atomic model interrupt/exception handling systems if executed on an SH4A
29649 system. Additional support from the interrupt/exception handling code of the
29650 system is not required for this model.
29653 This parameter specifies the offset in bytes of the variable in the thread
29654 control block structure that should be used by the generated atomic sequences
29655 when the @samp{soft-tcb} model has been selected. For other models this
29656 parameter is ignored. The specified value must be an integer multiple of four
29657 and in the range 0-1020.
29660 This parameter prevents mixed usage of multiple atomic models, even if they
29661 are compatible, and makes the compiler generate atomic sequences of the
29662 specified model only.
29668 Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
29669 Notice that depending on the particular hardware and software configuration
29670 this can degrade overall performance due to the operand cache line flushes
29671 that are implied by the @code{tas.b} instruction. On multi-core SH4A
29672 processors the @code{tas.b} instruction must be used with caution since it
29673 can result in data corruption for certain cache configurations.
29676 @opindex mprefergot
29677 When generating position-independent code, emit function calls using
29678 the Global Offset Table instead of the Procedure Linkage Table.
29681 @itemx -mno-usermode
29683 @opindex mno-usermode
29684 Don't allow (allow) the compiler generating privileged mode code. Specifying
29685 @option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
29686 inlined code would not work in user mode. @option{-musermode} is the default
29687 when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
29688 @option{-musermode} has no effect, since there is no user mode.
29690 @item -multcost=@var{number}
29691 @opindex multcost=@var{number}
29692 Set the cost to assume for a multiply insn.
29694 @item -mdiv=@var{strategy}
29695 @opindex mdiv=@var{strategy}
29696 Set the division strategy to be used for integer division operations.
29697 @var{strategy} can be one of:
29702 Calls a library function that uses the single-step division instruction
29703 @code{div1} to perform the operation. Division by zero calculates an
29704 unspecified result and does not trap. This is the default except for SH4,
29705 SH2A and SHcompact.
29708 Calls a library function that performs the operation in double precision
29709 floating point. Division by zero causes a floating-point exception. This is
29710 the default for SHcompact with FPU. Specifying this for targets that do not
29711 have a double precision FPU defaults to @code{call-div1}.
29714 Calls a library function that uses a lookup table for small divisors and
29715 the @code{div1} instruction with case distinction for larger divisors. Division
29716 by zero calculates an unspecified result and does not trap. This is the default
29717 for SH4. Specifying this for targets that do not have dynamic shift
29718 instructions defaults to @code{call-div1}.
29722 When a division strategy has not been specified the default strategy is
29723 selected based on the current target. For SH2A the default strategy is to
29724 use the @code{divs} and @code{divu} instructions instead of library function
29727 @item -maccumulate-outgoing-args
29728 @opindex maccumulate-outgoing-args
29729 Reserve space once for outgoing arguments in the function prologue rather
29730 than around each call. Generally beneficial for performance and size. Also
29731 needed for unwinding to avoid changing the stack frame around conditional code.
29733 @item -mdivsi3_libfunc=@var{name}
29734 @opindex mdivsi3_libfunc=@var{name}
29735 Set the name of the library function used for 32-bit signed division to
29737 This only affects the name used in the @samp{call} division strategies, and
29738 the compiler still expects the same sets of input/output/clobbered registers as
29739 if this option were not present.
29741 @item -mfixed-range=@var{register-range}
29742 @opindex mfixed-range
29743 Generate code treating the given register range as fixed registers.
29744 A fixed register is one that the register allocator cannot use. This is
29745 useful when compiling kernel code. A register range is specified as
29746 two registers separated by a dash. Multiple register ranges can be
29747 specified separated by a comma.
29749 @item -mbranch-cost=@var{num}
29750 @opindex mbranch-cost=@var{num}
29751 Assume @var{num} to be the cost for a branch instruction. Higher numbers
29752 make the compiler try to generate more branch-free code if possible.
29753 If not specified the value is selected depending on the processor type that
29754 is being compiled for.
29757 @itemx -mno-zdcbranch
29758 @opindex mzdcbranch
29759 @opindex mno-zdcbranch
29760 Assume (do not assume) that zero displacement conditional branch instructions
29761 @code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
29762 compiler prefers zero displacement branch code sequences. This is
29763 enabled by default when generating code for SH4 and SH4A. It can be explicitly
29764 disabled by specifying @option{-mno-zdcbranch}.
29766 @item -mcbranch-force-delay-slot
29767 @opindex mcbranch-force-delay-slot
29768 Force the usage of delay slots for conditional branches, which stuffs the delay
29769 slot with a @code{nop} if a suitable instruction cannot be found. By default
29770 this option is disabled. It can be enabled to work around hardware bugs as
29771 found in the original SH7055.
29774 @itemx -mno-fused-madd
29775 @opindex mfused-madd
29776 @opindex mno-fused-madd
29777 Generate code that uses (does not use) the floating-point multiply and
29778 accumulate instructions. These instructions are generated by default
29779 if hardware floating point is used. The machine-dependent
29780 @option{-mfused-madd} option is now mapped to the machine-independent
29781 @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
29782 mapped to @option{-ffp-contract=off}.
29788 Allow or disallow the compiler to emit the @code{fsca} instruction for sine
29789 and cosine approximations. The option @option{-mfsca} must be used in
29790 combination with @option{-funsafe-math-optimizations}. It is enabled by default
29791 when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
29792 approximations even if @option{-funsafe-math-optimizations} is in effect.
29798 Allow or disallow the compiler to emit the @code{fsrra} instruction for
29799 reciprocal square root approximations. The option @option{-mfsrra} must be used
29800 in combination with @option{-funsafe-math-optimizations} and
29801 @option{-ffinite-math-only}. It is enabled by default when generating code for
29802 SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
29803 even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
29806 @item -mpretend-cmove
29807 @opindex mpretend-cmove
29808 Prefer zero-displacement conditional branches for conditional move instruction
29809 patterns. This can result in faster code on the SH4 processor.
29813 Generate code using the FDPIC ABI.
29817 @node Solaris 2 Options
29818 @subsection Solaris 2 Options
29819 @cindex Solaris 2 options
29821 These @samp{-m} options are supported on Solaris 2:
29824 @item -mclear-hwcap
29825 @opindex mclear-hwcap
29826 @option{-mclear-hwcap} tells the compiler to remove the hardware
29827 capabilities generated by the Solaris assembler. This is only necessary
29828 when object files use ISA extensions not supported by the current
29829 machine, but check at runtime whether or not to use them.
29831 @item -mimpure-text
29832 @opindex mimpure-text
29833 @option{-mimpure-text}, used in addition to @option{-shared}, tells
29834 the compiler to not pass @option{-z text} to the linker when linking a
29835 shared object. Using this option, you can link position-dependent
29836 code into a shared object.
29838 @option{-mimpure-text} suppresses the ``relocations remain against
29839 allocatable but non-writable sections'' linker error message.
29840 However, the necessary relocations trigger copy-on-write, and the
29841 shared object is not actually shared across processes. Instead of
29842 using @option{-mimpure-text}, you should compile all source code with
29843 @option{-fpic} or @option{-fPIC}.
29847 These switches are supported in addition to the above on Solaris 2:
29852 This is a synonym for @option{-pthread}.
29855 @node SPARC Options
29856 @subsection SPARC Options
29857 @cindex SPARC options
29859 These @samp{-m} options are supported on the SPARC:
29862 @item -mno-app-regs
29864 @opindex mno-app-regs
29866 Specify @option{-mapp-regs} to generate output using the global registers
29867 2 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
29868 global register 1, each global register 2 through 4 is then treated as an
29869 allocable register that is clobbered by function calls. This is the default.
29871 To be fully SVR4 ABI-compliant at the cost of some performance loss,
29872 specify @option{-mno-app-regs}. You should compile libraries and system
29873 software with this option.
29879 With @option{-mflat}, the compiler does not generate save/restore instructions
29880 and uses a ``flat'' or single register window model. This model is compatible
29881 with the regular register window model. The local registers and the input
29882 registers (0--5) are still treated as ``call-saved'' registers and are
29883 saved on the stack as needed.
29885 With @option{-mno-flat} (the default), the compiler generates save/restore
29886 instructions (except for leaf functions). This is the normal operating mode.
29889 @itemx -mhard-float
29891 @opindex mhard-float
29892 Generate output containing floating-point instructions. This is the
29896 @itemx -msoft-float
29898 @opindex msoft-float
29899 Generate output containing library calls for floating point.
29900 @strong{Warning:} the requisite libraries are not available for all SPARC
29901 targets. Normally the facilities of the machine's usual C compiler are
29902 used, but this cannot be done directly in cross-compilation. You must make
29903 your own arrangements to provide suitable library functions for
29904 cross-compilation. The embedded targets @samp{sparc-*-aout} and
29905 @samp{sparclite-*-*} do provide software floating-point support.
29907 @option{-msoft-float} changes the calling convention in the output file;
29908 therefore, it is only useful if you compile @emph{all} of a program with
29909 this option. In particular, you need to compile @file{libgcc.a}, the
29910 library that comes with GCC, with @option{-msoft-float} in order for
29913 @item -mhard-quad-float
29914 @opindex mhard-quad-float
29915 Generate output containing quad-word (long double) floating-point
29918 @item -msoft-quad-float
29919 @opindex msoft-quad-float
29920 Generate output containing library calls for quad-word (long double)
29921 floating-point instructions. The functions called are those specified
29922 in the SPARC ABI@. This is the default.
29924 As of this writing, there are no SPARC implementations that have hardware
29925 support for the quad-word floating-point instructions. They all invoke
29926 a trap handler for one of these instructions, and then the trap handler
29927 emulates the effect of the instruction. Because of the trap handler overhead,
29928 this is much slower than calling the ABI library routines. Thus the
29929 @option{-msoft-quad-float} option is the default.
29931 @item -mno-unaligned-doubles
29932 @itemx -munaligned-doubles
29933 @opindex mno-unaligned-doubles
29934 @opindex munaligned-doubles
29935 Assume that doubles have 8-byte alignment. This is the default.
29937 With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
29938 alignment only if they are contained in another type, or if they have an
29939 absolute address. Otherwise, it assumes they have 4-byte alignment.
29940 Specifying this option avoids some rare compatibility problems with code
29941 generated by other compilers. It is not the default because it results
29942 in a performance loss, especially for floating-point code.
29945 @itemx -mno-user-mode
29946 @opindex muser-mode
29947 @opindex mno-user-mode
29948 Do not generate code that can only run in supervisor mode. This is relevant
29949 only for the @code{casa} instruction emitted for the LEON3 processor. This
29952 @item -mfaster-structs
29953 @itemx -mno-faster-structs
29954 @opindex mfaster-structs
29955 @opindex mno-faster-structs
29956 With @option{-mfaster-structs}, the compiler assumes that structures
29957 should have 8-byte alignment. This enables the use of pairs of
29958 @code{ldd} and @code{std} instructions for copies in structure
29959 assignment, in place of twice as many @code{ld} and @code{st} pairs.
29960 However, the use of this changed alignment directly violates the SPARC
29961 ABI@. Thus, it's intended only for use on targets where the developer
29962 acknowledges that their resulting code is not directly in line with
29963 the rules of the ABI@.
29965 @item -mstd-struct-return
29966 @itemx -mno-std-struct-return
29967 @opindex mstd-struct-return
29968 @opindex mno-std-struct-return
29969 With @option{-mstd-struct-return}, the compiler generates checking code
29970 in functions returning structures or unions to detect size mismatches
29971 between the two sides of function calls, as per the 32-bit ABI@.
29973 The default is @option{-mno-std-struct-return}. This option has no effect
29980 Enable Local Register Allocation. This is the default for SPARC since GCC 7
29981 so @option{-mno-lra} needs to be passed to get old Reload.
29983 @item -mcpu=@var{cpu_type}
29985 Set the instruction set, register set, and instruction scheduling parameters
29986 for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
29987 @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
29988 @samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
29989 @samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
29990 @samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
29991 @samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
29994 Native Solaris and GNU/Linux toolchains also support the value @samp{native},
29995 which selects the best architecture option for the host processor.
29996 @option{-mcpu=native} has no effect if GCC does not recognize
29999 Default instruction scheduling parameters are used for values that select
30000 an architecture and not an implementation. These are @samp{v7}, @samp{v8},
30001 @samp{sparclite}, @samp{sparclet}, @samp{v9}.
30003 Here is a list of each supported architecture and their supported
30011 supersparc, hypersparc, leon, leon3, leon5
30014 f930, f934, sparclite86x
30020 ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
30024 By default (unless configured otherwise), GCC generates code for the V7
30025 variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
30026 additionally optimizes it for the Cypress CY7C602 chip, as used in the
30027 SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
30028 SPARCStation 1, 2, IPX etc.
30030 With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
30031 architecture. The only difference from V7 code is that the compiler emits
30032 the integer multiply and integer divide instructions which exist in SPARC-V8
30033 but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
30034 optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
30037 With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
30038 the SPARC architecture. This adds the integer multiply, integer divide step
30039 and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
30040 With @option{-mcpu=f930}, the compiler additionally optimizes it for the
30041 Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
30042 @option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
30043 MB86934 chip, which is the more recent SPARClite with FPU@.
30045 With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
30046 the SPARC architecture. This adds the integer multiply, multiply/accumulate,
30047 integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
30048 but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
30049 optimizes it for the TEMIC SPARClet chip.
30051 With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
30052 architecture. This adds 64-bit integer and floating-point move instructions,
30053 3 additional floating-point condition code registers and conditional move
30054 instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
30055 optimizes it for the Sun UltraSPARC I/II/IIi chips. With
30056 @option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
30057 Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
30058 @option{-mcpu=niagara}, the compiler additionally optimizes it for
30059 Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
30060 additionally optimizes it for Sun UltraSPARC T2 chips. With
30061 @option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
30062 UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
30063 additionally optimizes it for Sun UltraSPARC T4 chips. With
30064 @option{-mcpu=niagara7}, the compiler additionally optimizes it for
30065 Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
30066 additionally optimizes it for Oracle M8 chips.
30068 @item -mtune=@var{cpu_type}
30070 Set the instruction scheduling parameters for machine type
30071 @var{cpu_type}, but do not set the instruction set or register set that the
30072 option @option{-mcpu=@var{cpu_type}} does.
30074 The same values for @option{-mcpu=@var{cpu_type}} can be used for
30075 @option{-mtune=@var{cpu_type}}, but the only useful values are those
30076 that select a particular CPU implementation. Those are
30077 @samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
30078 @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
30079 @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
30080 @samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
30081 @samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
30082 and GNU/Linux toolchains, @samp{native} can also be used.
30087 @opindex mno-v8plus
30088 With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
30089 difference from the V8 ABI is that the global and out registers are
30090 considered 64 bits wide. This is enabled by default on Solaris in 32-bit
30091 mode for all SPARC-V9 processors.
30097 With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
30098 Visual Instruction Set extensions. The default is @option{-mno-vis}.
30104 With @option{-mvis2}, GCC generates code that takes advantage of
30105 version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
30106 default is @option{-mvis2} when targeting a cpu that supports such
30107 instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
30108 also sets @option{-mvis}.
30114 With @option{-mvis3}, GCC generates code that takes advantage of
30115 version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
30116 default is @option{-mvis3} when targeting a cpu that supports such
30117 instructions, such as niagara-3 and later. Setting @option{-mvis3}
30118 also sets @option{-mvis2} and @option{-mvis}.
30124 With @option{-mvis4}, GCC generates code that takes advantage of
30125 version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
30126 default is @option{-mvis4} when targeting a cpu that supports such
30127 instructions, such as niagara-7 and later. Setting @option{-mvis4}
30128 also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}.
30134 With @option{-mvis4b}, GCC generates code that takes advantage of
30135 version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
30136 the additional VIS instructions introduced in the Oracle SPARC
30137 Architecture 2017. The default is @option{-mvis4b} when targeting a
30138 cpu that supports such instructions, such as m8 and later. Setting
30139 @option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3},
30140 @option{-mvis2} and @option{-mvis}.
30145 @opindex mno-cbcond
30146 With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
30147 Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
30148 when targeting a CPU that supports such instructions, such as Niagara-4 and
30155 With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
30156 Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
30157 when targeting a CPU that supports such instructions, such as Niagara-3 and
30163 @opindex mno-fsmuld
30164 With @option{-mfsmuld}, GCC generates code that takes advantage of the
30165 Floating-point Multiply Single to Double (FsMULd) instruction. The default is
30166 @option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
30167 or V9 with FPU except @option{-mcpu=leon}.
30173 With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
30174 Population Count instruction. The default is @option{-mpopc}
30175 when targeting a CPU that supports such an instruction, such as Niagara-2 and
30182 With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
30183 Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
30184 when targeting a CPU that supports such an instruction, such as Niagara-7 and
30188 @opindex mfix-at697f
30189 Enable the documented workaround for the single erratum of the Atmel AT697F
30190 processor (which corresponds to erratum #13 of the AT697E processor).
30193 @opindex mfix-ut699
30194 Enable the documented workarounds for the floating-point errata and the data
30195 cache nullify errata of the UT699 processor.
30198 @opindex mfix-ut700
30199 Enable the documented workaround for the back-to-back store errata of
30200 the UT699E/UT700 processor.
30202 @item -mfix-gr712rc
30203 @opindex mfix-gr712rc
30204 Enable the documented workaround for the back-to-back store errata of
30205 the GR712RC processor.
30208 These @samp{-m} options are supported in addition to the above
30209 on SPARC-V9 processors in 64-bit environments:
30216 Generate code for a 32-bit or 64-bit environment.
30217 The 32-bit environment sets int, long and pointer to 32 bits.
30218 The 64-bit environment sets int to 32 bits and long and pointer
30221 @item -mcmodel=@var{which}
30223 Set the code model to one of
30227 The Medium/Low code model: 64-bit addresses, programs
30228 must be linked in the low 32 bits of memory. Programs can be statically
30229 or dynamically linked.
30232 The Medium/Middle code model: 64-bit addresses, programs
30233 must be linked in the low 44 bits of memory, the text and data segments must
30234 be less than 2GB in size and the data segment must be located within 2GB of
30238 The Medium/Anywhere code model: 64-bit addresses, programs
30239 may be linked anywhere in memory, the text and data segments must be less
30240 than 2GB in size and the data segment must be located within 2GB of the
30244 The Medium/Anywhere code model for embedded systems:
30245 64-bit addresses, the text and data segments must be less than 2GB in
30246 size, both starting anywhere in memory (determined at link time). The
30247 global register %g4 points to the base of the data segment. Programs
30248 are statically linked and PIC is not supported.
30251 @item -mmemory-model=@var{mem-model}
30252 @opindex mmemory-model
30253 Set the memory model in force on the processor to one of
30257 The default memory model for the processor and operating system.
30260 Relaxed Memory Order
30263 Partial Store Order
30269 Sequential Consistency
30272 These memory models are formally defined in Appendix D of the SPARC-V9
30273 architecture manual, as set in the processor's @code{PSTATE.MM} field.
30276 @itemx -mno-stack-bias
30277 @opindex mstack-bias
30278 @opindex mno-stack-bias
30279 With @option{-mstack-bias}, GCC assumes that the stack pointer, and
30280 frame pointer if present, are offset by @minus{}2047 which must be added back
30281 when making stack frame references. This is the default in 64-bit mode.
30282 Otherwise, assume no such offset is present.
30285 @node System V Options
30286 @subsection Options for System V
30288 These additional options are available on System V Release 4 for
30289 compatibility with other compilers on those systems:
30294 Create a shared object.
30295 It is recommended that @option{-symbolic} or @option{-shared} be used instead.
30299 Identify the versions of each tool used by the compiler, in a
30300 @code{.ident} assembler directive in the output.
30304 Refrain from adding @code{.ident} directives to the output file (this is
30307 @item -YP,@var{dirs}
30309 Search the directories @var{dirs}, and no others, for libraries
30310 specified with @option{-l}.
30312 @item -Ym,@var{dir}
30314 Look in the directory @var{dir} to find the M4 preprocessor.
30315 The assembler uses this option.
30316 @c This is supposed to go with a -Yd for predefined M4 macro files, but
30317 @c the generic assembler that comes with Solaris takes just -Ym.
30320 @node TILE-Gx Options
30321 @subsection TILE-Gx Options
30322 @cindex TILE-Gx options
30324 These @samp{-m} options are supported on the TILE-Gx:
30327 @item -mcmodel=small
30328 @opindex mcmodel=small
30329 Generate code for the small model. The distance for direct calls is
30330 limited to 500M in either direction. PC-relative addresses are 32
30331 bits. Absolute addresses support the full address range.
30333 @item -mcmodel=large
30334 @opindex mcmodel=large
30335 Generate code for the large model. There is no limitation on call
30336 distance, pc-relative addresses, or absolute addresses.
30338 @item -mcpu=@var{name}
30340 Selects the type of CPU to be targeted. Currently the only supported
30341 type is @samp{tilegx}.
30347 Generate code for a 32-bit or 64-bit environment. The 32-bit
30348 environment sets int, long, and pointer to 32 bits. The 64-bit
30349 environment sets int to 32 bits and long and pointer to 64 bits.
30352 @itemx -mlittle-endian
30353 @opindex mbig-endian
30354 @opindex mlittle-endian
30355 Generate code in big/little endian mode, respectively.
30358 @node TILEPro Options
30359 @subsection TILEPro Options
30360 @cindex TILEPro options
30362 These @samp{-m} options are supported on the TILEPro:
30365 @item -mcpu=@var{name}
30367 Selects the type of CPU to be targeted. Currently the only supported
30368 type is @samp{tilepro}.
30372 Generate code for a 32-bit environment, which sets int, long, and
30373 pointer to 32 bits. This is the only supported behavior so the flag
30374 is essentially ignored.
30378 @subsection V850 Options
30379 @cindex V850 Options
30381 These @samp{-m} options are defined for V850 implementations:
30385 @itemx -mno-long-calls
30386 @opindex mlong-calls
30387 @opindex mno-long-calls
30388 Treat all calls as being far away (near). If calls are assumed to be
30389 far away, the compiler always loads the function's address into a
30390 register, and calls indirect through the pointer.
30396 Do not optimize (do optimize) basic blocks that use the same index
30397 pointer 4 or more times to copy pointer into the @code{ep} register, and
30398 use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
30399 option is on by default if you optimize.
30401 @item -mno-prolog-function
30402 @itemx -mprolog-function
30403 @opindex mno-prolog-function
30404 @opindex mprolog-function
30405 Do not use (do use) external functions to save and restore registers
30406 at the prologue and epilogue of a function. The external functions
30407 are slower, but use less code space if more than one function saves
30408 the same number of registers. The @option{-mprolog-function} option
30409 is on by default if you optimize.
30413 Try to make the code as small as possible. At present, this just turns
30414 on the @option{-mep} and @option{-mprolog-function} options.
30416 @item -mtda=@var{n}
30418 Put static or global variables whose size is @var{n} bytes or less into
30419 the tiny data area that register @code{ep} points to. The tiny data
30420 area can hold up to 256 bytes in total (128 bytes for byte references).
30422 @item -msda=@var{n}
30424 Put static or global variables whose size is @var{n} bytes or less into
30425 the small data area that register @code{gp} points to. The small data
30426 area can hold up to 64 kilobytes.
30428 @item -mzda=@var{n}
30430 Put static or global variables whose size is @var{n} bytes or less into
30431 the first 32 kilobytes of memory.
30435 Specify that the target processor is the V850.
30439 Specify that the target processor is the V850E3V5. The preprocessor
30440 constant @code{__v850e3v5__} is defined if this option is used.
30444 Specify that the target processor is the V850E3V5. This is an alias for
30445 the @option{-mv850e3v5} option.
30449 Specify that the target processor is the V850E2V3. The preprocessor
30450 constant @code{__v850e2v3__} is defined if this option is used.
30454 Specify that the target processor is the V850E2. The preprocessor
30455 constant @code{__v850e2__} is defined if this option is used.
30459 Specify that the target processor is the V850E1. The preprocessor
30460 constants @code{__v850e1__} and @code{__v850e__} are defined if
30461 this option is used.
30465 Specify that the target processor is the V850ES. This is an alias for
30466 the @option{-mv850e1} option.
30470 Specify that the target processor is the V850E@. The preprocessor
30471 constant @code{__v850e__} is defined if this option is used.
30473 If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
30474 nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
30475 are defined then a default target processor is chosen and the
30476 relevant @samp{__v850*__} preprocessor constant is defined.
30478 The preprocessor constants @code{__v850} and @code{__v851__} are always
30479 defined, regardless of which processor variant is the target.
30481 @item -mdisable-callt
30482 @itemx -mno-disable-callt
30483 @opindex mdisable-callt
30484 @opindex mno-disable-callt
30485 This option suppresses generation of the @code{CALLT} instruction for the
30486 v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
30489 This option is enabled by default when the RH850 ABI is
30490 in use (see @option{-mrh850-abi}), and disabled by default when the
30491 GCC ABI is in use. If @code{CALLT} instructions are being generated
30492 then the C preprocessor symbol @code{__V850_CALLT__} is defined.
30498 Pass on (or do not pass on) the @option{-mrelax} command-line option
30502 @itemx -mno-long-jumps
30503 @opindex mlong-jumps
30504 @opindex mno-long-jumps
30505 Disable (or re-enable) the generation of PC-relative jump instructions.
30508 @itemx -mhard-float
30509 @opindex msoft-float
30510 @opindex mhard-float
30511 Disable (or re-enable) the generation of hardware floating point
30512 instructions. This option is only significant when the target
30513 architecture is @samp{V850E2V3} or higher. If hardware floating point
30514 instructions are being generated then the C preprocessor symbol
30515 @code{__FPU_OK__} is defined, otherwise the symbol
30516 @code{__NO_FPU__} is defined.
30520 Enables the use of the e3v5 LOOP instruction. The use of this
30521 instruction is not enabled by default when the e3v5 architecture is
30522 selected because its use is still experimental.
30526 @opindex mrh850-abi
30528 Enables support for the RH850 version of the V850 ABI. This is the
30529 default. With this version of the ABI the following rules apply:
30533 Integer sized structures and unions are returned via a memory pointer
30534 rather than a register.
30537 Large structures and unions (more than 8 bytes in size) are passed by
30541 Functions are aligned to 16-bit boundaries.
30544 The @option{-m8byte-align} command-line option is supported.
30547 The @option{-mdisable-callt} command-line option is enabled by
30548 default. The @option{-mno-disable-callt} command-line option is not
30552 When this version of the ABI is enabled the C preprocessor symbol
30553 @code{__V850_RH850_ABI__} is defined.
30557 Enables support for the old GCC version of the V850 ABI. With this
30558 version of the ABI the following rules apply:
30562 Integer sized structures and unions are returned in register @code{r10}.
30565 Large structures and unions (more than 8 bytes in size) are passed by
30569 Functions are aligned to 32-bit boundaries, unless optimizing for
30573 The @option{-m8byte-align} command-line option is not supported.
30576 The @option{-mdisable-callt} command-line option is supported but not
30577 enabled by default.
30580 When this version of the ABI is enabled the C preprocessor symbol
30581 @code{__V850_GCC_ABI__} is defined.
30583 @item -m8byte-align
30584 @itemx -mno-8byte-align
30585 @opindex m8byte-align
30586 @opindex mno-8byte-align
30587 Enables support for @code{double} and @code{long long} types to be
30588 aligned on 8-byte boundaries. The default is to restrict the
30589 alignment of all objects to at most 4-bytes. When
30590 @option{-m8byte-align} is in effect the C preprocessor symbol
30591 @code{__V850_8BYTE_ALIGN__} is defined.
30594 @opindex mbig-switch
30595 Generate code suitable for big switch tables. Use this option only if
30596 the assembler/linker complain about out of range branches within a switch
30601 This option causes r2 and r5 to be used in the code generated by
30602 the compiler. This setting is the default.
30604 @item -mno-app-regs
30605 @opindex mno-app-regs
30606 This option causes r2 and r5 to be treated as fixed registers.
30611 @subsection VAX Options
30612 @cindex VAX options
30614 These @samp{-m} options are defined for the VAX:
30619 Do not output certain jump instructions (@code{aobleq} and so on)
30620 that the Unix assembler for the VAX cannot handle across long
30625 Do output those jump instructions, on the assumption that the
30626 GNU assembler is being used.
30630 Output code for G-format floating-point numbers instead of D-format.
30636 Enable Local Register Allocation. This is still experimental for the VAX,
30637 so by default the compiler uses standard reload.
30640 @node Visium Options
30641 @subsection Visium Options
30642 @cindex Visium options
30648 A program which performs file I/O and is destined to run on an MCM target
30649 should be linked with this option. It causes the libraries libc.a and
30650 libdebug.a to be linked. The program should be run on the target under
30651 the control of the GDB remote debugging stub.
30655 A program which performs file I/O and is destined to run on the simulator
30656 should be linked with option. This causes libraries libc.a and libsim.a to
30660 @itemx -mhard-float
30662 @opindex mhard-float
30663 Generate code containing floating-point instructions. This is the
30667 @itemx -msoft-float
30669 @opindex msoft-float
30670 Generate code containing library calls for floating-point.
30672 @option{-msoft-float} changes the calling convention in the output file;
30673 therefore, it is only useful if you compile @emph{all} of a program with
30674 this option. In particular, you need to compile @file{libgcc.a}, the
30675 library that comes with GCC, with @option{-msoft-float} in order for
30678 @item -mcpu=@var{cpu_type}
30680 Set the instruction set, register set, and instruction scheduling parameters
30681 for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
30682 @samp{mcm}, @samp{gr5} and @samp{gr6}.
30684 @samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
30686 By default (unless configured otherwise), GCC generates code for the GR5
30687 variant of the Visium architecture.
30689 With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
30690 architecture. The only difference from GR5 code is that the compiler will
30691 generate block move instructions.
30693 @item -mtune=@var{cpu_type}
30695 Set the instruction scheduling parameters for machine type @var{cpu_type},
30696 but do not set the instruction set or register set that the option
30697 @option{-mcpu=@var{cpu_type}} would.
30701 Generate code for the supervisor mode, where there are no restrictions on
30702 the access to general registers. This is the default.
30705 @opindex muser-mode
30706 Generate code for the user mode, where the access to some general registers
30707 is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
30708 mode; on the GR6, only registers r29 to r31 are affected.
30712 @subsection VMS Options
30714 These @samp{-m} options are defined for the VMS implementations:
30717 @item -mvms-return-codes
30718 @opindex mvms-return-codes
30719 Return VMS condition codes from @code{main}. The default is to return POSIX-style
30720 condition (e.g.@: error) codes.
30722 @item -mdebug-main=@var{prefix}
30723 @opindex mdebug-main=@var{prefix}
30724 Flag the first routine whose name starts with @var{prefix} as the main
30725 routine for the debugger.
30729 Default to 64-bit memory allocation routines.
30731 @item -mpointer-size=@var{size}
30732 @opindex mpointer-size=@var{size}
30733 Set the default size of pointers. Possible options for @var{size} are
30734 @samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
30735 for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
30736 The later option disables @code{pragma pointer_size}.
30739 @node VxWorks Options
30740 @subsection VxWorks Options
30741 @cindex VxWorks Options
30743 The options in this section are defined for all VxWorks targets.
30744 Options specific to the target hardware are listed with the other
30745 options for that target.
30750 GCC can generate code for both VxWorks kernels and real time processes
30751 (RTPs). This option switches from the former to the latter. It also
30752 defines the preprocessor macro @code{__RTP__}.
30755 @opindex non-static
30756 Link an RTP executable against shared libraries rather than static
30757 libraries. The options @option{-static} and @option{-shared} can
30758 also be used for RTPs (@pxref{Link Options}); @option{-static}
30765 These options are passed down to the linker. They are defined for
30766 compatibility with Diab.
30769 @opindex Xbind-lazy
30770 Enable lazy binding of function calls. This option is equivalent to
30771 @option{-Wl,-z,now} and is defined for compatibility with Diab.
30775 Disable lazy binding of function calls. This option is the default and
30776 is defined for compatibility with Diab.
30780 @subsection x86 Options
30781 @cindex x86 Options
30783 These @samp{-m} options are defined for the x86 family of computers.
30787 @item -march=@var{cpu-type}
30789 Generate instructions for the machine type @var{cpu-type}. In contrast to
30790 @option{-mtune=@var{cpu-type}}, which merely tunes the generated code
30791 for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
30792 to generate code that may not run at all on processors other than the one
30793 indicated. Specifying @option{-march=@var{cpu-type}} implies
30794 @option{-mtune=@var{cpu-type}}, except where noted otherwise.
30796 The choices for @var{cpu-type} are:
30800 This selects the CPU to generate code for at compilation time by determining
30801 the processor type of the compiling machine. Using @option{-march=native}
30802 enables all instruction subsets supported by the local machine (hence
30803 the result might not run on different machines). Using @option{-mtune=native}
30804 produces code optimized for the local machine under the constraints
30805 of the selected instruction set.
30808 A generic CPU with 64-bit extensions.
30813 These choices for @var{cpu-type} select the corresponding
30814 micro-architecture level from the x86-64 psABI. On ABIs other than
30815 the x86-64 psABI they select the same CPU features as the x86-64 psABI
30816 documents for the particular micro-architecture level.
30818 Since these @var{cpu-type} values do not have a corresponding
30819 @option{-mtune} setting, using @option{-march} with these values enables
30820 generic tuning. Specific tuning can be enabled using the
30821 @option{-mtune=@var{other-cpu-type}} option with an appropriate
30822 @var{other-cpu-type} value.
30825 Original Intel i386 CPU@.
30828 Intel i486 CPU@. (No scheduling is implemented for this chip.)
30832 Intel Pentium CPU with no MMX support.
30835 Intel Lakemont MCU, based on Intel Pentium CPU.
30838 Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
30841 Intel Pentium Pro CPU@.
30844 When used with @option{-march}, the Pentium Pro
30845 instruction set is used, so the code runs on all i686 family chips.
30846 When used with @option{-mtune}, it has the same meaning as @samp{generic}.
30849 Intel Pentium II CPU, based on Pentium Pro core with MMX instruction set
30854 Intel Pentium III CPU, based on Pentium Pro core with MMX and SSE instruction
30858 Intel Pentium M; low-power version of Intel Pentium III CPU
30859 with MMX, SSE and SSE2 instruction set support. Used by Centrino notebooks.
30863 Intel Pentium 4 CPU with MMX, SSE and SSE2 instruction set support.
30866 Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2 and SSE3 instruction
30870 Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
30871 SSE2 and SSE3 instruction set support.
30874 Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3 and SSSE3
30875 instruction set support.
30878 Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
30879 SSE4.1, SSE4.2 and POPCNT instruction set support.
30882 Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
30883 SSE4.1, SSE4.2, POPCNT, AES and PCLMUL instruction set support.
30886 Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
30887 SSE4.1, SSE4.2, POPCNT, AVX, AES and PCLMUL instruction set support.
30890 Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
30891 SSE4.1, SSE4.2, POPCNT, AVX, AES, PCLMUL, FSGSBASE, RDRND and F16C
30892 instruction set support.
30895 Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
30896 SSE4.1, SSE4.2, POPCNT, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, FMA,
30897 BMI, BMI2 and F16C instruction set support.
30900 Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
30901 SSE4.1, SSE4.2, POPCNT, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, FMA, BMI, BMI2,
30902 F16C, RDSEED ADCX and PREFETCHW instruction set support.
30905 Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
30906 SSE4.1, SSE4.2, POPCNT, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, FMA,
30907 BMI, BMI2, F16C, RDSEED, ADCX, PREFETCHW, CLFLUSHOPT, XSAVEC and XSAVES
30908 instruction set support.
30911 Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
30912 instruction set support.
30915 Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
30916 SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL and RDRND instruction set support.
30919 Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
30920 SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
30921 XSAVEOPT and FSGSBASE instruction set support.
30923 @item goldmont-plus
30924 Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
30925 SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
30926 XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX and UMIP instruction set support.
30929 Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
30930 SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
30931 XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, UMIP, GFNI-SSE, CLWB, MOVDIRI,
30932 MOVDIR64B, CLDEMOTE and WAITPKG instruction set support.
30935 Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
30936 SSSE3, SSE4.1, SSE4.2, POPCNT, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, FMA,
30937 BMI, BMI2, F16C, RDSEED, ADCX, PREFETCHW, PREFETCHWT1, AVX512F, AVX512PF,
30938 AVX512ER and AVX512CD instruction set support.
30941 Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
30942 SSSE3, SSE4.1, SSE4.2, POPCNT, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, FMA,
30943 BMI, BMI2, F16C, RDSEED, ADCX, PREFETCHW, PREFETCHWT1, AVX512F, AVX512PF,
30944 AVX512ER, AVX512CD, AVX5124VNNIW, AVX5124FMAPS and AVX512VPOPCNTDQ instruction
30947 @item skylake-avx512
30948 Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
30949 SSSE3, SSE4.1, SSE4.2, POPCNT, PKU, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, FMA,
30950 BMI, BMI2, F16C, RDSEED, ADCX, PREFETCHW, CLFLUSHOPT, XSAVEC, XSAVES, AVX512F,
30951 CLWB, AVX512VL, AVX512BW, AVX512DQ and AVX512CD instruction set support.
30954 Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
30955 SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, PKU, AVX, AVX2, AES, PCLMUL, FSGSBASE,
30956 RDRND, FMA, BMI, BMI2, F16C, RDSEED, ADCX, PREFETCHW, CLFLUSHOPT, XSAVEC,
30957 XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD, AVX512VBMI,
30958 AVX512IFMA, SHA and UMIP instruction set support.
30960 @item icelake-client
30961 Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
30962 SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, PKU, AVX, AVX2, AES, PCLMUL, FSGSBASE,
30963 RDRND, FMA, BMI, BMI2, F16C, RDSEED, ADCX, PREFETCHW, CLFLUSHOPT, XSAVEC,
30964 XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD, AVX512VBMI,
30965 AVX512IFMA, SHA, CLWB, UMIP, RDPID, GFNI, AVX512VBMI2, AVX512VPOPCNTDQ,
30966 AVX512BITALG, AVX512VNNI, VPCLMULQDQ, VAES instruction set support.
30968 @item icelake-server
30969 Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
30970 SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, PKU, AVX, AVX2, AES, PCLMUL, FSGSBASE,
30971 RDRND, FMA, BMI, BMI2, F16C, RDSEED, ADCX, PREFETCHW, CLFLUSHOPT, XSAVEC,
30972 XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD, AVX512VBMI,
30973 AVX512IFMA, SHA, CLWB, UMIP, RDPID, GFNI, AVX512VBMI2, AVX512VPOPCNTDQ,
30974 AVX512BITALG, AVX512VNNI, VPCLMULQDQ, VAES, PCONFIG and WBNOINVD instruction
30978 Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
30979 SSE4.1, SSE4.2, POPCNT, PKU, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, FMA, BMI,
30980 BMI2, F16C, RDSEED, ADCX, PREFETCHW, CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, CLWB,
30981 AVX512VL, AVX512BW, AVX512DQ, AVX512CD and AVX512VNNI instruction set support.
30984 Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
30985 SSE4.1, SSE4.2, POPCNT, PKU, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, FMA, BMI,
30986 BMI2, F16C, RDSEED, ADCX, PREFETCHW, CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, CLWB,
30987 AVX512VL, AVX512BW, AVX512DQ, AVX512CD, AVX512VNNI and AVX512BF16 instruction
30991 Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
30992 SSE4.1, SSE4.2, POPCNT, PKU, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, FMA, BMI,
30993 BMI2, F16C, RDSEED, ADCX, PREFETCHW, CLFLUSHOPT, XSAVEC, XSAVES, AVX512F,
30994 AVX512VL, AVX512BW, AVX512DQ, AVX512CD, AVX512VBMI, AVX512IFMA, SHA, CLWB, UMIP,
30995 RDPID, GFNI, AVX512VBMI2, AVX512VPOPCNTDQ, AVX512BITALG, AVX512VNNI, VPCLMULQDQ,
30996 VAES, PCONFIG, WBNOINVD, MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT and KEYLOCKER
30997 instruction set support.
30999 @item sapphirerapids
31000 Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
31001 SSSE3, SSE4.1, SSE4.2, POPCNT, PKU, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND,
31002 FMA, BMI, BMI2, F16C, RDSEED, ADCX, PREFETCHW, CLFLUSHOPT, XSAVEC, XSAVES,
31003 AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, AVX512CD, AVX512VNNI, AVX512BF16,
31004 MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG,
31005 SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8 and AVX-VNNI
31006 instruction set support.
31009 Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
31010 SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
31011 XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, UMIP, GFNI-SSE, CLWB, MOVDIRI,
31012 MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
31013 PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI
31014 instruction set support.
31017 Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
31018 SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, PKU, AVX, AVX2, AES, PCLMUL, FSGSBASE,
31019 RDRND, FMA, BMI, BMI2, F16C, RDSEED, ADCX, PREFETCHW, CLFLUSHOPT, XSAVEC,
31020 XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD, AVX512VBMI,
31021 AVX512IFMA, SHA, CLWB, UMIP, RDPID, GFNI, AVX512VBMI2, AVX512VPOPCNTDQ,
31022 AVX512BITALG, AVX512VNNI, VPCLMULQDQ, VAES instruction set support.
31025 AMD K6 CPU with MMX instruction set support.
31029 Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
31032 @itemx athlon-tbird
31033 AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
31039 Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
31040 instruction set support.
31046 Processors based on the AMD K8 core with x86-64 instruction set support,
31047 including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
31048 (This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
31049 instruction set extensions.)
31052 @itemx opteron-sse3
31053 @itemx athlon64-sse3
31054 Improved versions of AMD K8 cores with SSE3 instruction set support.
31058 CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
31059 supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
31060 instruction set extensions.)
31063 CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
31064 supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
31065 SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
31068 AMD Family 15h core based CPUs with x86-64 instruction set support. (This
31069 supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
31070 SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
31074 AMD Family 15h core based CPUs with x86-64 instruction set support. (This
31075 supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
31076 PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
31077 64-bit instruction set extensions.)
31080 AMD Family 15h core based CPUs with x86-64 instruction set support. (This
31081 supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
31082 AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
31083 SSE4.2, ABM and 64-bit instruction set extensions.)
31086 AMD Family 17h core based CPUs with x86-64 instruction set support. (This
31087 supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
31088 SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
31089 SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
31090 instruction set extensions.)
31093 AMD Family 17h core based CPUs with x86-64 instruction set support. (This
31094 supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
31095 MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
31096 SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
31097 WBNOINVD, and 64-bit instruction set extensions.)
31100 AMD Family 19h core based CPUs with x86-64 instruction set support. (This
31101 supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
31102 MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
31103 SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
31104 WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
31107 CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
31108 supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
31109 instruction set extensions.)
31112 CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
31113 includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
31114 SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
31117 IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
31121 IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
31122 instruction set support.
31125 VIA C3 CPU with MMX and 3DNow!@: instruction set support.
31126 (No scheduling is implemented for this chip.)
31129 VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
31130 (No scheduling is implemented for this chip.)
31133 VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
31134 (No scheduling is implemented for this chip.)
31137 VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
31138 (No scheduling is implemented for this chip.)
31141 VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
31142 (No scheduling is implemented for this chip.)
31145 VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
31146 (No scheduling is implemented for this chip.)
31149 VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
31150 (No scheduling is implemented for this chip.)
31153 VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
31154 AVX and AVX2 instruction set support.
31155 (No scheduling is implemented for this chip.)
31158 Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
31159 instruction set support.
31160 (No scheduling is implemented for this chip.)
31163 VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
31164 instruction set support.
31165 (No scheduling is implemented for this chip.)
31168 VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
31169 instruction set support.
31170 (No scheduling is implemented for this chip.)
31173 VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
31174 instruction set support.
31175 (No scheduling is implemented for this chip.)
31178 VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
31179 instruction set support.
31180 (No scheduling is implemented for this chip.)
31183 VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
31184 instruction set support.
31185 (No scheduling is implemented for this chip.)
31188 AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
31191 @item -mtune=@var{cpu-type}
31193 Tune to @var{cpu-type} everything applicable about the generated code, except
31194 for the ABI and the set of available instructions.
31195 While picking a specific @var{cpu-type} schedules things appropriately
31196 for that particular chip, the compiler does not generate any code that
31197 cannot run on the default machine type unless you use a
31198 @option{-march=@var{cpu-type}} option.
31199 For example, if GCC is configured for i686-pc-linux-gnu
31200 then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
31201 but still runs on i686 machines.
31203 The choices for @var{cpu-type} are the same as for @option{-march}.
31204 In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
31208 Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
31209 If you know the CPU on which your code will run, then you should use
31210 the corresponding @option{-mtune} or @option{-march} option instead of
31211 @option{-mtune=generic}. But, if you do not know exactly what CPU users
31212 of your application will have, then you should use this option.
31214 As new processors are deployed in the marketplace, the behavior of this
31215 option will change. Therefore, if you upgrade to a newer version of
31216 GCC, code generation controlled by this option will change to reflect
31218 that are most common at the time that version of GCC is released.
31220 There is no @option{-march=generic} option because @option{-march}
31221 indicates the instruction set the compiler can use, and there is no
31222 generic instruction set applicable to all processors. In contrast,
31223 @option{-mtune} indicates the processor (or, in this case, collection of
31224 processors) for which the code is optimized.
31227 Produce code optimized for the most current Intel processors, which are
31228 Haswell and Silvermont for this version of GCC. If you know the CPU
31229 on which your code will run, then you should use the corresponding
31230 @option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
31231 But, if you want your application performs better on both Haswell and
31232 Silvermont, then you should use this option.
31234 As new Intel processors are deployed in the marketplace, the behavior of
31235 this option will change. Therefore, if you upgrade to a newer version of
31236 GCC, code generation controlled by this option will change to reflect
31237 the most current Intel processors at the time that version of GCC is
31240 There is no @option{-march=intel} option because @option{-march} indicates
31241 the instruction set the compiler can use, and there is no common
31242 instruction set applicable to all processors. In contrast,
31243 @option{-mtune} indicates the processor (or, in this case, collection of
31244 processors) for which the code is optimized.
31247 @item -mcpu=@var{cpu-type}
31249 A deprecated synonym for @option{-mtune}.
31251 @item -mfpmath=@var{unit}
31253 Generate floating-point arithmetic for selected unit @var{unit}. The choices
31254 for @var{unit} are:
31258 Use the standard 387 floating-point coprocessor present on the majority of chips and
31259 emulated otherwise. Code compiled with this option runs almost everywhere.
31260 The temporary results are computed in 80-bit precision instead of the precision
31261 specified by the type, resulting in slightly different results compared to most
31262 of other chips. See @option{-ffloat-store} for more detailed description.
31264 This is the default choice for non-Darwin x86-32 targets.
31267 Use scalar floating-point instructions present in the SSE instruction set.
31268 This instruction set is supported by Pentium III and newer chips,
31269 and in the AMD line
31270 by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
31271 instruction set supports only single-precision arithmetic, thus the double and
31272 extended-precision arithmetic are still done using 387. A later version, present
31273 only in Pentium 4 and AMD x86-64 chips, supports double-precision
31276 For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
31277 or @option{-msse2} switches to enable SSE extensions and make this option
31278 effective. For the x86-64 compiler, these extensions are enabled by default.
31280 The resulting code should be considerably faster in the majority of cases and avoid
31281 the numerical instability problems of 387 code, but may break some existing
31282 code that expects temporaries to be 80 bits.
31284 This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
31285 and the default choice for x86-32 targets with the SSE2 instruction set
31286 when @option{-ffast-math} is enabled.
31291 Attempt to utilize both instruction sets at once. This effectively doubles the
31292 amount of available registers, and on chips with separate execution units for
31293 387 and SSE the execution resources too. Use this option with care, as it is
31294 still experimental, because the GCC register allocator does not model separate
31295 functional units well, resulting in unstable performance.
31298 @item -masm=@var{dialect}
31299 @opindex masm=@var{dialect}
31300 Output assembly instructions using selected @var{dialect}. Also affects
31301 which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
31302 extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
31303 order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
31304 not support @samp{intel}.
31307 @itemx -mno-ieee-fp
31309 @opindex mno-ieee-fp
31310 Control whether or not the compiler uses IEEE floating-point
31311 comparisons. These correctly handle the case where the result of a
31312 comparison is unordered.
31315 @itemx -mhard-float
31317 @opindex mhard-float
31318 Generate output containing 80387 instructions for floating point.
31321 @itemx -msoft-float
31323 @opindex msoft-float
31324 Generate output containing library calls for floating point.
31326 @strong{Warning:} the requisite libraries are not part of GCC@.
31327 Normally the facilities of the machine's usual C compiler are used, but
31328 this cannot be done directly in cross-compilation. You must make your
31329 own arrangements to provide suitable library functions for
31332 On machines where a function returns floating-point results in the 80387
31333 register stack, some floating-point opcodes may be emitted even if
31334 @option{-msoft-float} is used.
31336 @item -mno-fp-ret-in-387
31337 @opindex mno-fp-ret-in-387
31338 @opindex mfp-ret-in-387
31339 Do not use the FPU registers for return values of functions.
31341 The usual calling convention has functions return values of types
31342 @code{float} and @code{double} in an FPU register, even if there
31343 is no FPU@. The idea is that the operating system should emulate
31346 The option @option{-mno-fp-ret-in-387} causes such values to be returned
31347 in ordinary CPU registers instead.
31349 @item -mno-fancy-math-387
31350 @opindex mno-fancy-math-387
31351 @opindex mfancy-math-387
31352 Some 387 emulators do not support the @code{sin}, @code{cos} and
31353 @code{sqrt} instructions for the 387. Specify this option to avoid
31354 generating those instructions.
31355 This option is overridden when @option{-march}
31356 indicates that the target CPU always has an FPU and so the
31357 instruction does not need emulation. These
31358 instructions are not generated unless you also use the
31359 @option{-funsafe-math-optimizations} switch.
31361 @item -malign-double
31362 @itemx -mno-align-double
31363 @opindex malign-double
31364 @opindex mno-align-double
31365 Control whether GCC aligns @code{double}, @code{long double}, and
31366 @code{long long} variables on a two-word boundary or a one-word
31367 boundary. Aligning @code{double} variables on a two-word boundary
31368 produces code that runs somewhat faster on a Pentium at the
31369 expense of more memory.
31371 On x86-64, @option{-malign-double} is enabled by default.
31373 @strong{Warning:} if you use the @option{-malign-double} switch,
31374 structures containing the above types are aligned differently than
31375 the published application binary interface specifications for the x86-32
31376 and are not binary compatible with structures in code compiled
31377 without that switch.
31379 @item -m96bit-long-double
31380 @itemx -m128bit-long-double
31381 @opindex m96bit-long-double
31382 @opindex m128bit-long-double
31383 These switches control the size of @code{long double} type. The x86-32
31384 application binary interface specifies the size to be 96 bits,
31385 so @option{-m96bit-long-double} is the default in 32-bit mode.
31387 Modern architectures (Pentium and newer) prefer @code{long double}
31388 to be aligned to an 8- or 16-byte boundary. In arrays or structures
31389 conforming to the ABI, this is not possible. So specifying
31390 @option{-m128bit-long-double} aligns @code{long double}
31391 to a 16-byte boundary by padding the @code{long double} with an additional
31394 In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
31395 its ABI specifies that @code{long double} is aligned on 16-byte boundary.
31397 Notice that neither of these options enable any extra precision over the x87
31398 standard of 80 bits for a @code{long double}.
31400 @strong{Warning:} if you override the default value for your target ABI, this
31401 changes the size of
31402 structures and arrays containing @code{long double} variables,
31403 as well as modifying the function calling convention for functions taking
31404 @code{long double}. Hence they are not binary-compatible
31405 with code compiled without that switch.
31407 @item -mlong-double-64
31408 @itemx -mlong-double-80
31409 @itemx -mlong-double-128
31410 @opindex mlong-double-64
31411 @opindex mlong-double-80
31412 @opindex mlong-double-128
31413 These switches control the size of @code{long double} type. A size
31414 of 64 bits makes the @code{long double} type equivalent to the @code{double}
31415 type. This is the default for 32-bit Bionic C library. A size
31416 of 128 bits makes the @code{long double} type equivalent to the
31417 @code{__float128} type. This is the default for 64-bit Bionic C library.
31419 @strong{Warning:} if you override the default value for your target ABI, this
31420 changes the size of
31421 structures and arrays containing @code{long double} variables,
31422 as well as modifying the function calling convention for functions taking
31423 @code{long double}. Hence they are not binary-compatible
31424 with code compiled without that switch.
31426 @item -malign-data=@var{type}
31427 @opindex malign-data
31428 Control how GCC aligns variables. Supported values for @var{type} are
31429 @samp{compat} uses increased alignment value compatible uses GCC 4.8
31430 and earlier, @samp{abi} uses alignment value as specified by the
31431 psABI, and @samp{cacheline} uses increased alignment value to match
31432 the cache line size. @samp{compat} is the default.
31434 @item -mlarge-data-threshold=@var{threshold}
31435 @opindex mlarge-data-threshold
31436 When @option{-mcmodel=medium} is specified, data objects larger than
31437 @var{threshold} are placed in the large data section. This value must be the
31438 same across all objects linked into the binary, and defaults to 65535.
31442 Use a different function-calling convention, in which functions that
31443 take a fixed number of arguments return with the @code{ret @var{num}}
31444 instruction, which pops their arguments while returning. This saves one
31445 instruction in the caller since there is no need to pop the arguments
31448 You can specify that an individual function is called with this calling
31449 sequence with the function attribute @code{stdcall}. You can also
31450 override the @option{-mrtd} option by using the function attribute
31451 @code{cdecl}. @xref{Function Attributes}.
31453 @strong{Warning:} this calling convention is incompatible with the one
31454 normally used on Unix, so you cannot use it if you need to call
31455 libraries compiled with the Unix compiler.
31457 Also, you must provide function prototypes for all functions that
31458 take variable numbers of arguments (including @code{printf});
31459 otherwise incorrect code is generated for calls to those
31462 In addition, seriously incorrect code results if you call a
31463 function with too many arguments. (Normally, extra arguments are
31464 harmlessly ignored.)
31466 @item -mregparm=@var{num}
31468 Control how many registers are used to pass integer arguments. By
31469 default, no registers are used to pass arguments, and at most 3
31470 registers can be used. You can control this behavior for a specific
31471 function by using the function attribute @code{regparm}.
31472 @xref{Function Attributes}.
31474 @strong{Warning:} if you use this switch, and
31475 @var{num} is nonzero, then you must build all modules with the same
31476 value, including any libraries. This includes the system libraries and
31480 @opindex msseregparm
31481 Use SSE register passing conventions for float and double arguments
31482 and return values. You can control this behavior for a specific
31483 function by using the function attribute @code{sseregparm}.
31484 @xref{Function Attributes}.
31486 @strong{Warning:} if you use this switch then you must build all
31487 modules with the same value, including any libraries. This includes
31488 the system libraries and startup modules.
31490 @item -mvect8-ret-in-mem
31491 @opindex mvect8-ret-in-mem
31492 Return 8-byte vectors in memory instead of MMX registers. This is the
31493 default on VxWorks to match the ABI of the Sun Studio compilers until
31494 version 12. @emph{Only} use this option if you need to remain
31495 compatible with existing code produced by those previous compiler
31496 versions or older versions of GCC@.
31505 Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
31506 is specified, the significands of results of floating-point operations are
31507 rounded to 24 bits (single precision); @option{-mpc64} rounds the
31508 significands of results of floating-point operations to 53 bits (double
31509 precision) and @option{-mpc80} rounds the significands of results of
31510 floating-point operations to 64 bits (extended double precision), which is
31511 the default. When this option is used, floating-point operations in higher
31512 precisions are not available to the programmer without setting the FPU
31513 control word explicitly.
31515 Setting the rounding of floating-point operations to less than the default
31516 80 bits can speed some programs by 2% or more. Note that some mathematical
31517 libraries assume that extended-precision (80-bit) floating-point operations
31518 are enabled by default; routines in such libraries could suffer significant
31519 loss of accuracy, typically through so-called ``catastrophic cancellation'',
31520 when this option is used to set the precision to less than extended precision.
31522 @item -mstackrealign
31523 @opindex mstackrealign
31524 Realign the stack at entry. On the x86, the @option{-mstackrealign}
31525 option generates an alternate prologue and epilogue that realigns the
31526 run-time stack if necessary. This supports mixing legacy codes that keep
31527 4-byte stack alignment with modern codes that keep 16-byte stack alignment for
31528 SSE compatibility. See also the attribute @code{force_align_arg_pointer},
31529 applicable to individual functions.
31531 @item -mpreferred-stack-boundary=@var{num}
31532 @opindex mpreferred-stack-boundary
31533 Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
31534 byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
31535 the default is 4 (16 bytes or 128 bits).
31537 @strong{Warning:} When generating code for the x86-64 architecture with
31538 SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
31539 used to keep the stack boundary aligned to 8 byte boundary. Since
31540 x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
31541 intended to be used in controlled environment where stack space is
31542 important limitation. This option leads to wrong code when functions
31543 compiled with 16 byte stack alignment (such as functions from a standard
31544 library) are called with misaligned stack. In this case, SSE
31545 instructions may lead to misaligned memory access traps. In addition,
31546 variable arguments are handled incorrectly for 16 byte aligned
31547 objects (including x87 long double and __int128), leading to wrong
31548 results. You must build all modules with
31549 @option{-mpreferred-stack-boundary=3}, including any libraries. This
31550 includes the system libraries and startup modules.
31552 @item -mincoming-stack-boundary=@var{num}
31553 @opindex mincoming-stack-boundary
31554 Assume the incoming stack is aligned to a 2 raised to @var{num} byte
31555 boundary. If @option{-mincoming-stack-boundary} is not specified,
31556 the one specified by @option{-mpreferred-stack-boundary} is used.
31558 On Pentium and Pentium Pro, @code{double} and @code{long double} values
31559 should be aligned to an 8-byte boundary (see @option{-malign-double}) or
31560 suffer significant run time performance penalties. On Pentium III, the
31561 Streaming SIMD Extension (SSE) data type @code{__m128} may not work
31562 properly if it is not 16-byte aligned.
31564 To ensure proper alignment of this values on the stack, the stack boundary
31565 must be as aligned as that required by any value stored on the stack.
31566 Further, every function must be generated such that it keeps the stack
31567 aligned. Thus calling a function compiled with a higher preferred
31568 stack boundary from a function compiled with a lower preferred stack
31569 boundary most likely misaligns the stack. It is recommended that
31570 libraries that use callbacks always use the default setting.
31572 This extra alignment does consume extra stack space, and generally
31573 increases code size. Code that is sensitive to stack space usage, such
31574 as embedded systems and operating system kernels, may want to reduce the
31575 preferred alignment to @option{-mpreferred-stack-boundary=2}.
31632 @itemx -mavx512ifma
31633 @opindex mavx512ifma
31635 @itemx -mavx512vbmi
31636 @opindex mavx512vbmi
31647 @itemx -mclflushopt
31648 @opindex mclflushopt
31683 @itemx -mprefetchwt1
31684 @opindex mprefetchwt1
31755 @itemx -mavx512vbmi2
31756 @opindex mavx512vbmi2
31758 @itemx -mavx512bf16
31759 @opindex mavx512bf16
31761 @itemx -mavx512fp16
31762 @opindex mavx512fp16
31773 @itemx -mvpclmulqdq
31774 @opindex mvpclmulqdq
31776 @itemx -mavx512bitalg
31777 @opindex mavx512bitalg
31783 @opindex mmovdir64b
31793 @itemx -mavx512vpopcntdq
31794 @opindex mavx512vpopcntdq
31796 @itemx -mavx512vp2intersect
31797 @opindex mavx512vp2intersect
31799 @itemx -mavx5124fmaps
31800 @opindex mavx5124fmaps
31802 @itemx -mavx512vnni
31803 @opindex mavx512vnni
31808 @itemx -mavx5124vnniw
31809 @opindex mavx5124vnniw
31815 @opindex mserialize
31833 These switches enable the use of instructions in the MMX, SSE,
31834 SSE2, SSE3, SSSE3, SSE4, SSE4A, SSE4.1, SSE4.2, AVX, AVX2, AVX512F, AVX512PF,
31835 AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA,
31836 AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
31837 WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP,
31838 3DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE,
31839 XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2,
31840 GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16,
31841 ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE,
31842 UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512FP16
31843 or CLDEMOTE extended instruction sets. Each has a corresponding
31844 @option{-mno-} option to disable use of these instructions.
31846 These extensions are also available as built-in functions: see
31847 @ref{x86 Built-in Functions}, for details of the functions enabled and
31848 disabled by these switches.
31850 To generate SSE/SSE2 instructions automatically from floating-point
31851 code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
31853 GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
31854 generates new AVX instructions or AVX equivalence for all SSEx instructions
31857 These options enable GCC to use these extended instructions in
31858 generated code, even without @option{-mfpmath=sse}. Applications that
31859 perform run-time CPU detection must compile separate files for each
31860 supported architecture, using the appropriate flags. In particular,
31861 the file containing the CPU detection code should be compiled without
31864 @item -mdump-tune-features
31865 @opindex mdump-tune-features
31866 This option instructs GCC to dump the names of the x86 performance
31867 tuning features and default settings. The names can be used in
31868 @option{-mtune-ctrl=@var{feature-list}}.
31870 @item -mtune-ctrl=@var{feature-list}
31871 @opindex mtune-ctrl=@var{feature-list}
31872 This option is used to do fine grain control of x86 code generation features.
31873 @var{feature-list} is a comma separated list of @var{feature} names. See also
31874 @option{-mdump-tune-features}. When specified, the @var{feature} is turned
31875 on if it is not preceded with @samp{^}, otherwise, it is turned off.
31876 @option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
31877 developers. Using it may lead to code paths not covered by testing and can
31878 potentially result in compiler ICEs or runtime errors.
31881 @opindex mno-default
31882 This option instructs GCC to turn off all tunable features. See also
31883 @option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
31887 This option instructs GCC to emit a @code{cld} instruction in the prologue
31888 of functions that use string instructions. String instructions depend on
31889 the DF flag to select between autoincrement or autodecrement mode. While the
31890 ABI specifies the DF flag to be cleared on function entry, some operating
31891 systems violate this specification by not clearing the DF flag in their
31892 exception dispatchers. The exception handler can be invoked with the DF flag
31893 set, which leads to wrong direction mode when string instructions are used.
31894 This option can be enabled by default on 32-bit x86 targets by configuring
31895 GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
31896 instructions can be suppressed with the @option{-mno-cld} compiler option
31900 @opindex mvzeroupper
31901 This option instructs GCC to emit a @code{vzeroupper} instruction
31902 before a transfer of control flow out of the function to minimize
31903 the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
31906 @item -mprefer-avx128
31907 @opindex mprefer-avx128
31908 This option instructs GCC to use 128-bit AVX instructions instead of
31909 256-bit AVX instructions in the auto-vectorizer.
31911 @item -mprefer-vector-width=@var{opt}
31912 @opindex mprefer-vector-width
31913 This option instructs GCC to use @var{opt}-bit vector width in instructions
31914 instead of default on the selected platform.
31916 @item -mmove-max=@var{bits}
31918 This option instructs GCC to set the maximum number of bits can be
31919 moved from memory to memory efficiently to @var{bits}. The valid
31920 @var{bits} are 128, 256 and 512.
31922 @item -mstore-max=@var{bits}
31923 @opindex mstore-max
31924 This option instructs GCC to set the maximum number of bits can be
31925 stored to memory efficiently to @var{bits}. The valid @var{bits} are
31930 No extra limitations applied to GCC other than defined by the selected platform.
31933 Prefer 128-bit vector width for instructions.
31936 Prefer 256-bit vector width for instructions.
31939 Prefer 512-bit vector width for instructions.
31944 This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
31945 code to implement compare-and-exchange operations on 16-byte aligned 128-bit
31946 objects. This is useful for atomic updates of data structures exceeding one
31947 machine word in size. The compiler uses this instruction to implement
31948 @ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
31949 128-bit integers, a library call is always used.
31953 This option enables generation of @code{SAHF} instructions in 64-bit code.
31954 Early Intel Pentium 4 CPUs with Intel 64 support,
31955 prior to the introduction of Pentium 4 G1 step in December 2005,
31956 lacked the @code{LAHF} and @code{SAHF} instructions
31957 which are supported by AMD64.
31958 These are load and store instructions, respectively, for certain status flags.
31959 In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
31960 @code{drem}, and @code{remainder} built-in functions;
31961 see @ref{Other Builtins} for details.
31965 This option enables use of the @code{movbe} instruction to implement
31966 @code{__builtin_bswap32} and @code{__builtin_bswap64}.
31970 The @option{-mshstk} option enables shadow stack built-in functions
31971 from x86 Control-flow Enforcement Technology (CET).
31975 This option enables built-in functions @code{__builtin_ia32_crc32qi},
31976 @code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
31977 @code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
31981 This option enables built-in functions @code{__builtin_ia32_monitor},
31982 and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
31983 @code{mwait} machine instructions.
31987 This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
31988 (and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
31989 with an additional Newton-Raphson step
31990 to increase precision instead of @code{DIVSS} and @code{SQRTSS}
31991 (and their vectorized
31992 variants) for single-precision floating-point arguments. These instructions
31993 are generated only when @option{-funsafe-math-optimizations} is enabled
31994 together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
31995 Note that while the throughput of the sequence is higher than the throughput
31996 of the non-reciprocal instruction, the precision of the sequence can be
31997 decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
31999 Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
32000 (or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
32001 combination), and doesn't need @option{-mrecip}.
32003 Also note that GCC emits the above sequence with additional Newton-Raphson step
32004 for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
32005 already with @option{-ffast-math} (or the above option combination), and
32006 doesn't need @option{-mrecip}.
32008 @item -mrecip=@var{opt}
32009 @opindex mrecip=opt
32010 This option controls which reciprocal estimate instructions
32011 may be used. @var{opt} is a comma-separated list of options, which may
32012 be preceded by a @samp{!} to invert the option:
32016 Enable all estimate instructions.
32019 Enable the default instructions, equivalent to @option{-mrecip}.
32022 Disable all estimate instructions, equivalent to @option{-mno-recip}.
32025 Enable the approximation for scalar division.
32028 Enable the approximation for vectorized division.
32031 Enable the approximation for scalar square root.
32034 Enable the approximation for vectorized square root.
32037 So, for example, @option{-mrecip=all,!sqrt} enables
32038 all of the reciprocal approximations, except for square root.
32040 @item -mveclibabi=@var{type}
32041 @opindex mveclibabi
32042 Specifies the ABI type to use for vectorizing intrinsics using an
32043 external library. Supported values for @var{type} are @samp{svml}
32044 for the Intel short
32045 vector math library and @samp{acml} for the AMD math core library.
32046 To use this option, both @option{-ftree-vectorize} and
32047 @option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
32048 ABI-compatible library must be specified at link time.
32050 GCC currently emits calls to @code{vmldExp2},
32051 @code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2},
32052 @code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2},
32053 @code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2},
32054 @code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2},
32055 @code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4},
32056 @code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4},
32057 @code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4},
32058 @code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4},
32059 @code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding
32060 function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin},
32061 @code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
32062 @code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
32063 @code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
32064 @code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
32065 when @option{-mveclibabi=acml} is used.
32067 @item -mabi=@var{name}
32069 Generate code for the specified calling convention. Permissible values
32070 are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
32071 @samp{ms} for the Microsoft ABI. The default is to use the Microsoft
32072 ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
32073 You can control this behavior for specific functions by
32074 using the function attributes @code{ms_abi} and @code{sysv_abi}.
32075 @xref{Function Attributes}.
32077 @item -mforce-indirect-call
32078 @opindex mforce-indirect-call
32079 Force all calls to functions to be indirect. This is useful
32080 when using Intel Processor Trace where it generates more precise timing
32081 information for function calls.
32083 @item -mmanual-endbr
32084 @opindex mmanual-endbr
32085 Insert ENDBR instruction at function entry only via the @code{cf_check}
32086 function attribute. This is useful when used with the option
32087 @option{-fcf-protection=branch} to control ENDBR insertion at the
32090 @item -mcall-ms2sysv-xlogues
32091 @opindex mcall-ms2sysv-xlogues
32092 @opindex mno-call-ms2sysv-xlogues
32093 Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
32094 System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
32095 default, the code for saving and restoring these registers is emitted inline,
32096 resulting in fairly lengthy prologues and epilogues. Using
32097 @option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
32098 use stubs in the static portion of libgcc to perform these saves and restores,
32099 thus reducing function size at the cost of a few extra instructions.
32101 @item -mtls-dialect=@var{type}
32102 @opindex mtls-dialect
32103 Generate code to access thread-local storage using the @samp{gnu} or
32104 @samp{gnu2} conventions. @samp{gnu} is the conservative default;
32105 @samp{gnu2} is more efficient, but it may add compile- and run-time
32106 requirements that cannot be satisfied on all systems.
32109 @itemx -mno-push-args
32110 @opindex mpush-args
32111 @opindex mno-push-args
32112 Use PUSH operations to store outgoing parameters. This method is shorter
32113 and usually equally fast as method using SUB/MOV operations and is enabled
32114 by default. In some cases disabling it may improve performance because of
32115 improved scheduling and reduced dependencies.
32117 @item -maccumulate-outgoing-args
32118 @opindex maccumulate-outgoing-args
32119 If enabled, the maximum amount of space required for outgoing arguments is
32120 computed in the function prologue. This is faster on most modern CPUs
32121 because of reduced dependencies, improved scheduling and reduced stack usage
32122 when the preferred stack boundary is not equal to 2. The drawback is a notable
32123 increase in code size. This switch implies @option{-mno-push-args}.
32127 Support thread-safe exception handling on MinGW. Programs that rely
32128 on thread-safe exception handling must compile and link all code with the
32129 @option{-mthreads} option. When compiling, @option{-mthreads} defines
32130 @option{-D_MT}; when linking, it links in a special thread helper library
32131 @option{-lmingwthrd} which cleans up per-thread exception-handling data.
32133 @item -mms-bitfields
32134 @itemx -mno-ms-bitfields
32135 @opindex mms-bitfields
32136 @opindex mno-ms-bitfields
32138 Enable/disable bit-field layout compatible with the native Microsoft
32141 If @code{packed} is used on a structure, or if bit-fields are used,
32142 it may be that the Microsoft ABI lays out the structure differently
32143 than the way GCC normally does. Particularly when moving packed
32144 data between functions compiled with GCC and the native Microsoft compiler
32145 (either via function call or as data in a file), it may be necessary to access
32148 This option is enabled by default for Microsoft Windows
32149 targets. This behavior can also be controlled locally by use of variable
32150 or type attributes. For more information, see @ref{x86 Variable Attributes}
32151 and @ref{x86 Type Attributes}.
32153 The Microsoft structure layout algorithm is fairly simple with the exception
32154 of the bit-field packing.
32155 The padding and alignment of members of structures and whether a bit-field
32156 can straddle a storage-unit boundary are determine by these rules:
32159 @item Structure members are stored sequentially in the order in which they are
32160 declared: the first member has the lowest memory address and the last member
32163 @item Every data object has an alignment requirement. The alignment requirement
32164 for all data except structures, unions, and arrays is either the size of the
32165 object or the current packing size (specified with either the
32166 @code{aligned} attribute or the @code{pack} pragma),
32167 whichever is less. For structures, unions, and arrays,
32168 the alignment requirement is the largest alignment requirement of its members.
32169 Every object is allocated an offset so that:
32172 offset % alignment_requirement == 0
32175 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
32176 unit if the integral types are the same size and if the next bit-field fits
32177 into the current allocation unit without crossing the boundary imposed by the
32178 common alignment requirements of the bit-fields.
32181 MSVC interprets zero-length bit-fields in the following ways:
32184 @item If a zero-length bit-field is inserted between two bit-fields that
32185 are normally coalesced, the bit-fields are not coalesced.
32192 unsigned long bf_1 : 12;
32194 unsigned long bf_2 : 12;
32199 The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
32200 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
32202 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
32203 alignment of the zero-length bit-field is greater than the member that follows it,
32204 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
32225 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
32226 Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
32227 bit-field does not affect the alignment of @code{bar} or, as a result, the size
32230 Taking this into account, it is important to note the following:
32233 @item If a zero-length bit-field follows a normal bit-field, the type of the
32234 zero-length bit-field may affect the alignment of the structure as whole. For
32235 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
32236 normal bit-field, and is of type short.
32238 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
32239 still affect the alignment of the structure:
32250 Here, @code{t4} takes up 4 bytes.
32253 @item Zero-length bit-fields following non-bit-field members are ignored:
32265 Here, @code{t5} takes up 2 bytes.
32269 @item -mno-align-stringops
32270 @opindex mno-align-stringops
32271 @opindex malign-stringops
32272 Do not align the destination of inlined string operations. This switch reduces
32273 code size and improves performance in case the destination is already aligned,
32274 but GCC doesn't know about it.
32276 @item -minline-all-stringops
32277 @opindex minline-all-stringops
32278 By default GCC inlines string operations only when the destination is
32279 known to be aligned to least a 4-byte boundary.
32280 This enables more inlining and increases code
32281 size, but may improve performance of code that depends on fast
32282 @code{memcpy} and @code{memset} for short lengths.
32283 The option enables inline expansion of @code{strlen} for all
32284 pointer alignments.
32286 @item -minline-stringops-dynamically
32287 @opindex minline-stringops-dynamically
32288 For string operations of unknown size, use run-time checks with
32289 inline code for small blocks and a library call for large blocks.
32291 @item -mstringop-strategy=@var{alg}
32292 @opindex mstringop-strategy=@var{alg}
32293 Override the internal decision heuristic for the particular algorithm to use
32294 for inlining string operations. The allowed values for @var{alg} are:
32300 Expand using i386 @code{rep} prefix of the specified size.
32304 @itemx unrolled_loop
32305 Expand into an inline loop.
32308 Always use a library call.
32311 @item -mmemcpy-strategy=@var{strategy}
32312 @opindex mmemcpy-strategy=@var{strategy}
32313 Override the internal decision heuristic to decide if @code{__builtin_memcpy}
32314 should be inlined and what inline algorithm to use when the expected size
32315 of the copy operation is known. @var{strategy}
32316 is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
32317 @var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
32318 the max byte size with which inline algorithm @var{alg} is allowed. For the last
32319 triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
32320 in the list must be specified in increasing order. The minimal byte size for
32321 @var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
32324 @item -mmemset-strategy=@var{strategy}
32325 @opindex mmemset-strategy=@var{strategy}
32326 The option is similar to @option{-mmemcpy-strategy=} except that it is to control
32327 @code{__builtin_memset} expansion.
32329 @item -momit-leaf-frame-pointer
32330 @opindex momit-leaf-frame-pointer
32331 Don't keep the frame pointer in a register for leaf functions. This
32332 avoids the instructions to save, set up, and restore frame pointers and
32333 makes an extra register available in leaf functions. The option
32334 @option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
32335 which might make debugging harder.
32337 @item -mtls-direct-seg-refs
32338 @itemx -mno-tls-direct-seg-refs
32339 @opindex mtls-direct-seg-refs
32340 Controls whether TLS variables may be accessed with offsets from the
32341 TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
32342 or whether the thread base pointer must be added. Whether or not this
32343 is valid depends on the operating system, and whether it maps the
32344 segment to cover the entire TLS area.
32346 For systems that use the GNU C Library, the default is on.
32349 @itemx -mno-sse2avx
32351 Specify that the assembler should encode SSE instructions with VEX
32352 prefix. The option @option{-mavx} turns this on by default.
32357 If profiling is active (@option{-pg}), put the profiling
32358 counter call before the prologue.
32359 Note: On x86 architectures the attribute @code{ms_hook_prologue}
32360 isn't possible at the moment for @option{-mfentry} and @option{-pg}.
32362 @item -mrecord-mcount
32363 @itemx -mno-record-mcount
32364 @opindex mrecord-mcount
32365 If profiling is active (@option{-pg}), generate a __mcount_loc section
32366 that contains pointers to each profiling call. This is useful for
32367 automatically patching and out calls.
32370 @itemx -mno-nop-mcount
32371 @opindex mnop-mcount
32372 If profiling is active (@option{-pg}), generate the calls to
32373 the profiling functions as NOPs. This is useful when they
32374 should be patched in later dynamically. This is likely only
32375 useful together with @option{-mrecord-mcount}.
32377 @item -minstrument-return=@var{type}
32378 @opindex minstrument-return
32379 Instrument function exit in -pg -mfentry instrumented functions with
32380 call to specified function. This only instruments true returns ending
32381 with ret, but not sibling calls ending with jump. Valid types
32382 are @var{none} to not instrument, @var{call} to generate a call to __return__,
32383 or @var{nop5} to generate a 5 byte nop.
32385 @item -mrecord-return
32386 @itemx -mno-record-return
32387 @opindex mrecord-return
32388 Generate a __return_loc section pointing to all return instrumentation code.
32390 @item -mfentry-name=@var{name}
32391 @opindex mfentry-name
32392 Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
32394 @item -mfentry-section=@var{name}
32395 @opindex mfentry-section
32396 Set name of section to record -mrecord-mcount calls (default __mcount_loc).
32398 @item -mskip-rax-setup
32399 @itemx -mno-skip-rax-setup
32400 @opindex mskip-rax-setup
32401 When generating code for the x86-64 architecture with SSE extensions
32402 disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
32403 register when there are no variable arguments passed in vector registers.
32405 @strong{Warning:} Since RAX register is used to avoid unnecessarily
32406 saving vector registers on stack when passing variable arguments, the
32407 impacts of this option are callees may waste some stack space,
32408 misbehave or jump to a random location. GCC 4.4 or newer don't have
32409 those issues, regardless the RAX register value.
32412 @itemx -mno-8bit-idiv
32413 @opindex m8bit-idiv
32414 On some processors, like Intel Atom, 8-bit unsigned integer divide is
32415 much faster than 32-bit/64-bit integer divide. This option generates a
32416 run-time check. If both dividend and divisor are within range of 0
32417 to 255, 8-bit unsigned integer divide is used instead of
32418 32-bit/64-bit integer divide.
32420 @item -mavx256-split-unaligned-load
32421 @itemx -mavx256-split-unaligned-store
32422 @opindex mavx256-split-unaligned-load
32423 @opindex mavx256-split-unaligned-store
32424 Split 32-byte AVX unaligned load and store.
32426 @item -mstack-protector-guard=@var{guard}
32427 @itemx -mstack-protector-guard-reg=@var{reg}
32428 @itemx -mstack-protector-guard-offset=@var{offset}
32429 @opindex mstack-protector-guard
32430 @opindex mstack-protector-guard-reg
32431 @opindex mstack-protector-guard-offset
32432 Generate stack protection code using canary at @var{guard}. Supported
32433 locations are @samp{global} for global canary or @samp{tls} for per-thread
32434 canary in the TLS block (the default). This option has effect only when
32435 @option{-fstack-protector} or @option{-fstack-protector-all} is specified.
32437 With the latter choice the options
32438 @option{-mstack-protector-guard-reg=@var{reg}} and
32439 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
32440 which segment register (@code{%fs} or @code{%gs}) to use as base register
32441 for reading the canary, and from what offset from that base register.
32442 The default for those is as specified in the relevant ABI.
32444 @item -mgeneral-regs-only
32445 @opindex mgeneral-regs-only
32446 Generate code that uses only the general-purpose registers. This
32447 prevents the compiler from using floating-point, vector, mask and bound
32450 @item -mrelax-cmpxchg-loop
32451 @opindex mrelax-cmpxchg-loop
32452 Relax cmpxchg loop by emitting an early load and compare before cmpxchg,
32453 execute pause if load value is not expected. This reduces excessive
32454 cachline bouncing when and works for all atomic logic fetch builtins
32455 that generates compare and swap loop.
32457 @item -mindirect-branch=@var{choice}
32458 @opindex mindirect-branch
32459 Convert indirect call and jump with @var{choice}. The default is
32460 @samp{keep}, which keeps indirect call and jump unmodified.
32461 @samp{thunk} converts indirect call and jump to call and return thunk.
32462 @samp{thunk-inline} converts indirect call and jump to inlined call
32463 and return thunk. @samp{thunk-extern} converts indirect call and jump
32464 to external call and return thunk provided in a separate object file.
32465 You can control this behavior for a specific function by using the
32466 function attribute @code{indirect_branch}. @xref{Function Attributes}.
32468 Note that @option{-mcmodel=large} is incompatible with
32469 @option{-mindirect-branch=thunk} and
32470 @option{-mindirect-branch=thunk-extern} since the thunk function may
32471 not be reachable in the large code model.
32473 Note that @option{-mindirect-branch=thunk-extern} is compatible with
32474 @option{-fcf-protection=branch} since the external thunk can be made
32475 to enable control-flow check.
32477 @item -mfunction-return=@var{choice}
32478 @opindex mfunction-return
32479 Convert function return with @var{choice}. The default is @samp{keep},
32480 which keeps function return unmodified. @samp{thunk} converts function
32481 return to call and return thunk. @samp{thunk-inline} converts function
32482 return to inlined call and return thunk. @samp{thunk-extern} converts
32483 function return to external call and return thunk provided in a separate
32484 object file. You can control this behavior for a specific function by
32485 using the function attribute @code{function_return}.
32486 @xref{Function Attributes}.
32488 Note that @option{-mindirect-return=thunk-extern} is compatible with
32489 @option{-fcf-protection=branch} since the external thunk can be made
32490 to enable control-flow check.
32492 Note that @option{-mcmodel=large} is incompatible with
32493 @option{-mfunction-return=thunk} and
32494 @option{-mfunction-return=thunk-extern} since the thunk function may
32495 not be reachable in the large code model.
32498 @item -mindirect-branch-register
32499 @opindex mindirect-branch-register
32500 Force indirect call and jump via register.
32502 @item -mharden-sls=@var{choice}
32503 @opindex mharden-sls
32504 Generate code to mitigate against straight line speculation (SLS) with
32505 @var{choice}. The default is @samp{none} which disables all SLS
32506 hardening. @samp{return} enables SLS hardening for function return.
32507 @samp{indirect-branch} enables SLS hardening for indirect branch.
32508 @samp{all} enables all SLS hardening.
32510 @item -mindirect-branch-cs-prefix
32511 @opindex mindirect-branch-cs-prefix
32512 Add CS prefix to call and jmp to indirect thunk with branch target in
32513 r8-r15 registers so that the call and jmp instruction length is 6 bytes
32514 to allow them to be replaced with @samp{lfence; call *%r8-r15} or
32515 @samp{lfence; jmp *%r8-r15} at run-time.
32519 These @samp{-m} switches are supported in addition to the above
32520 on x86-64 processors in 64-bit environments.
32533 Generate code for a 16-bit, 32-bit or 64-bit environment.
32534 The @option{-m32} option sets @code{int}, @code{long}, and pointer types
32536 generates code that runs on any i386 system.
32538 The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
32539 types to 64 bits, and generates code for the x86-64 architecture.
32540 For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
32541 and @option{-mdynamic-no-pic} options.
32543 The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
32545 generates code for the x86-64 architecture.
32547 The @option{-m16} option is the same as @option{-m32}, except for that
32548 it outputs the @code{.code16gcc} assembly directive at the beginning of
32549 the assembly output so that the binary can run in 16-bit mode.
32551 The @option{-miamcu} option generates code which conforms to Intel MCU
32552 psABI. It requires the @option{-m32} option to be turned on.
32554 @item -mno-red-zone
32555 @opindex mno-red-zone
32557 Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
32558 by the x86-64 ABI; it is a 128-byte area beyond the location of the
32559 stack pointer that is not modified by signal or interrupt handlers
32560 and therefore can be used for temporary data without adjusting the stack
32561 pointer. The flag @option{-mno-red-zone} disables this red zone.
32563 @item -mcmodel=small
32564 @opindex mcmodel=small
32565 Generate code for the small code model: the program and its symbols must
32566 be linked in the lower 2 GB of the address space. Pointers are 64 bits.
32567 Programs can be statically or dynamically linked. This is the default
32570 @item -mcmodel=kernel
32571 @opindex mcmodel=kernel
32572 Generate code for the kernel code model. The kernel runs in the
32573 negative 2 GB of the address space.
32574 This model has to be used for Linux kernel code.
32576 @item -mcmodel=medium
32577 @opindex mcmodel=medium
32578 Generate code for the medium model: the program is linked in the lower 2
32579 GB of the address space. Small symbols are also placed there. Symbols
32580 with sizes larger than @option{-mlarge-data-threshold} are put into
32581 large data or BSS sections and can be located above 2GB. Programs can
32582 be statically or dynamically linked.
32584 @item -mcmodel=large
32585 @opindex mcmodel=large
32586 Generate code for the large model. This model makes no assumptions
32587 about addresses and sizes of sections.
32589 @item -maddress-mode=long
32590 @opindex maddress-mode=long
32591 Generate code for long address mode. This is only supported for 64-bit
32592 and x32 environments. It is the default address mode for 64-bit
32595 @item -maddress-mode=short
32596 @opindex maddress-mode=short
32597 Generate code for short address mode. This is only supported for 32-bit
32598 and x32 environments. It is the default address mode for 32-bit and
32604 Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
32605 indicate the micro-architecture ISA level required to execute the binary.
32608 @node x86 Windows Options
32609 @subsection x86 Windows Options
32610 @cindex x86 Windows Options
32611 @cindex Windows Options for x86
32613 These additional options are available for Microsoft Windows targets:
32619 specifies that a console application is to be generated, by
32620 instructing the linker to set the PE header subsystem type
32621 required for console applications.
32622 This option is available for Cygwin and MinGW targets and is
32623 enabled by default on those targets.
32627 This option is available for Cygwin and MinGW targets. It
32628 specifies that a DLL---a dynamic link library---is to be
32629 generated, enabling the selection of the required runtime
32630 startup object and entry point.
32632 @item -mnop-fun-dllimport
32633 @opindex mnop-fun-dllimport
32634 This option is available for Cygwin and MinGW targets. It
32635 specifies that the @code{dllimport} attribute should be ignored.
32639 This option is available for MinGW targets. It specifies
32640 that MinGW-specific thread support is to be used.
32644 This option is available for MinGW-w64 targets. It causes
32645 the @code{UNICODE} preprocessor macro to be predefined, and
32646 chooses Unicode-capable runtime startup code.
32650 This option is available for Cygwin and MinGW targets. It
32651 specifies that the typical Microsoft Windows predefined macros are to
32652 be set in the pre-processor, but does not influence the choice
32653 of runtime library/startup code.
32657 This option is available for Cygwin and MinGW targets. It
32658 specifies that a GUI application is to be generated by
32659 instructing the linker to set the PE header subsystem type
32662 @item -fno-set-stack-executable
32663 @opindex fno-set-stack-executable
32664 @opindex fset-stack-executable
32665 This option is available for MinGW targets. It specifies that
32666 the executable flag for the stack used by nested functions isn't
32667 set. This is necessary for binaries running in kernel mode of
32668 Microsoft Windows, as there the User32 API, which is used to set executable
32669 privileges, isn't available.
32671 @item -fwritable-relocated-rdata
32672 @opindex fno-writable-relocated-rdata
32673 @opindex fwritable-relocated-rdata
32674 This option is available for MinGW and Cygwin targets. It specifies
32675 that relocated-data in read-only section is put into the @code{.data}
32676 section. This is a necessary for older runtimes not supporting
32677 modification of @code{.rdata} sections for pseudo-relocation.
32679 @item -mpe-aligned-commons
32680 @opindex mpe-aligned-commons
32681 This option is available for Cygwin and MinGW targets. It
32682 specifies that the GNU extension to the PE file format that
32683 permits the correct alignment of COMMON variables should be
32684 used when generating code. It is enabled by default if
32685 GCC detects that the target assembler found during configuration
32686 supports the feature.
32689 See also under @ref{x86 Options} for standard options.
32691 @node Xstormy16 Options
32692 @subsection Xstormy16 Options
32693 @cindex Xstormy16 Options
32695 These options are defined for Xstormy16:
32700 Choose startup files and linker script suitable for the simulator.
32703 @node Xtensa Options
32704 @subsection Xtensa Options
32705 @cindex Xtensa Options
32707 These options are supported for Xtensa targets:
32711 @itemx -mno-const16
32713 @opindex mno-const16
32714 Enable or disable use of @code{CONST16} instructions for loading
32715 constant values. The @code{CONST16} instruction is currently not a
32716 standard option from Tensilica. When enabled, @code{CONST16}
32717 instructions are always used in place of the standard @code{L32R}
32718 instructions. The use of @code{CONST16} is enabled by default only if
32719 the @code{L32R} instruction is not available.
32722 @itemx -mno-fused-madd
32723 @opindex mfused-madd
32724 @opindex mno-fused-madd
32725 Enable or disable use of fused multiply/add and multiply/subtract
32726 instructions in the floating-point option. This has no effect if the
32727 floating-point option is not also enabled. Disabling fused multiply/add
32728 and multiply/subtract instructions forces the compiler to use separate
32729 instructions for the multiply and add/subtract operations. This may be
32730 desirable in some cases where strict IEEE 754-compliant results are
32731 required: the fused multiply add/subtract instructions do not round the
32732 intermediate result, thereby producing results with @emph{more} bits of
32733 precision than specified by the IEEE standard. Disabling fused multiply
32734 add/subtract instructions also ensures that the program output is not
32735 sensitive to the compiler's ability to combine multiply and add/subtract
32738 @item -mserialize-volatile
32739 @itemx -mno-serialize-volatile
32740 @opindex mserialize-volatile
32741 @opindex mno-serialize-volatile
32742 When this option is enabled, GCC inserts @code{MEMW} instructions before
32743 @code{volatile} memory references to guarantee sequential consistency.
32744 The default is @option{-mserialize-volatile}. Use
32745 @option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
32747 @item -mforce-no-pic
32748 @opindex mforce-no-pic
32749 For targets, like GNU/Linux, where all user-mode Xtensa code must be
32750 position-independent code (PIC), this option disables PIC for compiling
32753 @item -mtext-section-literals
32754 @itemx -mno-text-section-literals
32755 @opindex mtext-section-literals
32756 @opindex mno-text-section-literals
32757 These options control the treatment of literal pools. The default is
32758 @option{-mno-text-section-literals}, which places literals in a separate
32759 section in the output file. This allows the literal pool to be placed
32760 in a data RAM/ROM, and it also allows the linker to combine literal
32761 pools from separate object files to remove redundant literals and
32762 improve code size. With @option{-mtext-section-literals}, the literals
32763 are interspersed in the text section in order to keep them as close as
32764 possible to their references. This may be necessary for large assembly
32765 files. Literals for each function are placed right before that function.
32767 @item -mauto-litpools
32768 @itemx -mno-auto-litpools
32769 @opindex mauto-litpools
32770 @opindex mno-auto-litpools
32771 These options control the treatment of literal pools. The default is
32772 @option{-mno-auto-litpools}, which places literals in a separate
32773 section in the output file unless @option{-mtext-section-literals} is
32774 used. With @option{-mauto-litpools} the literals are interspersed in
32775 the text section by the assembler. Compiler does not produce explicit
32776 @code{.literal} directives and loads literals into registers with
32777 @code{MOVI} instructions instead of @code{L32R} to let the assembler
32778 do relaxation and place literals as necessary. This option allows
32779 assembler to create several literal pools per function and assemble
32780 very big functions, which may not be possible with
32781 @option{-mtext-section-literals}.
32783 @item -mtarget-align
32784 @itemx -mno-target-align
32785 @opindex mtarget-align
32786 @opindex mno-target-align
32787 When this option is enabled, GCC instructs the assembler to
32788 automatically align instructions to reduce branch penalties at the
32789 expense of some code density. The assembler attempts to widen density
32790 instructions to align branch targets and the instructions following call
32791 instructions. If there are not enough preceding safe density
32792 instructions to align a target, no widening is performed. The
32793 default is @option{-mtarget-align}. These options do not affect the
32794 treatment of auto-aligned instructions like @code{LOOP}, which the
32795 assembler always aligns, either by widening density instructions or
32796 by inserting NOP instructions.
32799 @itemx -mno-longcalls
32800 @opindex mlongcalls
32801 @opindex mno-longcalls
32802 When this option is enabled, GCC instructs the assembler to translate
32803 direct calls to indirect calls unless it can determine that the target
32804 of a direct call is in the range allowed by the call instruction. This
32805 translation typically occurs for calls to functions in other source
32806 files. Specifically, the assembler translates a direct @code{CALL}
32807 instruction into an @code{L32R} followed by a @code{CALLX} instruction.
32808 The default is @option{-mno-longcalls}. This option should be used in
32809 programs where the call target can potentially be out of range. This
32810 option is implemented in the assembler, not the compiler, so the
32811 assembly code generated by GCC still shows direct call
32812 instructions---look at the disassembled object code to see the actual
32813 instructions. Note that the assembler uses an indirect call for
32814 every cross-file call, not just those that really are out of range.
32816 @item -mabi=@var{name}
32818 Generate code for the specified ABI@. Permissible values are: @samp{call0},
32819 @samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
32822 @opindex mabi=call0
32823 When this option is enabled function parameters are passed in registers
32824 @code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
32825 caller-saved, and register @code{a15} may be used as a frame pointer.
32826 When this version of the ABI is enabled the C preprocessor symbol
32827 @code{__XTENSA_CALL0_ABI__} is defined.
32829 @item -mabi=windowed
32830 @opindex mabi=windowed
32831 When this option is enabled function parameters are passed in registers
32832 @code{a10} through @code{a15}, and called function rotates register window
32833 by 8 registers on entry so that its arguments are found in registers
32834 @code{a2} through @code{a7}. Register @code{a7} may be used as a frame
32835 pointer. Register window is rotated 8 registers back upon return.
32836 When this version of the ABI is enabled the C preprocessor symbol
32837 @code{__XTENSA_WINDOWED_ABI__} is defined.
32840 @node zSeries Options
32841 @subsection zSeries Options
32842 @cindex zSeries options
32844 These are listed under @xref{S/390 and zSeries Options}.
32850 @section Specifying Subprocesses and the Switches to Pass to Them
32853 @command{gcc} is a driver program. It performs its job by invoking a
32854 sequence of other programs to do the work of compiling, assembling and
32855 linking. GCC interprets its command-line parameters and uses these to
32856 deduce which programs it should invoke, and which command-line options
32857 it ought to place on their command lines. This behavior is controlled
32858 by @dfn{spec strings}. In most cases there is one spec string for each
32859 program that GCC can invoke, but a few programs have multiple spec
32860 strings to control their behavior. The spec strings built into GCC can
32861 be overridden by using the @option{-specs=} command-line switch to specify
32864 @dfn{Spec files} are plain-text files that are used to construct spec
32865 strings. They consist of a sequence of directives separated by blank
32866 lines. The type of directive is determined by the first non-whitespace
32867 character on the line, which can be one of the following:
32870 @item %@var{command}
32871 Issues a @var{command} to the spec file processor. The commands that can
32875 @item %include <@var{file}>
32876 @cindex @code{%include}
32877 Search for @var{file} and insert its text at the current point in the
32880 @item %include_noerr <@var{file}>
32881 @cindex @code{%include_noerr}
32882 Just like @samp{%include}, but do not generate an error message if the include
32883 file cannot be found.
32885 @item %rename @var{old_name} @var{new_name}
32886 @cindex @code{%rename}
32887 Rename the spec string @var{old_name} to @var{new_name}.
32891 @item *[@var{spec_name}]:
32892 This tells the compiler to create, override or delete the named spec
32893 string. All lines after this directive up to the next directive or
32894 blank line are considered to be the text for the spec string. If this
32895 results in an empty string then the spec is deleted. (Or, if the
32896 spec did not exist, then nothing happens.) Otherwise, if the spec
32897 does not currently exist a new spec is created. If the spec does
32898 exist then its contents are overridden by the text of this
32899 directive, unless the first character of that text is the @samp{+}
32900 character, in which case the text is appended to the spec.
32902 @item [@var{suffix}]:
32903 Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
32904 and up to the next directive or blank line are considered to make up the
32905 spec string for the indicated suffix. When the compiler encounters an
32906 input file with the named suffix, it processes the spec string in
32907 order to work out how to compile that file. For example:
32911 z-compile -input %i
32914 This says that any input file whose name ends in @samp{.ZZ} should be
32915 passed to the program @samp{z-compile}, which should be invoked with the
32916 command-line switch @option{-input} and with the result of performing the
32917 @samp{%i} substitution. (See below.)
32919 As an alternative to providing a spec string, the text following a
32920 suffix directive can be one of the following:
32923 @item @@@var{language}
32924 This says that the suffix is an alias for a known @var{language}. This is
32925 similar to using the @option{-x} command-line switch to GCC to specify a
32926 language explicitly. For example:
32933 Says that .ZZ files are, in fact, C++ source files.
32936 This causes an error messages saying:
32939 @var{name} compiler not installed on this system.
32943 GCC already has an extensive list of suffixes built into it.
32944 This directive adds an entry to the end of the list of suffixes, but
32945 since the list is searched from the end backwards, it is effectively
32946 possible to override earlier entries using this technique.
32950 GCC has the following spec strings built into it. Spec files can
32951 override these strings or create their own. Note that individual
32952 targets can also add their own spec strings to this list.
32955 asm Options to pass to the assembler
32956 asm_final Options to pass to the assembler post-processor
32957 cpp Options to pass to the C preprocessor
32958 cc1 Options to pass to the C compiler
32959 cc1plus Options to pass to the C++ compiler
32960 endfile Object files to include at the end of the link
32961 link Options to pass to the linker
32962 lib Libraries to include on the command line to the linker
32963 libgcc Decides which GCC support library to pass to the linker
32964 linker Sets the name of the linker
32965 predefines Defines to be passed to the C preprocessor
32966 signed_char Defines to pass to CPP to say whether @code{char} is signed
32968 startfile Object files to include at the start of the link
32971 Here is a small example of a spec file:
32974 %rename lib old_lib
32977 --start-group -lgcc -lc -leval1 --end-group %(old_lib)
32980 This example renames the spec called @samp{lib} to @samp{old_lib} and
32981 then overrides the previous definition of @samp{lib} with a new one.
32982 The new definition adds in some extra command-line options before
32983 including the text of the old definition.
32985 @dfn{Spec strings} are a list of command-line options to be passed to their
32986 corresponding program. In addition, the spec strings can contain
32987 @samp{%}-prefixed sequences to substitute variable text or to
32988 conditionally insert text into the command line. Using these constructs
32989 it is possible to generate quite complex command lines.
32991 Here is a table of all defined @samp{%}-sequences for spec
32992 strings. Note that spaces are not generated automatically around the
32993 results of expanding these sequences. Therefore you can concatenate them
32994 together or combine them with constant text in a single argument.
32998 Substitute one @samp{%} into the program name or argument.
33001 Substitute an empty argument.
33004 Substitute the name of the input file being processed.
33007 Substitute the basename for outputs related with the input file being
33008 processed. This is often the substring up to (and not including) the
33009 last period and not including the directory but, unless %w is active, it
33010 expands to the basename for auxiliary outputs, which may be influenced
33011 by an explicit output name, and by various other options that control
33012 how auxiliary outputs are named.
33015 This is the same as @samp{%b}, but include the file suffix (text after
33016 the last period). Without %w, it expands to the basename for dump
33020 Marks the argument containing or following the @samp{%d} as a
33021 temporary file name, so that that file is deleted if GCC exits
33022 successfully. Unlike @samp{%g}, this contributes no text to the
33025 @item %g@var{suffix}
33026 Substitute a file name that has suffix @var{suffix} and is chosen
33027 once per compilation, and mark the argument in the same way as
33028 @samp{%d}. To reduce exposure to denial-of-service attacks, the file
33029 name is now chosen in a way that is hard to predict even when previously
33030 chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
33031 might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
33032 the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
33033 treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
33034 was simply substituted with a file name chosen once per compilation,
33035 without regard to any appended suffix (which was therefore treated
33036 just like ordinary text), making such attacks more likely to succeed.
33038 @item %u@var{suffix}
33039 Like @samp{%g}, but generates a new temporary file name
33040 each time it appears instead of once per compilation.
33042 @item %U@var{suffix}
33043 Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
33044 new one if there is no such last file name. In the absence of any
33045 @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
33046 the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
33047 involves the generation of two distinct file names, one
33048 for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
33049 simply substituted with a file name chosen for the previous @samp{%u},
33050 without regard to any appended suffix.
33052 @item %j@var{suffix}
33053 Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
33054 writable, and if @option{-save-temps} is not used;
33055 otherwise, substitute the name
33056 of a temporary file, just like @samp{%u}. This temporary file is not
33057 meant for communication between processes, but rather as a junk
33058 disposal mechanism.
33060 @item %|@var{suffix}
33061 @itemx %m@var{suffix}
33062 Like @samp{%g}, except if @option{-pipe} is in effect. In that case
33063 @samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
33064 all. These are the two most common ways to instruct a program that it
33065 should read from standard input or write to standard output. If you
33066 need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
33067 construct: see for example @file{gcc/fortran/lang-specs.h}.
33069 @item %.@var{SUFFIX}
33070 Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
33071 when it is subsequently output with @samp{%*}. @var{SUFFIX} is
33072 terminated by the next space or %.
33075 Marks the argument containing or following the @samp{%w} as the
33076 designated output file of this compilation. This puts the argument
33077 into the sequence of arguments that @samp{%o} substitutes.
33080 Indicates that this compilation produces no output file.
33083 Substitutes the names of all the output files, with spaces
33084 automatically placed around them. You should write spaces
33085 around the @samp{%o} as well or the results are undefined.
33086 @samp{%o} is for use in the specs for running the linker.
33087 Input files whose names have no recognized suffix are not compiled
33088 at all, but they are included among the output files, so they are
33092 Substitutes the suffix for object files. Note that this is
33093 handled specially when it immediately follows @samp{%g, %u, or %U},
33094 because of the need for those to form complete file names. The
33095 handling is such that @samp{%O} is treated exactly as if it had already
33096 been substituted, except that @samp{%g, %u, and %U} do not currently
33097 support additional @var{suffix} characters following @samp{%O} as they do
33098 following, for example, @samp{.o}.
33101 Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
33102 @option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
33103 @option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
33104 and @option{-imultilib} as necessary.
33107 Current argument is the name of a library or startup file of some sort.
33108 Search for that file in a standard list of directories and substitute
33109 the full name found. The current working directory is included in the
33110 list of directories scanned.
33113 Current argument is the name of a linker script. Search for that file
33114 in the current list of directories to scan for libraries. If the file
33115 is located insert a @option{--script} option into the command line
33116 followed by the full path name found. If the file is not found then
33117 generate an error message. Note: the current working directory is not
33121 Print @var{str} as an error message. @var{str} is terminated by a newline.
33122 Use this when inconsistent options are detected.
33125 Print @var{str} as a notice. @var{str} is terminated by a newline.
33127 @item %(@var{name})
33128 Substitute the contents of spec string @var{name} at this point.
33130 @item %x@{@var{option}@}
33131 Accumulate an option for @samp{%X}.
33134 Output the accumulated linker options specified by a @samp{%x} spec string.
33137 Output the accumulated assembler options specified by @option{-Wa}.
33140 Output the accumulated preprocessor options specified by @option{-Wp}.
33143 Output @code{multilib_os_dir}.
33146 Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
33149 Process the @code{asm} spec. This is used to compute the
33150 switches to be passed to the assembler.
33153 Process the @code{asm_final} spec. This is a spec string for
33154 passing switches to an assembler post-processor, if such a program is
33158 Process the @code{link} spec. This is the spec for computing the
33159 command line passed to the linker. Typically it makes use of the
33160 @samp{%L %G %S %D and %E} sequences.
33163 Dump out a @option{-L} option for each directory that GCC believes might
33164 contain startup files. If the target supports multilibs then the
33165 current multilib directory is prepended to each of these paths.
33168 Process the @code{lib} spec. This is a spec string for deciding which
33169 libraries are included on the command line to the linker.
33172 Process the @code{libgcc} spec. This is a spec string for deciding
33173 which GCC support library is included on the command line to the linker.
33176 Process the @code{startfile} spec. This is a spec for deciding which
33177 object files are the first ones passed to the linker. Typically
33178 this might be a file named @file{crt0.o}.
33181 Process the @code{endfile} spec. This is a spec string that specifies
33182 the last object files that are passed to the linker.
33185 Process the @code{cpp} spec. This is used to construct the arguments
33186 to be passed to the C preprocessor.
33189 Process the @code{cc1} spec. This is used to construct the options to be
33190 passed to the actual C compiler (@command{cc1}).
33193 Process the @code{cc1plus} spec. This is used to construct the options to be
33194 passed to the actual C++ compiler (@command{cc1plus}).
33197 Substitute the variable part of a matched option. See below.
33198 Note that each comma in the substituted string is replaced by
33202 Remove all occurrences of @code{-S} from the command line. Note---this
33203 command is position dependent. @samp{%} commands in the spec string
33204 before this one see @code{-S}, @samp{%} commands in the spec string
33205 after this one do not.
33208 Similar to @samp{%<S}, but match all switches beginning with @code{-S}.
33211 Similar to @samp{%<S}, but keep @code{-S} in the GCC command line.
33213 @item %:@var{function}(@var{args})
33214 Call the named function @var{function}, passing it @var{args}.
33215 @var{args} is first processed as a nested spec string, then split
33216 into an argument vector in the usual fashion. The function returns
33217 a string which is processed as if it had appeared literally as part
33218 of the current spec.
33220 The following built-in spec functions are provided:
33223 @item @code{getenv}
33224 The @code{getenv} spec function takes two arguments: an environment
33225 variable name and a string. If the environment variable is not
33226 defined, a fatal error is issued. Otherwise, the return value is the
33227 value of the environment variable concatenated with the string. For
33228 example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
33231 %:getenv(TOPDIR /include)
33234 expands to @file{/path/to/top/include}.
33236 @item @code{if-exists}
33237 The @code{if-exists} spec function takes one argument, an absolute
33238 pathname to a file. If the file exists, @code{if-exists} returns the
33239 pathname. Here is a small example of its usage:
33243 crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
33246 @item @code{if-exists-else}
33247 The @code{if-exists-else} spec function is similar to the @code{if-exists}
33248 spec function, except that it takes two arguments. The first argument is
33249 an absolute pathname to a file. If the file exists, @code{if-exists-else}
33250 returns the pathname. If it does not exist, it returns the second argument.
33251 This way, @code{if-exists-else} can be used to select one file or another,
33252 based on the existence of the first. Here is a small example of its usage:
33256 crt0%O%s %:if-exists(crti%O%s) \
33257 %:if-exists-else(crtbeginT%O%s crtbegin%O%s)
33260 @item @code{if-exists-then-else}
33261 The @code{if-exists-then-else} spec function takes at least two arguments
33262 and an optional third one. The first argument is an absolute pathname to a
33263 file. If the file exists, the function returns the second argument.
33264 If the file does not exist, the function returns the third argument if there
33265 is one, or NULL otherwise. This can be used to expand one text, or optionally
33266 another, based on the existence of a file. Here is a small example of its
33270 -l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
33273 @item @code{sanitize}
33274 The @code{sanitize} spec function takes no arguments. It returns non-NULL if
33275 any address, thread or undefined behavior sanitizers are active.
33278 %@{%:sanitize(address):-funwind-tables@}
33281 @item @code{replace-outfile}
33282 The @code{replace-outfile} spec function takes two arguments. It looks for the
33283 first argument in the outfiles array and replaces it with the second argument. Here
33284 is a small example of its usage:
33287 %@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
33290 @item @code{remove-outfile}
33291 The @code{remove-outfile} spec function takes one argument. It looks for the
33292 first argument in the outfiles array and removes it. Here is a small example
33296 %:remove-outfile(-lm)
33299 @item @code{version-compare}
33300 The @code{version-compare} spec function takes four or five arguments of the following
33304 <comparison-op> <arg1> [<arg2>] <switch> <result>
33307 It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
33308 The supported @code{comparison-op} values are:
33312 True if @code{switch} is a later (or same) version than @code{arg1}
33315 Opposite of @code{>=}
33318 True if @code{switch} is an earlier version than @code{arg1}
33321 Opposite of @code{<}
33324 True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
33327 True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
33330 If the @code{switch} is not present at all, the condition is false unless the first character
33331 of the @code{comparison-op} is @code{!}.
33334 %:version-compare(>= 10.3 mmacosx-version-min= -lmx)
33337 The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
33340 @item @code{include}
33341 The @code{include} spec function behaves much like @code{%include}, with the advantage
33342 that it can be nested inside a spec and thus be conditionalized. It takes one argument,
33343 the filename, and looks for it in the startfile path. It always returns NULL.
33346 %@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
33349 @item @code{pass-through-libs}
33350 The @code{pass-through-libs} spec function takes any number of arguments. It
33351 finds any @option{-l} options and any non-options ending in @file{.a} (which it
33352 assumes are the names of linker input library archive files) and returns a
33353 result containing all the found arguments each prepended by
33354 @option{-plugin-opt=-pass-through=} and joined by spaces. This list is
33355 intended to be passed to the LTO linker plugin.
33358 %:pass-through-libs(%G %L %G)
33361 @item @code{print-asm-header}
33362 The @code{print-asm-header} function takes no arguments and simply
33363 prints a banner like:
33369 Use "-Wa,OPTION" to pass "OPTION" to the assembler.
33372 It is used to separate compiler options from assembler options
33373 in the @option{--target-help} output.
33376 The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
33377 empty string) if the second-to-last argument is greater than the last argument, and NULL
33378 otherwise. The following example inserts the @code{link_gomp} spec if the last
33379 @option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
33382 %@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
33385 @item @code{debug-level-gt}
33386 The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
33387 empty string) if @code{debug_info_level} is greater than the specified number, and NULL
33391 %@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
33396 Substitutes the @code{-S} switch, if that switch is given to GCC@.
33397 If that switch is not specified, this substitutes nothing. Note that
33398 the leading dash is omitted when specifying this option, and it is
33399 automatically inserted if the substitution is performed. Thus the spec
33400 string @samp{%@{foo@}} matches the command-line option @option{-foo}
33401 and outputs the command-line option @option{-foo}.
33404 Like %@{@code{S}@} but mark last argument supplied within as a file to be
33405 deleted on failure.
33408 Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes
33409 @code{@@FILE} if an @code{@@file} argument has been supplied.
33412 Substitutes all the switches specified to GCC whose names start
33413 with @code{-S}, but which also take an argument. This is used for
33414 switches like @option{-o}, @option{-D}, @option{-I}, etc.
33415 GCC considers @option{-o foo} as being
33416 one switch whose name starts with @samp{o}. %@{o*@} substitutes this
33417 text, including the space. Thus two arguments are generated.
33420 Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
33421 (the order of @code{S} and @code{T} in the spec is not significant).
33422 There can be any number of ampersand-separated variables; for each the
33423 wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
33426 Substitutes @code{X}, if the @option{-S} switch is given to GCC@.
33429 Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@.
33432 Substitutes @code{X} if one or more switches whose names start with
33433 @code{-S} are specified to GCC@. Normally @code{X} is substituted only
33434 once, no matter how many such switches appeared. However, if @code{%*}
33435 appears somewhere in @code{X}, then @code{X} is substituted once
33436 for each matching switch, with the @code{%*} replaced by the part of
33437 that switch matching the @code{*}.
33439 If @code{%*} appears as the last part of a spec sequence then a space
33440 is added after the end of the last substitution. If there is more
33441 text in the sequence, however, then a space is not generated. This
33442 allows the @code{%*} substitution to be used as part of a larger
33443 string. For example, a spec string like this:
33446 %@{mcu=*:--script=%*/memory.ld@}
33450 when matching an option like @option{-mcu=newchip} produces:
33453 --script=newchip/memory.ld
33457 Substitutes @code{X}, if processing a file with suffix @code{S}.
33460 Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
33463 Substitutes @code{X}, if processing a file for language @code{S}.
33466 Substitutes @code{X}, if not processing a file for language @code{S}.
33469 Substitutes @code{X} if either @code{-S} or @code{-P} is given to
33470 GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
33471 @code{*} sequences as well, although they have a stronger binding than
33472 the @samp{|}. If @code{%*} appears in @code{X}, all of the
33473 alternatives must be starred, and only the first matching alternative
33476 For example, a spec string like this:
33479 %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
33483 outputs the following command-line options from the following input
33484 command-line options:
33489 -d fred.c -foo -baz -boggle
33490 -d jim.d -bar -baz -boggle
33493 @item %@{%:@var{function}(@var{args}):X@}
33495 Call function named @var{function} with args @var{args}. If the
33496 function returns non-NULL, then @code{X} is substituted, if it returns
33497 NULL, it isn't substituted.
33499 @item %@{S:X; T:Y; :D@}
33501 If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is
33502 given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
33503 be as many clauses as you need. This may be combined with @code{.},
33504 @code{,}, @code{!}, @code{|}, and @code{*} as needed.
33509 The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}}
33510 or similar construct can use a backslash to ignore the special meaning
33511 of the character following it, thus allowing literal matching of a
33512 character that is otherwise specially treated. For example,
33513 @samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the
33514 @option{-std=iso9899:1999} option is given.
33516 The conditional text @code{X} in a @samp{%@{S:X@}} or similar
33517 construct may contain other nested @samp{%} constructs or spaces, or
33518 even newlines. They are processed as usual, as described above.
33519 Trailing white space in @code{X} is ignored. White space may also
33520 appear anywhere on the left side of the colon in these constructs,
33521 except between @code{.} or @code{*} and the corresponding word.
33523 The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
33524 handled specifically in these constructs. If another value of
33525 @option{-O} or the negated form of a @option{-f}, @option{-m}, or
33526 @option{-W} switch is found later in the command line, the earlier
33527 switch value is ignored, except with @{@code{S}*@} where @code{S} is
33528 just one letter, which passes all matching options.
33530 The character @samp{|} at the beginning of the predicate text is used to
33531 indicate that a command should be piped to the following command, but
33532 only if @option{-pipe} is specified.
33534 It is built into GCC which switches take arguments and which do not.
33535 (You might think it would be useful to generalize this to allow each
33536 compiler's spec to say which switches take arguments. But this cannot
33537 be done in a consistent fashion. GCC cannot even decide which input
33538 files have been specified without knowing which switches take arguments,
33539 and it must know which input files to compile in order to tell which
33542 GCC also knows implicitly that arguments starting in @option{-l} are to be
33543 treated as compiler output files, and passed to the linker in their
33544 proper position among the other output files.
33546 @node Environment Variables
33547 @section Environment Variables Affecting GCC
33548 @cindex environment variables
33550 @c man begin ENVIRONMENT
33551 This section describes several environment variables that affect how GCC
33552 operates. Some of them work by specifying directories or prefixes to use
33553 when searching for various kinds of files. Some are used to specify other
33554 aspects of the compilation environment.
33556 Note that you can also specify places to search using options such as
33557 @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
33558 take precedence over places specified using environment variables, which
33559 in turn take precedence over those specified by the configuration of GCC@.
33560 @xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
33561 GNU Compiler Collection (GCC) Internals}.
33566 @c @itemx LC_COLLATE
33568 @c @itemx LC_MONETARY
33569 @c @itemx LC_NUMERIC
33574 @c @findex LC_COLLATE
33575 @findex LC_MESSAGES
33576 @c @findex LC_MONETARY
33577 @c @findex LC_NUMERIC
33581 These environment variables control the way that GCC uses
33582 localization information which allows GCC to work with different
33583 national conventions. GCC inspects the locale categories
33584 @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
33585 so. These locale categories can be set to any value supported by your
33586 installation. A typical value is @samp{en_GB.UTF-8} for English in the United
33587 Kingdom encoded in UTF-8.
33589 The @env{LC_CTYPE} environment variable specifies character
33590 classification. GCC uses it to determine the character boundaries in
33591 a string; this is needed for some multibyte encodings that contain quote
33592 and escape characters that are otherwise interpreted as a string
33595 The @env{LC_MESSAGES} environment variable specifies the language to
33596 use in diagnostic messages.
33598 If the @env{LC_ALL} environment variable is set, it overrides the value
33599 of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
33600 and @env{LC_MESSAGES} default to the value of the @env{LANG}
33601 environment variable. If none of these variables are set, GCC
33602 defaults to traditional C English behavior.
33606 If @env{TMPDIR} is set, it specifies the directory to use for temporary
33607 files. GCC uses temporary files to hold the output of one stage of
33608 compilation which is to be used as input to the next stage: for example,
33609 the output of the preprocessor, which is the input to the compiler
33612 @item GCC_COMPARE_DEBUG
33613 @findex GCC_COMPARE_DEBUG
33614 Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
33615 @option{-fcompare-debug} to the compiler driver. See the documentation
33616 of this option for more details.
33618 @item GCC_EXEC_PREFIX
33619 @findex GCC_EXEC_PREFIX
33620 If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
33621 names of the subprograms executed by the compiler. No slash is added
33622 when this prefix is combined with the name of a subprogram, but you can
33623 specify a prefix that ends with a slash if you wish.
33625 If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
33626 an appropriate prefix to use based on the pathname it is invoked with.
33628 If GCC cannot find the subprogram using the specified prefix, it
33629 tries looking in the usual places for the subprogram.
33631 The default value of @env{GCC_EXEC_PREFIX} is
33632 @file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
33633 the installed compiler. In many cases @var{prefix} is the value
33634 of @code{prefix} when you ran the @file{configure} script.
33636 Other prefixes specified with @option{-B} take precedence over this prefix.
33638 This prefix is also used for finding files such as @file{crt0.o} that are
33641 In addition, the prefix is used in an unusual way in finding the
33642 directories to search for header files. For each of the standard
33643 directories whose name normally begins with @samp{/usr/local/lib/gcc}
33644 (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
33645 replacing that beginning with the specified prefix to produce an
33646 alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
33647 @file{foo/bar} just before it searches the standard directory
33648 @file{/usr/local/lib/bar}.
33649 If a standard directory begins with the configured
33650 @var{prefix} then the value of @var{prefix} is replaced by
33651 @env{GCC_EXEC_PREFIX} when looking for header files.
33653 @item COMPILER_PATH
33654 @findex COMPILER_PATH
33655 The value of @env{COMPILER_PATH} is a colon-separated list of
33656 directories, much like @env{PATH}. GCC tries the directories thus
33657 specified when searching for subprograms, if it cannot find the
33658 subprograms using @env{GCC_EXEC_PREFIX}.
33661 @findex LIBRARY_PATH
33662 The value of @env{LIBRARY_PATH} is a colon-separated list of
33663 directories, much like @env{PATH}. When configured as a native compiler,
33664 GCC tries the directories thus specified when searching for special
33665 linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
33666 using GCC also uses these directories when searching for ordinary
33667 libraries for the @option{-l} option (but directories specified with
33668 @option{-L} come first).
33672 @cindex locale definition
33673 This variable is used to pass locale information to the compiler. One way in
33674 which this information is used is to determine the character set to be used
33675 when character literals, string literals and comments are parsed in C and C++.
33676 When the compiler is configured to allow multibyte characters,
33677 the following values for @env{LANG} are recognized:
33681 Recognize JIS characters.
33683 Recognize SJIS characters.
33685 Recognize EUCJP characters.
33688 If @env{LANG} is not defined, or if it has some other value, then the
33689 compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
33690 recognize and translate multibyte characters.
33692 @item GCC_EXTRA_DIAGNOSTIC_OUTPUT
33693 @findex GCC_EXTRA_DIAGNOSTIC_OUTPUT
33694 If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
33695 then additional text will be emitted to stderr when fix-it hints are
33696 emitted. @option{-fdiagnostics-parseable-fixits} and
33697 @option{-fno-diagnostics-parseable-fixits} take precedence over this
33698 environment variable.
33702 Emit parseable fix-it hints, equivalent to
33703 @option{-fdiagnostics-parseable-fixits}. In particular, columns are
33704 expressed as a count of bytes, starting at byte 1 for the initial column.
33707 As @code{fixits-v1}, but columns are expressed as display columns,
33708 as per @option{-fdiagnostics-column-unit=display}.
33714 Some additional environment variables affect the behavior of the
33717 @include cppenv.texi
33721 @node Precompiled Headers
33722 @section Using Precompiled Headers
33723 @cindex precompiled headers
33724 @cindex speed of compilation
33726 Often large projects have many header files that are included in every
33727 source file. The time the compiler takes to process these header files
33728 over and over again can account for nearly all of the time required to
33729 build the project. To make builds faster, GCC allows you to
33730 @dfn{precompile} a header file.
33732 To create a precompiled header file, simply compile it as you would any
33733 other file, if necessary using the @option{-x} option to make the driver
33734 treat it as a C or C++ header file. You may want to use a
33735 tool like @command{make} to keep the precompiled header up-to-date when
33736 the headers it contains change.
33738 A precompiled header file is searched for when @code{#include} is
33739 seen in the compilation. As it searches for the included file
33740 (@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
33741 compiler looks for a precompiled header in each directory just before it
33742 looks for the include file in that directory. The name searched for is
33743 the name specified in the @code{#include} with @samp{.gch} appended. If
33744 the precompiled header file cannot be used, it is ignored.
33746 For instance, if you have @code{#include "all.h"}, and you have
33747 @file{all.h.gch} in the same directory as @file{all.h}, then the
33748 precompiled header file is used if possible, and the original
33749 header is used otherwise.
33751 Alternatively, you might decide to put the precompiled header file in a
33752 directory and use @option{-I} to ensure that directory is searched
33753 before (or instead of) the directory containing the original header.
33754 Then, if you want to check that the precompiled header file is always
33755 used, you can put a file of the same name as the original header in this
33756 directory containing an @code{#error} command.
33758 This also works with @option{-include}. So yet another way to use
33759 precompiled headers, good for projects not designed with precompiled
33760 header files in mind, is to simply take most of the header files used by
33761 a project, include them from another header file, precompile that header
33762 file, and @option{-include} the precompiled header. If the header files
33763 have guards against multiple inclusion, they are skipped because
33764 they've already been included (in the precompiled header).
33766 If you need to precompile the same header file for different
33767 languages, targets, or compiler options, you can instead make a
33768 @emph{directory} named like @file{all.h.gch}, and put each precompiled
33769 header in the directory, perhaps using @option{-o}. It doesn't matter
33770 what you call the files in the directory; every precompiled header in
33771 the directory is considered. The first precompiled header
33772 encountered in the directory that is valid for this compilation is
33773 used; they're searched in no particular order.
33775 There are many other possibilities, limited only by your imagination,
33776 good sense, and the constraints of your build system.
33778 A precompiled header file can be used only when these conditions apply:
33782 Only one precompiled header can be used in a particular compilation.
33785 A precompiled header cannot be used once the first C token is seen. You
33786 can have preprocessor directives before a precompiled header; you cannot
33787 include a precompiled header from inside another header.
33790 The precompiled header file must be produced for the same language as
33791 the current compilation. You cannot use a C precompiled header for a C++
33795 The precompiled header file must have been produced by the same compiler
33796 binary as the current compilation is using.
33799 Any macros defined before the precompiled header is included must
33800 either be defined in the same way as when the precompiled header was
33801 generated, or must not affect the precompiled header, which usually
33802 means that they don't appear in the precompiled header at all.
33804 The @option{-D} option is one way to define a macro before a
33805 precompiled header is included; using a @code{#define} can also do it.
33806 There are also some options that define macros implicitly, like
33807 @option{-O} and @option{-Wdeprecated}; the same rule applies to macros
33810 @item If debugging information is output when using the precompiled
33811 header, using @option{-g} or similar, the same kind of debugging information
33812 must have been output when building the precompiled header. However,
33813 a precompiled header built using @option{-g} can be used in a compilation
33814 when no debugging information is being output.
33816 @item The same @option{-m} options must generally be used when building
33817 and using the precompiled header. @xref{Submodel Options},
33818 for any cases where this rule is relaxed.
33820 @item Each of the following options must be the same when building and using
33821 the precompiled header:
33823 @gccoptlist{-fexceptions}
33826 Some other command-line options starting with @option{-f},
33827 @option{-p}, or @option{-O} must be defined in the same way as when
33828 the precompiled header was generated. At present, it's not clear
33829 which options are safe to change and which are not; the safest choice
33830 is to use exactly the same options when generating and using the
33831 precompiled header. The following are known to be safe:
33833 @gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock @gol
33834 -fsched-spec -fsched-spec-load -fsched-spec-load-dangerous @gol
33835 -fsched-verbose=@var{number} -fschedule-insns -fvisibility= @gol
33838 @item Address space layout randomization (ASLR) can lead to not binary identical
33839 PCH files. If you rely on stable PCH file contents disable ASLR when generating
33844 For all of these except the last, the compiler automatically
33845 ignores the precompiled header if the conditions aren't met. If you
33846 find an option combination that doesn't work and doesn't cause the
33847 precompiled header to be ignored, please consider filing a bug report,
33850 If you do use differing options when generating and using the
33851 precompiled header, the actual behavior is a mixture of the
33852 behavior for the options. For instance, if you use @option{-g} to
33853 generate the precompiled header but not when using it, you may or may
33854 not get debugging information for routines in the precompiled header.
33857 @section C++ Modules
33858 @cindex speed of compilation
33860 Modules are a C++20 language feature. As the name suggests, they
33861 provides a modular compilation system, intending to provide both
33862 faster builds and better library isolation. The ``Merging Modules''
33863 paper @uref{https://wg21.link/p1103}, provides the easiest to read set
33864 of changes to the standard, although it does not capture later
33865 changes. That specification is now part of C++20,
33866 @uref{git@@github.com:cplusplus/draft.git}, it is considered complete
33867 (there may be defect reports to come).
33869 @emph{G++'s modules support is not complete.} Other than bugs, the
33870 known missing pieces are:
33874 @item Private Module Fragment
33875 The Private Module Fragment is recognized, but an error is emitted.
33877 @item Partition definition visibility rules
33878 Entities may be defined in implementation partitions, and those
33879 definitions are not available outside of the module. This is not
33880 implemented, and the definitions are available to extra-module use.
33882 @item Textual merging of reachable GM entities
33883 Entities may be multiply defined across different header-units.
33884 These must be de-duplicated, and this is implemented across imports,
33885 or when an import redefines a textually-defined entity. However the
33886 reverse is not implemented---textually redefining an entity that has
33887 been defined in an imported header-unit. A redefinition error is
33890 @item Translation-Unit local referencing rules
33891 Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
33892 (@uref{https://wg21.link/p2003}) add limitations on which entities an
33893 exported region may reference (for instance, the entities an exported
33894 template definition may reference). These are not fully implemented.
33896 @item Language-linkage module attachment
33897 Declarations with explicit language linkage (@code{extern "C"} or
33898 @code{extern "C++"}) are attached to the global module, even when in
33899 the purview of a named module. This is not implemented. Such
33900 declarations will be attached to the module, if any, in which they are
33903 @item Standard Library Header Units
33904 The Standard Library is not provided as importable header units. If
33905 you want to import such units, you must explicitly build them first.
33906 If you do not do this with care, you may have multiple declarations,
33907 which the module machinery must merge---compiler resource usage can be
33908 affected by how you partition header files into header units.
33912 Modular compilation is @emph{not} enabled with just the
33913 @option{-std=c++20} option. You must explicitly enable it with the
33914 @option{-fmodules-ts} option. It is independent of the language
33915 version selected, although in pre-C++20 versions, it is of course an
33918 No new source file suffixes are required or supported. If you wish to
33919 use a non-standard suffix (@pxref{Overall Options}), you also need
33920 to provide a @option{-x c++} option too.@footnote{Some users like to
33921 distinguish module interface files with a new suffix, such as naming
33922 the source @code{module.cppm}, which involves
33923 teaching all tools about the new suffix. A different scheme, such as
33924 naming @code{module-m.cpp} would be less invasive.}
33926 Compiling a module interface unit produces an additional output (to
33927 the assembly or object file), called a Compiled Module Interface
33928 (CMI). This encodes the exported declarations of the module.
33929 Importing a module reads in the CMI. The import graph is a Directed
33930 Acyclic Graph (DAG). You must build imports before the importer.
33932 Header files may themselves be compiled to header units, which are a
33933 transitional ability aiming at faster compilation. The
33934 @option{-fmodule-header} option is used to enable this, and implies
33935 the @option{-fmodules-ts} option. These CMIs are named by the fully
33936 resolved underlying header file, and thus may be a complete pathname
33937 containing subdirectories. If the header file is found at an absolute
33938 pathname, the CMI location is still relative to a CMI root directory.
33940 As header files often have no suffix, you commonly have to specify a
33941 @option{-x} option to tell the compiler the source is a header file.
33942 You may use @option{-x c++-header}, @option{-x c++-user-header} or
33943 @option{-x c++-system-header}. When used in conjunction with
33944 @option{-fmodules-ts}, these all imply an appropriate
33945 @option{-fmodule-header} option. The latter two variants use the
33946 user or system include path to search for the file specified. This
33947 allows you to, for instance, compile standard library header files as
33948 header units, without needing to know exactly where they are
33949 installed. Specifying the language as one of these variants also
33950 inhibits output of the object file, as header files have no associated
33953 The @option{-fmodule-only} option disables generation of the
33954 associated object file for compiling a module interface. Only the CMI
33955 is generated. This option is implied when using the
33956 @option{-fmodule-header} option.
33958 The @option{-flang-info-include-translate} and
33959 @option{-flang-info-include-translate-not} options notes whether
33960 include translation occurs or not. With no argument, the first will
33961 note all include translation. The second will note all
33962 non-translations of include files not known to intentionally be
33963 textual. With an argument, queries about include translation of a
33964 header files with that particular trailing pathname are noted. You
33965 may repeat this form to cover several different header files. This
33966 option may be helpful in determining whether include translation is
33967 happening---if it is working correctly, it behaves as if it isn't
33970 The @option{-flang-info-module-cmi} option can be used to determine
33971 where the compiler is reading a CMI from. Without the option, the
33972 compiler is silent when such a read is successful. This option has an
33973 optional argument, which will restrict the notification to just the
33974 set of named modules or header units specified.
33976 The @option{-Winvalid-imported-macros} option causes all imported macros
33977 to be resolved at the end of compilation. Without this, imported
33978 macros are only resolved when expanded or (re)defined. This option
33979 detects conflicting import definitions for all macros.
33981 For details of the @option{-fmodule-mapper} family of options,
33982 @pxref{C++ Module Mapper}.
33985 * C++ Module Mapper:: Module Mapper
33986 * C++ Module Preprocessing:: Module Preprocessing
33987 * C++ Compiled Module Interface:: Compiled Module Interface
33990 @node C++ Module Mapper
33991 @subsection Module Mapper
33992 @cindex C++ Module Mapper
33994 A module mapper provides a server or file that the compiler queries to
33995 determine the mapping between module names and CMI files. It is also
33996 used to build CMIs on demand. @emph{Mapper functionality is in its
33997 infancy and is intended for experimentation with build system
34000 You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
34001 option or @env{CXX_MODULE_MAPPER} environment variable. The value may
34002 have one of the following forms:
34006 @item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
34007 An optional hostname and a numeric port number to connect to. If the
34008 hostname is omitted, the loopback address is used. If the hostname
34009 corresponds to multiple IPV6 addresses, these are tried in turn, until
34010 one is successful. If your host lacks IPv6, this form is
34011 non-functional. If you must use IPv4 use
34012 @option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
34014 @item =@var{socket}@r{[}?@var{ident}@r{]}
34015 A local domain socket. If your host lacks local domain sockets, this
34016 form is non-functional.
34018 @item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
34019 A program to spawn, and communicate with on its stdin/stdout streams.
34020 Your @var{PATH} environment variable is searched for the program.
34021 Arguments are separated by space characters, (it is not possible for
34022 one of the arguments delivered to the program to contain a space). An
34023 exception is if @var{program} begins with @@. In that case
34024 @var{program} (sans @@) is looked for in the compiler's internal
34025 binary directory. Thus the sample mapper-server can be specified
34026 with @code{@@g++-mapper-server}.
34028 @item <>@r{[}?@var{ident}@r{]}
34029 @item <>@var{inout}@r{[}?@var{ident}@r{]}
34030 @item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
34031 Named pipes or file descriptors to communicate over. The first form,
34032 @option{<>}, communicates over stdin and stdout. The other forms
34033 allow you to specify a file descriptor or name a pipe. A numeric value
34034 is interpreted as a file descriptor, otherwise named pipe is opened.
34035 The second form specifies a bidirectional pipe and the last form
34036 allows specifying two independent pipes. Using file descriptors
34037 directly in this manner is fragile in general, as it can require the
34038 cooperation of intermediate processes. In particular using stdin &
34039 stdout is fraught with danger as other compiler options might also
34040 cause the compiler to read stdin or write stdout, and it can have
34041 unfortunate interactions with signal delivery from the terminal.
34043 @item @var{file}@r{[}?@var{ident}@r{]}
34044 A mapping file consisting of space-separated module-name, filename
34045 pairs, one per line. Only the mappings for the direct imports and any
34046 module export name need be provided. If other mappings are provided,
34047 they override those stored in any imported CMI files. A repository
34048 root may be specified in the mapping file by using @samp{$root} as the
34049 module name in the first active line. Use of this option will disable
34050 any default module->CMI name mapping.
34054 As shown, an optional @var{ident} may suffix the first word of the
34055 option, indicated by a @samp{?} prefix. The value is used in the
34056 initial handshake with the module server, or to specify a prefix on
34057 mapping file lines. In the server case, the main source file name is
34058 used if no @var{ident} is specified. In the file case, all non-blank
34059 lines are significant, unless a value is specified, in which case only
34060 lines beginning with @var{ident} are significant. The @var{ident}
34061 must be separated by whitespace from the module name. Be aware that
34062 @samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
34063 significant to the shell, and therefore may need quoting.
34065 The mapper is connected to or loaded lazily, when the first module
34066 mapping is required. The networking protocols are only supported on
34067 hosts that provide networking. If no mapper is specified a default is
34070 A project-specific mapper is expected to be provided by the build
34071 system that invokes the compiler. It is not expected that a
34072 general-purpose server is provided for all compilations. As such, the
34073 server will know the build configuration, the compiler it invoked, and
34074 the environment (such as working directory) in which that is
34075 operating. As it may parallelize builds, several compilations may
34076 connect to the same socket.
34078 The default mapper generates CMI files in a @samp{gcm.cache}
34079 directory. CMI files have a @samp{.gcm} suffix. The module unit name
34080 is used directly to provide the basename. Header units construct a
34081 relative path using the underlying header file name. If the path is
34082 already relative, a @samp{,} directory is prepended. Internal
34083 @samp{..} components are translated to @samp{,,}. No attempt is made
34084 to canonicalize these filenames beyond that done by the preprocessor's
34085 include search algorithm, as in general it is ambiguous when symbolic
34088 The mapper protocol was published as ``A Module Mapper''
34089 @uref{https://wg21.link/p1184}. The implementation is provided by
34090 @command{libcody}, @uref{https://github.com/urnathan/libcody},
34091 which specifies the canonical protocol definition. A proof of concept
34092 server implementation embedded in @command{make} was described in
34093 ''Make Me A Module'', @uref{https://wg21.link/p1602}.
34095 @node C++ Module Preprocessing
34096 @subsection Module Preprocessing
34097 @cindex C++ Module Preprocessing
34099 Modules affect preprocessing because of header units and include
34100 translation. Some uses of the preprocessor as a separate step either
34101 do not produce a correct output, or require CMIs to be available.
34103 Header units import macros. These macros can affect later conditional
34104 inclusion, which therefore can cascade to differing import sets. When
34105 preprocessing, it is necessary to load the CMI. If a header unit is
34106 unavailable, the preprocessor issues a warning and continue (when
34107 not just preprocessing, an error is emitted). Detecting such imports
34108 requires preprocessor tokenization of the input stream to phase 4
34111 Include translation converts @code{#include}, @code{#include_next} and
34112 @code{#import} directives to internal @code{import} declarations.
34113 Whether a particular directive is translated is controlled by the
34114 module mapper. Header unit names are canonicalized during
34117 Dependency information can be emitted for macro import, extending the
34118 functionality of @option{-MD} and @option{-MMD} options. Detection of
34119 import declarations also requires phase 4 preprocessing, and thus
34120 requires full preprocessing (or compilation).
34122 The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt
34123 preprocessing before phase 4.
34125 The @option{-save-temps} option uses @option{-fdirectives-only} for
34126 preprocessing, and preserve the macro definitions in the preprocessed
34127 output. Usually you also want to use this option when explicitly
34128 preprocessing a header-unit, or consuming such preprocessed output:
34131 g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii
34132 g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii
34135 @node C++ Compiled Module Interface
34136 @subsection Compiled Module Interface
34137 @cindex C++ Compiled Module Interface
34139 CMIs are an additional artifact when compiling named module
34140 interfaces, partitions or header units. These are read when
34141 importing. CMI contents are implementation-specific, and in GCC's
34142 case tied to the compiler version. Consider them a rebuildable cache
34143 artifact, not a distributable object.
34145 When creating an output CMI, any missing directory components are
34146 created in a manner that is safe for concurrent builds creating
34147 multiple, different, CMIs within a common subdirectory tree.
34149 CMI contents are written to a temporary file, which is then atomically
34150 renamed. Observers either see old contents (if there is an
34151 existing file), or complete new contents. They do not observe the
34152 CMI during its creation. This is unlike object file writing, which
34153 may be observed by an external process.
34155 CMIs are read in lazily, if the host OS provides @code{mmap}
34156 functionality. Generally blocks are read when name lookup or template
34157 instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
34158 option may be used.
34160 The @option{--param lazy-modules=@var{n}} parameter controls the limit
34161 on the number of concurrently open module files during lazy loading.
34162 Should more modules be imported, an LRU algorithm is used to determine
34163 which files to close---until that file is needed again. This limit
34164 may be exceeded with deep module dependency hierarchies. With large
34165 code bases there may be more imports than the process limit of file
34166 descriptors. By default, the limit is a few less than the per-process
34167 file descriptor hard limit, if that is determinable.@footnote{Where
34168 applicable the soft limit is incremented as needed towards the hard limit.}
34170 GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
34171 You may use @command{readelf} to inspect them, although section
34172 contents are largely undecipherable. There is a section named
34173 @code{.gnu.c++.README}, which contains human-readable text. Other
34174 than the first line, each line consists of @code{@var{tag}: @code{value}}
34178 > @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
34180 String dump of section '.gnu.c++.README':
34181 [ 0] GNU C++ primary module interface
34182 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
34183 [ 6f] version: 2020/11/16-04:54
34185 [ 95] source: c_b.ii
34186 [ a4] dialect: C++20/coroutines
34187 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
34188 [ ee] repository: gcm.cache
34189 [ 104] buildtime: 2020/11/16 15:03:21 UTC
34190 [ 127] localtime: 2020/11/16 07:03:21 PST
34191 [ 14a] export: foo:part1 foo-part1.gcm
34194 Amongst other things, this lists the source that was built, C++
34195 dialect used and imports of the module.@footnote{The precise contents
34196 of this output may change.} The timestamp is the same value as that
34197 provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
34198 explicitly specified with the environment variable
34199 @code{SOURCE_DATE_EPOCH}. For further details
34200 @pxref{Environment Variables}.
34202 A set of related CMIs may be copied, provided the relative pathnames
34205 The @code{.gnu.c++.README} contents do not affect CMI integrity, and
34206 it may be removed or altered. The section numbering of the sections
34207 whose names do not begin with @code{.gnu.c++.}, or are not the string
34208 section is significant and must not be altered.